From 83b270cccd39dedbeee4d92de6b386279dc57f23 Mon Sep 17 00:00:00 2001 From: unitraxx Date: Fri, 5 Jul 2013 23:26:44 +0000 Subject: [PATCH] Lobby settings screen. Quick draft that will be used to test the server functionality. (Looks ugly now, need to merge with trunk again.) git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13096 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/gui/online/lobby_settings.stkgui | 32 +++++ sources.cmake | 4 + .../networking_lobby_settings.cpp | 114 ++++++++++++++++++ .../networking_lobby_settings.hpp | 72 +++++++++++ src/states_screens/online_screen.cpp | 12 +- 5 files changed, 231 insertions(+), 3 deletions(-) create mode 100644 data/gui/online/lobby_settings.stkgui create mode 100644 src/states_screens/networking_lobby_settings.cpp create mode 100644 src/states_screens/networking_lobby_settings.hpp diff --git a/data/gui/online/lobby_settings.stkgui b/data/gui/online/lobby_settings.stkgui new file mode 100644 index 000000000..fc5ff8deb --- /dev/null +++ b/data/gui/online/lobby_settings.stkgui @@ -0,0 +1,32 @@ + +
+ +
+ + +
+
+
+ + + +
+
+
+
+ + + + + + + +
+ + + +
diff --git a/sources.cmake b/sources.cmake index 218dab4f8..e473c713e 100644 --- a/sources.cmake +++ b/sources.cmake @@ -192,6 +192,8 @@ src/states_screens/help_screen_4.cpp src/states_screens/kart_selection.cpp src/states_screens/main_menu_screen.cpp src/states_screens/minimal_race_gui.cpp +src/states_screens/networking_lobby.cpp +src/states_screens/networking_lobby_settings.cpp src/states_screens/online_screen.cpp src/states_screens/options_screen_audio.cpp src/states_screens/options_screen_input2.cpp @@ -459,6 +461,8 @@ src/states_screens/help_screen_4.hpp src/states_screens/kart_selection.hpp src/states_screens/main_menu_screen.hpp src/states_screens/minimal_race_gui.hpp +src/states_screens/networking_lobby.hpp +src/states_screens/networking_lobby_settings.hpp src/states_screens/online_screen.hpp src/states_screens/options_screen_audio.hpp src/states_screens/options_screen_input2.hpp diff --git a/src/states_screens/networking_lobby_settings.cpp b/src/states_screens/networking_lobby_settings.cpp new file mode 100644 index 000000000..8e82fc313 --- /dev/null +++ b/src/states_screens/networking_lobby_settings.cpp @@ -0,0 +1,114 @@ +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2013 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/networking_lobby_settings.hpp" + +#include +#include + +#include "challenges/game_slot.hpp" +#include "challenges/unlock_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 "main_loop.hpp" +#include "states_screens/online_screen.hpp" +#include "states_screens/state_manager.hpp" +#include "states_screens/dialogs/message_dialog.hpp" +#include "modes/demo_world.hpp" +#include "utils/translation.hpp" + +#include "online/current_online_user.hpp" + + +using namespace GUIEngine; + +DEFINE_SCREEN_SINGLETON( NetworkingLobbySettings ); + +// ---------------------------------------------------------------------------- + +NetworkingLobbySettings::NetworkingLobbySettings() : Screen("online/lobby_settings.stkgui") +{ + +} // NetworkingLobbySettings + +// ---------------------------------------------------------------------------- + +void NetworkingLobbySettings::loadedFromFile() +{ + +} // loadedFromFile + +// ---------------------------------------------------------------------------- +bool NetworkingLobbySettings::hasLostConnection() +{ + return !CurrentOnlineUser::get()->isSignedIn(); +} + +// ---------------------------------------------------------------------------- +void NetworkingLobbySettings::beforeAddingWidget() +{ + +} // beforeAddingWidget + + + +// ---------------------------------------------------------------------------- +void NetworkingLobbySettings::init() +{ + Screen::init(); + setInitialFocus(); + DemoWorld::resetIdleTime(); //FIXME : what's this?} // init +} +// ---------------------------------------------------------------------------- +void NetworkingLobbySettings::onUpdate(float delta, irr::video::IVideoDriver* driver) +{ +} // onUpdate + +// ---------------------------------------------------------------------------- + +void NetworkingLobbySettings::eventCallback(Widget* widget, const std::string& name, const int playerID) +{ + +} // eventCallback + +// ---------------------------------------------------------------------------- + +void NetworkingLobbySettings::tearDown() +{ +} // tearDown + +// ---------------------------------------------------------------------------- +void NetworkingLobbySettings::onDisabledItemClicked(const std::string& item) +{ + +} // onDisabledItemClicked + +// ---------------------------------------------------------------------------- +void NetworkingLobbySettings::setInitialFocus() +{ +} // setInitialFocus + +// ---------------------------------------------------------------------------- +void NetworkingLobbySettings::onDialogClose() +{ + setInitialFocus(); +} // onDialogClose() diff --git a/src/states_screens/networking_lobby_settings.hpp b/src/states_screens/networking_lobby_settings.hpp new file mode 100644 index 000000000..bc71c0131 --- /dev/null +++ b/src/states_screens/networking_lobby_settings.hpp @@ -0,0 +1,72 @@ +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2013 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_NETWORKING_LOBBY_SETTINGS_HPP +#define HEADER_NETWORKING_LOBBY_SETTINGS_HPP + +#include "guiengine/screen.hpp" +#include "guiengine/widgets/label_widget.hpp" +#include "guiengine/widgets/ribbon_widget.hpp" +#include "guiengine/widgets/icon_button_widget.hpp" + +namespace GUIEngine { class Widget; class ListWidget; } + +/** + * \brief Handles the main menu + * \ingroup states_screens + */ +class NetworkingLobbySettings : public GUIEngine::Screen, + public GUIEngine::ScreenSingleton +{ +private: + friend class GUIEngine::ScreenSingleton; + + NetworkingLobbySettings(); + + /** \brief Checks if the user is still signed in. */ + bool hasLostConnection(); + /** \brief Sets which widget has to be focused. Depends on the user state. */ + void setInitialFocus(); + +public: + + virtual void onUpdate(float delta, irr::video::IVideoDriver* driver) 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 implement callback from parent class GUIEngine::Screen */ + virtual void onDisabledItemClicked(const std::string& item) OVERRIDE; + + /** \brief Implements the callback when a dialog gets closed. */ + virtual void onDialogClose() OVERRIDE; +}; + +#endif diff --git a/src/states_screens/online_screen.cpp b/src/states_screens/online_screen.cpp index 279922f2a..2e891b6f7 100644 --- a/src/states_screens/online_screen.cpp +++ b/src/states_screens/online_screen.cpp @@ -36,6 +36,7 @@ #include "states_screens/dialogs/login_dialog.hpp" #include "states_screens/dialogs/registration_dialog.hpp" #include "states_screens/networking_lobby.hpp" +#include "states_screens/networking_lobby_settings.hpp" #include "modes/demo_world.hpp" #include "utils/translation.hpp" @@ -185,11 +186,11 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name, const else if (selection == "create_server") { //if (m_recorded_state == Registered) - new MessageDialog("Coming soon!"); + StateManager::get()->pushScreen(NetworkingLobbySettings::getInstance()); } else if (selection == "quick_play") { - //if (m_recorded_state == Registered || m_recorded_state == Guest) + //if (m_recorded_state == Registered || m_recorded_state == Guest) FIXME StateManager::get()->pushScreen(NetworkingLobby::getInstance()); } @@ -204,10 +205,15 @@ void OnlineScreen::tearDown() // ---------------------------------------------------------------------------- void OnlineScreen::onDisabledItemClicked(const std::string& item) { - if (item == "find_server" || item =="create_server") + if (item == "find_server") { new LoginDialog(LoginDialog::Registration_Required); } + else if (item =="create_server") + { + StateManager::get()->pushScreen(NetworkingLobbySettings::getInstance()); + // FIXME temporary; new LoginDialog(LoginDialog::Registration_Required); + } else if (item == "quick_play") { StateManager::get()->pushScreen(NetworkingLobby::getInstance());