Save user configuration
This commit is contained in:
parent
effc02ce8e
commit
ca92c51f51
23
SDL/main.c
23
SDL/main.c
@ -399,6 +399,17 @@ restart:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char prefs_path[1024] = {0, };
|
||||||
|
|
||||||
|
static void save_configuration(void)
|
||||||
|
{
|
||||||
|
FILE *prefs_file = fopen(prefs_path, "wb");
|
||||||
|
if (prefs_file) {
|
||||||
|
fwrite(&configuration, 1, sizeof(configuration), prefs_file);
|
||||||
|
fclose(prefs_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#define str(x) #x
|
#define str(x) #x
|
||||||
@ -469,6 +480,18 @@ usage:
|
|||||||
|
|
||||||
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||||
|
|
||||||
|
char *prefs_dir = SDL_GetPrefPath("", "SameBoy");
|
||||||
|
snprintf(prefs_path, sizeof(prefs_path) - 1, "%sprefs.bin", prefs_dir);
|
||||||
|
SDL_free(prefs_dir);
|
||||||
|
|
||||||
|
FILE *prefs_file = fopen(prefs_path, "rb");
|
||||||
|
if (prefs_file) {
|
||||||
|
fread(&configuration, 1, sizeof(configuration), prefs_file);
|
||||||
|
fclose(prefs_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
atexit(save_configuration);
|
||||||
|
|
||||||
if (!init_shader_with_name(&shader, configuration.filter)) {
|
if (!init_shader_with_name(&shader, configuration.filter)) {
|
||||||
init_shader_with_name(&shader, "NearestNeighbor");
|
init_shader_with_name(&shader, "NearestNeighbor");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user