1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00

add setting for hp bar

This commit is contained in:
Laserlicht 2025-02-08 22:48:21 +01:00
parent a8211d12de
commit d98ce78c34
7 changed files with 34 additions and 2 deletions

View File

@ -363,6 +363,8 @@
"vcmi.battleOptions.endWithAutocombat.help": "{Ends battle}\n\nAuto-Combat plays battle to end instant",
"vcmi.battleOptions.showQuickSpell.hover": "Show Quickspell panel",
"vcmi.battleOptions.showQuickSpell.help": "{Show Quickspell panel}\n\nShow panel for quick selecting spells",
"vcmi.battleOptions.showHealthBar.hover": "Show health bar",
"vcmi.battleOptions.showHealthBar.help": "{Show health bar}\n\nShow health bar indicating remaining health before one unit dies.",
"vcmi.adventureMap.revisitObject.hover" : "Revisit Object",
"vcmi.adventureMap.revisitObject.help" : "{Revisit Object}\n\nIf a hero currently stands on a Map Object, he can revisit the location.",

View File

@ -363,6 +363,8 @@
"vcmi.battleOptions.endWithAutocombat.help": "{Kampf beenden}\n\nAutokampf spielt den Kampf sofort zu Ende",
"vcmi.battleOptions.showQuickSpell.hover": "Schnellzauber-Panel anzeigen",
"vcmi.battleOptions.showQuickSpell.help": "{Schnellzauber-Panel anzeigen}\n\nZeigt ein Panel, auf dem schnell Zauber ausgewählt werden können",
"vcmi.battleOptions.showHealthBar.hover": "Gesundheits-Balken anzeigen",
"vcmi.battleOptions.showHealthBar.help": "{Gesundheits-Balken anzeigen}\n\nAnzeige eines Gesundheitsbalkens, der die verbleibende Gesundheit anzeigt, bevor eine Einheit stirbt.",
"vcmi.adventureMap.revisitObject.hover" : "Objekt erneut besuchen",
"vcmi.adventureMap.revisitObject.help" : "{Objekt erneut besuchen}\n\nSteht ein Held gerade auf einem Kartenobjekt, kann er den Ort erneut aufsuchen.",

View File

@ -319,7 +319,7 @@ void BattleStacksController::showStackAmountBox(Canvas & canvas, const CStack *
Point textPosition = Point(amountBG->dimensions().x/2 + boxPosition.x, boxPosition.y + amountBG->dimensions().y/2);
if(settings["general"]["enableUiEnhancements"].Bool()) // combat health bar
if(settings["battle"]["showHealthBar"].Bool())
{
float health = CGI->creatures()->getByIndex(stack->creatureIndex())->getMaxHealth();
float healthRemaining = std::max(stack->getAvailableHealth() - (stack->getCount() - 1) * health, .0f);

View File

@ -76,6 +76,10 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner)
{
endWithAutocombatChangedCallback(value);
});
addCallback("showHealthBarChanged", [this, owner](bool value)
{
showHealthBarCallback(value, owner);
});
build(config);
std::shared_ptr<CToggleGroup> animationSpeedToggle = widget<CToggleGroup>("animationSpeedPicker");
@ -113,6 +117,9 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner)
std::shared_ptr<CToggleButton> endWithAutocombatCheckbox = widget<CToggleButton>("endWithAutocombatCheckbox");
endWithAutocombatCheckbox->setSelected(settings["battle"]["endWithAutocombat"].Bool());
std::shared_ptr<CToggleButton> showHealthBarCheckbox = widget<CToggleButton>("showHealthBarCheckbox");
showHealthBarCheckbox->setSelected(settings["battle"]["showHealthBar"].Bool());
}
int BattleOptionsTab::getAnimSpeed() const
@ -280,3 +287,11 @@ void BattleOptionsTab::endWithAutocombatChangedCallback(bool value)
Settings endWithAutocombat = settings.write["battle"]["endWithAutocombat"];
endWithAutocombat->Bool() = value;
}
void BattleOptionsTab::showHealthBarCallback(bool value, BattleInterface * parentBattleInterface)
{
Settings showHealthBar = settings.write["battle"]["showHealthBar"];
showHealthBar->Bool() = value;
if(parentBattleInterface)
parentBattleInterface->redrawBattlefield();
}

View File

@ -35,6 +35,7 @@ private:
void showQuickSpellChangedCallback(bool value, BattleInterface * parentBattleInterface);
void enableAutocombatSpellsChangedCallback(bool value);
void endWithAutocombatChangedCallback(bool value);
void showHealthBarCallback(bool value, BattleInterface * parentBattleInterface);
public:
BattleOptionsTab(BattleInterface * owner = nullptr);
};

View File

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

View File

@ -125,6 +125,9 @@
},
{
"text": "vcmi.battleOptions.skipBattleIntroMusic.hover",
},
{
"text": "vcmi.battleOptions.showHealthBar.hover",
}
]
},
@ -173,6 +176,11 @@
"name": "skipBattleIntroMusicCheckbox",
"help": "vcmi.battleOptions.skipBattleIntroMusic",
"callback": "skipBattleIntroMusicChanged"
},
{
"name": "showHealthBarCheckbox",
"help": "vcmi.battleOptions.showHealthBar",
"callback": "showHealthBarChanged"
}
]
},