mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 23:04:36 +01:00
refactor config and add window size
This commit is contained in:
@@ -985,7 +985,7 @@ void audio_init2(int device)
|
||||
}
|
||||
}
|
||||
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & 1 << 4)) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint32) = RCT2_GLOBAL(0x001425B74, uint32) != RCT2_GLOBAL(0x001425B78, uint32) || RCT2_GLOBAL(0x001425B74, uint32) != RCT2_GLOBAL(0x001425B7C, uint32);
|
||||
gSound_config.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();
|
||||
}
|
||||
|
||||
319
src/config.c
319
src/config.c
@@ -119,138 +119,6 @@ void config_reset_shortcut_keys()
|
||||
memcpy(gShortcutKeys, _defaultShortcutKeys, sizeof(gShortcutKeys));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the config file data/config.cfg
|
||||
* rct2: 0x006752D5
|
||||
*/
|
||||
void config_load()
|
||||
{
|
||||
FILE *fp=NULL;
|
||||
|
||||
const char *path = get_file_path(PATH_ID_GAMECFG);
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
|
||||
if (fp != NULL) {
|
||||
// Read and check magic number
|
||||
fread(RCT2_ADDRESS(0x013CE928, void), 1, 4, fp);
|
||||
|
||||
if (RCT2_GLOBAL(0x013CE928, int) == MagicNumber) {
|
||||
// Read options
|
||||
fread((void*)0x009AAC5C, 1, 2155, fp);
|
||||
fclose(fp);
|
||||
|
||||
//general configuration
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, sint8) = gGeneral_config.edge_scrolling;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, sint8) = gGeneral_config.currency_format;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) = gGeneral_config.measurement_format;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, sint8) = gGeneral_config.temperature_format;
|
||||
|
||||
// always show gridlines
|
||||
if (gGeneral_config.always_show_gridlines){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES;
|
||||
}
|
||||
else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= !CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES;
|
||||
}
|
||||
|
||||
// landscape smoothing
|
||||
if (!gGeneral_config.landscape_smoothing){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE;
|
||||
}
|
||||
else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= !CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE;
|
||||
}
|
||||
|
||||
// show height as units
|
||||
if (gGeneral_config.show_height_as_units){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS;
|
||||
}
|
||||
else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= !CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS;
|
||||
}
|
||||
|
||||
// save plugin data
|
||||
if (gGeneral_config.save_plugin_data){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_SAVE_PLUGIN_DATA;
|
||||
}
|
||||
else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= !CONFIG_FLAG_SAVE_PLUGIN_DATA;
|
||||
}
|
||||
|
||||
//sound configuration
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8) = gSound_config.sound_quality;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, sint8) = gSound_config.forced_software_buffering;
|
||||
|
||||
// Line below is temporaraly disabled until all config is in the new format.
|
||||
//if (RCT2_GLOBAL(0x009AB4C6, sint8) == 1)
|
||||
// return;
|
||||
|
||||
|
||||
RCT2_GLOBAL(0x009AB4C6, sint8) = 1; // no idea on what this does
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 2) * 256;
|
||||
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS))
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 1) * 256;
|
||||
RCT2_GLOBAL(0x009AA00D, sint8) = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* TODO: CLEANUP
|
||||
|
||||
if (RCT2_GLOBAL(0x009AB4C6, sint8) == 1)
|
||||
return;
|
||||
RCT2_GLOBAL(0x009AB4C6, sint8) = 1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, sint8) = 1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, sint8) = 1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = 0;
|
||||
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS))
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 1) * 256;
|
||||
RCT2_GLOBAL(0x009AA00D, sint8) = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8) = 0;
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_PHYSICAL, uint32) > 0x4000000) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8) = 1;
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_PHYSICAL, uint32) > 0x8000000)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8) = 2;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
RCT2_GLOBAL(0x009AAC75, sint8) = RCT2_ADDRESS(0x009AF601, sint8)[RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8)];
|
||||
RCT2_GLOBAL(0x009AAC76, sint8) = RCT2_ADDRESS(0x009AF604, sint8)[RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8)];
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = 0;
|
||||
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS))
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 1) * 256;
|
||||
RCT2_GLOBAL(0x009AA00D, sint8) = 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save configuration to the data/config.cfg file
|
||||
* rct2: 0x00675487
|
||||
*/
|
||||
void config_save()
|
||||
{
|
||||
FILE *fp=NULL;
|
||||
char *configIniPath = osinterface_get_orct2_homefolder();;
|
||||
|
||||
fp = fopen(get_file_path(PATH_ID_GAMECFG), "wb");
|
||||
if (fp != NULL){
|
||||
fwrite(&MagicNumber, 4, 1, fp);
|
||||
fwrite((void*)0x009AAC5C, 2155, 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
sprintf(configIniPath, "%s%c%s", configIniPath, osinterface_get_path_separator(), "config.ini");
|
||||
config_save_ini(configIniPath);
|
||||
}
|
||||
|
||||
void config_save_ini(char *path)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
@@ -383,15 +251,47 @@ void config_write_ini_general(FILE *fp)
|
||||
else
|
||||
fprintf(fp, "fullscreen_mode = borderless_fullscreen\n");
|
||||
|
||||
if (gGeneral_config.window_width != -1)
|
||||
fprintf(fp, "window_width = %d\n", gGeneral_config.window_width);
|
||||
if (gGeneral_config.window_height != -1)
|
||||
fprintf(fp, "window_height = %d\n", gGeneral_config.window_height);
|
||||
|
||||
fprintf(fp, "language = %d\n", gGeneral_config.language);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initilise the settings.
|
||||
* Any code not implemented in OpenRCT2 will still uses the old configuration option addresses. This function copies all the
|
||||
* OpenRCT2 configuration options to those addresses until the process is no longer necessary.
|
||||
*/
|
||||
void config_apply_to_old_addresses()
|
||||
{
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, sint8) = gGeneral_config.edge_scrolling;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, sint8) = gGeneral_config.currency_format;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) = gGeneral_config.measurement_format;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, sint8) = gGeneral_config.temperature_format;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CONSTRUCTION_MARKER, uint8) = gGeneral_config.construction_marker_colour;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8) = gSound_config.sound_quality;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, sint8) = gSound_config.forced_software_buffering;
|
||||
|
||||
int configFlags = 0;
|
||||
if (gGeneral_config.always_show_gridlines)
|
||||
configFlags |= CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES;
|
||||
if (!gGeneral_config.landscape_smoothing)
|
||||
configFlags |= CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE;
|
||||
if (gGeneral_config.show_height_as_units)
|
||||
configFlags |= CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS;
|
||||
if (gGeneral_config.save_plugin_data)
|
||||
configFlags |= CONFIG_FLAG_SAVE_PLUGIN_DATA;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) = configFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the settings.
|
||||
* It checks if the OpenRCT2 folder exists and creates it if it does not
|
||||
* parsing of the config file is done in config_parse_settings
|
||||
*/
|
||||
void config_init()
|
||||
void config_load()
|
||||
{
|
||||
char *path = osinterface_get_orct2_homefolder();
|
||||
FILE* fp;
|
||||
@@ -420,6 +320,18 @@ void config_init()
|
||||
}
|
||||
|
||||
free(path);
|
||||
|
||||
config_apply_to_old_addresses();
|
||||
}
|
||||
|
||||
void config_save()
|
||||
{
|
||||
char *configIniPath = osinterface_get_orct2_homefolder();;
|
||||
|
||||
sprintf(configIniPath, "%s%c%s", configIniPath, osinterface_get_path_separator(), "config.ini");
|
||||
config_save_ini(configIniPath);
|
||||
|
||||
config_apply_to_old_addresses();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -470,7 +382,6 @@ static void config_create_default(char *path)
|
||||
config_save_ini(path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse settings and set the game veriables
|
||||
* @param fp file pointer to the settings file
|
||||
@@ -510,7 +421,6 @@ static void config_parse_settings(FILE *fp)
|
||||
free(section);
|
||||
}
|
||||
|
||||
|
||||
static void config_sound(char *setting, char *value){
|
||||
if (strcmp(setting, "sound_quality") == 0){
|
||||
if (strcmp(value, "low") == 0){
|
||||
@@ -624,6 +534,12 @@ static void config_general(char *setting, char *value){
|
||||
else
|
||||
gGeneral_config.fullscreen_mode = 2;
|
||||
}
|
||||
else if (strcmp(setting, "window_width") == 0) {
|
||||
gGeneral_config.window_width = atoi(value);
|
||||
}
|
||||
else if (strcmp(setting, "window_height") == 0) {
|
||||
gGeneral_config.window_height = atoi(value);
|
||||
}
|
||||
else if (strcmp(setting, "language") == 0) {
|
||||
gGeneral_config.language = atoi(value);
|
||||
}
|
||||
@@ -823,3 +739,134 @@ static void config_error(char *msg){
|
||||
|
||||
}
|
||||
|
||||
#pragma region Obsolete
|
||||
|
||||
// The following functions are related to the original configuration file. This has now been replaced with a new configuration
|
||||
// INI file located in the user's OpenRCT2 home directory.
|
||||
|
||||
/**
|
||||
* Reads the config file data/config.cfg
|
||||
* rct2: 0x006752D5
|
||||
*/
|
||||
void config_dat_load()
|
||||
{
|
||||
FILE *fp=NULL;
|
||||
|
||||
const char *path = get_file_path(PATH_ID_GAMECFG);
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
|
||||
if (fp != NULL) {
|
||||
// Read and check magic number
|
||||
fread(RCT2_ADDRESS(0x013CE928, void), 1, 4, fp);
|
||||
|
||||
if (RCT2_GLOBAL(0x013CE928, int) == MagicNumber) {
|
||||
// Read options
|
||||
fread((void*)0x009AAC5C, 1, 2155, fp);
|
||||
fclose(fp);
|
||||
|
||||
//general configuration
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, sint8) = gGeneral_config.edge_scrolling;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, sint8) = gGeneral_config.currency_format;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) = gGeneral_config.measurement_format;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, sint8) = gGeneral_config.temperature_format;
|
||||
|
||||
// always show gridlines
|
||||
if (gGeneral_config.always_show_gridlines){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES;
|
||||
}
|
||||
else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= !CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES;
|
||||
}
|
||||
|
||||
// landscape smoothing
|
||||
if (!gGeneral_config.landscape_smoothing){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE;
|
||||
}
|
||||
else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= !CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE;
|
||||
}
|
||||
|
||||
// show height as units
|
||||
if (gGeneral_config.show_height_as_units){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS;
|
||||
}
|
||||
else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= !CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS;
|
||||
}
|
||||
|
||||
// save plugin data
|
||||
if (gGeneral_config.save_plugin_data){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_SAVE_PLUGIN_DATA;
|
||||
}
|
||||
else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= !CONFIG_FLAG_SAVE_PLUGIN_DATA;
|
||||
}
|
||||
|
||||
//sound configuration
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8) = gSound_config.sound_quality;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, sint8) = gSound_config.forced_software_buffering;
|
||||
|
||||
// Line below is temporaraly disabled until all config is in the new format.
|
||||
//if (RCT2_GLOBAL(0x009AB4C6, sint8) == 1)
|
||||
// return;
|
||||
|
||||
|
||||
RCT2_GLOBAL(0x009AB4C6, sint8) = 1; // no idea on what this does
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 2) * 256;
|
||||
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS))
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 1) * 256;
|
||||
RCT2_GLOBAL(0x009AA00D, sint8) = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* TODO: CLEANUP
|
||||
|
||||
if (RCT2_GLOBAL(0x009AB4C6, sint8) == 1)
|
||||
return;
|
||||
RCT2_GLOBAL(0x009AB4C6, sint8) = 1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, sint8) = 1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, sint8) = 1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = 0;
|
||||
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS))
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 1) * 256;
|
||||
RCT2_GLOBAL(0x009AA00D, sint8) = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8) = 0;
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_PHYSICAL, uint32) > 0x4000000) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8) = 1;
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_PHYSICAL, uint32) > 0x8000000)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8) = 2;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
RCT2_GLOBAL(0x009AAC75, sint8) = RCT2_ADDRESS(0x009AF601, sint8)[RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8)];
|
||||
RCT2_GLOBAL(0x009AAC76, sint8) = RCT2_ADDRESS(0x009AF604, sint8)[RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, sint8)];
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = 0;
|
||||
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS))
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 1) * 256;
|
||||
RCT2_GLOBAL(0x009AA00D, sint8) = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save configuration to the data/config.cfg file
|
||||
* rct2: 0x00675487
|
||||
*/
|
||||
void config_dat_save()
|
||||
{
|
||||
FILE *fp = fopen(get_file_path(PATH_ID_GAMECFG), "wb");
|
||||
if (fp != NULL){
|
||||
fwrite(&MagicNumber, 4, 1, fp);
|
||||
fwrite((void*)0x009AAC5C, 2155, 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -166,6 +166,4 @@ typedef struct shortcut_entry{
|
||||
extern general_configuration_t gGeneral_config;
|
||||
extern sound_configuration_t gSound_config;
|
||||
|
||||
void config_init();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -173,9 +173,8 @@ void viewport_create(rct_window *w, int x, int y, int width, int height, int zoo
|
||||
viewport->zoom = zoom;
|
||||
viewport->flags = 0;
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_KEYBOARD_SHORTCUTS, uint8) & 1){
|
||||
if (gGeneral_config.always_show_gridlines)
|
||||
viewport->flags |= VIEWPORT_FLAG_GRIDLINES;
|
||||
}
|
||||
w->viewport = viewport;
|
||||
|
||||
if (flags & VIEWPORT_FOCUS_TYPE_SPRITE){
|
||||
@@ -958,7 +957,7 @@ void hide_gridlines()
|
||||
RCT2_GLOBAL(0x009E32B0, uint8)--;
|
||||
if (RCT2_GLOBAL(0x009E32B0, uint8) == 0) {
|
||||
if ((mainWindow = window_get_main()) != NULL) {
|
||||
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES)) {
|
||||
if (!gGeneral_config.always_show_gridlines) {
|
||||
mainWindow->viewport->flags &= ~VIEWPORT_FLAG_GRIDLINES;
|
||||
window_invalidate(mainWindow);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ static void openrct2_loop();
|
||||
*/
|
||||
void openrct2_launch()
|
||||
{
|
||||
config_init();
|
||||
config_load();
|
||||
|
||||
// TODO add configuration option to allow multiple instances
|
||||
if (!platform_lock_single_instance()) {
|
||||
|
||||
@@ -82,7 +82,7 @@ void rct2_init()
|
||||
rct2_startup_checks();
|
||||
config_reset_shortcut_keys();
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0;
|
||||
config_load();
|
||||
// config_load();
|
||||
// RCT2_CALLPROC_EBPSAFE(0x00674B81); // pointless expansion pack crap
|
||||
object_list_load();
|
||||
scenario_load_list();
|
||||
@@ -91,9 +91,7 @@ void rct2_init()
|
||||
track_load_list(item);
|
||||
|
||||
gfx_load_g1();
|
||||
//RCT2_CALLPROC_EBPSAFE(0x006C19AC); //Load character widths
|
||||
gfx_load_character_widths();
|
||||
|
||||
osinterface_init();
|
||||
audio_init1();//RCT2_CALLPROC_EBPSAFE(0x006BA8E0); // init_audio();
|
||||
viewport_init_all();
|
||||
|
||||
@@ -82,7 +82,7 @@ void window_main_open()
|
||||
window->widgets = window_main_widgets;
|
||||
|
||||
viewport_create(window, window->x, window->y, window->width, window->height, 0,0x0FFF,0x0FFF, 0, 0x1, -1);
|
||||
window->viewport->flags |= 0x0400;
|
||||
window->viewport->flags |= VIEWPORT_FLAG_SOUND_ON;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32) = 0;
|
||||
RCT2_GLOBAL(0x009E32B0, uint8) = 0;
|
||||
RCT2_GLOBAL(0x009E32B2, uint8) = 0;
|
||||
@@ -97,7 +97,8 @@ void window_main_open()
|
||||
* This function immediately jumps to 0x00685BE1 this is the second function
|
||||
* decompiled.
|
||||
*/
|
||||
void window_main_paint(){
|
||||
void window_main_paint()
|
||||
{
|
||||
rct_window* w;
|
||||
rct_drawpixelinfo* dpi;
|
||||
|
||||
|
||||
@@ -288,74 +288,47 @@ static void window_options_mouseup()
|
||||
window_shortcut_keys_open();
|
||||
break;
|
||||
case WIDX_SCREEN_EDGE_SCROLLING:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, uint8) ^= 1;
|
||||
gGeneral_config.edge_scrolling ^= 1;
|
||||
config_save();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_REAL_NAME_CHECKBOX:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) ^= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_SHOW_REAL_GUEST_NAMES)
|
||||
#ifdef _MSC_VER
|
||||
__asm xor al, al
|
||||
#else
|
||||
__asm__ ( "xor al, al " );
|
||||
#endif
|
||||
|
||||
else
|
||||
#ifdef _MSC_VER
|
||||
__asm mov al, 1
|
||||
#else
|
||||
__asm__ ( "mov al, 1 " );
|
||||
#endif
|
||||
|
||||
|
||||
RCT2_CALLPROC_EBPSAFE(0x0069C52F);
|
||||
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:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) ^= CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE;
|
||||
gGeneral_config.landscape_smoothing = !(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8)
|
||||
& CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE);
|
||||
gGeneral_config.landscape_smoothing ^= 1;
|
||||
config_save();
|
||||
gfx_invalidate_screen();
|
||||
break;
|
||||
case WIDX_GRIDLINES_CHECKBOX:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) ^= CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES;
|
||||
gGeneral_config.always_show_gridlines = RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8)
|
||||
& CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES;
|
||||
gGeneral_config.always_show_gridlines ^= 1;
|
||||
config_save();
|
||||
gfx_invalidate_screen();
|
||||
|
||||
if ((w = window_get_main()) != NULL) {
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES)
|
||||
if (gGeneral_config.always_show_gridlines)
|
||||
w->viewport->flags |= VIEWPORT_FLAG_GRIDLINES;
|
||||
else
|
||||
w->viewport->flags &= ~VIEWPORT_FLAG_GRIDLINES;
|
||||
}
|
||||
break;
|
||||
case WIDX_SAVE_PLUGIN_DATA_CHECKBOX:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) ^= CONFIG_FLAG_SAVE_PLUGIN_DATA;
|
||||
gGeneral_config.save_plugin_data = !(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8)
|
||||
& CONFIG_FLAG_SAVE_PLUGIN_DATA);
|
||||
gGeneral_config.save_plugin_data ^= 1;
|
||||
config_save();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_SOUND_SW_BUFFER_CHECKBOX:
|
||||
pause_sounds();
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint8) ^= 1;
|
||||
gSound_config.forced_software_buffering ^= 1;
|
||||
config_save();
|
||||
unpause_sounds();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_SOUND_PAUSED_CHECKBOX:
|
||||
if (g_sounds_disabled){
|
||||
if (g_sounds_disabled)
|
||||
unpause_sounds();
|
||||
}
|
||||
else{
|
||||
else
|
||||
pause_sounds();
|
||||
}
|
||||
window_invalidate(w);
|
||||
break;
|
||||
}
|
||||
@@ -391,9 +364,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
|
||||
|
||||
window_options_show_dropdown(w, widget, 2);
|
||||
|
||||
gDropdownItemsChecked =
|
||||
(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &
|
||||
CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS) ? 1 : 2;
|
||||
gDropdownItemsChecked = gGeneral_config.show_height_as_units ? 1 : 2;
|
||||
break;
|
||||
case WIDX_MUSIC_DROPDOWN:
|
||||
gDropdownItemsFormat[0] = 1142;
|
||||
@@ -415,19 +386,19 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
|
||||
|
||||
window_options_show_dropdown(w, widget, num_items);
|
||||
|
||||
gDropdownItemsChecked = 1 << RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, uint8);
|
||||
gDropdownItemsChecked = 1 << gSound_config.sound_quality;
|
||||
break;
|
||||
case WIDX_CURRENCY_DROPDOWN:
|
||||
num_items = 10;
|
||||
|
||||
for (i = 0; i < num_items; i++) {
|
||||
gDropdownItemsFormat[i] = 1142;
|
||||
gDropdownItemsArgs[i] = STR_POUNDS + i; // all different currencies
|
||||
gDropdownItemsArgs[i] = STR_POUNDS + i;
|
||||
}
|
||||
|
||||
window_options_show_dropdown(w, widget, num_items);
|
||||
|
||||
gDropdownItemsChecked = 1 << (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, uint8) & 0x3F);
|
||||
gDropdownItemsChecked = 1 << gGeneral_config.currency_format;
|
||||
break;
|
||||
case WIDX_DISTANCE_DROPDOWN:
|
||||
gDropdownItemsFormat[0] = 1142;
|
||||
@@ -437,7 +408,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
|
||||
|
||||
window_options_show_dropdown(w, widget, 2);
|
||||
|
||||
gDropdownItemsChecked = 1 << RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8);
|
||||
gDropdownItemsChecked = 1 << gGeneral_config.measurement_format;
|
||||
break;
|
||||
case WIDX_RESOLUTION_DROPDOWN:
|
||||
// RCT2_CALLPROC_EBPSAFE(0x006BB2AF);
|
||||
@@ -462,7 +433,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
|
||||
|
||||
window_options_show_dropdown(w, widget, 2);
|
||||
|
||||
gDropdownItemsChecked = 1 << RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, uint8);
|
||||
gDropdownItemsChecked = 1 << gGeneral_config.temperature_format;
|
||||
break;
|
||||
case WIDX_CONSTRUCTION_MARKER_DROPDOWN:
|
||||
gDropdownItemsFormat[0] = 1142;
|
||||
@@ -472,7 +443,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
|
||||
|
||||
window_options_show_dropdown(w, widget, 2);
|
||||
|
||||
gDropdownItemsChecked = 1 << RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CONSTRUCTION_MARKER, uint8);
|
||||
gDropdownItemsChecked = 1 << gGeneral_config.construction_marker_colour;
|
||||
break;
|
||||
case WIDX_LANGUAGE_DROPDOWN:
|
||||
for (i = 1; i < LANGUAGE_COUNT; i++) {
|
||||
@@ -541,8 +512,6 @@ static void window_options_dropdown()
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_SOUND_QUALITY_DROPDOWN:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, uint8) = (uint8)dropdownIndex;
|
||||
|
||||
// TODO: no clue what this does (and if it's correct)
|
||||
RCT2_GLOBAL(0x009AAC75, uint8) = RCT2_GLOBAL(0x009AF601 + dropdownIndex, uint8);
|
||||
RCT2_GLOBAL(0x009AAC76, uint8) = RCT2_GLOBAL(0x009AF604 + dropdownIndex, uint8);
|
||||
@@ -551,13 +520,11 @@ static void window_options_dropdown()
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_CURRENCY_DROPDOWN:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, uint8) = dropdownIndex | 0xC0;
|
||||
gGeneral_config.currency_format = (sint8)dropdownIndex;
|
||||
config_save();
|
||||
gfx_invalidate_screen();
|
||||
break;
|
||||
case WIDX_DISTANCE_DROPDOWN:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8) = (uint8)dropdownIndex;
|
||||
gGeneral_config.measurement_format = (sint8)dropdownIndex;
|
||||
config_save();
|
||||
window_options_update_height_markers();
|
||||
@@ -584,16 +551,15 @@ static void window_options_dropdown()
|
||||
}
|
||||
break;
|
||||
case WIDX_TEMPERATURE_DROPDOWN:
|
||||
if (dropdownIndex != RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, uint8)) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, uint8) = (uint8)dropdownIndex;
|
||||
if (dropdownIndex != gGeneral_config.temperature_format) {
|
||||
gGeneral_config.temperature_format = (sint8)dropdownIndex;
|
||||
config_save();
|
||||
gfx_invalidate_screen();
|
||||
}
|
||||
break;
|
||||
case WIDX_CONSTRUCTION_MARKER_DROPDOWN:
|
||||
if (dropdownIndex != RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CONSTRUCTION_MARKER, uint8)) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CONSTRUCTION_MARKER, uint8) = (uint8)dropdownIndex;
|
||||
if (dropdownIndex != gGeneral_config.construction_marker_colour) {
|
||||
gGeneral_config.construction_marker_colour = (uint8)dropdownIndex;
|
||||
config_save();
|
||||
gfx_invalidate_screen();
|
||||
}
|
||||
@@ -659,17 +625,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 + (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, uint8) & 0x3F);
|
||||
RCT2_GLOBAL(0x013CE952 + 12, uint16) = STR_POUNDS + gGeneral_config.currency_format;
|
||||
|
||||
// distance: metric/imperial
|
||||
RCT2_GLOBAL(0x013CE952 + 14, uint16) = STR_IMPERIAL + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8);
|
||||
RCT2_GLOBAL(0x013CE952 + 14, uint16) = STR_IMPERIAL + gGeneral_config.measurement_format;
|
||||
|
||||
// temperature: celsius/fahrenheit
|
||||
RCT2_GLOBAL(0x013CE952 + 20, uint16) = STR_CELSIUS + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, uint8);
|
||||
RCT2_GLOBAL(0x013CE952 + 20, uint16) = STR_CELSIUS + gGeneral_config.temperature_format;
|
||||
|
||||
// height: units/real values
|
||||
RCT2_GLOBAL(0x013CE952 + 6, uint16) =
|
||||
((RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS)) ? STR_UNITS : STR_REAL_VALUES;
|
||||
RCT2_GLOBAL(0x013CE952 + 6, uint16) = gGeneral_config.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;
|
||||
@@ -697,7 +662,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 + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, uint8);
|
||||
RCT2_GLOBAL(0x013CE952 + 10, uint16) = STR_SOUND_LOW + gSound_config.sound_quality;
|
||||
|
||||
//Sound pause checkbox
|
||||
if (!g_sounds_disabled)
|
||||
@@ -706,7 +671,7 @@ static void window_options_invalidate()
|
||||
w->pressed_widgets &= ~(1ULL << WIDX_SOUND_PAUSED_CHECKBOX);
|
||||
|
||||
// sound software mixing buffer checkbox
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint8))
|
||||
if (gSound_config.forced_software_buffering)
|
||||
w->pressed_widgets |= (1ULL << WIDX_SOUND_SW_BUFFER_CHECKBOX);
|
||||
else
|
||||
w->pressed_widgets &= ~(1ULL << WIDX_SOUND_SW_BUFFER_CHECKBOX);
|
||||
@@ -722,7 +687,7 @@ static void window_options_invalidate()
|
||||
break;
|
||||
case WINDOW_OPTIONS_PAGE_INPUT:
|
||||
// screen edge scrolling checkbox
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, uint8))
|
||||
if (gGeneral_config.edge_scrolling)
|
||||
w->pressed_widgets |= (1ULL << WIDX_SCREEN_EDGE_SCROLLING);
|
||||
else
|
||||
w->pressed_widgets &= ~(1ULL << WIDX_SCREEN_EDGE_SCROLLING);
|
||||
@@ -738,7 +703,7 @@ static void window_options_invalidate()
|
||||
w->pressed_widgets &= ~(1ULL << WIDX_REAL_NAME_CHECKBOX);
|
||||
|
||||
// save plugin data checkbox
|
||||
if ((RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SAVE_PLUGIN_DATA))
|
||||
if (gGeneral_config.save_plugin_data)
|
||||
w->pressed_widgets |= (1ULL << WIDX_SAVE_PLUGIN_DATA_CHECKBOX);
|
||||
else
|
||||
w->pressed_widgets &= ~(1ULL << WIDX_SAVE_PLUGIN_DATA_CHECKBOX);
|
||||
@@ -828,13 +793,8 @@ static void window_options_show_dropdown(rct_window *w, rct_widget *widget, int
|
||||
|
||||
static void window_options_update_height_markers()
|
||||
{
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16) = 0;
|
||||
} else { // use real values (metric or imperial)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16) =
|
||||
(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint16) + 1) * 256;
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16) = gGeneral_config.show_height_as_units ?
|
||||
0 : (gGeneral_config.show_height_as_units + 1) * 256;
|
||||
config_save();
|
||||
gfx_invalidate_screen();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user