mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 09:32:52 +00:00
(OSX/iOS) Make iOS ObjC code more reusable with OSX
This commit is contained in:
parent
0181d72cdc
commit
266511b765
@ -122,12 +122,12 @@ static NSString* build_string_pair(NSString* stringA, NSString* stringB)
|
||||
_data = info;
|
||||
|
||||
[self.sections addObject: [NSArray arrayWithObjects:@"Core",
|
||||
build_string_pair(@"Core Name", ios_get_value_from_config(_data.data, @"corename", @"Unspecified")),
|
||||
build_string_pair(@"Core Name", objc_get_value_from_config(_data.data, @"corename", @"Unspecified")),
|
||||
nil]];
|
||||
|
||||
[self.sections addObject: [NSArray arrayWithObjects:@"Hardware/Software",
|
||||
build_string_pair(@"Developer", ios_get_value_from_config(_data.data, @"manufacturer", @"Unspecified")),
|
||||
build_string_pair(@"Name", ios_get_value_from_config(_data.data, @"systemname", @"Unspecified")),
|
||||
build_string_pair(@"Developer", objc_get_value_from_config(_data.data, @"manufacturer", @"Unspecified")),
|
||||
build_string_pair(@"Name", objc_get_value_from_config(_data.data, @"systemname", @"Unspecified")),
|
||||
nil]];
|
||||
|
||||
// Firmware
|
||||
@ -139,9 +139,9 @@ static NSString* build_string_pair(NSString* stringA, NSString* stringB)
|
||||
|
||||
for (int i = 0; i < firmwareCount; i ++)
|
||||
{
|
||||
NSString* path = ios_get_value_from_config(_data.data, [NSString stringWithFormat:@"firmware%d_path", i + 1], @"Unspecified");
|
||||
NSString* path = objc_get_value_from_config(_data.data, [NSString stringWithFormat:@"firmware%d_path", i + 1], @"Unspecified");
|
||||
path = [path stringByReplacingOccurrencesOfString:@"%sysdir%" withString:RetroArch_iOS.get.systemDirectory];
|
||||
[firmwareSection addObject:build_string_pair(ios_get_value_from_config(_data.data, [NSString stringWithFormat:@"firmware%d_desc", i + 1], @"Unspecified"), path)];
|
||||
[firmwareSection addObject:build_string_pair(objc_get_value_from_config(_data.data, [NSString stringWithFormat:@"firmware%d_desc", i + 1], @"Unspecified"), path)];
|
||||
}
|
||||
|
||||
_firmwareSectionIndex = self.sections.count;
|
||||
|
@ -35,8 +35,8 @@
|
||||
|
||||
// utility.m
|
||||
extern void ios_display_alert(NSString* message, NSString* title);
|
||||
extern void ios_clear_config_hack();
|
||||
extern void objc_clear_config_hack();
|
||||
extern bool path_make_and_check_directory(const char* path, mode_t mode, int amode);
|
||||
extern NSString* ios_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue);
|
||||
extern NSString* objc_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue);
|
||||
|
||||
#endif
|
||||
|
@ -127,7 +127,7 @@ static void event_show_rgui(void* userdata)
|
||||
|
||||
static void event_reload_config(void* userdata)
|
||||
{
|
||||
ios_clear_config_hack();
|
||||
objc_clear_config_hack();
|
||||
|
||||
uninit_drivers();
|
||||
config_load();
|
||||
@ -320,7 +320,7 @@ static void event_reload_config(void* userdata)
|
||||
if (_isRunning)
|
||||
ios_frontend_post_event(&event_reload_config, 0);
|
||||
else
|
||||
ios_clear_config_hack();
|
||||
objc_clear_config_hack();
|
||||
}
|
||||
|
||||
- (void)refreshSystemConfig
|
||||
|
@ -71,7 +71,7 @@ enum SettingTypes
|
||||
static RASettingData* boolean_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue)
|
||||
{
|
||||
RASettingData* result = [[RASettingData alloc] initWithType:BooleanSetting label:label name:name];
|
||||
result.value = ios_get_value_from_config(config, name, defaultValue);
|
||||
result.value = objc_get_value_from_config(config, name, defaultValue);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -81,9 +81,9 @@ static RASettingData* button_setting(config_file_t* config, uint32_t player, NSS
|
||||
|
||||
RASettingData* result = [[RASettingData alloc] initWithType:ButtonSetting label:label name:realname];
|
||||
result.msubValues = [NSMutableArray arrayWithObjects:
|
||||
ios_get_value_from_config(config, realname, defaultValue),
|
||||
ios_get_value_from_config(config, [realname stringByAppendingString:@"_btn"], @"nul"),
|
||||
ios_get_value_from_config(config, [realname stringByAppendingString:@"_axis"], @"nul"),
|
||||
objc_get_value_from_config(config, realname, defaultValue),
|
||||
objc_get_value_from_config(config, [realname stringByAppendingString:@"_btn"], @"nul"),
|
||||
objc_get_value_from_config(config, [realname stringByAppendingString:@"_axis"], @"nul"),
|
||||
nil];
|
||||
result.player = player ? player - 1 : 0;
|
||||
return result;
|
||||
@ -99,14 +99,14 @@ static RASettingData* group_setting(NSString* label, NSArray* settings)
|
||||
static RASettingData* enumeration_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue, NSArray* values)
|
||||
{
|
||||
RASettingData* result = [[RASettingData alloc] initWithType:EnumerationSetting label:label name:name];
|
||||
result.value = ios_get_value_from_config(config, name, defaultValue);
|
||||
result.value = objc_get_value_from_config(config, name, defaultValue);
|
||||
result.subValues = values;
|
||||
return result;
|
||||
}
|
||||
|
||||
static RASettingData* subpath_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue, NSString* path, NSString* extension)
|
||||
{
|
||||
NSString* value = ios_get_value_from_config(config, name, defaultValue);
|
||||
NSString* value = objc_get_value_from_config(config, name, defaultValue);
|
||||
value = [value stringByReplacingOccurrencesOfString:path withString:@""];
|
||||
|
||||
NSArray* values = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:path error:nil];
|
||||
@ -123,7 +123,7 @@ static RASettingData* subpath_setting(config_file_t* config, NSString* name, NSS
|
||||
static RASettingData* range_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue, double minValue, double maxValue)
|
||||
{
|
||||
RASettingData* result = [[RASettingData alloc] initWithType:RangeSetting label:label name:name];
|
||||
result.value = ios_get_value_from_config(config, name, defaultValue);
|
||||
result.value = objc_get_value_from_config(config, name, defaultValue);
|
||||
result.rangeMin = minValue;
|
||||
result.rangeMax = maxValue;
|
||||
return result;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "file.h"
|
||||
#import "views.h"
|
||||
|
||||
#ifdef IOS
|
||||
void ios_display_alert(NSString* message, NSString* title)
|
||||
{
|
||||
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:title ? title : @"RetroArch"
|
||||
@ -28,9 +29,10 @@ void ios_display_alert(NSString* message, NSString* title)
|
||||
otherButtonTitles:nil];
|
||||
[alert show];
|
||||
}
|
||||
#endif
|
||||
|
||||
// Little nudge to prevent stale values when reloading the confg file
|
||||
void ios_clear_config_hack()
|
||||
void objc_clear_config_hack()
|
||||
{
|
||||
g_extern.block_config_read = false;
|
||||
memset(g_settings.input.overlay, 0, sizeof(g_settings.input.overlay));
|
||||
@ -38,7 +40,7 @@ void ios_clear_config_hack()
|
||||
}
|
||||
|
||||
// Fetch a value from a config file, returning defaultValue if the value is not present
|
||||
NSString* ios_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue)
|
||||
NSString* objc_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue)
|
||||
{
|
||||
char* data = 0;
|
||||
if (config)
|
||||
@ -58,6 +60,7 @@ bool path_make_and_check_directory(const char* path, mode_t mode, int amode)
|
||||
return access(path, amode) == 0;
|
||||
}
|
||||
|
||||
#ifdef IOS
|
||||
// Simple class to reduce code duplication for fixed table views
|
||||
@implementation RATableViewController
|
||||
|
||||
@ -89,3 +92,4 @@ bool path_make_and_check_directory(const char* path, mode_t mode, int amode)
|
||||
}
|
||||
|
||||
@end
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user