mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 19:24:46 +00:00
ios: Made things more simple.
This commit is contained in:
parent
291220aa54
commit
4d9233b02a
@ -14,7 +14,6 @@
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
@property (strong, nonatomic) NSString *module_path;
|
||||
@property (strong, nonatomic) UINavigationController *navigator;
|
||||
@property (strong, nonatomic) NSString *nib_name;
|
||||
@property (strong, nonatomic) UIImage* file_icon;
|
||||
@property (strong, nonatomic) UIImage* folder_icon;
|
||||
@property (strong, nonatomic) UIBarButtonItem* settings_button;
|
||||
|
@ -30,9 +30,6 @@ extern uint32_t ios_current_touch_count ;
|
||||
// TODO: Relocate this!
|
||||
self.system_directory = "/var/mobile/Library/RetroArch/";
|
||||
mkdir(self.system_directory, 0755);
|
||||
|
||||
bool is_iphone = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone;
|
||||
self.nib_name = is_iphone ? @"ViewController_iPhone" : @"ViewController_iPad";
|
||||
|
||||
// Load icons
|
||||
self.file_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_file" ofType:@"png"]];
|
||||
@ -44,9 +41,9 @@ extern uint32_t ios_current_touch_count ;
|
||||
style:UIBarButtonItemStyleBordered
|
||||
target:nil action:nil];
|
||||
|
||||
|
||||
self.navigator = [[UINavigationController alloc] initWithNibName:self.nib_name bundle:nil];
|
||||
[self.navigator pushViewController: [[module_list alloc] initWithNibName:self.nib_name bundle:nil] animated:YES];
|
||||
// Setup window
|
||||
self.navigator = [[UINavigationController alloc] init];
|
||||
[self.navigator pushViewController: [[module_list alloc] init] animated:YES];
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window.rootViewController = self.navigator;
|
||||
|
@ -10,21 +10,18 @@
|
||||
|
||||
@implementation directory_list
|
||||
{
|
||||
char* path;
|
||||
|
||||
UITableView* table;
|
||||
char* directory;
|
||||
struct dirent_list* files;
|
||||
};
|
||||
|
||||
- (id)load_path:(const char*)directory
|
||||
- (id)initWithPath:(const char*)path
|
||||
{
|
||||
free_dirent_list(files);
|
||||
self = [super initWithStyle:UITableViewStylePlain];
|
||||
|
||||
directory = strdup(path);
|
||||
files = build_dirent_list(directory);
|
||||
[table reloadData];
|
||||
|
||||
free(path);
|
||||
path = strdup(directory);
|
||||
|
||||
|
||||
self.navigationItem.rightBarButtonItem = [RetroArch_iOS get].settings_button;
|
||||
[self setTitle: [[[NSString alloc] initWithUTF8String:directory] lastPathComponent]];
|
||||
|
||||
return self;
|
||||
@ -33,20 +30,7 @@
|
||||
- (void)dealloc
|
||||
{
|
||||
free_dirent_list(files);
|
||||
free(path);
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) style:UITableViewStylePlain];
|
||||
table.dataSource = self;
|
||||
table.delegate = self;
|
||||
|
||||
self.navigationItem.rightBarButtonItem = [RetroArch_iOS get].settings_button;
|
||||
|
||||
self.view = table;
|
||||
free(directory);
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
@ -56,20 +40,18 @@
|
||||
if (!item) return;
|
||||
|
||||
char new_path[4096];
|
||||
strcpy(new_path, path);
|
||||
strcat(new_path, item->d_name);
|
||||
snprintf(new_path, 4096, "%s/%s", directory, item->d_name);
|
||||
new_path[4095] = 0;
|
||||
|
||||
if (item->d_type)
|
||||
{
|
||||
strcat(new_path, "/");
|
||||
|
||||
[[RetroArch_iOS get].navigator pushViewController:[[[directory_list alloc] init] load_path: new_path] animated:YES];
|
||||
{
|
||||
[[RetroArch_iOS get].navigator
|
||||
pushViewController:[[directory_list alloc] initWithPath:new_path]
|
||||
animated:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[RetroArch_iOS get].window.rootViewController = [[game_view alloc]
|
||||
initWithNibName: [RetroArch_iOS get].nib_name
|
||||
bundle:nil];
|
||||
[RetroArch_iOS get].window.rootViewController = [[game_view alloc] init];
|
||||
|
||||
extern void ios_load_game(const char*);
|
||||
ios_load_game(new_path);
|
||||
@ -83,7 +65,7 @@
|
||||
|
||||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell* cell = [table dequeueReusableCellWithIdentifier:@"path"];
|
||||
UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:@"path"];
|
||||
cell = (cell != nil) ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"path"];
|
||||
|
||||
const struct dirent* item = get_dirent_at_index(files, indexPath.row);
|
||||
|
@ -71,6 +71,31 @@ void ios_close_game()
|
||||
EAGLContext *gl_context;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
gl_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
[EAGLContext setCurrentContext:gl_context];
|
||||
|
||||
gl_view = [[GLKView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) context:gl_context];
|
||||
gl_view.multipleTouchEnabled = YES;
|
||||
self.view = gl_view;
|
||||
|
||||
screen_scale = [[UIScreen mainScreen] scale];
|
||||
current_view = self;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if ([EAGLContext currentContext] == gl_context) [EAGLContext setCurrentContext:nil];
|
||||
gl_context = nil;
|
||||
gl_view = nil;
|
||||
}
|
||||
|
||||
|
||||
- (void)rarch_iterate:(id)sender
|
||||
{
|
||||
if (ra_initialized && !ra_done)
|
||||
@ -86,28 +111,6 @@ void ios_close_game()
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
gl_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
[EAGLContext setCurrentContext:gl_context];
|
||||
|
||||
gl_view = [[GLKView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) context:gl_context];
|
||||
gl_view.multipleTouchEnabled = YES;
|
||||
self.view = gl_view;
|
||||
|
||||
screen_scale = [[UIScreen mainScreen] scale];
|
||||
current_view = self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if ([EAGLContext currentContext] == gl_context) [EAGLContext setCurrentContext:nil];
|
||||
gl_context = nil;
|
||||
gl_view = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void ios_flip_game_view()
|
||||
|
@ -8,55 +8,32 @@
|
||||
|
||||
@implementation module_list
|
||||
{
|
||||
UITableView* table;
|
||||
|
||||
NSString* module_dir;
|
||||
NSMutableArray* modules;
|
||||
NSArray* modules;
|
||||
};
|
||||
|
||||
- (void)viewDidLoad
|
||||
- (id)init
|
||||
{
|
||||
[super viewDidLoad];
|
||||
self = [super initWithStyle:UITableViewStylePlain];
|
||||
|
||||
// Get the contents of the modules directory of the bundle.
|
||||
module_dir = [NSString stringWithFormat:@"%@/%@",
|
||||
[[NSBundle mainBundle] bundlePath],
|
||||
@"modules"];
|
||||
NSString* module_dir = [NSString stringWithFormat:@"%@/%@",
|
||||
[[NSBundle mainBundle] bundlePath],
|
||||
@"modules"];
|
||||
|
||||
NSArray *module_list = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:module_dir error:nil];
|
||||
|
||||
if (module_list == nil || [module_list count] == 0)
|
||||
{
|
||||
// TODO: Handle error!
|
||||
}
|
||||
|
||||
// Remove non .dylib files from the list
|
||||
modules = [NSMutableArray arrayWithArray:module_list];
|
||||
for (int i = 0; i < [modules count];)
|
||||
{
|
||||
if (![[modules objectAtIndex:i] hasSuffix:@".dylib"])
|
||||
{
|
||||
[modules removeObjectAtIndex:i];
|
||||
}
|
||||
else
|
||||
{
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
modules = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:module_dir error:nil];
|
||||
modules = [module_dir stringsByAppendingPaths:modules];
|
||||
modules = [modules pathsMatchingExtensions:[NSArray arrayWithObject:@"dylib"]];
|
||||
|
||||
[self setTitle:@"Choose Emulator"];
|
||||
table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) style:UITableViewStylePlain];
|
||||
table.dataSource = self;
|
||||
table.delegate = self;
|
||||
self.view = table;
|
||||
|
||||
self.navigationItem.rightBarButtonItem = [RetroArch_iOS get].settings_button;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[RetroArch_iOS get].module_path = [NSString stringWithFormat:@"%@/%@", module_dir, [modules objectAtIndex:indexPath.row]];
|
||||
[[RetroArch_iOS get].navigator pushViewController:[[[directory_list alloc] init] load_path:"/"] animated:YES];
|
||||
[RetroArch_iOS get].module_path = [modules objectAtIndex:indexPath.row];
|
||||
[[RetroArch_iOS get].navigator pushViewController:[[directory_list alloc] initWithPath:"/"] animated:YES];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
@ -66,13 +43,10 @@
|
||||
|
||||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell* cell = [table dequeueReusableCellWithIdentifier:@"module"];
|
||||
UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:@"module"];
|
||||
cell = (cell != nil) ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"module"];
|
||||
|
||||
if (modules)
|
||||
{
|
||||
cell.textLabel.text = [modules objectAtIndex:indexPath.row];
|
||||
}
|
||||
cell.textLabel.text = [[modules objectAtIndex:indexPath.row] lastPathComponent];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
@ -5,10 +5,10 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface module_list : UIViewController<UITableViewDelegate, UITableViewDataSource>
|
||||
@interface module_list : UITableViewController
|
||||
|
||||
@end
|
||||
|
||||
@interface directory_list : UIViewController <UITableViewDelegate, UITableViewDataSource>
|
||||
- (id)load_path:(const char*)directory;
|
||||
@interface directory_list : UITableViewController
|
||||
- (id)initWithPath:(const char*)path;
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user