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 e0b8ec7 commit f92ef8e
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(int 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 @@ -1133,9 +1133,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 @@ -1156,7 +1156,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 cause 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 @@ -310,13 +310,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 @@ -559,15 +559,30 @@ 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, cause 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 @@ -587,14 +602,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 @@ -411,12 +411,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 @@ -784,6 +790,7 @@ struct PadmapperOptions : OptionCategoryBase {
};

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

0 comments on commit f92ef8e

Please sign in to comment.