mirror of
https://github.com/libretro/RetroArch
synced 2025-03-26 20:37:10 +00:00
(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:
parent
aa338967f8
commit
bd1e970027
@ -200,11 +200,4 @@
|
||||
/*********************************************/
|
||||
@interface RAMenuItemStateSelect : NSObject<RAMenuItemBase> @end
|
||||
|
||||
/*********************************************/
|
||||
/* RAPauseMenu */
|
||||
/* Menu which provides options for the */
|
||||
/* currently running game. */
|
||||
/*********************************************/
|
||||
@interface RAPauseMenu : RAMenuBase @end
|
||||
|
||||
#endif
|
||||
#endif
|
123
apple/iOS/menu.m
123
apple/iOS/menu.m
@ -436,27 +436,68 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
||||
{
|
||||
if ((self = [super initWithStyle:UITableViewStylePlain]))
|
||||
{
|
||||
RAMainMenu* __weak weakSelf = self;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
- (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
|
||||
{
|
||||
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];
|
||||
}]];
|
||||
|
||||
[settings addObject:[RAMenuItemBasic itemWithDescription:@"Core Options"
|
||||
action:^{ [weakSelf.navigationController pushViewController:[RACoreOptionsMenu new] animated:YES]; }]];
|
||||
}
|
||||
|
||||
return self;
|
||||
@ -993,52 +1031,3 @@ static const void* const associated_core_key = &associated_core_key;
|
||||
}
|
||||
|
||||
@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
|
||||
|
@ -48,11 +48,14 @@ const void* apple_get_frontend_settings(void);
|
||||
|
||||
+ (RetroArch_iOS*)get;
|
||||
|
||||
- (void)showGameView;
|
||||
|
||||
- (void)loadingCore:(NSString*)core withFile:(const char*)file;
|
||||
- (void)unloadingCore:(NSString*)core;
|
||||
|
||||
- (void)refreshSystemConfig;
|
||||
|
||||
|
||||
@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* coreDirectory; // e.g. /Applications/RetroArch.app/modules
|
||||
|
@ -178,7 +178,6 @@ static void handle_touch_event(NSArray* touches)
|
||||
UIWindow* _window;
|
||||
NSString* _path;
|
||||
|
||||
bool _isGameTop;
|
||||
uint32_t _enabledOrientations;
|
||||
}
|
||||
|
||||
@ -195,7 +194,7 @@ static void handle_touch_event(NSArray* touches)
|
||||
|
||||
// Setup window
|
||||
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
_window.rootViewController = self;
|
||||
[self showPauseMenu:self];
|
||||
[_window makeKeyAndVisible];
|
||||
|
||||
// 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
|
||||
{
|
||||
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];
|
||||
|
||||
// Workaround to keep frontend settings fresh
|
||||
@ -280,14 +273,14 @@ static void handle_touch_event(NSArray* touches)
|
||||
// NOTE: This version only runs on iOS6
|
||||
- (NSUInteger)supportedInterfaceOrientations
|
||||
{
|
||||
return _isGameTop ? _enabledOrientations
|
||||
: UIInterfaceOrientationMaskAll;
|
||||
return g_extern.is_paused ? _enabledOrientations
|
||||
: UIInterfaceOrientationMaskAll;
|
||||
}
|
||||
|
||||
// NOTE: This version runs on iOS2-iOS5, but not iOS6
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
if (_isGameTop)
|
||||
if (!g_extern.is_paused)
|
||||
switch (interfaceOrientation)
|
||||
{
|
||||
case UIInterfaceOrientationPortrait:
|
||||
@ -303,23 +296,42 @@ static void handle_touch_event(NSArray* touches)
|
||||
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
|
||||
- (void)loadingCore:(NSString*)core withFile:(const char*)file
|
||||
{
|
||||
[self pushViewController:RAGameView.get animated:NO];
|
||||
(void)[[RACoreSettingsMenu alloc] initWithCore:core];
|
||||
|
||||
btpad_set_inquiry_state(false);
|
||||
|
||||
[self refreshSystemConfig];
|
||||
[self showGameView];
|
||||
}
|
||||
|
||||
- (void)unloadingCore:(NSString*)core
|
||||
{
|
||||
[self popToViewController:[RAGameView get] animated:NO];
|
||||
[self popViewControllerAnimated:NO];
|
||||
|
||||
[self showPauseMenu:self];
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
- (IBAction)showPauseMenu:(id)sender
|
||||
{
|
||||
[self pushViewController:[RAPauseMenu new] animated:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
Loading…
x
Reference in New Issue
Block a user