Fixed reloading bug in server selection

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13320 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-07-22 20:00:08 +00:00
parent bf2d907ccf
commit 311fb7bf4b
6 changed files with 33 additions and 16 deletions

View File

@ -1,19 +1,19 @@
<stkgui>
<div x="0" y="0" width="100%" height="100%" layout="vertical-row" >
<header text_align="center" width="80%" align="center" I18N="In the lobby settings screen" text="Lobby Settings"/>
<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 lobby settings screen" text="Name of the server"/>
<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 lobby settings screen" text="Max. number of players"/>
<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>

View File

@ -31,7 +31,7 @@
<spacer width="10" height="10" />
<buttonbar id="menu_bottomrow" x="0" y="0" width="20%" height="100%" align="center">
<buttonbar id="menu_bottomrow" x="0" y="0" width="10%" height="100%" align="center">
<icon-button id="sign_in" width="64" height="64" icon="gui/main_about.png" extend_label="50"
I18N="Main menu button" text="Sign In" label_location="hover"/>
<icon-button id="register" width="64" height="64" icon="gui/tutorial.png" extend_label="75"

View File

@ -65,6 +65,12 @@ namespace Online{
m_servers = new PtrVector<Server>;
m_info_message = "";
m_last_load_time = 0.0f;
m_joined_server = NULL;
}
ServersManager::~ServersManager(){
m_servers->clearAndDeleteAll();
delete m_joined_server;
}
// ============================================================================
@ -91,7 +97,7 @@ namespace Online{
{
m_servers->push_back(new Server(*servers_xml->getNode(i)));
}
m_last_load_time += Time::getRealTime();
m_last_load_time = Time::getRealTime();
}
m_info_message = input->getInfo();
//FIXME error message

View File

@ -48,6 +48,7 @@ namespace Online {
private:
ServersManager();
~ServersManager();
PtrVector<Server> * m_servers;
bool m_not_fetched;
Server * m_joined_server;

View File

@ -56,9 +56,11 @@ void ServerSelection::refresh()
{
m_refresh_request = ServersManager::acquire()->refreshRequest();
ServersManager::release();
m_fake_refresh = (m_refresh_request == NULL ? true : false);
m_server_list_widget->clear();
m_server_list_widget->addItem("spacer", L"");
m_server_list_widget->addItem("loading", Messages::fetchingServers());
m_reload_widget->setDeactivated();
}
@ -67,8 +69,9 @@ void ServerSelection::refresh()
void ServerSelection::loadedFromFile()
{
m_back_widget = getWidget<GUIEngine::IconButtonWidget>("back");
assert(m_back_widget != NULL);
m_reload_widget = getWidget<GUIEngine::IconButtonWidget>("reload");
assert(m_reload_widget != NULL);
m_server_list_widget = getWidget<GUIEngine::ListWidget>("server_list");
assert(m_server_list_widget != NULL);
m_server_list_widget->setColumnListener(this);
@ -89,7 +92,7 @@ void ServerSelection::init()
{
Screen::init();
m_sort_desc = true;
m_reload_widget->setActivated();
// Set the default sort order
Server::setSortOrder(Server::SO_NAME);
@ -194,11 +197,17 @@ void ServerSelection::onUpdate(float dt, irr::video::IVideoDriver*)
}
delete m_refresh_request;
m_refresh_request = NULL;
//m_options_widget->setActivated();
m_reload_widget->setActivated();
}
else
{
m_server_list_widget->renameItem("loading", Messages::fetchingServers());
}
}
else if(m_fake_refresh)
{
loadList();
m_fake_refresh = false;
m_reload_widget->setActivated();
}
} // onUpdate

View File

@ -38,22 +38,23 @@ private:
ServerSelection();
~ServerSelection();
GUIEngine::IconButtonWidget * m_back_widget;
GUIEngine::IconButtonWidget * m_reload_widget;
GUIEngine::LabelWidget * m_update_status;
GUIEngine::ListWidget * m_server_list_widget;
GUIEngine::IconButtonWidget * m_back_widget;
GUIEngine::IconButtonWidget * m_reload_widget;
GUIEngine::LabelWidget * m_update_status;
GUIEngine::ListWidget * m_server_list_widget;
/** Currently selected type. */
std::string m_type;
std::string m_type;
/** The currently selected index, used to re-select this item after
* addons_loading is being displayed. */
int m_selected_index;
int m_selected_index;
/** \brief To check (and set) if sort order is descending **/
bool m_sort_desc;
bool m_sort_desc;
Online::ServersManager::RefreshRequest * m_refresh_request;
Online::ServersManager::RefreshRequest * m_refresh_request;
bool m_fake_refresh;
void refresh();
public: