Adjust server creation screen for 1280x720

And add some more game modes
This commit is contained in:
Benau 2018-03-24 15:44:15 +08:00
parent 85895074aa
commit 946a902f98
3 changed files with 86 additions and 18 deletions

View File

@ -2,7 +2,6 @@
<stkgui> <stkgui>
<div x="0" y="0" width="100%" height="100%" layout="vertical-row" > <div x="0" y="0" width="100%" height="100%" layout="vertical-row" >
<header id="title" text_align="center" width="80%" align="center" I18N="In the server creation screen" text="Server Creation"/> <header id="title" text_align="center" width="80%" align="center" I18N="In the server creation screen" text="Server Creation"/>
<spacer height="15" width="10"/>
<box proportion="4" width="90%" layout="vertical-row" align="center"> <box proportion="4" width="90%" layout="vertical-row" align="center">
<div width="90%" align="center" layout="vertical-row" y="2%" height="96%"> <div width="90%" align="center" layout="vertical-row" y="2%" height="96%">
<div width="100%" align="center" layout="vertical-row" height="fit" > <div width="100%" align="center" layout="vertical-row" height="fit" >
@ -11,25 +10,24 @@
<textbox proportion="1" id="name" I18N="In the server creation screen"/> <textbox proportion="1" id="name" I18N="In the server creation screen"/>
</div> </div>
<spacer height="20" width="20"/> <spacer height="10" width="20"/>
<div width="100%" height="fit" layout="horizontal-row" > <div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the server creation screen" text="Max. number of players"/> <label proportion="1" text_align="left" I18N="In the server creation screen" text="Max. number of players"/>
<gauge id="max_players" proportion="1" min_value="2"/> <gauge id="max_players" proportion="1" min_value="2"/>
</div> </div>
<spacer height="20" width="20"/> <spacer height="10" width="20"/>
<div width="100%" height="fit" layout="horizontal-row" > <div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the server creation screen" text="Password (optional)"/> <label proportion="1" text_align="left" I18N="In the server creation screen" text="Password (optional)"/>
<textbox proportion="1" id="password" I18N="In the server creation screen"/> <textbox proportion="1" id="password" I18N="In the server creation screen"/>
</div> </div>
<spacer height="20" width="20"/> <spacer height="5" width="20"/>
<label width="100%" height="fit" text_align="left" I18N="In the server creation screen" text="Difficulty"/> <label width="100%" height="fit" text_align="left" I18N="In the server creation screen" text="Difficulty"/>
<!--<gauge id="difficulty" proportion="1" min_value="1" max_value="4"/>--> <ribbon id="difficulty" height="90" width="90%" align="center">
<ribbon id="difficulty" height="135" width="90%" align="center">
<icon-button id="novice" width="128" height="128" icon="gui/difficulty_easy.png" <icon-button id="novice" width="128" height="128" icon="gui/difficulty_easy.png"
I18N="Difficulty" text="Novice"/> I18N="Difficulty" text="Novice"/>
<icon-button id="intermediate" width="128" height="128" icon="gui/difficulty_medium.png" <icon-button id="intermediate" width="128" height="128" icon="gui/difficulty_medium.png"
@ -39,20 +37,23 @@
<icon-button id="best" width="128" height="128" icon="gui/difficulty_best.png" <icon-button id="best" width="128" height="128" icon="gui/difficulty_best.png"
I18N="Difficulty" text="SuperTux"/> I18N="Difficulty" text="SuperTux"/>
</ribbon> </ribbon>
<spacer height="20" width="20"/>
<label width="100%" height="fit" text_align="left" I18N="In the server creation screen" text="Game mode"/> <label width="100%" height="fit" text_align="left" I18N="In the server creation screen" text="Game mode"/>
<ribbon id="gamemode" height="135" width="50%" align="center"> <ribbon id="gamemode" height="90" width="90%" align="center">
<icon-button id="normal" width="128" height="128" icon="gui/mode_normal.png" <icon-button id="normal" width="128" height="128" icon="gui/mode_normal.png"
I18N="Multiplayer game mode" text="Normal Race"/> I18N="Multiplayer game mode" text="Normal Race"/>
<icon-button id="timetrial" width="128" height="128" icon="gui/mode_tt.png" <icon-button id="timetrial" width="128" height="128" icon="gui/mode_tt.png"
I18N="Multiplayer game mode" text="Time Trial"/> I18N="Multiplayer game mode" text="Time Trial"/>
<icon-button id="3strikes" width="128" height="128" icon="gui/mode_3strikes.png"
I18N="Multiplayer game mode" text="3 Strikes Battle"/>
<icon-button id="soccer" width="128" height="128" icon="gui/mode_soccer.png"
I18N="Multiplayer game mode" text="Soccer"/>
</ribbon> </ribbon>
<!--
<scrollable_toolbar id="gamemode" height="135" width="90%" label_location="bottom" align="center" <spacer height="10" width="20"/>
child_width="135" child_height="135" /> <div width="100%" height="fit" layout="horizontal-row" >
--> <label id="more-options" proportion="1" text_align="left"/>
<spinner id="more-options-spinner" proportion="1" wrap_around="true"/>
</div>
</div> </div>
<label id="info" proportion="1" width="100%" align="center" text_align="center" word_wrap="true" text=""/> <label id="info" proportion="1" width="100%" align="center" text_align="center" word_wrap="true" text=""/>
@ -63,8 +64,8 @@
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png" <icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
I18N="In the server creation screen" text="Cancel" label_location="bottom"/> I18N="In the server creation screen" text="Cancel" label_location="bottom"/>
</buttonbar> </buttonbar>
</div> </div>
</box> </box>
<spacer height="15" width="10"/>
</div> </div>
</stkgui> </stkgui>

View File

@ -60,7 +60,7 @@ void CreateServerScreen::loadedFromFile()
assert(m_max_players_widget != NULL); assert(m_max_players_widget != NULL);
int max = UserConfigParams::m_server_max_players.getDefaultValue(); int max = UserConfigParams::m_server_max_players.getDefaultValue();
m_max_players_widget->setMax(max); m_max_players_widget->setMax(max);
if (UserConfigParams::m_server_max_players > max) if (UserConfigParams::m_server_max_players > max)
UserConfigParams::m_server_max_players = max; UserConfigParams::m_server_max_players = max;
@ -69,8 +69,15 @@ void CreateServerScreen::loadedFromFile()
m_info_widget = getWidget<LabelWidget>("info"); m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_widget != NULL); assert(m_info_widget != NULL);
m_more_options_text = getWidget<LabelWidget>("more-options");
assert(m_more_options_text != NULL);
m_more_options_spinner = getWidget<SpinnerWidget>("more-options-spinner");
assert(m_more_options_spinner != NULL);
m_options_widget = getWidget<RibbonWidget>("options"); m_options_widget = getWidget<RibbonWidget>("options");
assert(m_options_widget != NULL); assert(m_options_widget != NULL);
m_game_mode_widget = getWidget<RibbonWidget>("gamemode");
assert(m_game_mode_widget != NULL);
m_create_widget = getWidget<IconButtonWidget>("create"); m_create_widget = getWidget<IconButtonWidget>("create");
assert(m_create_widget != NULL); assert(m_create_widget != NULL);
m_cancel_widget = getWidget<IconButtonWidget>("cancel"); m_cancel_widget = getWidget<IconButtonWidget>("cancel");
@ -107,6 +114,7 @@ void CreateServerScreen::init()
RibbonWidget* gamemode = getWidget<RibbonWidget>("gamemode"); RibbonWidget* gamemode = getWidget<RibbonWidget>("gamemode");
assert(gamemode != NULL); assert(gamemode != NULL);
gamemode->setSelection(0, PLAYER_ID_GAME_MASTER); gamemode->setSelection(0, PLAYER_ID_GAME_MASTER);
updateMoreOption(0);
} // init } // init
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -129,8 +137,63 @@ void CreateServerScreen::eventCallback(Widget* widget, const std::string& name,
createServer(); createServer();
} // is create_widget } // 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 } // 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 /** Called once per framce to check if the server creation request has
* finished. If so, if pushes the server creation sceen. * finished. If so, if pushes the server creation sceen.

View File

@ -39,14 +39,18 @@ private:
GUIEngine::TextBoxWidget * m_name_widget; GUIEngine::TextBoxWidget * m_name_widget;
GUIEngine::SpinnerWidget * m_max_players_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::LabelWidget * m_info_widget;
GUIEngine::RibbonWidget * m_game_mode_widget;
GUIEngine::RibbonWidget * m_options_widget; GUIEngine::RibbonWidget * m_options_widget;
GUIEngine::IconButtonWidget * m_create_widget; GUIEngine::IconButtonWidget * m_create_widget;
GUIEngine::IconButtonWidget * m_cancel_widget; GUIEngine::IconButtonWidget * m_cancel_widget;
void createServer(); void createServer();
void updateMoreOption(int game_mode);
public: public: