Merge remote-tracking branch 'origin/master' into fix_replay

This commit is contained in:
Benau 2016-02-17 14:03:58 +08:00
commit 64522d9d13
19 changed files with 327 additions and 492 deletions

View File

@ -1,63 +0,0 @@
<?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"/>
<spacer height="5%" width="25"/>
<box width="100%" height="38%" padding="10" layout="vertical-row">
<bright width="100%" text="Local Networking" align="center" text_align="left" />
<buttonbar id="lan" proportion="2" width="90%" align="center">
<icon-button id="find_lan_server" width="128" height="128"
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
I18N="In the online multiplayer screen" text="Find Server"/>
<icon-button id="create_lan_server" width="128" height="128"
icon="gui/online/menu_create_server.png" focus_icon="gui/online/menu_create_server_hover.png"
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="Users"/>
</buttonbar>
</box>
<spacer height="5%" width="25"/>
<box width="100%" height="38%" padding="10" layout="vertical-row">
<bright width="100%" text="Global Networking" align="center" text_align="left" />
<buttonbar id="menu_top_row" proportion="2" width="90%" align="center">
<icon-button id="find_wan_server" width="128" height="128"
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
I18N="In the online multiplayer screen" text="Find Server"/>
<icon-button id="create_wan_server" width="128" height="128"
icon="gui/online/menu_create_server.png" focus_icon="gui/online/menu_create_server_hover.png"
I18N="In the online multiplayer screen" text="Create Server"/>
<icon-button id="quick_wan_play" width="128" height="128"
icon="gui/online/menu_quick_play.png" focus_icon="gui/online/menu_quick_play_hover.png"
I18N="In the online multiplayer screen" text="Quick Play"/>
</buttonbar>
</box>
<bottombar x="2%" width="96%" height="10%" layout="horizontal-row">
<label text_align="left" align="center" height="100%" id="online_status" proportion="1" text=""/>
<spacer width="10" height="10" />
<buttonbar id="menu_bottomrow" x="0" y="0" width="12%" height="100%" align="center">
<icon-button id="profile" width="64" height="64" icon="gui/green_check.png" extend_label="50"
I18N="In the online multiplayer screen" text="Profile" label_location="hover"/>
<icon-button id="sign_out" width="64" height="64" icon="gui/main_quit.png" extend_label="70"
I18N="In the online multiplayer screen" text="Log Out" label_location="hover"/>
</buttonbar>
</bottombar>
</div>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
</stkgui>

View File

@ -9,6 +9,7 @@
<spacer height="25" width="10"/> <spacer height="25" width="10"/>
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center"> <tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_servers" width="128" height="128" icon="gui/main_network.png"/>
<icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png" <icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"
I18N="Section in the profile screen" text="Achievements"/> I18N="Section in the profile screen" text="Achievements"/>
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png"/> <icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png"/>

View File

@ -9,6 +9,7 @@
<spacer height="25" width="10"/> <spacer height="25" width="10"/>
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center"> <tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_servers" width="128" height="128" icon="gui/main_network.png"/>
<icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"/> <icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"/>
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png" <icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png"
I18N="Section in the profile screen" text="Friends"/> I18N="Section in the profile screen" text="Friends"/>

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
<div x="1%" y="1%" width="98%" height="98%" layout="vertical-row" >
<header id="title" text_align="center" width="80%" align="center" text="..."/>
<spacer height="25" width="10"/>
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_servers" width="128" height="128" icon="gui/main_network.png" I18N="Section in the profile screen" text="Servers"/>
<icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"/>
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png" />
<icon-button id="tab_settings" width="128" height="128" icon="gui/main_options.png" />
</tabs>
<box proportion="1" width="100%" layout="vertical-row">
<div x="1%" y="2%" width="98%" height="96%" layout="vertical-row" >
<spacer height="5%" width="25"/>
<box width="100%" proportion="1" padding="10" layout="vertical-row">
<bright width="100%" text="Local Networking" align="center" text_align="left" />
<buttonbar id="lan" proportion="2" width="90%" align="center">
<icon-button id="find_lan_server" width="128" height="128"
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
I18N="In the online multiplayer screen" text="Find Server"/>
<icon-button id="create_lan_server" width="128" height="128"
icon="gui/online/menu_create_server.png" focus_icon="gui/online/menu_create_server_hover.png"
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="Users"/>
-->
</buttonbar>
</box>
<spacer height="5%" width="25"/>
<box width="100%" proportion="1" padding="10" layout="vertical-row">
<bright width="100%" text="Global Networking" align="center" text_align="left" />
<buttonbar id="wan" proportion="2" width="90%" align="center">
<icon-button id="find_wan_server" width="128" height="128"
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
I18N="In the online multiplayer screen" text="Find Server"/>
<icon-button id="create_wan_server" width="128" height="128"
icon="gui/online/menu_create_server.png" focus_icon="gui/online/menu_create_server_hover.png"
I18N="In the online multiplayer screen" text="Create Server"/>
<icon-button id="quick_wan_play" width="128" height="128"
icon="gui/online/menu_quick_play.png" focus_icon="gui/online/menu_quick_play_hover.png"
I18N="In the online multiplayer screen" text="Quick Play"/>
</buttonbar>
</box>
</div>
</box>
</div>
</stkgui>

