(iOS) Combine RAPauseMenu into RAMainMenu. RAGameView is no longer displayed in the UINavigationController but is instead swapped with the navigation controller as needed.

This commit is contained in:
meancoot 2013-12-17 17:38:43 -05:00
parent aa338967f8
commit bd1e970027
4 changed files with 87 additions and 95 deletions

View File

@ -200,11 +200,4 @@
/*********************************************/ /*********************************************/
@interface RAMenuItemStateSelect : NSObject<RAMenuItemBase> @end @interface RAMenuItemStateSelect : NSObject<RAMenuItemBase> @end
/*********************************************/ #endif
/* RAPauseMenu */
/* Menu which provides options for the */
/* currently running game. */
/*********************************************/
@interface RAPauseMenu : RAMenuBase @end
#endif

View File

@ -436,27 +436,68 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
{ {
if ((self = [super initWithStyle:UITableViewStylePlain])) if ((self = [super initWithStyle:UITableViewStylePlain]))
{ {
RAMainMenu* __weak weakSelf = self;
self.title = @"RetroArch"; self.title = @"RetroArch";
self.sections =
(id)@[
@[ @"",
[RAMenuItemBasic itemWithDescription:@"Choose Core"
action:^{ [weakSelf chooseCoreWithPath:nil]; }
detail:^{ return weakSelf.core ? apple_get_core_display_name(weakSelf.core) : @"Auto Detect"; }],
[RAMenuItemBasic itemWithDescription:@"Load Content" action:^{ [weakSelf loadGame]; }],
[RAMenuItemBasic itemWithDescription:@"Load Content (History)" action:^{ [weakSelf loadHistory]; }],
[RAMenuItemBasic itemWithDescription:@"Settings"
action:^{ [weakSelf.navigationController pushViewController:[RAFrontendSettingsMenu new] animated:YES]; }]
]
];
} }
return self; return self;
} }
- (void)viewWillAppear:(BOOL)animated
{
[self reloadData];
}
- (void)willReloadData
{
RAMainMenu* __weak weakSelf = self;
self.sections = [NSMutableArray array];
[self.sections addObject:[NSArray arrayWithObjects:@"Content",
[RAMenuItemBasic itemWithDescription:@"Choose Core"
action:^{ [weakSelf chooseCoreWithPath:nil]; }
detail:^{ return weakSelf.core ? apple_get_core_display_name(weakSelf.core) : @"Auto Detect"; }],
[RAMenuItemBasic itemWithDescription:@"Load Content" action:^{ [weakSelf loadGame]; }],
[RAMenuItemBasic itemWithDescription:@"Load Content (History)" action:^{ [weakSelf loadHistory]; }],
nil]];
NSMutableArray* settings = [NSMutableArray arrayWithObjects:@"Settings",
[RAMenuItemBasic itemWithDescription:@"Frontend"
action:^{ [weakSelf.navigationController pushViewController:[RAFrontendSettingsMenu new] animated:YES]; }],
nil];
if (apple_is_running)
{
[self.sections addObject:[NSArray arrayWithObjects:@"Actions",
[RAMenuItemBasic itemWithDescription:@"Reset Content" action:^{ [weakSelf performBasicAction:RESET]; }],
[RAMenuItemBasic itemWithDescription:@"Close Content" action:^{ [weakSelf performBasicAction:QUIT]; }],
nil]];
[self.sections addObject:[NSArray arrayWithObjects:@"States",
[RAMenuItemStateSelect new],
[RAMenuItemBasic itemWithDescription:@"Load State" action:^{ [weakSelf performBasicAction:LOAD_STATE]; }],
[RAMenuItemBasic itemWithDescription:@"Save State" action:^{ [weakSelf performBasicAction:SAVE_STATE]; }],
nil]];
[settings addObject:[RAMenuItemBasic itemWithDescription:@"Core"
action:^{ [weakSelf.navigationController pushViewController:[[RACoreSettingsMenu alloc] initWithCore:apple_core] animated:YES]; }]];
[settings addObject:[RAMenuItemBasic itemWithDescription:@"Core Options"
action:^{ [weakSelf.navigationController pushViewController:[RACoreOptionsMenu new] animated:YES]; }]];
}
[self.sections addObject:settings];
if (apple_is_running)
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Resume" style:UIBarButtonItemStyleBordered target:[RetroArch_iOS get] action:@selector(showGameView)];
else
self.navigationItem.leftBarButtonItem = nil;
}
- (void)performBasicAction:(enum basic_event_t)action
{
[[RetroArch_iOS get] showGameView];
apple_frontend_post_event(apple_event_basic_command, action);
}
- (void)chooseCoreWithPath:(NSString*)path - (void)chooseCoreWithPath:(NSString*)path
{ {
RAMainMenu* __weak weakSelf = self; RAMainMenu* __weak weakSelf = self;
@ -641,9 +682,6 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
^{ ^{
[weakSelf.navigationController pushViewController:[[RASettingsGroupMenu alloc] initWithGroup:i] animated:YES]; [weakSelf.navigationController pushViewController:[[RASettingsGroupMenu alloc] initWithGroup:i] animated:YES];
}]]; }]];
[settings addObject:[RAMenuItemBasic itemWithDescription:@"Core Options"
action:^{ [weakSelf.navigationController pushViewController:[RACoreOptionsMenu new] animated:YES]; }]];
} }
return self; return self;
@ -993,52 +1031,3 @@ static const void* const associated_core_key = &associated_core_key;
} }
@end @end
/*********************************************/
/* RAPauseMenu */
/* Menu which provides options for the */
/* currently running game. */
/*********************************************/
@implementation RAPauseMenu
- (id)init
{
if ((self = [super initWithStyle:UITableViewStyleGrouped]))
{
RAPauseMenu* __weak weakSelf = self;
self.title = @"RetroArch Paused";
[self.sections addObject:@[@"Actions",
[RAMenuItemBasic itemWithDescription:@"Reset Content" action:^{ [weakSelf performBasicAction:RESET]; }],
[RAMenuItemBasic itemWithDescription:@"Close Content" action:^{ [weakSelf performBasicAction:QUIT]; }]
]];
[self.sections addObject:@[@"States",
[RAMenuItemStateSelect new],
[RAMenuItemBasic itemWithDescription:@"Load State" action:^{ [weakSelf performBasicAction:LOAD_STATE]; }],
[RAMenuItemBasic itemWithDescription:@"Save State" action:^{ [weakSelf performBasicAction:SAVE_STATE]; }]
]];
[self.sections addObject:@[@"Settings",
[RAMenuItemBasic itemWithDescription:@"Frontend"
action:^{ [weakSelf.navigationController pushViewController:[RAFrontendSettingsMenu new] animated:YES]; }],
[RAMenuItemBasic itemWithDescription:@"Core"
action:^{ [weakSelf.navigationController pushViewController:[[RACoreSettingsMenu alloc] initWithCore:apple_core] animated:YES]; }]
]];
}
return self;
}
- (void)dealloc
{
apple_refresh_config();
}
- (void)performBasicAction:(enum basic_event_t)action
{
[self.navigationController popViewControllerAnimated:(action != QUIT)];
apple_frontend_post_event(apple_event_basic_command, action);
}
@end

