1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-05-13 22:06:58 +02:00

Add settings entry, immediately refresh info bar on setting toggle

This commit is contained in:
Dydzio 2023-07-16 14:52:43 +02:00
parent f8fbafff2f
commit fe26ab4501
6 changed files with 31 additions and 12 deletions

View File

@ -87,6 +87,8 @@
"vcmi.adventureOptions.showGrid.help" : "{Show Grid}\n\nShow the grid overlay, highlighting the borders between adventure map tiles.", "vcmi.adventureOptions.showGrid.help" : "{Show Grid}\n\nShow the grid overlay, highlighting the borders between adventure map tiles.",
"vcmi.adventureOptions.borderScroll.hover" : "Border Scrolling", "vcmi.adventureOptions.borderScroll.hover" : "Border Scrolling",
"vcmi.adventureOptions.borderScroll.help" : "{Border Scrolling}\n\nScroll adventure map when cursor is adjacent to window edge. Can be disabled by holding down CTRL key.", "vcmi.adventureOptions.borderScroll.help" : "{Border Scrolling}\n\nScroll adventure map when cursor is adjacent to window edge. Can be disabled by holding down CTRL key.",
"vcmi.adventureOptions.infoBarCreatureManagement.hover" : "Info Panel Creature Management",
"vcmi.adventureOptions.infoBarCreatureManagement.help" : "{Info Panel Creature Management}\n\nAllows rearranging creatures in info panel instead of cycling between default components",
"vcmi.adventureOptions.mapScrollSpeed1.hover": "", "vcmi.adventureOptions.mapScrollSpeed1.hover": "",
"vcmi.adventureOptions.mapScrollSpeed5.hover": "", "vcmi.adventureOptions.mapScrollSpeed5.hover": "",
"vcmi.adventureOptions.mapScrollSpeed6.hover": "", "vcmi.adventureOptions.mapScrollSpeed6.hover": "",

View File

