diff --git a/data/gui/online/online_screen.stkgui b/data/gui/online/online_screen.stkgui deleted file mode 100644 index b8ee57373..000000000 --- a/data/gui/online/online_screen.stkgui +++ /dev/null @@ -1,63 +0,0 @@ - - -
-
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
diff --git a/data/gui/online/profile_achievements_tab.stkgui b/data/gui/online/profile_achievements_tab.stkgui index 7d519d661..dbf3256b5 100644 --- a/data/gui/online/profile_achievements_tab.stkgui +++ b/data/gui/online/profile_achievements_tab.stkgui @@ -9,6 +9,7 @@ + diff --git a/data/gui/online/profile_friends.stkgui b/data/gui/online/profile_friends.stkgui index e0e49473b..0e1213c61 100644 --- a/data/gui/online/profile_friends.stkgui +++ b/data/gui/online/profile_friends.stkgui @@ -9,6 +9,7 @@ + diff --git a/data/gui/online/profile_servers.stkgui b/data/gui/online/profile_servers.stkgui new file mode 100644 index 000000000..25ca99ffa --- /dev/null +++ b/data/gui/online/profile_servers.stkgui @@ -0,0 +1,61 @@ + + + + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
diff --git a/data/gui/online/profile_settings.stkgui b/data/gui/online/profile_settings.stkgui index d89d52c23..126519d9f 100644 --- a/data/gui/online/profile_settings.stkgui +++ b/data/gui/online/profile_settings.stkgui @@ -8,6 +8,7 @@ + push(); - #else ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId()); - TabOnlineProfileAchievements::getInstance()->push(); - #endif + OnlineProfileServers::getInstance()->push(); } else { diff --git a/src/states_screens/networking_lobby.cpp b/src/states_screens/networking_lobby.cpp index fd67427f4..362471bb6 100644 --- a/src/states_screens/networking_lobby.cpp +++ b/src/states_screens/networking_lobby.cpp @@ -23,6 +23,7 @@ #include #include "challenges/unlock_manager.hpp" +#include "config/player_manager.hpp" #include "graphics/irr_driver.hpp" #include "guiengine/scalable_font.hpp" #include "guiengine/widgets/icon_button_widget.hpp" @@ -37,7 +38,6 @@ #include "network/protocols/client_lobby_room_protocol.hpp" #include "network/servers_manager.hpp" #include "network/stk_host.hpp" -#include "states_screens/online_screen.hpp" #include "states_screens/state_manager.hpp" #include "states_screens/dialogs/message_dialog.hpp" #include "utils/translation.hpp" diff --git a/src/states_screens/online_profile_achievements.cpp b/src/states_screens/online_profile_achievements.cpp index 7e660ca5f..9bfdfeeb7 100644 --- a/src/states_screens/online_profile_achievements.cpp +++ b/src/states_screens/online_profile_achievements.cpp @@ -87,8 +87,11 @@ void BaseOnlineProfileAchievements::init() { OnlineProfileBase::init(); if (m_profile_tabs) + { 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. // m_visiting_profile is NULL if the user is not logged in. diff --git a/src/states_screens/online_profile_base.cpp b/src/states_screens/online_profile_base.cpp index 605c09984..ffd5f4176 100644 --- a/src/states_screens/online_profile_base.cpp +++ b/src/states_screens/online_profile_base.cpp @@ -27,6 +27,7 @@ #include "utils/translation.hpp" #include "states_screens/online_profile_friends.hpp" #include "states_screens/online_profile_achievements.hpp" +#include "states_screens/online_profile_servers.hpp" #include "states_screens/online_profile_settings.hpp" #include @@ -41,6 +42,10 @@ using namespace Online; OnlineProfileBase::OnlineProfileBase(const std::string &filename) : Screen(filename.c_str()) { + m_servers_tab = NULL; + m_friends_tab = NULL; + m_achievements_tab = NULL; + m_settings_tab = NULL; } // OnlineProfileBase // ----------------------------------------------------------------------------- @@ -53,15 +58,20 @@ void OnlineProfileBase::loadedFromFile() m_header = getWidget("title"); assert(m_header != NULL); - m_friends_tab = !m_profile_tabs ? NULL : - (IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_friends"); - assert(m_profile_tabs == NULL || m_friends_tab != NULL); - m_achievements_tab = !m_profile_tabs ? NULL : - (IconButtonWidget*)m_profile_tabs->findWidgetNamed("tab_achievements"); - assert(m_profile_tabs == NULL || m_achievements_tab != NULL); - m_settings_tab = !m_profile_tabs ? NULL : - (IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_settings"); - assert(m_profile_tabs == NULL || m_settings_tab != NULL); + if (m_profile_tabs != NULL) + { + m_friends_tab = (IconButtonWidget *)m_profile_tabs->findWidgetNamed("tab_friends"); + assert(m_friends_tab != NULL); + + m_servers_tab = (IconButtonWidget *)m_profile_tabs->findWidgetNamed("tab_servers"); + assert(m_servers_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 // ----------------------------------------------------------------------------- @@ -96,6 +106,7 @@ void OnlineProfileBase::init() if (m_profile_tabs) { + m_servers_tab->setTooltip(_("Servers")); m_friends_tab->setTooltip(_("Friends")); m_achievements_tab->setTooltip(_("Achievements")); m_settings_tab->setTooltip(_("Account Settings")); @@ -147,6 +158,8 @@ void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name, sm->replaceTopMostScreen(TabOnlineProfileAchievements::getInstance()); else if (selection == m_settings_tab->m_properties[PROP_ID]) sm->replaceTopMostScreen(OnlineProfileSettings::getInstance()); + else if (selection == m_servers_tab->m_properties[PROP_ID]) + sm->replaceTopMostScreen(OnlineProfileServers::getInstance()); } else if (name == "back") { diff --git a/src/states_screens/online_profile_base.hpp b/src/states_screens/online_profile_base.hpp index 0285edb4b..95a6906fa 100644 --- a/src/states_screens/online_profile_base.hpp +++ b/src/states_screens/online_profile_base.hpp @@ -42,6 +42,7 @@ protected: /** Pointer to the various widgets on the screen. */ GUIEngine::LabelWidget * m_header; GUIEngine::RibbonWidget* m_profile_tabs; + GUIEngine::IconButtonWidget * m_servers_tab; GUIEngine::IconButtonWidget * m_friends_tab; GUIEngine::IconButtonWidget * m_achievements_tab; GUIEngine::IconButtonWidget * m_settings_tab; diff --git a/src/states_screens/online_profile_friends.cpp b/src/states_screens/online_profile_friends.cpp index 7b534595d..593b974a3 100644 --- a/src/states_screens/online_profile_friends.cpp +++ b/src/states_screens/online_profile_friends.cpp @@ -87,6 +87,7 @@ void OnlineProfileFriends::init() m_sort_increasing = true; m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER ); + m_profile_tabs->setFocusForPlayer(PLAYER_ID_GAME_MASTER); assert(m_visiting_profile != NULL); m_visiting_profile->fetchFriends(); m_waiting_for_friends = true; diff --git a/src/states_screens/online_profile_servers.cpp b/src/states_screens/online_profile_servers.cpp new file mode 100644 index 000000000..61235f1b0 --- /dev/null +++ b/src/states_screens/online_profile_servers.cpp @@ -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 + +#include +#include + +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(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(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 + +// ---------------------------------------------------------------------------- + diff --git a/src/states_screens/online_profile_servers.hpp b/src/states_screens/online_profile_servers.hpp new file mode 100644 index 000000000..26816e6de --- /dev/null +++ b/src/states_screens/online_profile_servers.hpp @@ -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 +#include + +#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 +{ +protected: + OnlineProfileServers(); + + void doQuickPlay(); + +public: + friend class GUIEngine::ScreenSingleton; + + /** \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 diff --git a/src/states_screens/online_profile_settings.cpp b/src/states_screens/online_profile_settings.cpp index 1231b2c16..98c83129c 100644 --- a/src/states_screens/online_profile_settings.cpp +++ b/src/states_screens/online_profile_settings.cpp @@ -58,6 +58,7 @@ void OnlineProfileSettings::init() { OnlineProfileBase::init(); m_profile_tabs->select( m_settings_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER ); + m_settings_tab->setFocusForPlayer(PLAYER_ID_GAME_MASTER); } // init // ----------------------------------------------------------------------------- diff --git a/src/states_screens/online_screen.cpp b/src/states_screens/online_screen.cpp deleted file mode 100644 index 2aeb35aad..000000000 --- a/src/states_screens/online_screen.cpp +++ /dev/null @@ -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 -#include - -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("user-id"); - assert(m_user_id); - - m_back_widget = getWidget("back"); - assert(m_back_widget != NULL); - - m_top_menu_widget = getWidget("menu_top_row"); - assert(m_top_menu_widget != NULL); - - m_find_lan_server_widget = getWidget("find_lan_server"); - assert(m_find_lan_server_widget != NULL); - m_create_lan_server_widget = getWidget("create_lan_server"); - assert(m_create_lan_server_widget != NULL); - m_manage_user = getWidget("manage_user"); - assert(m_manage_user); - - m_find_wan_server_widget = getWidget("find_wan_server"); - assert(m_find_wan_server_widget != NULL); - m_create_wan_server_widget = getWidget("create_wan_server"); - assert(m_create_wan_server_widget != NULL); - m_quick_wan_play_widget = getWidget("quick_wan_play"); - assert(m_quick_wan_play_widget != NULL); - - m_bottom_menu_widget = getWidget("menu_bottomrow"); - assert(m_bottom_menu_widget != NULL); - m_profile_widget = getWidget("profile"); - assert(m_profile_widget != NULL); - m_sign_out_widget = getWidget("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(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() - diff --git a/src/states_screens/online_screen.hpp b/src/states_screens/online_screen.hpp deleted file mode 100644 index b306baa23..000000000 --- a/src/states_screens/online_screen.hpp +++ /dev/null @@ -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 -{ -private: - friend class GUIEngine::ScreenSingleton; - - 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 diff --git a/src/states_screens/race_result_gui.cpp b/src/states_screens/race_result_gui.cpp index 630aa7e55..c751e3335 100644 --- a/src/states_screens/race_result_gui.cpp +++ b/src/states_screens/race_result_gui.cpp @@ -48,7 +48,7 @@ #include "states_screens/main_menu_screen.hpp" #include "states_screens/networking_lobby.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/server_selection.hpp" #include "tracks/track.hpp" @@ -339,7 +339,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget, race_manager->exitRace(); race_manager->setAIKartOverride(""); Screen* newStack[] = {MainMenuScreen::getInstance(), - OnlineScreen::getInstance(), + OnlineProfileServers::getInstance(), ServerSelection::getInstance(), NetworkingLobby::getInstance(), NULL}; diff --git a/src/states_screens/server_selection.cpp b/src/states_screens/server_selection.cpp index dbf2f89e6..c3fa90a3e 100644 --- a/src/states_screens/server_selection.cpp +++ b/src/states_screens/server_selection.cpp @@ -200,7 +200,7 @@ void ServerSelection::eventCallback( GUIEngine::Widget* widget, */ void ServerSelection::onUpdate(float dt) { - if(!m_refresh_request) return; + if (!m_refresh_request) return; if (m_refresh_request->isDone()) {