#ifndef settings_h #define settings_h #include #include #define SETTINGS_FILE "sameboy-gtk3-settings.ini" #define FORMAT_FOR_KEY_TYPE(type) KEY_FORMAT_##type #define KEY_FORMAT_string "%s" #define KEY_FORMAT_integer "%d" #define KEY_FORMAT_boolean "%d" #define GTYPE_FOR_KEY_TYPE(type) GTYPE_##type #define GTYPE_string gchar * #define GTYPE_integer gint #define GTYPE_boolean gboolean // 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) \ ) \ 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 #define EXPAND_GROUP_MEMBER(member, key_type) GTYPE_FOR_KEY_TYPE(key_type) member; EXPAND_CONFIG #undef EXPAND_GROUP #undef EXPAND_GROUP_MEMBER } config_t; gchar* settings_file_path; GKeyFile *key_file; config_t config; void print_config(config_t *config); void load_config_from_key_file(config_t *config, GKeyFile *key_file); void init_settings(gchar *path); int load_settings(void); void save_settings(void); void free_settings(void); enum scaling_mode get_scaling_mode(void); void set_scaling_mode(enum scaling_mode); #endif /* settings_h */