Skip to content

Commit

Permalink
Move Game Mode to own category
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 authored and AJenbo committed Nov 30, 2024
1 parent f20c6bf commit 8d1fb2b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Source/DiabloUI/selstart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ std::vector<std::unique_ptr<UiItemBase>> vecDialog;
void ItemSelected(size_t value)
{
auto option = static_cast<StartUpGameMode>(vecDialogItems[value]->m_value);
sgOptions.StartUp.gameMode.SetValue(option);
sgOptions.GameMode.gameMode.SetValue(option);
SaveOptions();
endMenu = true;
}
Expand Down
6 changes: 3 additions & 3 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
27 changes: 19 additions & 8 deletions Source/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -450,15 +450,30 @@ 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") },
// Ask is missing, because we want to hide it from UI-Settings.
{ 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<OptionEntryBase *> 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") },
Expand All @@ -478,14 +493,10 @@ StartUpOptions::StartUpOptions()
{ StartUpSplash::None, N_("None") },
})
{
gameMode.SetValueChangedCallback(OptionGameModeChanged);
shareware.SetValueChangedCallback(OptionSharewareChanged);
}
std::vector<OptionEntryBase *> StartUpOptions::GetEntries()
{
return {
&gameMode,
&shareware,
&diabloIntro,
&hellfireIntro,
&splash,
Expand Down
12 changes: 10 additions & 2 deletions Source/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,18 @@ struct OptionCategoryBase {
const char *description;
};

struct StartUpOptions : OptionCategoryBase {
StartUpOptions();
struct GameModeOptions : OptionCategoryBase {
GameModeOptions();
std::vector<OptionEntryBase *> GetEntries() override;

OptionEntryEnum<StartUpGameMode> gameMode;
OptionEntryBoolean shareware;
};

struct StartUpOptions : OptionCategoryBase {
StartUpOptions();
std::vector<OptionEntryBase *> GetEntries() override;

/** @brief Play game intro video on diablo startup. */
OptionEntryEnum<StartUpIntro> diabloIntro;
/** @brief Play game intro video on hellfire startup. */
Expand Down Expand Up @@ -798,6 +804,7 @@ struct PadmapperOptions : OptionCategoryBase {
};

struct Options {
GameModeOptions GameMode;
StartUpOptions StartUp;
DiabloOptions Diablo;
HellfireOptions Hellfire;
Expand All @@ -815,6 +822,7 @@ struct Options {
{
return {
&Language,
&GameMode,
&StartUp,
&Graphics,
&Audio,
Expand Down

0 comments on commit 8d1fb2b

Please sign in to comment.