From af8dc6995d607b2d1214996df4460e569c22ebf4 Mon Sep 17 00:00:00 2001 From: EmeraldLockdown <86802223+EmeraldLoc@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:15:04 -0500 Subject: [PATCH] Allow user to change music in menu (#212) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Allow user to change music in menu * Remove annoying newline * Fully reset menu * No need for sSoundBox * Add music to castle grounds * Add translations * oops * Why did that not save!! * Update lang/Polish.ini Co-authored-by: Radek Krzyśków <46760021+Flower35@users.noreply.github.com> * Update lang/Czech.ini Co-authored-by: Radek Krzyśków <46760021+Flower35@users.noreply.github.com> * Update lang/Russian.ini Co-authored-by: Radek Krzyśków <46760021+Flower35@users.noreply.github.com> --------- Co-authored-by: Radek Krzyśków <46760021+Flower35@users.noreply.github.com> --- lang/Czech.ini | 2 +- lang/Dutch.ini | 2 +- lang/English.ini | 2 +- lang/French.ini | 2 +- lang/German.ini | 2 +- lang/Italian.ini | 2 +- lang/Polish.ini | 2 +- lang/Portuguese.ini | 2 +- lang/Russian.ini | 2 +- lang/Spanish.ini | 2 +- src/game/level_update.c | 22 ++++++---- src/pc/configfile.c | 4 +- src/pc/configfile.h | 2 +- src/pc/djui/djui_panel_menu_options.c | 58 +++++++++++++++++++++++---- src/pc/djui/djui_panel_menu_options.h | 9 +++++ 15 files changed, 87 insertions(+), 28 deletions(-) diff --git a/lang/Czech.ini b/lang/Czech.ini index ac3cd95fe..8152c4e42 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -260,7 +260,7 @@ QUIT = "Opustit hru" MENU_TITLE = "MENU" LEVEL = "Level" STAFF_ROLL = "Závěrečné titulky" -USE_STAGE_MUSIC = "Použít písničku z levelu" +MUSIC = "Písnička" RANDOM_STAGE = "Náhodný level" PLAY_VANILLA_DEMOS = "Přehrát dema" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index 48b09b8e1..2096c5c00 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -260,7 +260,7 @@ QUIT = "Stop" MENU_TITLE = "MENU" LEVEL = "Level" STAFF_ROLL = "Personeelsoverzicht" -USE_STAGE_MUSIC = "Gebruik level muziek" +MUSIC = "Muziek" RANDOM_STAGE = "Willekeurig level" PLAY_VANILLA_DEMOS = "Speel normale demos af" diff --git a/lang/English.ini b/lang/English.ini index 01b6bc872..146294cdf 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -260,7 +260,7 @@ QUIT = "Quit" MENU_TITLE = "MENU" LEVEL = "Level" STAFF_ROLL = "Staff Roll" -USE_STAGE_MUSIC = "Use Stage Music" +MUSIC = "Music" RANDOM_STAGE = "Random Stage" PLAY_VANILLA_DEMOS = "Play Vanilla Demos" diff --git a/lang/French.ini b/lang/French.ini index e29c207a2..edbf1751a 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -260,7 +260,7 @@ QUIT = "Quitter" MENU_TITLE = "MENU" LEVEL = "Niveau" STAFF_ROLL = "Générique de fin" -USE_STAGE_MUSIC = "Utiliser la musique du niveau" +MUSIC = "Musique" RANDOM_STAGE = "Niveau aléatoire" PLAY_VANILLA_DEMOS = "Jouer les démos" diff --git a/lang/German.ini b/lang/German.ini index 01152f04a..2d33dd95d 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -260,7 +260,7 @@ QUIT = "Beenden" MENU_TITLE = "MENÜ" LEVEL = "Level" STAFF_ROLL = "Abspann" -USE_STAGE_MUSIC = "Stufenmusik verwenden" +MUSIC = "Musik" RANDOM_STAGE = "Zufälliger Level" PLAY_VANILLA_DEMOS = "Original-Demos spielen" diff --git a/lang/Italian.ini b/lang/Italian.ini index 84995d7fa..3c2f921b9 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -258,7 +258,7 @@ QUIT = "Abbandona" MENU_TITLE = "MENÙ" LEVEL = "Livello" STAFF_ROLL = "Staff dei titoli di coda" -USE_STAGE_MUSIC = "Usa la musica del livello" +MUSIC = "Musica" RANDOM_STAGE = "Livello casuale" PLAY_VANILLA_DEMOS = "Riproduci le demo di gioco" diff --git a/lang/Polish.ini b/lang/Polish.ini index 3c8b999bd..75c7475ae 100644 --- a/lang/Polish.ini +++ b/lang/Polish.ini @@ -260,7 +260,7 @@ QUIT = "Wyjdź" MENU_TITLE = "MENU" LEVEL = "Poziom" STAFF_ROLL = "Napisy Końcowe" -USE_STAGE_MUSIC = "Użyj Muzyki z Poziomu" +MUSIC = "Muzyka" RANDOM_STAGE = "Losowy Poziom" PLAY_VANILLA_DEMOS = "Odtwarzaj Domyślne Dema" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index e756ea231..38d1d7614 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -260,7 +260,7 @@ QUIT = "Sair" MENU_TITLE = "MENU" LEVEL = "Nível" STAFF_ROLL = "Créditos finais" -USE_STAGE_MUSIC = "Usar música do nível" +MUSIC = "Música" RANDOM_STAGE = "Nível aleatório" PLAY_VANILLA_DEMOS = "Tocar demos originais" diff --git a/lang/Russian.ini b/lang/Russian.ini index f03f4759b..71976fc1d 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -259,7 +259,7 @@ QUIT = "Выход" MENU_TITLE = "MENU" LEVEL = "Уровень" STAFF_ROLL = "Завершение" -USE_STAGE_MUSIC = "Использовать музыку уровня" +MUSIC = "Музыка" RANDOM_STAGE = "Случайный уровень" PLAY_VANILLA_DEMOS = "Воспроизведение демо уровня" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index 90f9fc7d5..153785b6a 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -260,7 +260,7 @@ QUIT = "Salir" MENU_TITLE = "MENÚ" LEVEL = "Nivel" STAFF_ROLL = "Créditos Finales" -USE_STAGE_MUSIC = "Usar música del nivel" +MUSIC = "Música" RANDOM_STAGE = "Nivel aleatorio" PLAY_VANILLA_DEMOS = "Demos originales" diff --git a/src/game/level_update.c b/src/game/level_update.c index 5f44367f6..14f5a948b 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -41,6 +41,8 @@ #include "pc/configfile.h" #include "pc/network/network.h" #include "pc/djui/djui.h" +// used for getting gMainMenuSounds +#include "pc/djui/djui_panel_menu_options.h" #include "pc/lua/smlua_hooks.h" #include "pc/mods/mods.h" #include "pc/nametags.h" @@ -1491,16 +1493,20 @@ void update_menu_level(void) { // figure out music stop_cap_music(); - if (!configMenuSound || configMenuStaffRoll || curLevel == LEVEL_CASTLE_GROUNDS) { - reset_volume(); - disable_background_sound(); - set_background_music(0, SEQ_MENU_TITLE_SCREEN, 0); - } else { - reset_volume(); - disable_background_sound(); - if (gCurrentArea != NULL) { + reset_volume(); + disable_background_sound(); + if (gMainMenuSounds[configMenuSound].sound == STAGE_MUSIC) { + // if staff roll is on, set configMenuSound to Title Screen sequence, or 0 + if (configMenuStaffRoll) { + configMenuSound = 0; + } + if (curLevel == LEVEL_CASTLE_GROUNDS) { + set_background_music(0, SEQ_MENU_FILE_SELECT, 0); + } else if (gCurrentArea != NULL) { set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0); } + } else { + set_background_music(0, gMainMenuSounds[configMenuSound].sound, 0); } if (configMenuStaffRoll) { diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 27e19b945..df52a2aef 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -167,7 +167,7 @@ bool configSkipIntro = 0; bool configPauseAnywhere = false; bool configMenuStaffRoll = false; unsigned int configMenuLevel = 0; -bool configMenuSound = false; +unsigned int configMenuSound = 0; bool configMenuRandom = false; bool configMenuDemos = false; bool configDisablePopups = false; @@ -297,7 +297,7 @@ static const struct ConfigOption options[] = { {.name = "pause_anywhere", .type = CONFIG_TYPE_BOOL, .boolValue = &configPauseAnywhere}, {.name = "coop_menu_staff_roll", .type = CONFIG_TYPE_BOOL, .boolValue = &configMenuStaffRoll}, {.name = "coop_menu_level", .type = CONFIG_TYPE_UINT, .uintValue = &configMenuLevel}, - {.name = "coop_menu_sound", .type = CONFIG_TYPE_BOOL, .boolValue = &configMenuSound}, + {.name = "coop_menu_sound", .type = CONFIG_TYPE_UINT, .uintValue = &configMenuSound}, {.name = "coop_menu_random", .type = CONFIG_TYPE_BOOL, .boolValue = &configMenuRandom}, // {.name = "coop_menu_demos", .type = CONFIG_TYPE_BOOL, .boolValue = &configMenuDemos}, {.name = "disable_popups", .type = CONFIG_TYPE_BOOL, .boolValue = &configDisablePopups}, diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 161196841..642f47e58 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -117,7 +117,7 @@ extern bool configSkipIntro; extern bool configPauseAnywhere; extern bool configMenuStaffRoll; extern unsigned int configMenuLevel; -extern bool configMenuSound; +extern unsigned int configMenuSound; extern bool configMenuRandom; extern bool configMenuDemos; extern bool configDisablePopups; diff --git a/src/pc/djui/djui_panel_menu_options.c b/src/pc/djui/djui_panel_menu_options.c index 0808cac94..3495f77f6 100644 --- a/src/pc/djui/djui_panel_menu_options.c +++ b/src/pc/djui/djui_panel_menu_options.c @@ -6,21 +6,38 @@ #include "djui_panel_options.h" #include "djui_panel_misc.h" #include "djui_panel_pause.h" +#include "djui_panel_menu_options.h" #include "djui_hud_utils.h" #include "pc/utils/misc.h" #include "pc/configfile.h" #include "game/level_update.h" +#include "seq_ids.h" static struct DjuiSelectionbox* sLevelBox = NULL; -static struct DjuiCheckbox* sUseStageMusicCheckbox = NULL; static struct DjuiCheckbox* sRandomStageCheckbox = NULL; // static struct DjuiCheckbox* sVanillaDemosCheckbox = NULL; +struct MainMenuSounds gMainMenuSounds[] = { + { "Title Screen", SEQ_MENU_TITLE_SCREEN }, + { "File Select", SEQ_MENU_FILE_SELECT }, + { "Grass", SEQ_LEVEL_GRASS }, + { "Water", SEQ_LEVEL_WATER }, + { "Snow", SEQ_LEVEL_SNOW }, + { "Slide", SEQ_LEVEL_SLIDE }, + { "Bowser Stage", SEQ_LEVEL_KOOPA_ROAD }, + { "Bowser Fight", SEQ_LEVEL_BOSS_KOOPA }, + { "Spooky", SEQ_LEVEL_SPOOKY }, + { "Hot", SEQ_LEVEL_HOT }, + { "Underground", SEQ_LEVEL_UNDERGROUND }, + { "Bowser Finale", SEQ_LEVEL_BOSS_KOOPA_FINAL }, + { "Staff Roll", SEQ_EVENT_CUTSCENE_CREDITS }, + { "Stage Music", STAGE_MUSIC }, +}; + void djui_panel_main_menu_create(struct DjuiBase* caller); static void djui_panel_level_menu(UNUSED struct DjuiBase* caller) { djui_base_set_enabled(&sLevelBox->base, !(configMenuRandom || configMenuStaffRoll)); - djui_base_set_enabled(&sUseStageMusicCheckbox->base, !configMenuStaffRoll); djui_base_set_enabled(&sRandomStageCheckbox->base, !configMenuStaffRoll); // djui_base_set_enabled(&sVanillaDemosCheckbox->base, !configMenuStaffRoll); if (configMenuStaffRoll) { @@ -29,6 +46,22 @@ static void djui_panel_level_menu(UNUSED struct DjuiBase* caller) { } } +static void djui_panel_staff_roll(UNUSED struct DjuiBase* caller) { + // update level + djui_panel_level_menu(NULL); + // change menu sound + if (configMenuStaffRoll && gMainMenuSounds[configMenuSound].sound == STAGE_MUSIC) { + configMenuSound = 0; + } + // restart djui back to this menu + djui_panel_shutdown(); + gDjuiInMainMenu = true; + djui_panel_main_create(NULL); + djui_panel_options_create(NULL); + djui_panel_misc_create(NULL); + djui_panel_main_menu_create(NULL); +} + static void djui_panel_menu_options_djui_setting_change(UNUSED struct DjuiBase* caller) { if (gDjuiInMainMenu) { djui_panel_shutdown(); @@ -68,6 +101,7 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_FONT), djuiFontChoices, 2, &configDjuiThemeFont, djui_panel_menu_options_djui_setting_change); if (gDjuiInMainMenu) { + // get level choices char* levelChoices[18] = { "CG", "BOB", @@ -89,14 +123,24 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { "WDW" }; + // copy sound choices from gMainMenuSounds + int numSounds = sizeof(gMainMenuSounds) / sizeof(gMainMenuSounds[0]); + // if stage roll is on, we shouldn't be allowed to use Stage Music, so remove the entry + if (configMenuStaffRoll) { + numSounds -= 1; + } + char* soundChoices[sizeof(gMainMenuSounds)]; + + // loop thru all sounds names, and add those to the soundChoices string array + for (int i = 0; i < numSounds; i++) { + soundChoices[i] = gMainMenuSounds[i].name; + } + struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(body, DLANG(MENU_OPTIONS, LEVEL), levelChoices, 18, &configMenuLevel, NULL); djui_base_set_enabled(&selectionbox1->base, !(configMenuRandom || configMenuStaffRoll)); sLevelBox = selectionbox1; - - djui_checkbox_create(body, DLANG(MENU_OPTIONS, STAFF_ROLL), &configMenuStaffRoll, djui_panel_level_menu); - struct DjuiCheckbox* checkbox1 = djui_checkbox_create(body, DLANG(MENU_OPTIONS, USE_STAGE_MUSIC), &configMenuSound, NULL); - djui_base_set_enabled(&checkbox1->base, !configMenuStaffRoll); - sUseStageMusicCheckbox = checkbox1; + djui_selectionbox_create(body, DLANG(MENU_OPTIONS, MUSIC), soundChoices, numSounds, &configMenuSound, NULL); + djui_checkbox_create(body, DLANG(MENU_OPTIONS, STAFF_ROLL), &configMenuStaffRoll, djui_panel_staff_roll); struct DjuiCheckbox* checkbox2 = djui_checkbox_create(body, DLANG(MENU_OPTIONS, RANDOM_STAGE), &configMenuRandom, djui_panel_level_menu); djui_base_set_enabled(&checkbox2->base, !configMenuStaffRoll); sRandomStageCheckbox = checkbox2; diff --git a/src/pc/djui/djui_panel_menu_options.h b/src/pc/djui/djui_panel_menu_options.h index 497825ea8..788d9b4e4 100644 --- a/src/pc/djui/djui_panel_menu_options.h +++ b/src/pc/djui/djui_panel_menu_options.h @@ -1,4 +1,13 @@ #pragma once #include "djui.h" +#define STAGE_MUSIC 0 + +struct MainMenuSounds { + char* name; + int sound; +}; + +extern struct MainMenuSounds gMainMenuSounds[]; + void djui_panel_main_menu_create(struct DjuiBase* caller);