From d67fc02b26cf67f1e63cb9a465ea270acb1a37f0 Mon Sep 17 00:00:00 2001 From: meancoot Date: Fri, 24 May 2013 16:02:04 -0400 Subject: [PATCH] (iOS) Remove the Settings button on the top bar if a settings view controller is present in the backstack (prevents recursive opening of settings menu) --- ios/RetroArch/main.m | 21 ++++++++++++++++----- ios/RetroArch/settings/settings.h | 2 ++ ios/RetroArch/settings/settings.m | 5 +++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ios/RetroArch/main.m b/ios/RetroArch/main.m index 618b9caf07..8b70fd46a8 100644 --- a/ios/RetroArch/main.m +++ b/ios/RetroArch/main.m @@ -208,6 +208,7 @@ static void event_reload_config(void* userdata) bool _isGameTop; bool _isPaused; bool _isRunning; + uint32_t _settingMenusInBackStack; RAModuleInfo* _module; } @@ -268,11 +269,17 @@ static void event_reload_config(void* userdata) // UINavigationController: Never animate when pushing onto, or popping, an RAGameView - (void)pushViewController:(UIViewController*)theView animated:(BOOL)animated { + if ([theView respondsToSelector:@selector(isSettingsView)] && [(id)theView isSettingsView]) + _settingMenusInBackStack ++; + [super pushViewController:theView animated:animated && !_isGameTop]; } - (UIViewController*)popViewControllerAnimated:(BOOL)animated { + if ([self.topViewController respondsToSelector:@selector(isSettingsView)] && [(id)self.topViewController isSettingsView]) + _settingMenusInBackStack --; + return [super popViewControllerAnimated:animated && !_isGameTop]; } @@ -363,11 +370,15 @@ static void event_reload_config(void* userdata) #pragma mark PAUSE MENU - (UIBarButtonItem*)createSettingsButton { - return [[UIBarButtonItem alloc] - initWithTitle:@"Settings" - style:UIBarButtonItemStyleBordered - target:[RetroArch_iOS get] - action:@selector(showSystemSettings)]; + if (_settingMenusInBackStack == 0) + return [[UIBarButtonItem alloc] + initWithTitle:@"Settings" + style:UIBarButtonItemStyleBordered + target:[RetroArch_iOS get] + action:@selector(showSystemSettings)]; + + else + return nil; } - (IBAction)showPauseMenu:(id)sender diff --git a/ios/RetroArch/settings/settings.h b/ios/RetroArch/settings/settings.h index 2838072bf4..7982ce0967 100644 --- a/ios/RetroArch/settings/settings.h +++ b/ios/RetroArch/settings/settings.h @@ -50,6 +50,8 @@ enum SettingTypes - (id)initWithSettings:(NSArray*)values title:(NSString*)title; - (void)handleCustomAction:(NSString*)action withUserData:(id)data; - (void)writeSettings:(NSArray*)settingList toConfig:(config_file_t*)config; + +- (bool)isSettingsView; @end @interface RASettingsList : RASettingsSubList diff --git a/ios/RetroArch/settings/settings.m b/ios/RetroArch/settings/settings.m index c58eeef8b6..f465699811 100644 --- a/ios/RetroArch/settings/settings.m +++ b/ios/RetroArch/settings/settings.m @@ -348,6 +348,11 @@ static RASettingData* custom_action(NSString* action, id data) return self; } +- (bool)isSettingsView +{ + return true; +} + - (void)handleCustomAction:(NSString*)action withUserData:(id)data {