config: move some settings to a global config
This commit is contained in:
33
src/86box.c
33
src/86box.c
@@ -160,7 +160,7 @@ int window_remember;
|
||||
int vid_resize; /* (C) allow resizing */
|
||||
int invert_display = 0; /* (C) invert the display */
|
||||
int suppress_overscan = 0; /* (C) suppress overscans */
|
||||
int lang_id = 0; /* (C) language id */
|
||||
int lang_id = 0; /* (G) language id */
|
||||
int scale = 0; /* (C) screen scale factor */
|
||||
int dpi_scale = 0; /* (C) DPI scaling of the emulated
|
||||
screen */
|
||||
@@ -168,7 +168,7 @@ int vid_api = 0; /* (C) video r
|
||||
int vid_cga_contrast = 0; /* (C) video */
|
||||
int video_fullscreen = 0; /* (C) video */
|
||||
int video_fullscreen_scale = 0; /* (C) video */
|
||||
int video_fullscreen_first = 0; /* (C) video */
|
||||
int video_fullscreen_first = 0; /* (G) video */
|
||||
int enable_overscan = 0; /* (C) video */
|
||||
int force_43 = 0; /* (C) video */
|
||||
int video_filter_method = 1; /* (C) video */
|
||||
@@ -199,13 +199,13 @@ int cpu = 0; /* (C) cpu typ
|
||||
int fpu_type = 0; /* (C) fpu type */
|
||||
int fpu_softfloat = 0; /* (C) fpu uses softfloat */
|
||||
int time_sync = 0; /* (C) enable time sync */
|
||||
int confirm_reset = 1; /* (C) enable reset confirmation */
|
||||
int confirm_exit = 1; /* (C) enable exit confirmation */
|
||||
int confirm_save = 1; /* (C) enable save confirmation */
|
||||
int confirm_reset = 1; /* (G) enable reset confirmation */
|
||||
int confirm_exit = 1; /* (G) enable exit confirmation */
|
||||
int confirm_save = 1; /* (G) enable save confirmation */
|
||||
int enable_discord = 0; /* (C) enable Discord integration */
|
||||
int pit_mode = -1; /* (C) force setting PIT mode */
|
||||
int fm_driver = 0; /* (C) select FM sound driver */
|
||||
int open_dir_usr_path = 0; /* (C) default file open dialog directory
|
||||
int open_dir_usr_path = 0; /* (G) default file open dialog directory
|
||||
of usr_path */
|
||||
int video_fullscreen_scale_maximized = 0; /* (C) Whether fullscreen scaling settings
|
||||
also apply when maximized. */
|
||||
@@ -215,7 +215,7 @@ int hook_enabled = 1; /* (C) Keyboar
|
||||
int test_mode = 0; /* (C) Test mode */
|
||||
char uuid[MAX_UUID_LEN] = { '\0' }; /* (C) UUID or machine identifier */
|
||||
int sound_muted = 0; /* (C) Is sound muted? */
|
||||
int inhibit_multimedia_keys; /* (C) Inhibit multimedia keys on Windows. */
|
||||
int inhibit_multimedia_keys; /* (G) Inhibit multimedia keys on Windows. */
|
||||
|
||||
int other_ide_present = 0; /* IDE controllers from non-IDE cards are
|
||||
present */
|
||||
@@ -271,6 +271,7 @@ extern double exp_pow_table[0x800];
|
||||
char exe_path[2048]; /* path (dir) of executable */
|
||||
char usr_path[1024]; /* path (dir) of user data */
|
||||
char cfg_path[1024]; /* full path of config file */
|
||||
char global_cfg_path[1024]; /* full path of config file */
|
||||
FILE *stdlog = NULL; /* file to log output to */
|
||||
#if 0
|
||||
int scrnsz_x = SCREEN_RES_X; /* current screen size, X */
|
||||
@@ -616,6 +617,7 @@ pc_show_usage(char *s)
|
||||
"-M or --missing\t\t- dump missing machines and video cards\n"
|
||||
"-N or --noconfirm\t\t- do not ask for confirmation on quit\n"
|
||||
"-P or --vmpath path\t\t- set 'path' to be root for vm\n"
|
||||
"-O or --global path\t\t- set 'path' to be global config file\n"
|
||||
"-R or --rompath path\t\t- set 'path' to be ROM path\n"
|
||||
#ifndef USE_SDL_UI
|
||||
"-S or --settings\t\t\t- show only the settings dialog\n"
|
||||
@@ -655,6 +657,7 @@ pc_init(int argc, char *argv[])
|
||||
char *ppath = NULL;
|
||||
char *rpath = NULL;
|
||||
char *cfg = NULL;
|
||||
char *global = NULL;
|
||||
char *p;
|
||||
char temp[2048];
|
||||
char *fn[FDD_NUM] = { NULL };
|
||||
@@ -769,6 +772,11 @@ usage:
|
||||
#ifdef DEPRECATE_USAGE
|
||||
deprecated = 0;
|
||||
#endif
|
||||
} else if (!strcasecmp(argv[c], "--global") || !strcasecmp(argv[c], "-O")) {
|
||||
if ((c + 1) == argc || plat_dir_check(argv[c + 1]))
|
||||
goto usage;
|
||||
|
||||
global = argv[++c];
|
||||
} else if (!strcasecmp(argv[c], "--image") || !strcasecmp(argv[c], "-I")) {
|
||||
if ((c + 1) == argc)
|
||||
goto usage;
|
||||
@@ -996,6 +1004,14 @@ usage:
|
||||
/* At this point, we can safely create the full path name. */
|
||||
path_append_filename(cfg_path, usr_path, p);
|
||||
|
||||
/* Build the global configuration file path. */
|
||||
if (global == NULL) {
|
||||
plat_get_global_config_dir(global_cfg_path, sizeof(global_cfg_path));
|
||||
path_append_filename(global_cfg_path, global_cfg_path, CONFIG_FILE);
|
||||
} else {
|
||||
strncpy(global_cfg_path, global, sizeof(global_cfg_path) - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the current directory's name
|
||||
*
|
||||
@@ -1025,7 +1041,8 @@ usage:
|
||||
pclog("# ROM path: %s\n", rom_path->path);
|
||||
}
|
||||
|
||||
pclog("# Configuration file: %s\n#\n\n", cfg_path);
|
||||
pclog("# Global configuration file: %s\n", global_cfg_path);
|
||||
pclog("# VM configuration file: %s\n#\n\n", cfg_path);
|
||||
/*
|
||||
* We are about to read the configuration file, which MAY
|
||||
* put data into global variables (the hard- and floppy
|
||||
|
||||
172
src/config.c
172
src/config.c
@@ -88,6 +88,7 @@ static int cy;
|
||||
static int cw;
|
||||
static int ch;
|
||||
static ini_t config;
|
||||
static ini_t global;
|
||||
|
||||
#ifdef ENABLE_CONFIG_LOG
|
||||
int config_do_log = ENABLE_CONFIG_LOG;
|
||||
@@ -107,6 +108,35 @@ config_log(const char *fmt, ...)
|
||||
# define config_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
/* Load global configuration */
|
||||
static void
|
||||
load_global(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_section(global, "");
|
||||
char *p;
|
||||
|
||||
p = ini_section_get_string(cat, "language", NULL);
|
||||
if (p != NULL)
|
||||
lang_id = plat_language_code(p);
|
||||
else
|
||||
lang_id = plat_language_code(DEFAULT_LANGUAGE);
|
||||
|
||||
open_dir_usr_path = ini_section_get_int(cat, "open_dir_usr_path", 0);
|
||||
|
||||
confirm_reset = ini_section_get_int(cat, "confirm_reset", 1);
|
||||
confirm_exit = ini_section_get_int(cat, "confirm_exit", 1);
|
||||
confirm_save = ini_section_get_int(cat, "confirm_save", 1);
|
||||
|
||||
video_fullscreen_first = ini_section_get_int(cat, "video_fullscreen_first", 1);
|
||||
|
||||
inhibit_multimedia_keys = ini_section_get_int(cat, "inhibit_multimedia_keys", 0);
|
||||
|
||||
mouse_sensitivity = ini_section_get_double(cat, "mouse_sensitivity", 1.0);
|
||||
if (mouse_sensitivity < 0.1)
|
||||
mouse_sensitivity = 0.1;
|
||||
else if (mouse_sensitivity > 2.0)
|
||||
mouse_sensitivity = 2.0;
|
||||
}
|
||||
|
||||
/* Load "General" section. */
|
||||
static void
|
||||
@@ -128,12 +158,8 @@ load_general(void)
|
||||
|
||||
video_fullscreen_scale = ini_section_get_int(cat, "video_fullscreen_scale", 1);
|
||||
|
||||
video_fullscreen_first = ini_section_get_int(cat, "video_fullscreen_first", 1);
|
||||
|
||||
video_filter_method = ini_section_get_int(cat, "video_filter_method", 1);
|
||||
|
||||
inhibit_multimedia_keys = ini_section_get_int(cat, "inhibit_multimedia_keys", 0);
|
||||
|
||||
force_43 = !!ini_section_get_int(cat, "force_43", 0);
|
||||
scale = ini_section_get_int(cat, "scale", 1);
|
||||
if (scale > 9)
|
||||
@@ -179,26 +205,8 @@ load_general(void)
|
||||
hide_tool_bar = ini_section_get_int(cat, "hide_tool_bar", 0);
|
||||
sound_muted = ini_section_get_int(cat, "sound_muted", 0);
|
||||
|
||||
confirm_reset = ini_section_get_int(cat, "confirm_reset", 1);
|
||||
confirm_exit = ini_section_get_int(cat, "confirm_exit", 1);
|
||||
confirm_save = ini_section_get_int(cat, "confirm_save", 1);
|
||||
|
||||
p = ini_section_get_string(cat, "language", NULL);
|
||||
if (p != NULL)
|
||||
lang_id = plat_language_code(p);
|
||||
else
|
||||
lang_id = plat_language_code(DEFAULT_LANGUAGE);
|
||||
|
||||
mouse_sensitivity = ini_section_get_double(cat, "mouse_sensitivity", 1.0);
|
||||
if (mouse_sensitivity < 0.1)
|
||||
mouse_sensitivity = 0.1;
|
||||
else if (mouse_sensitivity > 2.0)
|
||||
mouse_sensitivity = 2.0;
|
||||
|
||||
enable_discord = !!ini_section_get_int(cat, "enable_discord", 0);
|
||||
|
||||
open_dir_usr_path = ini_section_get_int(cat, "open_dir_usr_path", 0);
|
||||
|
||||
video_framerate = ini_section_get_int(cat, "video_gl_framerate", -1);
|
||||
video_vsync = ini_section_get_int(cat, "video_gl_vsync", 0);
|
||||
|
||||
@@ -1800,7 +1808,21 @@ config_load(void)
|
||||
int i;
|
||||
ini_section_t c;
|
||||
|
||||
config_log("Loading config file '%s'..\n", cfg_path);
|
||||
config_log("Loading global config file '%s'...\n", global_cfg_path);
|
||||
|
||||
global = ini_read(global_cfg_path);
|
||||
|
||||
if (global == NULL) {
|
||||
global = ini_new();
|
||||
|
||||
lang_id = plat_language_code(DEFAULT_LANGUAGE);
|
||||
|
||||
config_log("Global config file not present or invalid!\n");
|
||||
} else {
|
||||
load_global();
|
||||
}
|
||||
|
||||
config_log("Loading VM config file '%s'...\n", cfg_path);
|
||||
|
||||
memset(hdd, 0, sizeof(hard_disk_t));
|
||||
memset(cdrom, 0, sizeof(cdrom_t) * CDROM_NUM);
|
||||
@@ -1813,7 +1835,6 @@ config_load(void)
|
||||
|
||||
if (config == NULL) {
|
||||
config = ini_new();
|
||||
config_changed = 1;
|
||||
|
||||
cpu_f = (cpu_family_t *) &cpu_families[0];
|
||||
cpu = 0;
|
||||
@@ -1873,9 +1894,7 @@ config_load(void)
|
||||
cassette_pcm = 0;
|
||||
cassette_ui_writeprot = 0;
|
||||
|
||||
lang_id = plat_language_code(DEFAULT_LANGUAGE);
|
||||
|
||||
config_log("Config file not present or invalid!\n");
|
||||
config_log("VM config file not present or invalid!\n");
|
||||
} else {
|
||||
load_general(); /* General */
|
||||
for (i = 0; i < MONITORS_NUM; i++)
|
||||
@@ -1913,13 +1932,63 @@ config_load(void)
|
||||
if (c != NULL)
|
||||
ini_rename_section(c, "3Dfx Voodoo Banshee");
|
||||
|
||||
config_log("VM config loaded.\n\n");
|
||||
}
|
||||
|
||||
/* Mark the configuration as changed. */
|
||||
config_changed = 1;
|
||||
|
||||
config_log("Config loaded.\n\n");
|
||||
video_copy = (video_grayscale || invert_display) ? video_transform_copy : memcpy;
|
||||
}
|
||||
|
||||
video_copy = (video_grayscale || invert_display) ? video_transform_copy : memcpy;
|
||||
/* Save global configuration */
|
||||
static void
|
||||
save_global(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(global, "");
|
||||
char buffer[512] = { 0 };
|
||||
|
||||
if (lang_id == plat_language_code(DEFAULT_LANGUAGE))
|
||||
ini_section_delete_var(cat, "language");
|
||||
else {
|
||||
plat_language_code_r(lang_id, buffer, 511);
|
||||
ini_section_set_string(cat, "language", buffer);
|
||||
}
|
||||
|
||||
if (open_dir_usr_path)
|
||||
ini_section_set_int(cat, "open_dir_usr_path", open_dir_usr_path);
|
||||
else
|
||||
ini_section_delete_var(cat, "open_dir_usr_path");
|
||||
|
||||
if (confirm_reset != 1)
|
||||
ini_section_set_int(cat, "confirm_reset", confirm_reset);
|
||||
else
|
||||
ini_section_delete_var(cat, "confirm_reset");
|
||||
|
||||
if (confirm_exit != 1)
|
||||
ini_section_set_int(cat, "confirm_exit", confirm_exit);
|
||||
else
|
||||
ini_section_delete_var(cat, "confirm_exit");
|
||||
|
||||
if (confirm_save != 1)
|
||||
ini_section_set_int(cat, "confirm_save", confirm_save);
|
||||
else
|
||||
ini_section_delete_var(cat, "confirm_save");
|
||||
|
||||
if (video_fullscreen_first == 1)
|
||||
ini_section_delete_var(cat, "video_fullscreen_first");
|
||||
else
|
||||
ini_section_set_int(cat, "video_fullscreen_first", video_fullscreen_first);
|
||||
|
||||
if (inhibit_multimedia_keys == 1)
|
||||
ini_section_set_int(cat, "inhibit_multimedia_keys", inhibit_multimedia_keys);
|
||||
else
|
||||
ini_section_delete_var(cat, "inhibit_multimedia_keys");
|
||||
|
||||
if (mouse_sensitivity != 1.0)
|
||||
ini_section_set_double(cat, "mouse_sensitivity", mouse_sensitivity);
|
||||
else
|
||||
ini_section_delete_var(cat, "mouse_sensitivity");
|
||||
}
|
||||
|
||||
/* Save "General" section. */
|
||||
@@ -1928,14 +1997,9 @@ save_general(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(config, "General");
|
||||
char temp[512];
|
||||
char buffer[512] = { 0 };
|
||||
|
||||
const char *va_name;
|
||||
|
||||
ini_section_set_int(cat, "inhibit_multimedia_keys", inhibit_multimedia_keys);
|
||||
if (inhibit_multimedia_keys == 0)
|
||||
ini_section_delete_var(cat, "inhibit_multimedia_keys");
|
||||
|
||||
ini_section_set_int(cat, "sound_muted", sound_muted);
|
||||
if (sound_muted == 0)
|
||||
ini_section_delete_var(cat, "sound_muted");
|
||||
@@ -1955,11 +2019,6 @@ save_general(void)
|
||||
else
|
||||
ini_section_set_int(cat, "video_fullscreen_scale", video_fullscreen_scale);
|
||||
|
||||
if (video_fullscreen_first == 1)
|
||||
ini_section_delete_var(cat, "video_fullscreen_first");
|
||||
else
|
||||
ini_section_set_int(cat, "video_fullscreen_first", video_fullscreen_first);
|
||||
|
||||
if (video_filter_method == 1)
|
||||
ini_section_delete_var(cat, "video_filter_method");
|
||||
else
|
||||
@@ -2041,43 +2100,11 @@ save_general(void)
|
||||
else
|
||||
ini_section_delete_var(cat, "hide_tool_bar");
|
||||
|
||||
if (confirm_reset != 1)
|
||||
ini_section_set_int(cat, "confirm_reset", confirm_reset);
|
||||
else
|
||||
ini_section_delete_var(cat, "confirm_reset");
|
||||
|
||||
if (confirm_exit != 1)
|
||||
ini_section_set_int(cat, "confirm_exit", confirm_exit);
|
||||
else
|
||||
ini_section_delete_var(cat, "confirm_exit");
|
||||
|
||||
if (confirm_save != 1)
|
||||
ini_section_set_int(cat, "confirm_save", confirm_save);
|
||||
else
|
||||
ini_section_delete_var(cat, "confirm_save");
|
||||
|
||||
if (mouse_sensitivity != 1.0)
|
||||
ini_section_set_double(cat, "mouse_sensitivity", mouse_sensitivity);
|
||||
else
|
||||
ini_section_delete_var(cat, "mouse_sensitivity");
|
||||
|
||||
if (lang_id == plat_language_code(DEFAULT_LANGUAGE))
|
||||
ini_section_delete_var(cat, "language");
|
||||
else {
|
||||
plat_language_code_r(lang_id, buffer, 511);
|
||||
ini_section_set_string(cat, "language", buffer);
|
||||
}
|
||||
|
||||
if (enable_discord)
|
||||
ini_section_set_int(cat, "enable_discord", enable_discord);
|
||||
else
|
||||
ini_section_delete_var(cat, "enable_discord");
|
||||
|
||||
if (open_dir_usr_path)
|
||||
ini_section_set_int(cat, "open_dir_usr_path", open_dir_usr_path);
|
||||
else
|
||||
ini_section_delete_var(cat, "open_dir_usr_path");
|
||||
|
||||
if (video_framerate != -1)
|
||||
ini_section_set_int(cat, "video_gl_framerate", video_framerate);
|
||||
else
|
||||
@@ -3133,6 +3160,9 @@ save_other_removable_devices(void)
|
||||
void
|
||||
config_save(void)
|
||||
{
|
||||
save_global(); /* Global */
|
||||
ini_write(global, global_cfg_path);
|
||||
|
||||
save_general(); /* General */
|
||||
for (uint8_t i = 0; i < MONITORS_NUM; i++)
|
||||
save_monitor(i); /* Monitors */
|
||||
|
||||
@@ -175,6 +175,7 @@ extern int hook_enabled; /* (C) Keyboard hook is enabled */
|
||||
extern char exe_path[2048]; /* path (dir) of executable */
|
||||
extern char usr_path[1024]; /* path (dir) of user data */
|
||||
extern char cfg_path[1024]; /* full path of config file */
|
||||
extern char global_cfg_path[1024]; /* full path of global config file */
|
||||
extern int open_dir_usr_path; /* default file open dialog directory of usr_path */
|
||||
extern char uuid[MAX_UUID_LEN]; /* UUID or machine identifier */
|
||||
#ifndef USE_NEW_DYNAREC
|
||||
|
||||
Reference in New Issue
Block a user