diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 161e6e222..d8e18d4e6 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -82,6 +82,7 @@ set(libdevilutionx_SRCS controls/plrctrls.cpp engine/animationinfo.cpp engine/demomode.cpp + engine/direction.cpp engine/load_cel.cpp engine/random.cpp engine/render/automap_render.cpp diff --git a/Source/engine/direction.cpp b/Source/engine/direction.cpp new file mode 100644 index 000000000..076ce09e2 --- /dev/null +++ b/Source/engine/direction.cpp @@ -0,0 +1,28 @@ +#include "engine/direction.hpp" + +namespace devilution { + +string_view DirectionToString(Direction direction) +{ + switch (direction) { + case Direction::South: + return "South"; + case Direction::SouthWest: + return "SouthWest"; + case Direction::West: + return "West"; + case Direction::NorthWest: + return "NorthWest"; + case Direction::North: + return "North"; + case Direction::NorthEast: + return "NorthEast"; + case Direction::East: + return "East"; + case Direction::SouthEast: + return "SouthEast"; + } + return ""; +} + +} // namespace devilution diff --git a/Source/engine/direction.hpp b/Source/engine/direction.hpp index ea01953e0..4738e8791 100644 --- a/Source/engine/direction.hpp +++ b/Source/engine/direction.hpp @@ -3,6 +3,8 @@ #include #include +#include "utils/stdcompat/string_view.hpp" + namespace devilution { enum class Direction : std::uint8_t { @@ -37,4 +39,6 @@ constexpr Direction Opposite(Direction facing) return static_cast((static_cast>(facing) + 4) % 8); } +string_view DirectionToString(Direction direction); + } // namespace devilution diff --git a/Source/itemdat.cpp b/Source/itemdat.cpp index 3e5cbb690..c874e56b1 100644 --- a/Source/itemdat.cpp +++ b/Source/itemdat.cpp @@ -9,6 +9,43 @@ namespace devilution { +string_view ItemTypeToString(ItemType itemType) +{ + switch (itemType) { + case ItemType::Misc: + return "Misc"; + case ItemType::Sword: + return "Sword"; + case ItemType::Axe: + return "Axe"; + case ItemType::Bow: + return "Bow"; + case ItemType::Mace: + return "Mace"; + case ItemType::Shield: + return "Shield"; + case ItemType::LightArmor: + return "LightArmor"; + case ItemType::Helm: + return "Helm"; + case ItemType::MediumArmor: + return "MediumArmor"; + case ItemType::HeavyArmor: + return "HeavyArmor"; + case ItemType::Staff: + return "Staff"; + case ItemType::Gold: + return "Gold"; + case ItemType::Ring: + return "Ring"; + case ItemType::Amulet: + return "Amulet"; + case ItemType::None: + return "None"; + } + return ""; +} + /** Contains the data related to each item ID. */ ItemData AllItemsList[] = { // clang-format off diff --git a/Source/itemdat.h b/Source/itemdat.h index 12dd9aa6a..9c84a6434 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -9,6 +9,7 @@ #include "objdat.h" #include "spelldat.h" +#include "utils/stdcompat/string_view.hpp" namespace devilution { @@ -244,6 +245,8 @@ enum class ItemType : int8_t { None = -1, }; +string_view ItemTypeToString(ItemType itemType); + enum unique_base_item : int8_t { UITYPE_NONE, UITYPE_SHORTBOW, diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 57b801420..2312d3a10 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -427,7 +427,7 @@ void DrawMonster(const Surface &out, Point tilePosition, Point targetBufferPosit "Draw Monster \"{}\" {}: facing {}, frame {} of {}", monster.mName, getMonsterModeDisplayName(monster._mmode), - monster._mdir, + DirectionToString(monster._mdir), nCel, frames); return; @@ -529,7 +529,7 @@ void DrawPlayer(const Surface &out, int pnum, Point tilePosition, Point targetBu pnum, player._pName, szMode, - player._pdir, + DirectionToString(player._pdir), nCel, frames); return; @@ -717,7 +717,7 @@ void DrawItem(const Surface &out, Point tilePosition, Point targetBufferPosition int nCel = item.AnimInfo.GetFrameToUseForRendering(); int frames = SDL_SwapLE32(*(DWORD *)cel->Data()); if (nCel < 1 || frames > 50 || nCel > frames) { - Log("Draw \"{}\" Item 1: frame {} of {}, item type=={}", item._iIName, nCel, frames, item._itype); + Log("Draw \"{}\" Item 1: frame {} of {}, item type=={}", item._iIName, nCel, frames, ItemTypeToString(item._itype)); return; }