1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

make hideable

This commit is contained in:
Laserlicht
2024-07-16 23:36:23 +02:00
parent 37b5de689a
commit 1daf6dfad1
8 changed files with 57 additions and 6 deletions

View File

@@ -420,7 +420,7 @@ BattleHero::BattleHero(const BattleInterface & owner, const CGHeroInstance * her
} }
QuickSpellPanel::QuickSpellPanel(BattleInterface & owner) QuickSpellPanel::QuickSpellPanel(BattleInterface & owner)
: CWindowObject(NEEDS_ANIMATED_BACKGROUND), owner(owner) : CIntObject(0), owner(owner)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);

View File

@@ -167,7 +167,7 @@ public:
int spellSlot; int spellSlot;
}; };
class QuickSpellPanel : public CWindowObject class QuickSpellPanel : public CIntObject
{ {
private: private:
std::shared_ptr<CFilledTexture> background; std::shared_ptr<CFilledTexture> background;

View File

@@ -80,6 +80,7 @@ BattleWindow::BattleWindow(BattleInterface & Owner):
owner.castThisSpell(id); owner.castThisSpell(id);
} }
}; };
addShortcut(EShortcut::BATTLE_TOGGLE_QUICKSPELL, [this](){ this->toggleStickyQuickSpellVisibility();});
addShortcut(EShortcut::BATTLE_SPELL_SHORTCUT_0, [useSpellIfPossible](){ useSpellIfPossible(0); }); addShortcut(EShortcut::BATTLE_SPELL_SHORTCUT_0, [useSpellIfPossible](){ useSpellIfPossible(0); });
addShortcut(EShortcut::BATTLE_SPELL_SHORTCUT_1, [useSpellIfPossible](){ useSpellIfPossible(1); }); addShortcut(EShortcut::BATTLE_SPELL_SHORTCUT_1, [useSpellIfPossible](){ useSpellIfPossible(1); });
addShortcut(EShortcut::BATTLE_SPELL_SHORTCUT_2, [useSpellIfPossible](){ useSpellIfPossible(2); }); addShortcut(EShortcut::BATTLE_SPELL_SHORTCUT_2, [useSpellIfPossible](){ useSpellIfPossible(2); });
@@ -205,9 +206,47 @@ void BattleWindow::createQuickSpellWindow()
{ {
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
std::shared_ptr<QuickSpellPanel> window = std::make_shared<QuickSpellPanel>(owner); quickSpellWindow = std::make_shared<QuickSpellPanel>(owner);
window->moveTo(Point(pos.x - 68, pos.y - 14)); quickSpellWindow->moveTo(Point(pos.x - 68, pos.y - 14));
GH.windows().pushWindow(window);
if(settings["battle"]["enableQuickSpellPanel"].Bool())
showStickyQuickSpellWindow();
else
hideStickyQuickSpellWindow();
}
void BattleWindow::toggleStickyQuickSpellVisibility()
{
if(settings["battle"]["enableQuickSpellPanel"].Bool())
hideStickyQuickSpellWindow();
else
showStickyQuickSpellWindow();
}
void BattleWindow::hideStickyQuickSpellWindow()
{
if(settings["battle"]["enableQuickSpellPanel"].Bool() == false)
return;
Settings showStickyQuickSpellWindow = settings.write["battle"]["enableQuickSpellPanel"];
showStickyQuickSpellWindow->Bool() = false;
quickSpellWindow->disable();
GH.windows().totalRedraw();
}
void BattleWindow::showStickyQuickSpellWindow()
{
if(settings["battle"]["enableQuickSpellPanel"].Bool() == true)
return;
Settings showStickyQuickSpellWindow = settings.write["battle"]["enableQuickSpellPanel"];
showStickyQuickSpellWindow->Bool() = true;
quickSpellWindow->enable();
GH.windows().totalRedraw();
} }
void BattleWindow::createTimerInfoWindows() void BattleWindow::createTimerInfoWindows()

View File

@@ -76,6 +76,7 @@ class BattleWindow : public InterfaceObjectConfigurable
void createQueue(); void createQueue();
void toggleStickyHeroWindowsVisibility(); void toggleStickyHeroWindowsVisibility();
void toggleStickyQuickSpellVisibility();
void createStickyHeroInfoWindows(); void createStickyHeroInfoWindows();
void createQuickSpellWindow(); void createQuickSpellWindow();
void createTimerInfoWindows(); void createTimerInfoWindows();
@@ -98,6 +99,10 @@ public:
void hideStickyHeroWindows(); void hideStickyHeroWindows();
void showStickyHeroWindows(); void showStickyHeroWindows();
/// Toggle permanent quickspell windows visibility
void hideStickyQuickSpellWindow();
void showStickyQuickSpellWindow();
/// Event handler for netpack changing hero mana points /// Event handler for netpack changing hero mana points
void heroManaPointsChanged(const CGHeroInstance * hero); void heroManaPointsChanged(const CGHeroInstance * hero);

View File

@@ -186,6 +186,7 @@ enum class EShortcut
BATTLE_TOGGLE_HEROES_STATS, BATTLE_TOGGLE_HEROES_STATS,
BATTLE_OPEN_ACTIVE_UNIT, BATTLE_OPEN_ACTIVE_UNIT,
BATTLE_OPEN_HOVERED_UNIT, BATTLE_OPEN_HOVERED_UNIT,
BATTLE_TOGGLE_QUICKSPELL,
BATTLE_SPELL_SHORTCUT_0, BATTLE_SPELL_SHORTCUT_0,
BATTLE_SPELL_SHORTCUT_1, BATTLE_SPELL_SHORTCUT_1,
BATTLE_SPELL_SHORTCUT_2, BATTLE_SPELL_SHORTCUT_2,

View File

@@ -222,6 +222,7 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const
{"battleTacticsNext", EShortcut::BATTLE_TACTICS_NEXT }, {"battleTacticsNext", EShortcut::BATTLE_TACTICS_NEXT },
{"battleTacticsEnd", EShortcut::BATTLE_TACTICS_END }, {"battleTacticsEnd", EShortcut::BATTLE_TACTICS_END },
{"battleSelectAction", EShortcut::BATTLE_SELECT_ACTION }, {"battleSelectAction", EShortcut::BATTLE_SELECT_ACTION },
{"battleToggleQuickSpell", EShortcut::BATTLE_TOGGLE_QUICKSPELL },
{"battleSpellShortcut0", EShortcut::BATTLE_SPELL_SHORTCUT_0 }, {"battleSpellShortcut0", EShortcut::BATTLE_SPELL_SHORTCUT_0 },
{"battleSpellShortcut1", EShortcut::BATTLE_SPELL_SHORTCUT_1 }, {"battleSpellShortcut1", EShortcut::BATTLE_SPELL_SHORTCUT_1 },
{"battleSpellShortcut2", EShortcut::BATTLE_SPELL_SHORTCUT_2 }, {"battleSpellShortcut2", EShortcut::BATTLE_SPELL_SHORTCUT_2 },

View File

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

View File

@@ -64,6 +64,7 @@
"battleOpenHoveredUnit": "V", "battleOpenHoveredUnit": "V",
"battleRetreat": "R", "battleRetreat": "R",
"battleSelectAction": "S", "battleSelectAction": "S",
"battleToggleQuickSpell": "T",
"battleSpellShortcut0": "0", "battleSpellShortcut0": "0",
"battleSpellShortcut1": "1", "battleSpellShortcut1": "1",
"battleSpellShortcut2": "2", "battleSpellShortcut2": "2",