1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Added temporary UI for simturns testing

This commit is contained in:
Ivan Savenko 2023-09-22 21:41:32 +03:00
parent 5b21a5ffbc
commit 54adeef29f
3 changed files with 50 additions and 6 deletions

View File

@ -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;

View File

@ -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
},
],

View File

@ -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)