28 if(entry == NULL)
return default_value;
39 value = mape_preferences_read_int(file, key, default_value);
41 if(value < lower_bound) value = lower_bound;
42 if(value > upper_bound) value = upper_bound;
47 static gboolean mape_preferences_read_boolean(
MapeConfigFile* file,
49 gboolean default_value)
55 if(entry == NULL)
return default_value;
58 if(g_strcasecmp(value,
"0") == 0 || g_strcasecmp(value,
"off") == 0 ||
59 g_strcasecmp(value,
"false") == 0)
return FALSE;
78 const gchar*
text =
"true";
79 if(value == FALSE)
text =
"false";
87 preferences->
tab_width = mape_preferences_read_ranged_int(
88 config,
"tab_width", 1, 8, 2);
90 config,
"tab_to_spaces", TRUE);
92 config,
"auto_indentation", TRUE);
94 config,
"text_wrapping", TRUE);
95 preferences->
line_numbers = mape_preferences_read_boolean(
96 config,
"line_numbers", TRUE);
98 config,
"highlight_line", TRUE);
100 config,
"bracket_matching", TRUE);
101 preferences->
fixed_seed = mape_preferences_read_boolean(
102 config,
"fixed_seed", FALSE);
103 preferences->
random_seed = mape_preferences_read_ranged_int(
104 config,
"random_seed", 0, (1u << 31u) - 1, rand() );
105 preferences->
map_width = mape_preferences_read_ranged_int(
106 config,
"map_width", 50, 500, 150);
107 preferences->
map_height = mape_preferences_read_ranged_int(
108 config,
"map_height", 50, 500, 150);
109 preferences->
map_zoom = mape_preferences_read_ranged_int(
110 config,
"map_zoom", 20, 500, 100) / 100.;
116 mape_preferences_write_int(
117 config,
"tab_width", preferences->
tab_width);
118 mape_preferences_write_boolean(
120 mape_preferences_write_boolean(
122 mape_preferences_write_boolean(
124 mape_preferences_write_boolean(
126 mape_preferences_write_boolean(
128 mape_preferences_write_boolean(
130 mape_preferences_write_boolean(
131 config,
"fixed_seed", preferences->
fixed_seed);
132 mape_preferences_write_int(
134 mape_preferences_write_int(
135 config,
"map_width", preferences->
map_width);
136 mape_preferences_write_int(
137 config,
"map_height", preferences->
map_height);
138 mape_preferences_write_int(
139 config,
"map_zoom", (
int)(preferences->
map_zoom * 100 + 0.5));
const gchar * mape_config_file_entry_get_value(MapeConfigFileEntry *entry)
void mape_config_file_set_entry(MapeConfigFile *file, const gchar *key, const gchar *value)
MapeConfigFileEntry * mape_config_file_get_entry_by_key(MapeConfigFile *file, const gchar *key)
void mape_preferences_from_config(MapePreferences *preferences, MapeConfigFile *config)
void mape_preferences_to_config(MapePreferences *preferences, MapeConfigFile *config)
gboolean auto_indentation
gboolean bracket_matching