Sfoglia il codice sorgente

Change main settings tabs to toggle group + fix json commas

Dydzio 2 anni fa
parent
commit
c2ef3331ef

+ 1 - 1
Mods/vcmi/Sprites/buttons/square.json

@@ -3,7 +3,7 @@
 	"images" :
 	[
 		{ "frame" : 0, "file" : "square-normal.png"},
-		{ "frame" : 1, "file" : "square-pressed-selected.png"}
+		{ "frame" : 1, "file" : "square-pressed-selected.png"},
 		{ "frame" : 2, "file" : "square-pressed.png"},
 		{ "frame" : 3, "file" : "square-normal-selected.png"}
 	]

+ 0 - 8
Mods/vcmi/Sprites/buttons/squareButton.json

@@ -1,8 +0,0 @@
-{
-	"basepath" : "buttons/",
-	"images" :
-	[
-		{ "frame" : 0, "file" : "square-normal.png"},
-		{ "frame" : 1, "file" : "square-pressed.png"}
-	]
-}

+ 2 - 2
Mods/vcmi/Sprites/buttons/triplewide.json

@@ -3,8 +3,8 @@
 	"images" :
 	[
 		{ "frame" : 0, "file" : "triplewide-normal.png"},
-		{ "frame" : 1, "file" : "triplewide-pressed-selected.png"}
-		{ "frame" : 2, "file" : "triplewide-pressed.png"}
+		{ "frame" : 1, "file" : "triplewide-pressed-selected.png"},
+		{ "frame" : 2, "file" : "triplewide-pressed.png"},
 		{ "frame" : 3, "file" : "triplewide-normal-selected.png"}
 	]
 }

+ 5 - 6
client/windows/settings/SettingsMainContainer.cpp

@@ -33,11 +33,7 @@ SettingsMainContainer::SettingsMainContainer(BattleInterface * parentBattleUi) :
 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
 
 	const JsonNode config(ResourceID("config/widgets/settings/settingsMainContainer.json"));
-	addCallback("activateGeneralTab", [this](int) { openTab(0); });
-	addCallback("activateAdventureTab", [this](int) { openTab(1); });
-	addCallback("activateBattleTab", [this](int) { openTab(2); });
-	addCallback("activateVcmiSettingsTab", [this](int) { openTab(3); });
-
+	addCallback("activateSettingsTab", [this](int tabId) { openTab(tabId); });
 	addCallback("loadGame", [this](int) { loadGameButtonCallback(); });
 	addCallback("saveGame", [this](int) { saveGameButtonCallback(); });
 	addCallback("restartGame", [this](int) { restartGameButtonCallback(); });
@@ -72,7 +68,10 @@ SettingsMainContainer::SettingsMainContainer(BattleInterface * parentBattleUi) :
 		defaultTabIndex = settings["general"]["lastSettingsTab"].Integer();
 
 	parentBattleInterface = parentBattleUi;
-	tabContentArea = std::make_shared<CTabbedInt>(std::bind(&SettingsMainContainer::createTab, this, _1), Point(0, 50), defaultTabIndex);
+	tabContentArea = std::make_shared<CTabbedInt>(std::bind(&SettingsMainContainer::createTab, this, _1), Point(0, 40), defaultTabIndex);
+
+	std::shared_ptr<CToggleGroup> mainTabs = widget<CToggleGroup>("settingsTabs");
+	mainTabs->setSelected(defaultTabIndex);
 }
 
 std::shared_ptr<CIntObject> SettingsMainContainer::createTab(size_t index)

+ 75 - 67
config/widgets/settings/settingsMainContainer.json

@@ -9,83 +9,91 @@
 		},
 
 		{
-			"name": "activateGeneralOptionsButton",
-			"type": "button",
-			"position": {"x": 0, "y": 0},
-			"image": "buttons/quadwide",
-			"help": "vcmi.settingsMainWindow.systemTab",
-			"callback": "activateGeneralTab",
+			"name": "settingsTabs",
+			"type": "toggleGroup",
+			"position": {
+				"x": 0,
+				"y": 0
+			},
 			"items":
 			[
 				{
-					"name": "generalTabButtonTitle",
-					"type": "label",
-					"font": "big",
-					"alignment": "center",
-					"color": "yellow",
-					"text": "core.genrltxt.568"
-				}
-			]
-		},
+					"index": 0,
+					"type": "toggleButton",
+					"position": {"x": 0, "y": 0},
+					"image": "buttons/quadwide",
+					"help": "vcmi.settingsMainWindow.systemTab",
+					"items":
+					[
+						{
+							"name": "generalTabButtonTitle",
+							"type": "label",
+							"font": "big",
+							"alignment": "center",
+							"color": "yellow",
+							"text": "core.genrltxt.568"
+						}
+					]
+				},
 
-		{
-			"name": "activateAdventureOptionsButton",
-			"type": "button",
-			"position": {"x": 150, "y": 0},
-			"image": "buttons/quadwide",
-			"help": "vcmi.settingsMainWindow.adventureTab",
-			"callback": "activateAdventureTab",
-			"items":
-			[
 				{
-					"name": "generalTabButtonTitle",
-					"type": "label",
-					"font": "big",
-					"alignment": "center",
-					"color": "yellow",
-					"text": "vcmi.settingsMainWindow.adventureTab.hover"
-				}
-			]
-		},
+					"index": 1,
+					"type": "toggleButton",
+					"position": {"x": 150, "y": 0},
+					"image": "buttons/quadwide",
+					"help": "vcmi.settingsMainWindow.adventureTab",
+					"items":
+					[
+						{
+							"name": "generalTabButtonTitle",
+							"type": "label",
+							"font": "big",
+							"alignment": "center",
+							"color": "yellow",
+							"text": "vcmi.settingsMainWindow.adventureTab.hover"
+						}
+					]
+				},
 
-		{
-			"name": "activateBattleOptionsButton",
-			"type": "button",
-			"position": {"x": 300, "y": 0},
-			"image": "buttons/quadwide",
-			"help": "vcmi.settingsMainWindow.battleTab",
-			"callback": "activateBattleTab",
-			"items":
-			[
 				{
-					"name": "adventureTabButtonTitle",
-					"type": "label",
-					"font": "big",
-					"alignment": "center",
-					"color": "yellow",
-					"text": "core.genrltxt.392"
-				}
-			]
-		},
+					"index": 2,
+					"type": "toggleButton",
+					"position": {"x": 300, "y": 0},
+					"image": "buttons/quadwide",
+					"help": "vcmi.settingsMainWindow.battleTab",
+					"items":
+					[
+						{
+							"name": "adventureTabButtonTitle",
+							"type": "label",
+							"font": "big",
+							"alignment": "center",
+							"color": "yellow",
+							"text": "core.genrltxt.392"
+						}
+					]
+				},
 
-		{
-			"name": "activateVcmiSettingsButton",
-			"type": "button",
-			"position": {"x": 450, "y": 0},
-			"image": "buttons/quadwide",
-			"help": "vcmi.settingsMainWindow.otherTab",
-			"callback": "activateVcmiSettingsTab",
-			"items":
-			[
 				{
-					"name": "otherTabButtonTitle",
-					"type": "label",
-					"font": "big",
-					"alignment": "center",
-					"color": "yellow",
-					"text": "vcmi.settingsMainWindow.otherTab.hover"
+					"index": 3,
+					"type": "toggleButton",
+					"position": {"x": 450, "y": 0},
+					"image": "buttons/quadwide",
+					"help": "vcmi.settingsMainWindow.otherTab",
+					"items":
+					[
+						{
+							"name": "otherTabButtonTitle",
+							"type": "label",
+							"font": "big",
+							"alignment": "center",
+							"color": "yellow",
+							"text": "vcmi.settingsMainWindow.otherTab.hover"
+						}
+					]
 				}
-			]
+			],
+			"callback": "activateSettingsTab"
 		},
 
 		{