1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Updated settings window to use new layouts & library

This commit is contained in:
Ivan Savenko
2023-05-15 14:00:52 +03:00
parent 7cbfd8117e
commit f2dfd6de42
5 changed files with 249 additions and 326 deletions

View File

@ -26,6 +26,7 @@
#include "../windows/InfoWindows.h" #include "../windows/InfoWindows.h"
#include "../../lib/CGeneralTextHandler.h" #include "../../lib/CGeneralTextHandler.h"
#include "../../lib/filesystem/ResourceID.h"
InterfaceObjectConfigurable::InterfaceObjectConfigurable(const JsonNode & config, int used, Point offset): InterfaceObjectConfigurable::InterfaceObjectConfigurable(const JsonNode & config, int used, Point offset):
InterfaceObjectConfigurable(used, offset) InterfaceObjectConfigurable(used, offset)
@ -80,7 +81,6 @@ void InterfaceObjectConfigurable::loadCustomBuilders(const JsonNode & config)
return this->buildWidget(actualConfig); return this->buildWidget(actualConfig);
}; };
registerBuilder(typeName, functor); registerBuilder(typeName, functor);
} }
} }
@ -94,6 +94,12 @@ void InterfaceObjectConfigurable::build(const JsonNode &config)
if(config.getType() == JsonNode::JsonType::DATA_STRUCT) if(config.getType() == JsonNode::JsonType::DATA_STRUCT)
{ {
if (!config["library"].isNull())
{
const JsonNode library(ResourceID(config["library"].String()));
loadCustomBuilders(library);
}
loadCustomBuilders(config["customTypes"]); loadCustomBuilders(config["customTypes"]);
for(auto & item : config["variables"].Struct()) for(auto & item : config["variables"].Struct())

View File

@ -1,4 +1,6 @@
{ {
"library" : "config/widgets/settings/library.json",
"items": "items":
[ [
{ {
@ -28,37 +30,39 @@
}, },
{ {
"name": "topSettingsLabels", "type" : "verticalLayout60",
"type": "labelGroup", "customType" : "labelCentered",
"font": "medium", "position": {"x": 150, "y": 62},
"alignment": "center",
"color": "yellow",
"items": "items":
[ [
{ {
"position": {"x": 150, "y": 62},
"text": "core.genrltxt.569" // Hero Speed "text": "core.genrltxt.569" // Hero Speed
}, },
{ {
"position": {"x": 150, "y": 122},
"text": "core.genrltxt.570" // Enemy Speed "text": "core.genrltxt.570" // Enemy Speed
}, },
{ {
"position": {"x": 150, "y": 182},
"text": "core.genrltxt.571" // Scrolling Speed "text": "core.genrltxt.571" // Scrolling Speed
} }
] ]
}, },
{
"type" : "verticalLayout60",
"customType" : "labelCentered",
"position": {"x": 324, "y": 90},
"items":
[
{ {
"name": "heroSpeedValueLabel", "name": "heroSpeedValueLabel",
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow",
"position": {"x": 324, "y": 90}
}, },
{
"name": "enemySpeedValueLabel",
},
{
"name": "mapScrollingValueLabel",
}
]
},
{ {
"name": "heroMovementSpeedPicker", "name": "heroMovementSpeedPicker",
"type": "toggleGroup", "type": "toggleGroup",
@ -110,16 +114,6 @@
], ],
"callback": "playerHeroSpeedChanged" "callback": "playerHeroSpeedChanged"
}, },
{
"name": "enemySpeedValueLabel",
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow",
"position": {"x": 324, "y": 150}
},
{ {
"name": "enemyMovementSpeedPicker", "name": "enemyMovementSpeedPicker",
"type": "toggleGroup", "type": "toggleGroup",
@ -176,15 +170,6 @@
], ],
"callback": "enemyHeroSpeedChanged" "callback": "enemyHeroSpeedChanged"
}, },
{
"name": "mapScrollingValueLabel",
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow",
"position": {"x": 324, "y": 210}
},
{ {
"name": "mapScrollSpeedPicker", "name": "mapScrollSpeedPicker",
"type": "toggleGroup", "type": "toggleGroup",
@ -296,120 +281,100 @@
/////////////////////////////////////// Right section - Original H3 options /////////////////////////////////////// Right section - Original H3 options
{ {
"name": "rightCheckboxesLabels", "type" : "verticalLayout",
"type": "labelGroup", "customType" : "labelDescription",
"font": "medium", "position": {"x": 415, "y": 55},
"alignment": "left",
"color": "white",
"items": "items":
[ [
{ {
"position": {"x": 415, "y": 55},
"text": "core.genrltxt.572" // TODO: show move path "text": "core.genrltxt.572" // TODO: show move path
}, },
{ {
"position": {"x": 415, "y": 85},
"text": "core.genrltxt.573" // show hero reminder "text": "core.genrltxt.573" // show hero reminder
}, },
{ {
"position": {"x": 415, "y": 115},
"text": "core.genrltxt.574" // quick combat "text": "core.genrltxt.574" // quick combat
} }
] ]
}, },
{ {
"name": "showMovePathPlaceholder", "type" : "verticalLayout",
"type": "picture", "customType" : "checkbox",
"image": "settingsWindow/checkBoxEmpty",
"position": {"x": 380, "y": 53}, "position": {"x": 380, "y": 53},
"items":
[
{
"name": "showMovePathPlaceholder",
"type": "checkboxFake",
}, },
{ {
"name": "heroReminderCheckbox", "name": "heroReminderCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "core.help.361", "help": "core.help.361",
"position": {"x": 380, "y": 83},
"callback": "heroReminderChanged" "callback": "heroReminderChanged"
}, },
{ {
"name": "quickCombatCheckbox", "name": "quickCombatCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "core.help.362", "help": "core.help.362",
"position": {"x": 380, "y": 113},
"callback": "quickCombatChanged" "callback": "quickCombatChanged"
}, },
]
},
/////////////////////////////////////// Bottom section - VCMI Options /////////////////////////////////////// Bottom section - VCMI Options
{ {
"name": "bottomCheckboxesLabels", "type": "verticalLayout",
"type": "labelGroup", "customType": "labelDescription",
"font": "medium", "position": {"x": 45, "y": 295},
"alignment": "left",
"color": "white",
"items": "items":
[ [
{ {
"position": {"x": 45, "y": 295},
"text": "vcmi.adventureOptions.numericQuantities.hover" "text": "vcmi.adventureOptions.numericQuantities.hover"
}, },
{ {
"position": {"x": 45, "y": 325},
"text": "vcmi.adventureOptions.forceMovementInfo.hover" "text": "vcmi.adventureOptions.forceMovementInfo.hover"
}, },
{ {
"position": {"x": 45, "y": 355},
"text": "vcmi.adventureOptions.showGrid.hover" "text": "vcmi.adventureOptions.showGrid.hover"
}, },
{ {
"position": {"x": 45, "y": 385},
"text": "vcmi.adventureOptions.mapSwipe.hover" "text": "vcmi.adventureOptions.mapSwipe.hover"
}, },
{ {
"position": {"x": 45, "y": 415},
"text": "vcmi.adventureOptions.infoBarPick.hover" "text": "vcmi.adventureOptions.infoBarPick.hover"
} }
] ]
}, },
{ {
"name": "numericQuantitiesCheckbox", "type": "verticalLayout",
"type": "toggleButton", "customType": "checkbox",
"image": "sysopchk.def",
"help": "vcmi.adventureOptions.numericQuantities",
"position": {"x": 10, "y": 293}, "position": {"x": 10, "y": 293},
"items":
[
{
"name": "numericQuantitiesCheckbox",
"help": "vcmi.adventureOptions.numericQuantities",
"callback": "numericQuantitiesChanged" "callback": "numericQuantitiesChanged"
}, },
{ {
"name": "forceMovementInfoCheckbox", "name": "forceMovementInfoCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "vcmi.adventureOptions.forceMovementInfo", "help": "vcmi.adventureOptions.forceMovementInfo",
"position": {"x": 10, "y": 323},
"callback": "forceMovementInfoChanged" "callback": "forceMovementInfoChanged"
}, },
{ {
"name": "showGridCheckbox", "name": "showGridCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "vcmi.adventureOptions.showGrid", "help": "vcmi.adventureOptions.showGrid",
"position": {"x": 10, "y": 353},
"callback": "showGridChanged" "callback": "showGridChanged"
}, },
{ {
"name": "mapSwipeCheckbox", "name": "mapSwipeCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "vcmi.adventureOptions.mapSwipe", "help": "vcmi.adventureOptions.mapSwipe",
"position": {"x": 10, "y": 383},
"callback": "mapSwipeChanged" "callback": "mapSwipeChanged"
}, },
{ {
"name": "infoBarPickCheckbox", "name": "infoBarPickCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "vcmi.adventureOptions.infoBarPick", "help": "vcmi.adventureOptions.infoBarPick",
"position": {"x": 10, "y": 413},
"callback": "infoBarPickChanged" "callback": "infoBarPickChanged"
} }
] ]
}
]
} }

View File

@ -1,4 +1,6 @@
{ {
"library" : "config/widgets/settings/library.json",
"items": "items":
[ [
{ {
@ -13,201 +15,141 @@
"image": "settingsWindow/lineHorizontal", "image": "settingsWindow/lineHorizontal",
"rect": { "x" : 5, "y" : 319, "w": 365, "h": 3} "rect": { "x" : 5, "y" : 319, "w": 365, "h": 3}
}, },
{
"name": "titlesLabels",
"type": "labelGroup",
"font": "medium",
"alignment": "left",
"color": "yellow",
"items":
[
{ {
"type" : "labelTitle",
"text": "core.genrltxt.396", // Auto-combat options "text": "core.genrltxt.396", // Auto-combat options
"position": {"x": 380, "y": 55} "position": {"x": 380, "y": 55}
}, },
{ {
"type" : "labelTitle",
"text": "core.genrltxt.397", // Creature info "text": "core.genrltxt.397", // Creature info
"position": {"x": 10, "y": 235} "position": {"x": 10, "y": 235}
}
]
}, },
/////////////////////////////////////// Right section - Auto-combat settings (NOT IMPLEMENTED) /////////////////////////////////////// Right section - Auto-combat settings (NOT IMPLEMENTED)
{ {
"name": "autoCombatLabels", "name": "autoCombatLabels",
"type": "labelGroup", "type" : "verticalLayout",
"font": "medium", "customType" : "labelDescription",
"alignment": "left", "position": {"x": 415, "y": 85},
"color": "white",
"items": "items":
[ [
{ {
"text": "core.genrltxt.398", // Creatures "text": "core.genrltxt.398" // Creatures
"position": {"x": 415, "y": 85}
}, },
{ {
"text": "core.genrltxt.399", // Spells "text": "core.genrltxt.399" // Spells
"position": {"x": 415, "y": 115}
}, },
{ {
"text": "core.genrltxt.400", // Catapult "text": "core.genrltxt.400" // Catapult
"position": {"x": 415, "y": 145}
}, },
{ {
"text": "core.genrltxt.151", // Ballista "text": "core.genrltxt.151" // Ballista
"position": {"x": 415, "y": 175}
}, },
{ {
"text": "core.genrltxt.401", // First Aid Tent "text": "core.genrltxt.401" // First Aid Tent
"position": {"x": 415, "y": 205}
} }
] ]
}, },
{ {
"name": "autoCombatCreaturesPlaceholder", "name": "autoCombatCheckboxes",
"type": "picture", "type" : "verticalLayout",
"image": "settingsWindow/checkBoxEmpty", "customType" : "checkboxFake",
"position": {"x": 380, "y": 83}, "position": {"x": 380, "y": 83},
}, "items":
{ [
"name": "autoCombatSpellsPlaceholder", {},
"type": "picture", {},
"image": "settingsWindow/checkBoxEmpty", {},
"position": {"x": 380, "y": 113}, {},
}, {}
{ ]
"name": "autoCombatCatapultPlaceholder",
"type": "picture",
"image": "settingsWindow/checkBoxEmpty",
"position": {"x": 380, "y": 143},
},
{
"name": "autoCombatBallistaPlaceholder",
"type": "picture",
"image": "settingsWindow/checkBoxEmpty",
"position": {"x": 380, "y": 173},
},
{
"name": "autoCombatFirstAidTentPlaceholder",
"type": "picture",
"image": "settingsWindow/checkBoxEmpty",
"position": {"x": 380, "y": 203},
}, },
/////////////////////////////////////// Left section - checkboxes /////////////////////////////////////// Left section - checkboxes
{ {
"name": "creatureInfoLabels", "type": "labelDescription",
"type": "labelGroup",
"font": "medium",
"alignment": "left",
"color": "white",
"items":
[
{
"text": "core.genrltxt.402", // All Stats "text": "core.genrltxt.402", // All Stats
"position": {"x": 45, "y": 265} "position": {"x": 45, "y": 265}
}, },
{ {
"type": "labelDescription",
"text": "core.genrltxt.403", // Spells only "text": "core.genrltxt.403", // Spells only
"position": {"x": 45, "y": 295} "position": {"x": 45, "y": 295}
}
]
}, },
{ {
"name": "creatureInfoAllPlaceholder", "name": "creatureInfoAllPlaceholder",
"type": "picture", "type": "checkboxFake",
"image": "settingsWindow/checkBoxEmpty",
"position": {"x": 10, "y": 263}, "position": {"x": 10, "y": 263},
}, },
{ {
"name": "creatureInfoSpellsPlaceholder", "name": "creatureInfoSpellsPlaceholder",
"type": "picture", "type": "checkboxFake",
"image": "settingsWindow/checkBoxEmpty",
"position": {"x": 10, "y": 293}, "position": {"x": 10, "y": 293},
}, },
{ {
"name": "generalOptionsLabels", "name": "generalOptionsLabels",
"type": "labelGroup", "type" : "verticalLayout",
"font": "medium", "customType" : "labelDescription",
"alignment": "left", "position": {"x": 45, "y": 55},
"color": "white",
"items": "items":
[ [
{ {
"text": "core.genrltxt.404", "text": "core.genrltxt.404",
"position": {"x": 45, "y": 55}
}, },
{ {
"text": "core.genrltxt.405", "text": "core.genrltxt.405",
"position": {"x": 45, "y": 85}
}, },
{ {
"text": "vcmi.battleOptions.movementHighlightOnHover.hover", "text": "vcmi.battleOptions.movementHighlightOnHover.hover",
"position": {"x": 45, "y": 115}
}, },
{ {
"text": "core.genrltxt.406", "text": "core.genrltxt.406",
"position": {"x": 45, "y": 145}
}, },
{ {
"text": "vcmi.battleOptions.skipBattleIntroMusic.hover", "text": "vcmi.battleOptions.skipBattleIntroMusic.hover",
"position": {"x": 45, "y": 175}
}, },
{ {
"text": "vcmi.battleOptions.touchscreenMode.hover", "text": "vcmi.battleOptions.touchscreenMode.hover",
"position": {"x": 45, "y": 205}
} }
] ]
}, },
{
"type" : "verticalLayout",
"customType" : "checkbox",
"position": {"x": 10, "y": 53},
"items":
[
{ {
"name": "viewGridCheckbox", "name": "viewGridCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "core.help.427", "help": "core.help.427",
"position": {"x": 10, "y": 53},
"callback": "viewGridChanged" "callback": "viewGridChanged"
}, },
{ {
"name": "movementShadowCheckbox", "name": "movementShadowCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "core.help.428", "help": "core.help.428",
"position": {"x": 10, "y": 83},
"callback": "movementShadowChanged" "callback": "movementShadowChanged"
}, },
{ {
"name": "movementHighlightOnHoverCheckbox", "name": "movementHighlightOnHoverCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "vcmi.battleOptions.movementHighlightOnHover", "help": "vcmi.battleOptions.movementHighlightOnHover",
"position": {"x": 10, "y": 113},
"callback": "movementHighlightOnHoverChanged" "callback": "movementHighlightOnHoverChanged"
}, },
{ {
"name": "mouseShadowCheckbox", "name": "mouseShadowCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "core.help.429", "help": "core.help.429",
"position": {"x": 10, "y": 143},
"callback": "mouseShadowChanged" "callback": "mouseShadowChanged"
}, },
{ {
"name": "skipBattleIntroMusicCheckbox", "name": "skipBattleIntroMusicCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "vcmi.battleOptions.skipBattleIntroMusic", "help": "vcmi.battleOptions.skipBattleIntroMusic",
"position": {"x": 10, "y": 173},
"callback": "skipBattleIntroMusicChanged" "callback": "skipBattleIntroMusicChanged"
}, },
{ {
"name": "touchscreenModeCheckbox", "name": "touchscreenModeCheckbox",
"type": "toggleButton",
"image": "sysopchk.def",
"help": "vcmi.battleOptions.touchscreenMode", "help": "vcmi.battleOptions.touchscreenMode",
"position": {"x": 10, "y": 203},
"callback": "touchscreenModeChanged" "callback": "touchscreenModeChanged"
}, },
]
},
/////////////////////////////////////// Bottom section - Animation Speed and Turn Order /////////////////////////////////////// Bottom section - Animation Speed and Turn Order
{ {
"name": "frameAnimationSpeed", "name": "frameAnimationSpeed",
@ -217,19 +159,13 @@
}, },
{ {
"name": "animationSpeedLabel", "name": "animationSpeedLabel",
"type": "label", "type": "labelCentered",
"font": "medium",
"alignment": "center",
"color": "yellow",
"text": "core.genrltxt.393", "text": "core.genrltxt.393",
"position": {"x": 150, "y": 362} "position": {"x": 150, "y": 362}
}, },
{ {
"name": "animationSpeedValueLabel", "name": "animationSpeedValueLabel",
"type": "label", "type": "labelCentered",
"font": "medium",
"alignment": "center",
"color": "yellow",
"position": {"x": 324, "y": 390} "position": {"x": 324, "y": 390}
}, },
{ {

View File

@ -1,56 +1,5 @@
{ {
"customTypes" : { "library" : "config/widgets/settings/library.json",
"labelTitle" : {
"type": "label",
"font": "medium",
"alignment": "left",
"color": "yellow"
},
"labelAudio" : {
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow"
},
"labelDescription" : {
"type": "label",
"font": "medium",
"alignment": "left",
"color": "white"
},
"checkbox" : {
"type": "toggleButton",
"image": "sysopchk.def",
},
"buttonGear" : {
"type": "button",
"image": "settingsWindow/button32",
"items":
[
{
"name": "gearIcon",
"type": "picture",
"image": "settingsWindow/gear",
"position": {"x": 0, "y": 0 }
}
]
},
"audioSlider" : {
"type": "slider",
"scrollBounds" : { "x" : -4, "y" : -34, "w" : 208, "h" : 52 },
"size": 200,
"style": "brown",
"orientation": "horizontal",
"itemsVisible": 0,
"itemsTotal": 100,
},
"verticalLayout" : {
"type" : "layout",
"vertical" : true,
"dynamic" : false,
"distance" : 30
}
},
"items": "items":
[ [
@ -136,12 +85,12 @@
}, },
/////////////////////////////////////// Right section - Audio Settings /////////////////////////////////////// Right section - Audio Settings
{ {
"type" : "labelAudio", "type" : "labelCentered",
"position": {"x": 460, "y": 98}, "position": {"x": 460, "y": 98},
"text": "core.genrltxt.394" // Music Volume "text": "core.genrltxt.394" // Music Volume
}, },
{ {
"type" : "labelAudio", "type" : "labelCentered",
"position": {"x": 460, "y": 158}, "position": {"x": 460, "y": 158},
"text": "core.genrltxt.395" // Effects volume "text": "core.genrltxt.395" // Effects volume
}, },
@ -159,7 +108,7 @@
}, },
{ {
"name": "musicValueLabel", "name": "musicValueLabel",
"type": "labelAudio", "type": "labelCentered",
"position": {"x": 565, "y": 98} "position": {"x": 565, "y": 98}
}, },
{ {
@ -176,7 +125,7 @@
}, },
{ {
"name": "soundValueLabel", "name": "soundValueLabel",
"type": "labelAudio", "type": "labelCentered",
"position": {"x": 565, "y": 158} "position": {"x": 565, "y": 158}
}, },
/////////////////////////////////////// Bottom section - Towns Settings /////////////////////////////////////// Bottom section - Towns Settings
@ -202,27 +151,32 @@
"callback": "availableCreaturesAsDwellingChanged" "callback": "availableCreaturesAsDwellingChanged"
}, },
{ {
"type" : "verticalLayout", "name": "availableCreaturesAsDwellingPicker",
"customType" : "checkbox", "type": "toggleGroup",
"position": {"x": 10, "y": 323}, "position": {"x": 10, "y": 323},
"items": "items":
[ [
{ {
"index": 0,
"type": "checkbox",
"help": "vcmi.otherOptions.creatureGrowthAsDwellingLabel", "help": "vcmi.otherOptions.creatureGrowthAsDwellingLabel",
"group" : "availableCreaturesAsDwellingPicker", "position": {"x": 0, "y": 0}
"index": 0
}, },
{ {
"index": 1,
"type": "checkbox",
"help": "vcmi.otherOptions.availableCreaturesAsDwellingLabel", "help": "vcmi.otherOptions.availableCreaturesAsDwellingLabel",
"group" : "availableCreaturesAsDwellingPicker", "position": {"x": 0, "y": 30}
"index": 1 },
],
"callback": "availableCreaturesAsDwellingChanged"
}, },
{ {
"name": "compactTownCreatureInfoCheckbox", "name": "compactTownCreatureInfoCheckbox",
"type": "checkbox",
"help": "vcmi.otherOptions.compactTownCreatureInfo", "help": "vcmi.otherOptions.compactTownCreatureInfo",
"position": {"x": 10, "y": 383},
"callback": "compactTownCreatureInfoChanged" "callback": "compactTownCreatureInfoChanged"
} }
] ]
}
]
} }

View File

@ -0,0 +1,62 @@
{
"labelTitle" : {
"type": "label",
"font": "medium",
"alignment": "left",
"color": "yellow"
},
"labelCentered" : {
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow"
},
"labelDescription" : {
"type": "label",
"font": "medium",
"alignment": "left",
"color": "white"
},
"checkbox" : {
"type": "toggleButton",
"image": "sysopchk.def",
},
"buttonGear" : {
"type": "button",
"image": "settingsWindow/button32",
"items":
[
{
"name": "gearIcon",
"type": "picture",
"image": "settingsWindow/gear",
"position": {"x": 0, "y": 0 }
}
]
},
"checkboxFake" : {
"type": "picture",
"image": "settingsWindow/checkBoxEmpty"
},
"audioSlider" : {
"type": "slider",
"scrollBounds" : { "x" : -4, "y" : -34, "w" : 208, "h" : 52 },
"size": 200,
"style": "brown",
"orientation": "horizontal",
"itemsVisible": 0,
"itemsTotal": 100,
},
"verticalLayout" : {
"type" : "layout",
"vertical" : true,
"dynamic" : false,
"distance" : 30
},
"verticalLayout60" : {
"type" : "layout",
"vertical" : true,
"dynamic" : false,
"distance" : 60
}
}