Browse Source

Add all (boolean) Game Settings to Settingsmenu (#3616)

pull/3620/head
obligaron 4 years ago committed by GitHub
parent
commit
ff5de056fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      Source/inv.cpp
  2. 4
      Source/monster.cpp
  3. 2
      Source/objects.cpp
  4. 62
      Source/options.cpp
  5. 26
      Source/options.h
  6. 2
      Source/qol/autopickup.cpp
  7. 6
      Source/qol/monhealthbar.cpp
  8. 2
      Source/quests.cpp
  9. 2
      Source/stores.cpp

12
Source/inv.cpp

@ -1387,23 +1387,23 @@ bool AutoEquipEnabled(const Player &player, const Item &item)
if (item.isWeapon()) {
// Monk can use unarmed attack as an encouraged option, thus we do not automatically equip weapons on him so as to not
// annoy players who prefer that playstyle.
return player._pClass != HeroClass::Monk && sgOptions.Gameplay.bAutoEquipWeapons;
return player._pClass != HeroClass::Monk && *sgOptions.Gameplay.autoEquipWeapons;
}
if (item.isArmor()) {
return sgOptions.Gameplay.bAutoEquipArmor;
return *sgOptions.Gameplay.autoEquipArmor;
}
if (item.isHelm()) {
return sgOptions.Gameplay.bAutoEquipHelms;
return *sgOptions.Gameplay.autoEquipHelms;
}
if (item.isShield()) {
return sgOptions.Gameplay.bAutoEquipShields;
return *sgOptions.Gameplay.autoEquipShields;
}
if (item.isJewelry()) {
return sgOptions.Gameplay.bAutoEquipJewelry;
return *sgOptions.Gameplay.autoEquipJewelry;
}
return true;
@ -2080,7 +2080,7 @@ bool UseInvItem(int pnum, int cii)
speedlist = true;
// If selected speedlist item exists in InvList, use the InvList item.
for (int i = 0; i < player._pNumInv && sgOptions.Gameplay.bAutoRefillBelt; i++) {
for (int i = 0; i < player._pNumInv && *sgOptions.Gameplay.autoRefillBelt; i++) {
if (player.InvList[i]._iMiscId == item->_iMiscId && player.InvList[i]._iSpell == item->_iSpell) {
c = i;
item = &player.InvList[c];

4
Source/monster.cpp

@ -4608,7 +4608,7 @@ void M_FallenFear(Point position)
void PrintMonstHistory(int mt)
{
if (sgOptions.Gameplay.bShowMonsterType) {
if (*sgOptions.Gameplay.showMonsterType) {
strcpy(tempstr, fmt::format(_("Type: {:s} Kills: {:d}"), GetMonsterTypeText(MonstersData[mt]), MonsterKillCounts[mt]).c_str());
} else {
strcpy(tempstr, fmt::format(_("Total kills: {:d}"), MonsterKillCounts[mt]).c_str());
@ -4684,7 +4684,7 @@ void PrintMonstHistory(int mt)
void PrintUniqueHistory()
{
auto &monster = Monsters[pcursmonst];
if (sgOptions.Gameplay.bShowMonsterType) {
if (*sgOptions.Gameplay.showMonsterType) {
strcpy(tempstr, fmt::format(_("Type: {:s}"), GetMonsterTypeText(*monster.MData)).c_str());
AddPanelString(tempstr);
}

2
Source/objects.cpp

@ -4338,7 +4338,7 @@ unsigned int Object::GetId() const
bool Object::IsDisabled() const
{
if (!sgOptions.Gameplay.bDisableCripplingShrines) {
if (!*sgOptions.Gameplay.disableCripplingShrines) {
return false;
}
if (IsAnyOf(_otype, _object_id::OBJ_GOATSHRINE, _object_id::OBJ_CAULDRON)) {

62
Source/options.cpp

@ -28,6 +28,7 @@
#include "diablo.h"
#include "engine/demomode.h"
#include "options.h"
#include "qol/monhealthbar.h"
#include "qol/xpbar.h"
#include "utils/file_util.h"
#include "utils/language.h"
@ -210,6 +211,16 @@ void OptionExperienceBarChanged()
FreeXPBar();
}
void OptionEnemyHealthBarChanged()
{
if (!gbRunGame)
return;
if (*sgOptions.Gameplay.enemyHealthBar)
InitMonsterHealthBar();
else
FreeMonsterHealthBar();
}
} // namespace
void SetIniValue(const char *sectionName, const char *keyName, const char *value, int len)
@ -285,18 +296,6 @@ void LoadOptions()
sgOptions.Graphics.bShowFPS = (GetIniInt("Graphics", "Show FPS", 0) != 0);
sgOptions.Gameplay.nTickRate = GetIniInt("Game", "Speed", 20);
sgOptions.Gameplay.bEnemyHealthBar = GetIniBool("Game", "Enemy Health Bar", false);
sgOptions.Gameplay.bAutoGoldPickup = GetIniBool("Game", "Auto Gold Pickup", AUTO_PICKUP_DEFAULT(false));
sgOptions.Gameplay.bAdriaRefillsMana = GetIniBool("Game", "Adria Refills Mana", false);
sgOptions.Gameplay.bAutoEquipWeapons = GetIniBool("Game", "Auto Equip Weapons", true);
sgOptions.Gameplay.bAutoEquipArmor = GetIniBool("Game", "Auto Equip Armor", AUTO_PICKUP_DEFAULT(false));
sgOptions.Gameplay.bAutoEquipHelms = GetIniBool("Game", "Auto Equip Helms", AUTO_PICKUP_DEFAULT(false));
sgOptions.Gameplay.bAutoEquipShields = GetIniBool("Game", "Auto Equip Shields", AUTO_PICKUP_DEFAULT(false));
sgOptions.Gameplay.bAutoEquipJewelry = GetIniBool("Game", "Auto Equip Jewelry", AUTO_PICKUP_DEFAULT(false));
sgOptions.Gameplay.bRandomizeQuests = GetIniBool("Game", "Randomize Quests", true);
sgOptions.Gameplay.bShowMonsterType = GetIniBool("Game", "Show Monster Type", false);
sgOptions.Gameplay.bDisableCripplingShrines = GetIniBool("Game", "Disable Crippling Shrines", false);
sgOptions.Gameplay.bAutoRefillBelt = GetIniBool("Game", "Auto Refill Belt", AUTO_PICKUP_DEFAULT(false));
GetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress, sizeof(sgOptions.Network.szBindAddress), "0.0.0.0");
sgOptions.Network.nPort = GetIniInt("Network", "Port", 6112);
@ -430,18 +429,6 @@ void SaveOptions()
SetIniValue("Graphics", "Show FPS", sgOptions.Graphics.bShowFPS);
SetIniValue("Game", "Speed", sgOptions.Gameplay.nTickRate);
SetIniValue("Game", "Enemy Health Bar", sgOptions.Gameplay.bEnemyHealthBar);
SetIniValue("Game", "Auto Gold Pickup", sgOptions.Gameplay.bAutoGoldPickup);
SetIniValue("Game", "Adria Refills Mana", sgOptions.Gameplay.bAdriaRefillsMana);
SetIniValue("Game", "Auto Equip Weapons", sgOptions.Gameplay.bAutoEquipWeapons);
SetIniValue("Game", "Auto Equip Armor", sgOptions.Gameplay.bAutoEquipArmor);
SetIniValue("Game", "Auto Equip Helms", sgOptions.Gameplay.bAutoEquipHelms);
SetIniValue("Game", "Auto Equip Shields", sgOptions.Gameplay.bAutoEquipShields);
SetIniValue("Game", "Auto Equip Jewelry", sgOptions.Gameplay.bAutoEquipJewelry);
SetIniValue("Game", "Randomize Quests", sgOptions.Gameplay.bRandomizeQuests);
SetIniValue("Game", "Show Monster Type", sgOptions.Gameplay.bShowMonsterType);
SetIniValue("Game", "Disable Crippling Shrines", sgOptions.Gameplay.bDisableCripplingShrines);
SetIniValue("Game", "Auto Refill Belt", sgOptions.Gameplay.bAutoRefillBelt);
SetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress);
SetIniValue("Network", "Port", sgOptions.Network.nPort);
@ -646,9 +633,22 @@ GameplayOptions::GameplayOptions()
, testBard("Test Bard", OptionEntryFlags::CantChangeInGame, N_("Test Bard"), N_("Force the Bard character type to appear in the hero selection menu."), false)
, testBarbarian("Test Barbarian", OptionEntryFlags::CantChangeInGame, N_("Test Barbarian"), N_("Force the Barbarian character type to appear in the hero selection menu."), false)
, experienceBar("Experience Bar", OptionEntryFlags::None, N_("Experience Bar"), N_("Experience Bar is added to the UI at the bottom of the screen."), AUTO_PICKUP_DEFAULT(false))
, enemyHealthBar("Enemy Health Bar", OptionEntryFlags::None, N_("Enemy Health Bar"), N_("Enemy Health Bar is displayed at the top of the screen."), false)
, autoGoldPickup("Auto Gold Pickup", OptionEntryFlags::None, N_("Auto Gold Pickup"), N_("Gold is automatically collected when in close proximity to the player."), AUTO_PICKUP_DEFAULT(false))
, adriaRefillsMana("Adria Refills Mana", OptionEntryFlags::None, N_("Adria Refills Mana"), N_("Adria will refill your mana when you visit her shop."), false)
, autoEquipWeapons("Auto Equip Weapons", OptionEntryFlags::None, N_("Auto Equip Weapons"), N_("Weapons will be automatically equipped on pickup or purchase if enabled."), true)
, autoEquipArmor("Auto Equip Armor", OptionEntryFlags::None, N_("Auto Equip Armor"), N_("Armor will be automatically equipped on pickup or purchase if enabled."), AUTO_PICKUP_DEFAULT(false))
, autoEquipHelms("Auto Equip Helms", OptionEntryFlags::None, N_("Auto Equip Helms"), N_("Helms will be automatically equipped on pickup or purchase if enabled."), AUTO_PICKUP_DEFAULT(false))
, autoEquipShields("Auto Equip Shields", OptionEntryFlags::None, N_("Auto Equip Shields"), N_("Shields will be automatically equipped on pickup or purchase if enabled."), AUTO_PICKUP_DEFAULT(false))
, autoEquipJewelry("Auto Equip Jewelry", OptionEntryFlags::None, N_("Auto Equip Jewelry"), N_("Jewelry will be automatically equipped on pickup or purchase if enabled."), AUTO_PICKUP_DEFAULT(false))
, randomizeQuests("Randomize Quests", OptionEntryFlags::CantChangeInGame, N_("Randomize Quests"), N_("Randomly selecting available quests for new games."), true)
, showMonsterType("Show Monster Type", OptionEntryFlags::None, N_("Show Monster Type"), N_("Hovering over a monster will display the type of monster in the description box in the UI."), false)
, autoRefillBelt("Auto Refill Belt", OptionEntryFlags::None, N_("Auto Refill Belt"), N_("Refill belt from inventory when belt item is consumed."), AUTO_PICKUP_DEFAULT(false))
, disableCripplingShrines("Disable Crippling Shrines", OptionEntryFlags::None, N_("Disable Crippling Shrines"), N_("When enabled Cauldrons, Fascinating Shrines, Goat Shrines, Ornate Shrines and Sacred Shrines are not able to be clicked on and labeled as disabled."), false)
{
grabInput.SetValueChangedCallback(OptionGrabInputChanged);
grabInput.SetValueChangedCallback(OptionExperienceBarChanged);
experienceBar.SetValueChangedCallback(OptionExperienceBarChanged);
enemyHealthBar.SetValueChangedCallback(OptionEnemyHealthBarChanged);
}
std::vector<OptionEntryBase *> GameplayOptions::GetEntries()
{
@ -661,6 +661,18 @@ std::vector<OptionEntryBase *> GameplayOptions::GetEntries()
&testBard,
&testBarbarian,
&experienceBar,
&enemyHealthBar,
&autoGoldPickup,
&adriaRefillsMana,
&autoEquipWeapons,
&autoEquipArmor,
&autoEquipHelms,
&autoEquipShields,
&autoEquipJewelry,
&randomizeQuests,
&showMonsterType,
&autoRefillBelt,
&disableCripplingShrines,
};
}

26
Source/options.h

@ -288,29 +288,29 @@ struct GameplayOptions : OptionCategoryBase {
/** @brief Show the current level progress. */
OptionEntryBoolean experienceBar;
/** @brief Show enemy health at the top of the screen. */
bool bEnemyHealthBar;
OptionEntryBoolean enemyHealthBar;
/** @brief Automatically pick up gold when walking over it. */
bool bAutoGoldPickup;
OptionEntryBoolean autoGoldPickup;
/** @brief Recover mana when talking to Adria. */
bool bAdriaRefillsMana;
OptionEntryBoolean adriaRefillsMana;
/** @brief Automatically attempt to equip weapon-type items when picking them up. */
bool bAutoEquipWeapons;
OptionEntryBoolean autoEquipWeapons;
/** @brief Automatically attempt to equip armor-type items when picking them up. */
bool bAutoEquipArmor;
OptionEntryBoolean autoEquipArmor;
/** @brief Automatically attempt to equip helm-type items when picking them up. */
bool bAutoEquipHelms;
OptionEntryBoolean autoEquipHelms;
/** @brief Automatically attempt to equip shield-type items when picking them up. */
bool bAutoEquipShields;
OptionEntryBoolean autoEquipShields;
/** @brief Automatically attempt to equip jewelry-type items when picking them up. */
bool bAutoEquipJewelry;
OptionEntryBoolean autoEquipJewelry;
/** @brief Only enable 2/3 quests in each game session */
bool bRandomizeQuests;
OptionEntryBoolean randomizeQuests;
/** @brief Indicates whether or not monster type (Animal, Demon, Undead) is shown along with other monster information. */
bool bShowMonsterType;
/** @brief Refill belt form inventory, or rather, use potions/scrolls from inventory first when belt item is consumed. */
bool bAutoRefillBelt;
OptionEntryBoolean showMonsterType;
/** @brief Refill belt from inventory, or rather, use potions/scrolls from inventory first when belt item is consumed. */
OptionEntryBoolean autoRefillBelt;
/** @brief Locally disable clicking on shrines which permanently cripple character. */
bool bDisableCripplingShrines;
OptionEntryBoolean disableCripplingShrines;
};
struct ControllerOptions : OptionCategoryBase {

2
Source/qol/autopickup.cpp

@ -34,7 +34,7 @@ bool HasRoomForGold()
void AutoGoldPickup(int pnum)
{
if (!sgOptions.Gameplay.bAutoGoldPickup)
if (!*sgOptions.Gameplay.autoGoldPickup)
return;
if (pnum != MyPlayerId)

6
Source/qol/monhealthbar.cpp

@ -23,7 +23,7 @@ Art playerExpTags;
void InitMonsterHealthBar()
{
if (!sgOptions.Gameplay.bEnemyHealthBar)
if (!*sgOptions.Gameplay.enemyHealthBar)
return;
LoadMaskedArt("data\\healthbox.pcx", &healthBox, 1, 1);
@ -49,7 +49,7 @@ void FreeMonsterHealthBar()
void DrawMonsterHealthBar(const Surface &out)
{
if (!sgOptions.Gameplay.bEnemyHealthBar)
if (!*sgOptions.Gameplay.enemyHealthBar)
return;
assert(healthBox.surface != nullptr);
@ -101,7 +101,7 @@ void DrawMonsterHealthBar(const Surface &out)
}
};
if (sgOptions.Gameplay.bShowMonsterType) {
if (*sgOptions.Gameplay.showMonsterType) {
Uint8 borderColor = getBorderColor(monster.MData->mMonstClass);
int borderWidth = width - (border * 2);
UnsafeDrawHorizontalLine(out, { position.x + border, position.y + border }, borderWidth, borderColor);

2
Source/quests.cpp

@ -317,7 +317,7 @@ void InitQuests()
}
}
if (!gbIsMultiplayer && sgOptions.Gameplay.bRandomizeQuests) {
if (!gbIsMultiplayer && *sgOptions.Gameplay.randomizeQuests) {
// Quests are set from the seed used to generate level 16.
InitialiseQuestPools(glSeedTbl[15], Quests);
}

2
Source/stores.cpp

@ -648,7 +648,7 @@ void StartSmithRepair()
void FillManaPlayer()
{
if (!sgOptions.Gameplay.bAdriaRefillsMana)
if (!*sgOptions.Gameplay.adriaRefillsMana)
return;
auto &myPlayer = Players[MyPlayerId];

Loading…
Cancel
Save