Переглянути джерело

Implement AI simturns checkbox

Ivan Savenko 2 роки тому
батько
коміт
d1ae5bbee5
2 змінених файлів з 10 додано та 0 видалено
  1. 9 0
      client/lobby/OptionsTabBase.cpp
  2. 1 0
      config/widgets/turnOptionsTab.json

+ 9 - 0
client/lobby/OptionsTabBase.cpp

@@ -53,6 +53,12 @@ OptionsTabBase::OptionsTabBase(const JsonPath & configPath)
 		CSH->setSimturnsInfo(info);
 	});
 
+	addCallback("setSimturnAI", [&](int index){
+		SimturnsInfo info = SEL->getStartInfo()->simturnsInfo;
+		info.allowHumanWithAI = 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
 	// normal: 2:00, 12:30
@@ -237,6 +243,9 @@ void OptionsTabBase::recreate()
 	if(auto w = widget<CLabel>("labelSimturnsDurationValueMax"))
 		w->setText(generateSimturnsDurationText(SEL->getStartInfo()->simturnsInfo.optionalTurns));
 
+	if(auto buttonSimturnsAI = widget<CToggleButton>("buttonSimturnsAI"))
+		buttonSimturnsAI->setSelectedSilent(SEL->getStartInfo()->simturnsInfo.allowHumanWithAI);
+
 	const auto & turnTimerRemote = SEL->getStartInfo()->turnTimerInfo;
 
 	//classic timer

+ 1 - 0
config/widgets/turnOptionsTab.json

@@ -267,6 +267,7 @@
 			"rect": {"x": 70, "y": 480, "w": 300, "h": 40}
 		},
 		{
+			"name": "buttonSimturnsAI",
 			"position": {"x": 70, "y": 535},
 			"type": "toggleButton",
 			"image": "lobby/checkbox"