Browse Source

Options: Move Diablo/Hellfire option to StartUp and integrate in Settings Dialog

pull/3662/head
obligaron 4 years ago committed by Anders Jenbo
parent
commit
88ffa9f98a
  1. 9
      Source/DiabloUI/selstart.cpp
  2. 8
      Source/DiabloUI/settingsmenu.cpp
  3. 4
      Source/diablo.cpp
  4. 15
      Source/options.cpp
  5. 12
      Source/options.h

9
Source/DiabloUI/selstart.cpp

@ -17,9 +17,8 @@ Art artLogo;
void ItemSelected(int value)
{
auto option = static_cast<StartUpGameOption>(vecDialogItems[value]->m_value);
sgOptions.Hellfire.startUpGameOption = option;
gbIsHellfire = option == StartUpGameOption::Hellfire;
auto option = static_cast<StartUpGameMode>(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<UiImage>(&artLogo, rect, UiFlags::AlignCenter, /*bAnimated=*/true));
vecDialogItems.push_back(std::make_unique<UiListItem>(_("Enter Hellfire"), static_cast<int>(StartUpGameOption::Hellfire)));
vecDialogItems.push_back(std::make_unique<UiListItem>(_("Switch to Diablo"), static_cast<int>(StartUpGameOption::Diablo)));
vecDialogItems.push_back(std::make_unique<UiListItem>(_("Enter Hellfire"), static_cast<int>(StartUpGameMode::Hellfire)));
vecDialogItems.push_back(std::make_unique<UiListItem>(_("Switch to Diablo"), static_cast<int>(StartUpGameMode::Diablo)));
vecDialog.push_back(std::make_unique<UiList>(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);

8
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<UiScrollbar>(&ArtScrollBarBackground, &ArtScrollBarThumb, &ArtScrollBarArrow, MakeSdlRect(rectList.position.x + rectList.size.width + 5, rectList.position.y, 25, rectList.size.height)));
vecDialog.push_back(std::make_unique<UiArtText>(optionDescription, MakeSdlRect(rectDescription), UiFlags::FontSize12 | UiFlags::ColorUiSilverDark | UiFlags::AlignCenter, 1, IsSmallFontTall() ? 22 : 18));
if (diabdat_mpq && hellfire_mpq)
vecDialogItems.push_back(std::make_unique<UiListItem>(gbIsHellfire ? _("Switch to Diablo") : _("Switch to Hellfire"), static_cast<int>(SpecialMenuEntry::SwitchGame), UiFlags::ColorUiGold));
if (diabdat_mpq)
vecDialogItems.push_back(std::make_unique<UiListItem>(gbIsSpawn ? _("Switch to Fullgame") : _("Switch to Shareware"), static_cast<int>(SpecialMenuEntry::ToggleSpawn), UiFlags::ColorUiGold));

4
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

15
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<StartUpGameOption>(GetIniInt("Hellfire", "StartUpGameOption", static_cast<int>(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<int>(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<OptionEntryBase *> StartUpOptions::GetEntries()
{
return {
&gameMode,
&diabloIntro,
&hellfireIntro,
&splash,

12
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<OptionEntryBase *> GetEntries() override;
OptionEntryEnum<StartUpGameMode> gameMode;
/** @brief Play game intro video on diablo startup. */
OptionEntryEnum<StartUpIntro> 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 {

Loading…
Cancel
Save