1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Merge pull request #3589 from Laserlicht/queue_adjust

adjustable queue size for embedded queue
This commit is contained in:
Ivan Savenko 2024-02-05 18:44:45 +02:00 committed by GitHub
commit 156f1d9311
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 5 deletions

View File

@ -852,12 +852,19 @@ StackQueue::StackQueue(bool Embedded, BattleInterface & owner)
owner(owner)
{
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
uint32_t queueSize = QUEUE_SIZE_BIG;
if(embedded)
{
pos.w = QUEUE_SIZE * 41;
int32_t queueSmallOutsideYOffset = 65;
bool queueSmallOutside = settings["battle"]["queueSmallOutside"].Bool() && (pos.y - queueSmallOutsideYOffset) >= 0;
queueSize = std::clamp(static_cast<int>(settings["battle"]["queueSmallSlots"].Float()), 1, queueSmallOutside ? GH.screenDimensions().x / 41 : 19);
pos.w = queueSize * 41;
pos.h = 49;
pos.x += parent->pos.w/2 - pos.w/2;
pos.y += 10;
pos.y += queueSmallOutside ? -queueSmallOutsideYOffset : 10;
icons = GH.renderHandler().loadAnimation(AnimationPath::builtin("CPRSMALL"));
stateIcons = GH.renderHandler().loadAnimation(AnimationPath::builtin("VCMI/BATTLEQUEUE/STATESSMALL"));
@ -878,7 +885,7 @@ StackQueue::StackQueue(bool Embedded, BattleInterface & owner)
}
stateIcons->preload();
stackBoxes.resize(QUEUE_SIZE);
stackBoxes.resize(queueSize);
for (int i = 0; i < stackBoxes.size(); i++)
{
stackBoxes[i] = std::make_shared<StackBox>(this);

View File

@ -239,7 +239,7 @@ class StackQueue : public CIntObject
std::optional<uint32_t> getBoundUnitID() const;
};
static const int QUEUE_SIZE = 10;
static const int QUEUE_SIZE_BIG = 10;
std::shared_ptr<CFilledTexture> background;
std::vector<std::shared_ptr<StackBox>> stackBoxes;
BattleInterface & owner;

View File

@ -304,7 +304,7 @@
"type" : "object",
"additionalProperties" : false,
"default" : {},
"required" : [ "speedFactor", "mouseShadow", "cellBorders", "stackRange", "movementHighlightOnHover", "rangeLimitHighlightOnHover", "showQueue", "swipeAttackDistance", "queueSize", "stickyHeroInfoWindows", "enableAutocombatSpells", "endWithAutocombat" ],
"required" : [ "speedFactor", "mouseShadow", "cellBorders", "stackRange", "movementHighlightOnHover", "rangeLimitHighlightOnHover", "showQueue", "swipeAttackDistance", "queueSize", "stickyHeroInfoWindows", "enableAutocombatSpells", "endWithAutocombat", "queueSmallSlots", "queueSmallOutside" ],
"properties" : {
"speedFactor" : {
"type" : "number",
@ -354,6 +354,14 @@
"endWithAutocombat" : {
"type": "boolean",
"default": false
},
"queueSmallSlots" : {
"type": "number",
"default": 10
},
"queueSmallOutside" : {
"type": "boolean",
"default": false
}
}
},