diff --git a/ios/RetroArch/RetroArch_iOS.h b/ios/RetroArch/RetroArch_iOS.h index ced57264bf..a185024c3d 100644 --- a/ios/RetroArch/RetroArch_iOS.h +++ b/ios/RetroArch/RetroArch_iOS.h @@ -7,8 +7,8 @@ #import -extern NSString *const GSEventKeyDownNotification; -extern NSString *const GSEventKeyUpNotification; +extern NSString* const GSEventKeyDownNotification; +extern NSString* const GSEventKeyUpNotification; @interface RetroArch_iOS : UIResponder @@ -16,12 +16,13 @@ extern NSString *const GSEventKeyUpNotification; - (void)runGame:(NSString*)path; - (void)gameHasExited; +- (void)pushViewController:(UIViewController*)theView; +- (void)popViewController; + @property (strong, nonatomic) NSString* system_directory; @property (strong, nonatomic) NSString* config_file_path; -@property (strong, nonatomic) UIWindow *window; -@property (strong, nonatomic) NSString *module_path; -@property (strong, nonatomic) UINavigationController *navigator; +@property (strong, nonatomic) NSString* module_path; @property (strong, nonatomic) UIImage* file_icon; @property (strong, nonatomic) UIImage* folder_icon; @property (strong, nonatomic) UIBarButtonItem* settings_button; diff --git a/ios/RetroArch/RetroArch_iOS.m b/ios/RetroArch/RetroArch_iOS.m index cdbd5b2159..d591ce0f82 100644 --- a/ios/RetroArch/RetroArch_iOS.m +++ b/ios/RetroArch/RetroArch_iOS.m @@ -23,6 +23,9 @@ extern uint32_t ios_current_touch_count; @implementation RetroArch_iOS { game_view* game; + + UIWindow* window; + UINavigationController* navigator; } + (RetroArch_iOS*)get @@ -33,18 +36,34 @@ extern uint32_t ios_current_touch_count; - (void)runGame:(NSString*)path { game = [[game_view alloc] initWithGame:path]; - self.window.rootViewController = game; - self.navigator = nil; + window.rootViewController = game; + navigator = nil; } - (void)gameHasExited { game = nil; - self.navigator = [[UINavigationController alloc] init]; - [self.navigator pushViewController: [[module_list alloc] init] animated:YES]; + navigator = [[UINavigationController alloc] init]; + [navigator pushViewController: [[module_list alloc] init] animated:YES]; - self.window.rootViewController = self.navigator; + window.rootViewController = navigator; +} + +- (void)pushViewController:(UIViewController*)theView +{ + if (navigator != nil) + { + [navigator pushViewController:theView animated:YES]; + } +} + +- (void)popViewController +{ + if (navigator != nil) + { + [navigator popViewControllerAnimated:YES]; + } } - (void)applicationDidFinishLaunching:(UIApplication *)application @@ -68,12 +87,12 @@ extern uint32_t ios_current_touch_count; self.settings_button.action = @selector(show_settings); // Setup window - self.navigator = [[UINavigationController alloc] init]; - [self.navigator pushViewController: [[module_list alloc] init] animated:YES]; + navigator = [[UINavigationController alloc] init]; + [navigator pushViewController: [[module_list alloc] init] animated:YES]; - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.window.rootViewController = self.navigator; - [self.window makeKeyAndVisible]; + window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + window.rootViewController = navigator; + [window makeKeyAndVisible]; // Setup keyboard hack [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: GSEventKeyDownNotification object: nil]; @@ -110,7 +129,7 @@ extern uint32_t ios_current_touch_count; - (void)show_settings { - [self.navigator pushViewController: [[SettingsList alloc] init] animated:YES]; + [self pushViewController:[SettingsList new]]; } - (void)processTouches:(NSArray*)touches diff --git a/ios/RetroArch/directory_list.m b/ios/RetroArch/directory_list.m index f1243428ed..be92a5f04d 100644 --- a/ios/RetroArch/directory_list.m +++ b/ios/RetroArch/directory_list.m @@ -57,9 +57,7 @@ static BOOL is_directory(NSString* path) if(is_directory(path)) { - [[RetroArch_iOS get].navigator - pushViewController:[[directory_list alloc] initWithPath:path] - animated:YES]; + [[RetroArch_iOS get] pushViewController:[[directory_list alloc] initWithPath:path]]; } else { diff --git a/ios/RetroArch/module_list.m b/ios/RetroArch/module_list.m index 758ea06222..3a9a27461c 100644 --- a/ios/RetroArch/module_list.m +++ b/ios/RetroArch/module_list.m @@ -52,7 +52,7 @@ static void display_error_alert(NSString* message) - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [RetroArch_iOS get].module_path = [modules objectAtIndex:indexPath.row]; - [[RetroArch_iOS get].navigator pushViewController:[[directory_list alloc] initWithPath:nil] animated:YES]; + [[RetroArch_iOS get] pushViewController:[[directory_list alloc] initWithPath:nil]]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section diff --git a/ios/RetroArch/settings/enumeration_list.m b/ios/RetroArch/settings/enumeration_list.m index 61823d1fc9..9f368f09db 100644 --- a/ios/RetroArch/settings/enumeration_list.m +++ b/ios/RetroArch/settings/enumeration_list.m @@ -55,7 +55,7 @@ value.value = @""; [view reloadData]; - [[RetroArch_iOS get].navigator popViewControllerAnimated:YES]; + [[RetroArch_iOS get] popViewController]; } @end diff --git a/ios/RetroArch/settings/settings_sublist.m b/ios/RetroArch/settings/settings_sublist.m index b2f836bc90..3c3d2b9aa5 100644 --- a/ios/RetroArch/settings/settings_sublist.m +++ b/ios/RetroArch/settings/settings_sublist.m @@ -66,9 +66,7 @@ static const char* const SETTINGID = "SETTING"; { case EnumerationSetting: case FileListSetting: - [[RetroArch_iOS get].navigator - pushViewController:[[SettingEnumerationList alloc] initWithSetting:setting fromTable:(UITableView*)self.view] - animated:YES]; + [[RetroArch_iOS get] pushViewController:[[SettingEnumerationList alloc] initWithSetting:setting fromTable:(UITableView*)self.view]]; break; case ButtonSetting: @@ -76,9 +74,7 @@ static const char* const SETTINGID = "SETTING"; break; case GroupSetting: - [[RetroArch_iOS get].navigator - pushViewController:[[SettingsSubList alloc] initWithSettings:setting.subValues title:setting.label] - animated:YES]; + [[RetroArch_iOS get] pushViewController:[[SettingsSubList alloc] initWithSettings:setting.subValues title:setting.label]]; break; default: