瀏覽代碼

Added temporary UI for simturns testing

Ivan Savenko 2 年之前
父節點
當前提交
54adeef29f
共有 3 個文件被更改,包括 50 次插入6 次删除
  1. 18 0
      client/lobby/OptionsTab.cpp
  2. 31 5
      config/widgets/optionsTab.json
  3. 1 1
      lib/StartInfo.h

+ 18 - 0
client/lobby/OptionsTab.cpp

@@ -58,6 +58,12 @@ OptionsTab::OptionsTab() : humanPlayers(0)
 			CSH->setTurnTimerInfo(tinfo);
 		}
 	});
+
+	addCallback("setSimturnDuration", [&](int index){
+		SimturnsInfo info;
+		info.optionalTurns = index;
+		CSH->setSimturnsInfo(info);
+	});
 	
 	//helper function to parse string containing time to integer reflecting time in seconds
 	//assumed that input string can be modified by user, function shall support user's intention
@@ -214,6 +220,18 @@ void OptionsTab::recreate()
 
 		entries.insert(std::make_pair(pInfo.first, std::make_shared<PlayerOptionsEntry>(pInfo.second, * this)));
 	}
+
+	//Simultaneous turns
+	if(auto turnSlider = widget<CSlider>("labelSimturnsDurationValue"))
+		turnSlider->scrollTo(SEL->getStartInfo()->simturnsInfo.optionalTurns);
+
+	if(auto w = widget<CLabel>("labelSimturnsDurationValue"))
+	{
+		MetaString message;
+		message.appendRawString("Simturns: up to %d days");
+		message.replaceNumber(SEL->getStartInfo()->simturnsInfo.optionalTurns);
+		w->setText(message.toString());
+	}
 	
 	const auto & turnTimerRemote = SEL->getStartInfo()->turnTimerInfo;
 	

+ 31 - 5
config/widgets/optionsTab.json

@@ -73,16 +73,41 @@
 			"adoptHeight": true
 		},
 		
-		// timer
 		{
+			"name": "simturnsDuration",
+			"type": "slider",
+			"orientation": "horizontal",
+			"position": {"x": 55, "y": 537},
+			"size": 194,
+			"callback": "setSimturnDuration",
+			"itemsVisible": 1,
+			"itemsTotal": 28,
+			"selected": 0,
+			"style": "blue",
+			"scrollBounds": {"x": 0, "y": 0, "w": 194, "h": 32},
+			"panningStep": 20
+		},
+		
+		{
+			"name": "labelSimturnsDurationValue",
 			"type": "label",
 			"font": "small",
 			"alignment": "center",
-			"color": "yellow",
-			"text": "core.genrltxt.521",
-			"position": {"x": 222, "y": 544}
+			"color": "white",
+			"text": "",
+			"position": {"x": 319, "y": 545}
 		},
 		
+		// timer
+		//{
+		//	"type": "label",
+		//	"font": "small",
+		//	"alignment": "center",
+		//	"color": "yellow",
+		//	"text": "core.genrltxt.521",
+		//	"position": {"x": 222, "y": 544}
+		//},
+		
 		{
 			"name": "labelTurnDurationValue",
 			"type": "label",
@@ -104,7 +129,8 @@
 			"itemsTotal": 11,
 			"selected": 11,
 			"style": "blue",
-			"scrollBounds": {"x": -3, "y": -25, "w": 337, "h": 43},
+			"scrollBounds": {"x": 0, "y": 0, "w": 194, "h": 32},
+			//"scrollBounds": {"x": -3, "y": -25, "w": 337, "h": 43},
 			"panningStep": 20
 		},
 	],

+ 1 - 1
lib/StartInfo.h

@@ -30,7 +30,7 @@ struct DLL_LINKAGE SimturnsInfo
 	/// Maximum number of turns that might be played simultaneously unless contact is detected
 	int optionalTurns = 0;
 	/// If set to true, human and 1 AI can act at the same time
-	bool allowHumanWithAI = false;
+	bool allowHumanWithAI = true;
 
 	template <typename Handler>
 	void serialize(Handler &h, const int version)