mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fixes from code review
This commit is contained in:
parent
b53894ac2d
commit
b73f9325ad
@ -28,20 +28,22 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack(const Point & position)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
||||
pos += position;
|
||||
setRedrawParent(true);
|
||||
|
||||
const auto backpackCap = VLC->settings()->getInteger(EGameSettings::HEROES_BACKPACK_CAP);
|
||||
auto visibleCapacityMax = HERO_BACKPACK_WINDOW_SLOT_LINES * HERO_BACKPACK_WINDOW_SLOT_COLUMNS;
|
||||
auto visibleCapacityMax = HERO_BACKPACK_WINDOW_SLOT_ROWS * HERO_BACKPACK_WINDOW_SLOT_COLUMNS;
|
||||
if(backpackCap >= 0)
|
||||
visibleCapacityMax = visibleCapacityMax > backpackCap ? backpackCap : visibleCapacityMax;
|
||||
|
||||
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++)
|
||||
const int slotSizeWithMargin = 46;
|
||||
|
||||
for(int i = 0; i < visibleCapacityMax; i++)
|
||||
{
|
||||
auto artifactSlotBackground = std::make_shared<CPicture>("heroWindow/artifactSlotEmpty",
|
||||
Point(46 * (i % HERO_BACKPACK_WINDOW_SLOT_COLUMNS), 46 * (i / HERO_BACKPACK_WINDOW_SLOT_COLUMNS)));
|
||||
Point(slotSizeWithMargin * (i % HERO_BACKPACK_WINDOW_SLOT_COLUMNS), slotSizeWithMargin * (i / HERO_BACKPACK_WINDOW_SLOT_COLUMNS)));
|
||||
|
||||
backpackSlotsBackgrounds.emplace_back(artifactSlotBackground);
|
||||
}
|
||||
@ -49,7 +51,7 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack(const Point & position)
|
||||
for(auto & artPlace : backpack)
|
||||
{
|
||||
artPlace = std::make_shared<CHeroArtPlace>(
|
||||
Point(46 * (artPlaceIdx % HERO_BACKPACK_WINDOW_SLOT_COLUMNS), 46 * (artPlaceIdx / HERO_BACKPACK_WINDOW_SLOT_COLUMNS)));
|
||||
Point(slotSizeWithMargin * (artPlaceIdx % HERO_BACKPACK_WINDOW_SLOT_COLUMNS), slotSizeWithMargin * (artPlaceIdx / HERO_BACKPACK_WINDOW_SLOT_COLUMNS)));
|
||||
artPlace->setArtifact(nullptr);
|
||||
artPlace->leftClickCallback = std::bind(&CArtifactsOfHeroBase::leftClickArtPlace, this, _1);
|
||||
artPlace->rightClickCallback = std::bind(&CArtifactsOfHeroBase::rightClickArtPlace, this, _1);
|
||||
@ -67,8 +69,8 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack(const Point & position)
|
||||
scrollBackpack(static_cast<int>(pos) * HERO_BACKPACK_WINDOW_SLOT_COLUMNS - backpackPos);
|
||||
};
|
||||
backpackListBox = std::make_shared<CListBoxWithCallback>(
|
||||
posMoved, onCreate, Point(0, 0), Point(0, 0), HERO_BACKPACK_WINDOW_SLOT_LINES, 0, 0, 1,
|
||||
Rect(HERO_BACKPACK_WINDOW_SLOT_COLUMNS * 46 + 10, 0, HERO_BACKPACK_WINDOW_SLOT_LINES * 46 - 5, 0));
|
||||
posMoved, onCreate, Point(0, 0), Point(0, 0), HERO_BACKPACK_WINDOW_SLOT_ROWS, 0, 0, 1,
|
||||
Rect(HERO_BACKPACK_WINDOW_SLOT_COLUMNS * slotSizeWithMargin + 10, 0, HERO_BACKPACK_WINDOW_SLOT_ROWS * slotSizeWithMargin - 5, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +97,6 @@ void CArtifactsOfHeroBackpack::scrollBackpack(int offset)
|
||||
slot = slot + 1;
|
||||
}
|
||||
redraw();
|
||||
setRedrawParent(true);
|
||||
}
|
||||
|
||||
void CArtifactsOfHeroBackpack::updateBackpackSlots()
|
||||
|
@ -33,5 +33,5 @@ private:
|
||||
std::shared_ptr<CListBoxWithCallback> backpackListBox;
|
||||
std::vector<std::shared_ptr<CPicture>> backpackSlotsBackgrounds;
|
||||
const size_t HERO_BACKPACK_WINDOW_SLOT_COLUMNS = 8;
|
||||
const size_t HERO_BACKPACK_WINDOW_SLOT_LINES = 8;
|
||||
const size_t HERO_BACKPACK_WINDOW_SLOT_ROWS = 8;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user