mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Add settings entry, immediately refresh info bar on setting toggle
This commit is contained in:
parent
f8fbafff2f
commit
fe26ab4501
@ -87,6 +87,8 @@
|
||||
"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.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.mapScrollSpeed5.hover": "",
|
||||
"vcmi.adventureOptions.mapScrollSpeed6.hover": "",
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../gui/WindowHandler.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
#include "../../lib/CConfigHandler.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||
@ -52,7 +53,7 @@ CInfoBar::VisibleHeroInfo::VisibleHeroInfo(const CGHeroInstance * hero)
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
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);
|
||||
else
|
||||
heroTooltip = std::make_shared<CHeroTooltip>(Point(0,0), hero);
|
||||
@ -63,7 +64,7 @@ CInfoBar::VisibleTownInfo::VisibleTownInfo(const CGTownInstance * town)
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
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);
|
||||
else
|
||||
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(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool())
|
||||
if(settings["gameTweaks"]["infoBarCreatureManagement"].Bool())
|
||||
return;
|
||||
|
||||
showGameStatus();
|
||||
@ -313,11 +314,13 @@ void CInfoBar::hover(bool on)
|
||||
CInfoBar::CInfoBar(const Rect & position)
|
||||
: CIntObject(LCLICK | SHOW_POPUP | HOVER, position.topLeft()),
|
||||
timerCounter(0),
|
||||
state(EMPTY)
|
||||
state(EMPTY),
|
||||
listener(settings.listen["gameTweaks"]["infoBarCreatureManagement"])
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
pos.w = position.w;
|
||||
pos.h = position.h;
|
||||
listener(std::bind(&CInfoBar::OnInfoBarCreatureManagementChanged, this));
|
||||
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)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../gui/CIntObject.h"
|
||||
#include "CConfigHandler.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
@ -142,6 +143,7 @@ private:
|
||||
EState state;
|
||||
uint32_t timerCounter;
|
||||
bool shouldPopAll = false;
|
||||
SettingsListener listener;
|
||||
|
||||
std::queue<std::pair<VisibleComponentInfo::Cache, int>> componentsQueue;
|
||||
|
||||
@ -193,5 +195,8 @@ public:
|
||||
|
||||
/// check if infobar is showed something about pickups
|
||||
bool showingComponents();
|
||||
|
||||
/// event handler for custom listening on game setting change
|
||||
void OnInfoBarCreatureManagementChanged();
|
||||
};
|
||||
|
||||
|
@ -110,9 +110,9 @@ AdventureOptionsTab::AdventureOptionsTab()
|
||||
{
|
||||
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);
|
||||
|
||||
@ -146,6 +146,6 @@ AdventureOptionsTab::AdventureOptionsTab()
|
||||
std::shared_ptr<CToggleButton> borderScrollCheckbox = widget<CToggleButton>("borderScrollCheckbox");
|
||||
borderScrollCheckbox->setSelected(settings["adventure"]["borderScroll"].Bool());
|
||||
|
||||
std::shared_ptr<CToggleButton> infoBoxCreatureManagementCheckbox = widget<CToggleButton>("infoBoxCreatureManagementCheckbox");
|
||||
infoBoxCreatureManagementCheckbox->setSelected(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool());
|
||||
std::shared_ptr<CToggleButton> infoBarCreatureManagementCheckbox = widget<CToggleButton>("infoBarCreatureManagementCheckbox");
|
||||
infoBarCreatureManagementCheckbox->setSelected(settings["gameTweaks"]["infoBarCreatureManagement"].Bool());
|
||||
}
|
||||
|
@ -499,7 +499,8 @@
|
||||
"availableCreaturesAsDwellingLabel",
|
||||
"compactTownCreatureInfo",
|
||||
"infoBarPick",
|
||||
"skipBattleIntroMusic"
|
||||
"skipBattleIntroMusic",
|
||||
"infoBarCreatureManagement"
|
||||
],
|
||||
"properties" : {
|
||||
"showGrid" : {
|
||||
@ -529,6 +530,10 @@
|
||||
"skipBattleIntroMusic" : {
|
||||
"type" : "boolean",
|
||||
"default" : false
|
||||
},
|
||||
"infoBarCreatureManagement": {
|
||||
"type" : "boolean",
|
||||
"default" : false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -375,9 +375,9 @@
|
||||
"callback": "borderScrollChanged"
|
||||
},
|
||||
{
|
||||
"name": "infoBoxCreatureManagementCheckbox",
|
||||
"help": "vcmi.adventureOptions.infoBoxCreatureManagement",
|
||||
"callback": "infoBoxCreatureManagementChanged"
|
||||
"name": "infoBarCreatureManagementCheckbox",
|
||||
"help": "vcmi.adventureOptions.infoBarCreatureManagement",
|
||||
"callback": "infoBarCreatureManagementChanged"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user