1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Initial version of Turn Options tab screen

This commit is contained in:
Ivan Savenko 2023-11-09 16:41:00 +02:00
parent 3268ebe27c
commit 32633d5f52
10 changed files with 273 additions and 48 deletions

View File

@ -220,14 +220,24 @@
"vcmi.randomMapTab.widgets.teamAlignmentsLabel" : "Team Alignments",
"vcmi.randomMapTab.widgets.roadTypesLabel" : "Road Types",
"vcmi.optionsTab.widgets.chessFieldBase.help" : "{Extra timer}\n\nStarts counting down when the {turn timer} reaches zero. It is set only once at the beginning of the game. When this timer reaches zero, the player's turn ends.",
"vcmi.optionsTab.widgets.chessFieldTurn.help" : "{Turn timer}\n\nStarts counting down when the player starts their turn on the adventure map. It is reset to its initial value at the start of each turn. Any unused turn time will be added to the {Extra timer} if it is in use.",
"vcmi.optionsTab.widgets.chessFieldBattle.help" : "{Battle timer}\n\nCounts down during battles when the {stack timer} reaches zero. It is reset to its initial value at the start of each battle. If the timer reaches zero, the currently active stack will defend.",
"vcmi.optionsTab.widgets.chessFieldCreature.help" : "{Stack timer}\n\nStarts counting down when the player is selecting an action for the current stack during battle. It resets to its initial value after the stack's action is completed.",
"vcmi.optionsTab.widgets.labelTimer" : "Timer",
"vcmi.optionsTab.widgets.timerModeSwitch.classic" : "Classic timer",
"vcmi.optionsTab.widgets.timerModeSwitch.chess" : "Chess timer",
"vcmi.optionsTab.turnOptions.hover" : "Turn Options",
"vcmi.optionsTab.turnOptions.help" : "Select turn timer and simultaneous turns options",
"vcmi.optionsTab.chessFieldBase.hover" : "Base timer",
"vcmi.optionsTab.chessFieldTurn.hover" : "Turn timer",
"vcmi.optionsTab.chessFieldBattle.hover" : "Battle timer",
"vcmi.optionsTab.chessFieldCreature.hover" : "Unit timer",
"vcmi.optionsTab.chessFieldBase.help" : "Starts counting down when the {Turn Timer} reaches zero. It is set only once at the beginning of the game. When this timer reaches zero, the player's turn ends.",
"vcmi.optionsTab.chessFieldTurn.help" : "Starts counting down when the player starts their turn on the adventure map. It is reset to its initial value at the start of each turn. Any unused turn time will be added to the {Extra Timer} if it is in use.",
"vcmi.optionsTab.chessFieldBattle.help" : "Counts down during battles when the {Unit Timer} reaches zero. It is reset to its initial value at the start of each battle. If the timer reaches zero, the currently active stack will defend.",
"vcmi.optionsTab.chessFieldCreature.help" : "Starts counting down when the player is selecting an action for the current stack during battle. It resets to its initial value after the stack's action is completed.",
"vcmi.optionsTab.simturnsMin.hover" : "Simultaneous turns (minimum)",
"vcmi.optionsTab.simturnsMax.hover" : "Simultaneous turns (maximum)",
"vcmi.optionsTab.simturnsAI.hover" : "(Experimental) Simultaneous AI Turns",
"vcmi.optionsTab.simturnsMin.help" : "Players will act simultaneously for specified number of days. Contacts between players are blocked",
"vcmi.optionsTab.simturnsMax.help" : "Players will act simultaneously until they meet each other or if specified date has been reached",
"vcmi.optionsTab.simturnsAI.help" : "",
// Custom victory conditions for H3 campaigns and HotA maps
"vcmi.map.victoryCondition.daysPassed.toOthers" : "The enemy has managed to survive till this day. Victory is theirs!",

View File