View File

@ -8,6 +8,7 @@
<spacer height="25" width="10"/> <spacer height="25" width="10"/>
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center"> <tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_servers" width="128" height="128" icon="gui/main_network.png"/>
<icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"/> <icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"/>
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png" /> <icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png" />
<icon-button id="tab_settings" width="128" height="128" icon="gui/main_options.png" <icon-button id="tab_settings" width="128" height="128" icon="gui/main_options.png"

View File

@ -26,7 +26,6 @@
#include "network/network_config.hpp" #include "network/network_config.hpp"
#include "network/servers_manager.hpp" #include "network/servers_manager.hpp"
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
#include "states_screens/online_screen.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "states_screens/dialogs/message_dialog.hpp" #include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/networking_lobby.hpp" #include "states_screens/networking_lobby.hpp"

View File

@ -44,7 +44,7 @@
#include "states_screens/help_screen_1.hpp" #include "states_screens/help_screen_1.hpp"
#include "states_screens/offline_kart_selection.hpp" #include "states_screens/offline_kart_selection.hpp"
#include "states_screens/online_profile_achievements.hpp" #include "states_screens/online_profile_achievements.hpp"
#include "states_screens/online_screen.hpp" #include "states_screens/online_profile_servers.hpp"
#include "states_screens/options_screen_video.hpp" #include "states_screens/options_screen_video.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "states_screens/user_screen.hpp" #include "states_screens/user_screen.hpp"
@ -490,15 +490,11 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
"\"Connect to the Internet\".")); "\"Connect to the Internet\"."));
return; return;
} }
if (PlayerManager::getCurrentOnlineId()) if (PlayerManager::getCurrentOnlineId())
{ {
// For 0.8.2 disable the server menu, instead go to online profile
#ifdef ENABLE_NETWORK_MULTIPLAYER_SCREEN
OnlineScreen::getInstance()->push();
#else
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId()); ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
TabOnlineProfileAchievements::getInstance()->push(); OnlineProfileServers::getInstance()->push();
#endif
} }
else else
{ {

View File

@ -23,6 +23,7 @@
#include <iostream> #include <iostream>
#include "challenges/unlock_manager.hpp" #include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "guiengine/scalable_font.hpp" #include "guiengine/scalable_font.hpp"
#include "guiengine/widgets/icon_button_widget.hpp" #include "guiengine/widgets/icon_button_widget.hpp"
@ -37,7 +38,6 @@
#include "network/protocols/client_lobby_room_protocol.hpp" #include "network/protocols/client_lobby_room_protocol.hpp"
#include "network/servers_manager.hpp" #include "network/servers_manager.hpp"
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
#include "states_screens/online_screen.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "states_screens/dialogs/message_dialog.hpp" #include "states_screens/dialogs/message_dialog.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"

View File

@ -87,8 +87,11 @@ void BaseOnlineProfileAchievements::init()
{ {
OnlineProfileBase::init(); OnlineProfileBase::init();
if (m_profile_tabs) if (m_profile_tabs)
{
m_profile_tabs->select(m_achievements_tab->m_properties[PROP_ID], m_profile_tabs->select(m_achievements_tab->m_properties[PROP_ID],
PLAYER_ID_GAME_MASTER); PLAYER_ID_GAME_MASTER);
m_profile_tabs->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
// For current user add the progrss information. // For current user add the progrss information.
// m_visiting_profile is NULL if the user is not logged in. // m_visiting_profile is NULL if the user is not logged in.

View File

@ -27,6 +27,7 @@
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include "states_screens/online_profile_friends.hpp" #include "states_screens/online_profile_friends.hpp"
#include "states_screens/online_profile_achievements.hpp" #include "states_screens/online_profile_achievements.hpp"
#include "states_screens/online_profile_servers.hpp"
#include "states_screens/online_profile_settings.hpp" #include "states_screens/online_profile_settings.hpp"
#include <iostream> #include <iostream>
@ -41,6 +42,10 @@ using namespace Online;
OnlineProfileBase::OnlineProfileBase(const std::string &filename) OnlineProfileBase::OnlineProfileBase(const std::string &filename)
: Screen(filename.c_str()) : Screen(filename.c_str())
{ {
m_servers_tab = NULL;
m_friends_tab = NULL;
m_achievements_tab = NULL;
m_settings_tab = NULL;
} // OnlineProfileBase } // OnlineProfileBase
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -53,15 +58,20 @@ void OnlineProfileBase::loadedFromFile()
m_header = getWidget<LabelWidget>("title"); m_header = getWidget<LabelWidget>("title");
assert(m_header != NULL); assert(m_header != NULL);
m_friends_tab = !m_profile_tabs ? NULL : if (m_profile_tabs != NULL)
(IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_friends"); {
assert(m_profile_tabs == NULL || m_friends_tab != NULL); m_friends_tab = (IconButtonWidget *)m_profile_tabs->findWidgetNamed("tab_friends");
m_achievements_tab = !m_profile_tabs ? NULL : assert(m_friends_tab != NULL);
(IconButtonWidget*)m_profile_tabs->findWidgetNamed("tab_achievements");
assert(m_profile_tabs == NULL || m_achievements_tab != NULL); m_servers_tab = (IconButtonWidget *)m_profile_tabs->findWidgetNamed("tab_servers");
m_settings_tab = !m_profile_tabs ? NULL : assert(m_servers_tab != NULL);
(IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_settings");
assert(m_profile_tabs == NULL || m_settings_tab != NULL); m_achievements_tab = (IconButtonWidget*)m_profile_tabs->findWidgetNamed("tab_achievements");
assert(m_profile_tabs == NULL || m_achievements_tab != NULL);
m_settings_tab = (IconButtonWidget *)m_profile_tabs->findWidgetNamed("tab_settings");
assert(m_settings_tab != NULL);
}
} // loadedFromFile } // loadedFromFile
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -96,6 +106,7 @@ void OnlineProfileBase::init()
if (m_profile_tabs) if (m_profile_tabs)
{ {
m_servers_tab->setTooltip(_("Servers"));
m_friends_tab->setTooltip(_("Friends")); m_friends_tab->setTooltip(_("Friends"));
m_achievements_tab->setTooltip(_("Achievements")); m_achievements_tab->setTooltip(_("Achievements"));
m_settings_tab->setTooltip(_("Account Settings")); m_settings_tab->setTooltip(_("Account Settings"));
@ -147,6 +158,8 @@ void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name,
sm->replaceTopMostScreen(TabOnlineProfileAchievements::getInstance()); sm->replaceTopMostScreen(TabOnlineProfileAchievements::getInstance());
else if (selection == m_settings_tab->m_properties[PROP_ID]) else if (selection == m_settings_tab->m_properties[PROP_ID])
sm->replaceTopMostScreen(OnlineProfileSettings::getInstance()); sm->replaceTopMostScreen(OnlineProfileSettings::getInstance());
else if (selection == m_servers_tab->m_properties[PROP_ID])
sm->replaceTopMostScreen(OnlineProfileServers::getInstance());
} }
else if (name == "back") else if (name == "back")
{ {

View File

@ -42,6 +42,7 @@ protected:
/** Pointer to the various widgets on the screen. */ /** Pointer to the various widgets on the screen. */
GUIEngine::LabelWidget * m_header; GUIEngine::LabelWidget * m_header;
GUIEngine::RibbonWidget* m_profile_tabs; GUIEngine::RibbonWidget* m_profile_tabs;
GUIEngine::IconButtonWidget * m_servers_tab;
GUIEngine::IconButtonWidget * m_friends_tab; GUIEngine::IconButtonWidget * m_friends_tab;
GUIEngine::IconButtonWidget * m_achievements_tab; GUIEngine::IconButtonWidget * m_achievements_tab;
GUIEngine::IconButtonWidget * m_settings_tab; GUIEngine::IconButtonWidget * m_settings_tab;

View File

@ -87,6 +87,7 @@ void OnlineProfileFriends::init()
m_sort_increasing = true; m_sort_increasing = true;
m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID], m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID],
PLAYER_ID_GAME_MASTER ); PLAYER_ID_GAME_MASTER );
m_profile_tabs->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
assert(m_visiting_profile != NULL); assert(m_visiting_profile != NULL);
m_visiting_profile->fetchFriends(); m_visiting_profile->fetchFriends();
m_waiting_for_friends = true; m_waiting_for_friends = true;

View File

@ -0,0 +1,170 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2010-2015 Glenn De Jonghe
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "states_screens/online_profile_servers.hpp"
#include "audio/sfx_manager.hpp"
#include "config/player_manager.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/scalable_font.hpp"
#include "guiengine/screen.hpp"
#include "guiengine/widget.hpp"
#include "network/network_config.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocols/connect_to_server.hpp"
#include "network/protocols/request_connection.hpp"
#include "network/servers_manager.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/create_server_screen.hpp"
#include "states_screens/networking_lobby.hpp"
#include "states_screens/server_selection.hpp"
#include "utils/translation.hpp"
#include <IGUIButton.h>
#include <iostream>
#include <sstream>
using namespace GUIEngine;
using namespace irr::core;
using namespace irr::gui;
using namespace Online;
DEFINE_SCREEN_SINGLETON( OnlineProfileServers );
// -----------------------------------------------------------------------------
OnlineProfileServers::OnlineProfileServers() : OnlineProfileBase("online/profile_servers.stkgui")
{
} // OnlineProfileServers
// -----------------------------------------------------------------------------
void OnlineProfileServers::loadedFromFile()
{
OnlineProfileBase::loadedFromFile();
} // loadedFromFile
// -----------------------------------------------------------------------------
void OnlineProfileServers::init()
{
OnlineProfileBase::init();
m_profile_tabs->select( m_servers_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER );
m_servers_tab->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
// OnlineScreen::getInstance()->push();
} // init
// -----------------------------------------------------------------------------
void OnlineProfileServers::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
OnlineProfileBase::eventCallback( widget, name, playerID);
if (name == "lan")
{
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == "create_lan_server")
{
NetworkConfig::get()->setIsLAN();
NetworkConfig::get()->setIsServer(true);
CreateServerScreen::getInstance()->push();
// TODO: create lan server
}
else if (selection == "find_lan_server")
{
NetworkConfig::get()->setIsLAN();
NetworkConfig::get()->setIsServer(false);
ServerSelection::getInstance()->push();
}
}
else if (name == "wan")
{
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == "find_wan_server")
{
NetworkConfig::get()->setIsWAN();
NetworkConfig::get()->setIsServer(false);
ServerSelection::getInstance()->push();
}
else if (selection == "create_wan_server")
{
NetworkConfig::get()->setIsWAN();
NetworkConfig::get()->setIsServer(true);
CreateServerScreen::getInstance()->push();
}
else if (selection == "quick_wan_play")
{
doQuickPlay();
}
}
} // eventCallback
// ----------------------------------------------------------------------------
void OnlineProfileServers::doQuickPlay()
{
// Refresh server list.
HTTPRequest* refresh_request = ServersManager::get()->getRefreshRequest(false);
if (refresh_request != NULL) // consider request done
{
refresh_request->executeNow();
delete refresh_request;
}
else
{
Log::error("OnlineScreen", "Could not get the server list.");
return;
}
// select first one
const Server *server = ServersManager::get()->getQuickPlay();
// do a join request
XMLRequest *join_request = new RequestConnection::ServerJoinRequest();
if (!join_request)
{
SFXManager::get()->quickSound("anvil");
return;
}
PlayerManager::setUserDetails(join_request, "request-connection",
Online::API::SERVER_PATH);
join_request->addParameter("server_id", server->getServerId());
join_request->executeNow();
if (join_request->isSuccess())
{
delete join_request;
NetworkingLobby::getInstance()->push();
ConnectToServer *cts = new ConnectToServer(server->getServerId(),
server->getHostId());
ProtocolManager::getInstance()->requestStart(cts);
}
else
{
SFXManager::get()->quickSound("anvil");
}
} // doQuickPlay
// ----------------------------------------------------------------------------

View File

@ -0,0 +1,57 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013-2015 Glenn De Jonghe
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef __HEADER_ONLINE_PROFILE_SERVERS_HPP__
#define __HEADER_ONLINE_PROFILE_SERVERS_HPP__
#include <string>
#include <irrString.h>
#include "guiengine/screen.hpp"
#include "guiengine/widgets.hpp"
#include "states_screens/online_profile_base.hpp"
namespace GUIEngine { class Widget; }
/**
* \brief Online profiel overview screen
* \ingroup states_screens
*/
class OnlineProfileServers : public OnlineProfileBase, public GUIEngine::ScreenSingleton<OnlineProfileServers>
{
protected:
OnlineProfileServers();
void doQuickPlay();
public:
friend class GUIEngine::ScreenSingleton<OnlineProfileServers>;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void loadedFromFile() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
const int playerID) OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void init() OVERRIDE;
};
#endif

