(OSX) The settings panel now works

This commit is contained in:
meancoot 2013-08-26 14:05:16 -04:00
parent 5411646504
commit dbc1758a99
3 changed files with 59 additions and 7 deletions

View File

@ -36,6 +36,7 @@
- (void)loadingCore:(RAModuleInfo*)core withFile:(const char*)file;
- (void)unloadingCore:(RAModuleInfo*)core;
- (NSString*)configPath;
@end

View File

@ -227,6 +227,11 @@
_wantReload = false;
}
- (NSString*)configPath
{
return [[self retroarchConfigPath] stringByAppendingPathComponent:@"retroarch.cfg"];
}
- (NSString*)retroarchConfigPath
{
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);

View File

@ -23,7 +23,7 @@ struct global fake_extern;
static const void* associated_name_tag = (void*)&associated_name_tag;
@interface RASettingCell : NSTableCellView
@property (strong) NSString* stringValue;
@property (nonatomic) NSString* stringValue;
@property (nonatomic) IBOutlet NSNumber* numericValue;
@property (nonatomic) bool booleanValue;
@property (nonatomic) const rarch_setting_t* setting;
@ -34,6 +34,9 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
{
_setting = aSetting;
if (!_setting)
return;
switch (aSetting->type)
{
case ST_INT: self.numericValue = @(*(int*)aSetting->value); break;
@ -53,9 +56,30 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
self.stringValue = panel.URL.path;
}
- (IBAction)valueChanged:(id)sender
- (void)setNumericValue:(NSNumber *)numericValue
{
printf("GABOR\n");
_numericValue = numericValue;
if (_setting && _setting->type == ST_INT)
*(int*)_setting->value = [_numericValue intValue];
else if (_setting && _setting->type == ST_FLOAT)
*(float*)_setting->value = [_numericValue floatValue];
}
- (void)setBooleanValue:(bool)booleanValue
{
_booleanValue = booleanValue;
if (_setting && _setting->type == ST_BOOL)
*(bool*)_setting->value = _booleanValue;
}
- (void)setStringValue:(NSString *)stringValue
{
_stringValue = stringValue;
if (_setting && (_setting->type == ST_STRING || _setting->type == ST_PATH))
strlcpy(_setting->value, _stringValue.UTF8String, _setting->size);
}
@end
@ -127,14 +151,15 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
}
}
[self load];
[NSApplication.sharedApplication beginSheet:_window modalForWindow:RetroArch_OSX.get->window modalDelegate:nil didEndSelector:nil contextInfo:nil];
[NSApplication.sharedApplication runModalForWindow:_window];
}
- (IBAction)close:(id)sender
- (void)load
{
#if 0
config_file_t* conf = config_file_new(0);
config_file_t* conf = config_file_new([RetroArch_OSX get].configPath.UTF8String);
for (int i = 0; setting_data[i].type; i ++)
{
switch (setting_data[i].type)
@ -149,7 +174,28 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
}
}
config_file_free(conf);
#endif
}
- (IBAction)close:(id)sender
{
config_file_t* conf = config_file_new(0);
for (int i = 0; setting_data[i].type; i ++)
{
switch (setting_data[i].type)
{
case ST_BOOL: config_set_bool (conf, setting_data[i].name, * (bool*)setting_data[i].value); break;
case ST_INT: config_set_int (conf, setting_data[i].name, * (int*)setting_data[i].value); break;
case ST_FLOAT: config_set_float (conf, setting_data[i].name, *(float*)setting_data[i].value); break;
case ST_PATH: config_set_string(conf, setting_data[i].name, (char*)setting_data[i].value); break;
case ST_STRING: config_set_string(conf, setting_data[i].name, (char*)setting_data[i].value); break;
case ST_HEX: break;
default: break;
}
}
config_file_write(conf, [RetroArch_OSX get].configPath.UTF8String);
config_file_free(conf);
apple_refresh_config();
[NSApplication.sharedApplication stopModal];
[NSApplication.sharedApplication endSheet:_window returnCode:0];