1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Basic separation of adventure map & general tabs

This commit is contained in:
Dydzio
2023-02-12 19:25:59 +01:00
parent 58bed920b4
commit de5138c854
8 changed files with 287 additions and 221 deletions

View File

@@ -7,10 +7,53 @@
* Full text of license available in license.txt file, in main folder * Full text of license available in license.txt file, in main folder
* *
*/ */
#include "StdInc.h"
#include "AdventureOptionsTab.h" #include "AdventureOptionsTab.h"
AdventureOptionsTab::AdventureOptionsTab() #include "../../../lib/filesystem/ResourceID.h"
{ #include "../../gui/CGuiHandler.h"
#include "../../widgets/Buttons.h"
#include "../../widgets/TextControls.h"
#include "../../widgets/Images.h"
#include "CConfigHandler.h"
static void setBoolSetting(std::string group, std::string field, bool value)
{
Settings fullscreen = settings.write[group][field];
fullscreen->Bool() = value;
}
static void setIntSetting(std::string group, std::string field, int value)
{
Settings entry = settings.write[group][field];
entry->Float() = value;
}
AdventureOptionsTab::AdventureOptionsTab()
: InterfaceObjectConfigurable()
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/settings/adventureOptionsTab.json"));
addCallback("playerHeroSpeedChanged", std::bind(&setIntSetting, "adventure", "heroSpeed", _1));
addCallback("enemyHeroSpeedChanged", std::bind(&setIntSetting, "adventure", "enemySpeed", _1));
addCallback("mapScrollSpeedChanged", std::bind(&setIntSetting, "adventure", "scrollSpeed", _1));
addCallback("heroReminderChanged", std::bind(&setBoolSetting, "adventure", "heroReminder", _1));
addCallback("quickCombatChanged", std::bind(&setBoolSetting, "adventure", "quickCombat", _1));
build(config);
std::shared_ptr<CToggleGroup> playerHeroSpeedToggle = widget<CToggleGroup>("heroMovementSpeedPicker");
playerHeroSpeedToggle->setSelected((int)settings["adventure"]["heroSpeed"].Float());
std::shared_ptr<CToggleGroup> enemyHeroSpeedToggle = widget<CToggleGroup>("enemyMovementSpeedPicker");
enemyHeroSpeedToggle->setSelected((int)settings["adventure"]["enemySpeed"].Float());
std::shared_ptr<CToggleGroup> mapScrollSpeedToggle = widget<CToggleGroup>("mapScrollSpeedPicker");
mapScrollSpeedToggle->setSelected((int)settings["adventure"]["scrollSpeed"].Float());
std::shared_ptr<CToggleButton> heroReminderCheckbox = widget<CToggleButton>("heroReminderCheckbox");
heroReminderCheckbox->setSelected((bool)settings["adventure"]["heroReminder"].Bool());
std::shared_ptr<CToggleButton> quickCombatCheckbox = widget<CToggleButton>("quickCombatCheckbox");
quickCombatCheckbox->setSelected((bool)settings["adventure"]["quickCombat"].Bool());
} }

View File

