mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
ios: Use a UINavigationController to manage file browser history.
This commit is contained in:
parent
675468e9d6
commit
7b3ebc3078
@ -13,6 +13,7 @@
|
|||||||
962979F616C43B9500E6DCE0 /* ic_dir.png in Resources */ = {isa = PBXBuildFile; fileRef = 962979F416C43B9500E6DCE0 /* ic_dir.png */; };
|
962979F616C43B9500E6DCE0 /* ic_dir.png in Resources */ = {isa = PBXBuildFile; fileRef = 962979F416C43B9500E6DCE0 /* ic_dir.png */; };
|
||||||
962979F716C43B9500E6DCE0 /* ic_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 962979F516C43B9500E6DCE0 /* ic_file.png */; };
|
962979F716C43B9500E6DCE0 /* ic_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 962979F516C43B9500E6DCE0 /* ic_file.png */; };
|
||||||
96297A0116C4767F00E6DCE0 /* dirent_list.c in Sources */ = {isa = PBXBuildFile; fileRef = 962979FF16C4767F00E6DCE0 /* dirent_list.c */; };
|
96297A0116C4767F00E6DCE0 /* dirent_list.c in Sources */ = {isa = PBXBuildFile; fileRef = 962979FF16C4767F00E6DCE0 /* dirent_list.c */; };
|
||||||
|
96297A0516C4996400E6DCE0 /* browser.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A0416C4996400E6DCE0 /* browser.m */; };
|
||||||
96AFAE2A16C1D4EA009DE44C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2916C1D4EA009DE44C /* UIKit.framework */; };
|
96AFAE2A16C1D4EA009DE44C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2916C1D4EA009DE44C /* UIKit.framework */; };
|
||||||
96AFAE2C16C1D4EA009DE44C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2B16C1D4EA009DE44C /* Foundation.framework */; };
|
96AFAE2C16C1D4EA009DE44C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2B16C1D4EA009DE44C /* Foundation.framework */; };
|
||||||
96AFAE2E16C1D4EA009DE44C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2D16C1D4EA009DE44C /* CoreGraphics.framework */; };
|
96AFAE2E16C1D4EA009DE44C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2D16C1D4EA009DE44C /* CoreGraphics.framework */; };
|
||||||
@ -89,6 +90,8 @@
|
|||||||
962979F516C43B9500E6DCE0 /* ic_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_file.png; path = "../android/phoenix/res/drawable-xhdpi/ic_file.png"; sourceTree = "<group>"; };
|
962979F516C43B9500E6DCE0 /* ic_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_file.png; path = "../android/phoenix/res/drawable-xhdpi/ic_file.png"; sourceTree = "<group>"; };
|
||||||
962979FF16C4767F00E6DCE0 /* dirent_list.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dirent_list.c; sourceTree = "<group>"; };
|
962979FF16C4767F00E6DCE0 /* dirent_list.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dirent_list.c; sourceTree = "<group>"; };
|
||||||
96297A0016C4767F00E6DCE0 /* dirent_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dirent_list.h; sourceTree = "<group>"; };
|
96297A0016C4767F00E6DCE0 /* dirent_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dirent_list.h; sourceTree = "<group>"; };
|
||||||
|
96297A0316C4996400E6DCE0 /* browser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = browser.h; sourceTree = "<group>"; };
|
||||||
|
96297A0416C4996400E6DCE0 /* browser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = browser.m; sourceTree = "<group>"; };
|
||||||
96AFAE2516C1D4EA009DE44C /* RetroArch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArch.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
96AFAE2516C1D4EA009DE44C /* RetroArch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArch.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
96AFAE2916C1D4EA009DE44C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
96AFAE2916C1D4EA009DE44C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||||
96AFAE2B16C1D4EA009DE44C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
96AFAE2B16C1D4EA009DE44C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||||
@ -345,6 +348,8 @@
|
|||||||
96CF015B16C2F72900ABF9C9 /* ios_input.c */,
|
96CF015B16C2F72900ABF9C9 /* ios_input.c */,
|
||||||
9629797516C3CD2400E6DCE0 /* dirlist.h */,
|
9629797516C3CD2400E6DCE0 /* dirlist.h */,
|
||||||
9629797616C3CD2400E6DCE0 /* dirlist.m */,
|
9629797616C3CD2400E6DCE0 /* dirlist.m */,
|
||||||
|
96297A0316C4996400E6DCE0 /* browser.h */,
|
||||||
|
96297A0416C4996400E6DCE0 /* browser.m */,
|
||||||
);
|
);
|
||||||
path = RetroArch;
|
path = RetroArch;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -793,6 +798,7 @@
|
|||||||
962979ED16C3E86F00E6DCE0 /* gameview.m in Sources */,
|
962979ED16C3E86F00E6DCE0 /* gameview.m in Sources */,
|
||||||
962979EF16C3EA3E00E6DCE0 /* ioseagl_ctx.c in Sources */,
|
962979EF16C3EA3E00E6DCE0 /* ioseagl_ctx.c in Sources */,
|
||||||
96297A0116C4767F00E6DCE0 /* dirent_list.c in Sources */,
|
96297A0116C4767F00E6DCE0 /* dirent_list.c in Sources */,
|
||||||
|
96297A0516C4996400E6DCE0 /* browser.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#import "AppDelegate.h"
|
#import "AppDelegate.h"
|
||||||
#import "dirlist.h"
|
#import "dirlist.h"
|
||||||
|
#import "browser.h"
|
||||||
|
|
||||||
#define MAX_TOUCH 16
|
#define MAX_TOUCH 16
|
||||||
extern struct
|
extern struct
|
||||||
@ -27,9 +28,9 @@ extern uint32_t ios_current_touch_count ;
|
|||||||
|
|
||||||
// Override point for customization after application launch.
|
// Override point for customization after application launch.
|
||||||
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
|
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
|
||||||
self.window.rootViewController = [[dirlist_view alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
|
self.window.rootViewController = [[browser alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
|
||||||
else
|
else
|
||||||
self.window.rootViewController = [[dirlist_view alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
|
self.window.rootViewController = [[browser alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
|
||||||
|
|
||||||
[self.window makeKeyAndVisible];
|
[self.window makeKeyAndVisible];
|
||||||
}
|
}
|
||||||
|
14
ios/RetroArch/browser.h
Normal file
14
ios/RetroArch/browser.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//
|
||||||
|
// browser.h
|
||||||
|
// RetroArch
|
||||||
|
//
|
||||||
|
// Created by Jason Fetters on 2/7/13.
|
||||||
|
// Copyright (c) 2013 RetroArch. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <UIKit/UIkit.h>
|
||||||
|
|
||||||
|
@interface browser : UINavigationController
|
||||||
|
|
||||||
|
@end
|
21
ios/RetroArch/browser.m
Normal file
21
ios/RetroArch/browser.m
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// browser.m
|
||||||
|
// RetroArch
|
||||||
|
//
|
||||||
|
// Created by Jason Fetters on 2/7/13.
|
||||||
|
// Copyright (c) 2013 RetroArch. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "browser.h"
|
||||||
|
#import "dirlist.h"
|
||||||
|
@implementation browser
|
||||||
|
|
||||||
|
- (void)viewDidLoad
|
||||||
|
{
|
||||||
|
[super viewDidLoad];
|
||||||
|
|
||||||
|
[self pushViewController:[[[dirlist_view alloc] init] load_path:"/" ] animated:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
@ -22,7 +22,7 @@ static bool is_dirent_verboten(const struct dirent* entry)
|
|||||||
{
|
{
|
||||||
if (!entry) return true;
|
if (!entry) return true;
|
||||||
if (strcmp(entry->d_name, ".") == 0) return true;
|
if (strcmp(entry->d_name, ".") == 0) return true;
|
||||||
//if (strcmp(entry->d_name, "..") == 0) return true;
|
if (strcmp(entry->d_name, "..") == 0) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,5 +8,5 @@
|
|||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@interface dirlist_view : UIViewController <UITableViewDelegate, UITableViewDataSource>
|
@interface dirlist_view : UIViewController <UITableViewDelegate, UITableViewDataSource>
|
||||||
|
- (id)load_path:(const char*)directory;
|
||||||
@end
|
@end
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
@implementation dirlist_view
|
@implementation dirlist_view
|
||||||
{
|
{
|
||||||
char path[4096];
|
char* path;
|
||||||
|
|
||||||
UITableView* table;
|
UITableView* table;
|
||||||
struct dirent_list* files;
|
struct dirent_list* files;
|
||||||
|
|
||||||
@ -20,26 +21,43 @@
|
|||||||
UIImage* folder_icon;
|
UIImage* folder_icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
-(void)dealloc
|
- (id)load_path:(const char*)directory
|
||||||
{
|
{
|
||||||
free_dirent_list(files);
|
free_dirent_list(files);
|
||||||
files = 0;
|
files = build_dirent_list(directory);
|
||||||
|
[table reloadData];
|
||||||
|
|
||||||
|
free(path);
|
||||||
|
path = strdup(directory);
|
||||||
|
|
||||||
|
[self setTitle: [[NSString alloc] initWithUTF8String:directory]];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
free_dirent_list(files);
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidLoad
|
- (void)viewDidLoad
|
||||||
{
|
{
|
||||||
|
[super viewDidLoad];
|
||||||
|
|
||||||
file_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_file" ofType:@"png"]];
|
file_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_file" ofType:@"png"]];
|
||||||
folder_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_dir" ofType:@"png"]];
|
folder_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_dir" ofType:@"png"]];
|
||||||
|
|
||||||
[super viewDidLoad];
|
|
||||||
|
|
||||||
strcpy(path, "/");
|
|
||||||
files = build_dirent_list(path);
|
|
||||||
|
|
||||||
table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) style:UITableViewStylePlain];
|
table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) style:UITableViewStylePlain];
|
||||||
table.dataSource = self;
|
table.dataSource = self;
|
||||||
table.delegate = self;
|
table.delegate = self;
|
||||||
|
|
||||||
|
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
|
||||||
|
initWithTitle:@"Parent"
|
||||||
|
style:UIBarButtonItemStyleBordered
|
||||||
|
target:nil action:nil];
|
||||||
|
|
||||||
|
|
||||||
self.view = table;
|
self.view = table;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,38 +67,27 @@
|
|||||||
|
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
|
char new_path[4096];
|
||||||
|
strcpy(new_path, path);
|
||||||
|
strcat(new_path, item->d_name);
|
||||||
|
|
||||||
if (item->d_type)
|
if (item->d_type)
|
||||||
{
|
{
|
||||||
if (strcmp(item->d_name, "..") == 0)
|
strcat(new_path, "/");
|
||||||
{
|
|
||||||
char* last_slash = strrchr(path, '/');
|
|
||||||
if (last_slash) *last_slash = 0;
|
|
||||||
path[0] = (path[0] == 0) ? '/' : path[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcat(path, "/");
|
|
||||||
strcat(path, item->d_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
free_dirent_list(files);
|
UINavigationController *pvc = (UINavigationController*)self.parentViewController;
|
||||||
files = build_dirent_list(path);
|
[pvc pushViewController:[[[dirlist_view alloc] init] load_path: new_path] animated:YES];
|
||||||
[table reloadData];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UIWindow *window = [UIApplication sharedApplication].keyWindow;
|
UIWindow *window = [UIApplication sharedApplication].keyWindow;
|
||||||
|
|
||||||
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
|
bool is_phone = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone);
|
||||||
window.rootViewController = [[game_view alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
|
window.rootViewController = [[game_view alloc] initWithNibName:
|
||||||
else
|
(is_phone ? @"ViewController_iPhone" : @"ViewController_iPad") bundle:nil];
|
||||||
window.rootViewController = [[game_view alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
|
|
||||||
|
|
||||||
strcat(path, "/");
|
|
||||||
strcat(path, item->d_name);
|
|
||||||
|
|
||||||
extern void ios_load_game(const char*);
|
extern void ios_load_game(const char*);
|
||||||
ios_load_game(path);
|
ios_load_game(new_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,18 +106,8 @@
|
|||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
cell.textLabel.text = [[NSString string] initWithUTF8String:item->d_name];
|
cell.textLabel.text = [[NSString string] initWithUTF8String:item->d_name];
|
||||||
|
cell.accessoryType = (item->d_type) ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;
|
||||||
if (item->d_type)
|
cell.imageView.image = (item->d_type) ? folder_icon : file_icon;
|
||||||
{
|
|
||||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
|
||||||
cell.imageView.image = folder_icon;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
|
||||||
cell.imageView.image = file_icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
[cell.imageView sizeToFit];
|
[cell.imageView sizeToFit];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user