From 89aea95b0020980604a0a1ec5bb280406d79ce94 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 26 Oct 2018 15:22:14 +0800 Subject: [PATCH] Bring back the quit button for continuing grand prix --- src/network/protocols/client_lobby.cpp | 1 + src/states_screens/online/tracks_screen.cpp | 27 ++++++++++++++++++--- src/states_screens/online/tracks_screen.hpp | 11 ++++++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index c5177c083..10e78315d 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -875,6 +875,7 @@ void ClientLobby::startSelection(Event* event) ->createActivePlayer(std::get<1>(p), std::get<0>(p)); } input_manager->getDeviceManager()->setAssignMode(ASSIGN); + TracksScreen::getInstance()->setQuitServer(); TracksScreen::getInstance()->setNetworkTracks(); TracksScreen::getInstance()->push(); } diff --git a/src/states_screens/online/tracks_screen.cpp b/src/states_screens/online/tracks_screen.cpp index da5142c7a..ab2f5d3e4 100644 --- a/src/states_screens/online/tracks_screen.cpp +++ b/src/states_screens/online/tracks_screen.cpp @@ -122,9 +122,18 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, // ----------------------------------------------------------------------------- bool TracksScreen::onEscapePressed() { - auto cl = LobbyProtocol::get(); - if (cl) - cl->clearPlayers(); + if (m_quit_server) + { + // Remove this screen + StateManager::get()->popMenu(); + STKHost::get()->shutdown(); + } + else + { + auto cl = LobbyProtocol::get(); + if (cl) + cl->clearPlayers(); + } // remove the screen return true; } // onEscapePressed @@ -134,6 +143,7 @@ void TracksScreen::tearDown() { m_network_tracks = false; m_selected_track = NULL; + m_quit_server = false; } // tearDown // ----------------------------------------------------------------------------- @@ -227,6 +237,17 @@ void TracksScreen::beforeAddingWidget() // ----------------------------------------------------------------------------- void TracksScreen::init() { + // change the back button image (because it makes the game quit) + if (m_quit_server) + { + IconButtonWidget* back_button = getWidget("back"); + back_button->setImage("gui/icons/main_quit.png"); + } + else + { + IconButtonWidget* back_button = getWidget("back"); + back_button->setImage("gui/icons/back.png"); + } if (!m_network_tracks) m_vote_timeout = std::numeric_limits::max(); diff --git a/src/states_screens/online/tracks_screen.hpp b/src/states_screens/online/tracks_screen.hpp index 293428b77..1942ff5f7 100644 --- a/src/states_screens/online/tracks_screen.hpp +++ b/src/states_screens/online/tracks_screen.hpp @@ -48,6 +48,9 @@ private: { m_network_tracks = false; m_reverse_checked = false; + m_quit_server = false; + m_bottom_box_height = -1; + m_vote_timeout = std::numeric_limits::max(); } Track* m_selected_track = NULL; @@ -55,11 +58,11 @@ private: GUIEngine::SpinnerWidget* m_laps; GUIEngine::LabelWidget* m_votes; - bool m_network_tracks, m_reverse_checked; + bool m_network_tracks, m_reverse_checked, m_quit_server; - int m_bottom_box_height = -1; + int m_bottom_box_height; - uint64_t m_vote_timeout = std::numeric_limits::max(); + uint64_t m_vote_timeout; std::map m_vote_messages; @@ -99,6 +102,8 @@ public: void setNetworkTracks() { m_network_tracks = true; } + void setQuitServer() { m_quit_server = true; } + void resetVote() { m_vote_messages.clear();