@@ -11,7 +11,7 @@
#include "../../gui/InterfaceObjectConfigurable.h" #include "../../gui/InterfaceObjectConfigurable.h"
class AdventureOptionsTab : InterfaceObjectConfigurable class AdventureOptionsTab : public InterfaceObjectConfigurable
{ {
public: public:
AdventureOptionsTab(); AdventureOptionsTab();

View File

@@ -53,11 +53,6 @@ GeneralOptionsTab::GeneralOptionsTab()
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/settings/generalOptionsTab.json")); const JsonNode config(ResourceID("config/widgets/settings/generalOptionsTab.json"));
addCallback("playerHeroSpeedChanged", std::bind(&setIntSetting, "adventure", "heroSpeed", _1));
addCallback("enemyHeroSpeedChanged", std::bind(&setIntSetting, "adventure", "enemySpeed", _1));
addCallback("mapScrollSpeedChanged", std::bind(&setIntSetting, "adventure", "scrollSpeed", _1));
addCallback("heroReminderChanged", std::bind(&setBoolSetting, "adventure", "heroReminder", _1));
addCallback("quickCombatChanged", std::bind(&setBoolSetting, "adventure", "quickCombat", _1));
addCallback("spellbookAnimationChanged", std::bind(&setBoolSetting, "video", "spellbookAnimation", _1)); addCallback("spellbookAnimationChanged", std::bind(&setBoolSetting, "video", "spellbookAnimation", _1));
addCallback("fullscreenChanged", std::bind(&GeneralOptionsTab::setFullscreenMode, this, _1)); addCallback("fullscreenChanged", std::bind(&GeneralOptionsTab::setFullscreenMode, this, _1));
addCallback("setGameResolution", std::bind(&GeneralOptionsTab::selectGameResolution, this)); addCallback("setGameResolution", std::bind(&GeneralOptionsTab::selectGameResolution, this));
@@ -70,22 +65,6 @@ GeneralOptionsTab::GeneralOptionsTab()
resolutionLabel->setText(resolutionToString(currentResolution["width"].Integer(), currentResolution["height"].Integer())); resolutionLabel->setText(resolutionToString(currentResolution["width"].Integer(), currentResolution["height"].Integer()));
std::shared_ptr<CToggleGroup> playerHeroSpeedToggle = widget<CToggleGroup>("heroMovementSpeedPicker");
playerHeroSpeedToggle->setSelected((int)settings["adventure"]["heroSpeed"].Float());
std::shared_ptr<CToggleGroup> enemyHeroSpeedToggle = widget<CToggleGroup>("enemyMovementSpeedPicker");
enemyHeroSpeedToggle->setSelected((int)settings["adventure"]["enemySpeed"].Float());
std::shared_ptr<CToggleGroup> mapScrollSpeedToggle = widget<CToggleGroup>("mapScrollSpeedPicker");
mapScrollSpeedToggle->setSelected((int)settings["adventure"]["scrollSpeed"].Float());
std::shared_ptr<CToggleButton> heroReminderCheckbox = widget<CToggleButton>("heroReminderCheckbox");
heroReminderCheckbox->setSelected((bool)settings["adventure"]["heroReminder"].Bool());
std::shared_ptr<CToggleButton> quickCombatCheckbox = widget<CToggleButton>("quickCombatCheckbox");
quickCombatCheckbox->setSelected((bool)settings["adventure"]["quickCombat"].Bool());
std::shared_ptr<CToggleButton> spellbookAnimationCheckbox = widget<CToggleButton>("spellbookAnimationCheckbox"); std::shared_ptr<CToggleButton> spellbookAnimationCheckbox = widget<CToggleButton>("spellbookAnimationCheckbox");
spellbookAnimationCheckbox->setSelected((bool)settings["video"]["spellbookAnimation"].Bool()); spellbookAnimationCheckbox->setSelected((bool)settings["video"]["spellbookAnimation"].Bool());

View File

@@ -14,8 +14,9 @@
#include "SettingsMainContainer.h" #include "SettingsMainContainer.h"
#include "GeneralOptionsTab.h" #include "GeneralOptionsTab.h"
#include "VcmiSettingsWindow.h" #include "AdventureOptionsTab.h"
#include "BattleOptionsTab.h" #include "BattleOptionsTab.h"
#include "VcmiSettingsWindow.h"
#include "filesystem/ResourceID.h" #include "filesystem/ResourceID.h"
#include "CGeneralTextHandler.h" #include "CGeneralTextHandler.h"
@@ -32,9 +33,10 @@ SettingsMainContainer::SettingsMainContainer(BattleInterface * parentBattleUi) :
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/settings/settingsMainContainer.json")); const JsonNode config(ResourceID("config/widgets/settings/settingsMainContainer.json"));
addCallback("activateMainTab", [this](int) { openTab(0); }); addCallback("activateGeneralTab", [this](int) { openTab(0); });
addCallback("activateBattleSettingsTab", [this](int) { openTab(1); }); addCallback("activateAdventureTab", [this](int) { openTab(1); });
addCallback("activateVcmiSettingsTab", [this](int) { openTab(2); }); addCallback("activateBattleTab", [this](int) { openTab(2); });
addCallback("activateVcmiSettingsTab", [this](int) { openTab(3); });
addCallback("loadGame", [this](int) { loadGameButtonCallback(); }); addCallback("loadGame", [this](int) { loadGameButtonCallback(); });
addCallback("saveGame", [this](int) { saveGameButtonCallback(); }); addCallback("saveGame", [this](int) { saveGameButtonCallback(); });
@@ -80,8 +82,10 @@ std::shared_ptr<CIntObject> SettingsMainContainer::createTab(size_t index)
case 0: case 0:
return std::make_shared<GeneralOptionsTab>(); return std::make_shared<GeneralOptionsTab>();
case 1: case 1:
return std::make_shared<BattleOptionsTab>(parentBattleInterface); return std::make_shared<AdventureOptionsTab>();
case 2: case 2:
return std::make_shared<BattleOptionsTab>(parentBattleInterface);
case 3:
return std::make_shared<VcmiSettingsWindow>(); return std::make_shared<VcmiSettingsWindow>();
default: default:
logGlobal->error("Wrong settings tab ID!"); logGlobal->error("Wrong settings tab ID!");

View File

@@ -0,0 +1,206 @@
{
"items":
[
{
"name": "leftSettingsLabels",
"type": "labelGroup",
"font": "medium",
"alignment": "center",
"color": "yellow",
"items":
[
{
"position": {"x": 122, "y": 32},
"text": "core.genrltxt.569"
},
{
"position": {"x": 122, "y": 98},
"text": "core.genrltxt.570"
},
{
"position": {"x": 122, "y": 164},
"text": "core.genrltxt.571"
}
]
},
{
"name": "rightSideCheckboxesLabels",
"type": "labelGroup",
"font": "medium",
"alignment": "left",
"color": "white",
"items":
[
{
"position": {"x": 64, "y": 258},
"text": "core.genrltxt.572"
},
{
"position": {"x": 64, "y": 294},
"text": "core.genrltxt.573"
},
{
"position": {"x": 64, "y": 330},
"text": "core.genrltxt.574"
}
]
},
{
"name": "heroMovementSpeedPicker",
"type": "toggleGroup",
"position": {"x": 28, "y": 45},
"items":
[
{
"index": 1,
"type": "toggleButton",
"image": "sysopb1",
"help": "core.help.349",
"position": {"x": 0, "y": 0}
},
{
"index": 2,
"type": "toggleButton",
"image": "sysopb2",
"help": "core.help.350",
"position": {"x": 48, "y": 0}
},
{
"index": 4,
"type": "toggleButton",
"image": "sysopb3",
"help": "core.help.351",
"position": {"x": 96, "y": 0}
},
{
"index": 16,
"type": "toggleButton",
"image": "sysopb4",
"help": "core.help.352",
"position": {"x": 144, "y": 0}
},
{
"index": 9999,
"type": "toggleButton",
"image": "sysopb8",
"help": "core.help.356",
"position": {"x": 192, "y": 0}
}
],
"callback": "playerHeroSpeedChanged"
},
{
"name": "enemyMovementSpeedPicker",
"type": "toggleGroup",
"position": {"x": 28, "y": 112},
"items":
[
{
"index": 2,
"type": "toggleButton",
"image": "sysopb5",
"help": "core.help.353",
"position": {"x": 0, "y": 0}
},
{
"index": 4,
"type": "toggleButton",
"image": "sysopb6",
"help": "core.help.354",
"position": {"x": 48, "y": 0}
},
{
"index": 8,
"type": "toggleButton",
"image": "sysopb7",
"help": "core.help.355",
"position": {"x": 96, "y": 0}
},
{
"index": 0,
"type": "toggleButton",
"image": "sysopb8",
"help": "core.help.356",
"position": {"x": 144, "y": 0}
}
],
"callback": "enemyHeroSpeedChanged"
},
{
"name": "mapScrollSpeedPicker",
"type": "toggleGroup",
"position": {"x": 28, "y": 178},
"items":
[
{
"index": 1,
"type": "toggleButton",
"image": "sysopb9",
"help": "core.help.357",
"position": {"x": 0, "y": 0}
},
{
"index": 2,
"type": "toggleButton",
"image": "sysob10",
"help": "core.help.358",
"position": {"x": 64, "y": 0}
},
{
"index": 4,
"type": "toggleButton",
"image": "sysob11",
"help": "core.help.359",
"position": {"x": 128, "y": 0}
},
{
"index": 6,
"type": "toggleButton",
"image": "sysob11",
"help": "core.help.359",
"position": {"x": 192, "y": 0}
},
{
"index": 8,
"type": "toggleButton",
"image": "sysob11",
"help": "core.help.359",
"position": {"x": 256, "y": 0}
}
],
"callback": "mapScrollSpeedChanged"
},
{
"name": "heroReminderCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "core.help.361",
"position": {"x": 28, "y": 292},
"callback": "heroReminderChanged"
},
{
"name": "quickCombatCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "core.help.362",
"position": {"x": 28, "y": 328},
"callback": "quickCombatChanged"
}
]
}

View File

@@ -20,24 +20,6 @@
"text": "core.genrltxt.393", "text": "core.genrltxt.393",
"position": {"x": 122, "y": 214} "position": {"x": 122, "y": 214}
}, },
{
"name": "musicVolumeLabel",
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow",
"text": "core.genrltxt.394",
"position": {"x": 122, "y": 293}
},
{
"name": "effectsVolumeLabel",
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow",
"text": "core.genrltxt.395",
"position": {"x": 122, "y": 359}
},
{ {
"name": "autoCombatOptionsLabel", "name": "autoCombatOptionsLabel",
"type": "label", "type": "label",

View File

@@ -20,27 +20,15 @@
"items": "items":
[ [
{ {
"position": {"x": 122, "y": 64}, "position": {"x": 122, "y": 30},
"text": "core.genrltxt.569"
},
{
"position": {"x": 122, "y": 130},
"text": "core.genrltxt.570"
},
{
"position": {"x": 122, "y": 196},
"text": "core.genrltxt.571"
},
{
"position": {"x": 122, "y": 262},
"text": "vcmi.systemOptions.resolutionButton.hover" "text": "vcmi.systemOptions.resolutionButton.hover"
}, },
{ {
"position": {"x": 122, "y": 347}, "position": {"x": 122, "y": 115},
"text": "core.genrltxt.394" "text": "core.genrltxt.394"
}, },
{ {
"position": {"x": 122, "y": 412}, "position": {"x": 122, "y": 180},
"text": "core.genrltxt.395" "text": "core.genrltxt.395"
} }
] ]
@@ -55,167 +43,22 @@
"items": "items":
[ [
{ {
"position": {"x": 282, "y": 57}, "position": {"x": 64, "y": 258},
"text": "core.genrltxt.572"
},
{
"position": {"x": 282, "y": 89},
"text": "core.genrltxt.573"
},
{
"position": {"x": 282, "y": 121},
"text": "core.genrltxt.574"
},
{
"position": {"x": 282, "y": 153},
"text": "core.genrltxt.577" "text": "core.genrltxt.577"
}, },
{ {
"position": {"x": 282, "y": 217}, "position": {"x": 64, "y": 294},
"text": "vcmi.systemOptions.fullscreenButton.hover" "text": "vcmi.systemOptions.fullscreenButton.hover"
} }
] ]
}, },
{
"name": "heroMovementSpeedPicker",
"type": "toggleGroup",
"position": {"x": 28, "y": 77},
"items":
[
{
"index": 1,
"type": "toggleButton",
"image": "sysopb1",
"help": "core.help.349",
"position": {"x": 0, "y": 0}
},
{
"index": 2,
"type": "toggleButton",
"image": "sysopb2",
"help": "core.help.350",
"position": {"x": 48, "y": 0}
},
{
"index": 4,
"type": "toggleButton",
"image": "sysopb3",
"help": "core.help.351",
"position": {"x": 96, "y": 0}
},
{
"index": 8,
"type": "toggleButton",
"image": "sysopb4",
"help": "core.help.352",
"position": {"x": 144, "y": 0}
}
],
"callback": "playerHeroSpeedChanged"
},
{
"name": "enemyMovementSpeedPicker",
"type": "toggleGroup",
"position": {"x": 28, "y": 144},
"items":
[
{
"index": 2,
"type": "toggleButton",
"image": "sysopb5",
"help": "core.help.353",
"position": {"x": 0, "y": 0}
},
{
"index": 4,
"type": "toggleButton",
"image": "sysopb6",
"help": "core.help.354",
"position": {"x": 48, "y": 0}
},
{
"index": 8,
"type": "toggleButton",
"image": "sysopb7",
"help": "core.help.355",
"position": {"x": 96, "y": 0}
},
{
"index": 0,
"type": "toggleButton",
"image": "sysopb8",
"help": "core.help.356",
"position": {"x": 144, "y": 0}
}
],
"callback": "enemyHeroSpeedChanged"
},
{
"name": "mapScrollSpeedPicker",
"type": "toggleGroup",
"position": {"x": 28, "y": 210},
"items":
[
{
"index": 1,
"type": "toggleButton",
"image": "sysopb9",
"help": "core.help.357",
"position": {"x": 0, "y": 0}
},
{
"index": 2,
"type": "toggleButton",
"image": "sysob10",
"help": "core.help.358",
"position": {"x": 64, "y": 0}
},
{
"index": 4,
"type": "toggleButton",
"image": "sysob11",
"help": "core.help.359",
"position": {"x": 128, "y": 0}
}
],
"callback": "mapScrollSpeedChanged"
},
{
"name": "heroReminderCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "core.help.361",
"position": {"x": 246, "y": 87},
"callback": "heroReminderChanged"
},
{
"name": "quickCombatCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "core.help.362",
"position": {"x": 246, "y": 119},
"callback": "quickCombatChanged"
},
{ {
"name": "spellbookAnimationCheckbox", "name": "spellbookAnimationCheckbox",
"type": "toggleButton", "type": "toggleButton",
"image": "sysopchk.def", "image": "sysopchk.def",
"help": "core.help.364", "help": "core.help.364",
"position": {"x": 246, "y": 151}, "position": {"x": 28, "y": 256},
"callback": "spellbookAnimationChanged" "callback": "spellbookAnimationChanged"
}, },
@@ -224,14 +67,14 @@
"type": "toggleButton", "type": "toggleButton",
"image": "sysopchk.def", "image": "sysopchk.def",
"help": "vcmi.systemOptions.fullscreenButton", "help": "vcmi.systemOptions.fullscreenButton",
"position": {"x": 246, "y": 215}, "position": {"x": 28, "y": 292},
"callback": "fullscreenChanged" "callback": "fullscreenChanged"
}, },
{ {
"name": "resolutionButton", "name": "resolutionButton",
"type": "button", "type": "button",
"position": {"x": 28, "y": 275}, "position": {"x": 28, "y": 43},
"image": "buttons/resolution", "image": "buttons/resolution",
"help": "vcmi.systemOptions.resolutionButton", "help": "vcmi.systemOptions.resolutionButton",
"callback": "setGameResolution", "callback": "setGameResolution",
@@ -244,13 +87,13 @@
"font": "medium", "font": "medium",
"alignment": "center", "alignment": "center",
"color": "yellow", "color": "yellow",
"position": {"x": 170, "y": 292} "position": {"x": 170, "y": 60}
}, },
{ {
"name": "musicSlider", "name": "musicSlider",
"type": "slider", "type": "slider",
"position": {"x": 29, "y": 359}, "position": {"x": 29, "y": 127},
"size": 190, "size": 190,
"style": "brown", "style": "brown",
"orientation": "horizontal", "orientation": "horizontal",
@@ -262,7 +105,7 @@
{ {
"name": "soundVolumeSlider", "name": "soundVolumeSlider",
"type": "slider", "type": "slider",
"position": {"x": 29, "y": 425}, "position": {"x": 29, "y": 193},
"size": 190, "size": 190,
"style": "brown", "style": "brown",
"orientation": "horizontal", "orientation": "horizontal",

View File

@@ -9,27 +9,36 @@
}, },
{ {
"name": "activateSystemOptionsButton", "name": "activateGeneralOptionsButton",
"type": "button", "type": "button",
"position": {"x": 0, "y": 0}, "position": {"x": 0, "y": 0},
"image": "buttons/vcmisettings", "image": "buttons/vcmisettings",
"help": "TODO", "help": "TODO",
"callback": "activateMainTab" "callback": "activateGeneralTab"
}, },
{ {
"name": "activateBattleSettingsButton", "name": "activateAdventureOptionsButton",
"type": "button", "type": "button",
"position": {"x": 220, "y": 0}, "position": {"x": 200, "y": 0},
"image": "buttons/vcmisettings", "image": "buttons/vcmisettings",
"help": "TODO", "help": "TODO",
"callback": "activateBattleSettingsTab" "callback": "activateAdventureTab"
},
{
"name": "activateBattleOptionsButton",
"type": "button",
"position": {"x": 400, "y": 0},
"image": "buttons/vcmisettings",
"help": "TODO",
"callback": "activateBattleTab"
}, },
{ {
"name": "activateVcmiSettingsButton", "name": "activateVcmiSettingsButton",
"type": "button", "type": "button",
"position": {"x": 440, "y": 0}, "position": {"x": 600, "y": 0},
"image": "buttons/vcmisettings", "image": "buttons/vcmisettings",
"help": "TODO", "help": "TODO",
"callback": "activateVcmiSettingsTab" "callback": "activateVcmiSettingsTab"