From 8d1fb2bd63a59a55b13dc43849a96284b439aec8 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 23 Aug 2024 17:20:38 -0400 Subject: [PATCH] Move Game Mode to own category --- Source/DiabloUI/selstart.cpp | 2 +- Source/diablo.cpp | 6 +++--- Source/options.cpp | 27 +++++++++++++++++++-------- Source/options.h | 12 ++++++++++-- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Source/DiabloUI/selstart.cpp b/Source/DiabloUI/selstart.cpp index 89e5e2220..09540aa9f 100644 --- a/Source/DiabloUI/selstart.cpp +++ b/Source/DiabloUI/selstart.cpp @@ -18,7 +18,7 @@ std::vector> vecDialog; void ItemSelected(size_t value) { auto option = static_cast(vecDialogItems[value]->m_value); - sgOptions.StartUp.gameMode.SetValue(option); + sgOptions.GameMode.gameMode.SetValue(option); SaveOptions(); endMenu = true; } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index ea8ad252d..8937e9cc8 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1176,9 +1176,9 @@ void ApplicationInit() void DiabloInit() { - if (forceSpawn || *sgOptions.StartUp.shareware) + if (forceSpawn || *sgOptions.GameMode.shareware) gbIsSpawn = true; - if (forceDiablo || *sgOptions.StartUp.gameMode == StartUpGameMode::Diablo) + if (forceDiablo || *sgOptions.GameMode.gameMode == StartUpGameMode::Diablo) gbIsHellfire = false; if (forceHellfire) gbIsHellfire = true; @@ -1199,7 +1199,7 @@ void DiabloInit() UiInitialize(); was_ui_init = true; - if (gbIsHellfire && !forceHellfire && *sgOptions.StartUp.gameMode == StartUpGameMode::Ask) { + if (gbIsHellfire && !forceHellfire && *sgOptions.GameMode.gameMode == StartUpGameMode::Ask) { UiSelStartUpGameOption(); if (!gbIsHellfire) { // Reinitialize the UI Elements because we changed the game diff --git a/Source/options.cpp b/Source/options.cpp index 8ef40efc1..c1a095e07 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -194,13 +194,13 @@ void OptionLanguageCodeChanged() void OptionGameModeChanged() { - gbIsHellfire = *sgOptions.StartUp.gameMode == StartUpGameMode::Hellfire; + gbIsHellfire = *sgOptions.GameMode.gameMode == StartUpGameMode::Hellfire; discord_manager::UpdateMenu(true); } void OptionSharewareChanged() { - gbIsSpawn = *sgOptions.StartUp.shareware; + gbIsSpawn = *sgOptions.GameMode.shareware; } void OptionAudioChanged() @@ -450,8 +450,8 @@ std::string_view OptionCategoryBase::GetDescription() const return _(description); } -StartUpOptions::StartUpOptions() - : OptionCategoryBase("StartUp", N_("Start Up"), N_("Start Up Settings")) +GameModeOptions::GameModeOptions() + : OptionCategoryBase("GameMode", N_("Game Mode"), N_("Game Mode Settings")) , gameMode("Game", OptionEntryFlags::NeedHellfireMpq | OptionEntryFlags::RecreateUI, N_("Game Mode"), N_("Play Diablo or Hellfire."), StartUpGameMode::Ask, { { StartUpGameMode::Diablo, N_("Diablo") }, @@ -459,6 +459,21 @@ StartUpOptions::StartUpOptions() { StartUpGameMode::Hellfire, N_("Hellfire") }, }) , shareware("Shareware", OptionEntryFlags::NeedDiabloMpq | OptionEntryFlags::RecreateUI, N_("Restrict to Shareware"), N_("Makes the game compatible with the demo. Enables multiplayer with friends who don't own a full copy of Diablo."), false) + +{ + gameMode.SetValueChangedCallback(OptionGameModeChanged); + shareware.SetValueChangedCallback(OptionSharewareChanged); +} +std::vector GameModeOptions::GetEntries() +{ + return { + &gameMode, + &shareware, + }; +} + +StartUpOptions::StartUpOptions() + : OptionCategoryBase("StartUp", N_("Start Up"), N_("Start Up Settings")) , diabloIntro("Diablo Intro", OptionEntryFlags::OnlyDiablo, N_("Intro"), N_("Shown Intro cinematic."), StartUpIntro::Once, { { StartUpIntro::Off, N_("OFF") }, @@ -478,14 +493,10 @@ StartUpOptions::StartUpOptions() { StartUpSplash::None, N_("None") }, }) { - gameMode.SetValueChangedCallback(OptionGameModeChanged); - shareware.SetValueChangedCallback(OptionSharewareChanged); } std::vector StartUpOptions::GetEntries() { return { - &gameMode, - &shareware, &diabloIntro, &hellfireIntro, &splash, diff --git a/Source/options.h b/Source/options.h index e1af62395..f365b50ca 100644 --- a/Source/options.h +++ b/Source/options.h @@ -412,12 +412,18 @@ protected: const char *description; }; -struct StartUpOptions : OptionCategoryBase { - StartUpOptions(); +struct GameModeOptions : OptionCategoryBase { + GameModeOptions(); std::vector GetEntries() override; OptionEntryEnum gameMode; OptionEntryBoolean shareware; +}; + +struct StartUpOptions : OptionCategoryBase { + StartUpOptions(); + std::vector GetEntries() override; + /** @brief Play game intro video on diablo startup. */ OptionEntryEnum diabloIntro; /** @brief Play game intro video on hellfire startup. */ @@ -798,6 +804,7 @@ private: }; struct Options { + GameModeOptions GameMode; StartUpOptions StartUp; DiabloOptions Diablo; HellfireOptions Hellfire; @@ -815,6 +822,7 @@ struct Options { { return { &Language, + &GameMode, &StartUp, &Graphics, &Audio,