1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

improve reading and saving of configuration

This commit is contained in:
IntelOrca
2015-02-16 22:47:11 +00:00
parent 136936cdb2
commit 7f0ed995b5
21 changed files with 791 additions and 845 deletions

View File

@@ -222,9 +222,6 @@
<ClCompile Include="..\src\util\util.c">
<Filter>Source\Util</Filter>
</ClCompile>
<ClCompile Include="..\src\config.c">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\src\editor.c">
<Filter>Source</Filter>
</ClCompile>
@@ -333,14 +330,12 @@
<ClCompile Include="..\src\world\fountain.c">
<Filter>Source\World</Filter>
</ClCompile>
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\world\banner.c">
<Filter>Source\World</Filter>
</ClCompile>
<ClCompile Include="..\src\windows\staff_fire_prompt.c">
<Filter>Source\Windows</Filter>
</ClCompile>
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\windows\viewport.c">
<Filter>Source\Windows</Filter>
</ClCompile>
@@ -362,11 +357,11 @@
<ClCompile Include="..\src\ride\station.c">
<Filter>Source\Ride</Filter>
</ClCompile>
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\windows\ride_construction.c">
<Filter>Source\Windows</Filter>
</ClCompile>
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\interface\keyboard_shortcut.c">
<Filter>Source\Interface</Filter>
</ClCompile>
@@ -427,6 +422,9 @@
<ClCompile Include="..\src\windows\loadsave.c">
<Filter>Source\Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\config.c">
<Filter>Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\management\award.h">

View File

@@ -1545,7 +1545,7 @@ void stop_completed_sounds()
void start_title_music()
{
int musicPathId;
switch (gGeneral_config.title_music) {
switch (gConfigSound.title_music) {
default:
return;
case 1:
@@ -1751,7 +1751,7 @@ void audio_init2(int device)
rct_dsdevice dsdevice = RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[device];
RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_GUID, GUID) = dsdevice.guid;
RCT2_GLOBAL(0x009AAC5C, uint8) = 1;
config_save();
config_save_default();
RCT2_GLOBAL(0x014241BC, uint32) = 1;
int successtimer = audio_create_timer();
RCT2_GLOBAL(0x014241BC, uint32) = 0;
@@ -1763,9 +1763,9 @@ void audio_init2(int device)
}
}
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & 1 << 4)) {
gSound_config.forced_software_buffering = RCT2_GLOBAL(0x001425B74, uint32) != RCT2_GLOBAL(0x001425B78, uint32) || RCT2_GLOBAL(0x001425B74, uint32) != RCT2_GLOBAL(0x001425B7C, uint32);
gConfigSound.forced_software_buffering = RCT2_GLOBAL(0x001425B74, uint32) != RCT2_GLOBAL(0x001425B78, uint32) || RCT2_GLOBAL(0x001425B74, uint32) != RCT2_GLOBAL(0x001425B7C, uint32);
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= 1 << 4;
config_save();
config_save_default();
}
}

View File

@@ -24,4 +24,6 @@
#include "diagnostic.h"
#include "rct2.h"
#define SafeFree(x) if ((x) != NULL) { free(x); (x) = NULL; }
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -96,30 +96,11 @@ enum{
};
extern uint16 gShortcutKeys[SHORTCUT_COUNT];
void config_reset_shortcut_keys();
void config_load();
void config_save();
int config_find_or_browse_install_directory();
// New config format
#define MAX_CONFIG_LENGTH 256
typedef struct sound_configuration {
sint8 sound_quality;
sint8 forced_software_buffering;
} sound_configuration_t;
typedef struct general_configuration {
uint8 play_intro;
uint8 confirmation_prompt;
uint8 screenshot_format;
char game_path[MAX_PATH];
utf8string game_path;
sint8 measurement_format;
sint8 temperature_format;
sint8 currency_format;
@@ -132,44 +113,35 @@ typedef struct general_configuration {
//new
uint8 fullscreen_mode;
sint16 fullscreen_width;
sint16 fullscreen_height;
sint16 window_width;
sint16 window_height;
sint32 fullscreen_width;
sint32 fullscreen_height;
sint32 window_width;
sint32 window_height;
uint16 language;
uint8 window_snap_proximity;
} general_configuration;
typedef struct sound_configuration {
sint8 forced_software_buffering;
sint8 sound_quality;
uint8 title_music;
} general_configuration_t;
static const struct { const char *key; int value; } _currencyLookupTable[] = {
{ "GBP", CURRENCY_POUNDS },
{ "USD", CURRENCY_DOLLARS },
{ "FRF", CURRENCY_FRANC },
{ "DEM", CURRENCY_DEUTSCHMARK },
{ "YEN", CURRENCY_YEN },
{ "ESP", CURRENCY_PESETA },
{ "ITL", CURRENCY_LIRA },
{ "NLG", CURRENCY_GUILDERS },
{ "NOK", CURRENCY_KRONA },
{ "SEK", CURRENCY_KRONA },
{ "DEK", CURRENCY_KRONA },
{ "EUR", CURRENCY_EUROS },
{ "\xA3", CURRENCY_POUNDS },
{ "\x24", CURRENCY_DOLLARS },
{ "\xA5", CURRENCY_YEN },
{ "\xB5", CURRENCY_EUROS }
};
} sound_configuration;
typedef struct shortcut_entry {
uint8 key;
uint8 modifier;
} shortcut_entry;
//typedef struct hotkey_configuration{
extern general_configuration gConfigGeneral;
extern sound_configuration gConfigSound;
//};
extern general_configuration_t gGeneral_config;
extern sound_configuration_t gSound_config;
extern uint16 gShortcutKeys[SHORTCUT_COUNT];
void config_set_defaults();
bool config_open_default();
bool config_save_default();
void config_reset_shortcut_keys();
bool config_find_or_browse_install_directory();
#endif

View File

@@ -286,7 +286,7 @@ void game_update()
if (RCT2_GLOBAL(0x009AAC73, uint8) != 255) {
RCT2_GLOBAL(0x009AAC73, uint8)++;
if (RCT2_GLOBAL(0x009AAC73, uint8) == 255)
config_save();
config_save_default();
}
}
@@ -784,7 +784,7 @@ char save_game()
// Ensure path has .SV6 extension
path_set_extension(path, ".SV6");
if (scenario_save(path, gGeneral_config.save_plugin_data ? 1 : 0)) {
if (scenario_save(path, gConfigGeneral.save_plugin_data ? 1 : 0)) {
game_do_command(0, 1047, 0, -1, GAME_COMMAND_0, 0, 0);
gfx_invalidate_screen();
return 1;

View File

@@ -351,7 +351,7 @@ static void input_window_position_continue(rct_window *w, int wdx, int wdy, int
{
int snapProximity;
snapProximity = w->flags & WF_NO_SNAPPING ? 0 : gGeneral_config.window_snap_proximity;
snapProximity = w->flags & WF_NO_SNAPPING ? 0 : gConfigGeneral.window_snap_proximity;
window_move_and_snap(w, x - wdx, y - wdy, snapProximity);
}

View File

@@ -50,7 +50,7 @@ void keyboard_shortcut_set(int key)
gShortcutKeys[RCT2_GLOBAL(0x009DE511, uint8)] = key;
window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST);
config_save();
config_save_default();
}
/**

View File

@@ -50,7 +50,7 @@ void screenshot_check()
if (screenshotIndex != -1) {
char *lang_3165 = (char*)0x009BC677;
sprintf(lang_3165, "SCR%d%s", screenshotIndex, _screenshot_format_extension[gGeneral_config.screenshot_format]);
sprintf(lang_3165, "SCR%d%s", screenshotIndex, _screenshot_format_extension[gConfigGeneral.screenshot_format]);
RCT2_GLOBAL(0x013CE952, uint16) = 3165;
// RCT2_GLOBAL(0x013CE952, uint16) = STR_SCR_BMP;
@@ -96,7 +96,7 @@ static int screenshot_get_next_path(char *path, int format)
int screenshot_dump()
{
switch (gGeneral_config.screenshot_format) {
switch (gConfigGeneral.screenshot_format) {
case SCREENSHOT_FORMAT_BMP:
return screenshot_dump_bmp();
case SCREENSHOT_FORMAT_PNG:

View File

@@ -174,7 +174,7 @@ void viewport_create(rct_window *w, int x, int y, int width, int height, int zoo
viewport->zoom = zoom;
viewport->flags = 0;
if (gGeneral_config.always_show_gridlines)
if (gConfigGeneral.always_show_gridlines)
viewport->flags |= VIEWPORT_FLAG_GRIDLINES;
w->viewport = viewport;
@@ -1109,7 +1109,7 @@ void hide_gridlines()
RCT2_GLOBAL(0x009E32B0, uint8)--;
if (RCT2_GLOBAL(0x009E32B0, uint8) == 0) {
if ((mainWindow = window_get_main()) != NULL) {
if (!gGeneral_config.always_show_gridlines) {
if (!gConfigGeneral.always_show_gridlines) {
mainWindow->viewport->flags &= ~VIEWPORT_FLAG_GRIDLINES;
window_invalidate(mainWindow);
}

View File

@@ -277,7 +277,7 @@ void format_comma_separated_fixed_2dp(char **dest, long long value)
void format_currency(char **dest, long long value)
{
const rct_currency_spec *currencySpec = &g_currency_specs[gGeneral_config.currency_format];
const rct_currency_spec *currencySpec = &g_currency_specs[gConfigGeneral.currency_format];
int rate = currencySpec->rate;
value *= rate;
@@ -309,7 +309,7 @@ void format_currency(char **dest, long long value)
void format_currency_2dp(char **dest, long long value)
{
const rct_currency_spec *currencySpec = &g_currency_specs[gGeneral_config.currency_format];
const rct_currency_spec *currencySpec = &g_currency_specs[gConfigGeneral.currency_format];
int rate = currencySpec->rate;
value *= rate;
@@ -355,7 +355,7 @@ void format_length(char **dest, uint16 value)
{
rct_string_id stringId = 2733;
if (gGeneral_config.measurement_format == MEASUREMENT_FORMAT_IMPERIAL) {
if (gConfigGeneral.measurement_format == MEASUREMENT_FORMAT_IMPERIAL) {
value = metres_to_feet(value);
stringId--;
}
@@ -368,7 +368,7 @@ void format_velocity(char **dest, uint16 value)
{
rct_string_id stringId = 2734;
if (gGeneral_config.measurement_format == MEASUREMENT_FORMAT_METRIC) {
if (gConfigGeneral.measurement_format == MEASUREMENT_FORMAT_METRIC) {
value = mph_to_kmph(value);
stringId++;
}

View File

@@ -120,7 +120,15 @@ void openrct2_launch()
return;
}
config_load();
config_set_defaults();
if (!config_open_default()) {
if (!config_find_or_browse_install_directory()) {
log_fatal("An RCT2 install directory must be specified!");
return;
}
}
config_save_default();
// TODO add configuration option to allow multiple instances
if (!platform_lock_single_instance()) {
@@ -132,7 +140,7 @@ void openrct2_launch()
audio_init();
audio_get_devices();
get_dsound_devices();
language_open(gGeneral_config.language);
language_open(gConfigGeneral.language);
if (!rct2_init())
return;

View File

@@ -120,9 +120,9 @@ void platform_update_fullscreen_resolutions()
gNumResolutions = (int)(resPlace - &gResolutions[0]) + 1;
// Update config fullscreen resolution if not set
if (gGeneral_config.fullscreen_width == -1 || gGeneral_config.fullscreen_height == -1) {
gGeneral_config.fullscreen_width = gResolutions[gNumResolutions - 1].width;
gGeneral_config.fullscreen_height = gResolutions[gNumResolutions - 1].height;
if (gConfigGeneral.fullscreen_width == -1 || gConfigGeneral.fullscreen_height == -1) {
gConfigGeneral.fullscreen_width = gResolutions[gNumResolutions - 1].width;
gConfigGeneral.fullscreen_height = gResolutions[gNumResolutions - 1].height;
}
}
@@ -352,10 +352,10 @@ void platform_process_messages()
gLastKeyPressed = e.key.keysym.sym;
gKeysPressed[e.key.keysym.scancode] = 1;
if (e.key.keysym.sym == SDLK_RETURN && e.key.keysym.mod & KMOD_ALT) {
int targetMode = gGeneral_config.fullscreen_mode == 0 ? 2 : 0;
int targetMode = gConfigGeneral.fullscreen_mode == 0 ? 2 : 0;
platform_set_fullscreen_mode(targetMode);
gGeneral_config.fullscreen_mode = targetMode;
config_save();
gConfigGeneral.fullscreen_mode = targetMode;
config_save_default();
break;
}
@@ -473,8 +473,8 @@ static void platform_create_window()
RCT2_CALLPROC_EBPSAFE(0x0068371D);
// Get window size
width = gGeneral_config.window_width;
height = gGeneral_config.window_height;
width = gConfigGeneral.window_width;
height = gConfigGeneral.window_height;
if (width == -1) width = 640;
if (height == -1) height = 480;
@@ -496,7 +496,7 @@ static void platform_create_window()
platform_resize(width, height);
platform_update_fullscreen_resolutions();
platform_set_fullscreen_mode(gGeneral_config.fullscreen_mode);
platform_set_fullscreen_mode(gConfigGeneral.fullscreen_mode);
}
int platform_scancode_to_rct_keycode(int sdl_key)
@@ -555,10 +555,10 @@ void platform_set_fullscreen_mode(int mode)
// Set window size
if (mode == SDL_WINDOW_FULLSCREEN) {
platform_update_fullscreen_resolutions();
platform_get_closest_resolution(gGeneral_config.fullscreen_width, gGeneral_config.fullscreen_height, &width, &height);
platform_get_closest_resolution(gConfigGeneral.fullscreen_width, gConfigGeneral.fullscreen_height, &width, &height);
SDL_SetWindowSize(gWindow, width, height);
} else if (mode == 0) {
SDL_SetWindowSize(gWindow, gGeneral_config.window_width, gGeneral_config.window_height);
SDL_SetWindowSize(gWindow, gConfigGeneral.window_width, gConfigGeneral.window_height);
}
if (SDL_SetWindowFullscreen(gWindow, mode)) {

View File

@@ -57,7 +57,7 @@ static void rct2_update_2();
static jmp_buf _end_update_jump;
void rct2_quit() {
if (gGeneral_config.confirmation_prompt) {
if (gConfigGeneral.confirmation_prompt) {
RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) = PM_QUIT;
window_save_prompt_open();
} else
@@ -116,7 +116,7 @@ int rct2_init()
title_load();
gfx_clear(RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo), 10);
RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, uint8) = gGeneral_config.play_intro ? 8 : 255;
RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, uint8) = gConfigGeneral.play_intro ? 8 : 255;
log_verbose("initialising game finished");
return 1;
@@ -131,15 +131,15 @@ int rct2_init_directories()
// windows_get_registry_install_info((rct2_install_info*)0x009AA10C, "RollerCoaster Tycoon 2 Setup", "MS Sans Serif", 0);
// check install directory
if (!platform_directory_exists(gGeneral_config.game_path)) {
log_verbose("install directory does not exist, %s", gGeneral_config.game_path);
if (!platform_directory_exists(gConfigGeneral.game_path)) {
log_verbose("install directory does not exist, %s", gConfigGeneral.game_path);
if (!config_find_or_browse_install_directory()) {
log_fatal("Invalid RCT2 installation path. Please correct in config.ini.");
return 0;
}
}
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char), gGeneral_config.game_path);
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char), gConfigGeneral.game_path);
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char), RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char));
strcat(RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char), "\\");
@@ -360,7 +360,7 @@ const char *get_file_path(int pathId)
// The original implementation checks if the file is on CD-ROM here (file_on_cdrom[pathId] @ 0x009AA0B1).
// If so, the CD-ROM path (cdrom_path @ 0x9AA318) is used instead. This has been removed for now for
// the sake of simplicity.
strcpy(path, gGeneral_config.game_path);
strcpy(path, gConfigGeneral.game_path);
// Make sure base path is terminated with a slash
if (strlen(path) == 0 || path[strlen(path) - 1] != '\\')

View File

@@ -44,8 +44,9 @@ typedef unsigned long uint32;
typedef unsigned long long uint64;
typedef char utf8;
typedef wchar_t utf16;
typedef utf8* utf8string;
typedef const utf8* const_utf8string;
typedef wchar_t utf16;
typedef utf16* utf16string;
#define rol8(x, shift) (((uint8)(x) << (shift)) | ((uint8)(x) >> (8 - (shift))))

View File

@@ -295,7 +295,7 @@ void title_update()
if (RCT2_GLOBAL(0x009AAC73, uint8) != 255) {
RCT2_GLOBAL(0x009AAC73, uint8)++;
if (RCT2_GLOBAL(0x009AAC73, uint8) == 255)
config_save();
config_save_default();
}
}

View File

@@ -317,7 +317,7 @@ void window_editor_bottom_toolbar_jump_forward_to_save_scenario()
// Save the scenario
parkFlagsBackup = RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32);
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) &= ~PARK_FLAGS_18;
success = scenario_save(path, gGeneral_config.save_plugin_data ? 3 : 2);
success = scenario_save(path, gConfigGeneral.save_plugin_data ? 3 : 2);
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = parkFlagsBackup;
if (success) {

View File

@@ -577,7 +577,7 @@ static void window_loadsave_select(rct_window *w, const char *path)
}
break;
case (LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME) :
if (scenario_save((char*)path, gGeneral_config.save_plugin_data ? 1 : 0)) {
if (scenario_save((char*)path, gConfigGeneral.save_plugin_data ? 1 : 0)) {
window_close(w);
game_do_command(0, 1047, 0, -1, GAME_COMMAND_0, 0, 0);
@@ -599,7 +599,7 @@ static void window_loadsave_select(rct_window *w, const char *path)
}
break;
case (LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE) :
if (scenario_save((char*)path, gGeneral_config.save_plugin_data ? 3 : 2)) {
if (scenario_save((char*)path, gConfigGeneral.save_plugin_data ? 3 : 2)) {
window_close(w);
gfx_invalidate_screen();
}
@@ -613,7 +613,7 @@ static void window_loadsave_select(rct_window *w, const char *path)
int parkFlagsBackup = RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32);
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) &= ~PARK_FLAGS_18;
s6Info->var_000 = 255;
int success = scenario_save((char*)path, gGeneral_config.save_plugin_data ? 3 : 2);
int success = scenario_save((char*)path, gConfigGeneral.save_plugin_data ? 3 : 2);
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = parkFlagsBackup;
if (success) {

View File

@@ -293,8 +293,8 @@ static void window_options_mouseup()
window_shortcut_keys_open();
break;
case WIDX_SCREEN_EDGE_SCROLLING:
gGeneral_config.edge_scrolling ^= 1;
config_save();
gConfigGeneral.edge_scrolling ^= 1;
config_save_default();
window_invalidate(w);
break;
case WIDX_REAL_NAME_CHECKBOX:
@@ -302,30 +302,30 @@ static void window_options_mouseup()
RCT2_CALLPROC_X(0x0069C52F, RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_SHOW_REAL_GUEST_NAMES ? 0 : 1, 0, 0, 0, 0, 0, 0);
break;
case WIDX_TILE_SMOOTHING_CHECKBOX:
gGeneral_config.landscape_smoothing ^= 1;
config_save();
gConfigGeneral.landscape_smoothing ^= 1;
config_save_default();
gfx_invalidate_screen();
break;
case WIDX_GRIDLINES_CHECKBOX:
gGeneral_config.always_show_gridlines ^= 1;
config_save();
gConfigGeneral.always_show_gridlines ^= 1;
config_save_default();
gfx_invalidate_screen();
if ((w = window_get_main()) != NULL) {
if (gGeneral_config.always_show_gridlines)
if (gConfigGeneral.always_show_gridlines)
w->viewport->flags |= VIEWPORT_FLAG_GRIDLINES;
else
w->viewport->flags &= ~VIEWPORT_FLAG_GRIDLINES;
}
break;
case WIDX_SAVE_PLUGIN_DATA_CHECKBOX:
gGeneral_config.save_plugin_data ^= 1;
config_save();
gConfigGeneral.save_plugin_data ^= 1;
config_save_default();
window_invalidate(w);
break;
case WIDX_SOUND_SW_BUFFER_CHECKBOX:
pause_sounds();
gSound_config.forced_software_buffering ^= 1;
config_save();
gConfigSound.forced_software_buffering ^= 1;
config_save_default();
unpause_sounds();
window_invalidate(w);
break;
@@ -369,7 +369,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
window_options_show_dropdown(w, widget, 2);
gDropdownItemsChecked = gGeneral_config.show_height_as_units ? 1 : 2;
gDropdownItemsChecked = gConfigGeneral.show_height_as_units ? 1 : 2;
break;
case WIDX_MUSIC_DROPDOWN:
gDropdownItemsFormat[0] = 1142;
@@ -391,7 +391,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
window_options_show_dropdown(w, widget, num_items);
gDropdownItemsChecked = 1 << gSound_config.sound_quality;
gDropdownItemsChecked = 1 << gConfigSound.sound_quality;
break;
case WIDX_TITLE_MUSIC_DROPDOWN:
num_items = 3;
@@ -403,7 +403,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
window_options_show_dropdown(w, widget, num_items);
gDropdownItemsChecked = 1 << gGeneral_config.title_music;
gDropdownItemsChecked = 1 << gConfigSound.title_music;
break;
case WIDX_CURRENCY_DROPDOWN:
num_items = 10;
@@ -415,7 +415,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
window_options_show_dropdown(w, widget, num_items);
gDropdownItemsChecked = 1 << gGeneral_config.currency_format;
gDropdownItemsChecked = 1 << gConfigGeneral.currency_format;
break;
case WIDX_DISTANCE_DROPDOWN:
gDropdownItemsFormat[0] = 1142;
@@ -425,7 +425,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
window_options_show_dropdown(w, widget, 2);
gDropdownItemsChecked = 1 << gGeneral_config.measurement_format;
gDropdownItemsChecked = 1 << gConfigGeneral.measurement_format;
break;
case WIDX_RESOLUTION_DROPDOWN:
{
@@ -442,7 +442,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
args[1] = resolution->width;
args[2] = resolution->height;
if (resolution->width == gGeneral_config.fullscreen_width && resolution->height == gGeneral_config.fullscreen_height)
if (resolution->width == gConfigGeneral.fullscreen_width && resolution->height == gConfigGeneral.fullscreen_height)
selectedResolution = i;
}
@@ -463,7 +463,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
window_options_show_dropdown(w, widget, 3);
gDropdownItemsChecked = 1 << gGeneral_config.fullscreen_mode;
gDropdownItemsChecked = 1 << gConfigGeneral.fullscreen_mode;
break;
case WIDX_TEMPERATURE_DROPDOWN:
gDropdownItemsFormat[0] = 1142;
@@ -473,7 +473,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
window_options_show_dropdown(w, widget, 2);
gDropdownItemsChecked = 1 << gGeneral_config.temperature_format;
gDropdownItemsChecked = 1 << gConfigGeneral.temperature_format;
break;
case WIDX_CONSTRUCTION_MARKER_DROPDOWN:
gDropdownItemsFormat[0] = 1142;
@@ -483,7 +483,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
window_options_show_dropdown(w, widget, 2);
gDropdownItemsChecked = 1 << gGeneral_config.construction_marker_colour;
gDropdownItemsChecked = 1 << gConfigGeneral.construction_marker_colour;
break;
case WIDX_LANGUAGE_DROPDOWN:
for (i = 1; i < LANGUAGE_COUNT; i++) {
@@ -536,64 +536,64 @@ static void window_options_dropdown()
case WIDX_HEIGHT_LABELS_DROPDOWN:
// reset flag and set it to 1 if height as units is selected
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= ~CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS;
gGeneral_config.show_height_as_units = 0;
gConfigGeneral.show_height_as_units = 0;
if (dropdownIndex == 0) {
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS;
gGeneral_config.show_height_as_units = 1;
gConfigGeneral.show_height_as_units = 1;
}
window_options_update_height_markers();
break;
case WIDX_MUSIC_DROPDOWN:
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) = (uint8)dropdownIndex;
config_save();
config_save_default();
stop_ride_music();//RCT2_CALLPROC_EBPSAFE(0x006BCA9F);
window_invalidate(w);
break;
case WIDX_SOUND_QUALITY_DROPDOWN:
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MAX_VEHICLE_SOUNDS, uint8) = RCT2_GLOBAL(0x009AF601 + dropdownIndex, uint8);
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MAX_NO_SOUNDS, uint8) = RCT2_GLOBAL(0x009AF604 + dropdownIndex, uint8);
gSound_config.sound_quality = (sint8)dropdownIndex;
config_save();
gConfigSound.sound_quality = (sint8)dropdownIndex;
config_save_default();
window_invalidate(w);
break;
case WIDX_TITLE_MUSIC_DROPDOWN:
if (dropdownIndex == 1 && !platform_file_exists(get_file_path(PATH_ID_CSS50))) {
window_error_open(2742, 2743);
} else {
gGeneral_config.title_music = (sint8)dropdownIndex;
config_save();
gConfigSound.title_music = (sint8)dropdownIndex;
config_save_default();
window_invalidate(w);
}
break;
case WIDX_CURRENCY_DROPDOWN:
gGeneral_config.currency_format = (sint8)dropdownIndex;
config_save();
gConfigGeneral.currency_format = (sint8)dropdownIndex;
config_save_default();
gfx_invalidate_screen();
break;
case WIDX_DISTANCE_DROPDOWN:
gGeneral_config.measurement_format = (sint8)dropdownIndex;
config_save();
gConfigGeneral.measurement_format = (sint8)dropdownIndex;
config_save_default();
window_options_update_height_markers();
break;
case WIDX_RESOLUTION_DROPDOWN:
{
resolution *resolution = &gResolutions[dropdownIndex];
if (resolution->width != gGeneral_config.fullscreen_width || resolution->height != gGeneral_config.fullscreen_height) {
gGeneral_config.fullscreen_width = resolution->width;
gGeneral_config.fullscreen_height = resolution->height;
if (resolution->width != gConfigGeneral.fullscreen_width || resolution->height != gConfigGeneral.fullscreen_height) {
gConfigGeneral.fullscreen_width = resolution->width;
gConfigGeneral.fullscreen_height = resolution->height;
if (gGeneral_config.fullscreen_mode == SDL_WINDOW_FULLSCREEN)
if (gConfigGeneral.fullscreen_mode == SDL_WINDOW_FULLSCREEN)
platform_set_fullscreen_mode(SDL_WINDOW_FULLSCREEN);
config_save();
config_save_default();
gfx_invalidate_screen();
}
}
break;
case WIDX_FULLSCREEN_DROPDOWN:
if (dropdownIndex != gGeneral_config.fullscreen_mode){
if (dropdownIndex != gConfigGeneral.fullscreen_mode){
if (dropdownIndex == 2){
w->disabled_widgets |= (1 << WIDX_RESOLUTION_DROPDOWN);
w->disabled_widgets |= (1 << WIDX_RESOLUTION);
@@ -603,29 +603,29 @@ static void window_options_dropdown()
}
platform_set_fullscreen_mode(dropdownIndex);
gGeneral_config.fullscreen_mode = (uint8)dropdownIndex;
config_save();
gConfigGeneral.fullscreen_mode = (uint8)dropdownIndex;
config_save_default();
}
break;
case WIDX_TEMPERATURE_DROPDOWN:
if (dropdownIndex != gGeneral_config.temperature_format) {
gGeneral_config.temperature_format = (sint8)dropdownIndex;
config_save();
if (dropdownIndex != gConfigGeneral.temperature_format) {
gConfigGeneral.temperature_format = (sint8)dropdownIndex;
config_save_default();
gfx_invalidate_screen();
}
break;
case WIDX_CONSTRUCTION_MARKER_DROPDOWN:
if (dropdownIndex != gGeneral_config.construction_marker_colour) {
gGeneral_config.construction_marker_colour = (uint8)dropdownIndex;
config_save();
if (dropdownIndex != gConfigGeneral.construction_marker_colour) {
gConfigGeneral.construction_marker_colour = (uint8)dropdownIndex;
config_save_default();
gfx_invalidate_screen();
}
break;
case WIDX_LANGUAGE_DROPDOWN:
if (dropdownIndex != gCurrentLanguage - 1) {
language_open(dropdownIndex + 1);
gGeneral_config.language = dropdownIndex + 1;
config_save();
gConfigGeneral.language = dropdownIndex + 1;
config_save_default();
gfx_invalidate_screen();
}
break;
@@ -652,9 +652,9 @@ static void window_options_invalidate()
switch (w->page) {
case WINDOW_OPTIONS_PAGE_DISPLAY:
// resolution
RCT2_GLOBAL(0x013CE952 + 16, uint16) = gGeneral_config.fullscreen_width;
RCT2_GLOBAL(0x013CE952 + 18, uint16) = gGeneral_config.fullscreen_height;
RCT2_GLOBAL(0x013CE952 + 12, uint16) = 2773 + gGeneral_config.fullscreen_mode;
RCT2_GLOBAL(0x013CE952 + 16, uint16) = (uint16)gConfigGeneral.fullscreen_width;
RCT2_GLOBAL(0x013CE952 + 18, uint16) = (uint16)gConfigGeneral.fullscreen_height;
RCT2_GLOBAL(0x013CE952 + 12, uint16) = 2773 + gConfigGeneral.fullscreen_mode;
// landscape tile smoothing checkbox
if ((RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE))
@@ -682,16 +682,16 @@ static void window_options_invalidate()
break;
case WINDOW_OPTIONS_PAGE_CULTURE:
// currency: pounds, dollars, etc. (10 total)
RCT2_GLOBAL(0x013CE952 + 12, uint16) = STR_POUNDS + gGeneral_config.currency_format;
RCT2_GLOBAL(0x013CE952 + 12, uint16) = STR_POUNDS + gConfigGeneral.currency_format;
// distance: metric/imperial
RCT2_GLOBAL(0x013CE952 + 14, uint16) = STR_IMPERIAL + gGeneral_config.measurement_format;
RCT2_GLOBAL(0x013CE952 + 14, uint16) = STR_IMPERIAL + gConfigGeneral.measurement_format;
// temperature: celsius/fahrenheit
RCT2_GLOBAL(0x013CE952 + 20, uint16) = STR_CELSIUS + gGeneral_config.temperature_format;
RCT2_GLOBAL(0x013CE952 + 20, uint16) = STR_CELSIUS + gConfigGeneral.temperature_format;
// height: units/real values
RCT2_GLOBAL(0x013CE952 + 6, uint16) = gGeneral_config.show_height_as_units ? STR_UNITS : STR_REAL_VALUES;
RCT2_GLOBAL(0x013CE952 + 6, uint16) = gConfigGeneral.show_height_as_units ? STR_UNITS : STR_REAL_VALUES;
window_options_widgets[WIDX_LANGUAGE].type = WWT_DROPDOWN;
window_options_widgets[WIDX_LANGUAGE_DROPDOWN].type = WWT_DROPDOWN_BUTTON;
@@ -719,7 +719,7 @@ static void window_options_invalidate()
RCT2_GLOBAL(0x013CE952 + 8, uint16) = STR_OFF + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8);
// sound quality: low/medium/high
RCT2_GLOBAL(0x013CE952 + 10, uint16) = STR_SOUND_LOW + gSound_config.sound_quality;
RCT2_GLOBAL(0x013CE952 + 10, uint16) = STR_SOUND_LOW + gConfigSound.sound_quality;
//Sound pause checkbox
if (!g_sounds_disabled)
@@ -728,7 +728,7 @@ static void window_options_invalidate()
w->pressed_widgets &= ~(1ULL << WIDX_SOUND_PAUSED_CHECKBOX);
// sound software mixing buffer checkbox
if (gSound_config.forced_software_buffering)
if (gConfigSound.forced_software_buffering)
w->pressed_widgets |= (1ULL << WIDX_SOUND_SW_BUFFER_CHECKBOX);
else
w->pressed_widgets &= ~(1ULL << WIDX_SOUND_SW_BUFFER_CHECKBOX);
@@ -746,7 +746,7 @@ static void window_options_invalidate()
break;
case WINDOW_OPTIONS_PAGE_INPUT:
// screen edge scrolling checkbox
if (gGeneral_config.edge_scrolling)
if (gConfigGeneral.edge_scrolling)
w->pressed_widgets |= (1ULL << WIDX_SCREEN_EDGE_SCROLLING);
else
w->pressed_widgets &= ~(1ULL << WIDX_SCREEN_EDGE_SCROLLING);
@@ -762,7 +762,7 @@ static void window_options_invalidate()
w->pressed_widgets &= ~(1ULL << WIDX_REAL_NAME_CHECKBOX);
// save plugin data checkbox
if (gGeneral_config.save_plugin_data)
if (gConfigGeneral.save_plugin_data)
w->pressed_widgets |= (1ULL << WIDX_SAVE_PLUGIN_DATA_CHECKBOX);
else
w->pressed_widgets &= ~(1ULL << WIDX_SAVE_PLUGIN_DATA_CHECKBOX);
@@ -835,7 +835,7 @@ static void window_options_paint()
gfx_draw_string_left(dpi, 2738, w, 12, w->x + 10, w->y + window_options_widgets[WIDX_TITLE_MUSIC].top + 1);
gfx_draw_string_left(
dpi,
2739 + gGeneral_config.title_music,
2739 + gConfigSound.title_music,
NULL,
12,
w->x + window_options_widgets[WIDX_TITLE_MUSIC].left + 1,
@@ -861,9 +861,9 @@ static void window_options_show_dropdown(rct_window *w, rct_widget *widget, int
static void window_options_update_height_markers()
{
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16) = gGeneral_config.show_height_as_units ?
0 : (gGeneral_config.measurement_format + 1) * 256;
config_save();
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16) = gConfigGeneral.show_height_as_units ?
0 : (gConfigGeneral.measurement_format + 1) * 256;
config_save_default();
gfx_invalidate_screen();
}

View File

@@ -174,7 +174,7 @@ void window_save_prompt_open()
window_save_prompt_widgets[WIDX_TITLE].image = stringId;
window_save_prompt_widgets[WIDX_LABEL].image = prompt_mode + STR_SAVE_BEFORE_LOADING;
if (!gGeneral_config.confirmation_prompt) {
if (!gConfigGeneral.confirmation_prompt) {
/* game_load_or_quit_no_save_prompt() will exec requested task and close this window
* immediately again.
* TODO restructure these functions when we're sure game_load_or_quit_no_save_prompt()

View File

@@ -128,7 +128,7 @@ static void window_shortcut_mouseup()
break;
case WIDX_RESET:
config_reset_shortcut_keys();
config_save();
config_save_default();
window_invalidate(w);
break;
}