Merge branch 'master' of https://github.com/supertuxkart/stk-code
This commit is contained in:
commit
fbf158eaa4
BIN
data/CREDITS
BIN
data/CREDITS
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<stkgui>
|
||||
<div x="0" y="0" width="100%" height="100%" layout="vertical-row" >
|
||||
<header 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">
|
||||
<div width="90%" align="center" layout="vertical-row" y="2%" height="96%">
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<stkgui>
|
||||
<div x="0" y="0" width="100%" height="fit" layout="vertical-row">
|
||||
<button id="user-id" width="20%" height="fit" align="right"/>
|
||||
</div>
|
||||
|
||||
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row" >
|
||||
|
||||
<header text_align="center" width="80%" align="center" I18N="In the online multiplayer screen" text="Online Multiplayer"/>
|
||||
@ -17,7 +21,7 @@
|
||||
I18N="In the online multiplayer screen" text="Create Server"/>
|
||||
<icon-button id="manage_user" width="128" height="128"
|
||||
icon="gui/options_players.png"
|
||||
I18N="In the online multiplayer screen" text="Local Users"/>
|
||||
I18N="In the online multiplayer screen" text="Users"/>
|
||||
</buttonbar>
|
||||
</box>
|
||||
|
||||
|
@ -626,12 +626,12 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( BoolUserConfigParam(true, "weather_gfx",
|
||||
&m_graphics_quality, "Weather effects") );
|
||||
PARAM_PREFIX IntUserConfigParam m_show_steering_animations
|
||||
PARAM_DEFAULT( IntUserConfigParam(ANIMS_ALL,
|
||||
PARAM_DEFAULT( IntUserConfigParam(ANIMS_PLAYERS_ONLY,
|
||||
"steering_animations", &m_graphics_quality,
|
||||
"Whether to display kart animations (0=disabled for all; "
|
||||
"1=enabled for humans, disabled for AIs; 2=enabled for all") );
|
||||
PARAM_PREFIX IntUserConfigParam m_anisotropic
|
||||
PARAM_DEFAULT( IntUserConfigParam(8, "anisotropic",
|
||||
PARAM_DEFAULT( IntUserConfigParam(4, "anisotropic",
|
||||
&m_graphics_quality,
|
||||
"Quality of anisotropic filtering (usual values include 2-4-8-16; 0 to disable)") );
|
||||
PARAM_PREFIX BoolUserConfigParam m_trilinear
|
||||
@ -666,7 +666,7 @@ namespace UserConfigParams
|
||||
"shadows_resoltion", &m_graphics_quality,
|
||||
"Shadow resolution (0 = disabled") );
|
||||
PARAM_PREFIX BoolUserConfigParam m_degraded_IBL
|
||||
PARAM_DEFAULT(BoolUserConfigParam(false,
|
||||
PARAM_DEFAULT(BoolUserConfigParam(true,
|
||||
"Degraded_IBL", &m_graphics_quality,
|
||||
"Disable specular IBL"));
|
||||
|
||||
|
@ -96,6 +96,7 @@ GPUTimer m_perf_query[Q_LAST];
|
||||
|
||||
const int MIN_SUPPORTED_HEIGHT = 768;
|
||||
const int MIN_SUPPORTED_WIDTH = 1024;
|
||||
const bool ALLOW_1280_X_720 = true;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** The constructor creates the irrlicht device. It first creates a NULL
|
||||
@ -327,8 +328,9 @@ void IrrDriver::createListOfVideoModes()
|
||||
{
|
||||
const int w = modes->getVideoModeResolution(i).Width;
|
||||
const int h = modes->getVideoModeResolution(i).Height;
|
||||
if ( (h < MIN_SUPPORTED_HEIGHT || w < MIN_SUPPORTED_WIDTH) &&
|
||||
( ! (h==600 && w==800 && UserConfigParams::m_artist_debug_mode) ) )
|
||||
if ((h < MIN_SUPPORTED_HEIGHT || w < MIN_SUPPORTED_WIDTH) &&
|
||||
(!(h==600 && w==800 && UserConfigParams::m_artist_debug_mode) &&
|
||||
(!(h==720 && w==1280 && ALLOW_1280_X_720 == true))))
|
||||
continue;
|
||||
|
||||
VideoMode mode(w, h);
|
||||
|
@ -28,7 +28,7 @@ namespace Online
|
||||
{
|
||||
Server::SortOrder Server::m_sort_order = Server::SO_NAME;
|
||||
|
||||
Server::Server(const XMLNode & xml)
|
||||
Server::Server(const XMLNode & xml, bool is_lan)
|
||||
{
|
||||
assert(xml.getName() == "server");
|
||||
|
||||
@ -37,9 +37,10 @@ namespace Online
|
||||
m_server_id = 0;
|
||||
m_current_players = 0;
|
||||
m_max_players = 0;
|
||||
m_is_lan = is_lan;
|
||||
|
||||
xml.get("name", &m_lower_case_name);
|
||||
m_name = StringUtils::xmlDecode(m_lower_case_name);
|
||||
m_name = StringUtils::xmlDecode(m_lower_case_name);
|
||||
m_lower_case_name = StringUtils::toLowerCase(m_lower_case_name);
|
||||
|
||||
xml.get("id", &m_server_id);
|
||||
@ -49,6 +50,18 @@ namespace Online
|
||||
|
||||
} // Server(const XML&)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
Server::Server(const core::stringw &name, bool is_lan, int max_players,
|
||||
int current_players)
|
||||
{
|
||||
m_name = name;
|
||||
m_satisfaction_score = 0;
|
||||
m_server_id = 0;
|
||||
m_current_players = current_players;
|
||||
m_max_players = max_players;
|
||||
m_is_lan = is_lan;
|
||||
} // server(name, ...)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/**
|
||||
* \brief Filter the add-on with a list of words.
|
||||
|
@ -65,6 +65,9 @@ namespace Online
|
||||
/** The score/rating given */
|
||||
float m_satisfaction_score;
|
||||
|
||||
/** True if this server is on the LAN, false otherwise. */
|
||||
bool m_is_lan;
|
||||
|
||||
/** The sort order to be used in the comparison. */
|
||||
static SortOrder m_sort_order;
|
||||
|
||||
@ -73,8 +76,9 @@ namespace Online
|
||||
public:
|
||||
|
||||
/** Initialises the object from an XML node. */
|
||||
Server(const XMLNode & xml);
|
||||
|
||||
Server(const XMLNode &xml, bool is_lan);
|
||||
Server(const core::stringw &name, bool is_lan, int max_players,
|
||||
int current_players);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the sort order used in the comparison function. It is static, so
|
||||
* that each instance can access the sort order. */
|
||||
|
@ -18,13 +18,14 @@
|
||||
|
||||
#include "online/servers_manager.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <irrString.h>
|
||||
#include <assert.h>
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "utils/time.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <irrString.h>
|
||||
#include <string>
|
||||
|
||||
#define SERVER_REFRESH_INTERVAL 5.0f
|
||||
|
||||
namespace Online
|
||||
@ -37,29 +38,31 @@ namespace Online
|
||||
manager_singleton = new ServersManager();
|
||||
|
||||
return manager_singleton;
|
||||
}
|
||||
} // get
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void ServersManager::deallocate()
|
||||
{
|
||||
delete manager_singleton;
|
||||
manager_singleton = NULL;
|
||||
} // deallocate
|
||||
|
||||
// ============================================================================
|
||||
// ========================================================================
|
||||
ServersManager::ServersManager()
|
||||
{
|
||||
m_last_load_time.setAtomic(0.0f);
|
||||
m_joined_server.setAtomic(NULL);
|
||||
}
|
||||
} // ServersManager
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
ServersManager::~ServersManager()
|
||||
{
|
||||
cleanUpServers();
|
||||
MutexLocker(m_joined_server);
|
||||
delete m_joined_server.getData();
|
||||
}
|
||||
} // ~ServersManager
|
||||
|
||||
// ============================================================================
|
||||
// ------------------------------------------------------------------------
|
||||
void ServersManager::cleanUpServers()
|
||||
{
|
||||
m_sorted_servers.lock();
|
||||
@ -68,12 +71,12 @@ namespace Online
|
||||
m_mapped_servers.lock();
|
||||
m_mapped_servers.getData().clear();
|
||||
m_mapped_servers.unlock();
|
||||
}
|
||||
} // cleanUpServers
|
||||
|
||||
// ============================================================================
|
||||
ServersManager::RefreshRequest * ServersManager::refreshRequest(bool request_now) const
|
||||
// ------------------------------------------------------------------------
|
||||
ServersManager::RefreshRequest* ServersManager::refreshRequest(bool request_now) const
|
||||
{
|
||||
RefreshRequest * request = NULL;
|
||||
RefreshRequest* request = NULL;
|
||||
if(StkTime::getRealTime() - m_last_load_time.getAtomic() > SERVER_REFRESH_INTERVAL)
|
||||
{
|
||||
request = new RefreshRequest();
|
||||
@ -84,9 +87,14 @@ namespace Online
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
} // refreshRequest
|
||||
|
||||
void ServersManager::refresh(bool success, const XMLNode * input)
|
||||
// ------------------------------------------------------------------------
|
||||
/** Callback from the refresh request.
|
||||
* \param success If the refresh was successful.
|
||||
* \param input The XML data describing the server.
|
||||
*/
|
||||
void ServersManager::refresh(bool success, const XMLNode *input)
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
@ -94,30 +102,31 @@ namespace Online
|
||||
return;
|
||||
}
|
||||
|
||||
const XMLNode * servers_xml = input->getNode("servers");
|
||||
const XMLNode *servers_xml = input->getNode("servers");
|
||||
cleanUpServers();
|
||||
for (unsigned int i = 0; i < servers_xml->getNumNodes(); i++)
|
||||
{
|
||||
addServer(new Server(*servers_xml->getNode(i)));
|
||||
addServer(new Server(*servers_xml->getNode(i), /*is_lan*/false));
|
||||
}
|
||||
m_last_load_time.setAtomic((float)StkTime::getRealTime());
|
||||
}
|
||||
} // refresh
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void ServersManager::RefreshRequest::callback()
|
||||
{
|
||||
ServersManager::get()->refresh(isSuccess(), getXMLData());
|
||||
}
|
||||
} // callback
|
||||
|
||||
// ============================================================================
|
||||
const Server * ServersManager::getQuickPlay() const
|
||||
// ------------------------------------------------------------------------
|
||||
const Server* ServersManager::getQuickPlay() const
|
||||
{
|
||||
if(m_sorted_servers.getData().size() > 0)
|
||||
return getServerBySort(0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
} // getQuickPlay
|
||||
|
||||
// ============================================================================
|
||||
// ------------------------------------------------------------------------
|
||||
void ServersManager::setJoinedServer(uint32_t id)
|
||||
{
|
||||
MutexLocker(m_joined_server);
|
||||
@ -125,18 +134,18 @@ namespace Online
|
||||
|
||||
// It's a copy!
|
||||
m_joined_server.getData() = new Server(*getServerByID(id));
|
||||
}
|
||||
} // setJoinedServer
|
||||
|
||||
// ============================================================================
|
||||
// ------------------------------------------------------------------------
|
||||
void ServersManager::unsetJoinedServer()
|
||||
{
|
||||
MutexLocker(m_joined_server);
|
||||
delete m_joined_server.getData();
|
||||
m_joined_server.getData() = NULL;
|
||||
}
|
||||
} // unsetJoinedServer
|
||||
|
||||
// ============================================================================
|
||||
void ServersManager::addServer(Server * server)
|
||||
// ------------------------------------------------------------------------
|
||||
void ServersManager::addServer(Server *server)
|
||||
{
|
||||
m_sorted_servers.lock();
|
||||
m_sorted_servers.getData().push_back(server);
|
||||
@ -145,40 +154,40 @@ namespace Online
|
||||
m_mapped_servers.lock();
|
||||
m_mapped_servers.getData()[server->getServerId()] = server;
|
||||
m_mapped_servers.unlock();
|
||||
}
|
||||
} // addServer
|
||||
|
||||
// ============================================================================
|
||||
// ------------------------------------------------------------------------
|
||||
int ServersManager::getNumServers () const
|
||||
{
|
||||
MutexLocker(m_sorted_servers);
|
||||
return m_sorted_servers.getData().size();
|
||||
}
|
||||
} // getNumServers
|
||||
|
||||
// ============================================================================
|
||||
const Server * ServersManager::getServerBySort (int index) const
|
||||
// ------------------------------------------------------------------------
|
||||
const Server* ServersManager::getServerBySort (int index) const
|
||||
{
|
||||
MutexLocker(m_sorted_servers);
|
||||
return m_sorted_servers.getData().get(index);
|
||||
}
|
||||
} // getServerBySort
|
||||
|
||||
// ============================================================================
|
||||
const Server * ServersManager::getServerByID (uint32_t id) const
|
||||
// ------------------------------------------------------------------------
|
||||
const Server* ServersManager::getServerByID (uint32_t id) const
|
||||
{
|
||||
MutexLocker(m_mapped_servers);
|
||||
return m_mapped_servers.getData().at(id);
|
||||
}
|
||||
} // getServerByID
|
||||
|
||||
// ============================================================================
|
||||
Server * ServersManager::getJoinedServer() const
|
||||
// ------------------------------------------------------------------------
|
||||
Server* ServersManager::getJoinedServer() const
|
||||
{
|
||||
return m_joined_server.getAtomic();
|
||||
}
|
||||
} // getJoinedServer
|
||||
|
||||
// ============================================================================
|
||||
// ------------------------------------------------------------------------
|
||||
void ServersManager::sort(bool sort_desc)
|
||||
{
|
||||
MutexLocker(m_sorted_servers);
|
||||
m_sorted_servers.getData().insertionSort(0, sort_desc);
|
||||
}
|
||||
} // sort
|
||||
|
||||
} // namespace Online
|
||||
|
@ -19,12 +19,12 @@
|
||||
#ifndef HEADER_SERVERS_MANAGER_HPP
|
||||
#define HEADER_SERVERS_MANAGER_HPP
|
||||
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "utils/types.hpp"
|
||||
#include "online/server.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "online/server.hpp"
|
||||
#include "online/xml_request.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "utils/synchronised.hpp"
|
||||
#include "utils/types.hpp"
|
||||
|
||||
namespace Online
|
||||
{
|
||||
@ -35,17 +35,19 @@ namespace Online
|
||||
class ServersManager
|
||||
{
|
||||
public:
|
||||
|
||||
// ====================================================================
|
||||
class RefreshRequest : public XMLRequest
|
||||
{
|
||||
virtual void callback ();
|
||||
public:
|
||||
RefreshRequest() : XMLRequest() {}
|
||||
};
|
||||
}; // RefreshRequest
|
||||
// ====================================================================
|
||||
|
||||
private:
|
||||
ServersManager();
|
||||
~ServersManager();
|
||||
|
||||
/** Sorted vector of servers */
|
||||
Synchronised<PtrVector<Server> > m_sorted_servers;
|
||||
|
||||
@ -53,29 +55,29 @@ namespace Online
|
||||
Synchronised<std::map<uint32_t, Server*> > m_mapped_servers;
|
||||
|
||||
/** This is a pointer to a copy of the server, the moment it got joined */
|
||||
Synchronised<Server *> m_joined_server;
|
||||
Synchronised<Server *> m_joined_server;
|
||||
|
||||
Synchronised<float> m_last_load_time;
|
||||
void refresh(bool success, const XMLNode * input);
|
||||
void cleanUpServers();
|
||||
Synchronised<float> m_last_load_time;
|
||||
void refresh(bool success, const XMLNode * input);
|
||||
void cleanUpServers();
|
||||
|
||||
public:
|
||||
// Singleton
|
||||
static ServersManager* get();
|
||||
static void deallocate();
|
||||
static ServersManager* get();
|
||||
static void deallocate();
|
||||
|
||||
RefreshRequest * refreshRequest(bool request_now = true) const;
|
||||
void setJoinedServer(uint32_t server_id);
|
||||
void unsetJoinedServer();
|
||||
void addServer(Server * server);
|
||||
int getNumServers () const;
|
||||
const Server * getServerByID (uint32_t server_id) const;
|
||||
const Server * getServerBySort (int index) const;
|
||||
void sort(bool sort_desc);
|
||||
Server * getJoinedServer() const;
|
||||
RefreshRequest * refreshRequest(bool request_now = true) const;
|
||||
void setJoinedServer(uint32_t server_id);
|
||||
void unsetJoinedServer();
|
||||
void addServer(Server * server);
|
||||
int getNumServers () const;
|
||||
const Server * getServerByID (uint32_t server_id) const;
|
||||
const Server * getServerBySort (int index) const;
|
||||
void sort(bool sort_desc);
|
||||
Server * getJoinedServer() const;
|
||||
|
||||
// Returns the best server to join
|
||||
const Server * getQuickPlay() const;
|
||||
const Server * getQuickPlay() const;
|
||||
|
||||
}; // class ServersManager
|
||||
} // namespace Online
|
||||
|
@ -47,6 +47,7 @@ DEFINE_SCREEN_SINGLETON( CreateServerScreen );
|
||||
CreateServerScreen::CreateServerScreen() : Screen("online/create_server.stkgui")
|
||||
{
|
||||
m_server_creation_request = NULL;
|
||||
m_is_lan = false;
|
||||
} // CreateServerScreen
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -89,7 +90,12 @@ void CreateServerScreen::init()
|
||||
setInitialFocus();
|
||||
DemoWorld::resetIdleTime();
|
||||
m_info_widget->setText("", false);
|
||||
}
|
||||
LabelWidget *title = getWidget<LabelWidget>("title");
|
||||
|
||||
title->setText(m_is_lan ? _("Create LAN Server")
|
||||
: _("Create Server") , false);
|
||||
} // init
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CreateServerScreen::onUpdate(float delta)
|
||||
{
|
||||
@ -99,7 +105,8 @@ void CreateServerScreen::onUpdate(float delta)
|
||||
{
|
||||
if(m_server_creation_request->isSuccess())
|
||||
{
|
||||
new ServerInfoDialog(m_server_creation_request->getCreatedServerID(), true);
|
||||
new ServerInfoDialog(m_server_creation_request->getCreatedServerID(),
|
||||
true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -124,22 +131,36 @@ void CreateServerScreen::onUpdate(float delta)
|
||||
// ----------------------------------------------------------------------------
|
||||
void CreateServerScreen::serverCreationRequest()
|
||||
{
|
||||
if (m_is_lan)
|
||||
{
|
||||
const irr::core::stringw name = m_name_widget->getText().trim();
|
||||
const int max_players = m_max_players_widget->getValue();
|
||||
Server *server = new Server(name, /*lan*/true, max_players,
|
||||
/*current_player*/1);
|
||||
ServersManager::get()->addServer(server);
|
||||
return;
|
||||
}
|
||||
|
||||
// Now must be WAN: forward request to the stk server
|
||||
const irr::core::stringw name = m_name_widget->getText().trim();
|
||||
const int max_players = m_max_players_widget->getValue();
|
||||
m_info_widget->setErrorColor();
|
||||
if (name.size() < 4 || name.size() > 30)
|
||||
{
|
||||
m_info_widget->setText(_("Name has to be between 4 and 30 characters long!"), false);
|
||||
m_info_widget->setText(
|
||||
_("Name has to be between 4 and 30 characters long!"), false);
|
||||
}
|
||||
else if (max_players < 2 || max_players > 12)
|
||||
{
|
||||
m_info_widget->setText(_("The maxinum number of players has to be between 2 and 12."), false);
|
||||
m_info_widget->setText(
|
||||
_("The maxinum number of players has to be between 2 and 12."), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
m_server_creation_request = new ServerCreationRequest();
|
||||
PlayerManager::setUserDetails(m_server_creation_request, "create", Online::API::SERVER_PATH);
|
||||
PlayerManager::setUserDetails(m_server_creation_request, "create",
|
||||
Online::API::SERVER_PATH);
|
||||
m_server_creation_request->addParameter("name", name);
|
||||
m_server_creation_request->addParameter("max_players", max_players);
|
||||
m_server_creation_request->queue();
|
||||
@ -147,13 +168,18 @@ void CreateServerScreen::serverCreationRequest()
|
||||
return;
|
||||
}
|
||||
SFXManager::get()->quickSound("anvil");
|
||||
}
|
||||
// --------------------------------------------------------------------
|
||||
} // serverCreationRequest
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Callbacks from the online create server request.
|
||||
*/
|
||||
void CreateServerScreen::ServerCreationRequest::callback()
|
||||
{
|
||||
if (isSuccess())
|
||||
{
|
||||
Server *server = new Server(*getXMLData()->getNode("server"));
|
||||
// Must be a LAN server
|
||||
Server *server = new Server(*getXMLData()->getNode("server"),
|
||||
/*is lan*/false);
|
||||
ServersManager::get()->addServer(server);
|
||||
m_created_server_id = server->getServerId();
|
||||
} // isSuccess
|
||||
@ -165,7 +191,8 @@ void CreateServerScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
{
|
||||
if (name == m_options_widget->m_properties[PROP_ID])
|
||||
{
|
||||
const std::string& selection = m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
const std::string& selection =
|
||||
m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
if (selection == m_cancel_widget->m_properties[PROP_ID])
|
||||
{
|
||||
StateManager::get()->escapePressed();
|
||||
@ -173,7 +200,7 @@ void CreateServerScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
else if (selection == m_create_widget->m_properties[PROP_ID])
|
||||
{
|
||||
serverCreationRequest();
|
||||
}
|
||||
} // is create_widget
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
|
@ -35,6 +35,9 @@ class CreateServerScreen : public GUIEngine::Screen,
|
||||
private:
|
||||
friend class GUIEngine::ScreenSingleton<CreateServerScreen>;
|
||||
|
||||
/** */
|
||||
bool m_is_lan;
|
||||
|
||||
CreateServerScreen();
|
||||
|
||||
GUIEngine::TextBoxWidget * m_name_widget;
|
||||
@ -93,6 +96,10 @@ public:
|
||||
|
||||
/** \brief Implements the callback when a dialog gets closed. */
|
||||
virtual void onDialogClose() OVERRIDE;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets if a lan or wan server is to be created. */
|
||||
void setIsLan(bool is_lan) { m_is_lan = is_lan; }
|
||||
}; // class CreateServerScreen
|
||||
|
||||
#endif
|
||||
|
@ -67,6 +67,9 @@ OnlineScreen::~OnlineScreen()
|
||||
|
||||
void OnlineScreen::loadedFromFile()
|
||||
{
|
||||
m_user_id = getWidget<ButtonWidget>("user-id");
|
||||
assert(m_user_id);
|
||||
|
||||
m_back_widget = getWidget<IconButtonWidget>("back");
|
||||
assert(m_back_widget != NULL);
|
||||
|
||||
@ -87,9 +90,6 @@ void OnlineScreen::loadedFromFile()
|
||||
m_quick_wan_play_widget = getWidget<IconButtonWidget>("quick_wan_play");
|
||||
assert(m_quick_wan_play_widget != NULL);
|
||||
|
||||
m_online_status_widget = getWidget<LabelWidget>("online_status");
|
||||
assert(m_online_status_widget != NULL);
|
||||
|
||||
m_bottom_menu_widget = getWidget<RibbonWidget>("menu_bottomrow");
|
||||
assert(m_bottom_menu_widget != NULL);
|
||||
m_profile_widget = getWidget<IconButtonWidget>("profile");
|
||||
@ -135,6 +135,14 @@ void OnlineScreen::beforeAddingWidget()
|
||||
m_create_wan_server_widget->setActive(false);
|
||||
m_profile_widget->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_quick_wan_play_widget->setActive(true);
|
||||
m_find_wan_server_widget->setActive(true);
|
||||
m_create_wan_server_widget->setActive(true);
|
||||
m_sign_out_widget->setVisible(true);
|
||||
m_profile_widget->setVisible(true);
|
||||
}
|
||||
|
||||
} // beforeAddingWidget
|
||||
|
||||
@ -144,30 +152,28 @@ void OnlineScreen::init()
|
||||
Screen::init();
|
||||
setInitialFocus();
|
||||
DemoWorld::resetIdleTime();
|
||||
core::stringw m = _("Logged in as: %s.",
|
||||
PlayerManager::getCurrentOnlineUserName());
|
||||
m_online_status_widget->setText(m, false);
|
||||
|
||||
} // init
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void OnlineScreen::onUpdate(float delta)
|
||||
{
|
||||
PlayerProfile *player = PlayerManager::getCurrentPlayer();
|
||||
if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
|
||||
{
|
||||
m_user_id->setText(player->getLastOnlineName() + "@stk");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_user_id->setText(player->getName());
|
||||
}
|
||||
|
||||
if (hasStateChanged())
|
||||
{
|
||||
GUIEngine::reshowCurrentScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_recorded_state == PlayerProfile::OS_SIGNING_IN)
|
||||
{
|
||||
m_online_status_widget->setText(StringUtils::loadingDots(_("Logging in")),
|
||||
false );
|
||||
}
|
||||
else if (m_recorded_state == PlayerProfile::OS_SIGNING_OUT)
|
||||
{
|
||||
m_online_status_widget->setText(StringUtils::loadingDots(_("Logging out")),
|
||||
false );
|
||||
}
|
||||
} // onUpdate
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -241,10 +247,13 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
else if (selection == m_create_lan_server_widget->m_properties[PROP_ID])
|
||||
{
|
||||
CreateServerScreen::getInstance()->setIsLan(true);
|
||||
CreateServerScreen::getInstance()->push();
|
||||
// TODO: create lan server
|
||||
}
|
||||
else if (selection == m_find_lan_server_widget->m_properties[PROP_ID])
|
||||
{
|
||||
ServerSelection::getInstance()->push();
|
||||
// TODO: find lan server;
|
||||
}
|
||||
else if (selection == m_manage_user->m_properties[PROP_ID])
|
||||
@ -262,6 +271,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
else if (selection == m_create_wan_server_widget->m_properties[PROP_ID])
|
||||
{
|
||||
CreateServerScreen::getInstance()->setIsLan(false);
|
||||
CreateServerScreen::getInstance()->push();
|
||||
}
|
||||
else if (selection == m_quick_wan_play_widget->m_properties[PROP_ID])
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
namespace GUIEngine { class Widget; class ListWidget; }
|
||||
namespace GUIEngine { class Widget; class ListWidget; class ButtonWidget; }
|
||||
|
||||
/**
|
||||
* \brief Handles the main menu
|
||||
@ -40,23 +40,24 @@ private:
|
||||
OnlineScreen();
|
||||
~OnlineScreen();
|
||||
|
||||
GUIEngine::IconButtonWidget * m_back_widget;
|
||||
GUIEngine::IconButtonWidget *m_back_widget;
|
||||
|
||||
GUIEngine::RibbonWidget * m_top_menu_widget;
|
||||
GUIEngine::IconButtonWidget * m_find_lan_server_widget;
|
||||
GUIEngine::IconButtonWidget * m_create_lan_server_widget;
|
||||
GUIEngine::IconButtonWidget * m_manage_user;
|
||||
GUIEngine::RibbonWidget *m_top_menu_widget;
|
||||
GUIEngine::IconButtonWidget *m_find_lan_server_widget;
|
||||
GUIEngine::IconButtonWidget *m_create_lan_server_widget;
|
||||
GUIEngine::IconButtonWidget *m_manage_user;
|
||||
|
||||
GUIEngine::IconButtonWidget * m_find_wan_server_widget;
|
||||
GUIEngine::IconButtonWidget * m_create_wan_server_widget;
|
||||
GUIEngine::IconButtonWidget * m_quick_wan_play_widget;
|
||||
GUIEngine::IconButtonWidget *m_find_wan_server_widget;
|
||||
GUIEngine::IconButtonWidget *m_create_wan_server_widget;
|
||||
GUIEngine::IconButtonWidget *m_quick_wan_play_widget;
|
||||
|
||||
GUIEngine::LabelWidget * m_online_status_widget;
|
||||
GUIEngine::RibbonWidget *m_bottom_menu_widget;
|
||||
GUIEngine::IconButtonWidget *m_register_widget;
|
||||
GUIEngine::IconButtonWidget *m_profile_widget;
|
||||
GUIEngine::IconButtonWidget *m_sign_out_widget;
|
||||
|
||||
GUIEngine::RibbonWidget * m_bottom_menu_widget;
|
||||
GUIEngine::IconButtonWidget * m_register_widget;
|
||||
GUIEngine::IconButtonWidget * m_profile_widget;
|
||||
GUIEngine::IconButtonWidget * m_sign_out_widget;
|
||||
/** Keep the widget to to the user name. */
|
||||
GUIEngine::ButtonWidget *m_user_id;
|
||||
|
||||
PlayerProfile::OnlineState m_recorded_state;
|
||||
|
||||
|
@ -64,7 +64,7 @@ void ServerSelection::refresh()
|
||||
m_server_list_widget->addItem("loading",
|
||||
StringUtils::loadingDots(_("Fetching servers")));
|
||||
m_reload_widget->setActive(false);
|
||||
}
|
||||
} // refresh
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -88,7 +88,8 @@ void ServerSelection::beforeAddingWidget()
|
||||
m_server_list_widget->clearColumns();
|
||||
m_server_list_widget->addColumn( _("Name"), 3 );
|
||||
m_server_list_widget->addColumn( _("Players"), 1);
|
||||
}
|
||||
} // beforeAddingWidget
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void ServerSelection::init()
|
||||
@ -110,11 +111,11 @@ void ServerSelection::init()
|
||||
void ServerSelection::loadList()
|
||||
{
|
||||
m_server_list_widget->clear();
|
||||
ServersManager * manager = ServersManager::get();
|
||||
ServersManager *manager = ServersManager::get();
|
||||
manager->sort(m_sort_desc);
|
||||
for(int i=0; i < manager->getNumServers(); i++)
|
||||
{
|
||||
const Server * server = manager->getServerBySort(i);
|
||||
const Server *server = manager->getServerBySort(i);
|
||||
core::stringw num_players;
|
||||
num_players.append(StringUtils::toWString(server->getCurrentPlayers()));
|
||||
num_players.append("/");
|
||||
|
@ -46,8 +46,12 @@ private:
|
||||
/** \brief To check (and set) if sort order is descending **/
|
||||
bool m_sort_desc;
|
||||
|
||||
const Online::ServersManager::RefreshRequest * m_refresh_request;
|
||||
const Online::ServersManager::RefreshRequest *m_refresh_request;
|
||||
bool m_fake_refresh;
|
||||
|
||||
/** True if only lan servers should be shown. */
|
||||
bool m_is_lan;
|
||||
|
||||
void refresh();
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user