From b49676a887c8c8a47360eeef1a65a150fb5ee0bc Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Mon, 11 May 2015 13:17:33 -0400 Subject: [PATCH] Added option for random title music in main menu Added STR_5126 to UK and US languages rand() is seeded in rct2_init() --- data/language/english_uk.txt | 1 + data/language/english_us.txt | 1 + src/audio/audio.c | 6 ++++++ src/rct2.c | 1 + src/windows/options.c | 11 +++++++---- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index 2d1928bf82..ce12abf832 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3459,3 +3459,4 @@ STR_5122 :Show all vehicles sharing a track/ride type STR_5123 :Renew rides STR_5124 :No Six Flags STR_5125 :All destructable +STR_5126 :Random title music diff --git a/data/language/english_us.txt b/data/language/english_us.txt index 12ee4e49d1..06889b26a8 100644 --- a/data/language/english_us.txt +++ b/data/language/english_us.txt @@ -3471,3 +3471,4 @@ STR_5122 :Show all vehicles sharing a track/ride type STR_5123 :Renew rides STR_5124 :No Six Flags STR_5125 :All destructable +STR_5126 :Random title music diff --git a/src/audio/audio.c b/src/audio/audio.c index f562678469..9dc0bb10c8 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -1549,6 +1549,12 @@ void start_title_music() case 2: musicPathId = PATH_ID_CSS17; break; + case 3: + if (rand() & 1) + musicPathId = PATH_ID_CSS50; + else + musicPathId = PATH_ID_CSS17; + break; } if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) && RCT2_GLOBAL(0x009AF59D, uint8) & 1 diff --git a/src/rct2.c b/src/rct2.c index 0221d9ecdf..f70848a2a7 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -72,6 +72,7 @@ int rct2_init() RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) = 0; RCT2_GLOBAL(0x009AC310, char*) = RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, char*); get_system_time(); + srand(time(0)); RCT2_GLOBAL(0x009DEA69, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, short); RCT2_GLOBAL(0x009DEA6B, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MONTH, short); if (!rct2_init_directories()) diff --git a/src/windows/options.c b/src/windows/options.c index a4301b0619..473bbc9eda 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -396,12 +396,15 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget* gDropdownItemsChecked = gConfigGeneral.show_height_as_units ? 1 : 2; break; case WIDX_TITLE_MUSIC_DROPDOWN: - num_items = 3; + num_items = 4; - for (i = 0; i < num_items; i++) { + for (i = 0; i < num_items - 1; i++) { gDropdownItemsFormat[i] = 1142; gDropdownItemsArgs[i] = 2739 + i; } + // Random title music + gDropdownItemsFormat[3] = 1142; + gDropdownItemsArgs[3] = 5126; window_options_show_dropdown(w, widget, num_items); @@ -556,7 +559,7 @@ static void window_options_dropdown() window_options_update_height_markers(); break; case WIDX_TITLE_MUSIC_DROPDOWN: - if (dropdownIndex == 1 && !platform_file_exists(get_file_path(PATH_ID_CSS50))) { + if ((dropdownIndex == 1 || dropdownIndex == 3) && !platform_file_exists(get_file_path(PATH_ID_CSS50))) { window_error_open(2742, 2743); } else { gConfigSound.title_music = (sint8)dropdownIndex; @@ -837,7 +840,7 @@ static void window_options_paint() gfx_draw_string_left(dpi, 2738, w, 12, w->x + 10, w->y + window_options_widgets[WIDX_TITLE_MUSIC].top + 1); gfx_draw_string_left( dpi, - 2739 + gConfigSound.title_music, + (gConfigSound.title_music == 3 ? 5126 : 2739 + gConfigSound.title_music), NULL, 12, w->x + window_options_widgets[WIDX_TITLE_MUSIC].left + 1,