aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneonloop2021-08-12 18:52:54 +0000
committerneonloop2021-08-12 18:52:54 +0000
commit95c2f03dca179259a11025b3e773ef705ae4f894 (patch)
tree4a0e06e11280f31333172c041056ca569fb79d71
parent147ce424f9d908cab634942e448200805a5e5430 (diff)
downloadpicoarch-95c2f03dca179259a11025b3e773ef705ae4f894.tar.gz
picoarch-95c2f03dca179259a11025b3e773ef705ae4f894.tar.bz2
picoarch-95c2f03dca179259a11025b3e773ef705ae4f894.zip
Allows core-hidden options
-rw-r--r--config.c14
-rw-r--r--core.c8
-rw-r--r--menu.c7
-rw-r--r--options.c18
-rw-r--r--options.h3
5 files changed, 29 insertions, 21 deletions
diff --git a/config.c b/config.c
index 1d3bce6..e124c81 100644
--- a/config.c
+++ b/config.c
@@ -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);
}
}
diff --git a/core.c b/core.c
index 64741ae..46c038f 100644
--- a/core.c
+++ b/core.c
@@ -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;
diff --git a/menu.c b/menu.c
index d5e606a..ea331cf 100644
--- a/menu.c
+++ b/menu.c
@@ -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;
diff --git a/options.c b/options.c
index 249af71..ba80bd1 100644
--- a/options.c
+++ b/options.c
@@ -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) {
diff --git a/options.h b/options.h
index fde4616..8dcc68b 100644
--- a/options.h
+++ b/options.h
@@ -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);