Some "create server" improvements in both screen and flow. Creating one doesn't actually let you join the server, but pops up the server info dialog of it, which gives you the option to join.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13329 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-07-23 20:58:24 +00:00
parent cdab5caf35
commit a632aca9c9
5 changed files with 39 additions and 46 deletions

View File

@ -4,34 +4,33 @@
<header text_align="center" width="80%" align="center" I18N="In the create server screen" text="Server Creation"/>
<spacer height="15" width="10"/>
<box proportion="4" width="90%" layout="vertical-row" align="center">
<div width="90%" align="center" layout="vertical-row" height="fit" >
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the create server screen" text="Name of the server"/>
<textbox proportion="2" id="name" I18N="In the login dialog"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the create server screen" text="Max. number of players"/>
<gauge id="max_players" proportion="2" min_value="2" max_value="12"/>
</div>
</div>
<label id="info" proportion="1" width="90%" align="center" text_align="center" word_wrap="true" text=""/>
<buttonbar id="options" x="0" y="0" width="100%" height="10%" align="center">
<icon-button id="create" width="64" height="64" icon="gui/tutorial.png" extend_label="75"
I18N="Main menu button" text="Create" label_location="hover"/>
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png" extend_label="70"
I18N="Main menu button" text="Cancel" label_location="hover"/>
</buttonbar>
<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%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the create server screen" text="Name of the server"/>
<textbox proportion="1" id="name" I18N="In the create server screen"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the create server screen" text="Max. number of players"/>
<gauge id="max_players" proportion="1" min_value="2" max_value="12"/>
</div>
</div>
<label id="info" proportion="1" width="100%" align="center" text_align="center" word_wrap="true" text=""/>
<buttonbar id="options" x="0" y="0" width="30%" height="12%" align="center">
<icon-button id="create" width="64" height="64" icon="gui/tutorial.png"
I18N="Main menu button" text="Create" label_location="bottom"/>
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
I18N="Main menu button" text="Cancel" label_location="bottom"/>
</buttonbar>
</div>
</box>
<spacer height="15" width="10"/>
</div>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
</stkgui>

View File

@ -46,7 +46,6 @@ DEFINE_SCREEN_SINGLETON( CreateServerScreen );
CreateServerScreen::CreateServerScreen() : Screen("online/create_server.stkgui")
{
m_server_creation_request = NULL;
m_enter_server = true;
} // CreateServerScreen
// ----------------------------------------------------------------------------
@ -57,8 +56,11 @@ void CreateServerScreen::loadedFromFile()
m_name_widget = getWidget<TextBoxWidget>("name");
assert(m_name_widget != NULL);
m_name_widget->setText(CurrentUser::acquire()->getUserName() + _("'s server"));
CurrentUser::release();
m_max_players_widget = getWidget<SpinnerWidget>("max_players");
assert(m_max_players_widget != NULL);
m_max_players_widget->setValue(8);
m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_widget != NULL);
@ -86,6 +88,7 @@ void CreateServerScreen::init()
Screen::init();
setInitialFocus();
DemoWorld::resetIdleTime();
m_info_widget->setText("", false);
}
// ----------------------------------------------------------------------------
void CreateServerScreen::onUpdate(float delta, irr::video::IVideoDriver* driver)
@ -96,13 +99,7 @@ void CreateServerScreen::onUpdate(float delta, irr::video::IVideoDriver* driver
{
if(m_server_creation_request->isSuccess())
{
if (m_enter_server){
new ServerInfoDialog(m_server_creation_request->getCreatedServerID(),true);
}
else
{
StateManager::get()->escapePressed();
}
new ServerInfoDialog(m_server_creation_request->getCreatedServerID(), true);
}
else
{

View File

@ -37,8 +37,6 @@ private:
CreateServerScreen();
bool m_enter_server;
GUIEngine::TextBoxWidget * m_name_widget;
GUIEngine::SpinnerWidget * m_max_players_widget;
@ -48,8 +46,6 @@ private:
GUIEngine::IconButtonWidget * m_create_widget;
GUIEngine::IconButtonWidget * m_cancel_widget;
Online::CurrentUser::ServerCreationRequest * m_server_creation_request;
/** \brief Sets which widget has to be focused. Depends on the user state. */

View File

@ -40,12 +40,13 @@ using namespace Online;
// -----------------------------------------------------------------------------
ServerInfoDialog::ServerInfoDialog(uint32_t server_id, bool join) :
ServerInfoDialog::ServerInfoDialog(uint32_t server_id, bool from_server_creation) :
ModalDialog(0.8f,0.8f)
{
m_server_id = server_id;
m_self_destroy = false;
m_enter_lobby = false;
m_from_server_creation = from_server_creation;
m_server_join_request = NULL;
loadFromFile("online/server_info_dialog.stkgui");
@ -57,7 +58,8 @@ ServerInfoDialog::ServerInfoDialog(uint32_t server_id, bool join) :
ServersManager::release();
m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_widget != NULL);
if (m_from_server_creation)
m_info_widget->setText(_("Server successfully created. You can now join it."), true);
m_options_widget = getWidget<RibbonWidget>("options");
assert(m_options_widget != NULL);
m_join_widget = getWidget<IconButtonWidget>("join");
@ -65,8 +67,7 @@ ServerInfoDialog::ServerInfoDialog(uint32_t server_id, bool join) :
m_cancel_widget = getWidget<IconButtonWidget>("cancel");
assert(m_cancel_widget != NULL);
m_options_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
if (join)
requestJoin();
}
// -----------------------------------------------------------------------------
@ -149,10 +150,10 @@ void ServerInfoDialog::onUpdate(float dt)
if (m_self_destroy)
{
ModalDialog::dismiss();
if (m_from_server_creation)
StateManager::get()->popMenu();
if (m_enter_lobby)
{
StateManager::get()->pushScreen(NetworkingLobby::getInstance());
}
return;
}
}

View File

@ -41,6 +41,7 @@ private:
bool m_self_destroy;
bool m_enter_lobby;
bool m_from_server_creation;
Online::CurrentUser::ServerJoinRequest * m_server_join_request;
float m_load_timer;
@ -57,14 +58,13 @@ private:
void requestJoin();
public:
ServerInfoDialog(uint32_t server_id, bool join = false);
ServerInfoDialog(uint32_t server_id, bool just_created = false);
~ServerInfoDialog();
void onEnterPressedInternal();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
virtual void onUpdate(float dt);
//virtual void onTextUpdated();
};
#endif