SameBoy/gtk3/settings.h

83 lines
2.3 KiB
C
Raw Normal View History

#ifndef settings_h
#define settings_h
2019-09-25 20:47:04 +00:00
#include <gtk/gtk.h>
#include <Core/gb.h>
#define SETTINGS_FILE "sameboy-gtk3-settings.ini"
2019-09-25 20:47:04 +00:00
#define FORMAT_FOR_KEY_TYPE(type) FORMAT_FOR_##type
#define FORMAT_FOR_string "%s"
#define FORMAT_FOR_integer "%d"
#define FORMAT_FOR_boolean "%d"
2019-09-25 00:48:07 +00:00
2019-09-25 20:47:04 +00:00
#define GTYPE_OF_KEY_TYPE(type) GTYPE_OF_##type
#define GTYPE_OF_string gchar *
#define GTYPE_OF_integer gint
#define GTYPE_OF_boolean gboolean
#define GTYPE_IS_POINTER(type) GTYPE_IS_POINTER_##type
#define GTYPE_IS_POINTER_string 1
#define GTYPE_IS_POINTER_integer 0
#define GTYPE_IS_POINTER_boolean 0
2019-09-25 00:48:07 +00:00
// Note: Make sure to use a member name only once for the whole config struct
#define EXPAND_CONFIG \
EXPAND_GROUP(Emulation, \
EXPAND_GROUP_MEMBER(boot_rom_path, string) /* overrides search location for boot ROMs by name */ \
EXPAND_GROUP_MEMBER(rewind_duration, integer) \
EXPAND_GROUP_MEMBER(dmg_revision_name, string) \
EXPAND_GROUP_MEMBER(sgb_revision_name, string) \
EXPAND_GROUP_MEMBER(cgb_revision_name, string) \
) \
EXPAND_GROUP(Video, \
EXPAND_GROUP_MEMBER(shader, string) \
EXPAND_GROUP_MEMBER(color_correction_id, string) \
EXPAND_GROUP_MEMBER(keep_aspect_ratio, boolean) \
EXPAND_GROUP_MEMBER(use_integer_scaling, boolean) \
2019-09-25 20:47:04 +00:00
EXPAND_GROUP_MEMBER(menubar_override, string) \
2019-09-25 00:48:07 +00:00
) \
EXPAND_GROUP(Audio, \
EXPAND_GROUP_MEMBER(high_pass_filter_id, string) \
) \
EXPAND_GROUP(Controls, \
\
)
typedef struct config_t {
#define EXPAND_GROUP(group_name, members) members
2019-09-25 20:47:04 +00:00
#define EXPAND_GROUP_MEMBER(member, key_type) GTYPE_OF_KEY_TYPE(key_type) member;
2019-09-25 00:48:07 +00:00
EXPAND_CONFIG
#undef EXPAND_GROUP
#undef EXPAND_GROUP_MEMBER
} config_t;
2019-09-25 20:47:04 +00:00
enum menubar_override {
MENUBAR_AUTO,
MENUBAR_SHOW,
MENUBAR_HIDE
};
2019-09-25 00:48:07 +00:00
gchar* settings_file_path;
GKeyFile *key_file;
2019-09-25 00:48:07 +00:00
config_t config;
void print_config(config_t *config);
void load_config_from_key_file(config_t *config, GKeyFile *key_file);
2019-09-25 20:47:04 +00:00
void init_settings(gchar *path, GtkWindow *preferences);
2019-09-25 00:48:07 +00:00
int load_settings(void);
void save_settings(void);
2019-09-25 00:48:07 +00:00
void free_settings(void);
2019-09-25 20:47:04 +00:00
enum menubar_override get_show_menubar(void);
void set_show_menubar(enum menubar_override);
GB_color_correction_mode_t get_color_correction_mode(void);
void set_color_correction_mode(GB_color_correction_mode_t);
GB_highpass_mode_t get_highpass_mode(void);
void set_highpass_mode(GB_highpass_mode_t);
#endif /* settings_h */