diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index ed94a9158b..73de4e65e8 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3486,7 +3486,7 @@ STR_5149 :{SMALLFONT}{BLACK}Open the cheats window STR_5150 :Enable debugging tools STR_5151 :, STR_5152 :. -STR_5153 :Colour schemes... +STR_5153 :Edit Themes... STR_5154 :Hardware display STR_5155 :Allow testing of unfinished tracks STR_5156 :{SMALLFONT}{BLACK}Allows testing of most ride types even when the track is unfinished, does not apply to block sectioned modes @@ -3551,7 +3551,7 @@ STR_5214 :Map Generation STR_5215 :Track Design Manager STR_5216 :Track Design Manager List STR_5217 :Cheats -STR_5218 :Colour Schemes +STR_5218 :Themes STR_5219 :Options STR_5220 :Keyboard Shortcuts STR_5221 :Change Keyboard Shortcut @@ -3571,13 +3571,13 @@ STR_5234 :{SMALLFONT}{BLACK}Prompts STR_5235 :{SMALLFONT}{BLACK}Settings STR_5236 :Window: STR_5237 :Palette: -STR_5238 :Colour Schemes: +STR_5238 :Current Theme: STR_5239 :Duplicate -STR_5240 :Enter a name for the colour scheme +STR_5240 :Enter a name for the theme STR_5241 :Can't change this preset STR_5242 :Preset name already exists STR_5243 :Invalid characters used -STR_5244 :Colour schemes +STR_5244 :Themes STR_5245 :Top Toolbar STR_5246 :Bottom Toolbar STR_5247 :Track Editor Bottom Toolbar @@ -3589,3 +3589,7 @@ STR_5252 :Title Scenario Selection STR_5253 :Park Information STR_5254 :Add nausea STR_5255 :{MEDIUMFONT}{BLACK}All peeps become nauseous +STR_5256 :Create a new theme to make changes to +STR_5257 :{SMALLFONT}{BLACK}Create a new theme based on the current one +STR_5258 :{SMALLFONT}{BLACK}Delete the current theme +STR_5259 :{SMALLFONT}{BLACK}Rename the current theme diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index cc5a145480..7ffaf599b9 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -37,7 +37,7 @@ - + @@ -145,7 +145,7 @@ - + @@ -175,7 +175,7 @@ - + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index a62688e2ec..b4708cd894 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -450,12 +450,12 @@ Source\Network - - Source\Windows - - + Source\Interface + + Source\Windows + @@ -668,7 +668,7 @@ Source\Network - + Source\Interface diff --git a/src/config.c b/src/config.c index 0202917af0..a7157668b7 100644 --- a/src/config.c +++ b/src/config.c @@ -23,7 +23,7 @@ #include "localisation/language.h" #include "localisation/localisation.h" #include "util/util.h" -#include "interface/colour_schemes.h" +#include "interface/themes.h" // Magic number for original game cfg file static const int MagicNumber = 0x0003113A; @@ -182,7 +182,7 @@ config_property_definition _interfaceDefinitions[] = { { offsetof(interface_configuration, toolbar_show_cheats), "toolbar_show_cheats", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL }, { offsetof(interface_configuration, allow_subtype_switching), "allow_subtype_switching", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL }, { offsetof(interface_configuration, console_small_font), "console_small_font", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL }, - { offsetof(interface_configuration, current_colour_scheme_preset), "colour_scheme_preset", CONFIG_VALUE_TYPE_STRING, { .value_string = "*RCT2" }, NULL }, + { offsetof(interface_configuration, current_theme_preset), "current_theme", CONFIG_VALUE_TYPE_STRING, { .value_string = "*RCT2" }, NULL }, }; config_property_definition _soundDefinitions[] = { @@ -224,7 +224,7 @@ interface_configuration gConfigInterface; sound_configuration gConfigSound; cheat_configuration gConfigCheat; twitch_configuration gConfigTwitch; -colour_schemes_configuration gConfigColourSchemes; +themes_configuration gConfigThemes; bool config_open(const utf8string path); bool config_save(const utf8string path); @@ -999,37 +999,37 @@ bool config_shortcut_keys_save() #pragma endregion -#pragma region Colour Schemes +#pragma region Themes -static void colour_schemes_remove_extension(char *path); -static bool colour_schemes_open(const utf8string path); -static bool colour_schemes_save(const utf8string path, int preset); -static void colour_schemes_read_properties(int preset, window_colours **current_window_colours, const_utf8string line); -static void colour_schemes_set_property(window_colours *colour_scheme, utf8string name, utf8string value); +static void themes_remove_extension(char *path); +static bool themes_open(const utf8string path); +static bool themes_save(const utf8string path, int preset); +static void themes_read_properties(int preset, window_colours **current_window_colours, const_utf8string line); +static void themes_set_property(window_colours *colour_scheme, utf8string name, utf8string value); -void colour_schemes_set_default() +void themes_set_default() { utf8 path[MAX_PATH]; - platform_get_user_directory(path, "colour schemes"); + platform_get_user_directory(path, "themes"); platform_ensure_directory_exists(path); - gConfigColourSchemes.num_presets = 2; - gConfigColourSchemes.presets = malloc(sizeof(colour_scheme_preset) * gConfigColourSchemes.num_presets); + gConfigThemes.num_presets = 2; + gConfigThemes.presets = malloc(sizeof(theme_preset) * gConfigThemes.num_presets); // Set RCT2 colour scheme - strcpy(gConfigColourSchemes.presets[0].name, language_get_string(2741)); - gConfigColourSchemes.presets[0].colour_schemes = malloc(sizeof(window_colours) * gNumColourSchemeWindows); + strcpy(gConfigThemes.presets[0].name, language_get_string(2741)); + gConfigThemes.presets[0].colour_schemes = malloc(sizeof(window_colours) * gNumColourSchemeWindows); for (int i = 0; i < (int)gNumColourSchemeWindows; i++) { for (int j = 0; j < 6; j++) - gConfigColourSchemes.presets[0].colour_schemes[i].colours[j] = gColourSchemes[i].colours[j]; + gConfigThemes.presets[0].colour_schemes[i].colours[j] = gColourSchemes[i].colours[j]; } // Set RCT1 colour scheme - strcpy(gConfigColourSchemes.presets[1].name, language_get_string(2740)); - gConfigColourSchemes.presets[1].colour_schemes = malloc(sizeof(window_colours) * gNumColourSchemeWindows); + strcpy(gConfigThemes.presets[1].name, language_get_string(2740)); + gConfigThemes.presets[1].colour_schemes = malloc(sizeof(window_colours) * gNumColourSchemeWindows); for (int i = 0; i < (int)gNumColourSchemeWindows; i++) { uint8 changed_colour = 0xFF; for (int k = 0; gColourSchemesRCT1[k].classification != 0xFF; k++) { @@ -1039,61 +1039,61 @@ void colour_schemes_set_default() } } for (int j = 0; j < 6; j++) { - gConfigColourSchemes.presets[1].colour_schemes[i].colours[j] = (changed_colour != 0xFF ? gColourSchemesRCT1[changed_colour].colours[j] : gColourSchemes[i].colours[j]); + gConfigThemes.presets[1].colour_schemes[i].colours[j] = (changed_colour != 0xFF ? gColourSchemesRCT1[changed_colour].colours[j] : gColourSchemes[i].colours[j]); } } } -void colour_schemes_load_presets() +void themes_load_presets() { utf8 path[MAX_PATH]; file_info file; int fileEnumHandle, i; - platform_get_user_directory(path, "colour schemes"); + platform_get_user_directory(path, "themes"); strcat(path, "*.ini"); fileEnumHandle = platform_enumerate_files_begin(path); while (platform_enumerate_files_next(fileEnumHandle, &file)) { - platform_get_user_directory(path, "colour schemes"); + platform_get_user_directory(path, "themes"); strcat(path, file.path); - colour_schemes_open(path); + themes_open(path); } platform_enumerate_files_end(fileEnumHandle); - if (strcmp(gConfigInterface.current_colour_scheme_preset, "*RCT2") == 0) { - colour_scheme_change_preset(0); + if (strcmp(gConfigInterface.current_theme_preset, "*RCT2") == 0) { + theme_change_preset(0); } - else if (strcmp(gConfigInterface.current_colour_scheme_preset, "*RCT1") == 0) { - colour_scheme_change_preset(1); + else if (strcmp(gConfigInterface.current_theme_preset, "*RCT1") == 0) { + theme_change_preset(1); } else { - for (i = 2; i < gConfigColourSchemes.num_presets; i++) { - if (strcmp(gConfigInterface.current_colour_scheme_preset, gConfigColourSchemes.presets[i].name) == 0) { - colour_scheme_change_preset(i); + for (i = 2; i < gConfigThemes.num_presets; i++) { + if (strcmp(gConfigInterface.current_theme_preset, gConfigThemes.presets[i].name) == 0) { + theme_change_preset(i); break; } } - if (i == gConfigColourSchemes.num_presets) { - colour_scheme_change_preset(0); + if (i == gConfigThemes.num_presets) { + theme_change_preset(0); } } } -bool colour_schemes_save_preset(int preset) +bool themes_save_preset(int preset) { utf8 path[MAX_PATH]; - platform_get_user_directory(path, "colour schemes"); - strcat(path, gConfigColourSchemes.presets[preset].name); + platform_get_user_directory(path, "themes"); + strcat(path, gConfigThemes.presets[preset].name); strcat(path, ".ini"); - if (colour_schemes_save(path, preset)) { + if (themes_save(path, preset)) { return true; } return false; } -bool colour_schemes_open(const utf8string path) +bool themes_open(const utf8string path) { FILE *file; uint8 *lineBuffer; @@ -1108,21 +1108,21 @@ bool colour_schemes_open(const utf8string path) // Check if the colour scheme is already loaded // No nead to read the first two presets as they're hardcoded in - for (preset = 2; preset < gConfigColourSchemes.num_presets; preset++) { - if (strcmp(path, gConfigColourSchemes.presets[preset].name) == 0) { + for (preset = 2; preset < gConfigThemes.num_presets; preset++) { + if (strcmp(path, gConfigThemes.presets[preset].name) == 0) { break; } } // Otherwise allocate one - if (preset == gConfigColourSchemes.num_presets) { - gConfigColourSchemes.num_presets++; - gConfigColourSchemes.presets = realloc(gConfigColourSchemes.presets, sizeof(colour_scheme_preset) * gConfigColourSchemes.num_presets); - strcpy(gConfigColourSchemes.presets[preset].name, path_get_filename(path)); - colour_schemes_remove_extension(gConfigColourSchemes.presets[preset].name); - gConfigColourSchemes.presets[preset].colour_schemes = malloc(sizeof(window_colours) * gNumColourSchemeWindows); + if (preset == gConfigThemes.num_presets) { + gConfigThemes.num_presets++; + gConfigThemes.presets = realloc(gConfigThemes.presets, sizeof(theme_preset) * gConfigThemes.num_presets); + strcpy(gConfigThemes.presets[preset].name, path_get_filename(path)); + themes_remove_extension(gConfigThemes.presets[preset].name); + gConfigThemes.presets[preset].colour_schemes = malloc(sizeof(window_colours) * gNumColourSchemeWindows); for (int i = 0; i < (int)gNumColourSchemeWindows; i++) { for (int j = 0; j < 6; j++) - gConfigColourSchemes.presets[preset].colour_schemes[i].colours[j] = gColourSchemes[i].colours[j]; + gConfigThemes.presets[preset].colour_schemes[i].colours[j] = gColourSchemes[i].colours[j]; } } @@ -1139,7 +1139,7 @@ bool colour_schemes_open(const utf8string path) while ((c = fgetc(file)) != EOF) { if (c == '\n' || c == '\r') { lineBuffer[lineLength++] = 0; - colour_schemes_read_properties(preset, ¤tColourScheme, (const_utf8string)lineBuffer); + themes_read_properties(preset, ¤tColourScheme, (const_utf8string)lineBuffer); lineLength = 0; } else { @@ -1154,7 +1154,7 @@ bool colour_schemes_open(const utf8string path) if (lineLength > 0) { lineBuffer[lineLength++] = 0; - colour_schemes_read_properties(preset, ¤tColourScheme, lineBuffer); + themes_read_properties(preset, ¤tColourScheme, lineBuffer); } free(lineBuffer); @@ -1162,7 +1162,7 @@ bool colour_schemes_open(const utf8string path) return true; } -static bool colour_schemes_save(const utf8string path, int preset) +static bool themes_save(const utf8string path, int preset) { FILE *file; int i, j; @@ -1175,7 +1175,7 @@ static bool colour_schemes_save(const utf8string path, int preset) for (i = 0; i < (int)gNumColourSchemeWindows; i++) { window_colour_scheme* colour_scheme_info = &gColourSchemes[i]; - window_colours* colour_scheme = &gConfigColourSchemes.presets[preset].colour_schemes[i]; + window_colours* colour_scheme = &gConfigThemes.presets[preset].colour_schemes[i]; fputc('[', file); fwrite(colour_scheme_info->section_name, strlen(colour_scheme_info->section_name), 1, file); @@ -1196,7 +1196,7 @@ static bool colour_schemes_save(const utf8string path, int preset) return true; } -static void colour_schemes_read_properties(int preset, window_colours **colour_scheme, const_utf8string line) +static void themes_read_properties(int preset, window_colours **colour_scheme, const_utf8string line) { utf8string ch = (utf8string)line; utf8_skip_whitespace(&ch); @@ -1208,7 +1208,7 @@ static void colour_schemes_read_properties(int preset, window_colours **colour_s sectionName[strlen(sectionName) - 1] = '\0'; for (int i = 0; i < (int)gNumColourSchemeWindows; i++) { if (strcmp(sectionName, gColourSchemes[i].section_name) == 0) { - *colour_scheme = &(gConfigColourSchemes.presets[preset].colour_schemes[i]); + *colour_scheme = &(gConfigThemes.presets[preset].colour_schemes[i]); break; } } @@ -1220,13 +1220,13 @@ static void colour_schemes_read_properties(int preset, window_colours **colour_s int propertyNameSize, valueSize; if (config_get_property_name_value(ch, &propertyName, &propertyNameSize, &value, &valueSize)) { propertyName[propertyNameSize] = '\0'; - colour_schemes_set_property(*colour_scheme, propertyName, value); + themes_set_property(*colour_scheme, propertyName, value); } } } } -static void colour_schemes_set_property(window_colours *colour_scheme, utf8string name, utf8string value) +static void themes_set_property(window_colours *colour_scheme, utf8string name, utf8string value) { const_utf8string colour_names[] = { "colour_0", "colour_1", "colour_2", "colour_3", "colour_4", "colour_5" }; @@ -1237,7 +1237,7 @@ static void colour_schemes_set_property(window_colours *colour_scheme, utf8strin } } -static void colour_schemes_remove_extension(char *path) +static void themes_remove_extension(char *path) { char *ch; diff --git a/src/config.h b/src/config.h index f0b9354f22..7765f6b3ad 100644 --- a/src/config.h +++ b/src/config.h @@ -147,7 +147,7 @@ typedef struct { uint8 toolbar_show_cheats; uint8 allow_subtype_switching; uint8 console_small_font; - utf8string current_colour_scheme_preset; + utf8string current_theme_preset; } interface_configuration; typedef struct { @@ -181,12 +181,12 @@ typedef struct { typedef struct { window_colours *colour_schemes; char name[256]; -} colour_scheme_preset; +} theme_preset; typedef struct { - colour_scheme_preset *presets; + theme_preset *presets; uint16 num_presets; -} colour_schemes_configuration; +} themes_configuration; typedef struct { uint8 key; @@ -198,7 +198,7 @@ extern interface_configuration gConfigInterface; extern sound_configuration gConfigSound; extern cheat_configuration gConfigCheat; extern twitch_configuration gConfigTwitch; -extern colour_schemes_configuration gConfigColourSchemes; +extern themes_configuration gConfigThemes; extern uint16 gShortcutKeys[SHORTCUT_COUNT]; @@ -214,8 +214,8 @@ bool config_shortcut_keys_save(); bool config_find_or_browse_install_directory(); -void colour_schemes_set_default(); -void colour_schemes_load_presets(); -bool colour_schemes_save_preset(int preset); +void themes_set_default(); +void themes_load_presets(); +bool themes_save_preset(int preset); #endif diff --git a/src/interface/console.c b/src/interface/console.c index 2ae81a966a..b5348db336 100644 --- a/src/interface/console.c +++ b/src/interface/console.c @@ -780,8 +780,8 @@ static int cc_open(const char **argv, int argc) { window_editor_inventions_list_open(); } else if (strcmp(argv[0], "options") == 0) { window_options_open(); - } else if (strcmp(argv[0], "colour_schemes") == 0) { - window_colour_schemes_open(); + } else if (strcmp(argv[0], "themes") == 0) { + window_themes_open(); } else { console_writeline_error("Invalid window."); @@ -831,7 +831,7 @@ char* console_window_table[] = { "object_selection", "inventions_list", "options", - "colour_schemes" + "themes" }; console_command console_command_table[] = { diff --git a/src/interface/colour_schemes.c b/src/interface/themes.c similarity index 78% rename from src/interface/colour_schemes.c rename to src/interface/themes.c index ab6ccb56f1..06f66687ae 100644 --- a/src/interface/colour_schemes.c +++ b/src/interface/themes.c @@ -21,7 +21,7 @@ #include "../config.h" #include "../localisation/string_ids.h" #include "window.h" -#include "colour_schemes.h" +#include "themes.h" window_colour_scheme gColourSchemes[] = { { WC_TOP_TOOLBAR, { 7, 12, 24, 1, 0, 0 }, 4, 5245, "top_toolbar" }, @@ -70,7 +70,7 @@ window_colour_scheme gColourSchemes[] = { { WC_LOADSAVE_OVERWRITE_PROMPT, { 154, 0, 0, 0, 0, 0 }, 1, 5227, "loadsave_overwrite_prompt" }, { WC_TITLE_OPTIONS, { 140, 140, 140, 0, 0, 0 }, 3, 5251, "title_options" }, { WC_LAND_RIGHTS, { 19, 19, 19, 0, 0, 0 }, 3, 5196, "land_rights" }, - { WC_COLOUR_SCHEMES, { 1, 12, 12, 0, 0, 0 }, 3, 5218, "colour_schemes" }, + { WC_THEMES, { 1, 12, 12, 0, 0, 0 }, 3, 5218, "themes" }, { WC_STAFF, { 1, 4, 4, 0, 0, 0 }, 3, 5207, "staff" }, { WC_EDITOR_TRACK_BOTTOM_TOOLBAR, { 135, 135, 135, 0, 0, 0 }, 3, 5247, "editor_track_bottom_toolbar" }, { WC_EDITOR_SCENARIO_BOTTOM_TOOLBAR, { 150, 150, 141, 0, 0, 0 }, 3, 5248, "editor_scenario_bottom_toolbar" }, @@ -97,7 +97,7 @@ marked_window_colours gColourSchemesRCT1[sizeof(gColourSchemes)] = { { 0xFF, { 0, 0, 0, 0, 0, 0 } } // End }; -uint16 gCurrentColourSchemePreset = 0; +uint16 gCurrentTheme = 0; uint32 gNumColourSchemeWindows = sizeof(gColourSchemes) / sizeof(window_colour_scheme); window_colour_scheme* colour_scheme_get_by_class(rct_windowclass classification) @@ -155,78 +155,78 @@ void colour_scheme_update_by_class(rct_window *window, rct_windowclass classific // window->flags &= ~WF_TRANSPARENT; } -void colour_scheme_change_preset(int preset) +void theme_change_preset(int preset) { - if (preset >= 0 && preset < gConfigColourSchemes.num_presets) { + if (preset >= 0 && preset < gConfigThemes.num_presets) { switch (preset) { case 0: - gConfigInterface.current_colour_scheme_preset = "*RCT2"; + gConfigInterface.current_theme_preset = "*RCT2"; break; case 1: - gConfigInterface.current_colour_scheme_preset = "*RCT1"; + gConfigInterface.current_theme_preset = "*RCT1"; break; default: - gConfigInterface.current_colour_scheme_preset = gConfigColourSchemes.presets[preset].name; + gConfigInterface.current_theme_preset = gConfigThemes.presets[preset].name; break; } - gCurrentColourSchemePreset = preset; + gCurrentTheme = preset; for (int i = 0; i < (int)gNumColourSchemeWindows; i++) { for (int j = 0; j < gColourSchemes[i].num_colours; j++) { - gColourSchemes[i].colours[j] = gConfigColourSchemes.presets[preset].colour_schemes[i].colours[j]; + gColourSchemes[i].colours[j] = gConfigThemes.presets[preset].colour_schemes[i].colours[j]; } } } window_invalidate_all(); } -void colour_scheme_create_preset(const char *name) +void theme_create_preset(const char *name) { - int preset = gConfigColourSchemes.num_presets; - gConfigColourSchemes.num_presets++; - gConfigColourSchemes.presets = realloc(gConfigColourSchemes.presets, sizeof(colour_scheme_preset) * gConfigColourSchemes.num_presets); - strcpy(gConfigColourSchemes.presets[preset].name, name); - gConfigColourSchemes.presets[preset].colour_schemes = malloc(sizeof(window_colours) * gNumColourSchemeWindows); + int preset = gConfigThemes.num_presets; + gConfigThemes.num_presets++; + gConfigThemes.presets = realloc(gConfigThemes.presets, sizeof(theme_preset) * gConfigThemes.num_presets); + strcpy(gConfigThemes.presets[preset].name, name); + gConfigThemes.presets[preset].colour_schemes = malloc(sizeof(window_colours) * gNumColourSchemeWindows); for (int i = 0; i < (int)gNumColourSchemeWindows; i++) { for (int j = 0; j < 6; j++) - gConfigColourSchemes.presets[preset].colour_schemes[i].colours[j] = gColourSchemes[i].colours[j]; + gConfigThemes.presets[preset].colour_schemes[i].colours[j] = gColourSchemes[i].colours[j]; } - colour_schemes_save_preset(preset); - colour_scheme_change_preset(preset); + themes_save_preset(preset); + theme_change_preset(preset); } -void colour_scheme_delete_preset(int preset) +void theme_delete_preset(int preset) { if (preset >= 2) { utf8 path[MAX_PATH]; - platform_get_user_directory(path, "colour schemes"); - strcat(path, gConfigColourSchemes.presets[preset].name); + platform_get_user_directory(path, "themes"); + strcat(path, gConfigThemes.presets[preset].name); strcat(path, ".ini"); platform_file_delete(path); - for (int i = preset; i < gConfigColourSchemes.num_presets - 1; i++) { - gConfigColourSchemes.presets[i] = gConfigColourSchemes.presets[i + 1]; + for (int i = preset; i < gConfigThemes.num_presets - 1; i++) { + gConfigThemes.presets[i] = gConfigThemes.presets[i + 1]; } - gConfigColourSchemes.num_presets--; - colour_scheme_change_preset(0); + gConfigThemes.num_presets--; + theme_change_preset(0); } } -void colour_scheme_rename_preset(int preset, const char *newName) +void theme_rename_preset(int preset, const char *newName) { if (preset >= 2) { utf8 src[MAX_PATH], dest[MAX_PATH]; - platform_get_user_directory(src, "colour schemes"); - platform_get_user_directory(dest, "colour schemes"); - strcat(src, gConfigColourSchemes.presets[preset].name); + platform_get_user_directory(src, "themes"); + platform_get_user_directory(dest, "themes"); + strcat(src, gConfigThemes.presets[preset].name); strcat(dest, newName); strcat(src, ".ini"); strcat(dest, ".ini"); platform_file_move(src, dest); - strcpy(gConfigColourSchemes.presets[gCurrentColourSchemePreset].name, newName); + strcpy(gConfigThemes.presets[gCurrentTheme].name, newName); - if (preset == gCurrentColourSchemePreset) { - gConfigInterface.current_colour_scheme_preset = gConfigColourSchemes.presets[gCurrentColourSchemePreset].name; + if (preset == gCurrentTheme) { + gConfigInterface.current_theme_preset = gConfigThemes.presets[gCurrentTheme].name; } } } diff --git a/src/interface/colour_schemes.h b/src/interface/themes.h similarity index 87% rename from src/interface/colour_schemes.h rename to src/interface/themes.h index f88e1a7c77..be5deb3ffe 100644 --- a/src/interface/colour_schemes.h +++ b/src/interface/themes.h @@ -42,7 +42,7 @@ extern window_colour_scheme gColourSchemes[]; extern marked_window_colours gColourSchemesRCT1[]; -extern uint16 gCurrentColourSchemePreset; +extern uint16 gCurrentTheme; extern uint32 gNumColourSchemeWindows; @@ -52,9 +52,9 @@ int colour_scheme_get_index_by_class(rct_windowclass classification); void colour_scheme_update(rct_window *window); void colour_scheme_update_by_class(rct_window *window, rct_windowclass classification); -void colour_scheme_change_preset(int preset); -void colour_scheme_create_preset(const char *name); -void colour_scheme_delete_preset(int preset); -void colour_scheme_rename_preset(int preset, const char *newName); +void theme_change_preset(int preset); +void theme_create_preset(const char *name); +void theme_delete_preset(int preset); +void theme_rename_preset(int preset, const char *newName); #endif \ No newline at end of file diff --git a/src/interface/window.h b/src/interface/window.h index 0434f225c5..9bae78e466 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -405,7 +405,7 @@ enum { WC_LOADSAVE_OVERWRITE_PROMPT = 116, WC_TITLE_OPTIONS = 117, WC_LAND_RIGHTS = 118, - WC_COLOUR_SCHEMES = 119, + WC_THEMES = 119, // Only used for colour schemes WC_STAFF = 220, @@ -566,7 +566,7 @@ void window_music_credits_open(); void window_publisher_credits_open(); void window_track_manage_open(); void window_viewport_open(); -void window_colour_schemes_open(); +void window_themes_open(); void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, rct_string_id existing_text, uint32 existing_args, int maxLength); void window_text_input_raw_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, utf8string existing_text, int maxLength); rct_window *window_mapgen_open(); diff --git a/src/openrct2.c b/src/openrct2.c index a66731d302..6721a5e008 100644 --- a/src/openrct2.c +++ b/src/openrct2.c @@ -146,8 +146,8 @@ bool openrct2_initialise() language_open(gConfigGeneral.language); http_init(); - colour_schemes_set_default(); - colour_schemes_load_presets(); + themes_set_default(); + themes_load_presets(); if (!rct2_init()) return false; diff --git a/src/windows/about.c b/src/windows/about.c index b56d26188e..9cc7045cd9 100644 --- a/src/windows/about.c +++ b/src/windows/about.c @@ -23,7 +23,7 @@ #include "../sprites.h" #include "../interface/widget.h" #include "../interface/window.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_ABOUT_WIDGET_IDX { WIDX_BACKGROUND, diff --git a/src/windows/banner.c b/src/windows/banner.c index c1daee3ddb..34bc104436 100644 --- a/src/windows/banner.c +++ b/src/windows/banner.c @@ -31,7 +31,7 @@ #include "error.h" #include "dropdown.h" #include "../drawing/drawing.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define WW 113 #define WH 96 diff --git a/src/windows/cheats.c b/src/windows/cheats.c index 71c5d0d35f..3b99076f01 100644 --- a/src/windows/cheats.c +++ b/src/windows/cheats.c @@ -33,7 +33,7 @@ #include "../world/footpath.h" #include "../world/park.h" #include "../world/sprite.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" //#define WW 200 //#define WH 128 diff --git a/src/windows/clear_scenery.c b/src/windows/clear_scenery.c index 4aee7d9012..9e44474ce9 100644 --- a/src/windows/clear_scenery.c +++ b/src/windows/clear_scenery.c @@ -25,7 +25,7 @@ #include "../sprites.h" #include "../interface/widget.h" #include "../interface/window.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_CLEAR_SCENERY_WIDGET_IDX { WIDX_BACKGROUND, diff --git a/src/windows/colour_schemes.c b/src/windows/colour_schemes.c deleted file mode 100644 index ebb3158702..0000000000 --- a/src/windows/colour_schemes.c +++ /dev/null @@ -1,800 +0,0 @@ -/***************************************************************************** -* Copyright (c) 2014 Maciek Baron, Dániel Tar -* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. -* -* This file is part of OpenRCT2. -* -* OpenRCT2 is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "../addresses.h" -#include "../config.h" -#include "../game.h" -#include "../drawing/drawing.h" -#include "../input.h" -#include "../interface/viewport.h" -#include "../interface/widget.h" -#include "../interface/window.h" -#include "../localisation/localisation.h" -#include "../peep/peep.h" -#include "../peep/staff.h" -#include "../world/sprite.h" -#include "../sprites.h" -#include "dropdown.h" -#include "../interface/colour_schemes.h" -#include "error.h" - -enum { - WINDOW_COLOUR_SCHEMES_TAB_MAIN_UI, - WINDOW_COLOUR_SCHEMES_TAB_PARK, - WINDOW_COLOUR_SCHEMES_TAB_TOOLS, - WINDOW_COLOUR_SCHEMES_TAB_RIDES_PEEPS, - WINDOW_COLOUR_SCHEMES_TAB_EDITORS, - WINDOW_COLOUR_SCHEMES_TAB_MISC, - WINDOW_COLOUR_SCHEMES_TAB_PROMPTS, - WINDOW_COLOUR_SCHEMES_TAB_SETTINGS -} WINDOW_COLOUR_SCHEMES_TAB; - -static void window_colour_schemes_emptysub() { } -static void window_colour_schemes_close(); -static void window_colour_schemes_mouseup(); -static void window_colour_schemes_resize(); -static void window_colour_schemes_mousedown(int widgetIndex, rct_window*w, rct_widget* widget); -static void window_colour_schemes_dropdown(); -static void window_colour_schemes_update(rct_window *w); -static void window_colour_schemes_scrollgetsize(); -static void window_colour_schemes_scrollmousedown(); -static void window_colour_schemes_scrollmouseover(); -static void window_colour_schemes_textinput(); -static void window_colour_schemes_tooltip(); -static void window_colour_schemes_invalidate(); -static void window_colour_schemes_paint(); -static void window_colour_schemes_scrollpaint(); -static void window_colour_schemes_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w); - -static void* window_colour_schemes_events[] = { - window_colour_schemes_close, - window_colour_schemes_mouseup, - window_colour_schemes_resize, - window_colour_schemes_mousedown, - window_colour_schemes_dropdown, - window_colour_schemes_emptysub, - window_colour_schemes_update, - window_colour_schemes_emptysub, - window_colour_schemes_emptysub, - window_colour_schemes_emptysub, - window_colour_schemes_emptysub, - window_colour_schemes_emptysub, - window_colour_schemes_emptysub, - window_colour_schemes_emptysub, - window_colour_schemes_emptysub, - window_colour_schemes_scrollgetsize, - window_colour_schemes_scrollmousedown, - window_colour_schemes_emptysub, - window_colour_schemes_scrollmouseover, - window_colour_schemes_textinput, - window_colour_schemes_emptysub, - window_colour_schemes_emptysub, - window_colour_schemes_tooltip, - window_colour_schemes_emptysub, - window_colour_schemes_emptysub, - window_colour_schemes_invalidate, - window_colour_schemes_paint, - window_colour_schemes_scrollpaint, -}; - -enum WINDOW_STAFF_LIST_WIDGET_IDX { - WIDX_COLOUR_SCHEMES_BACKGROUND, - WIDX_COLOUR_SCHEMES_TITLE, - WIDX_COLOUR_SCHEMES_CLOSE, - WIDX_COLOUR_SCHEMES_TAB_CONTENT_PANEL, - WIDX_COLOUR_SCHEMES_MAIN_UI_TAB, - WIDX_COLOUR_SCHEMES_PARK_TAB, - WIDX_COLOUR_SCHEMES_TOOLS_TAB, - WIDX_COLOUR_SCHEMES_RIDE_PEEPS_TAB, - WIDX_COLOUR_SCHEMES_EDITORS_TAB, - WIDX_COLOUR_SCHEMES_MISC_TAB, - WIDX_COLOUR_SCHEMES_PROMPTS_TAB, - WIDX_COLOUR_SCHEMES_SETTINGS_TAB, - WIDX_COLOUR_SCHEMES_PRESETS, - WIDX_COLOUR_SCHEMES_PRESETS_DROPDOWN, - WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON, - WIDX_COLOUR_SCHEMES_DELETE_BUTTON, - WIDX_COLOUR_SCHEMES_RENAME_BUTTON, - WIDX_COLOUR_SCHEMES_COLORBTN_MASK, - WIDX_COLOUR_SCHEMES_LIST, -}; - -static rct_widget window_colour_schemes_widgets[] = { - { WWT_FRAME, 0, 0, 319, 0, 269, 0x0FFFFFFFF, STR_NONE }, // panel / background - { WWT_CAPTION, 0, 1, 318, 1, 14, 5244, STR_WINDOW_TITLE_TIP }, // title bar - { WWT_CLOSEBOX, 0, 307, 317, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close button - { WWT_RESIZE, 1, 0, 319, 43, 269, 0x0FFFFFFFF, STR_NONE }, // tab content panel - { WWT_TAB, 1, 3, 33, 17, 43, 0x02000144E, 5228 }, // main ui tab - { WWT_TAB, 1, 34, 64, 17, 43, 0x02000144E, 5229 }, // park tab - { WWT_TAB, 1, 65, 95, 17, 43, 0x02000144E, 5230 }, // tools tab - { WWT_TAB, 1, 96, 126, 17, 43, 0x02000144E, 5231 }, // rides and peeps tab - { WWT_TAB, 1, 127, 157, 17, 43, 0x02000144E, 5232 }, // editors tab - { WWT_TAB, 1, 158, 188, 17, 43, 0x02000144E, 5233 }, // misc tab - { WWT_TAB, 1, 189, 219, 17, 43, 0x02000144E, 5234 }, // prompts tab - { WWT_TAB, 1, 220, 250, 17, 43, 0x02000144E, 5235 }, // settings tab - { WWT_DROPDOWN, 1, 125, 299, 60, 71, STR_NONE, STR_NONE }, // Preset colour schemes - { WWT_DROPDOWN_BUTTON, 1, 288, 298, 61, 70, 876, STR_NONE }, - { WWT_DROPDOWN_BUTTON, 1, 10, 100, 82, 93, 5239, STR_NONE }, // Duplicate button - { WWT_DROPDOWN_BUTTON, 1, 110, 200, 82, 93, 3349, STR_NONE }, // Delete button - { WWT_DROPDOWN_BUTTON, 1, 210, 300, 82, 93, 3348, STR_NONE }, // Rename button - { WWT_COLORBTN, 1, 0, 0, 0, 0, STR_NONE, STR_NONE }, // color button mask - { WWT_SCROLL, 1, 3, 316, 60, 266, 2, STR_NONE }, // staff list - { WIDGETS_END }, -}; - -static int window_colour_schemes_tab_animation_loops[] = { - 32, - 1, - 1, - 64, - 32, - 8, - 14, - 32 -}; -static int window_colour_schemes_tab_animation_divisor[] = { - 4, - 1, - 1, - 4, - 2, - 2, - 2, - 4 -}; -static int window_colour_schemes_tab_sprites[] = { - SPR_TAB_KIOSKS_AND_FACILITIES_0, - 5200, - SPR_G2_TAB_LAND, - SPR_TAB_RIDE_0, - 5205, - 5201, - SPR_TAB_STAFF_OPTIONS_0, - 5221 -}; - -static rct_windowclass window_colour_schemes_tab_1_classes[] = { - WC_TOP_TOOLBAR, - WC_BOTTOM_TOOLBAR, - WC_EDITOR_SCENARIO_BOTTOM_TOOLBAR, - WC_EDITOR_TRACK_BOTTOM_TOOLBAR, - WC_TITLE_MENU, - WC_TITLE_EXIT, - WC_TITLE_OPTIONS, - WC_SCENARIO_SELECT -}; - -static rct_windowclass window_colour_schemes_tab_2_classes[] = { - WC_PARK_INFORMATION, - WC_FINANCES, - WC_NEW_CAMPAIGN, - WC_RESEARCH, - WC_MAP, - WC_VIEWPORT, - WC_RECENT_NEWS -}; - -static rct_windowclass window_colour_schemes_tab_3_classes[] = { - WC_LAND, - WC_WATER, - WC_CLEAR_SCENERY, - WC_LAND_RIGHTS, - WC_SCENERY, - WC_FOOTPATH, - WC_RIDE_CONSTRUCTION, - WC_TRACK_DESIGN_PLACE, - WC_CONSTRUCT_RIDE, - WC_TRACK_DESIGN_LIST -}; - -static rct_windowclass window_colour_schemes_tab_4_classes[] = { - WC_RIDE, - WC_RIDE_LIST, - WC_PEEP, - WC_GUEST_LIST, - WC_STAFF, - WC_STAFF_LIST, - WC_BANNER -}; - -static rct_windowclass window_colour_schemes_tab_5_classes[] = { - WC_EDITOR_OBJECT_SELECTION, - WC_EDITOR_INVENTION_LIST, - WC_EDITOR_SCENARIO_OPTIONS, - WC_EDTIOR_OBJECTIVE_OPTIONS, - WC_MAPGEN, - WC_MANAGE_TRACK_DESIGN, - WC_INSTALL_TRACK -}; - -static rct_windowclass window_colour_schemes_tab_6_classes[] = { - WC_CHEATS, - WC_COLOUR_SCHEMES, - WC_OPTIONS, - WC_KEYBOARD_SHORTCUT_LIST, - WC_CHANGE_KEYBOARD_SHORTCUT, - WC_LOADSAVE -}; - -static rct_windowclass window_colour_schemes_tab_7_classes[] = { - WC_SAVE_PROMPT, - WC_DEMOLISH_RIDE_PROMPT, - WC_FIRE_PROMPT, - WC_TRACK_DELETE_PROMPT, - WC_LOADSAVE_OVERWRITE_PROMPT -}; - -// Info, Research, Wrench, Entrance, Slide, Gears, Point Finger -// Info, Entrance, Construction, Slide, Wrench, Gear, Todo -static uint8 _selected_tab = 0; -static sint16 _color_index_1 = -1; -static sint8 _color_index_2 = -1; -static const uint8 _row_height = 32; -static const uint8 _button_offset_x = 220; -static const uint8 _button_offset_y = 3; -static const uint8 _check_offset_y = 3 + 12 + 2; - - -void window_colour_schemes_init_vars() -{ - _selected_tab = WINDOW_COLOUR_SCHEMES_TAB_MAIN_UI; -} - -static window_colour_scheme* get_colour_scheme_tab() -{ - switch (_selected_tab) { - case 0: return colour_scheme_get_by_class(window_colour_schemes_tab_1_classes[_color_index_1]); - case 1: return colour_scheme_get_by_class(window_colour_schemes_tab_2_classes[_color_index_1]); - case 2: return colour_scheme_get_by_class(window_colour_schemes_tab_3_classes[_color_index_1]); - case 3: return colour_scheme_get_by_class(window_colour_schemes_tab_4_classes[_color_index_1]); - case 4: return colour_scheme_get_by_class(window_colour_schemes_tab_5_classes[_color_index_1]); - case 5: return colour_scheme_get_by_class(window_colour_schemes_tab_6_classes[_color_index_1]); - case 6: return colour_scheme_get_by_class(window_colour_schemes_tab_7_classes[_color_index_1]); - } - return NULL; -} -static window_colour_scheme* get_colour_scheme_tab_by_index(int index) -{ - switch (_selected_tab) { - case 0: return colour_scheme_get_by_class(window_colour_schemes_tab_1_classes[index]); - case 1: return colour_scheme_get_by_class(window_colour_schemes_tab_2_classes[index]); - case 2: return colour_scheme_get_by_class(window_colour_schemes_tab_3_classes[index]); - case 3: return colour_scheme_get_by_class(window_colour_schemes_tab_4_classes[index]); - case 4: return colour_scheme_get_by_class(window_colour_schemes_tab_5_classes[index]); - case 5: return colour_scheme_get_by_class(window_colour_schemes_tab_6_classes[index]); - case 6: return colour_scheme_get_by_class(window_colour_schemes_tab_7_classes[index]); - } - return NULL; -} - -static int get_colour_scheme_tab_count() -{ - switch (_selected_tab) { - case 0: return sizeof(window_colour_schemes_tab_1_classes); - case 1: return sizeof(window_colour_schemes_tab_2_classes); - case 2: return sizeof(window_colour_schemes_tab_3_classes); - case 3: return sizeof(window_colour_schemes_tab_4_classes); - case 4: return sizeof(window_colour_schemes_tab_5_classes); - case 5: return sizeof(window_colour_schemes_tab_6_classes); - case 6: return sizeof(window_colour_schemes_tab_7_classes); - } - return 0; -} - -static int get_colour_scheme_index() { - switch (_selected_tab) { - case 0: return colour_scheme_get_index_by_class(window_colour_schemes_tab_1_classes[_color_index_1]); - case 1: return colour_scheme_get_index_by_class(window_colour_schemes_tab_2_classes[_color_index_1]); - case 2: return colour_scheme_get_index_by_class(window_colour_schemes_tab_3_classes[_color_index_1]); - case 3: return colour_scheme_get_index_by_class(window_colour_schemes_tab_4_classes[_color_index_1]); - case 4: return colour_scheme_get_index_by_class(window_colour_schemes_tab_5_classes[_color_index_1]); - case 5: return colour_scheme_get_index_by_class(window_colour_schemes_tab_6_classes[_color_index_1]); - case 6: return colour_scheme_get_index_by_class(window_colour_schemes_tab_7_classes[_color_index_1]); - } - return -1; -} - -static void window_colour_schemes_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w) -{ - int sprite_idx; - - for (int i = 0; i < 8; i++) { - sprite_idx = window_colour_schemes_tab_sprites[i]; - if (_selected_tab == i) - sprite_idx += w->frame_no / window_colour_schemes_tab_animation_divisor[_selected_tab]; - gfx_draw_sprite(dpi, sprite_idx, w->x + w->widgets[WIDX_COLOUR_SCHEMES_MAIN_UI_TAB + i].left, w->y + w->widgets[WIDX_COLOUR_SCHEMES_MAIN_UI_TAB + i].top, 0); - } -} - -void window_colour_schemes_open() -{ - rct_window* window; - - // Check if window is already open - window = window_bring_to_front_by_class(WC_COLOUR_SCHEMES); - if (window != NULL) - return; - - window = window_create_auto_pos(320, 270, (uint32*)window_colour_schemes_events, WC_COLOUR_SCHEMES, 0x0400); - window->widgets = window_colour_schemes_widgets; - window->enabled_widgets = - (1 << WIDX_COLOUR_SCHEMES_CLOSE) | - (1 << WIDX_COLOUR_SCHEMES_MAIN_UI_TAB) | - (1 << WIDX_COLOUR_SCHEMES_PARK_TAB) | - (1 << WIDX_COLOUR_SCHEMES_TOOLS_TAB) | - (1 << WIDX_COLOUR_SCHEMES_RIDE_PEEPS_TAB) | - (1 << WIDX_COLOUR_SCHEMES_EDITORS_TAB) | - (1 << WIDX_COLOUR_SCHEMES_MISC_TAB) | - (1 << WIDX_COLOUR_SCHEMES_PROMPTS_TAB) | - (1 << WIDX_COLOUR_SCHEMES_SETTINGS_TAB) | - (1 << WIDX_COLOUR_SCHEMES_COLORBTN_MASK) | - (1 << WIDX_COLOUR_SCHEMES_PRESETS) | - (1 << WIDX_COLOUR_SCHEMES_PRESETS_DROPDOWN) | - (1 << WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON) | - (1 << WIDX_COLOUR_SCHEMES_DELETE_BUTTON) | - (1 << WIDX_COLOUR_SCHEMES_RENAME_BUTTON); - - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].type = WWT_SCROLL; - - window_colour_schemes_init_vars(); - - window_init_scroll_widgets(window); - window->list_information_type = 0; - _color_index_1 = -1; - _color_index_2 = -1; - window->min_width = 320; - window->min_height = 270; - window->max_width = 320; - window->max_height = 450; - window->flags |= WF_RESIZABLE; -} - -void window_colour_schemes_close() { - rct_window *w; - - window_get_register(w); -} - -static void window_colour_schemes_mouseup() -{ - short widgetIndex; - rct_window *w; - - window_widget_get_registers(w, widgetIndex); - - switch (widgetIndex) { - case WIDX_COLOUR_SCHEMES_CLOSE: - window_close(w); - break; - case WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON: - window_text_input_open(w, widgetIndex, 5239, 5240, 1170, (uint32)&gConfigColourSchemes.presets[gCurrentColourSchemePreset].name, 64); - break; - case WIDX_COLOUR_SCHEMES_DELETE_BUTTON: - if (gCurrentColourSchemePreset >= 2) { - colour_scheme_delete_preset(gCurrentColourSchemePreset); - } - else { - window_error_open(5241, STR_NONE); - } - break; - case WIDX_COLOUR_SCHEMES_RENAME_BUTTON: - if (gCurrentColourSchemePreset >= 2) { - window_text_input_open(w, widgetIndex, 3348, 5240, 1170, (uint32)&gConfigColourSchemes.presets[gCurrentColourSchemePreset].name, 64); - } - else { - window_error_open(5241, STR_NONE); - } - break; - } -} - -static void window_colour_schemes_resize() -{ - rct_window *w; - - window_get_register(w); - - if (_selected_tab == WINDOW_COLOUR_SCHEMES_TAB_SETTINGS) { - window_set_resize(w, 320, 107, 320, 107); - gfx_invalidate_screen(); - } - else { - w->min_width = 320; - w->min_height = 270; - w->max_width = 320; - w->max_height = 450; - - if (w->width < w->min_width) { - w->width = w->min_width; - window_invalidate(w); - } - if (w->height < w->min_height) { - w->height = w->min_height; - window_invalidate(w); - } - if (w->width > w->max_width) { - w->width = w->max_width; - window_invalidate(w); - } - if (w->height > w->max_height) { - w->height = w->max_height; - window_invalidate(w); - } - } -} - -static void window_colour_schemes_mousedown(int widgetIndex, rct_window* w, rct_widget* widget) -{ - short newSelectedTab; - int num_items, i; - - switch (widgetIndex) { - case WIDX_COLOUR_SCHEMES_MAIN_UI_TAB: - case WIDX_COLOUR_SCHEMES_PARK_TAB: - case WIDX_COLOUR_SCHEMES_TOOLS_TAB: - case WIDX_COLOUR_SCHEMES_RIDE_PEEPS_TAB: - case WIDX_COLOUR_SCHEMES_EDITORS_TAB: - case WIDX_COLOUR_SCHEMES_MISC_TAB: - case WIDX_COLOUR_SCHEMES_PROMPTS_TAB: - case WIDX_COLOUR_SCHEMES_SETTINGS_TAB: - /*if (widgetIndex == WIDX_COLOUR_SCHEMES_SETTINGS_TAB) { - window_set_resize(w, 320, 100, 320, 100); - w->flags &= ~WF_RESIZABLE; - } - else if (_selected_tab == WINDOW_COLOUR_SCHEMES_TAB_SETTINGS) { - w->flags |= WF_RESIZABLE; - window_set_resize(w, 320, 270, 320, 450); - }*/ - newSelectedTab = widgetIndex - WIDX_COLOUR_SCHEMES_MAIN_UI_TAB; - if (_selected_tab == newSelectedTab) - break; - _selected_tab = (uint8)newSelectedTab; - w->scrolls[0].v_top = 0; - w->frame_no = 0; - window_event_resize_call(w); - window_invalidate(w); - break; - case WIDX_COLOUR_SCHEMES_PRESETS_DROPDOWN: - num_items = gConfigColourSchemes.num_presets; - - widget--; - for (i = 0; i < num_items; i++) { - gDropdownItemsFormat[i] = 2777; - gDropdownItemsArgs[i] = (uint64)&gConfigColourSchemes.presets[i].name; - } - - window_dropdown_show_text_custom_width( - w->x + widget->left, - w->y + widget->top, - widget->bottom - widget->top + 1, - w->colours[1], - DROPDOWN_FLAG_STAY_OPEN, - num_items, - widget->right - widget->left - 3 - ); - - gDropdownItemsChecked = 1 << gCurrentColourSchemePreset; - break; - } -} - -static void window_colour_schemes_dropdown() -{ - rct_window* w; - short widgetIndex, dropdownIndex; - window_dropdown_get_registers(w, widgetIndex, dropdownIndex); - - switch (widgetIndex) { - case WIDX_COLOUR_SCHEMES_LIST: - if (dropdownIndex != -1) { - get_colour_scheme_tab()->colours[_color_index_2] = dropdownIndex | get_colour_scheme_tab()->colours[_color_index_2] & 0x80; - gConfigColourSchemes.presets[gCurrentColourSchemePreset].colour_schemes[get_colour_scheme_index()].colours[_color_index_2] = dropdownIndex | get_colour_scheme_tab()->colours[_color_index_2] & 0x80; - window_invalidate_all(); - _color_index_1 = -1; - _color_index_2 = -1; - - if (gCurrentColourSchemePreset >= 2) - colour_schemes_save_preset(gCurrentColourSchemePreset); - } - break; - case WIDX_COLOUR_SCHEMES_PRESETS_DROPDOWN: - if (dropdownIndex != -1) { - colour_scheme_change_preset(dropdownIndex); - } - config_save_default(); - break; - } - -} - -void window_colour_schemes_update(rct_window *w) -{ - w->frame_no++; - if (w->frame_no >= window_colour_schemes_tab_animation_loops[_selected_tab]) - w->frame_no = 0; - - widget_invalidate(w, WIDX_COLOUR_SCHEMES_MAIN_UI_TAB + _selected_tab); - -} - -void window_colour_schemes_scrollgetsize() { - rct_window *w; - - window_get_register(w); - - int scrollHeight = get_colour_scheme_tab_count() * _row_height; - int i = scrollHeight - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].bottom + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].top + 21; - if (i < 0) - i = 0; - if (i < w->scrolls[0].v_top) { - w->scrolls[0].v_top = i; - window_invalidate(w); - } - - #ifdef _MSC_VER - __asm mov ecx, 420 - #else - __asm__("mov ecx, 420 "); - #endif - - #ifdef _MSC_VER - __asm mov edx, scrollHeight - #else - __asm__("mov edx, %[scrollHeight] " : [scrollHeight] "+m" (scrollHeight)); - #endif -} - -void window_colour_schemes_scrollmousedown() { - short x, y, scrollIndex; - rct_window *w; - - window_scrollmouse_get_registers(w, scrollIndex, x, y); - - if (_selected_tab == 7) - return; - - if (y / _row_height < get_colour_scheme_tab_count()) { - int y2 = y % _row_height; - _color_index_1 = y / _row_height; - _color_index_2 = ((x - _button_offset_x) / 12); - if (_color_index_2 < get_colour_scheme_tab()->num_colours) { - if (x >= _button_offset_x && x < _button_offset_x + 12 * 6 && y2 >= _button_offset_y && y2 < _button_offset_y + 11) { - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_COLORBTN_MASK].left = _button_offset_x + _color_index_2 * 12 + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].left; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_COLORBTN_MASK].top = _color_index_1 * _row_height + _button_offset_y - w->scrolls[0].v_top + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].top; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_COLORBTN_MASK].right = window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_COLORBTN_MASK].left + 11; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_COLORBTN_MASK].bottom = window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_COLORBTN_MASK].top + 11; - window_dropdown_show_colour(w, &(window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_COLORBTN_MASK]), w->colours[1], get_colour_scheme_tab()->colours[_color_index_2]); - } - else if (x >= _button_offset_x && x < _button_offset_x + 12 * 6 - 1 && y2 >= _check_offset_y && y2 < _check_offset_y + 11) { - if (get_colour_scheme_tab()->colours[_color_index_2] & 0x80) { - get_colour_scheme_tab()->colours[_color_index_2] &= 0x7F; - - gConfigColourSchemes.presets[gCurrentColourSchemePreset].colour_schemes[get_colour_scheme_index()].colours[_color_index_2] &= 0x7F; - } - else { - get_colour_scheme_tab()->colours[_color_index_2] |= 0x80; - gConfigColourSchemes.presets[gCurrentColourSchemePreset].colour_schemes[get_colour_scheme_index()].colours[_color_index_2] |= 0x80; - } - if (gCurrentColourSchemePreset >= 2) - colour_schemes_save_preset(gCurrentColourSchemePreset); - window_invalidate_all(); - } - } - } -} - -void window_colour_schemes_scrollmouseover() { - short x, y, scrollIndex; - rct_window *w; - - window_scrollmouse_get_registers(w, scrollIndex, x, y); - - //if (_selected_tab == 7) - // return; -} - -static bool valid_characters(const char *name) -{ - for (int i = 0; name[i] != '\0'; i++) { - if (name[i] == '\\' || name[i] == '/' || name[i] == ':' || name[i] == '?' || name[i] == '*' || name[i] == '<' || name[i] == '>' || name[i] == '|') - return false; - } - return true; -} - -static void window_colour_schemes_textinput() -{ - rct_window *w; - short widgetIndex; - uint8 result; - char *text; - - window_textinput_get_registers(w, widgetIndex, result, text); - - if (!result || text[0] == 0) - return; - - switch (widgetIndex) { - case WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON: - case WIDX_COLOUR_SCHEMES_RENAME_BUTTON: - if (valid_characters(text)) { - bool nameTaken = false; - for (int i = 0; i < gConfigColourSchemes.num_presets; i++) { - if (strcmp(gConfigColourSchemes.presets[i].name, text) == 0) { - window_error_open(5242, STR_NONE); - nameTaken = true; - break; - } - } - if (!nameTaken) { - if (widgetIndex == WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON) { - colour_scheme_create_preset(text); - } - else { - colour_scheme_rename_preset(gCurrentColourSchemePreset, text); - } - config_save_default(); - window_invalidate(w); - } - } - else { - window_error_open(5243, STR_NONE); - } - break; - } -} - -void window_colour_schemes_tooltip() -{ - RCT2_GLOBAL(0x013CE952, uint16) = STR_LIST; -} - -void window_colour_schemes_invalidate() -{ - rct_window *w; - - window_get_register(w); - colour_scheme_update(w); - - int pressed_widgets = w->pressed_widgets & 0xFFFFF00F; - uint8 tabIndex = _selected_tab; - uint8 widgetIndex = tabIndex + 4; - - w->pressed_widgets = pressed_widgets | (1 << widgetIndex); - - if (window_find_by_class(WC_DROPDOWN) == NULL) { - _color_index_1 = -1; - _color_index_2 = -1; - } - - - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_BACKGROUND].right = w->width - 1; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_BACKGROUND].bottom = w->height - 1; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_TAB_CONTENT_PANEL].right = w->width - 1; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_TAB_CONTENT_PANEL].bottom = w->height - 1; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_TITLE].right = w->width - 2; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_CLOSE].left = w->width - 2 - 0x0B; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_CLOSE].right = w->width - 2 - 0x0B + 0x0A; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].right = w->width - 4; - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].bottom = w->height - 0x0F; - - if (_selected_tab == 7) { - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].type = WWT_EMPTY; - } - else { - window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].type = WWT_SCROLL; - } -} - -void window_colour_schemes_paint() { - rct_window *w; - rct_drawpixelinfo *dpi; - - window_paint_get_registers(w, dpi); - - // Widgets - window_draw_widgets(w, dpi); - window_colour_schemes_draw_tab_images(dpi, w); - - if (_selected_tab < 7) { - - gfx_draw_string_left(dpi, 5236, w, w->colours[1], w->x + 6, 58 - 12 + w->y + 1); - gfx_draw_string_left(dpi, 5237, w, w->colours[1], w->x + 220, 58 - 12 + w->y + 1); - } - else { - RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint32) = (uint32)&gConfigColourSchemes.presets[gCurrentColourSchemePreset].name; - gfx_draw_string_left(dpi, 5238, NULL, w->colours[1], w->x + 10, w->y + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_PRESETS].top + 1); - gfx_draw_string_left( - dpi, - 1170, - (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, - w->colours[1], - w->x + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_PRESETS].left + 1, - w->y + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_PRESETS].top - ); - } -} - -/** -* -* rct2: 0x006BD785 -*/ -void window_colour_schemes_scrollpaint() -{ - int y; - uint8 selectedTab; - rct_window *w; - rct_drawpixelinfo *dpi; - - window_paint_get_registers(w, dpi); - - if (_selected_tab == 7) - return; - - if ((w->colours[1] & 0x80) == 0) - //gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ((char*)0x0141FC48)[w->colours[1] * 8]); - gfx_clear(dpi, ((char*)0x0141FC48)[w->colours[1] * 8] * 0x1010101); - y = 0; - selectedTab = _selected_tab; - for (int i = 0; i < get_colour_scheme_tab_count(); i++) { - if (y > dpi->y + dpi->height) { - break; - } - if (y + _row_height >= dpi->y) { - if (i + 1 < get_colour_scheme_tab_count()) { - int colour = w->colours[1]; - if (colour & 0x80) { - colour = RCT2_ADDRESS(0x009DEDF4, uint8)[colour]; - - colour = colour | 0x2000000; - gfx_fill_rect(dpi, 0, y + _row_height - 2, window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].right, y + _row_height - 2, colour + 1); - gfx_fill_rect(dpi, 0, y + _row_height - 1, window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].right, y + _row_height - 1, colour + 2); - } - else { - colour = RCT2_ADDRESS(0x0141FC47, uint8)[w->colours[1] * 8]; - gfx_fill_rect(dpi, 0, y + _row_height - 2, window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].right, y + _row_height - 2, colour); - colour = RCT2_ADDRESS(0x0141FC4B, uint8)[w->colours[1] * 8]; - gfx_fill_rect(dpi, 0, y + _row_height - 1, window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].right, y + _row_height - 1, colour); - } - } - //gfx_fill_rect_inset(dpi, 0, y + _row_height - 2, window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].right + 1, y + _row_height - 1, w->colours[1], 0x20); - - for (int j = 0; j < get_colour_scheme_tab_by_index(i)->num_colours; j++) { - - gfx_draw_string_left(dpi, get_colour_scheme_tab_by_index(i)->name, NULL, w->colours[1], 2, y + 4); - - uint32 image = ((get_colour_scheme_tab_by_index(i)->colours[j] & 0x7F) << 19) + 0x600013C3; - if (i == _color_index_1 && j == _color_index_2) { - image = ((get_colour_scheme_tab_by_index(i)->colours[j] & 0x7F) << 19) + 0x600013C4; - } - gfx_draw_sprite(dpi, image, _button_offset_x + 12 * j, y + _button_offset_y, 0); - - gfx_fill_rect_inset(dpi, _button_offset_x + 12 * j, y + _check_offset_y, _button_offset_x + 12 * j + 9, y + _check_offset_y + 10, w->colours[1], 0xE0); - if (get_colour_scheme_tab_by_index(i)->colours[j] & 0x80) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = -1; - gfx_draw_string(dpi, (char*)0x009DED72, w->colours[1] & 0x7F, _button_offset_x + 12 * j, y + _check_offset_y); - } - - } - } - - y += _row_height; - } -} diff --git a/src/windows/demolish_ride_prompt.c b/src/windows/demolish_ride_prompt.c index 2f7350b9d2..5bdf32447b 100644 --- a/src/windows/demolish_ride_prompt.c +++ b/src/windows/demolish_ride_prompt.c @@ -27,7 +27,7 @@ #include "../peep/staff.h" #include "../sprites.h" #include "../world/sprite.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define WW 200 #define WH 100 diff --git a/src/windows/editor_bottom_toolbar.c b/src/windows/editor_bottom_toolbar.c index 316a5c18c8..4035526cfd 100644 --- a/src/windows/editor_bottom_toolbar.c +++ b/src/windows/editor_bottom_toolbar.c @@ -33,7 +33,7 @@ #include "../util/util.h" #include "../world/scenery.h" #include "error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WIDX_PREVIOUS_IMAGE, // 1 diff --git a/src/windows/editor_inventions_list.c b/src/windows/editor_inventions_list.c index 1cca4c85a3..9ed35c7ee6 100644 --- a/src/windows/editor_inventions_list.c +++ b/src/windows/editor_inventions_list.c @@ -27,7 +27,7 @@ #include "../management/research.h" #include "../object.h" #include "../world/scenery.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #pragma region Widgets diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 3b1996f295..084c4efb28 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -29,7 +29,7 @@ #include "../ride/track.h" #include "../scenario.h" #include "error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS, diff --git a/src/windows/editor_objective_options.c b/src/windows/editor_objective_options.c index db1f406cf1..52071d8287 100644 --- a/src/windows/editor_objective_options.c +++ b/src/windows/editor_objective_options.c @@ -28,7 +28,7 @@ #include "../world/park.h" #include "dropdown.h" #include "error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define DISABLE_SIX_FLAGS_CHECKBOX diff --git a/src/windows/editor_scenario_options.c b/src/windows/editor_scenario_options.c index 87c239a200..fa458e916f 100644 --- a/src/windows/editor_scenario_options.c +++ b/src/windows/editor_scenario_options.c @@ -26,7 +26,7 @@ #include "../sprites.h" #include "error.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #pragma region Widgets diff --git a/src/windows/finances.c b/src/windows/finances.c index f16db8ee67..17fc47d1e9 100644 --- a/src/windows/finances.c +++ b/src/windows/finances.c @@ -33,7 +33,7 @@ #include "../scenario.h" #include "../sprites.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WINDOW_FINANCES_PAGE_SUMMARY, diff --git a/src/windows/footpath.c b/src/windows/footpath.c index a7a1c71066..614ca87e81 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -30,7 +30,7 @@ #include "../world/footpath.h" #include "../world/map.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { PATH_CONSTRUCTION_MODE_LAND, diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index 7da22bd3af..9789ec2a0c 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -31,7 +31,7 @@ #include "../world/climate.h" #include "../world/park.h" #include "../world/sprite.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_GAME_BOTTOM_TOOLBAR_WIDGET_IDX { WIDX_LEFT_OUTSET, diff --git a/src/windows/guest.c b/src/windows/guest.c index 651588b603..90843629b3 100644 --- a/src/windows/guest.c +++ b/src/windows/guest.c @@ -37,7 +37,7 @@ #include "../input.h" #include "dropdown.h" #include "error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_GUEST_PAGE { WINDOW_GUEST_OVERVIEW, diff --git a/src/windows/guest_list.c b/src/windows/guest_list.c index 7bc2dd1d7e..c10a0398fb 100644 --- a/src/windows/guest_list.c +++ b/src/windows/guest_list.c @@ -29,7 +29,7 @@ #include "../sprites.h" #include "../world/sprite.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { PAGE_INDIVIDUAL, diff --git a/src/windows/install_track.c b/src/windows/install_track.c index f66b8bb8d9..c98aca69d0 100644 --- a/src/windows/install_track.c +++ b/src/windows/install_track.c @@ -28,7 +28,7 @@ #include "../ride/track.h" #include "../sprites.h" #include "error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WIDX_BACKGROUND, diff --git a/src/windows/land.c b/src/windows/land.c index c7b2d29367..5c5c308f81 100644 --- a/src/windows/land.c +++ b/src/windows/land.c @@ -26,7 +26,7 @@ #include "../sprites.h" #include "../world/map.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_LAND_WIDGET_IDX { WIDX_BACKGROUND, diff --git a/src/windows/land_rights.c b/src/windows/land_rights.c index 0f3d83e5de..9a81fc3cbb 100644 --- a/src/windows/land_rights.c +++ b/src/windows/land_rights.c @@ -27,7 +27,7 @@ #include "../sprites.h" #include "../world/map.h" #include "../game.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" const int MAX_LAND_RIGHTS_SIZE = 64; diff --git a/src/windows/loadsave.c b/src/windows/loadsave.c index 4c4afade91..8c2ce3b618 100644 --- a/src/windows/loadsave.c +++ b/src/windows/loadsave.c @@ -28,7 +28,7 @@ #include "../scenario.h" #include "../title.h" #include "../windows/error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #pragma region Widgets diff --git a/src/windows/map.c b/src/windows/map.c index 69be2f881e..44adcf74ec 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -26,7 +26,7 @@ #include "../interface/window.h" #include "../sprites.h" #include "../world/scenery.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_MAP_WIDGET_IDX { diff --git a/src/windows/mapgen.c b/src/windows/mapgen.c index aed304a256..7f272df135 100644 --- a/src/windows/mapgen.c +++ b/src/windows/mapgen.c @@ -28,7 +28,7 @@ #include "../world/mapgen.h" #include "../world/scenery.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WINDOW_MAPGEN_PAGE_BASE, diff --git a/src/windows/new_campaign.c b/src/windows/new_campaign.c index 094253fa33..f64a894d51 100644 --- a/src/windows/new_campaign.c +++ b/src/windows/new_campaign.c @@ -27,7 +27,7 @@ #include "../management/marketing.h" #include "../ride/ride.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define SELECTED_RIDE_UNDEFINED ((uint16)0xFFFF) diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index 1cc1aaa236..6115e5db05 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -30,7 +30,7 @@ #include "../ride/track.h" #include "../interface/widget.h" #include "../interface/window.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define _window_new_ride_current_tab RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) diff --git a/src/windows/news.c b/src/windows/news.c index fd93b4edc8..512bff4d0e 100644 --- a/src/windows/news.c +++ b/src/windows/news.c @@ -27,7 +27,7 @@ #include "../sprites.h" #include "../interface/widget.h" #include "../interface/window.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_NEWS_WIDGET_IDX { WIDX_BACKGROUND, diff --git a/src/windows/options.c b/src/windows/options.c index 12979b66af..3491a2816e 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -39,7 +39,7 @@ #include "../sprites.h" #include "dropdown.h" #include "error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WINDOW_OPTIONS_PAGE_DISPLAY, @@ -72,9 +72,9 @@ enum WINDOW_OPTIONS_WIDGET_IDX { WIDX_CONSTRUCTION_MARKER, WIDX_CONSTRUCTION_MARKER_DROPDOWN, WIDX_HARDWARE_DISPLAY_CHECKBOX, - WIDX_COLOUR_SCHEMES, - WIDX_COLOUR_SCHEMES_DROPDOWN, - WIDX_COLOUR_SCHEMES_BUTTON, + WIDX_THEMES, + WIDX_THEMES_DROPDOWN, + WIDX_THEMES_BUTTON, WIDX_LANGUAGE, WIDX_LANGUAGE_DROPDOWN, @@ -301,9 +301,9 @@ void window_options_open() (1ULL << WIDX_TILE_SMOOTHING_CHECKBOX) | (1ULL << WIDX_GRIDLINES_CHECKBOX) | (1ULL << WIDX_HARDWARE_DISPLAY_CHECKBOX) | - (1ULL << WIDX_COLOUR_SCHEMES) | - (1ULL << WIDX_COLOUR_SCHEMES_DROPDOWN) | - (1ULL << WIDX_COLOUR_SCHEMES_BUTTON) | + (1ULL << WIDX_THEMES) | + (1ULL << WIDX_THEMES_DROPDOWN) | + (1ULL << WIDX_THEMES_BUTTON) | (1ULL << WIDX_SAVE_PLUGIN_DATA_CHECKBOX) | (1ULL << WIDX_AUTOSAVE) | (1ULL << WIDX_AUTOSAVE_DROPDOWN) | @@ -417,8 +417,8 @@ static void window_options_mouseup() config_save_default(); window_invalidate(w); break; - case WIDX_COLOUR_SCHEMES_BUTTON: - window_colour_schemes_open(); + case WIDX_THEMES_BUTTON: + window_themes_open(); window_invalidate(w); break; case WIDX_FOLLOWER_PEEP_NAMES_CHECKBOX: @@ -597,17 +597,17 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget* gDropdownItemsChecked = 1 << gConfigGeneral.construction_marker_colour; break; - case WIDX_COLOUR_SCHEMES_DROPDOWN: - num_items = gConfigColourSchemes.num_presets; + case WIDX_THEMES_DROPDOWN: + num_items = gConfigThemes.num_presets; for (i = 0; i < num_items; i++) { gDropdownItemsFormat[i] = 2777; - gDropdownItemsArgs[i] = (uint64)&gConfigColourSchemes.presets[i].name; + gDropdownItemsArgs[i] = (uint64)&gConfigThemes.presets[i].name; } window_options_show_dropdown(w, widget, num_items); - gDropdownItemsChecked = 1 << gCurrentColourSchemePreset; + gDropdownItemsChecked = 1 << gCurrentTheme; break; case WIDX_LANGUAGE_DROPDOWN: for (i = 1; i < LANGUAGE_COUNT; i++) { @@ -768,9 +768,9 @@ static void window_options_dropdown() gfx_invalidate_screen(); } break; - case WIDX_COLOUR_SCHEMES_DROPDOWN: + case WIDX_THEMES_DROPDOWN: if (dropdownIndex != -1) { - colour_scheme_change_preset(dropdownIndex); + theme_change_preset(dropdownIndex); } config_save_default(); break; @@ -842,9 +842,9 @@ static void window_options_invalidate() window_options_widgets[WIDX_CONSTRUCTION_MARKER].type = WWT_DROPDOWN; window_options_widgets[WIDX_CONSTRUCTION_MARKER_DROPDOWN].type = WWT_DROPDOWN_BUTTON; window_options_widgets[WIDX_HARDWARE_DISPLAY_CHECKBOX].type = WWT_CHECKBOX; - window_options_widgets[WIDX_COLOUR_SCHEMES].type = WWT_DROPDOWN; - window_options_widgets[WIDX_COLOUR_SCHEMES_DROPDOWN].type = WWT_DROPDOWN_BUTTON; - window_options_widgets[WIDX_COLOUR_SCHEMES_BUTTON].type = WWT_DROPDOWN_BUTTON; + window_options_widgets[WIDX_THEMES].type = WWT_DROPDOWN; + window_options_widgets[WIDX_THEMES_DROPDOWN].type = WWT_DROPDOWN_BUTTON; + window_options_widgets[WIDX_THEMES_BUTTON].type = WWT_DROPDOWN_BUTTON; break; case WINDOW_OPTIONS_PAGE_CULTURE: // currency: pounds, dollars, etc. (10 total) @@ -992,15 +992,16 @@ static void window_options_paint() gfx_draw_string_left(dpi, STR_FULLSCREEN_MODE, w, 12, w->x + 10, w->y + window_options_widgets[WIDX_FULLSCREEN].top + 1); gfx_draw_string_left(dpi, STR_CONSTRUCTION_MARKER, w, 0, w->x + 10, w->y + window_options_widgets[WIDX_CONSTRUCTION_MARKER].top + 1); - RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint32) = (uint32)&gConfigColourSchemes.presets[gCurrentColourSchemePreset].name; - gfx_draw_string_left(dpi, 5238, NULL, w->colours[1], w->x + 10, w->y + window_options_widgets[WIDX_COLOUR_SCHEMES].top + 1); - gfx_draw_string_left( + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint32) = (uint32)&gConfigThemes.presets[gCurrentTheme].name; + gfx_draw_string_left(dpi, 5238, NULL, w->colours[1], w->x + 10, w->y + window_options_widgets[WIDX_THEMES].top + 1); + gfx_draw_string_left_clipped( dpi, 1170, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, w->colours[1], - w->x + window_options_widgets[WIDX_COLOUR_SCHEMES].left + 1, - w->y + window_options_widgets[WIDX_COLOUR_SCHEMES].top + w->x + window_options_widgets[WIDX_THEMES].left + 1, + w->y + window_options_widgets[WIDX_THEMES].top, + window_options_widgets[WIDX_THEMES_DROPDOWN].left - window_options_widgets[WIDX_THEMES].left - 4 ); break; case WINDOW_OPTIONS_PAGE_CULTURE: diff --git a/src/windows/park.c b/src/windows/park.c index d737ba5558..a4b7e17b47 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -38,7 +38,7 @@ #include "../world/sprite.h" #include "../management/finance.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_PARK_PAGE { WINDOW_PARK_PAGE_ENTRANCE, diff --git a/src/windows/research.c b/src/windows/research.c index 25831d6c65..e06ca46dbb 100644 --- a/src/windows/research.c +++ b/src/windows/research.c @@ -30,7 +30,7 @@ #include "../sprites.h" #include "../world/scenery.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WINDOW_RESEARCH_PAGE_DEVELOPMENT, diff --git a/src/windows/ride.c b/src/windows/ride.c index 69a42ee60f..989d1092f2 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -36,7 +36,7 @@ #include "../world/sprite.h" #include "../audio/audio.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define var_496(w) RCT2_GLOBAL((int)w + 0x496, uint16) diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index 615d696ef0..1823a2151c 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -24,7 +24,7 @@ #include "../game.h" #include "../ride/track.h" #include "../drawing/drawing.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" /* move to ride.c */ void sub_6b2fa9(rct_windownumber number){ diff --git a/src/windows/ride_list.c b/src/windows/ride_list.c index eccece57cc..df045542a2 100644 --- a/src/windows/ride_list.c +++ b/src/windows/ride_list.c @@ -28,7 +28,7 @@ #include "../interface/widget.h" #include "../interface/window.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { PAGE_RIDES, diff --git a/src/windows/save_prompt.c b/src/windows/save_prompt.c index 7ee23be8db..be2349cc90 100644 --- a/src/windows/save_prompt.c +++ b/src/windows/save_prompt.c @@ -28,7 +28,7 @@ #include "../openrct2.h" #include "../sprites.h" #include "../tutorial.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_SAVE_PROMPT_WIDGET_IDX { WIDX_BACKGROUND, diff --git a/src/windows/scenery.c b/src/windows/scenery.c index 5fc443bb7e..912a9d5a08 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -32,7 +32,7 @@ #include "../world/scenery.h" #include "../world/sprite.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define WINDOW_SCENERY_WIDTH 634 #define WINDOW_SCENERY_HEIGHT 142 diff --git a/src/windows/shortcut_key_change.c b/src/windows/shortcut_key_change.c index 994f1f706a..01cf458ca6 100644 --- a/src/windows/shortcut_key_change.c +++ b/src/windows/shortcut_key_change.c @@ -23,7 +23,7 @@ #include "../interface/window.h" #include "../interface/widget.h" #include "../localisation/localisation.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define WW 250 #define WH 60 diff --git a/src/windows/shortcut_keys.c b/src/windows/shortcut_keys.c index 55f42fb5c4..24e6db0dd9 100644 --- a/src/windows/shortcut_keys.c +++ b/src/windows/shortcut_keys.c @@ -24,7 +24,7 @@ #include "../interface/widget.h" #include "../localisation/localisation.h" #include "../platform/platform.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define WW 340 #define WH 240 diff --git a/src/windows/sign.c b/src/windows/sign.c index abc052324a..7689997a3a 100644 --- a/src/windows/sign.c +++ b/src/windows/sign.c @@ -32,7 +32,7 @@ #include "error.h" #include "dropdown.h" #include "../drawing/drawing.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define WW 113 #define WH 96 diff --git a/src/windows/staff.c b/src/windows/staff.c index f865bbe3b5..e2183ef642 100644 --- a/src/windows/staff.c +++ b/src/windows/staff.c @@ -34,7 +34,7 @@ #include "../input.h" #include "dropdown.h" #include "error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define WW 190 #define WH 180 diff --git a/src/windows/staff_fire_prompt.c b/src/windows/staff_fire_prompt.c index 31ec1a77d1..f6b4cf169a 100644 --- a/src/windows/staff_fire_prompt.c +++ b/src/windows/staff_fire_prompt.c @@ -27,7 +27,7 @@ #include "../peep/staff.h" #include "../sprites.h" #include "../world/sprite.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define WW 200 #define WH 100 diff --git a/src/windows/staff_list.c b/src/windows/staff_list.c index 86cad33ca4..f67ed2ffeb 100644 --- a/src/windows/staff_list.c +++ b/src/windows/staff_list.c @@ -31,7 +31,7 @@ #include "../peep/staff.h" #include "../world/sprite.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WINDOW_STAFF_LIST_TAB_HANDYMEN, diff --git a/src/windows/themes.c b/src/windows/themes.c new file mode 100644 index 0000000000..a3bf9e1c9d --- /dev/null +++ b/src/windows/themes.c @@ -0,0 +1,792 @@ +/***************************************************************************** +* Copyright (c) 2014 Maciek Baron, Dániel Tar +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "../addresses.h" +#include "../config.h" +#include "../game.h" +#include "../drawing/drawing.h" +#include "../input.h" +#include "../interface/viewport.h" +#include "../interface/widget.h" +#include "../interface/window.h" +#include "../localisation/localisation.h" +#include "../peep/peep.h" +#include "../peep/staff.h" +#include "../world/sprite.h" +#include "../sprites.h" +#include "dropdown.h" +#include "../interface/themes.h" +#include "error.h" + +enum { + WINDOW_THEMES_TAB_SETTINGS, + WINDOW_THEMES_TAB_MAIN_UI, + WINDOW_THEMES_TAB_PARK, + WINDOW_THEMES_TAB_TOOLS, + WINDOW_THEMES_TAB_RIDES_PEEPS, + WINDOW_THEMES_TAB_EDITORS, + WINDOW_THEMES_TAB_MISC, + WINDOW_THEMES_TAB_PROMPTS +} WINDOW_THEMES_TAB; + +static void window_themes_emptysub() { } +static void window_themes_close(); +static void window_themes_mouseup(); +static void window_themes_resize(); +static void window_themes_mousedown(int widgetIndex, rct_window*w, rct_widget* widget); +static void window_themes_dropdown(); +static void window_themes_update(rct_window *w); +static void window_themes_scrollgetsize(); +static void window_themes_scrollmousedown(); +static void window_themes_scrollmouseover(); +static void window_themes_textinput(); +static void window_themes_tooltip(); +static void window_themes_invalidate(); +static void window_themes_paint(); +static void window_themes_scrollpaint(); +static void window_themes_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w); + +static void* window_themes_events[] = { + window_themes_close, + window_themes_mouseup, + window_themes_resize, + window_themes_mousedown, + window_themes_dropdown, + window_themes_emptysub, + window_themes_update, + window_themes_emptysub, + window_themes_emptysub, + window_themes_emptysub, + window_themes_emptysub, + window_themes_emptysub, + window_themes_emptysub, + window_themes_emptysub, + window_themes_emptysub, + window_themes_scrollgetsize, + window_themes_scrollmousedown, + window_themes_emptysub, + window_themes_scrollmouseover, + window_themes_textinput, + window_themes_emptysub, + window_themes_emptysub, + window_themes_tooltip, + window_themes_emptysub, + window_themes_emptysub, + window_themes_invalidate, + window_themes_paint, + window_themes_scrollpaint, +}; + +enum WINDOW_STAFF_LIST_WIDGET_IDX { + WIDX_THEMES_BACKGROUND, + WIDX_THEMES_TITLE, + WIDX_THEMES_CLOSE, + WIDX_THEMES_TAB_CONTENT_PANEL, + WIDX_THEMES_SETTINGS_TAB, + WIDX_THEMES_MAIN_UI_TAB, + WIDX_THEMES_PARK_TAB, + WIDX_THEMES_TOOLS_TAB, + WIDX_THEMES_RIDE_PEEPS_TAB, + WIDX_THEMES_EDITORS_TAB, + WIDX_THEMES_MISC_TAB, + WIDX_THEMES_PROMPTS_TAB, + WIDX_THEMES_PRESETS, + WIDX_THEMES_PRESETS_DROPDOWN, + WIDX_THEMES_DUPLICATE_BUTTON, + WIDX_THEMES_DELETE_BUTTON, + WIDX_THEMES_RENAME_BUTTON, + WIDX_THEMES_COLORBTN_MASK, + WIDX_THEMES_LIST, +}; + +static rct_widget window_themes_widgets[] = { + { WWT_FRAME, 0, 0, 319, 0, 106, 0x0FFFFFFFF, STR_NONE }, // panel / background + { WWT_CAPTION, 0, 1, 318, 1, 14, 5244, STR_WINDOW_TITLE_TIP }, // title bar + { WWT_CLOSEBOX, 0, 307, 317, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close button + { WWT_RESIZE, 1, 0, 319, 43, 106, 0x0FFFFFFFF, STR_NONE }, // tab content panel + { WWT_TAB, 1, 3, 33, 17, 43, 0x02000144E, 5235 }, // settings tab + { WWT_TAB, 1, 34, 64, 17, 43, 0x02000144E, 5228 }, // main ui tab + { WWT_TAB, 1, 65, 95, 17, 43, 0x02000144E, 5229 }, // park tab + { WWT_TAB, 1, 96, 126, 17, 43, 0x02000144E, 5230 }, // tools tab + { WWT_TAB, 1, 127, 157, 17, 43, 0x02000144E, 5232 }, // rides and peeps tab + { WWT_TAB, 1, 158, 188, 17, 43, 0x02000144E, 5232 }, // editors tab + { WWT_TAB, 1, 189, 219, 17, 43, 0x02000144E, 5233 }, // misc tab + { WWT_TAB, 1, 220, 250, 17, 43, 0x02000144E, 5234 }, // prompts tab + { WWT_DROPDOWN, 1, 125, 299, 60, 71, STR_NONE, STR_NONE }, // Preset colour schemes + { WWT_DROPDOWN_BUTTON, 1, 288, 298, 61, 70, 876, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 1, 10, 100, 82, 93, 5239, 5257 }, // Duplicate button + { WWT_DROPDOWN_BUTTON, 1, 110, 200, 82, 93, 3349, 5258 }, // Delete button + { WWT_DROPDOWN_BUTTON, 1, 210, 300, 82, 93, 3348, 5259 }, // Rename button + { WWT_COLORBTN, 1, 0, 0, 0, 0, STR_NONE, STR_NONE }, // color button mask + { WWT_SCROLL, 1, 3, 316, 60, 103, 2, STR_NONE }, // staff list + { WIDGETS_END }, +}; + +static int window_themes_tab_animation_loops[] = { + 32, + 32, + 1, + 1, + 64, + 32, + 8, + 14 +}; +static int window_themes_tab_animation_divisor[] = { + 4, + 4, + 1, + 1, + 4, + 2, + 2, + 2 +}; +static int window_themes_tab_sprites[] = { + 5221, + SPR_TAB_KIOSKS_AND_FACILITIES_0, + 5200, + SPR_G2_TAB_LAND, + SPR_TAB_RIDE_0, + 5205, + 5201, + SPR_TAB_STAFF_OPTIONS_0 +}; + +static rct_windowclass window_themes_tab_1_classes[] = { + WC_TOP_TOOLBAR, + WC_BOTTOM_TOOLBAR, + WC_EDITOR_SCENARIO_BOTTOM_TOOLBAR, + WC_EDITOR_TRACK_BOTTOM_TOOLBAR, + WC_TITLE_MENU, + WC_TITLE_EXIT, + WC_TITLE_OPTIONS, + WC_SCENARIO_SELECT +}; + +static rct_windowclass window_themes_tab_2_classes[] = { + WC_PARK_INFORMATION, + WC_FINANCES, + WC_NEW_CAMPAIGN, + WC_RESEARCH, + WC_MAP, + WC_VIEWPORT, + WC_RECENT_NEWS +}; + +static rct_windowclass window_themes_tab_3_classes[] = { + WC_LAND, + WC_WATER, + WC_CLEAR_SCENERY, + WC_LAND_RIGHTS, + WC_SCENERY, + WC_FOOTPATH, + WC_RIDE_CONSTRUCTION, + WC_TRACK_DESIGN_PLACE, + WC_CONSTRUCT_RIDE, + WC_TRACK_DESIGN_LIST +}; + +static rct_windowclass window_themes_tab_4_classes[] = { + WC_RIDE, + WC_RIDE_LIST, + WC_PEEP, + WC_GUEST_LIST, + WC_STAFF, + WC_STAFF_LIST, + WC_BANNER +}; + +static rct_windowclass window_themes_tab_5_classes[] = { + WC_EDITOR_OBJECT_SELECTION, + WC_EDITOR_INVENTION_LIST, + WC_EDITOR_SCENARIO_OPTIONS, + WC_EDTIOR_OBJECTIVE_OPTIONS, + WC_MAPGEN, + WC_MANAGE_TRACK_DESIGN, + WC_INSTALL_TRACK +}; + +static rct_windowclass window_themes_tab_6_classes[] = { + WC_CHEATS, + WC_THEMES, + WC_OPTIONS, + WC_KEYBOARD_SHORTCUT_LIST, + WC_CHANGE_KEYBOARD_SHORTCUT, + WC_LOADSAVE +}; + +static rct_windowclass window_themes_tab_7_classes[] = { + WC_SAVE_PROMPT, + WC_DEMOLISH_RIDE_PROMPT, + WC_FIRE_PROMPT, + WC_TRACK_DELETE_PROMPT, + WC_LOADSAVE_OVERWRITE_PROMPT +}; + +static uint8 _selected_tab = 0; +static sint16 _color_index_1 = -1; +static sint8 _color_index_2 = -1; +static const uint8 _row_height = 32; +static const uint8 _button_offset_x = 220; +static const uint8 _button_offset_y = 3; +static const uint8 _check_offset_y = 3 + 12 + 2; + +void window_themes_init_vars() +{ + _selected_tab = WINDOW_THEMES_TAB_SETTINGS; +} + +static window_colour_scheme* get_colour_scheme_tab() +{ + switch (_selected_tab) { + case 1: return colour_scheme_get_by_class(window_themes_tab_1_classes[_color_index_1]); + case 2: return colour_scheme_get_by_class(window_themes_tab_2_classes[_color_index_1]); + case 3: return colour_scheme_get_by_class(window_themes_tab_3_classes[_color_index_1]); + case 4: return colour_scheme_get_by_class(window_themes_tab_4_classes[_color_index_1]); + case 5: return colour_scheme_get_by_class(window_themes_tab_5_classes[_color_index_1]); + case 6: return colour_scheme_get_by_class(window_themes_tab_6_classes[_color_index_1]); + case 7: return colour_scheme_get_by_class(window_themes_tab_7_classes[_color_index_1]); + } + return NULL; +} +static window_colour_scheme* get_colour_scheme_tab_by_index(int index) +{ + switch (_selected_tab) { + case 1: return colour_scheme_get_by_class(window_themes_tab_1_classes[index]); + case 2: return colour_scheme_get_by_class(window_themes_tab_2_classes[index]); + case 3: return colour_scheme_get_by_class(window_themes_tab_3_classes[index]); + case 4: return colour_scheme_get_by_class(window_themes_tab_4_classes[index]); + case 5: return colour_scheme_get_by_class(window_themes_tab_5_classes[index]); + case 6: return colour_scheme_get_by_class(window_themes_tab_6_classes[index]); + case 7: return colour_scheme_get_by_class(window_themes_tab_7_classes[index]); + } + return NULL; +} + +static int get_colour_scheme_tab_count() +{ + switch (_selected_tab) { + case 1: return sizeof(window_themes_tab_1_classes); + case 2: return sizeof(window_themes_tab_2_classes); + case 3: return sizeof(window_themes_tab_3_classes); + case 4: return sizeof(window_themes_tab_4_classes); + case 5: return sizeof(window_themes_tab_5_classes); + case 6: return sizeof(window_themes_tab_6_classes); + case 7: return sizeof(window_themes_tab_7_classes); + } + return 0; +} + +static int get_colour_scheme_index() { + switch (_selected_tab) { + case 1: return colour_scheme_get_index_by_class(window_themes_tab_1_classes[_color_index_1]); + case 2: return colour_scheme_get_index_by_class(window_themes_tab_2_classes[_color_index_1]); + case 3: return colour_scheme_get_index_by_class(window_themes_tab_3_classes[_color_index_1]); + case 4: return colour_scheme_get_index_by_class(window_themes_tab_4_classes[_color_index_1]); + case 5: return colour_scheme_get_index_by_class(window_themes_tab_5_classes[_color_index_1]); + case 6: return colour_scheme_get_index_by_class(window_themes_tab_6_classes[_color_index_1]); + case 7: return colour_scheme_get_index_by_class(window_themes_tab_7_classes[_color_index_1]); + } + return -1; +} + +static void window_themes_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w) +{ + int sprite_idx; + + for (int i = 0; i < 8; i++) { + sprite_idx = window_themes_tab_sprites[i]; + if (_selected_tab == i) + sprite_idx += w->frame_no / window_themes_tab_animation_divisor[_selected_tab]; + gfx_draw_sprite(dpi, sprite_idx, w->x + w->widgets[WIDX_THEMES_SETTINGS_TAB + i].left, w->y + w->widgets[WIDX_THEMES_SETTINGS_TAB + i].top, 0); + } +} + +void window_themes_open() +{ + rct_window* window; + + // Check if window is already open + window = window_bring_to_front_by_class(WC_THEMES); + if (window != NULL) + return; + + window = window_create_auto_pos(320, 107, (uint32*)window_themes_events, WC_THEMES, 0x0400); + window->widgets = window_themes_widgets; + window->enabled_widgets = + (1 << WIDX_THEMES_CLOSE) | + (1 << WIDX_THEMES_SETTINGS_TAB) | + (1 << WIDX_THEMES_MAIN_UI_TAB) | + (1 << WIDX_THEMES_PARK_TAB) | + (1 << WIDX_THEMES_TOOLS_TAB) | + (1 << WIDX_THEMES_RIDE_PEEPS_TAB) | + (1 << WIDX_THEMES_EDITORS_TAB) | + (1 << WIDX_THEMES_MISC_TAB) | + (1 << WIDX_THEMES_PROMPTS_TAB) | + (1 << WIDX_THEMES_COLORBTN_MASK) | + (1 << WIDX_THEMES_PRESETS) | + (1 << WIDX_THEMES_PRESETS_DROPDOWN) | + (1 << WIDX_THEMES_DUPLICATE_BUTTON) | + (1 << WIDX_THEMES_DELETE_BUTTON) | + (1 << WIDX_THEMES_RENAME_BUTTON); + + window_themes_init_vars(); + + window_init_scroll_widgets(window); + window->list_information_type = 0; + _color_index_1 = -1; + _color_index_2 = -1; + window->min_width = 320; + window->min_height = 107; + window->max_width = 320; + window->max_height = 107; + window->flags |= WF_RESIZABLE; +} + +void window_themes_close() { + rct_window *w; + + window_get_register(w); +} + +static void window_themes_mouseup() +{ + short widgetIndex; + rct_window *w; + + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex) { + case WIDX_THEMES_CLOSE: + window_close(w); + break; + case WIDX_THEMES_DUPLICATE_BUTTON: + window_text_input_open(w, widgetIndex, 5239, 5240, 1170, (uint32)&gConfigThemes.presets[gCurrentTheme].name, 64); + break; + case WIDX_THEMES_DELETE_BUTTON: + if (gCurrentTheme >= 2) { + theme_delete_preset(gCurrentTheme); + } + else { + window_error_open(5241, STR_NONE); + } + break; + case WIDX_THEMES_RENAME_BUTTON: + if (gCurrentTheme >= 2) { + window_text_input_open(w, widgetIndex, 3348, 5240, 1170, (uint32)&gConfigThemes.presets[gCurrentTheme].name, 64); + } + else { + window_error_open(5241, STR_NONE); + } + break; + } +} + +static void window_themes_resize() +{ + rct_window *w; + + window_get_register(w); + + if (_selected_tab == WINDOW_THEMES_TAB_SETTINGS) { + window_set_resize(w, 320, 107, 320, 107); + gfx_invalidate_screen(); + } + else { + w->min_width = 320; + w->min_height = 270; + w->max_width = 320; + w->max_height = 450; + + if (w->width < w->min_width) { + w->width = w->min_width; + window_invalidate(w); + } + if (w->height < w->min_height) { + w->height = w->min_height; + window_invalidate(w); + } + if (w->width > w->max_width) { + w->width = w->max_width; + window_invalidate(w); + } + if (w->height > w->max_height) { + w->height = w->max_height; + window_invalidate(w); + } + } +} + +static void window_themes_mousedown(int widgetIndex, rct_window* w, rct_widget* widget) +{ + short newSelectedTab; + int num_items, i; + + switch (widgetIndex) { + case WIDX_THEMES_SETTINGS_TAB: + case WIDX_THEMES_MAIN_UI_TAB: + case WIDX_THEMES_PARK_TAB: + case WIDX_THEMES_TOOLS_TAB: + case WIDX_THEMES_RIDE_PEEPS_TAB: + case WIDX_THEMES_EDITORS_TAB: + case WIDX_THEMES_MISC_TAB: + case WIDX_THEMES_PROMPTS_TAB: + newSelectedTab = widgetIndex - WIDX_THEMES_SETTINGS_TAB; + if (_selected_tab == newSelectedTab) + break; + _selected_tab = (uint8)newSelectedTab; + w->scrolls[0].v_top = 0; + w->frame_no = 0; + window_event_resize_call(w); + window_invalidate(w); + break; + case WIDX_THEMES_PRESETS_DROPDOWN: + num_items = gConfigThemes.num_presets; + + widget--; + for (i = 0; i < num_items; i++) { + gDropdownItemsFormat[i] = 2777; + gDropdownItemsArgs[i] = (uint64)&gConfigThemes.presets[i].name; + } + + window_dropdown_show_text_custom_width( + w->x + widget->left, + w->y + widget->top, + widget->bottom - widget->top + 1, + w->colours[1], + DROPDOWN_FLAG_STAY_OPEN, + num_items, + widget->right - widget->left - 3 + ); + + gDropdownItemsChecked = 1 << gCurrentTheme; + break; + } +} + +static void window_themes_dropdown() +{ + rct_window* w; + short widgetIndex, dropdownIndex; + window_dropdown_get_registers(w, widgetIndex, dropdownIndex); + + switch (widgetIndex) { + case WIDX_THEMES_LIST: + if (dropdownIndex != -1) { + get_colour_scheme_tab()->colours[_color_index_2] = dropdownIndex | get_colour_scheme_tab()->colours[_color_index_2] & 0x80; + gConfigThemes.presets[gCurrentTheme].colour_schemes[get_colour_scheme_index()].colours[_color_index_2] = dropdownIndex | get_colour_scheme_tab()->colours[_color_index_2] & 0x80; + window_invalidate_all(); + _color_index_1 = -1; + _color_index_2 = -1; + + if (gCurrentTheme >= 2) + themes_save_preset(gCurrentTheme); + } + break; + case WIDX_THEMES_PRESETS_DROPDOWN: + if (dropdownIndex != -1) { + theme_change_preset(dropdownIndex); + } + config_save_default(); + break; + } + +} + +void window_themes_update(rct_window *w) +{ + w->frame_no++; + if (w->frame_no >= window_themes_tab_animation_loops[_selected_tab]) + w->frame_no = 0; + + widget_invalidate(w, WIDX_THEMES_SETTINGS_TAB + _selected_tab); + +} + +void window_themes_scrollgetsize() { + rct_window *w; + + window_get_register(w); + + int scrollHeight = get_colour_scheme_tab_count() * _row_height; + int i = scrollHeight - window_themes_widgets[WIDX_THEMES_LIST].bottom + window_themes_widgets[WIDX_THEMES_LIST].top + 21; + if (i < 0) + i = 0; + if (i < w->scrolls[0].v_top) { + w->scrolls[0].v_top = i; + window_invalidate(w); + } + + #ifdef _MSC_VER + __asm mov ecx, 420 + #else + __asm__("mov ecx, 420 "); + #endif + + #ifdef _MSC_VER + __asm mov edx, scrollHeight + #else + __asm__("mov edx, %[scrollHeight] " : [scrollHeight] "+m" (scrollHeight)); + #endif +} + +void window_themes_scrollmousedown() { + short x, y, scrollIndex; + rct_window *w; + + window_scrollmouse_get_registers(w, scrollIndex, x, y); + + if (_selected_tab == WINDOW_THEMES_TAB_SETTINGS) + return; + + if (y / _row_height < get_colour_scheme_tab_count()) { + int y2 = y % _row_height; + _color_index_1 = y / _row_height; + _color_index_2 = ((x - _button_offset_x) / 12); + if (_color_index_2 < get_colour_scheme_tab()->num_colours) { + if (x >= _button_offset_x && x < _button_offset_x + 12 * 6 && y2 >= _button_offset_y && y2 < _button_offset_y + 11) { + if (gCurrentTheme >= 2) { + window_themes_widgets[WIDX_THEMES_COLORBTN_MASK].left = _button_offset_x + _color_index_2 * 12 + window_themes_widgets[WIDX_THEMES_LIST].left; + window_themes_widgets[WIDX_THEMES_COLORBTN_MASK].top = _color_index_1 * _row_height + _button_offset_y - w->scrolls[0].v_top + window_themes_widgets[WIDX_THEMES_LIST].top; + window_themes_widgets[WIDX_THEMES_COLORBTN_MASK].right = window_themes_widgets[WIDX_THEMES_COLORBTN_MASK].left + 11; + window_themes_widgets[WIDX_THEMES_COLORBTN_MASK].bottom = window_themes_widgets[WIDX_THEMES_COLORBTN_MASK].top + 11; + window_dropdown_show_colour(w, &(window_themes_widgets[WIDX_THEMES_COLORBTN_MASK]), w->colours[1], get_colour_scheme_tab()->colours[_color_index_2]); + } + else { + window_error_open(5241, 5256); + } + } + else if (x >= _button_offset_x && x < _button_offset_x + 12 * 6 - 1 && y2 >= _check_offset_y && y2 < _check_offset_y + 11) { + if (gCurrentTheme >= 2) { + if (get_colour_scheme_tab()->colours[_color_index_2] & 0x80) { + get_colour_scheme_tab()->colours[_color_index_2] &= 0x7F; + + gConfigThemes.presets[gCurrentTheme].colour_schemes[get_colour_scheme_index()].colours[_color_index_2] &= 0x7F; + } + else { + get_colour_scheme_tab()->colours[_color_index_2] |= 0x80; + gConfigThemes.presets[gCurrentTheme].colour_schemes[get_colour_scheme_index()].colours[_color_index_2] |= 0x80; + } + themes_save_preset(gCurrentTheme); + window_invalidate_all(); + } + else { + window_error_open(5241, 5256); + } + } + } + } +} + +void window_themes_scrollmouseover() { + short x, y, scrollIndex; + rct_window *w; + + window_scrollmouse_get_registers(w, scrollIndex, x, y); + + //if (_selected_tab == WINDOW_THEMES_TAB_SETTINGS) + // return; +} + +static bool valid_characters(const char *name) +{ + for (int i = 0; name[i] != '\0'; i++) { + if (name[i] == '\\' || name[i] == '/' || name[i] == ':' || name[i] == '?' || name[i] == '*' || name[i] == '<' || name[i] == '>' || name[i] == '|') + return false; + } + return true; +} + +static void window_themes_textinput() +{ + rct_window *w; + short widgetIndex; + uint8 result; + char *text; + + window_textinput_get_registers(w, widgetIndex, result, text); + + if (!result || text[0] == 0) + return; + + switch (widgetIndex) { + case WIDX_THEMES_DUPLICATE_BUTTON: + case WIDX_THEMES_RENAME_BUTTON: + if (valid_characters(text)) { + bool nameTaken = false; + for (int i = 0; i < gConfigThemes.num_presets; i++) { + if (strcmp(gConfigThemes.presets[i].name, text) == 0) { + window_error_open(5242, STR_NONE); + nameTaken = true; + break; + } + } + if (!nameTaken) { + if (widgetIndex == WIDX_THEMES_DUPLICATE_BUTTON) { + theme_create_preset(text); + } + else { + theme_rename_preset(gCurrentTheme, text); + } + config_save_default(); + window_invalidate(w); + } + } + else { + window_error_open(5243, STR_NONE); + } + break; + } +} + +void window_themes_tooltip() +{ + RCT2_GLOBAL(0x013CE952, uint16) = STR_LIST; +} + +void window_themes_invalidate() +{ + rct_window *w; + + window_get_register(w); + colour_scheme_update(w); + + int pressed_widgets = w->pressed_widgets & 0xFFFFF00F; + uint8 widgetIndex = _selected_tab + 4; + + w->pressed_widgets = pressed_widgets | (1 << widgetIndex); + + if (window_find_by_class(WC_DROPDOWN) == NULL) { + _color_index_1 = -1; + _color_index_2 = -1; + } + + window_themes_widgets[WIDX_THEMES_BACKGROUND].right = w->width - 1; + window_themes_widgets[WIDX_THEMES_BACKGROUND].bottom = w->height - 1; + window_themes_widgets[WIDX_THEMES_TAB_CONTENT_PANEL].right = w->width - 1; + window_themes_widgets[WIDX_THEMES_TAB_CONTENT_PANEL].bottom = w->height - 1; + window_themes_widgets[WIDX_THEMES_TITLE].right = w->width - 2; + window_themes_widgets[WIDX_THEMES_CLOSE].left = w->width - 2 - 0x0B; + window_themes_widgets[WIDX_THEMES_CLOSE].right = w->width - 2 - 0x0B + 0x0A; + window_themes_widgets[WIDX_THEMES_LIST].right = w->width - 4; + window_themes_widgets[WIDX_THEMES_LIST].bottom = w->height - 0x0F; + + if (_selected_tab == WINDOW_THEMES_TAB_SETTINGS) { + window_themes_widgets[WIDX_THEMES_LIST].type = WWT_EMPTY; + } + else { + window_themes_widgets[WIDX_THEMES_LIST].type = WWT_SCROLL; + } +} + +void window_themes_paint() { + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + // Widgets + window_draw_widgets(w, dpi); + window_themes_draw_tab_images(dpi, w); + + if (_selected_tab != WINDOW_THEMES_TAB_SETTINGS) { + + gfx_draw_string_left(dpi, 5236, w, w->colours[1], w->x + 6, 58 - 12 + w->y + 1); + gfx_draw_string_left(dpi, 5237, w, w->colours[1], w->x + 220, 58 - 12 + w->y + 1); + } + else { + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint32) = (uint32)&gConfigThemes.presets[gCurrentTheme].name; + gfx_draw_string_left(dpi, 5238, NULL, w->colours[1], w->x + 10, w->y + window_themes_widgets[WIDX_THEMES_PRESETS].top + 1); + gfx_draw_string_left_clipped( + dpi, + 1170, + (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, + w->colours[1], + w->x + window_themes_widgets[WIDX_THEMES_PRESETS].left + 1, + w->y + window_themes_widgets[WIDX_THEMES_PRESETS].top, + w->x + window_themes_widgets[WIDX_THEMES_PRESETS_DROPDOWN].left - window_themes_widgets[WIDX_THEMES_PRESETS].left - 4 + ); + } +} + +/** +* +* rct2: 0x006BD785 +*/ +void window_themes_scrollpaint() +{ + int y; + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + if (_selected_tab == WINDOW_THEMES_TAB_SETTINGS) + return; + + if ((w->colours[1] & 0x80) == 0) + //gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ((char*)0x0141FC48)[w->colours[1] * 8]); + gfx_clear(dpi, ((char*)0x0141FC48)[w->colours[1] * 8] * 0x1010101); + y = 0; + for (int i = 0; i < get_colour_scheme_tab_count(); i++) { + if (y > dpi->y + dpi->height) { + break; + } + if (y + _row_height >= dpi->y) { + if (i + 1 < get_colour_scheme_tab_count()) { + int colour = w->colours[1]; + if (colour & 0x80) { + colour = RCT2_ADDRESS(0x009DEDF4, uint8)[colour]; + + colour = colour | 0x2000000; + gfx_fill_rect(dpi, 0, y + _row_height - 2, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 2, colour + 1); + gfx_fill_rect(dpi, 0, y + _row_height - 1, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 1, colour + 2); + } + else { + colour = RCT2_ADDRESS(0x0141FC47, uint8)[w->colours[1] * 8]; + gfx_fill_rect(dpi, 0, y + _row_height - 2, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 2, colour); + colour = RCT2_ADDRESS(0x0141FC4B, uint8)[w->colours[1] * 8]; + gfx_fill_rect(dpi, 0, y + _row_height - 1, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 1, colour); + } + } + + for (int j = 0; j < get_colour_scheme_tab_by_index(i)->num_colours; j++) { + + gfx_draw_string_left(dpi, get_colour_scheme_tab_by_index(i)->name, NULL, w->colours[1], 2, y + 4); + + uint32 image = ((get_colour_scheme_tab_by_index(i)->colours[j] & 0x7F) << 19) + 0x600013C3; + if (i == _color_index_1 && j == _color_index_2) { + image = ((get_colour_scheme_tab_by_index(i)->colours[j] & 0x7F) << 19) + 0x600013C4; + } + gfx_draw_sprite(dpi, image, _button_offset_x + 12 * j, y + _button_offset_y, 0); + + gfx_fill_rect_inset(dpi, _button_offset_x + 12 * j, y + _check_offset_y, _button_offset_x + 12 * j + 9, y + _check_offset_y + 10, w->colours[1], 0xE0); + if (get_colour_scheme_tab_by_index(i)->colours[j] & 0x80) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = -1; + gfx_draw_string(dpi, (char*)0x009DED72, w->colours[1] & 0x7F, _button_offset_x + 12 * j, y + _check_offset_y); + } + + } + } + + y += _row_height; + } +} diff --git a/src/windows/title_exit.c b/src/windows/title_exit.c index 61273eaa53..4c52d07349 100644 --- a/src/windows/title_exit.c +++ b/src/windows/title_exit.c @@ -25,7 +25,7 @@ #include "../localisation/localisation.h" #include "../interface/widget.h" #include "../interface/window.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" static rct_widget window_title_exit_widgets[] = { { WWT_IMGBTN, 2, 0, 39, 0, 63, SPR_MENU_EXIT, STR_EXIT }, diff --git a/src/windows/title_menu.c b/src/windows/title_menu.c index 33a60ed1e2..cd5882bc99 100644 --- a/src/windows/title_menu.c +++ b/src/windows/title_menu.c @@ -28,7 +28,7 @@ #include "../sprites.h" #include "../tutorial.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WIDX_START_NEW_GAME, diff --git a/src/windows/title_options.c b/src/windows/title_options.c index db02786a90..a5d9ef610c 100644 --- a/src/windows/title_options.c +++ b/src/windows/title_options.c @@ -24,7 +24,7 @@ #include "../localisation/localisation.h" #include "../interface/widget.h" #include "../interface/window.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" static rct_widget window_title_options_widgets[] = { { WWT_DROPDOWN_BUTTON, 2, 0, 79, 0, 11, STR_OPTIONS, STR_NONE }, diff --git a/src/windows/title_scenarioselect.c b/src/windows/title_scenarioselect.c index 93dfd5e7bc..57ec8a4ef1 100644 --- a/src/windows/title_scenarioselect.c +++ b/src/windows/title_scenarioselect.c @@ -27,7 +27,7 @@ #include "../sprites.h" #include "../interface/widget.h" #include "../interface/window.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WIDX_BACKGROUND, diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 522309108e..b80641d51e 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -34,7 +34,7 @@ #include "../world/scenery.h" #include "../world/banner.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WIDX_PAUSE, diff --git a/src/windows/track_list.c b/src/windows/track_list.c index 91019a49f9..92d4546a5f 100644 --- a/src/windows/track_list.c +++ b/src/windows/track_list.c @@ -28,7 +28,7 @@ #include "../ride/track.h" #include "../sprites.h" #include "error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum { WIDX_BACKGROUND, diff --git a/src/windows/track_manage.c b/src/windows/track_manage.c index 023251c5c3..fe8055f14d 100644 --- a/src/windows/track_manage.c +++ b/src/windows/track_manage.c @@ -24,7 +24,7 @@ #include "../localisation/localisation.h" #include "../ride/track.h" #include "error.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #pragma region Widgets diff --git a/src/windows/track_place.c b/src/windows/track_place.c index 4e0ebe457c..d55cd5f994 100644 --- a/src/windows/track_place.c +++ b/src/windows/track_place.c @@ -29,7 +29,7 @@ #include "../sprites.h" #include "../ride/track.h" #include "../ride/track_data.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define TRACK_MINI_PREVIEW_WIDTH 168 #define TRACK_MINI_PREVIEW_HEIGHT 78 diff --git a/src/windows/viewport.c b/src/windows/viewport.c index 11147d8df5..c40ea69850 100644 --- a/src/windows/viewport.c +++ b/src/windows/viewport.c @@ -28,7 +28,7 @@ #include "../interface/widget.h" #include "../interface/window.h" #include "dropdown.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" #define INITIAL_WIDTH 500 #define INITIAL_HEIGHT 350 diff --git a/src/windows/water.c b/src/windows/water.c index 6f371e09f2..07bba3425e 100644 --- a/src/windows/water.c +++ b/src/windows/water.c @@ -25,7 +25,7 @@ #include "../localisation/localisation.h" #include "../sprites.h" #include "../world/map.h" -#include "../interface/colour_schemes.h" +#include "../interface/themes.h" enum WINDOW_WATER_WIDGET_IDX { WIDX_BACKGROUND,