mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
New garrison interface layout: Reversed two rows + labels below slot
This commit is contained in:
@@ -410,7 +410,19 @@ CGarrisonSlot::CGarrisonSlot(CGarrisonInt * Owner, int x, int y, SlotID IID, CGa
|
|||||||
pos.h = 64;
|
pos.h = 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
stackCount = std::make_shared<CLabel>(pos.w, pos.h, owner->smallIcons ? FONT_TINY : FONT_MEDIUM, ETextAlignment::BOTTOMRIGHT, Colors::WHITE);
|
int labelPosW = pos.w;
|
||||||
|
int labelPosH = pos.h;
|
||||||
|
|
||||||
|
if(Owner->layout == CGarrisonInt::EGarrisonIntSlotsLayout::REVERSED_TWO_ROWS) //labels under icon
|
||||||
|
{
|
||||||
|
labelPosW = pos.w / 2 + 1;
|
||||||
|
labelPosH += 7;
|
||||||
|
}
|
||||||
|
ETextAlignment labelAlignment = Owner->layout == CGarrisonInt::EGarrisonIntSlotsLayout::REVERSED_TWO_ROWS
|
||||||
|
? ETextAlignment::CENTER
|
||||||
|
: ETextAlignment::BOTTOMRIGHT;
|
||||||
|
|
||||||
|
stackCount = std::make_shared<CLabel>(labelPosW, labelPosH, owner->smallIcons ? FONT_TINY : FONT_MEDIUM, labelAlignment, Colors::WHITE);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -503,10 +515,22 @@ void CGarrisonInt::createSlots()
|
|||||||
{
|
{
|
||||||
if(!garrisonSlots[j])
|
if(!garrisonSlots[j])
|
||||||
garrisonSlots[j] = std::make_shared<CGarrisonSlot>(this, i*garOffset.x + (j*distance), i*garOffset.y, SlotID(j), static_cast<CGarrisonSlot::EGarrisonType>(i), nullptr);
|
garrisonSlots[j] = std::make_shared<CGarrisonSlot>(this, i*garOffset.x + (j*distance), i*garOffset.y, SlotID(j), static_cast<CGarrisonSlot::EGarrisonType>(i), nullptr);
|
||||||
if(twoRows && j>=4)
|
|
||||||
|
if(layout == EGarrisonIntSlotsLayout::TWO_ROWS && j >= 4)
|
||||||
{
|
{
|
||||||
garrisonSlots[j]->moveBy(Point(-126, 37));
|
garrisonSlots[j]->moveBy(Point(-126, 37));
|
||||||
}
|
}
|
||||||
|
else if(layout == EGarrisonIntSlotsLayout::REVERSED_TWO_ROWS)
|
||||||
|
{
|
||||||
|
if(j >= 3)
|
||||||
|
{
|
||||||
|
garrisonSlots[j]->moveBy(Point(-90, 49));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
garrisonSlots[j]->moveBy(Point(36, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
vstd::concatenate(availableSlots, garrisonSlots);
|
vstd::concatenate(availableSlots, garrisonSlots);
|
||||||
}
|
}
|
||||||
@@ -647,7 +671,7 @@ void CGarrisonInt::bulkSmartSplitStack(const CGarrisonSlot * selected)
|
|||||||
|
|
||||||
CGarrisonInt::CGarrisonInt(int x, int y, int inx, const Point & garsOffset,
|
CGarrisonInt::CGarrisonInt(int x, int y, int inx, const Point & garsOffset,
|
||||||
const CArmedInstance * s1, const CArmedInstance * s2,
|
const CArmedInstance * s1, const CArmedInstance * s2,
|
||||||
bool _removableUnits, bool smallImgs, bool _twoRows)
|
bool _removableUnits, bool smallImgs, EGarrisonIntSlotsLayout _layout)
|
||||||
: highlighted(nullptr),
|
: highlighted(nullptr),
|
||||||
inSplittingMode(false),
|
inSplittingMode(false),
|
||||||
interx(inx),
|
interx(inx),
|
||||||
@@ -655,7 +679,7 @@ CGarrisonInt::CGarrisonInt(int x, int y, int inx, const Point & garsOffset,
|
|||||||
pb(false),
|
pb(false),
|
||||||
smallIcons(smallImgs),
|
smallIcons(smallImgs),
|
||||||
removableUnits(_removableUnits),
|
removableUnits(_removableUnits),
|
||||||
twoRows(_twoRows)
|
layout(_layout)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|
||||||
|
@@ -81,6 +81,13 @@ class CGarrisonInt :public CIntObject
|
|||||||
bool checkSelected(const CGarrisonSlot * selected, TQuantity min = 0) const;
|
bool checkSelected(const CGarrisonSlot * selected, TQuantity min = 0) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class EGarrisonIntSlotsLayout
|
||||||
|
{
|
||||||
|
ONE_ROW,
|
||||||
|
TWO_ROWS,
|
||||||
|
REVERSED_TWO_ROWS
|
||||||
|
};
|
||||||
|
|
||||||
int interx; ///< Space between slots
|
int interx; ///< Space between slots
|
||||||
Point garOffset; ///< Offset between garrisons (not used if only one hero)
|
Point garOffset; ///< Offset between garrisons (not used if only one hero)
|
||||||
std::vector<std::shared_ptr<CButton>> splitButtons; ///< May be empty if no buttons
|
std::vector<std::shared_ptr<CButton>> splitButtons; ///< May be empty if no buttons
|
||||||
@@ -89,9 +96,10 @@ public:
|
|||||||
bool pb,
|
bool pb,
|
||||||
smallIcons, ///< true - 32x32 imgs, false - 58x64
|
smallIcons, ///< true - 32x32 imgs, false - 58x64
|
||||||
removableUnits, ///< player Can remove units from up
|
removableUnits, ///< player Can remove units from up
|
||||||
twoRows, ///< slots Will be placed in 2 rows
|
|
||||||
owned[2]; ///< player Owns up or down army ([0] upper, [1] lower)
|
owned[2]; ///< player Owns up or down army ([0] upper, [1] lower)
|
||||||
|
|
||||||
|
EGarrisonIntSlotsLayout layout;
|
||||||
|
|
||||||
void selectSlot(CGarrisonSlot * slot); ///< @param slot null = deselect
|
void selectSlot(CGarrisonSlot * slot); ///< @param slot null = deselect
|
||||||
const CGarrisonSlot * getSelection() const;
|
const CGarrisonSlot * getSelection() const;
|
||||||
|
|
||||||
@@ -123,13 +131,13 @@ public:
|
|||||||
/// @param s1, s2 Top and bottom armies
|
/// @param s1, s2 Top and bottom armies
|
||||||
/// @param _removableUnits You can take units from top
|
/// @param _removableUnits You can take units from top
|
||||||
/// @param smallImgs Units images size 64x58 or 32x32
|
/// @param smallImgs Units images size 64x58 or 32x32
|
||||||
/// @param _twoRows Display slots in 2 row (1st row = 4 slots, 2nd = 3 slots)
|
/// @param _layout - when TWO_ROWS - Display slots in 2 rows (1st row = 4 slots, 2nd = 3 slots), REVERSED_TWO_ROWS = 3 slots in 1st row
|
||||||
CGarrisonInt(int x, int y, int inx,
|
CGarrisonInt(int x, int y, int inx,
|
||||||
const Point & garsOffset,
|
const Point & garsOffset,
|
||||||
const CArmedInstance * s1, const CArmedInstance * s2 = nullptr,
|
const CArmedInstance * s1, const CArmedInstance * s2 = nullptr,
|
||||||
bool _removableUnits = true,
|
bool _removableUnits = true,
|
||||||
bool smallImgs = false,
|
bool smallImgs = false,
|
||||||
bool _twoRows = false);
|
EGarrisonIntSlotsLayout _layout = EGarrisonIntSlotsLayout::ONE_ROW);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGarrisonHolder
|
class CGarrisonHolder
|
||||||
|
@@ -772,7 +772,7 @@ CTownItem::CTownItem(const CGTownInstance * Town)
|
|||||||
hall = std::make_shared<CTownInfo>( 69, 31, town, true);
|
hall = std::make_shared<CTownInfo>( 69, 31, town, true);
|
||||||
fort = std::make_shared<CTownInfo>(111, 31, town, false);
|
fort = std::make_shared<CTownInfo>(111, 31, town, false);
|
||||||
|
|
||||||
garr = std::make_shared<CGarrisonInt>(313, 3, 4, Point(232,0), town->getUpperArmy(), town->visitingHero, true, true, true);
|
garr = std::make_shared<CGarrisonInt>(313, 3, 4, Point(232,0), town->getUpperArmy(), town->visitingHero, true, true, CGarrisonInt::EGarrisonIntSlotsLayout::TWO_ROWS);
|
||||||
heroes = std::make_shared<HeroSlots>(town, Point(244,6), Point(475,6), garr, false);
|
heroes = std::make_shared<HeroSlots>(town, Point(244,6), Point(475,6), garr, false);
|
||||||
|
|
||||||
size_t iconIndex = town->town->clientInfo.icons[town->hasFort()][town->builded >= CGI->settings()->getInteger(EGameSettings::TOWNS_BUILDINGS_PER_TURN_CAP)];
|
size_t iconIndex = town->town->clientInfo.icons[town->hasFort()][town->builded >= CGI->settings()->getInteger(EGameSettings::TOWNS_BUILDINGS_PER_TURN_CAP)];
|
||||||
|
Reference in New Issue
Block a user