Browse Source

Make belt_item_type in to an enum class

pull/6374/head
Anders Jenbo 4 years ago
parent
commit
974f517fd9
  1. 8
      Source/controls/plrctrls.cpp
  2. 10
      Source/controls/plrctrls.h
  3. 4
      Source/controls/touch/renderers.cpp
  4. 8
      Source/controls/touch/renderers.h
  5. 8
      Source/diablo.cpp

8
Source/controls/plrctrls.cpp

@ -1587,10 +1587,10 @@ void ProcessGameAction(const GameAction &action)
case GameActionType_SEND_KEY:
break;
case GameActionType_USE_HEALTH_POTION:
UseBeltItem(BLT_HEALING);
UseBeltItem(BeltItemType::Healing);
break;
case GameActionType_USE_MANA_POTION:
UseBeltItem(BLT_MANA);
UseBeltItem(BeltItemType::Mana);
break;
case GameActionType_PRIMARY_ACTION:
PerformPrimaryAction();
@ -1782,7 +1782,7 @@ void plrctrls_after_game_logic()
Movement(*MyPlayer);
}
void UseBeltItem(int type)
void UseBeltItem(BeltItemType type)
{
for (int i = 0; i < MaxBeltItems; i++) {
Item &item = MyPlayer->SpdList[i];
@ -1794,7 +1794,7 @@ void UseBeltItem(int type)
bool isHealing = isRejuvenation || IsAnyOf(item._iMiscId, IMISC_HEAL, IMISC_FULLHEAL) || item.isScrollOf(SpellID::Healing);
bool isMana = isRejuvenation || IsAnyOf(item._iMiscId, IMISC_MANA, IMISC_FULLMANA);
if ((type == BLT_HEALING && isHealing) || (type == BLT_MANA && isMana)) {
if ((type == BeltItemType::Healing && isHealing) || (type == BeltItemType::Mana && isMana)) {
UseInvItem(INVITEM_BELT_FIRST + i);
break;
}

10
Source/controls/plrctrls.h

@ -12,10 +12,10 @@
namespace devilution {
typedef enum belt_item_type : uint8_t {
BLT_HEALING,
BLT_MANA,
} belt_item_type;
enum class BeltItemType : uint8_t {
Healing,
Mana,
};
enum class ControlTypes : uint8_t {
None,
@ -68,7 +68,7 @@ bool IsMovementHandlerActive();
void DetectInputMethod(const SDL_Event &event, const ControllerButtonEvent &gamepadEvent);
void ProcessGameAction(const GameAction &action);
void UseBeltItem(int type);
void UseBeltItem(BeltItemType type);
// Talk to towners, click on inv items, attack, etc.
void PerformPrimaryAction();

4
Source/controls/touch/renderers.cpp

@ -382,7 +382,7 @@ std::optional<VirtualGamepadPotionType> PotionButtonRenderer::GetPotionType()
continue;
}
if (potionType == BLT_HEALING) {
if (potionType == BeltItemType::Healing) {
if (item._iMiscId == IMISC_HEAL)
return GAMEPAD_HEALING;
if (item._iMiscId == IMISC_FULLHEAL)
@ -391,7 +391,7 @@ std::optional<VirtualGamepadPotionType> PotionButtonRenderer::GetPotionType()
return GAMEPAD_SCROLL_OF_HEALING;
}
if (potionType == BLT_MANA) {
if (potionType == BeltItemType::Mana) {
if (item._iMiscId == IMISC_MANA)
return GAMEPAD_MANA;
if (item._iMiscId == IMISC_FULLMANA)

8
Source/controls/touch/renderers.h

@ -183,7 +183,7 @@ private:
class PotionButtonRenderer : public VirtualPadButtonRenderer {
public:
PotionButtonRenderer(VirtualPadButton *potionButton, belt_item_type potionType)
PotionButtonRenderer(VirtualPadButton *potionButton, BeltItemType potionType)
: VirtualPadButtonRenderer(potionButton)
, potionType(potionType)
{
@ -192,7 +192,7 @@ public:
void RenderPotion(RenderFunction renderFunction, const ButtonTexture &potionArt);
private:
belt_item_type potionType;
BeltItemType potionType;
VirtualGamepadButtonType GetButtonType();
std::optional<VirtualGamepadPotionType> GetPotionType();
@ -208,8 +208,8 @@ public:
, secondaryActionButtonRenderer(&virtualGamepad->secondaryActionButton)
, spellActionButtonRenderer(&virtualGamepad->spellActionButton)
, cancelButtonRenderer(&virtualGamepad->cancelButton)
, healthButtonRenderer(&virtualGamepad->healthButton, BLT_HEALING)
, manaButtonRenderer(&virtualGamepad->manaButton, BLT_MANA)
, healthButtonRenderer(&virtualGamepad->healthButton, BeltItemType::Healing)
, manaButtonRenderer(&virtualGamepad->manaButton, BeltItemType::Mana)
{
}

8
Source/diablo.cpp

@ -1727,7 +1727,7 @@ void InitKeymapActions()
N_("Use health potion"),
N_("Use health potions from belt."),
SDLK_UNKNOWN,
[] { UseBeltItem(BLT_HEALING); },
[] { UseBeltItem(BeltItemType::Healing); },
nullptr,
CanPlayerTakeAction);
sgOptions.Keymapper.AddAction(
@ -1735,7 +1735,7 @@ void InitKeymapActions()
N_("Use mana potion"),
N_("Use mana potions from belt."),
SDLK_UNKNOWN,
[] { UseBeltItem(BLT_MANA); },
[] { UseBeltItem(BeltItemType::Mana); },
nullptr,
CanPlayerTakeAction);
sgOptions.Keymapper.AddAction(
@ -2131,7 +2131,7 @@ void InitPadmapActions()
N_("Use health potion"),
N_("Use health potions from belt."),
ControllerButton_BUTTON_LEFTSHOULDER,
[] { UseBeltItem(BLT_HEALING); },
[] { UseBeltItem(BeltItemType::Healing); },
nullptr,
CanPlayerTakeAction);
sgOptions.Padmapper.AddAction(
@ -2139,7 +2139,7 @@ void InitPadmapActions()
N_("Use mana potion"),
N_("Use mana potions from belt."),
ControllerButton_BUTTON_RIGHTSHOULDER,
[] { UseBeltItem(BLT_MANA); },
[] { UseBeltItem(BeltItemType::Mana); },
nullptr,
CanPlayerTakeAction);
sgOptions.Padmapper.AddAction(

Loading…
Cancel
Save