@ -51,6 +51,7 @@ set(client_SRCS
lobby/CSavingScreen.cpp
lobby/CScenarioInfoScreen.cpp
lobby/CSelectionBase.cpp
lobby/TurnOptionsTab.cpp
lobby/OptionsTab.cpp
lobby/OptionsTabBase.cpp
lobby/RandomMapTab.cpp
@ -212,6 +213,7 @@ set(client_HEADERS
lobby/CSavingScreen.h
lobby/CScenarioInfoScreen.h
lobby/CSelectionBase.h
lobby/TurnOptionsTab.h
lobby/OptionsTab.h
lobby/OptionsTabBase.h
lobby/RandomMapTab.h

View File

@ -8,14 +8,15 @@
*
*/
#include "StdInc.h"
#include "CLobbyScreen.h"
#include "CBonusSelection.h"
#include "SelectionTab.h"
#include "RandomMapTab.h"
#include "OptionsTab.h"
#include "../CServerHandler.h"
#include "CBonusSelection.h"
#include "TurnOptionsTab.h"
#include "OptionsTab.h"
#include "RandomMapTab.h"
#include "SelectionTab.h"
#include "../CServerHandler.h"
#include "../gui/CGuiHandler.h"
#include "../gui/Shortcut.h"
#include "../widgets/Buttons.h"
@ -50,6 +51,7 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
});
buttonOptions = std::make_shared<CButton>(Point(411, 510), AnimationPath::builtin("GSPBUTT.DEF"), CGI->generaltexth->zelp[46], std::bind(&CLobbyScreen::toggleTab, this, tabOpt), EShortcut::LOBBY_ADDITIONAL_OPTIONS);
buttonTurnOptions = std::make_shared<CButton>(Point(619, 510), AnimationPath::builtin("GSPBUT2.DEF"), CGI->generaltexth->zelp[46], std::bind(&CLobbyScreen::toggleTab, this, tabTurnOptions), EShortcut::NONE);
};
buttonChat = std::make_shared<CButton>(Point(619, 80), AnimationPath::builtin("GSPBUT2.DEF"), CGI->generaltexth->zelp[48], std::bind(&CLobbyScreen::toggleChat, this), EShortcut::LOBBY_HIDE_CHAT);
@ -60,6 +62,7 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
case ESelectionScreen::newGame:
{
tabOpt = std::make_shared<OptionsTab>();
tabTurnOptions = std::make_shared<TurnOptionsTab>();
tabRand = std::make_shared<RandomMapTab>();
tabRand->mapInfoChanged += std::bind(&IServerAPI::setMapInfo, CSH, _1, _2);
buttonRMG = std::make_shared<CButton>(Point(411, 105), AnimationPath::builtin("GSPBUTT.DEF"), CGI->generaltexth->zelp[47], 0, EShortcut::LOBBY_RANDOM_MAP);
@ -78,6 +81,7 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
case ESelectionScreen::loadGame:
{
tabOpt = std::make_shared<OptionsTab>();
tabTurnOptions = std::make_shared<TurnOptionsTab>();
buttonStart = std::make_shared<CButton>(Point(411, 535), AnimationPath::builtin("SCNRLOD.DEF"), CGI->generaltexth->zelp[103], std::bind(&CLobbyScreen::startScenario, this, true), EShortcut::LOBBY_LOAD_GAME);
initLobby();
break;
@ -145,6 +149,7 @@ void CLobbyScreen::toggleMode(bool host)
auto buttonColor = host ? Colors::WHITE : Colors::ORANGE;
buttonSelect->addTextOverlay(CGI->generaltexth->allTexts[500], FONT_SMALL, buttonColor);
buttonOptions->addTextOverlay(CGI->generaltexth->allTexts[501], FONT_SMALL, buttonColor);
buttonTurnOptions->addTextOverlay(CGI->generaltexth->translate("vcmi.optionsTab.turnOptions.hover"), FONT_SMALL, buttonColor);
if(buttonRMG)
{
buttonRMG->addTextOverlay(CGI->generaltexth->allTexts[740], FONT_SMALL, buttonColor);
@ -152,9 +157,13 @@ void CLobbyScreen::toggleMode(bool host)
}
buttonSelect->block(!host);
buttonOptions->block(!host);
buttonTurnOptions->block(!host);
if(CSH->mi)
{
tabOpt->recreate();
tabTurnOptions->recreate();
}
}
void CLobbyScreen::toggleChat()
@ -168,8 +177,13 @@ void CLobbyScreen::toggleChat()
void CLobbyScreen::updateAfterStateChange()
{
if(CSH->mi && tabOpt)
tabOpt->recreate();
if(CSH->mi)
{
if (tabOpt)
tabOpt->recreate();
if (tabTurnOptions)
tabTurnOptions->recreate();
}
buttonStart->block(CSH->mi == nullptr || CSH->isGuest());

View File

@ -26,6 +26,7 @@ class CAnimImage;
class CToggleGroup;
class RandomMapTab;
class OptionsTab;
class TurnOptionsTab;
class SelectionTab;
class InfoCard;
class CChatBox;
@ -57,12 +58,14 @@ public:
std::shared_ptr<CButton> buttonSelect;
std::shared_ptr<CButton> buttonRMG;
std::shared_ptr<CButton> buttonOptions;
std::shared_ptr<CButton> buttonTurnOptions;
std::shared_ptr<CButton> buttonStart;
std::shared_ptr<CButton> buttonBack;
std::shared_ptr<CButton> buttonSimturns;
std::shared_ptr<SelectionTab> tabSel;
std::shared_ptr<OptionsTab> tabOpt;
std::shared_ptr<TurnOptionsTab> tabTurnOptions;
std::shared_ptr<RandomMapTab> tabRand;
std::shared_ptr<CIntObject> curTab;

View File

@ -43,7 +43,7 @@
#include "../../lib/mapping/CMapHeader.h"
OptionsTab::OptionsTab()
: OptionsTabBase(JsonPath::builtin("config/widgets/optionsTab.json"))
: OptionsTabBase(JsonPath::builtin("config/widgets/playerOptionsTab.json"))
, humanPlayers(0)
{
}

View File

@ -190,7 +190,7 @@ void OptionsTabBase::recreate()
if(auto w = widget<CLabel>("labelSimturnsDurationValue"))
{
MetaString message;
message.appendRawString("Simturns: up to %d days");
message.appendRawString("%d days");
message.replaceNumber(SEL->getStartInfo()->simturnsInfo.optionalTurns);
w->setText(message.toString());
}

View File

@ -0,0 +1,18 @@
/*
* TurnOptionsTab.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "TurnOptionsTab.h"
TurnOptionsTab::TurnOptionsTab()
: OptionsTabBase(JsonPath::builtin("config/widgets/turnOptionsTab.json"))
{
}

View File

@ -0,0 +1,18 @@
/*
* TurnOptionsTab.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "OptionsTabBase.h"
class TurnOptionsTab : public OptionsTabBase
{
public:
TurnOptionsTab();
};

View File

@ -73,41 +73,16 @@
"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": "white",
"text": "",
"position": {"x": 319, "y": 545}
"color": "yellow",
"text": "core.genrltxt.521",
"position": {"x": 222, "y": 544}
},
// timer
//{
// "type": "label",
// "font": "small",
// "alignment": "center",
// "color": "yellow",
// "text": "core.genrltxt.521",
// "position": {"x": 222, "y": 544}
//},
{
"name": "labelTurnDurationValue",
"type": "label",
@ -129,8 +104,7 @@
"itemsTotal": 11,
"selected": 11,
"style": "blue",
"scrollBounds": {"x": 0, "y": 0, "w": 194, "h": 32},
//"scrollBounds": {"x": -3, "y": -25, "w": 337, "h": 43},
"scrollBounds": {"x": -3, "y": -25, "w": 337, "h": 43},
"panningStep": 20
},
],

View File

@ -0,0 +1,186 @@
{
"customTypes" : {
"verticalLayout66" : {
"type" : "layout",
"vertical" : true,
"dynamic" : false,
"distance" : 66
},
"labelTitle" : {
"type": "label",
"font": "small",
"alignment": "left",
"color": "yellow"
},
"labelDescription" : {
"type": "multiLineLabel",
"font": "small",
"alignment": "center",
"color": "white",
"rect": {"x": 0, "y": 0, "w": 300, "h": 35},
"adoptHeight": true
},
"timeInput" : {
"type": "textInput",
"background": "timerField",
"alignment": "center",
"text": "00:00",
"rect": {"x": 0, "y": 0, "w": 84, "h": 25},
"offset": {"x": 0, "y": 0}
}
},
"items":
[
{
"name": "background",
"type": "picture",
"image": "RANMAPBK",
"position": {"x": 0, "y": 6}
},
{
"name": "labelTitle",
"type": "label",
"font": "big",
"alignment": "center",
"color": "yellow",
"text": "vcmi.optionsTab.turnOptions.hover",
"position": {"x": 222, "y": 36}
},
{
"name": "labelSubTitle",
"type": "multiLineLabel",
"font": "small",
"alignment": "center",
"color": "white",
"text": "vcmi.optionsTab.turnOptions.help",
"rect": {"x": 60, "y": 48, "w": 320, "h": 0},
"adoptHeight": true
},
{
"type" : "verticalLayout66",
"customType" : "labelTitle",
"position": {"x": 70, "y": 134},
"items":
[
{
"text": "vcmi.optionsTab.chessFieldBase.hover"
},
{
"text": "vcmi.optionsTab.chessFieldTurn.hover"
},
{
"text": "vcmi.optionsTab.chessFieldBattle.hover"
},
{
"text": "vcmi.optionsTab.chessFieldCreature.hover"
},
{
"text": "vcmi.optionsTab.simturnsMin.hover"
},
{
"text": "vcmi.optionsTab.simturnsMax.hover"
}
]
},
{
"type" : "verticalLayout66",
"customType" : "labelDescription",
"position": {"x": 70, "y": 153},
"items":
[
{
"text": "vcmi.optionsTab.chessFieldBase.help"
},
{
"text": "vcmi.optionsTab.chessFieldTurn.help"
},
{
"text": "vcmi.optionsTab.chessFieldBattle.help"
},
{
"text": "vcmi.optionsTab.chessFieldCreature.help"
},
{
"text": "vcmi.optionsTab.simturnsMin.help"
},
{
"text": "vcmi.optionsTab.simturnsMax.help"
}
]
},
{
"type" : "verticalLayout66",
"customType" : "timeInput",
"position": {"x": 294, "y": 129},
"items":
[
{
"name": "chessFieldBase",
"callback": "parseAndSetTimer_base",
"help": "vcmi.optionsTab.chessFieldBase.help"
},
{
"name": "chessFieldTurn",
"callback": "parseAndSetTimer_turn",
"help": "vcmi.optionsTab.chessFieldTurn.help"
},
{
"name": "chessFieldBattle",
"callback": "parseAndSetTimer_battle",
"help": "vcmi.optionsTab.chessFieldBattle.help"
},
{
"name": "chessFieldCreature",
"callback": "parseAndSetTimer_creature",
"help": "vcmi.optionsTab.chessFieldCreature.help"
},
]
},
// simturns
{
"name": "simturnsDuration",
"type": "slider",
"orientation": "horizontal",
"position": {"x": 258, "y": 398},
"size": 120,
"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": "white",
"text": "",
"position": {"x": 320, "y": 406}
},
{
"position": {"x": 70, "y": 535},
"type": "toggleButton",
"image": "sysopchk.def"
},
{
"name": "labelSimturnsAI",
"type": "label",
"font": "small",
"alignment": "left",
"color": "yellow",
"text": "vcmi.optionsTab.simturnsAI.hover",
"position": {"x": 110, "y": 540}
}
]
}