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) UIWindow *window;
|
||||||
@property (strong, nonatomic) NSString *module_path;
|
@property (strong, nonatomic) NSString *module_path;
|
||||||
@property (strong, nonatomic) UINavigationController *navigator;
|
@property (strong, nonatomic) UINavigationController *navigator;
|
||||||
@property (strong, nonatomic) NSString *nib_name;
|
|
||||||
@property (strong, nonatomic) UIImage* file_icon;
|
@property (strong, nonatomic) UIImage* file_icon;
|
||||||
@property (strong, nonatomic) UIImage* folder_icon;
|
@property (strong, nonatomic) UIImage* folder_icon;
|
||||||
@property (strong, nonatomic) UIBarButtonItem* settings_button;
|
@property (strong, nonatomic) UIBarButtonItem* settings_button;
|
||||||
|
|
|
@ -31,9 +31,6 @@ extern uint32_t ios_current_touch_count ;
|
||||||
self.system_directory = "/var/mobile/Library/RetroArch/";
|
self.system_directory = "/var/mobile/Library/RetroArch/";
|
||||||
mkdir(self.system_directory, 0755);
|
mkdir(self.system_directory, 0755);
|
||||||
|
|
||||||
bool is_iphone = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone;
|
|
||||||
self.nib_name = is_iphone ? @"ViewController_iPhone" : @"ViewController_iPad";
|
|
||||||
|
|
||||||
// Load icons
|
// Load icons
|
||||||
self.file_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_file" ofType:@"png"]];
|
self.file_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_file" ofType:@"png"]];
|
||||||
self.folder_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_dir" ofType:@"png"]];
|
self.folder_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_dir" ofType:@"png"]];
|
||||||
|
@ -44,9 +41,9 @@ extern uint32_t ios_current_touch_count ;
|
||||||
style:UIBarButtonItemStyleBordered
|
style:UIBarButtonItemStyleBordered
|
||||||
target:nil action:nil];
|
target:nil action:nil];
|
||||||
|
|
||||||
|
// Setup window
|
||||||
self.navigator = [[UINavigationController alloc] initWithNibName:self.nib_name bundle:nil];
|
self.navigator = [[UINavigationController alloc] init];
|
||||||
[self.navigator pushViewController: [[module_list alloc] initWithNibName:self.nib_name bundle:nil] animated:YES];
|
[self.navigator pushViewController: [[module_list alloc] init] animated:YES];
|
||||||
|
|
||||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||||
self.window.rootViewController = self.navigator;
|
self.window.rootViewController = self.navigator;
|
||||||
|
|
|
@ -10,21 +10,18 @@
|
||||||
|
|
||||||
@implementation directory_list
|
@implementation directory_list
|
||||||
{
|
{
|
||||||
char* path;
|
char* directory;
|
||||||
|
|
||||||
UITableView* table;
|
|
||||||
struct dirent_list* files;
|
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);
|
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]];
|
[self setTitle: [[[NSString alloc] initWithUTF8String:directory] lastPathComponent]];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -33,20 +30,7 @@
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
free_dirent_list(files);
|
free_dirent_list(files);
|
||||||
free(path);
|
free(directory);
|
||||||
}
|
|
||||||
|
|
||||||
- (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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
@ -56,20 +40,18 @@
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
char new_path[4096];
|
char new_path[4096];
|
||||||
strcpy(new_path, path);
|
snprintf(new_path, 4096, "%s/%s", directory, item->d_name);
|
||||||
strcat(new_path, item->d_name);
|
new_path[4095] = 0;
|
||||||
|
|
||||||
if (item->d_type)
|
if (item->d_type)
|
||||||
{
|
{
|
||||||
strcat(new_path, "/");
|
[[RetroArch_iOS get].navigator
|
||||||
|
pushViewController:[[directory_list alloc] initWithPath:new_path]
|
||||||
[[RetroArch_iOS get].navigator pushViewController:[[[directory_list alloc] init] load_path: new_path] animated:YES];
|
animated:YES];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[RetroArch_iOS get].window.rootViewController = [[game_view alloc]
|
[RetroArch_iOS get].window.rootViewController = [[game_view alloc] init];
|
||||||
initWithNibName: [RetroArch_iOS get].nib_name
|
|
||||||
bundle:nil];
|
|
||||||
|
|
||||||
extern void ios_load_game(const char*);
|
extern void ios_load_game(const char*);
|
||||||
ios_load_game(new_path);
|
ios_load_game(new_path);
|
||||||
|
@ -83,7 +65,7 @@
|
||||||
|
|
||||||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
- (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"];
|
cell = (cell != nil) ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"path"];
|
||||||
|
|
||||||
const struct dirent* item = get_dirent_at_index(files, indexPath.row);
|
const struct dirent* item = get_dirent_at_index(files, indexPath.row);
|
||||||
|
|
|
@ -71,6 +71,31 @@ void ios_close_game()
|
||||||
EAGLContext *gl_context;
|
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
|
- (void)rarch_iterate:(id)sender
|
||||||
{
|
{
|
||||||
if (ra_initialized && !ra_done)
|
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
|
@end
|
||||||
|
|
||||||
void ios_flip_game_view()
|
void ios_flip_game_view()
|
||||||
|
|
|
@ -8,55 +8,32 @@
|
||||||
|
|
||||||
@implementation module_list
|
@implementation module_list
|
||||||
{
|
{
|
||||||
UITableView* table;
|
NSArray* modules;
|
||||||
|
|
||||||
NSString* module_dir;
|
|
||||||
NSMutableArray* modules;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
- (void)viewDidLoad
|
- (id)init
|
||||||
{
|
{
|
||||||
[super viewDidLoad];
|
self = [super initWithStyle:UITableViewStylePlain];
|
||||||
|
|
||||||
// Get the contents of the modules directory of the bundle.
|
// Get the contents of the modules directory of the bundle.
|
||||||
module_dir = [NSString stringWithFormat:@"%@/%@",
|
NSString* module_dir = [NSString stringWithFormat:@"%@/%@",
|
||||||
[[NSBundle mainBundle] bundlePath],
|
[[NSBundle mainBundle] bundlePath],
|
||||||
@"modules"];
|
@"modules"];
|
||||||
|
|
||||||
NSArray *module_list = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:module_dir error:nil];
|
modules = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:module_dir error:nil];
|
||||||
|
modules = [module_dir stringsByAppendingPaths:modules];
|
||||||
if (module_list == nil || [module_list count] == 0)
|
modules = [modules pathsMatchingExtensions:[NSArray arrayWithObject:@"dylib"]];
|
||||||
{
|
|
||||||
// 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 ++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[self setTitle:@"Choose Emulator"];
|
[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;
|
self.navigationItem.rightBarButtonItem = [RetroArch_iOS get].settings_button;
|
||||||
|
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
[RetroArch_iOS get].module_path = [NSString stringWithFormat:@"%@/%@", module_dir, [modules objectAtIndex:indexPath.row]];
|
[RetroArch_iOS get].module_path = [modules objectAtIndex:indexPath.row];
|
||||||
[[RetroArch_iOS get].navigator pushViewController:[[[directory_list alloc] init] load_path:"/"] animated:YES];
|
[[RetroArch_iOS get].navigator pushViewController:[[directory_list alloc] initWithPath:"/"] animated:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||||
|
@ -66,13 +43,10 @@
|
||||||
|
|
||||||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
- (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"];
|
cell = (cell != nil) ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"module"];
|
||||||
|
|
||||||
if (modules)
|
cell.textLabel.text = [[modules objectAtIndex:indexPath.row] lastPathComponent];
|
||||||
{
|
|
||||||
cell.textLabel.text = [modules objectAtIndex:indexPath.row];
|
|
||||||
}
|
|
||||||
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface module_list : UIViewController<UITableViewDelegate, UITableViewDataSource>
|
@interface module_list : UITableViewController
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface directory_list : UIViewController <UITableViewDelegate, UITableViewDataSource>
|
@interface directory_list : UITableViewController
|
||||||
- (id)load_path:(const char*)directory;
|
- (id)initWithPath:(const char*)path;
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue