OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
preferences.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "mape/configfile.h"
#include "mape/preferences.h"
Include dependency graph for preferences.c:

Go to the source code of this file.

Functions

void mape_preferences_from_config (MapePreferences *preferences, MapeConfigFile *config)
 
void mape_preferences_to_config (MapePreferences *preferences, MapeConfigFile *config)
 

Function Documentation

void mape_preferences_from_config ( MapePreferences preferences,
MapeConfigFile config 
)

Definition at line 84 of file preferences.c.

References MapePreferences_::auto_indentation, MapePreferences_::bracket_matching, MapePreferences_::fixed_seed, MapePreferences_::highlight_line, MapePreferences_::line_numbers, MapePreferences_::map_height, MapePreferences_::map_width, MapePreferences_::map_zoom, MapePreferences_::random_seed, MapePreferences_::tab_to_spaces, MapePreferences_::tab_width, and MapePreferences_::text_wrapping.

Referenced by mape_window_new().

86 {
87  preferences->tab_width = mape_preferences_read_ranged_int(
88  config, "tab_width", 1, 8, 2);
89  preferences->tab_to_spaces = mape_preferences_read_boolean(
90  config, "tab_to_spaces", TRUE);
91  preferences->auto_indentation = mape_preferences_read_boolean(
92  config, "auto_indentation", TRUE);
93  preferences->text_wrapping = mape_preferences_read_boolean(
94  config, "text_wrapping", TRUE);
95  preferences->line_numbers = mape_preferences_read_boolean(
96  config, "line_numbers", TRUE);
97  preferences->highlight_line = mape_preferences_read_boolean(
98  config, "highlight_line", TRUE);
99  preferences->bracket_matching = mape_preferences_read_boolean(
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.;
111 }
gboolean line_numbers
Definition: preferences.h:27
unsigned int tab_width
Definition: preferences.h:23
gboolean highlight_line
Definition: preferences.h:28
gboolean tab_to_spaces
Definition: preferences.h:24
gboolean auto_indentation
Definition: preferences.h:25
gboolean text_wrapping
Definition: preferences.h:26
unsigned int random_seed
Definition: preferences.h:31
gboolean bracket_matching
Definition: preferences.h:29
unsigned int map_width
Definition: preferences.h:32
gboolean fixed_seed
Definition: preferences.h:30
unsigned int map_height
Definition: preferences.h:33

Here is the caller graph for this function:

void mape_preferences_to_config ( MapePreferences preferences,
MapeConfigFile config 
)

Definition at line 113 of file preferences.c.

References MapePreferences_::auto_indentation, MapePreferences_::bracket_matching, MapePreferences_::fixed_seed, MapePreferences_::highlight_line, MapePreferences_::line_numbers, MapePreferences_::map_height, MapePreferences_::map_width, MapePreferences_::map_zoom, MapePreferences_::random_seed, MapePreferences_::tab_to_spaces, MapePreferences_::tab_width, and MapePreferences_::text_wrapping.

115 {
116  mape_preferences_write_int(
117  config, "tab_width", preferences->tab_width);
118  mape_preferences_write_boolean(
119  config, "tab_to_spaces", preferences->tab_to_spaces);
120  mape_preferences_write_boolean(
121  config, "auto_indentation", preferences->auto_indentation);
122  mape_preferences_write_boolean(
123  config, "text_wrapping", preferences->text_wrapping);
124  mape_preferences_write_boolean(
125  config, "line_numbers", preferences->line_numbers);
126  mape_preferences_write_boolean(
127  config, "highlight_line", preferences->highlight_line);
128  mape_preferences_write_boolean(
129  config, "bracket_matching", preferences->bracket_matching);
130  mape_preferences_write_boolean(
131  config, "fixed_seed", preferences->fixed_seed);
132  mape_preferences_write_int(
133  config, "random_seed", preferences->random_seed);
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));
140 }
gboolean line_numbers
Definition: preferences.h:27
unsigned int tab_width
Definition: preferences.h:23
gboolean highlight_line
Definition: preferences.h:28
gboolean tab_to_spaces
Definition: preferences.h:24
gboolean auto_indentation
Definition: preferences.h:25
gboolean text_wrapping
Definition: preferences.h:26
unsigned int random_seed
Definition: preferences.h:31
gboolean bracket_matching
Definition: preferences.h:29
unsigned int map_width
Definition: preferences.h:32
gboolean fixed_seed
Definition: preferences.h:30
unsigned int map_height
Definition: preferences.h:33