View File

@ -58,6 +58,7 @@ void OnlineProfileSettings::init()
{ {
OnlineProfileBase::init(); OnlineProfileBase::init();
m_profile_tabs->select( m_settings_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER ); m_profile_tabs->select( m_settings_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER );
m_settings_tab->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
} // init } // init
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -1,315 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013-2015 Glenn De Jonghe
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DEBUG_MENU_ITEM 0
#include "states_screens/online_screen.hpp"
#include "audio/sfx_manager.hpp"
#include "config/player_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "guiengine/scalable_font.hpp"
#include "input/device_manager.hpp"
#include "input/input_manager.hpp"
#include "io/file_manager.hpp"
#include "modes/demo_world.hpp"
#include "network/network_config.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocols/connect_to_server.hpp"
#include "network/protocols/request_connection.hpp"
#include "network/servers_manager.hpp"
#include "online/profile_manager.hpp"
#include "online/request.hpp"
#include "states_screens/create_server_screen.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/networking_lobby.hpp"
#include "states_screens/online_profile_achievements.hpp"
#include "states_screens/server_selection.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/user_screen.hpp"
#include <string>
#include <iostream>
using namespace GUIEngine;
using namespace Online;
DEFINE_SCREEN_SINGLETON( OnlineScreen );
// ----------------------------------------------------------------------------
OnlineScreen::OnlineScreen() : Screen("online/online_screen.stkgui")
{
m_recorded_state = PlayerProfile::OS_SIGNED_OUT;
} // OnlineScreen
// ----------------------------------------------------------------------------
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);
m_top_menu_widget = getWidget<RibbonWidget>("menu_top_row");
assert(m_top_menu_widget != NULL);
m_find_lan_server_widget = getWidget<IconButtonWidget>("find_lan_server");
assert(m_find_lan_server_widget != NULL);
m_create_lan_server_widget = getWidget<IconButtonWidget>("create_lan_server");
assert(m_create_lan_server_widget != NULL);
m_manage_user = getWidget<IconButtonWidget>("manage_user");
assert(m_manage_user);
m_find_wan_server_widget = getWidget<IconButtonWidget>("find_wan_server");
assert(m_find_wan_server_widget != NULL);
m_create_wan_server_widget = getWidget<IconButtonWidget>("create_wan_server");
assert(m_create_wan_server_widget != NULL);
m_quick_wan_play_widget = getWidget<IconButtonWidget>("quick_wan_play");
assert(m_quick_wan_play_widget != NULL);
m_bottom_menu_widget = getWidget<RibbonWidget>("menu_bottomrow");
assert(m_bottom_menu_widget != NULL);
m_profile_widget = getWidget<IconButtonWidget>("profile");
assert(m_profile_widget != NULL);
m_sign_out_widget = getWidget<IconButtonWidget>("sign_out");
assert(m_sign_out_widget != NULL);
} // loadedFromFile
// ----------------------------------------------------------------------------
/** Checks if the recorded state differs from the actual state and sets it.
*/
bool OnlineScreen::hasStateChanged()
{
PlayerProfile::OnlineState previous_state = m_recorded_state;
m_recorded_state = PlayerManager::getCurrentOnlineState();
if (previous_state != m_recorded_state)
return true;
return false;
} // hasStateChanged
// ----------------------------------------------------------------------------
void OnlineScreen::beforeAddingWidget()
{
// Set everything that could be set invisible or deactivated
// to active and visible
m_bottom_menu_widget->setVisible(true);
m_top_menu_widget->setVisible(true);
hasStateChanged();
if (m_recorded_state == PlayerProfile::OS_SIGNED_OUT ||
m_recorded_state == PlayerProfile::OS_SIGNING_IN ||
m_recorded_state == PlayerProfile::OS_SIGNING_OUT)
{
m_quick_wan_play_widget->setActive(false);
m_find_wan_server_widget->setActive(false);
m_create_wan_server_widget->setActive(false);
m_sign_out_widget->setVisible(false);
m_profile_widget->setVisible(false);
}
else if (m_recorded_state == PlayerProfile::OS_GUEST)
{
m_find_wan_server_widget->setActive(false);
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
// ----------------------------------------------------------------------------
void OnlineScreen::init()
{
Screen::init();
setInitialFocus();
DemoWorld::resetIdleTime();
} // 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;
}
} // onUpdate
// ----------------------------------------------------------------------------
/** Executes the quick play selection. Atm this is all blocking.
*/
void OnlineScreen::doQuickPlay()
{
// Refresh server list.
HTTPRequest* refresh_request = ServersManager::get()->getRefreshRequest(false);
if (refresh_request != NULL) // consider request done
{
refresh_request->executeNow();
delete refresh_request;
}
else
{
Log::error("OnlineScreen", "Could not get the server list.");
return;
}
// select first one
const Server *server = ServersManager::get()->getQuickPlay();
// do a join request
XMLRequest *join_request = new RequestConnection::ServerJoinRequest();
if (!join_request)
{
SFXManager::get()->quickSound("anvil");
return;
}
PlayerManager::setUserDetails(join_request, "request-connection",
Online::API::SERVER_PATH);
join_request->addParameter("server_id", server->getServerId());
join_request->executeNow();
if (join_request->isSuccess())
{
delete join_request;
NetworkingLobby::getInstance()->push();
ConnectToServer *cts = new ConnectToServer(server->getServerId(),
server->getHostId());
ProtocolManager::getInstance()->requestStart(cts);
}
else
{
SFXManager::get()->quickSound("anvil");
}
} // doQuickPlay
// ----------------------------------------------------------------------------
void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == m_back_widget->m_properties[PROP_ID])
{
StateManager::get()->escapePressed();
return;
}
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
if (ribbon == NULL) return;
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == m_sign_out_widget->m_properties[PROP_ID])
{
PlayerManager::requestSignOut();
StateManager::get()->popMenu();
}
else if (selection == m_create_lan_server_widget->m_properties[PROP_ID])
{
NetworkConfig::get()->setIsLAN();
NetworkConfig::get()->setIsServer(true);
CreateServerScreen::getInstance()->push();
// TODO: create lan server
}
else if (selection == m_find_lan_server_widget->m_properties[PROP_ID])
{
NetworkConfig::get()->setIsLAN();
NetworkConfig::get()->setIsServer(false);
ServerSelection::getInstance()->push();
}
else if (selection == m_manage_user->m_properties[PROP_ID])
{
UserScreen::getInstance()->push();
}
else if (selection == m_profile_widget->m_properties[PROP_ID])
{
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
OnlineProfileAchievements::getInstance()->push();
}
else if (selection == m_find_wan_server_widget->m_properties[PROP_ID])
{
NetworkConfig::get()->setIsWAN();
NetworkConfig::get()->setIsServer(false);
ServerSelection::getInstance()->push();
}
else if (selection == m_create_wan_server_widget->m_properties[PROP_ID])
{
NetworkConfig::get()->setIsWAN();
NetworkConfig::get()->setIsServer(true);
CreateServerScreen::getInstance()->push();
}
else if (selection == m_quick_wan_play_widget->m_properties[PROP_ID])
{
doQuickPlay();
}
} // eventCallback
// ----------------------------------------------------------------------------
void OnlineScreen::tearDown()
{
}
// ----------------------------------------------------------------------------
/** Sets which widget has to be focused. Depends on the user state.
*/
void OnlineScreen::setInitialFocus()
{
if (m_recorded_state == PlayerProfile::OS_SIGNED_IN)
m_top_menu_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
else
m_bottom_menu_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
} // setInitialFocus
// ----------------------------------------------------------------------------
void OnlineScreen::onDialogClose()
{
if (hasStateChanged())
GUIEngine::reshowCurrentScreen();
else
setInitialFocus();
} // onDialogClose()