@ -27,6 +27,7 @@
#include "../gui/WindowHandler.h" #include "../gui/WindowHandler.h"
#include "../../CCallback.h" #include "../../CCallback.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CGeneralTextHandler.h" #include "../../lib/CGeneralTextHandler.h"
#include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/mapObjects/CGTownInstance.h" #include "../../lib/mapObjects/CGTownInstance.h"
@ -52,7 +53,7 @@ CInfoBar::VisibleHeroInfo::VisibleHeroInfo(const CGHeroInstance * hero)
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
background = std::make_shared<CPicture>("ADSTATHR"); background = std::make_shared<CPicture>("ADSTATHR");
if(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool()) if(settings["gameTweaks"]["infoBarCreatureManagement"].Bool())
heroTooltip = std::make_shared<CInteractableHeroTooltip>(Point(0,0), hero); heroTooltip = std::make_shared<CInteractableHeroTooltip>(Point(0,0), hero);
else else
heroTooltip = std::make_shared<CHeroTooltip>(Point(0,0), hero); heroTooltip = std::make_shared<CHeroTooltip>(Point(0,0), hero);
@ -63,7 +64,7 @@ CInfoBar::VisibleTownInfo::VisibleTownInfo(const CGTownInstance * town)
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
background = std::make_shared<CPicture>("ADSTATCS"); background = std::make_shared<CPicture>("ADSTATCS");
if(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool()) if(settings["gameTweaks"]["infoBarCreatureManagement"].Bool())
townTooltip = std::make_shared<CInteractableTownTooltip>(Point(0,0), town); townTooltip = std::make_shared<CInteractableTownTooltip>(Point(0,0), town);
else else
townTooltip = std::make_shared<CTownTooltip>(Point(0,0), town); townTooltip = std::make_shared<CTownTooltip>(Point(0,0), town);
@ -286,7 +287,7 @@ void CInfoBar::clickReleased(const Point & cursorPosition)
if(state == HERO || state == TOWN) if(state == HERO || state == TOWN)
{ {
if(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool()) if(settings["gameTweaks"]["infoBarCreatureManagement"].Bool())
return; return;
showGameStatus(); showGameStatus();
@ -313,11 +314,13 @@ void CInfoBar::hover(bool on)
CInfoBar::CInfoBar(const Rect & position) CInfoBar::CInfoBar(const Rect & position)
: CIntObject(LCLICK | SHOW_POPUP | HOVER, position.topLeft()), : CIntObject(LCLICK | SHOW_POPUP | HOVER, position.topLeft()),
timerCounter(0), timerCounter(0),
state(EMPTY) state(EMPTY),
listener(settings.listen["gameTweaks"]["infoBarCreatureManagement"])
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
pos.w = position.w; pos.w = position.w;
pos.h = position.h; pos.h = position.h;
listener(std::bind(&CInfoBar::OnInfoBarCreatureManagementChanged, this));
reset(); reset();
} }
@ -325,6 +328,10 @@ CInfoBar::CInfoBar(const Point & position): CInfoBar(Rect(position.x, position.y
{ {
} }
void CInfoBar::OnInfoBarCreatureManagementChanged()
{
showSelection();
}
void CInfoBar::setTimer(uint32_t msToTrigger) void CInfoBar::setTimer(uint32_t msToTrigger)
{ {

View File

@ -10,6 +10,7 @@
#pragma once #pragma once
#include "../gui/CIntObject.h" #include "../gui/CIntObject.h"
#include "CConfigHandler.h"
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
@ -142,6 +143,7 @@ private:
EState state; EState state;
uint32_t timerCounter; uint32_t timerCounter;
bool shouldPopAll = false; bool shouldPopAll = false;
SettingsListener listener;
std::queue<std::pair<VisibleComponentInfo::Cache, int>> componentsQueue; std::queue<std::pair<VisibleComponentInfo::Cache, int>> componentsQueue;
@ -193,5 +195,8 @@ public:
/// check if infobar is showed something about pickups /// check if infobar is showed something about pickups
bool showingComponents(); bool showingComponents();
/// event handler for custom listening on game setting change
void OnInfoBarCreatureManagementChanged();
}; };

View File

@ -110,9 +110,9 @@ AdventureOptionsTab::AdventureOptionsTab()
{ {
return setBoolSetting("adventure", "borderScroll", value); return setBoolSetting("adventure", "borderScroll", value);
}); });
addCallback("infoBoxCreatureManagementChanged", [](bool value) addCallback("infoBarCreatureManagementChanged", [](bool value)
{ {
return setBoolSetting("gameTweaks", "infoBoxCreatureManagement", value); return setBoolSetting("gameTweaks", "infoBarCreatureManagement", value);
}); });
build(config); build(config);
@ -146,6 +146,6 @@ AdventureOptionsTab::AdventureOptionsTab()
std::shared_ptr<CToggleButton> borderScrollCheckbox = widget<CToggleButton>("borderScrollCheckbox"); std::shared_ptr<CToggleButton> borderScrollCheckbox = widget<CToggleButton>("borderScrollCheckbox");
borderScrollCheckbox->setSelected(settings["adventure"]["borderScroll"].Bool()); borderScrollCheckbox->setSelected(settings["adventure"]["borderScroll"].Bool());
std::shared_ptr<CToggleButton> infoBoxCreatureManagementCheckbox = widget<CToggleButton>("infoBoxCreatureManagementCheckbox"); std::shared_ptr<CToggleButton> infoBarCreatureManagementCheckbox = widget<CToggleButton>("infoBarCreatureManagementCheckbox");
infoBoxCreatureManagementCheckbox->setSelected(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool()); infoBarCreatureManagementCheckbox->setSelected(settings["gameTweaks"]["infoBarCreatureManagement"].Bool());
} }

View File

@ -499,7 +499,8 @@
"availableCreaturesAsDwellingLabel", "availableCreaturesAsDwellingLabel",
"compactTownCreatureInfo", "compactTownCreatureInfo",
"infoBarPick", "infoBarPick",
"skipBattleIntroMusic" "skipBattleIntroMusic",
"infoBarCreatureManagement"
], ],
"properties" : { "properties" : {
"showGrid" : { "showGrid" : {
@ -529,6 +530,10 @@
"skipBattleIntroMusic" : { "skipBattleIntroMusic" : {
"type" : "boolean", "type" : "boolean",
"default" : false "default" : false
},
"infoBarCreatureManagement": {
"type" : "boolean",
"default" : false
} }
} }
} }

View File

@ -375,9 +375,9 @@
"callback": "borderScrollChanged" "callback": "borderScrollChanged"
}, },
{ {
"name": "infoBoxCreatureManagementCheckbox", "name": "infoBarCreatureManagementCheckbox",
"help": "vcmi.adventureOptions.infoBoxCreatureManagement", "help": "vcmi.adventureOptions.infoBarCreatureManagement",
"callback": "infoBoxCreatureManagementChanged" "callback": "infoBarCreatureManagementChanged"
} }
] ]
} }