From 946a902f98726c582eeaff88d0c3938825666f0c Mon Sep 17 00:00:00 2001 From: Benau Date: Sat, 24 Mar 2018 15:44:15 +0800 Subject: [PATCH] Adjust server creation screen for 1280x720 And add some more game modes --- data/gui/online/create_server.stkgui | 35 +++++------ src/states_screens/create_server_screen.cpp | 65 ++++++++++++++++++++- src/states_screens/create_server_screen.hpp | 4 ++ 3 files changed, 86 insertions(+), 18 deletions(-) diff --git a/data/gui/online/create_server.stkgui b/data/gui/online/create_server.stkgui index 9f5fce33e..ed18d5abc 100644 --- a/data/gui/online/create_server.stkgui +++ b/data/gui/online/create_server.stkgui @@ -2,7 +2,6 @@
-
@@ -11,25 +10,24 @@
- +
- +
- - - + + +
-
diff --git a/src/states_screens/create_server_screen.cpp b/src/states_screens/create_server_screen.cpp index ddca30f85..a5c0f8716 100644 --- a/src/states_screens/create_server_screen.cpp +++ b/src/states_screens/create_server_screen.cpp @@ -60,7 +60,7 @@ void CreateServerScreen::loadedFromFile() assert(m_max_players_widget != NULL); int max = UserConfigParams::m_server_max_players.getDefaultValue(); m_max_players_widget->setMax(max); - + if (UserConfigParams::m_server_max_players > max) UserConfigParams::m_server_max_players = max; @@ -69,8 +69,15 @@ void CreateServerScreen::loadedFromFile() m_info_widget = getWidget("info"); assert(m_info_widget != NULL); + m_more_options_text = getWidget("more-options"); + assert(m_more_options_text != NULL); + m_more_options_spinner = getWidget("more-options-spinner"); + assert(m_more_options_spinner != NULL); + m_options_widget = getWidget("options"); assert(m_options_widget != NULL); + m_game_mode_widget = getWidget("gamemode"); + assert(m_game_mode_widget != NULL); m_create_widget = getWidget("create"); assert(m_create_widget != NULL); m_cancel_widget = getWidget("cancel"); @@ -107,6 +114,7 @@ void CreateServerScreen::init() RibbonWidget* gamemode = getWidget("gamemode"); assert(gamemode != NULL); gamemode->setSelection(0, PLAYER_ID_GAME_MASTER); + updateMoreOption(0); } // init // ---------------------------------------------------------------------------- @@ -129,8 +137,63 @@ void CreateServerScreen::eventCallback(Widget* widget, const std::string& name, createServer(); } // is create_widget } + else if (name == m_game_mode_widget->m_properties[PROP_ID]) + { + const int selection = + m_game_mode_widget->getSelection(PLAYER_ID_GAME_MASTER); + updateMoreOption(selection); + } + } // eventCallback +// ---------------------------------------------------------------------------- +void CreateServerScreen::updateMoreOption(int game_mode) +{ + switch (game_mode) + { + case 0: + case 1: + { + m_more_options_text->setVisible(true); + //I18N: In the create server screen + m_more_options_text->setText(_("No. of grand prix track(s)"), + false); + m_more_options_spinner->setVisible(true); + m_more_options_spinner->clearLabels(); + m_more_options_spinner->addLabel(_("Disabled")); + for (int i = 1; i <= 20; i++) + { + m_more_options_spinner->addLabel + (StringUtils::utf8ToWide(StringUtils::toString(i))); + } + m_more_options_spinner->setValue(0); + break; + } + case 3: + { + m_more_options_text->setVisible(true); + m_more_options_spinner->setVisible(true); + m_more_options_spinner->clearLabels(); + //I18N: In the create server screen + m_more_options_text->setText(_("Soccer game type"), false); + m_more_options_spinner->setVisible(true); + m_more_options_spinner->clearLabels(); + //I18N: In the create server screen for soccer server + m_more_options_spinner->addLabel(_("Time limit")); + //I18N: In the create server screen for soccer server + m_more_options_spinner->addLabel(_("Goals limit")); + m_more_options_spinner->setValue(0); + break; + } + default: + { + m_more_options_text->setVisible(false); + m_more_options_spinner->setVisible(false); + break; + } + } +} // updateMoreOption + // ---------------------------------------------------------------------------- /** Called once per framce to check if the server creation request has * finished. If so, if pushes the server creation sceen. diff --git a/src/states_screens/create_server_screen.hpp b/src/states_screens/create_server_screen.hpp index 5429d6ec2..2793ef98a 100644 --- a/src/states_screens/create_server_screen.hpp +++ b/src/states_screens/create_server_screen.hpp @@ -39,14 +39,18 @@ private: GUIEngine::TextBoxWidget * m_name_widget; GUIEngine::SpinnerWidget * m_max_players_widget; + GUIEngine::SpinnerWidget* m_more_options_spinner; + GUIEngine::LabelWidget * m_more_options_text; GUIEngine::LabelWidget * m_info_widget; + GUIEngine::RibbonWidget * m_game_mode_widget; GUIEngine::RibbonWidget * m_options_widget; GUIEngine::IconButtonWidget * m_create_widget; GUIEngine::IconButtonWidget * m_cancel_widget; void createServer(); + void updateMoreOption(int game_mode); public: