diff --git a/Source/DiabloUI/selstart.cpp b/Source/DiabloUI/selstart.cpp index d2c5c2f99..30b177d1a 100644 --- a/Source/DiabloUI/selstart.cpp +++ b/Source/DiabloUI/selstart.cpp @@ -17,9 +17,8 @@ Art artLogo; void ItemSelected(int value) { - auto option = static_cast(vecDialogItems[value]->m_value); - sgOptions.Hellfire.startUpGameOption = option; - gbIsHellfire = option == StartUpGameOption::Hellfire; + auto option = static_cast(vecDialogItems[value]->m_value); + sgOptions.StartUp.gameMode.SetValue(option); endMenu = true; } @@ -40,8 +39,8 @@ void UiSelStartUpGameOption() SDL_Rect rect = { 0, (Sint16)(UI_OFFSET_Y), 0, 0 }; vecDialog.push_back(std::make_unique(&artLogo, rect, UiFlags::AlignCenter, /*bAnimated=*/true)); - vecDialogItems.push_back(std::make_unique(_("Enter Hellfire"), static_cast(StartUpGameOption::Hellfire))); - vecDialogItems.push_back(std::make_unique(_("Switch to Diablo"), static_cast(StartUpGameOption::Diablo))); + vecDialogItems.push_back(std::make_unique(_("Enter Hellfire"), static_cast(StartUpGameMode::Hellfire))); + vecDialogItems.push_back(std::make_unique(_("Switch to Diablo"), static_cast(StartUpGameMode::Diablo))); vecDialog.push_back(std::make_unique(vecDialogItems, vecDialogItems.size(), PANEL_LEFT + 64, (UI_OFFSET_Y + 240), 510, 43, UiFlags::AlignCenter | UiFlags::FontSize42 | UiFlags::ColorUiGold, 5)); UiInitList(nullptr, ItemSelected, EscPressed, vecDialog, true); diff --git a/Source/DiabloUI/settingsmenu.cpp b/Source/DiabloUI/settingsmenu.cpp index 4f22131ab..09c175a65 100644 --- a/Source/DiabloUI/settingsmenu.cpp +++ b/Source/DiabloUI/settingsmenu.cpp @@ -26,7 +26,6 @@ Rectangle rectDescription; enum class SpecialMenuEntry { None = -1, PreviousMenu = -2, - SwitchGame = -3, ToggleSpawn = -4, }; @@ -71,11 +70,6 @@ void ItemSelected(int value) case SpecialMenuEntry::PreviousMenu: endMenu = true; break; - case SpecialMenuEntry::SwitchGame: - gbIsHellfire = !gbIsHellfire; - endMenu = true; - recreateUI = true; - break; case SpecialMenuEntry::ToggleSpawn: gbIsSpawn = !gbIsSpawn; UiSetSpawned(gbIsSpawn); @@ -137,8 +131,6 @@ void UiSettingsMenu() vecDialog.push_back(std::make_unique(&ArtScrollBarBackground, &ArtScrollBarThumb, &ArtScrollBarArrow, MakeSdlRect(rectList.position.x + rectList.size.width + 5, rectList.position.y, 25, rectList.size.height))); vecDialog.push_back(std::make_unique(optionDescription, MakeSdlRect(rectDescription), UiFlags::FontSize12 | UiFlags::ColorUiSilverDark | UiFlags::AlignCenter, 1, IsSmallFontTall() ? 22 : 18)); - if (diabdat_mpq && hellfire_mpq) - vecDialogItems.push_back(std::make_unique(gbIsHellfire ? _("Switch to Diablo") : _("Switch to Hellfire"), static_cast(SpecialMenuEntry::SwitchGame), UiFlags::ColorUiGold)); if (diabdat_mpq) vecDialogItems.push_back(std::make_unique(gbIsSpawn ? _("Switch to Fullgame") : _("Switch to Shareware"), static_cast(SpecialMenuEntry::ToggleSpawn), UiFlags::ColorUiGold)); diff --git a/Source/diablo.cpp b/Source/diablo.cpp index c23d594a3..e9cab3288 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -916,7 +916,7 @@ void DiabloInit() if (forceSpawn) gbIsSpawn = true; - if (forceDiablo || sgOptions.Hellfire.startUpGameOption == StartUpGameOption::Diablo) + if (forceDiablo || *sgOptions.StartUp.gameMode == StartUpGameMode::Diablo) gbIsHellfire = false; if (forceHellfire) gbIsHellfire = true; @@ -944,7 +944,7 @@ void DiabloInit() ReadOnlyTest(); - if (gbIsHellfire && !forceHellfire && sgOptions.Hellfire.startUpGameOption == StartUpGameOption::None) { + if (gbIsHellfire && !forceHellfire && *sgOptions.StartUp.gameMode == StartUpGameMode::Ask) { UiSelStartUpGameOption(); if (!gbIsHellfire) { // Reinitalize the UI Elements cause we changed the game diff --git a/Source/options.cpp b/Source/options.cpp index 05e71d13e..80ec2cec1 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -242,6 +242,11 @@ void OptionLanguageCodeChanged() init_language_archives(); } +void OptionGameModeChanged() +{ + gbIsHellfire = *sgOptions.StartUp.gameMode == StartUpGameMode::Hellfire; +} + } // namespace void SetIniValue(const char *sectionName, const char *keyName, const char *value, int len) @@ -279,7 +284,6 @@ void LoadOptions() sgOptions.Diablo.lastMultiplayerHero = GetIniInt("Diablo", "LastMultiplayerHero", 0); sgOptions.Hellfire.lastSinglePlayerHero = GetIniInt("Hellfire", "LastSinglePlayerHero", 0); sgOptions.Hellfire.lastMultiplayerHero = GetIniInt("Hellfire", "LastMultiplayerHero", 0); - sgOptions.Hellfire.startUpGameOption = static_cast(GetIniInt("Hellfire", "StartUpGameOption", static_cast(StartUpGameOption::None))); GetIniValue("Hellfire", "SItem", sgOptions.Hellfire.szItem, sizeof(sgOptions.Hellfire.szItem), ""); sgOptions.Audio.nSoundVolume = GetIniInt("Audio", "Sound Volume", VOLUME_MAX); @@ -350,7 +354,6 @@ void SaveOptions() SetIniValue("Hellfire", "SItem", sgOptions.Hellfire.szItem); SetIniValue("Hellfire", "LastSinglePlayerHero", sgOptions.Hellfire.lastSinglePlayerHero); SetIniValue("Hellfire", "LastMultiplayerHero", sgOptions.Hellfire.lastMultiplayerHero); - SetIniValue("Hellfire", "StartUpGameOption", static_cast(sgOptions.Hellfire.startUpGameOption)); SetIniValue("Audio", "Sound Volume", sgOptions.Audio.nSoundVolume); SetIniValue("Audio", "Music Volume", sgOptions.Audio.nMusicVolume); @@ -512,6 +515,12 @@ string_view OptionCategoryBase::GetDescription() const StartUpOptions::StartUpOptions() : OptionCategoryBase("StartUp", N_("Start Up"), N_("Start Up Settings")) + , gameMode("Game", OptionEntryFlags::NeedHellfireMpq | OptionEntryFlags::RecreateUI, N_("Game Mode"), N_("Play Diablo or Hellfire."), StartUpGameMode::Ask, + { + { StartUpGameMode::Diablo, N_("Diablo") }, + // Ask is missing, cause we want to hide it from UI-Settings. + { StartUpGameMode::Hellfire, N_("Hellfire") }, + }) , diabloIntro("Diablo Intro", OptionEntryFlags::OnlyDiablo, N_("Intro"), N_("Shown Intro cinematic."), StartUpIntro::Once, { { StartUpIntro::Off, N_("OFF") }, @@ -531,10 +540,12 @@ StartUpOptions::StartUpOptions() { StartUpSplash::None, N_("None") }, }) { + gameMode.SetValueChangedCallback(OptionGameModeChanged); } std::vector StartUpOptions::GetEntries() { return { + &gameMode, &diabloIntro, &hellfireIntro, &splash, diff --git a/Source/options.h b/Source/options.h index d2d1a273f..26f341e1f 100644 --- a/Source/options.h +++ b/Source/options.h @@ -10,10 +10,11 @@ namespace devilution { -enum class StartUpGameOption { - None, - Hellfire, - Diablo, +enum class StartUpGameMode { + /** @brief If hellfire is present, asks the user what game he wants to start. */ + Ask = 0, + Hellfire = 1, + Diablo = 2, }; enum class StartUpIntro { @@ -234,6 +235,7 @@ struct StartUpOptions : OptionCategoryBase { StartUpOptions(); std::vector GetEntries() override; + OptionEntryEnum gameMode; /** @brief Play game intro video on diablo startup. */ OptionEntryEnum diabloIntro; /** @brief Play game intro video on hellfire startup. */ @@ -261,8 +263,6 @@ struct HellfireOptions : OptionCategoryBase { std::uint32_t lastSinglePlayerHero; /** @brief Remembers what multiplayer hero/save was last used. */ std::uint32_t lastMultiplayerHero; - - StartUpGameOption startUpGameOption; }; struct AudioOptions : OptionCategoryBase {