mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 18:35:22 +00:00
(OSX) Some setting menu work
This commit is contained in:
parent
72057ab9be
commit
2c20644ecb
@ -17,6 +17,9 @@
|
||||
#import "../RetroArch/RetroArch_Apple.h"
|
||||
#include "../RetroArch/setting_data.h"
|
||||
|
||||
struct settings fake_settings;
|
||||
struct global fake_extern;
|
||||
|
||||
@interface RASettingsDelegate : NSObject<NSTableViewDataSource, NSTableViewDelegate,
|
||||
NSOutlineViewDataSource, NSOutlineViewDelegate>
|
||||
@end
|
||||
@ -37,6 +40,9 @@
|
||||
NSMutableArray* thisSubGroup = nil;
|
||||
_settings = [NSMutableArray array];
|
||||
|
||||
memcpy(&fake_settings, &g_settings, sizeof(struct settings));
|
||||
memcpy(&fake_extern, &g_extern, sizeof(struct global));
|
||||
|
||||
for (int i = 0; setting_data[i].type; i ++)
|
||||
{
|
||||
switch (setting_data[i].type)
|
||||
@ -83,11 +89,51 @@
|
||||
|
||||
- (IBAction)close:(id)sender
|
||||
{
|
||||
#if 0
|
||||
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_free(conf);
|
||||
#endif
|
||||
|
||||
[NSApplication.sharedApplication stopModal];
|
||||
[NSApplication.sharedApplication endSheet:_window returnCode:0];
|
||||
[_window orderOut:nil];
|
||||
}
|
||||
|
||||
- (void)readConfigFile:(const char*)path
|
||||
{
|
||||
config_file_t* conf = config_file_new(path);
|
||||
if (conf)
|
||||
{
|
||||
for (int i = 0; setting_data[i].type; i ++)
|
||||
{
|
||||
switch (setting_data[i].type)
|
||||
{
|
||||
case ST_BOOL: config_get_bool (conf, setting_data[i].name, (bool*)setting_data[i].value); break;
|
||||
case ST_INT: config_get_int (conf, setting_data[i].name, (int*)setting_data[i].value); break;
|
||||
case ST_FLOAT: config_get_float(conf, setting_data[i].name, (float*)setting_data[i].value); break;
|
||||
case ST_PATH: config_get_array(conf, setting_data[i].name, (char*)setting_data[i].value, setting_data[i].size); break;
|
||||
case ST_STRING: config_get_array(conf, setting_data[i].name, (char*)setting_data[i].value, setting_data[i].size); break;
|
||||
case ST_HEX: break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
config_file_free(conf);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark View Builders
|
||||
- (NSView*)labelAccessoryFor:(NSString*)text onTable:(NSTableView*)table
|
||||
@ -105,7 +151,7 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSView*)booleanAccessoryFor:(const rarch_setting_t*)setting onTable:(NSTableView*)table
|
||||
- (NSView*)booleanAccessoryFor:(const rarch_setting_t*)setting index:(NSNumber*)index onTable:(NSTableView*)table
|
||||
{
|
||||
NSButton* result = [table makeViewWithIdentifier:@"boolean" owner:self];
|
||||
|
||||
@ -114,12 +160,21 @@
|
||||
result = [NSButton new];
|
||||
result.buttonType = NSSwitchButton;
|
||||
result.title = @"";
|
||||
result.target = self;
|
||||
result.action = @selector(booleanChanged:);
|
||||
}
|
||||
|
||||
result.state = *(bool*)setting->value;
|
||||
objc_setAssociatedObject(result, "INDEX", index, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)booleanChanged:(NSButton*)sender
|
||||
{
|
||||
int index = [objc_getAssociatedObject(sender, "INDEX") intValue];
|
||||
*(bool*)setting_data[index].value = sender.state;
|
||||
}
|
||||
|
||||
#pragma mark Section Table
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView*)view
|
||||
{
|
||||
@ -172,7 +227,7 @@
|
||||
{
|
||||
switch (setting->type)
|
||||
{
|
||||
case ST_BOOL: return [self booleanAccessoryFor:setting onTable:outlineView];
|
||||
case ST_BOOL: return [self booleanAccessoryFor:setting index:item onTable:outlineView];
|
||||
|
||||
case ST_PATH:
|
||||
case ST_STRING:
|
||||
|
@ -28,6 +28,7 @@ typedef struct
|
||||
const char* name;
|
||||
|
||||
void* value;
|
||||
uint32_t size;
|
||||
|
||||
const char* short_description;
|
||||
const char* long_description;
|
||||
@ -40,18 +41,25 @@ typedef struct
|
||||
bool allow_blank;
|
||||
} rarch_setting_t;
|
||||
|
||||
#define START_GROUP(NAME) { ST_GROUP, NAME, 0, 0, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define END_GROUP() { ST_END_GROUP, 0, 0, 0, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define START_SUB_GROUP(NAME) { ST_SUB_GROUP, NAME, 0, 0, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define END_SUB_GROUP() { ST_END_SUB_GROUP, 0, 0, 0, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define START_GROUP(NAME) { ST_GROUP, NAME, 0, 0, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define END_GROUP() { ST_END_GROUP, 0, 0, 0, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_BOOL(TARGET, NAME, SHORT) { ST_BOOL, NAME, &TARGET, SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_INT(TARGET, NAME, SHORT) { ST_INT, NAME, &TARGET, SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_FLOAT(TARGET, NAME, SHORT) { ST_FLOAT, NAME, &TARGET, SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_PATH(TARGET, NAME, SHORT) { ST_PATH, NAME, &TARGET, SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_STRING(TARGET, NAME, SHORT) { ST_STRING, NAME, &TARGET, SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_HEX(TARGET, NAME, SHORT) { ST_HEX, NAME, &TARGET, SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
extern struct settings fake_settings;
|
||||
extern struct global fake_extern;
|
||||
|
||||
// HACK
|
||||
#define g_settings fake_settings
|
||||
#define g_extern fake_extern
|
||||
|
||||
#define START_GROUP(NAME) { ST_GROUP, NAME },
|
||||
#define END_GROUP() { ST_END_GROUP },
|
||||
#define START_SUB_GROUP(NAME) { ST_SUB_GROUP, NAME },
|
||||
#define END_SUB_GROUP() { ST_END_SUB_GROUP },
|
||||
#define START_GROUP(NAME) { ST_GROUP, NAME, 0, 0, 0, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define END_GROUP() { ST_END_GROUP, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_BOOL(TARGET, NAME, SHORT) { ST_BOOL, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_INT(TARGET, NAME, SHORT) { ST_INT, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_FLOAT(TARGET, NAME, SHORT) { ST_FLOAT, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_PATH(TARGET, NAME, SHORT) { ST_PATH, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_STRING(TARGET, NAME, SHORT) { ST_STRING, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_HEX(TARGET, NAME, SHORT) { ST_HEX, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
|
||||
const rarch_setting_t setting_data[] =
|
||||
{
|
||||
@ -162,8 +170,8 @@ const rarch_setting_t setting_data[] =
|
||||
/* Input: Overlay */
|
||||
#ifdef HAVE_OVERLAY
|
||||
CONFIG_PATH(g_settings.input.overlay, "input_overlay", "Input Overlay")
|
||||
CONFIG_FLOAT(g_settings.input.overlay_opacity, "overlay_opacity", "Overlay Opacity")
|
||||
CONFIG_FLOAT(g_settings.input.overlay_scale, "overlay_scale", "Overlay Scale")
|
||||
CONFIG_FLOAT(g_settings.input.overlay_opacity, "input_overlay_opacity", "Overlay Opacity")
|
||||
CONFIG_FLOAT(g_settings.input.overlay_scale, "input_overlay_scale", "Overlay Scale")
|
||||
#endif
|
||||
|
||||
/* Input: Android */
|
||||
@ -266,4 +274,8 @@ const rarch_setting_t setting_data[] =
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
// HACK
|
||||
#undef g_settings fake_settings
|
||||
#undef g_extern fake_extern
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user