1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Further progress - UI tweaks, new settings etc

This commit is contained in:
Dydzio
2023-02-14 20:30:06 +01:00
parent 80a5595d6c
commit fb06aca0bb
24 changed files with 277 additions and 36 deletions

View File

@@ -28,11 +28,15 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner):
addCallback("movementShadowChanged", std::bind(&BattleOptionsTab::movementShadowChangedCallback, this, _1, owner));
addCallback("mouseShadowChanged", std::bind(&BattleOptionsTab::mouseShadowChangedCallback, this, _1));
addCallback("animationSpeedChanged", std::bind(&BattleOptionsTab::animationSpeedChangedCallback, this, _1));
addCallback("showQueueChanged", std::bind(&BattleOptionsTab::showQueueChangedCallback, this, _1));
addCallback("queueSizeChanged", std::bind(&BattleOptionsTab::queueSizeChangedCallback, this, _1));
build(config);
std::shared_ptr<CToggleGroup> animationSpeedToggle = widget<CToggleGroup>("animationSpeedPicker");
animationSpeedToggle->setSelected(getAnimSpeed());
std::shared_ptr<CToggleGroup> queueSizeToggle = widget<CToggleGroup>("queueSizePicker");
queueSizeToggle->setSelected(getQueueSizeId());
std::shared_ptr<CToggleButton> viewGridCheckbox = widget<CToggleButton>("viewGridCheckbox");
viewGridCheckbox->setSelected((bool)settings["battle"]["cellBorders"].Bool());
@@ -42,6 +46,9 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner):
std::shared_ptr<CToggleButton> mouseShadowCheckbox = widget<CToggleButton>("mouseShadowCheckbox");
mouseShadowCheckbox->setSelected((bool)settings["battle"]["mouseShadow"].Bool());
std::shared_ptr<CToggleButton> showQueueCheckbox = widget<CToggleButton>("showQueueCheckbox");
showQueueCheckbox->setSelected((bool)settings["battle"]["showQueue"].Bool());
}
int BattleOptionsTab::getAnimSpeed() const
@@ -52,6 +59,34 @@ int BattleOptionsTab::getAnimSpeed() const
return static_cast<int>(std::round(settings["battle"]["speedFactor"].Float()));
}
int BattleOptionsTab::getQueueSizeId() const
{
std::string text = settings["battle"]["queueSize"].String();
if(text == "auto")
return 0;
else if(text == "small")
return 1;
else if(text == "big")
return 2;
return 0;
}
std::string BattleOptionsTab::getQueueSizeStringFromId(int value) const
{
switch(value)
{
case 0:
return "auto";
case 1:
return "small";
case 2:
return "big";
default:
return "auto";
}
}
void BattleOptionsTab::viewGridChangedCallback(bool value, BattleInterface * parentBattleInterface)
{
Settings cellBorders = settings.write["battle"]["cellBorders"];
@@ -80,3 +115,16 @@ void BattleOptionsTab::animationSpeedChangedCallback(int value)
speed->Float() = float(value);
}
void BattleOptionsTab::showQueueChangedCallback(bool value)
{
Settings shadow = settings.write["battle"]["showQueue"];
shadow->Bool() = value;
}
void BattleOptionsTab::queueSizeChangedCallback(int value)
{
std::string stringifiedValue = getQueueSizeStringFromId(value);
Settings size = settings.write["battle"]["queueSize"];
size->String() = stringifiedValue;
}