diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 3ffb2b4c0c..df4f98a776 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3667,6 +3667,7 @@ STR_6345 :Tile Inspector: Increase element height STR_6346 :Tile Inspector: Decrease element height STR_6347 :Path additions cannot be placed on level crossings! STR_6348 :Remove level crossing first! +STR_6349 :Random title sequence ############# # Scenarios # diff --git a/distribution/changelog.txt b/distribution/changelog.txt index f523c2331b..07bc294e96 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.2.4+ (in development) ------------------------------------------------------------------------ +- Feature: [#3154] Use a random title sequence each time it is shown. - Feature: [#7865] Transport rides can now be synchronised. - Feature: [#9073] Shortcut keys for the Tile Inspector. - Feature: [#10305] Add two shortcuts for increasing and decreasing the scaling factor. diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index d882058b06..bbdb4e4292 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -157,6 +157,7 @@ enum WINDOW_OPTIONS_WIDGET_IDX { // Misc WIDX_TITLE_SEQUENCE_GROUP = WIDX_PAGE_START, + WIDX_TITLE_SEQUENCE_RANDOM, WIDX_TITLE_SEQUENCE, WIDX_TITLE_SEQUENCE_DROPDOWN, WIDX_TITLE_SEQUENCE_BUTTON, @@ -332,22 +333,23 @@ static rct_widget window_options_controls_and_interface_widgets[] = { static rct_widget window_options_misc_widgets[] = { MAIN_OPTIONS_WIDGETS, #define TITLE_SEQUENCE_START 53 - { WWT_GROUPBOX, 1, 5, 304, TITLE_SEQUENCE_START + 0, TITLE_SEQUENCE_START + 49, STR_OPTIONS_TITLE_SEQUENCE, STR_NONE }, - { WWT_DROPDOWN, 1, 135, 299, TITLE_SEQUENCE_START + 15, TITLE_SEQUENCE_START + 26, STR_STRING, STR_NONE }, // Title sequence dropdown - { WWT_BUTTON, 1, 288, 298, TITLE_SEQUENCE_START + 16, TITLE_SEQUENCE_START + 25, STR_DROPDOWN_GLYPH, STR_TITLE_SEQUENCE_TIP }, // Title sequence dropdown button - { WWT_BUTTON, 1, 135, 299, TITLE_SEQUENCE_START + 30, TITLE_SEQUENCE_START + 42, STR_EDIT_TITLE_SEQUENCES_BUTTON, STR_EDIT_TITLE_SEQUENCES_BUTTON_TIP }, // Edit title sequences button + { WWT_GROUPBOX, 1, 5, 304, TITLE_SEQUENCE_START + 0, TITLE_SEQUENCE_START + 64, STR_OPTIONS_TITLE_SEQUENCE, STR_NONE }, + { WWT_CHECKBOX, 2, 10, 299, TITLE_SEQUENCE_START + 15, TITLE_SEQUENCE_START + 30, STR_OPTIONS_RANDOM_TITLE_SEQUENCE, STR_NONE}, //Random Title Sequence + { WWT_DROPDOWN, 1, 135, 299, TITLE_SEQUENCE_START + 32, TITLE_SEQUENCE_START + 43, STR_STRING, STR_NONE }, // Title sequence dropdown + { WWT_BUTTON, 1, 288, 298, TITLE_SEQUENCE_START + 33, TITLE_SEQUENCE_START + 44, STR_DROPDOWN_GLYPH, STR_TITLE_SEQUENCE_TIP }, // Title sequence dropdown button + { WWT_BUTTON, 1, 135, 299, TITLE_SEQUENCE_START + 48, TITLE_SEQUENCE_START + 60, STR_EDIT_TITLE_SEQUENCES_BUTTON, STR_EDIT_TITLE_SEQUENCES_BUTTON_TIP }, // Edit title sequences button #undef TITLE_SEQUENCE_START -#define SCENARIO_START 107 +#define SCENARIO_START 122 { WWT_GROUPBOX, 1, 5, 304, SCENARIO_START + 0, SCENARIO_START + 50, STR_OPTIONS_SCENARIO_SELECTION, STR_NONE }, { WWT_DROPDOWN, 1, 175, 299, SCENARIO_START + 15, SCENARIO_START + 26, STR_NONE, STR_NONE }, // Scenario select mode { WWT_BUTTON, 1, 288, 298, SCENARIO_START + 16, SCENARIO_START + 25, STR_DROPDOWN_GLYPH, STR_SCENARIO_GROUPING_TIP }, { WWT_CHECKBOX, 2, 25, 299, SCENARIO_START + 30, SCENARIO_START + 45, STR_OPTIONS_SCENARIO_UNLOCKING, STR_SCENARIO_UNLOCKING_TIP }, // Unlocking of scenarios #undef SCENARIO_START -#define SCENARIO_OPTIONS_START 162 +#define SCENARIO_OPTIONS_START 177 { WWT_GROUPBOX, 1, 5, 304, SCENARIO_OPTIONS_START + 0, SCENARIO_OPTIONS_START + 34, STR_SCENARIO_OPTIONS, STR_NONE }, { WWT_CHECKBOX, 2, 10, 299, SCENARIO_OPTIONS_START + 15, SCENARIO_OPTIONS_START + 29, STR_ALLOW_EARLY_COMPLETION, STR_EARLY_COMPLETION_TIP }, // Allow early scenario completion #undef SCENARIO_OPTIONS_START -#define TWEAKS_START 201 +#define TWEAKS_START 216 { WWT_GROUPBOX, 1, 5, 304, TWEAKS_START + 0, TWEAKS_START + 80, STR_OPTIONS_TWEAKS, STR_NONE }, { WWT_CHECKBOX, 2, 10, 299, TWEAKS_START + 15, TWEAKS_START + 29, STR_REAL_NAME, STR_REAL_NAME_TIP }, // Show 'real' names of guests { WWT_CHECKBOX, 2, 10, 299, TWEAKS_START + 30, TWEAKS_START + 44, STR_AUTO_STAFF_PLACEMENT, STR_AUTO_STAFF_PLACEMENT_TIP }, // Auto staff placement @@ -593,6 +595,7 @@ static uint64_t window_options_page_enabled_widgets[] = { (1 << WIDX_TITLE_SEQUENCE) | (1 << WIDX_TITLE_SEQUENCE_DROPDOWN) | (1 << WIDX_TITLE_SEQUENCE_BUTTON) | + (1 << WIDX_TITLE_SEQUENCE_RANDOM) | (1 << WIDX_SCENARIO_GROUPING) | (1 << WIDX_SCENARIO_GROUPING_DROPDOWN) | (1 << WIDX_SCENARIO_UNLOCKING) | @@ -909,6 +912,11 @@ static void window_options_mouseup(rct_window* w, rct_widgetindex widgetIndex) config_save_default(); window_close_by_class(WC_SCENARIO_SELECT); break; + case WIDX_TITLE_SEQUENCE_RANDOM: + gConfigInterface.random_title_sequence ^= 1; + config_save_default(); + w->Invalidate(); + break; case WIDX_AUTO_OPEN_SHOPS: gConfigGeneral.auto_open_shops = !gConfigGeneral.auto_open_shops; config_save_default(); @@ -1904,8 +1912,21 @@ static void window_options_invalidate(rct_window* w) widget_set_checkbox_value(w, WIDX_REAL_NAME_CHECKBOX, gConfigGeneral.show_real_names_of_guests); widget_set_checkbox_value(w, WIDX_AUTO_STAFF_PLACEMENT, gConfigGeneral.auto_staff_placement); widget_set_checkbox_value(w, WIDX_AUTO_OPEN_SHOPS, gConfigGeneral.auto_open_shops); + widget_set_checkbox_value(w, WIDX_TITLE_SEQUENCE_RANDOM, gConfigInterface.random_title_sequence); widget_set_checkbox_value(w, WIDX_ALLOW_EARLY_COMPLETION, gConfigGeneral.allow_early_completion); + // Disable title sequence dropdown if set to random + if (gConfigInterface.random_title_sequence) + { + w->disabled_widgets |= (1 << WIDX_TITLE_SEQUENCE_DROPDOWN); + w->disabled_widgets |= (1 << WIDX_TITLE_SEQUENCE); + } + else + { + w->disabled_widgets &= ~(1 << WIDX_TITLE_SEQUENCE_DROPDOWN); + w->disabled_widgets &= ~(1 << WIDX_TITLE_SEQUENCE); + } + if (gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_DIFFICULTY) window_options_misc_widgets[WIDX_SCENARIO_GROUPING].text = STR_OPTIONS_SCENARIO_DIFFICULTY; else diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 08d59488ee..78094e51ee 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -299,6 +299,7 @@ namespace Config model->console_small_font = reader->GetBoolean("console_small_font", false); model->current_theme_preset = reader->GetCString("current_theme", "*RCT2"); model->current_title_sequence_preset = reader->GetCString("current_title_sequence", "*OPENRCT2"); + model->random_title_sequence = reader->GetBoolean("random_title_sequence", false); model->object_selection_filter_flags = reader->GetInt32("object_selection_filter_flags", 0x3FFF); model->scenarioselect_last_tab = reader->GetInt32("scenarioselect_last_tab", 0); } @@ -317,6 +318,7 @@ namespace Config writer->WriteBoolean("console_small_font", model->console_small_font); writer->WriteString("current_theme", model->current_theme_preset); writer->WriteString("current_title_sequence", model->current_title_sequence_preset); + writer->WriteBoolean("random_title_sequence", model->random_title_sequence); writer->WriteInt32("object_selection_filter_flags", model->object_selection_filter_flags); writer->WriteInt32("scenarioselect_last_tab", model->scenarioselect_last_tab); } diff --git a/src/openrct2/config/Config.h b/src/openrct2/config/Config.h index 9d5f6159fd..07fc42c67e 100644 --- a/src/openrct2/config/Config.h +++ b/src/openrct2/config/Config.h @@ -106,6 +106,7 @@ struct InterfaceConfiguration bool toolbar_show_mute; bool toolbar_show_chat; bool console_small_font; + bool random_title_sequence; utf8* current_theme_preset; utf8* current_title_sequence_preset; int32_t object_selection_filter_flags; diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 349191644d..7a22c49185 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3894,6 +3894,8 @@ enum STR_CANNOT_BUILD_PATH_ADDITIONS_ON_LEVEL_CROSSINGS = 6347, STR_REMOVE_LEVEL_CROSSING_FIRST = 6348, + STR_OPTIONS_RANDOM_TITLE_SEQUENCE = 6349, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 }; diff --git a/src/openrct2/title/TitleScreen.cpp b/src/openrct2/title/TitleScreen.cpp index 8643d5b48d..acb8f14e2a 100644 --- a/src/openrct2/title/TitleScreen.cpp +++ b/src/openrct2/title/TitleScreen.cpp @@ -27,6 +27,7 @@ #include "../scenario/Scenario.h" #include "../scenario/ScenarioRepository.h" #include "../ui/UiContext.h" +#include "../util/Util.h" #include "TitleSequence.h" #include "TitleSequenceManager.h" #include "TitleSequencePlayer.h" @@ -225,6 +226,62 @@ void TitleScreen::TitleInitialise() { _sequencePlayer = GetContext()->GetUiContext()->GetTitleSequencePlayer(); } + if (gConfigInterface.random_title_sequence) + { + bool RCT1Installed = false, RCT1AAInstalled = false, RCT1LLInstalled = false; + int RCT1Count = 0; + size_t scenarioCount = scenario_repository_get_count(); + + for (size_t s = 0; s < scenarioCount; s++) + { + if (scenario_repository_get_by_index(s)->source_game == SCENARIO_SOURCE_RCT1) + { + RCT1Count++; + } + if (scenario_repository_get_by_index(s)->source_game == SCENARIO_SOURCE_RCT1_AA) + { + RCT1AAInstalled = true; + } + if (scenario_repository_get_by_index(s)->source_game == SCENARIO_SOURCE_RCT1_LL) + { + RCT1LLInstalled = true; + } + } + + // Mega Park can show up in the scenario list even if RCT1 has been uninstalled, so it must be greater than 1 + if (RCT1Count > 1) + { + RCT1Installed = true; + } + + int32_t random = 0; + bool safeSequence = false; + std::string RCT1String = format_string(STR_TITLE_SEQUENCE_RCT1, gCommonFormatArgs); + std::string RCT1AAString = format_string(STR_TITLE_SEQUENCE_RCT1_AA, gCommonFormatArgs); + std::string RCT1LLString = format_string(STR_TITLE_SEQUENCE_RCT1_AA_LL, gCommonFormatArgs); + + // Ensure the random sequence chosen isn't from RCT1 or expansion if the player doesn't have it installed + while (!safeSequence) + { + size_t total = TitleSequenceManager::GetCount(); + random = util_rand() % (int32_t)total; + const utf8* scName = title_sequence_manager_get_name(random); + safeSequence = true; + if (scName == RCT1String) + { + safeSequence = RCT1Installed; + } + if (scName == RCT1AAString) + { + safeSequence = RCT1AAInstalled; + } + if (scName == RCT1LLString) + { + safeSequence = RCT1LLInstalled; + } + } + ChangePresetSequence(random); + } size_t seqId = title_get_config_sequence(); if (seqId == SIZE_MAX) {