diff options
author | neonloop | 2021-08-12 18:52:54 +0000 |
---|---|---|
committer | neonloop | 2021-08-12 18:52:54 +0000 |
commit | 95c2f03dca179259a11025b3e773ef705ae4f894 (patch) | |
tree | 4a0e06e11280f31333172c041056ca569fb79d71 | |
parent | 147ce424f9d908cab634942e448200805a5e5430 (diff) | |
download | picoarch-95c2f03dca179259a11025b3e773ef705ae4f894.tar.gz picoarch-95c2f03dca179259a11025b3e773ef705ae4f894.tar.bz2 picoarch-95c2f03dca179259a11025b3e773ef705ae4f894.zip |
Allows core-hidden options
-rw-r--r-- | config.c | 14 | ||||
-rw-r--r-- | core.c | 8 | ||||
-rw-r--r-- | menu.c | 7 | ||||
-rw-r--r-- | options.c | 18 | ||||
-rw-r--r-- | options.h | 3 |
5 files changed, 29 insertions, 21 deletions
@@ -46,9 +46,9 @@ void config_write(FILE *f) } for (size_t i = 0; i < core_options.len; i++) { - const char* k = options_get_key(i); - if (!options_is_blocked(k)) - fprintf(f, "%s = %s\n", k, options_get_value(k)); + struct core_option_entry *entry = &core_options.entries[i]; + if (!entry->blocked) + fprintf(f, "%s = %s\n", entry->key, options_get_value(entry->key)); } } @@ -106,15 +106,15 @@ void config_read(const char* cfg) for (size_t i = 0; i < core_options.len; i++) { char value[256] = {0}; - const char *key = options_get_key(i); - if (options_is_blocked(key)) + struct core_option_entry *entry = &core_options.entries[i]; + if (entry->blocked) continue; - char *tmp = config_find_value(cfg, key); + char *tmp = config_find_value(cfg, entry->key); if (!tmp) continue; parse_str_val(value, tmp); - options_set_value(key, value); + options_set_value(entry->key, value); } } @@ -337,6 +337,14 @@ static bool pa_environment(unsigned cmd, void *data) { } break; } + case RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY: { /* 55 */ + const struct retro_core_option_display *display = + (const struct retro_core_option_display *)data; + + if (display) + options_set_visible(display->key, display->visible); + break; + } case RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK: { /* 62 */ const struct retro_audio_buffer_status_callback *cb = (const struct retro_audio_buffer_status_callback *)data; @@ -201,14 +201,13 @@ static int menu_loop_core_options_page(int offset, int keys) { } for (i = offset, menu_idx = 0; i < core_options.len && menu_idx < CORE_OPTIONS_PER_PAGE; i++) { - struct core_option_entry *entry; + struct core_option_entry *entry = &core_options.entries[i]; menu_entry *option; - const char *key = options_get_key(i); + const char *key = entry->key; - if (options_is_blocked(key)) + if (entry->blocked || !entry->visible) continue; - entry = options_get_entry(key); option = &e_menu_core_options[menu_idx]; option->name = entry->desc; @@ -128,6 +128,7 @@ void options_init(const struct retro_core_option_definition *defs) { entry->blocked = option_blocked(def->key); if (entry->blocked) core_options.visible_len--; + entry->visible = true; len = strlen(def->desc) + 1; entry->desc = (char *)calloc(len, sizeof(char)); @@ -243,6 +244,7 @@ void options_init_variables(const struct retro_variable *vars) { if (entry->blocked) core_options.visible_len--; + entry->visible = true; len = strlen(var->value) + 1; value = (char *)calloc(len, sizeof(char)); if (!value) { @@ -332,15 +334,6 @@ struct core_option_entry* options_get_entry(const char* key) { return NULL; } - -bool options_is_blocked(const char *key) { - struct core_option_entry* entry = options_get_entry(key); - if (entry) { - return entry->blocked; - } - return true; -} - const char* options_get_value(const char* key) { struct core_option_entry* entry = options_get_entry(key); if (entry) @@ -389,6 +382,13 @@ void options_set_value_index(const char* key, int value) { } } +void options_set_visible(const char* key, bool visible) { + struct core_option_entry* entry = options_get_entry(key); + if (entry) { + entry->visible = visible; + } +} + const char** options_get_options(const char* key) { struct core_option_entry* entry = options_get_entry(key); if (entry) { @@ -18,6 +18,7 @@ struct core_option_entry { int prev_value; int default_value; bool blocked; + bool visible; char **values; char **labels; char *retro_var_value; @@ -39,7 +40,6 @@ void options_update_changed(void); const char* options_get_key(int index); struct core_option_entry* options_get_entry(const char* key); -bool options_is_blocked(const char *key); const char* options_get_value(const char* key); int* options_get_value_ptr(const char* key); @@ -47,6 +47,7 @@ int options_get_value_index(const char* key); void options_set_value(const char* key, const char *value); void options_set_value_index(const char* key, int value); +void options_set_visible(const char* key, bool visible); const char** options_get_options(const char* key); void options_free(void); |