Fix quitting the server

This commit is contained in:
Benau 2018-03-08 13:19:24 +08:00
parent 0b00640760
commit 2d86adce3c
3 changed files with 19 additions and 18 deletions

View File

@ -145,7 +145,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
}
else if (name == "back")
{
StateManager::get()->popMenu();
StateManager::get()->escapePressed();
return;
}
@ -188,13 +188,13 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
} // eventCallback
// ----------------------------------------------------------------------------
void OnlineScreen::tearDown()
/** Also called when pressing the back button. It resets the flags to indicate
* a networked game.
*/
bool OnlineScreen::onEscapePressed()
{
} // tearDown
NetworkConfig::get()->unsetNetworking();
return true;
} // onEscapePressed
// ----------------------------------------------------------------------------
void OnlineScreen::onDisabledItemClicked(const std::string& item)
{
} // onDisabledItemClicked

View File

@ -62,10 +62,8 @@ public:
virtual void init() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void tearDown() OVERRIDE;
virtual bool onEscapePressed() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void onDisabledItemClicked(const std::string& item) OVERRIDE;
};
#endif

View File

@ -44,7 +44,7 @@
#include "modes/overworld.hpp"
#include "modes/soccer_world.hpp"
#include "modes/world_with_rank.hpp"
#include "network/protocol_manager.hpp"
#include "network/stk_host.hpp"
#include "network/protocols/client_lobby.hpp"
#include "race/highscores.hpp"
#include "scriptengine/property_animator.hpp"
@ -52,9 +52,8 @@
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/networking_lobby.hpp"
#include "states_screens/network_kart_selection.hpp"
#include "states_screens/online_profile_servers.hpp"
#include "states_screens/online_screen.hpp"
#include "states_screens/race_setup_screen.hpp"
#include "states_screens/server_selection.hpp"
#include "tracks/track.hpp"
#include "tracks/track_manager.hpp"
#include "utils/string_utils.hpp"
@ -172,10 +171,10 @@ void RaceResultGUI::enableAllButtons()
{
Log::info("This work was networked", "This is a network world.");
top->setVisible(false);
middle->setText(_("Continue."));
middle->setText(_("Continue"));
middle->setVisible(true);
middle->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
bottom->setText(_("Quit the server."));
bottom->setText(_("Quit the server"));
bottom->setVisible(true);
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
@ -355,9 +354,14 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
}
if (name == "bottom") // Quit server (return to main menu)
{
if (STKHost::existHost())
{
STKHost::get()->shutdown();
}
race_manager->exitRace();
race_manager->setAIKartOverride("");
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
NetworkConfig::get()->unsetNetworking();
}
return;
}
@ -427,8 +431,7 @@ void RaceResultGUI::backToLobby()
race_manager->exitRace();
race_manager->setAIKartOverride("");
Screen* newStack[] = { MainMenuScreen::getInstance(),
OnlineProfileServers::getInstance(),
ServerSelection::getInstance(),
OnlineScreen::getInstance(),
NetworkingLobby::getInstance(),
NULL };
StateManager::get()->resetAndSetStack(newStack);