View File

@ -1,92 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013-2015 Glenn De Jonghe
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_ONLINE_SCREEN_HPP
#define HEADER_ONLINE_SCREEN_HPP
#include "config/player_manager.hpp"
#include "guiengine/screen.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
#include "utils/ptr_vector.hpp"
namespace GUIEngine { class Widget; class ListWidget; class ButtonWidget; }
/**
* \brief Handles the main menu
* \ingroup states_screens
*/
class OnlineScreen : public GUIEngine::Screen,
public GUIEngine::ScreenSingleton<OnlineScreen>
{
private:
friend class GUIEngine::ScreenSingleton<OnlineScreen>;
OnlineScreen();
~OnlineScreen();
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::IconButtonWidget *m_find_wan_server_widget;
GUIEngine::IconButtonWidget *m_create_wan_server_widget;
GUIEngine::IconButtonWidget *m_quick_wan_play_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;
bool hasStateChanged();
void setInitialFocus();
void doQuickPlay();
public:
virtual void onUpdate(float delta) OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void loadedFromFile() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
const int playerID) OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void beforeAddingWidget() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void init() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void tearDown() OVERRIDE;
/** \brief Implements the callback when a dialog gets closed. */
virtual void onDialogClose() OVERRIDE;
};
#endif

View File

@ -48,7 +48,7 @@
#include "states_screens/main_menu_screen.hpp" #include "states_screens/main_menu_screen.hpp"
#include "states_screens/networking_lobby.hpp" #include "states_screens/networking_lobby.hpp"
#include "states_screens/network_kart_selection.hpp" #include "states_screens/network_kart_selection.hpp"
#include "states_screens/online_screen.hpp" #include "states_screens/online_profile_servers.hpp"
#include "states_screens/race_setup_screen.hpp" #include "states_screens/race_setup_screen.hpp"
#include "states_screens/server_selection.hpp" #include "states_screens/server_selection.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
@ -339,7 +339,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
race_manager->exitRace(); race_manager->exitRace();
race_manager->setAIKartOverride(""); race_manager->setAIKartOverride("");
Screen* newStack[] = {MainMenuScreen::getInstance(), Screen* newStack[] = {MainMenuScreen::getInstance(),
OnlineScreen::getInstance(), OnlineProfileServers::getInstance(),
ServerSelection::getInstance(), ServerSelection::getInstance(),
NetworkingLobby::getInstance(), NetworkingLobby::getInstance(),
NULL}; NULL};

View File

@ -200,7 +200,7 @@ void ServerSelection::eventCallback( GUIEngine::Widget* widget,
*/ */
void ServerSelection::onUpdate(float dt) void ServerSelection::onUpdate(float dt)
{ {
if(!m_refresh_request) return; if (!m_refresh_request) return;
if (m_refresh_request->isDone()) if (m_refresh_request->isDone())
{ {