View File

@ -48,11 +48,14 @@ const void* apple_get_frontend_settings(void);
+ (RetroArch_iOS*)get; + (RetroArch_iOS*)get;
- (void)showGameView;
- (void)loadingCore:(NSString*)core withFile:(const char*)file; - (void)loadingCore:(NSString*)core withFile:(const char*)file;
- (void)unloadingCore:(NSString*)core; - (void)unloadingCore:(NSString*)core;
- (void)refreshSystemConfig; - (void)refreshSystemConfig;
@property (nonatomic) NSString* configDirectory; // e.g. /var/mobile/Documents/.RetroArch @property (nonatomic) NSString* configDirectory; // e.g. /var/mobile/Documents/.RetroArch
@property (nonatomic) NSString* globalConfigFile; // e.g. /var/mobile/Documents/.RetroArch/retroarch.cfg @property (nonatomic) NSString* globalConfigFile; // e.g. /var/mobile/Documents/.RetroArch/retroarch.cfg
@property (nonatomic) NSString* coreDirectory; // e.g. /Applications/RetroArch.app/modules @property (nonatomic) NSString* coreDirectory; // e.g. /Applications/RetroArch.app/modules

View File

@ -178,7 +178,6 @@ static void handle_touch_event(NSArray* touches)
UIWindow* _window; UIWindow* _window;
NSString* _path; NSString* _path;
bool _isGameTop;
uint32_t _enabledOrientations; uint32_t _enabledOrientations;
} }
@ -195,7 +194,7 @@ static void handle_touch_event(NSArray* touches)
// Setup window // Setup window
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_window.rootViewController = self; [self showPauseMenu:self];
[_window makeKeyAndVisible]; [_window makeKeyAndVisible];
// Build system paths and test permissions // Build system paths and test permissions
@ -264,13 +263,7 @@ static void handle_touch_event(NSArray* touches)
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{ {
apple_input_reset_icade_buttons(); apple_input_reset_icade_buttons();
_isGameTop = [viewController isKindOfClass:[RAGameView class]];
g_extern.is_paused = !_isGameTop;
[[UIApplication sharedApplication] setStatusBarHidden:_isGameTop withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setIdleTimerDisabled:_isGameTop];
[self setNavigationBarHidden:_isGameTop animated:!_isGameTop];
[self setToolbarHidden:!viewController.toolbarItems.count animated:YES]; [self setToolbarHidden:!viewController.toolbarItems.count animated:YES];
// Workaround to keep frontend settings fresh // Workaround to keep frontend settings fresh
@ -280,14 +273,14 @@ static void handle_touch_event(NSArray* touches)
// NOTE: This version only runs on iOS6 // NOTE: This version only runs on iOS6
- (NSUInteger)supportedInterfaceOrientations - (NSUInteger)supportedInterfaceOrientations
{ {
return _isGameTop ? _enabledOrientations return g_extern.is_paused ? _enabledOrientations
: UIInterfaceOrientationMaskAll; : UIInterfaceOrientationMaskAll;
} }
// NOTE: This version runs on iOS2-iOS5, but not iOS6 // NOTE: This version runs on iOS2-iOS5, but not iOS6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{ {
if (_isGameTop) if (!g_extern.is_paused)
switch (interfaceOrientation) switch (interfaceOrientation)
{ {
case UIInterfaceOrientationPortrait: case UIInterfaceOrientationPortrait:
@ -303,23 +296,42 @@ static void handle_touch_event(NSArray* touches)
return YES; return YES;
} }
- (void)showGameView
{
[self popToRootViewControllerAnimated:NO];
[_window setRootViewController:[RAGameView get]];
g_extern.is_paused = false;
[[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setIdleTimerDisabled:true];
}
- (IBAction)showPauseMenu:(id)sender
{
[_window setRootViewController:self];
g_extern.is_paused = true;
[[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setIdleTimerDisabled:false];
}
#pragma mark RetroArch_Platform #pragma mark RetroArch_Platform
- (void)loadingCore:(NSString*)core withFile:(const char*)file - (void)loadingCore:(NSString*)core withFile:(const char*)file
{ {
[self pushViewController:RAGameView.get animated:NO];
(void)[[RACoreSettingsMenu alloc] initWithCore:core]; (void)[[RACoreSettingsMenu alloc] initWithCore:core];
btpad_set_inquiry_state(false); btpad_set_inquiry_state(false);
[self refreshSystemConfig]; [self refreshSystemConfig];
[self showGameView];
} }
- (void)unloadingCore:(NSString*)core - (void)unloadingCore:(NSString*)core
{ {
[self popToViewController:[RAGameView get] animated:NO]; [self showPauseMenu:self];
[self popViewControllerAnimated:NO];
btpad_set_inquiry_state(true); btpad_set_inquiry_state(true);
} }
@ -339,11 +351,6 @@ static void handle_touch_event(NSArray* touches)
ios_set_logging_state([RetroArch_iOS get].logPath.UTF8String, apple_frontend_settings.logging_enabled); ios_set_logging_state([RetroArch_iOS get].logPath.UTF8String, apple_frontend_settings.logging_enabled);
} }
- (IBAction)showPauseMenu:(id)sender
{
[self pushViewController:[RAPauseMenu new] animated:YES];
}
@end @end
int main(int argc, char *argv[]) int main(int argc, char *argv[])