From b53894ac2d93c44460e52a6668fcc81fbf9554cf Mon Sep 17 00:00:00 2001 From: Dydzio Date: Sun, 20 Aug 2023 18:57:53 +0200 Subject: [PATCH] Add artifact slots backgrounds --- .../Sprites/heroWindow/artifactSlotEmpty.png | Bin 0 -> 133 bytes client/widgets/CArtifactsOfHeroBackpack.cpp | 19 ++++++++++++++---- client/widgets/CArtifactsOfHeroBackpack.h | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 Mods/vcmi/Sprites/heroWindow/artifactSlotEmpty.png diff --git a/Mods/vcmi/Sprites/heroWindow/artifactSlotEmpty.png b/Mods/vcmi/Sprites/heroWindow/artifactSlotEmpty.png new file mode 100644 index 0000000000000000000000000000000000000000..f0dec09728fc1f413e050d6702087aee95298970 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^Iv~u%3?!3ZZJGq6cmjMvT!Hk?+1)8#w#I7mhdkHY z1Nkf^L4LsvK#+Olf)|jl;_2cTQo)$)z_w^%!GQ%^x!A&tUmOT6;1~X;5iKfr_2G#^ aUWP9dWghHLS*r|G&*16m=d#Wzp$P!0i6>wH literal 0 HcmV?d00001 diff --git a/client/widgets/CArtifactsOfHeroBackpack.cpp b/client/widgets/CArtifactsOfHeroBackpack.cpp index 2bf968cdf..80aab5d67 100644 --- a/client/widgets/CArtifactsOfHeroBackpack.cpp +++ b/client/widgets/CArtifactsOfHeroBackpack.cpp @@ -14,6 +14,7 @@ #include "../gui/Shortcut.h" #include "Buttons.h" +#include "Images.h" #include "GameSettings.h" #include "IHandlerBase.h" #include "ObjectLists.h" @@ -29,12 +30,22 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack(const Point & position) pos += position; const auto backpackCap = VLC->settings()->getInteger(EGameSettings::HEROES_BACKPACK_CAP); - auto visibleCapasityMax = HERO_BACKPACK_WINDOW_SLOT_LINES * HERO_BACKPACK_WINDOW_SLOT_COLUMNS; + auto visibleCapacityMax = HERO_BACKPACK_WINDOW_SLOT_LINES * HERO_BACKPACK_WINDOW_SLOT_COLUMNS; if(backpackCap >= 0) - visibleCapasityMax = visibleCapasityMax > backpackCap ? backpackCap : visibleCapasityMax; + visibleCapacityMax = visibleCapacityMax > backpackCap ? backpackCap : visibleCapacityMax; - backpack.resize(visibleCapasityMax); + backpack.resize(visibleCapacityMax); + backpackSlotsBackgrounds.resize(visibleCapacityMax); size_t artPlaceIdx = 0; + + for(int i = 0; i < HERO_BACKPACK_WINDOW_SLOT_LINES * HERO_BACKPACK_WINDOW_SLOT_COLUMNS; i++) + { + auto artifactSlotBackground = std::make_shared("heroWindow/artifactSlotEmpty", + Point(46 * (i % HERO_BACKPACK_WINDOW_SLOT_COLUMNS), 46 * (i / HERO_BACKPACK_WINDOW_SLOT_COLUMNS))); + + backpackSlotsBackgrounds.emplace_back(artifactSlotBackground); + } + for(auto & artPlace : backpack) { artPlace = std::make_shared( @@ -45,7 +56,7 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack(const Point & position) artPlaceIdx++; } - if(backpackCap < 0 || visibleCapasityMax < backpackCap) + if(backpackCap < 0 || visibleCapacityMax < backpackCap) { auto onCreate = [](size_t index) -> std::shared_ptr { diff --git a/client/widgets/CArtifactsOfHeroBackpack.h b/client/widgets/CArtifactsOfHeroBackpack.h index f504ba62c..f3735795e 100644 --- a/client/widgets/CArtifactsOfHeroBackpack.h +++ b/client/widgets/CArtifactsOfHeroBackpack.h @@ -31,6 +31,7 @@ public: private: std::shared_ptr backpackListBox; + std::vector> backpackSlotsBackgrounds; const size_t HERO_BACKPACK_WINDOW_SLOT_COLUMNS = 8; const size_t HERO_BACKPACK_WINDOW_SLOT_LINES = 8; };