diff --git a/data/gui/online/lobby.stkgui b/data/gui/online/lobby.stkgui new file mode 100644 index 000000000..a19b2f1fb --- /dev/null +++ b/data/gui/online/lobby.stkgui @@ -0,0 +1,49 @@ + +
+ +
+ +
+
+ + + + +
+ + + +
+ + + + +
+
+ + + + + + +
+ + + +
diff --git a/src/states_screens/networking_lobby.cpp b/src/states_screens/networking_lobby.cpp new file mode 100644 index 000000000..d3d894a44 --- /dev/null +++ b/src/states_screens/networking_lobby.cpp @@ -0,0 +1,124 @@ +// 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.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( NetworkingLobby ); + +// ---------------------------------------------------------------------------- + +NetworkingLobby::NetworkingLobby() : Screen("online/lobby.stkgui") +{ + +} // NetworkingLobby + +// ---------------------------------------------------------------------------- + +void NetworkingLobby::loadedFromFile() +{ + m_online_status_widget = getWidget("online_status"); + assert(m_online_status_widget != NULL); + + m_bottom_menu_widget = getWidget("menu_bottomrow"); + assert(m_bottom_menu_widget != NULL); + /*m_sign_in_widget = (IconButtonWidget *) m_bottom_menu_widget->findWidgetNamed("sign_in"); + assert(m_sign_in_widget != NULL);*/ + + +} // loadedFromFile + +// ---------------------------------------------------------------------------- +bool NetworkingLobby::hasLostConnection() +{ + return !CurrentOnlineUser::get()->isSignedIn(); +} + +// ---------------------------------------------------------------------------- +void NetworkingLobby::beforeAddingWidget() +{ + +} // beforeAddingWidget + + + +// ---------------------------------------------------------------------------- +void NetworkingLobby::init() +{ + Screen::init(); + setInitialFocus(); + DemoWorld::resetIdleTime(); //FIXME : what's this? + m_online_status_widget->setText(irr::core::stringw(_("Signed in as : ")) + CurrentOnlineUser::get()->getUserName() + ".", false); +} // init + +// ---------------------------------------------------------------------------- +void NetworkingLobby::onUpdate(float delta, irr::video::IVideoDriver* driver) +{ +} // onUpdate + +// ---------------------------------------------------------------------------- + +void NetworkingLobby::eventCallback(Widget* widget, const std::string& name, const int playerID) +{ + +} // eventCallback + +// ---------------------------------------------------------------------------- + +void NetworkingLobby::tearDown() +{ +} // tearDown + +// ---------------------------------------------------------------------------- +void NetworkingLobby::onDisabledItemClicked(const std::string& item) +{ + +} // onDisabledItemClicked + +// ---------------------------------------------------------------------------- +void NetworkingLobby::setInitialFocus() +{ +} // setInitialFocus + +// ---------------------------------------------------------------------------- +void NetworkingLobby::onDialogClose() +{ + setInitialFocus(); +} // onDialogClose() diff --git a/src/states_screens/networking_lobby.hpp b/src/states_screens/networking_lobby.hpp new file mode 100644 index 000000000..76779a67f --- /dev/null +++ b/src/states_screens/networking_lobby.hpp @@ -0,0 +1,79 @@ +// 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_HPP +#define HEADER_NETWORKING_LOBBY_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 NetworkingLobby : public GUIEngine::Screen, + public GUIEngine::ScreenSingleton +{ +private: + friend class GUIEngine::ScreenSingleton; + + NetworkingLobby(); + + GUIEngine::LabelWidget * m_online_status_widget; + + GUIEngine::RibbonWidget * m_bottom_menu_widget; + GUIEngine::IconButtonWidget * m_sign_in_widget; + GUIEngine::IconButtonWidget * m_register_widget; + GUIEngine::IconButtonWidget * m_sign_out_widget; + + /** \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 800eeafee..279922f2a 100644 --- a/src/states_screens/online_screen.cpp +++ b/src/states_screens/online_screen.cpp @@ -35,6 +35,7 @@ #include "states_screens/dialogs/message_dialog.hpp" #include "states_screens/dialogs/login_dialog.hpp" #include "states_screens/dialogs/registration_dialog.hpp" +#include "states_screens/networking_lobby.hpp" #include "modes/demo_world.hpp" #include "utils/translation.hpp" @@ -189,7 +190,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name, const else if (selection == "quick_play") { //if (m_recorded_state == Registered || m_recorded_state == Guest) - new MessageDialog("Coming soon!"); + StateManager::get()->pushScreen(NetworkingLobby::getInstance()); } } // eventCallback @@ -205,11 +206,12 @@ void OnlineScreen::onDisabledItemClicked(const std::string& item) { if (item == "find_server" || item =="create_server") { - new LoginDialog(LoginDialog::Registration_Required); + new LoginDialog(LoginDialog::Registration_Required); } else if (item == "quick_play") { - new LoginDialog(LoginDialog::Signing_In_Required); + StateManager::get()->pushScreen(NetworkingLobby::getInstance()); + // FIXME temporary; new LoginDialog(LoginDialog::Signing_In_Required); } } // onDisabledItemClicked @@ -229,4 +231,4 @@ void OnlineScreen::onDialogClose() GUIEngine::reshowCurrentScreen(); else setInitialFocus(); -} // onLoginDialogClose() +} // onDialogClose()