[GTK3] Rename settings.c to config.c

This commit is contained in:
Maximilian Mader 2020-05-16 16:56:09 +02:00
parent 7e9ebde585
commit 7dbd0e18f9
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
4 changed files with 89 additions and 91 deletions

View File

@ -1,6 +1,6 @@
#include "check_menu_radio_group.h" #include "check_menu_radio_group.h"
void check_menu_item_group_handler(GtkCheckMenuItem *item, CheckMenuItemGroupHandlerData *data) { static void check_menu_item_group_handler(GtkCheckMenuItem *item, CheckMenuItemGroupHandlerData *data) {
bool cancel = false; bool cancel = false;
if (data->handler) { if (data->handler) {

View File

@ -1,9 +1,9 @@
#include "settings.h" #include "config.h"
#define get_object(id) gtk_builder_get_object(builder, id) #define get_object(id) gtk_builder_get_object(builder, id)
#define builder_get(type, id) type(get_object(id)) #define builder_get(type, id) type(get_object(id))
gchar* settings_file_path; gchar* config_file_path;
GKeyFile *key_file; GKeyFile *key_file;
static void print_config_error(GError *error) { static void print_config_error(GError *error) {
@ -113,8 +113,8 @@ void save_config_to_key_file(config_t *config, GKeyFile *key_file) {
#undef EXPAND_GROUP_MEMBER_IF_1 #undef EXPAND_GROUP_MEMBER_IF_1
// Save config to disk // Save config to disk
if (!g_key_file_save_to_file(key_file, settings_file_path, &error)) { if (!g_key_file_save_to_file(key_file, config_file_path, &error)) {
g_warning ("Failed to save %s: %s", settings_file_path, error->message); g_warning ("Failed to save %s: %s", config_file_path, error->message);
g_error_free(error); g_error_free(error);
return; return;
} }
@ -148,26 +148,26 @@ void on_preferences_realize(GtkWidget *w, gpointer builder_ptr) {
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "rumble_mode_selector"), config.controls.rumble_mode); gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "rumble_mode_selector"), config.controls.rumble_mode);
} }
void init_settings(GApplication *app, gchar *path, GDateTime **modification_date, GtkWindow *preferences) { void init_config(GApplication *app, gchar *path, GDateTime **modification_date, GtkWindow *preferences) {
free_settings(); free_config();
key_file = g_key_file_new(); key_file = g_key_file_new();
if (path != NULL) { if (path != NULL) {
settings_file_path = path; config_file_path = path;
} }
else { else {
settings_file_path = g_build_filename(g_get_user_config_dir(), SETTINGS_FILE, NULL); config_file_path = g_build_filename(g_get_user_config_dir(), CONFIG_FILE, NULL);
} }
load_settings(app, modification_date); load_config(app, modification_date);
} }
int load_settings(GApplication *app, GDateTime **modification_date) { void load_config(GApplication *app, GDateTime **modification_date) {
GError *error = NULL; GError *error = NULL;
g_message("Trying to load settings from %s", settings_file_path); g_message("Trying to load config from %s", config_file_path);
g_autoptr(GFile) file = g_file_new_for_path(settings_file_path); g_autoptr(GFile) file = g_file_new_for_path(config_file_path);
g_autoptr(GFileInfo) file_info = g_file_query_info(file, "time::*", G_FILE_QUERY_INFO_NONE, NULL, NULL); g_autoptr(GFileInfo) file_info = g_file_query_info(file, "time::*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
#if GLIB_CHECK_VERSION(2,62,0) #if GLIB_CHECK_VERSION(2,62,0)
@ -178,12 +178,12 @@ int load_settings(GApplication *app, GDateTime **modification_date) {
*modification_date = g_date_time_new_from_timeval_utc(&tv); *modification_date = g_date_time_new_from_timeval_utc(&tv);
#endif #endif
if (!g_key_file_load_from_file(key_file, settings_file_path, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) { if (!g_key_file_load_from_file(key_file, config_file_path, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) {
if (error->domain == G_FILE_ERROR) { if (error->domain == G_FILE_ERROR) {
g_warning("Unable to load %s: %s", settings_file_path, error->message); g_warning("Unable to load %s: %s", config_file_path, error->message);
} }
else if (error->domain == G_KEY_FILE_ERROR) { else if (error->domain == G_KEY_FILE_ERROR) {
g_warning("Failed to parse %s: %s", settings_file_path, error->message); g_warning("Failed to parse %s: %s", config_file_path, error->message);
} }
g_error_free(error); g_error_free(error);
@ -194,16 +194,14 @@ int load_settings(GApplication *app, GDateTime **modification_date) {
// Update GAction states // Update GAction states
g_action_group_change_action_state(G_ACTION_GROUP(app), "toggle_mute", g_variant_new_boolean(config.audio.muted)); g_action_group_change_action_state(G_ACTION_GROUP(app), "toggle_mute", g_variant_new_boolean(config.audio.muted));
return 0;
} }
void save_settings(GtkWindow *main_window, GDateTime *saved_modification_date) { void save_config(GtkWindow *main_window, GDateTime *saved_modification_date) {
GError *error = NULL; GError *error = NULL;
g_message("Trying to save settings to %s", settings_file_path); g_message("Trying to save config to %s", config_file_path);
g_autoptr(GFile) file = g_file_new_for_path(settings_file_path); g_autoptr(GFile) file = g_file_new_for_path(config_file_path);
g_autoptr(GFileInfo) file_info = g_file_query_info(file, "time::*", G_FILE_QUERY_INFO_NONE, NULL, NULL); g_autoptr(GFileInfo) file_info = g_file_query_info(file, "time::*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
#if GLIB_CHECK_VERSION(2,62,0) #if GLIB_CHECK_VERSION(2,62,0)
@ -242,7 +240,7 @@ void save_settings(GtkWindow *main_window, GDateTime *saved_modification_date) {
} }
} }
void free_settings(void) { void free_config(void) {
if (key_file != NULL) { if (key_file != NULL) {
g_key_file_free(key_file); g_key_file_free(key_file);
key_file = NULL; key_file = NULL;
@ -264,7 +262,7 @@ void update_boot_rom_selector(GtkBuilder *builder) {
gtk_combo_box_text_append(combo_box, "other", "Other"); gtk_combo_box_text_append(combo_box, "other", "Other");
} }
GB_color_correction_mode_t get_color_correction_mode(void) { GB_color_correction_mode_t config_get_color_correction_mode(void) {
if (config.video.color_correction_id == NULL) goto default_value; if (config.video.color_correction_id == NULL) goto default_value;
if (g_strcmp0(config.video.color_correction_id, "disabled") == 0) { if (g_strcmp0(config.video.color_correction_id, "disabled") == 0) {
@ -288,7 +286,7 @@ GB_color_correction_mode_t get_color_correction_mode(void) {
default_value: return GB_COLOR_CORRECTION_EMULATE_HARDWARE; default_value: return GB_COLOR_CORRECTION_EMULATE_HARDWARE;
} }
void set_color_correction_mode(GB_color_correction_mode_t mode) { void config_set_color_correction_mode(GB_color_correction_mode_t mode) {
switch (mode) { switch (mode) {
case GB_COLOR_CORRECTION_DISABLED: case GB_COLOR_CORRECTION_DISABLED:
config.video.color_correction_id = "disabled"; config.video.color_correction_id = "disabled";
@ -308,7 +306,7 @@ void set_color_correction_mode(GB_color_correction_mode_t mode) {
} }
} }
GB_frame_blending_mode_t get_frame_blending_mode(void) { GB_frame_blending_mode_t config_get_frame_blending_mode(void) {
if (config.video.frame_blending_mode == NULL) goto default_value; if (config.video.frame_blending_mode == NULL) goto default_value;
if (g_strcmp0(config.video.frame_blending_mode, "disabled") == 0) { if (g_strcmp0(config.video.frame_blending_mode, "disabled") == 0) {
@ -326,7 +324,7 @@ GB_frame_blending_mode_t get_frame_blending_mode(void) {
default_value: return GB_FRAME_BLENDING_MODE_DISABLED; default_value: return GB_FRAME_BLENDING_MODE_DISABLED;
} }
void set_frame_blending_mode(GB_frame_blending_mode_t mode) { void config_set_frame_blending_mode(GB_frame_blending_mode_t mode) {
switch (mode) { switch (mode) {
case GB_FRAME_BLENDING_MODE_DISABLED: case GB_FRAME_BLENDING_MODE_DISABLED:
config.video.frame_blending_mode = "disabled"; config.video.frame_blending_mode = "disabled";
@ -341,7 +339,7 @@ void set_frame_blending_mode(GB_frame_blending_mode_t mode) {
} }
} }
GB_border_mode_t get_display_border_mode(void) { GB_border_mode_t config_get_display_border_mode(void) {
if (config.video.display_border_mode == NULL) goto default_value; if (config.video.display_border_mode == NULL) goto default_value;
if (g_strcmp0(config.video.display_border_mode, "never") == 0) { if (g_strcmp0(config.video.display_border_mode, "never") == 0) {
@ -359,7 +357,7 @@ GB_border_mode_t get_display_border_mode(void) {
default_value: return GB_BORDER_NEVER; default_value: return GB_BORDER_NEVER;
} }
void set_display_border_mode(GB_border_mode_t mode) { void config_set_display_border_mode(GB_border_mode_t mode) {
switch (mode) { switch (mode) {
case GB_BORDER_NEVER: case GB_BORDER_NEVER:
config.video.display_border_mode = "never"; config.video.display_border_mode = "never";
@ -373,7 +371,7 @@ void set_display_border_mode(GB_border_mode_t mode) {
} }
} }
const GB_palette_t* get_monochrome_palette(void) { const GB_palette_t* config_get_monochrome_palette(void) {
if (config.video.monochrome_palette_id == NULL) goto default_value; if (config.video.monochrome_palette_id == NULL) goto default_value;
if (g_strcmp0(config.video.monochrome_palette_id, "greyscale") == 0) { if (g_strcmp0(config.video.monochrome_palette_id, "greyscale") == 0) {
@ -394,7 +392,7 @@ const GB_palette_t* get_monochrome_palette(void) {
default_value: return &GB_PALETTE_GREY; default_value: return &GB_PALETTE_GREY;
} }
void set_monochrome_palette(const GB_palette_t *mode) { void config_set_monochrome_palette(const GB_palette_t *mode) {
g_message("%p | %p | %p | %p | %p", mode, &GB_PALETTE_GREY, &GB_PALETTE_DMG, &GB_PALETTE_MGB, &GB_PALETTE_GBL); g_message("%p | %p | %p | %p | %p", mode, &GB_PALETTE_GREY, &GB_PALETTE_DMG, &GB_PALETTE_MGB, &GB_PALETTE_GBL);
if (mode == &GB_PALETTE_GREY) { if (mode == &GB_PALETTE_GREY) {
@ -411,7 +409,7 @@ void set_monochrome_palette(const GB_palette_t *mode) {
} }
} }
GB_highpass_mode_t get_highpass_mode(void) { GB_highpass_mode_t config_get_highpass_mode(void) {
if (config.audio.high_pass_filter_id == NULL) goto default_value; if (config.audio.high_pass_filter_id == NULL) goto default_value;
if (g_strcmp0(config.audio.high_pass_filter_id, "disabled") == 0) { if (g_strcmp0(config.audio.high_pass_filter_id, "disabled") == 0) {
@ -429,7 +427,7 @@ GB_highpass_mode_t get_highpass_mode(void) {
default_value: return GB_HIGHPASS_ACCURATE; default_value: return GB_HIGHPASS_ACCURATE;
} }
void set_highpass_mode(GB_highpass_mode_t mode) { void config_set_highpass_mode(GB_highpass_mode_t mode) {
switch (mode) { switch (mode) {
case GB_HIGHPASS_OFF: case GB_HIGHPASS_OFF:
config.audio.high_pass_filter_id = "disabled"; config.audio.high_pass_filter_id = "disabled";
@ -445,7 +443,7 @@ void set_highpass_mode(GB_highpass_mode_t mode) {
} }
} }
const GB_rumble_mode_t get_rumble_mode(void) { const GB_rumble_mode_t config_get_rumble_mode(void) {
if (config.controls.rumble_mode == NULL) goto default_value; if (config.controls.rumble_mode == NULL) goto default_value;
if (g_strcmp0(config.controls.rumble_mode, "never") == 0) { if (g_strcmp0(config.controls.rumble_mode, "never") == 0) {
@ -463,7 +461,7 @@ const GB_rumble_mode_t get_rumble_mode(void) {
default_value: return GB_RUMBLE_DISABLED; default_value: return GB_RUMBLE_DISABLED;
} }
void set_rumble_mode(GB_rumble_mode_t mode) { void config_set_rumble_mode(GB_rumble_mode_t mode) {
switch (mode) { switch (mode) {
case GB_RUMBLE_DISABLED: case GB_RUMBLE_DISABLED:
config.controls.rumble_mode = "never"; config.controls.rumble_mode = "never";
@ -477,26 +475,26 @@ void set_rumble_mode(GB_rumble_mode_t mode) {
} }
} }
GB_model_t get_model(void) { GB_model_t config_get_model(void) {
if (g_strcmp0(config.emulation.model, "DMG") == 0) { if (g_strcmp0(config.emulation.model, "DMG") == 0) {
return get_dmg_model(); return config_get_dmg_model();
} }
else if (g_strcmp0(config.emulation.model, "MGB") == 0) { else if (g_strcmp0(config.emulation.model, "MGB") == 0) {
g_warning("Emulation of MGBs is unsupported, falling back to DMG."); g_warning("Emulation of MGBs is unsupported, falling back to DMG.");
return get_dmg_model(); return config_get_dmg_model();
} }
else if (g_strcmp0(config.emulation.model, "AGB") == 0) { else if (g_strcmp0(config.emulation.model, "AGB") == 0) {
return GB_MODEL_AGB; return GB_MODEL_AGB;
} }
else if (g_strcmp0(config.emulation.model, "SGB") == 0) { else if (g_strcmp0(config.emulation.model, "SGB") == 0) {
return get_sgb_model(); return config_get_sgb_model();
} }
return get_cgb_model(); return config_get_cgb_model();
} }
void set_model(GB_model_t model) { void config_set_model(GB_model_t model) {
switch (model & GB_MODEL_FAMILY_MASK) { switch (model & GB_MODEL_FAMILY_MASK) {
case GB_MODEL_DMG_FAMILY: case GB_MODEL_DMG_FAMILY:
if (model & GB_MODEL_SGB) { if (model & GB_MODEL_SGB) {
@ -522,7 +520,7 @@ void set_model(GB_model_t model) {
} }
} }
GB_model_t get_dmg_model(void) { GB_model_t config_get_dmg_model(void) {
if (config.emulation.dmg_revision_name == NULL) goto default_value; if (config.emulation.dmg_revision_name == NULL) goto default_value;
// TODO: Synchronize with GB_model_t (Core/gb.h) // TODO: Synchronize with GB_model_t (Core/gb.h)
@ -533,7 +531,7 @@ GB_model_t get_dmg_model(void) {
default_value: return GB_MODEL_DMG_B; default_value: return GB_MODEL_DMG_B;
} }
GB_model_t get_sgb_model(void) { GB_model_t config_get_sgb_model(void) {
if (config.emulation.sgb_revision_name == NULL) goto default_value; if (config.emulation.sgb_revision_name == NULL) goto default_value;
// TODO: Synchronize with GB_model_t (Core/gb.h) // TODO: Synchronize with GB_model_t (Core/gb.h)
@ -550,7 +548,7 @@ GB_model_t get_sgb_model(void) {
default_value: return GB_MODEL_SGB2; default_value: return GB_MODEL_SGB2;
} }
GB_model_t get_cgb_model(void) { GB_model_t config_get_cgb_model(void) {
if (config.emulation.cgb_revision_name == NULL) goto default_value; if (config.emulation.cgb_revision_name == NULL) goto default_value;
// TODO: Synchronize with GB_model_t (Core/gb.h) // TODO: Synchronize with GB_model_t (Core/gb.h)

View File

@ -1,11 +1,11 @@
#ifndef settings_h #ifndef config_h
#define settings_h #define config_h
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <Core/gb.h> #include <Core/gb.h>
#include "shader.h" #include "shader.h"
#define SETTINGS_FILE "sameboy-gtk3-settings.ini" #define CONFIG_FILE "sameboy-gtk3.ini"
#define FORMAT_FOR_KEY_TYPE(type) FORMAT_FOR_##type #define FORMAT_FOR_KEY_TYPE(type) FORMAT_FOR_##type
#define FORMAT_FOR_string "%s" #define FORMAT_FOR_string "%s"
@ -76,36 +76,36 @@ void on_preferences_realize(GtkWidget *w, gpointer builder_ptr);
void print_config(config_t *config); void print_config(config_t *config);
void load_config_from_key_file(config_t *config, GKeyFile *key_file); void load_config_from_key_file(config_t *config, GKeyFile *key_file);
void init_settings(GApplication *app, gchar *path, GDateTime **modification_date, GtkWindow *preferences); void init_config(GApplication *app, gchar *path, GDateTime **modification_date, GtkWindow *preferences);
int load_settings(GApplication *app, GDateTime **modification_date); void load_config(GApplication *app, GDateTime **modification_date);
void save_settings(GtkWindow *main_window, GDateTime *saved_modification_date); void save_config(GtkWindow *main_window, GDateTime *saved_modification_date);
void free_settings(void); void free_config(void);
void update_boot_rom_selector(GtkBuilder *builder); void update_boot_rom_selector(GtkBuilder *builder);
GB_color_correction_mode_t get_color_correction_mode(void); GB_color_correction_mode_t config_get_color_correction_mode(void);
void set_color_correction_mode(GB_color_correction_mode_t); void config_set_color_correction_mode(GB_color_correction_mode_t);
GB_frame_blending_mode_t get_frame_blending_mode(void); GB_frame_blending_mode_t config_get_frame_blending_mode(void);
void set_frame_blending_mode(GB_frame_blending_mode_t); void config_set_frame_blending_mode(GB_frame_blending_mode_t);
GB_border_mode_t get_display_border_mode(void); GB_border_mode_t config_get_display_border_mode(void);
void set_display_border_mode(GB_border_mode_t); void config_set_display_border_mode(GB_border_mode_t);
GB_highpass_mode_t get_highpass_mode(void); GB_highpass_mode_t config_get_highpass_mode(void);
void set_highpass_mode(GB_highpass_mode_t); void config_set_highpass_mode(GB_highpass_mode_t);
const GB_palette_t* get_monochrome_palette(void); const GB_palette_t* config_get_monochrome_palette(void);
void set_monochrome_palette(const GB_palette_t*); void config_set_monochrome_palette(const GB_palette_t*);
const GB_rumble_mode_t get_rumble_mode(void); const GB_rumble_mode_t config_get_rumble_mode(void);
void set_rumble_mode(const GB_rumble_mode_t); void config_set_rumble_mode(const GB_rumble_mode_t);
void set_model(GB_model_t model); void config_set_model(GB_model_t model);
GB_model_t get_model(void); GB_model_t config_get_model(void);
GB_model_t get_dmg_model(void); GB_model_t config_get_dmg_model(void);
GB_model_t get_sgb_model(void); GB_model_t config_get_sgb_model(void);
GB_model_t get_cgb_model(void); GB_model_t config_get_cgb_model(void);
#endif /* settings_h */ #endif /* config_h */

View File

@ -9,7 +9,7 @@
#include <Core/gb.h> #include <Core/gb.h>
#include "settings.h" #include "config.h"
#include "shader.h" #include "shader.h"
#include "check_menu_radio_group.h" #include "check_menu_radio_group.h"
@ -564,12 +564,12 @@ static gboolean init_audio(void) {
return gui_data.audio_initialized = true; return gui_data.audio_initialized = true;
} }
static GB_model_t get_model_type(void) { static GB_model_t config_get_model_type(void) {
if (gui_data.cli_options.model != -1) { if (gui_data.cli_options.model != -1) {
return gui_data.cli_options.model; return gui_data.cli_options.model;
} }
return get_model(); return config_get_model();
} }
static void gb_audio_callback(GB_gameboy_t *gb, GB_sample_t *sample) { static void gb_audio_callback(GB_gameboy_t *gb, GB_sample_t *sample) {
@ -917,7 +917,7 @@ static void set_combo_box_row_separator_func(GtkContainer *container) {
static unsigned char number_of_buffers(void) { static unsigned char number_of_buffers(void) {
if (gui_data.fallback_canvas) return 2; if (gui_data.fallback_canvas) return 2;
bool should_blend = get_frame_blending_mode() != GB_FRAME_BLENDING_MODE_DISABLED; bool should_blend = config_get_frame_blending_mode() != GB_FRAME_BLENDING_MODE_DISABLED;
return should_blend? 3 : 2; return should_blend? 3 : 2;
} }
@ -1205,7 +1205,7 @@ static void vblank(GB_gameboy_t *gb) {
flip(); flip();
if (gui_data.border_mode_changed) { if (gui_data.border_mode_changed) {
GB_set_border_mode(gb, get_display_border_mode()); GB_set_border_mode(gb, config_get_display_border_mode());
update_window_geometry(); update_window_geometry();
gui_data.border_mode_changed = false; gui_data.border_mode_changed = false;
@ -1460,14 +1460,14 @@ static void load_boot_rom(GB_gameboy_t *gb, GB_boot_rom_t type) {
static void init(void) { static void init(void) {
if (GB_is_inited(&gb)) return; if (GB_is_inited(&gb)) return;
GB_init(&gb, get_model_type()); GB_init(&gb, config_get_model_type());
GB_set_vblank_callback(&gb, vblank); GB_set_vblank_callback(&gb, vblank);
GB_set_pixels_output(&gb, get_current_buffer()); GB_set_pixels_output(&gb, get_current_buffer());
GB_set_rgb_encode_callback(&gb, rgb_encode); GB_set_rgb_encode_callback(&gb, rgb_encode);
GB_set_sample_rate(&gb, GB_audio_get_sample_rate()); GB_set_sample_rate(&gb, GB_audio_get_sample_rate());
GB_set_color_correction_mode(&gb, get_color_correction_mode()); GB_set_color_correction_mode(&gb, config_get_color_correction_mode());
GB_set_highpass_filter_mode(&gb, get_highpass_mode()); GB_set_highpass_filter_mode(&gb, config_get_highpass_mode());
GB_set_rewind_length(&gb, config.emulation.rewind_duration); GB_set_rewind_length(&gb, config.emulation.rewind_duration);
GB_set_update_input_hint_callback(&gb, handle_events); GB_set_update_input_hint_callback(&gb, handle_events);
GB_apu_set_sample_callback(&gb, gb_audio_callback); GB_apu_set_sample_callback(&gb, gb_audio_callback);
@ -1477,18 +1477,18 @@ static void init(void) {
GB_set_boot_rom_load_callback(&gb, load_boot_rom); GB_set_boot_rom_load_callback(&gb, load_boot_rom);
GB_set_rumble_callback(&gb, rumble_callback); GB_set_rumble_callback(&gb, rumble_callback);
GB_set_rumble_mode(&gb, get_rumble_mode()); GB_set_rumble_mode(&gb, config_get_rumble_mode());
if (get_display_border_mode() <= GB_BORDER_ALWAYS) { if (config_get_display_border_mode() <= GB_BORDER_ALWAYS) {
GB_set_border_mode(&gb, get_display_border_mode()); GB_set_border_mode(&gb, config_get_display_border_mode());
} }
update_window_geometry(); update_window_geometry();
} }
static void reset(void) { static void reset(void) {
g_debug("Reset: %d == %d", get_model_type(), gui_data.prev_model); g_debug("Reset: %d == %d", config_get_model_type(), gui_data.prev_model);
GB_model_t current_model = get_model_type(); GB_model_t current_model = config_get_model_type();
if (gui_data.prev_model == -1 || gui_data.prev_model == current_model) { if (gui_data.prev_model == -1 || gui_data.prev_model == current_model) {
GB_reset(&gb); GB_reset(&gb);
@ -1497,9 +1497,9 @@ static void reset(void) {
GB_switch_model_and_reset(&gb, current_model); GB_switch_model_and_reset(&gb, current_model);
} }
GB_set_palette(&gb, get_monochrome_palette()); GB_set_palette(&gb, config_get_monochrome_palette());
gui_data.prev_model = get_model_type(); gui_data.prev_model = config_get_model_type();
// Check SGB -> non-SGB and non-SGB to SGB transitions // Check SGB -> non-SGB and non-SGB to SGB transitions
if (GB_get_screen_width(&gb) != gui_data.last_screen_width || GB_get_screen_height(&gb) != gui_data.last_screen_height) { if (GB_get_screen_width(&gb) != gui_data.last_screen_width || GB_get_screen_height(&gb) != gui_data.last_screen_height) {
@ -1652,8 +1652,8 @@ static void quit(void) {
while (gui_data.stopping); while (gui_data.stopping);
GtkWindow *window = gui_data.main_window ? GTK_WINDOW(gui_data.main_window) : NULL; GtkWindow *window = gui_data.main_window ? GTK_WINDOW(gui_data.main_window) : NULL;
save_settings(window, gui_data.config_modification_date); save_config(window, gui_data.config_modification_date);
free_settings(); free_config();
for (unsigned i = 0; i < gui_data.controller_count; i++) { for (unsigned i = 0; i < gui_data.controller_count; i++) {
struct Controller_t *s = &gui_data.controllers[i]; struct Controller_t *s = &gui_data.controllers[i];
@ -2019,7 +2019,7 @@ static void startup(GApplication *app, gpointer null_ptr) {
gui_data.preferences = GTK_WINDOW(get_object("preferences")); gui_data.preferences = GTK_WINDOW(get_object("preferences"));
g_signal_connect(gui_data.preferences, "realize", G_CALLBACK(on_preferences_realize), (gpointer) gui_data.builder); g_signal_connect(gui_data.preferences, "realize", G_CALLBACK(on_preferences_realize), (gpointer) gui_data.builder);
init_settings(app, gui_data.cli_options.config_path, &gui_data.config_modification_date, gui_data.preferences); init_config(app, gui_data.cli_options.config_path, &gui_data.config_modification_date, gui_data.preferences);
gui_data.vram_viewer = GTK_WINDOW(get_object("vram_viewer")); gui_data.vram_viewer = GTK_WINDOW(get_object("vram_viewer"));
gui_data.memory_viewer = GTK_WINDOW(get_object("memory_viewer")); gui_data.memory_viewer = GTK_WINDOW(get_object("memory_viewer"));
@ -2173,7 +2173,7 @@ static void gl_draw(void) {
glClearColor(0, 0, 0, 1); glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
GB_frame_blending_mode_t mode = get_frame_blending_mode(); GB_frame_blending_mode_t mode = config_get_frame_blending_mode();
if (!previous) { if (!previous) {
mode = GB_FRAME_BLENDING_MODE_DISABLED; mode = GB_FRAME_BLENDING_MODE_DISABLED;
} }
@ -2579,7 +2579,7 @@ G_MODULE_EXPORT void on_color_correction_changed(GtkWidget *w, gpointer user_dat
config.video.color_correction_id = (gchar *)gtk_combo_box_get_active_id(box); config.video.color_correction_id = (gchar *)gtk_combo_box_get_active_id(box);
if (GB_is_inited(&gb)) { if (GB_is_inited(&gb)) {
GB_set_color_correction_mode(&gb, get_color_correction_mode()); GB_set_color_correction_mode(&gb, config_get_color_correction_mode());
} }
} }
@ -2599,7 +2599,7 @@ G_MODULE_EXPORT void on_monochrome_palette_changed(GtkWidget *w, gpointer user_d
GtkComboBox *box = GTK_COMBO_BOX(w); GtkComboBox *box = GTK_COMBO_BOX(w);
config.video.monochrome_palette_id = (gchar *)gtk_combo_box_get_active_id(box); config.video.monochrome_palette_id = (gchar *)gtk_combo_box_get_active_id(box);
GB_set_palette(&gb, get_monochrome_palette()); GB_set_palette(&gb, config_get_monochrome_palette());
} }
G_MODULE_EXPORT void on_dmg_model_changed(GtkWidget *w, gpointer user_data_ptr) { G_MODULE_EXPORT void on_dmg_model_changed(GtkWidget *w, gpointer user_data_ptr) {
@ -2619,7 +2619,7 @@ G_MODULE_EXPORT void on_highpass_filter_changed(GtkWidget *w, gpointer user_data
config.audio.high_pass_filter_id = (gchar *)gtk_combo_box_get_active_id(GTK_COMBO_BOX(w)); config.audio.high_pass_filter_id = (gchar *)gtk_combo_box_get_active_id(GTK_COMBO_BOX(w));
if (GB_is_inited(&gb)) { if (GB_is_inited(&gb)) {
GB_set_highpass_filter_mode(&gb, get_highpass_mode()); GB_set_highpass_filter_mode(&gb, config_get_highpass_mode());
} }
} }
@ -2695,7 +2695,7 @@ G_MODULE_EXPORT void on_rumble_mode_changed(GtkWidget *w, gpointer user_data_ptr
GtkComboBox *box = GTK_COMBO_BOX(w); GtkComboBox *box = GTK_COMBO_BOX(w);
config.controls.rumble_mode = (gchar *)gtk_combo_box_get_active_id(box); config.controls.rumble_mode = (gchar *)gtk_combo_box_get_active_id(box);
GB_set_rumble_mode(&gb, get_rumble_mode()); GB_set_rumble_mode(&gb, config_get_rumble_mode());
} }
G_MODULE_EXPORT void on_analog_speed_controls_changed(GtkWidget *w, gpointer user_data_ptr) { G_MODULE_EXPORT void on_analog_speed_controls_changed(GtkWidget *w, gpointer user_data_ptr) {