Moved lan/wan setting to static functions in STKHost.
This commit is contained in:
parent
15e3ac021f
commit
f05ee47e2b
@ -40,9 +40,10 @@
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
|
||||
STKHost *STKHost::m_stk_host = NULL;
|
||||
int STKHost::m_max_players = 0;
|
||||
bool STKHost::m_is_server = false;
|
||||
STKHost *STKHost::m_stk_host = NULL;
|
||||
int STKHost::m_max_players = 0;
|
||||
bool STKHost::m_is_server = false;
|
||||
STKHost::NetworkType STKHost::m_network_type = STKHost::NETWORK_NONE;
|
||||
|
||||
// ============================================================================
|
||||
/** Constructor that just initialises this object (esp. opening the packet
|
||||
|
@ -97,6 +97,11 @@ private:
|
||||
/** Maximum number of players on the server. */
|
||||
static int m_max_players;
|
||||
|
||||
enum NetworkType
|
||||
{ NETWORK_NONE, NETWORK_WAN, NETWORK_LAN };
|
||||
|
||||
static NetworkType m_network_type;
|
||||
|
||||
STKHost();
|
||||
virtual ~STKHost();
|
||||
|
||||
@ -128,6 +133,16 @@ public:
|
||||
* if a host (server or client) exists. */
|
||||
static bool isNetworking() { return m_stk_host!=NULL; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return true if it's a networked game with a LAN server. */
|
||||
static bool isLAN() { return m_network_type == NETWORK_LAN; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return true if it's a networked game but with a WAN server. */
|
||||
static bool isWAN() { return m_network_type == NETWORK_WAN; }
|
||||
// ------------------------------------------------------------------------
|
||||
static void setIsLAN() { m_network_type = NETWORK_LAN; }
|
||||
// ------------------------------------------------------------------------
|
||||
static void setIsWAN() { m_network_type = NETWORK_WAN; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
static void* mainLoop(void* self);
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "modes/demo_world.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "online/servers_manager.hpp"
|
||||
#include "states_screens/online_screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
@ -47,7 +48,6 @@ DEFINE_SCREEN_SINGLETON( CreateServerScreen );
|
||||
CreateServerScreen::CreateServerScreen() : Screen("online/create_server.stkgui")
|
||||
{
|
||||
m_server_creation_request = NULL;
|
||||
m_is_lan = false;
|
||||
} // CreateServerScreen
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -81,13 +81,13 @@ void CreateServerScreen::init()
|
||||
m_info_widget->setText("", false);
|
||||
LabelWidget *title = getWidget<LabelWidget>("title");
|
||||
|
||||
title->setText(m_is_lan ? _("Create LAN Server")
|
||||
: _("Create Server") , false);
|
||||
title->setText(STKHost::isLAN() ? _("Create LAN Server")
|
||||
: _("Create Server") , false);
|
||||
|
||||
// I18n: Name of the server. %s is either the online or local user name
|
||||
m_name_widget->setText(_("%s's server",
|
||||
m_is_lan ? PlayerManager::getCurrentPlayer()->getName()
|
||||
: PlayerManager::getCurrentOnlineUserName()
|
||||
STKHost::isLAN() ? PlayerManager::getCurrentPlayer()->getName()
|
||||
: PlayerManager::getCurrentOnlineUserName()
|
||||
)
|
||||
);
|
||||
} // init
|
||||
@ -173,7 +173,7 @@ void CreateServerScreen::serverCreationRequest()
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_is_lan)
|
||||
if (STKHost::isLAN())
|
||||
{
|
||||
const irr::core::stringw name = m_name_widget->getText().trim();
|
||||
const int max_players = m_max_players_widget->getValue();
|
||||
|
@ -35,9 +35,6 @@ class CreateServerScreen : public GUIEngine::Screen,
|
||||
private:
|
||||
friend class GUIEngine::ScreenSingleton<CreateServerScreen>;
|
||||
|
||||
/** */
|
||||
bool m_is_lan;
|
||||
|
||||
CreateServerScreen();
|
||||
|
||||
GUIEngine::TextBoxWidget * m_name_widget;
|
||||
@ -85,9 +82,6 @@ public:
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void tearDown() 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
|
||||
|
@ -494,6 +494,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
if (PlayerManager::getCurrentOnlineId())
|
||||
{
|
||||
// For 0.8.2 disable the server menu, instead go to online profile
|
||||
#define ENABLE_NETWORK_MULTIPLAYER_SCREEN
|
||||
#ifdef ENABLE_NETWORK_MULTIPLAYER_SCREEN
|
||||
OnlineScreen::getInstance()->push();
|
||||
#else
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/protocols/connect_to_server.hpp"
|
||||
#include "network/protocols/request_connection.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "online/profile_manager.hpp"
|
||||
#include "online/request.hpp"
|
||||
#include "online/servers_manager.hpp"
|
||||
@ -247,12 +248,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);
|
||||
STKHost::setIsLAN();
|
||||
CreateServerScreen::getInstance()->push();
|
||||
// TODO: create lan server
|
||||
}
|
||||
else if (selection == m_find_lan_server_widget->m_properties[PROP_ID])
|
||||
{
|
||||
STKHost::setIsLAN();
|
||||
ServerSelection::getInstance()->push();
|
||||
// TODO: find lan server;
|
||||
}
|
||||
@ -267,11 +269,12 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
else if (selection == m_find_wan_server_widget->m_properties[PROP_ID])
|
||||
{
|
||||
STKHost::setIsWAN();
|
||||
ServerSelection::getInstance()->push();
|
||||
}
|
||||
else if (selection == m_create_wan_server_widget->m_properties[PROP_ID])
|
||||
{
|
||||
CreateServerScreen::getInstance()->setIsLan(false);
|
||||
STKHost::setIsWAN();
|
||||
CreateServerScreen::getInstance()->push();
|
||||
}
|
||||
else if (selection == m_quick_wan_play_widget->m_properties[PROP_ID])
|
||||
|
Loading…
Reference in New Issue
Block a user