diff --git a/client/gui/InterfaceObjectConfigurable.cpp b/client/gui/InterfaceObjectConfigurable.cpp index a7e1b4d73..a107222d5 100644 --- a/client/gui/InterfaceObjectConfigurable.cpp +++ b/client/gui/InterfaceObjectConfigurable.cpp @@ -26,6 +26,7 @@ #include "../windows/InfoWindows.h" #include "../../lib/CGeneralTextHandler.h" +#include "../../lib/filesystem/ResourceID.h" InterfaceObjectConfigurable::InterfaceObjectConfigurable(const JsonNode & config, int used, Point offset): InterfaceObjectConfigurable(used, offset) @@ -80,7 +81,6 @@ void InterfaceObjectConfigurable::loadCustomBuilders(const JsonNode & config) return this->buildWidget(actualConfig); }; - registerBuilder(typeName, functor); } } @@ -94,6 +94,12 @@ void InterfaceObjectConfigurable::build(const JsonNode &config) if(config.getType() == JsonNode::JsonType::DATA_STRUCT) { + if (!config["library"].isNull()) + { + const JsonNode library(ResourceID(config["library"].String())); + loadCustomBuilders(library); + } + loadCustomBuilders(config["customTypes"]); for(auto & item : config["variables"].Struct()) @@ -101,7 +107,7 @@ void InterfaceObjectConfigurable::build(const JsonNode &config) logGlobal->debug("Read variable named %s", item.first); variables[item.first] = item.second; } - + items = &config["items"]; } diff --git a/config/widgets/settings/adventureOptionsTab.json b/config/widgets/settings/adventureOptionsTab.json index 1184d9069..40751131a 100644 --- a/config/widgets/settings/adventureOptionsTab.json +++ b/config/widgets/settings/adventureOptionsTab.json @@ -1,4 +1,6 @@ { + "library" : "config/widgets/settings/library.json", + "items": [ { @@ -28,37 +30,39 @@ }, { - "name": "topSettingsLabels", - "type": "labelGroup", - "font": "medium", - "alignment": "center", - "color": "yellow", + "type" : "verticalLayout60", + "customType" : "labelCentered", + "position": {"x": 150, "y": 62}, "items": [ { - "position": {"x": 150, "y": 62}, "text": "core.genrltxt.569" // Hero Speed }, { - "position": {"x": 150, "y": 122}, "text": "core.genrltxt.570" // Enemy Speed }, { - "position": {"x": 150, "y": 182}, "text": "core.genrltxt.571" // Scrolling Speed } ] }, - { - "name": "heroSpeedValueLabel", - "type": "label", - "font": "medium", - "alignment": "center", - "color": "yellow", - "position": {"x": 324, "y": 90} + "type" : "verticalLayout60", + "customType" : "labelCentered", + "position": {"x": 324, "y": 90}, + "items": + [ + { + "name": "heroSpeedValueLabel", + }, + { + "name": "enemySpeedValueLabel", + }, + { + "name": "mapScrollingValueLabel", + } + ] }, - { "name": "heroMovementSpeedPicker", "type": "toggleGroup", @@ -110,16 +114,6 @@ ], "callback": "playerHeroSpeedChanged" }, - - { - "name": "enemySpeedValueLabel", - "type": "label", - "font": "medium", - "alignment": "center", - "color": "yellow", - "position": {"x": 324, "y": 150} - }, - { "name": "enemyMovementSpeedPicker", "type": "toggleGroup", @@ -176,15 +170,6 @@ ], "callback": "enemyHeroSpeedChanged" }, - - { - "name": "mapScrollingValueLabel", - "type": "label", - "font": "medium", - "alignment": "center", - "color": "yellow", - "position": {"x": 324, "y": 210} - }, { "name": "mapScrollSpeedPicker", "type": "toggleGroup", @@ -296,120 +281,100 @@ /////////////////////////////////////// Right section - Original H3 options { - "name": "rightCheckboxesLabels", - "type": "labelGroup", - "font": "medium", - "alignment": "left", - "color": "white", + "type" : "verticalLayout", + "customType" : "labelDescription", + "position": {"x": 415, "y": 55}, "items": [ { - "position": {"x": 415, "y": 55}, "text": "core.genrltxt.572" // TODO: show move path }, { - "position": {"x": 415, "y": 85}, "text": "core.genrltxt.573" // show hero reminder }, { - "position": {"x": 415, "y": 115}, "text": "core.genrltxt.574" // quick combat } ] }, { - "name": "showMovePathPlaceholder", - "type": "picture", - "image": "settingsWindow/checkBoxEmpty", + "type" : "verticalLayout", + "customType" : "checkbox", "position": {"x": 380, "y": 53}, - }, - { - "name": "heroReminderCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "core.help.361", - "position": {"x": 380, "y": 83}, - "callback": "heroReminderChanged" - }, - { - "name": "quickCombatCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "core.help.362", - "position": {"x": 380, "y": 113}, - "callback": "quickCombatChanged" - }, - -/////////////////////////////////////// Bottom section - VCMI Options - { - "name": "bottomCheckboxesLabels", - "type": "labelGroup", - "font": "medium", - "alignment": "left", - "color": "white", "items": [ { - "position": {"x": 45, "y": 295}, + "name": "showMovePathPlaceholder", + "type": "checkboxFake", + }, + { + "name": "heroReminderCheckbox", + "help": "core.help.361", + "callback": "heroReminderChanged" + }, + { + "name": "quickCombatCheckbox", + "help": "core.help.362", + "callback": "quickCombatChanged" + }, + ] + }, +/////////////////////////////////////// Bottom section - VCMI Options + { + "type": "verticalLayout", + "customType": "labelDescription", + "position": {"x": 45, "y": 295}, + "items": + [ + { "text": "vcmi.adventureOptions.numericQuantities.hover" }, { - "position": {"x": 45, "y": 325}, "text": "vcmi.adventureOptions.forceMovementInfo.hover" }, { - "position": {"x": 45, "y": 355}, "text": "vcmi.adventureOptions.showGrid.hover" }, { - "position": {"x": 45, "y": 385}, "text": "vcmi.adventureOptions.mapSwipe.hover" }, { - "position": {"x": 45, "y": 415}, "text": "vcmi.adventureOptions.infoBarPick.hover" } ] }, { - "name": "numericQuantitiesCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "vcmi.adventureOptions.numericQuantities", + "type": "verticalLayout", + "customType": "checkbox", "position": {"x": 10, "y": 293}, - "callback": "numericQuantitiesChanged" - }, - { - "name": "forceMovementInfoCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "vcmi.adventureOptions.forceMovementInfo", - "position": {"x": 10, "y": 323}, - "callback": "forceMovementInfoChanged" - }, - { - "name": "showGridCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "vcmi.adventureOptions.showGrid", - "position": {"x": 10, "y": 353}, - "callback": "showGridChanged" - }, - { - "name": "mapSwipeCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "vcmi.adventureOptions.mapSwipe", - "position": {"x": 10, "y": 383}, - "callback": "mapSwipeChanged" - }, - { - "name": "infoBarPickCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "vcmi.adventureOptions.infoBarPick", - "position": {"x": 10, "y": 413}, - "callback": "infoBarPickChanged" + "items": + [ + { + "name": "numericQuantitiesCheckbox", + "help": "vcmi.adventureOptions.numericQuantities", + "callback": "numericQuantitiesChanged" + }, + { + "name": "forceMovementInfoCheckbox", + "help": "vcmi.adventureOptions.forceMovementInfo", + "callback": "forceMovementInfoChanged" + }, + { + "name": "showGridCheckbox", + "help": "vcmi.adventureOptions.showGrid", + "callback": "showGridChanged" + }, + { + "name": "mapSwipeCheckbox", + "help": "vcmi.adventureOptions.mapSwipe", + "callback": "mapSwipeChanged" + }, + { + "name": "infoBarPickCheckbox", + "help": "vcmi.adventureOptions.infoBarPick", + "callback": "infoBarPickChanged" + } + ] } ] } diff --git a/config/widgets/settings/battleOptionsTab.json b/config/widgets/settings/battleOptionsTab.json index 8854271a4..f4f1b8b4b 100644 --- a/config/widgets/settings/battleOptionsTab.json +++ b/config/widgets/settings/battleOptionsTab.json @@ -1,4 +1,6 @@ { + "library" : "config/widgets/settings/library.json", + "items": [ { @@ -13,200 +15,140 @@ "image": "settingsWindow/lineHorizontal", "rect": { "x" : 5, "y" : 319, "w": 365, "h": 3} }, - { - "name": "titlesLabels", - "type": "labelGroup", - "font": "medium", - "alignment": "left", - "color": "yellow", - "items": - [ - { - "text": "core.genrltxt.396", // Auto-combat options - "position": {"x": 380, "y": 55} - }, - { - "text": "core.genrltxt.397", // Creature info - "position": {"x": 10, "y": 235} - } - ] + "type" : "labelTitle", + "text": "core.genrltxt.396", // Auto-combat options + "position": {"x": 380, "y": 55} + }, + { + "type" : "labelTitle", + "text": "core.genrltxt.397", // Creature info + "position": {"x": 10, "y": 235} }, /////////////////////////////////////// Right section - Auto-combat settings (NOT IMPLEMENTED) { "name": "autoCombatLabels", - "type": "labelGroup", - "font": "medium", - "alignment": "left", - "color": "white", + "type" : "verticalLayout", + "customType" : "labelDescription", + "position": {"x": 415, "y": 85}, "items": [ { - "text": "core.genrltxt.398", // Creatures - "position": {"x": 415, "y": 85} + "text": "core.genrltxt.398" // Creatures }, { - "text": "core.genrltxt.399", // Spells - "position": {"x": 415, "y": 115} + "text": "core.genrltxt.399" // Spells }, { - "text": "core.genrltxt.400", // Catapult - "position": {"x": 415, "y": 145} + "text": "core.genrltxt.400" // Catapult }, { - "text": "core.genrltxt.151", // Ballista - "position": {"x": 415, "y": 175} + "text": "core.genrltxt.151" // Ballista }, { - "text": "core.genrltxt.401", // First Aid Tent - "position": {"x": 415, "y": 205} + "text": "core.genrltxt.401" // First Aid Tent } ] }, { - "name": "autoCombatCreaturesPlaceholder", - "type": "picture", - "image": "settingsWindow/checkBoxEmpty", + "name": "autoCombatCheckboxes", + "type" : "verticalLayout", + "customType" : "checkboxFake", "position": {"x": 380, "y": 83}, - }, - { - "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}, + "items": + [ + {}, + {}, + {}, + {}, + {} + ] }, /////////////////////////////////////// Left section - checkboxes { - "name": "creatureInfoLabels", - "type": "labelGroup", - "font": "medium", - "alignment": "left", - "color": "white", - "items": - [ - { - "text": "core.genrltxt.402", // All Stats - "position": {"x": 45, "y": 265} - }, - { - "text": "core.genrltxt.403", // Spells only - "position": {"x": 45, "y": 295} - } - ] + "type": "labelDescription", + "text": "core.genrltxt.402", // All Stats + "position": {"x": 45, "y": 265} + }, + { + "type": "labelDescription", + "text": "core.genrltxt.403", // Spells only + "position": {"x": 45, "y": 295} }, { "name": "creatureInfoAllPlaceholder", - "type": "picture", - "image": "settingsWindow/checkBoxEmpty", + "type": "checkboxFake", "position": {"x": 10, "y": 263}, }, { "name": "creatureInfoSpellsPlaceholder", - "type": "picture", - "image": "settingsWindow/checkBoxEmpty", + "type": "checkboxFake", "position": {"x": 10, "y": 293}, }, - { "name": "generalOptionsLabels", - "type": "labelGroup", - "font": "medium", - "alignment": "left", - "color": "white", + "type" : "verticalLayout", + "customType" : "labelDescription", + "position": {"x": 45, "y": 55}, "items": [ { "text": "core.genrltxt.404", - "position": {"x": 45, "y": 55} }, { "text": "core.genrltxt.405", - "position": {"x": 45, "y": 85} }, { "text": "vcmi.battleOptions.movementHighlightOnHover.hover", - "position": {"x": 45, "y": 115} }, { "text": "core.genrltxt.406", - "position": {"x": 45, "y": 145} }, { "text": "vcmi.battleOptions.skipBattleIntroMusic.hover", - "position": {"x": 45, "y": 175} }, { "text": "vcmi.battleOptions.touchscreenMode.hover", - "position": {"x": 45, "y": 205} } ] }, - { - "name": "viewGridCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "core.help.427", + "type" : "verticalLayout", + "customType" : "checkbox", "position": {"x": 10, "y": 53}, - "callback": "viewGridChanged" - }, - { - "name": "movementShadowCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "core.help.428", - "position": {"x": 10, "y": 83}, - "callback": "movementShadowChanged" - }, - { - "name": "movementHighlightOnHoverCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "vcmi.battleOptions.movementHighlightOnHover", - "position": {"x": 10, "y": 113}, - "callback": "movementHighlightOnHoverChanged" - }, - { - "name": "mouseShadowCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "core.help.429", - "position": {"x": 10, "y": 143}, - "callback": "mouseShadowChanged" - }, - { - "name": "skipBattleIntroMusicCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "vcmi.battleOptions.skipBattleIntroMusic", - "position": {"x": 10, "y": 173}, - "callback": "skipBattleIntroMusicChanged" - }, - { - "name": "touchscreenModeCheckbox", - "type": "toggleButton", - "image": "sysopchk.def", - "help": "vcmi.battleOptions.touchscreenMode", - "position": {"x": 10, "y": 203}, - "callback": "touchscreenModeChanged" + "items": + [ + { + "name": "viewGridCheckbox", + "help": "core.help.427", + "callback": "viewGridChanged" + }, + { + "name": "movementShadowCheckbox", + "help": "core.help.428", + "callback": "movementShadowChanged" + }, + { + "name": "movementHighlightOnHoverCheckbox", + "help": "vcmi.battleOptions.movementHighlightOnHover", + "callback": "movementHighlightOnHoverChanged" + }, + { + "name": "mouseShadowCheckbox", + "help": "core.help.429", + "callback": "mouseShadowChanged" + }, + { + "name": "skipBattleIntroMusicCheckbox", + "help": "vcmi.battleOptions.skipBattleIntroMusic", + "callback": "skipBattleIntroMusicChanged" + }, + { + "name": "touchscreenModeCheckbox", + "help": "vcmi.battleOptions.touchscreenMode", + "callback": "touchscreenModeChanged" + }, + ] }, /////////////////////////////////////// Bottom section - Animation Speed and Turn Order { @@ -217,19 +159,13 @@ }, { "name": "animationSpeedLabel", - "type": "label", - "font": "medium", - "alignment": "center", - "color": "yellow", + "type": "labelCentered", "text": "core.genrltxt.393", "position": {"x": 150, "y": 362} }, { "name": "animationSpeedValueLabel", - "type": "label", - "font": "medium", - "alignment": "center", - "color": "yellow", + "type": "labelCentered", "position": {"x": 324, "y": 390} }, { diff --git a/config/widgets/settings/generalOptionsTab.json b/config/widgets/settings/generalOptionsTab.json index c3b48cde5..5a87015d8 100644 --- a/config/widgets/settings/generalOptionsTab.json +++ b/config/widgets/settings/generalOptionsTab.json @@ -1,56 +1,5 @@ { - "customTypes" : { - "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 - } - }, + "library" : "config/widgets/settings/library.json", "items": [ @@ -136,12 +85,12 @@ }, /////////////////////////////////////// Right section - Audio Settings { - "type" : "labelAudio", + "type" : "labelCentered", "position": {"x": 460, "y": 98}, "text": "core.genrltxt.394" // Music Volume }, { - "type" : "labelAudio", + "type" : "labelCentered", "position": {"x": 460, "y": 158}, "text": "core.genrltxt.395" // Effects volume }, @@ -159,7 +108,7 @@ }, { "name": "musicValueLabel", - "type": "labelAudio", + "type": "labelCentered", "position": {"x": 565, "y": 98} }, { @@ -176,7 +125,7 @@ }, { "name": "soundValueLabel", - "type": "labelAudio", + "type": "labelCentered", "position": {"x": 565, "y": 158} }, /////////////////////////////////////// Bottom section - Towns Settings @@ -202,27 +151,32 @@ "callback": "availableCreaturesAsDwellingChanged" }, { - "type" : "verticalLayout", - "customType" : "checkbox", + "name": "availableCreaturesAsDwellingPicker", + "type": "toggleGroup", "position": {"x": 10, "y": 323}, "items": [ { + "index": 0, + "type": "checkbox", "help": "vcmi.otherOptions.creatureGrowthAsDwellingLabel", - "group" : "availableCreaturesAsDwellingPicker", - "index": 0 + "position": {"x": 0, "y": 0} }, { + "index": 1, + "type": "checkbox", "help": "vcmi.otherOptions.availableCreaturesAsDwellingLabel", - "group" : "availableCreaturesAsDwellingPicker", - "index": 1 + "position": {"x": 0, "y": 30} }, - { - "name": "compactTownCreatureInfoCheckbox", - "help": "vcmi.otherOptions.compactTownCreatureInfo", - "callback": "compactTownCreatureInfoChanged" - } - ] + ], + "callback": "availableCreaturesAsDwellingChanged" + }, + { + "name": "compactTownCreatureInfoCheckbox", + "type": "checkbox", + "help": "vcmi.otherOptions.compactTownCreatureInfo", + "position": {"x": 10, "y": 383}, + "callback": "compactTownCreatureInfoChanged" } ] } diff --git a/config/widgets/settings/library.json b/config/widgets/settings/library.json new file mode 100644 index 000000000..c5ea07f95 --- /dev/null +++ b/config/widgets/settings/library.json @@ -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 + } +}