Avoid pushing and using screen in no graphics
This commit is contained in:
parent
840771d189
commit
4a9135c8c0
@ -53,6 +53,12 @@ void AbstractStateManager::enterGameState()
|
||||
assert(!ModalDialog::isADialogActive());
|
||||
assert(!ScreenKeyboard::isActive());
|
||||
|
||||
if (GUIEngine::isNoGraphics())
|
||||
{
|
||||
setGameState(GAME);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getCurrentScreen() != NULL) getCurrentScreen()->tearDown();
|
||||
m_menu_stack.clear();
|
||||
m_menu_stack.emplace_back(RACE_STATE_NAME, (Screen*)NULL);
|
||||
|
@ -110,6 +110,12 @@ namespace GUIEngine
|
||||
*/
|
||||
void resetAndSetStack(Screen* screens[]);
|
||||
|
||||
/**
|
||||
* \brief Used in no graphics STK to enter menu screen (when server is
|
||||
* idle state)
|
||||
*/
|
||||
void enterMenuState() { setGameState(MENU); }
|
||||
|
||||
/**
|
||||
* \brief call to make the state manager enter game mode.
|
||||
* Causes the menu stack to be cleared; all widgets shown on screen
|
||||
|
@ -1408,7 +1408,10 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
|
||||
else
|
||||
NetworkConfig::get()->setIsLAN();
|
||||
STKHost::create();
|
||||
NetworkingLobby::getInstance()->setJoinedServer(server);
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
NetworkingLobby::getInstance()->setJoinedServer(server);
|
||||
else if (NetworkConfig::get()->isClient())
|
||||
std::make_shared<ConnectToServer>(server)->requestStart();
|
||||
}
|
||||
|
||||
if (NetworkConfig::get()->isServer())
|
||||
@ -2253,7 +2256,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (STKHost::existHost())
|
||||
{
|
||||
NetworkingLobby::getInstance()->push();
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
NetworkingLobby::getInstance()->push();
|
||||
}
|
||||
else if (!UserConfigParams::m_no_start_screen)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "config/user_config.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "guiengine/message_queue.hpp"
|
||||
#include "guiengine/screen_keyboard.hpp"
|
||||
@ -57,7 +58,6 @@
|
||||
#include "states_screens/dialogs/addons_pack.hpp"
|
||||
#include "states_screens/online/networking_lobby.hpp"
|
||||
#include "states_screens/online/network_kart_selection.hpp"
|
||||
#include "states_screens/race_result_gui.hpp"
|
||||
#include "states_screens/online/tracks_screen.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
@ -134,7 +134,8 @@ void ClientLobby::setup()
|
||||
m_auto_back_to_lobby_time = std::numeric_limits<uint64_t>::max();
|
||||
m_start_live_game_time = std::numeric_limits<uint64_t>::max();
|
||||
m_received_server_result = false;
|
||||
TracksScreen::getInstance()->resetVote();
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
TracksScreen::getInstance()->resetVote();
|
||||
LobbyProtocol::setup();
|
||||
m_state.store(NONE);
|
||||
} // setup
|
||||
@ -264,7 +265,8 @@ void ClientLobby::addAllPlayers(Event* event)
|
||||
PeerVote winner_vote(data);
|
||||
|
||||
m_game_setup->setRace(winner_vote);
|
||||
TracksScreen::getInstance()->setResult(winner_peer_id, winner_vote);
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
TracksScreen::getInstance()->setResult(winner_peer_id, winner_vote);
|
||||
|
||||
std::shared_ptr<STKPeer> peer = event->getPeerSP();
|
||||
peer->cleanPlayerProfiles();
|
||||
@ -547,8 +549,11 @@ void ClientLobby::receivePlayerVote(Event* event)
|
||||
vote.m_track_name.c_str());
|
||||
}
|
||||
addVote(host_id, vote);
|
||||
TracksScreen::getInstance()->addVote(host_id, vote);
|
||||
TracksScreen::getInstance()->updatePlayerVotes();
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
{
|
||||
TracksScreen::getInstance()->addVote(host_id, vote);
|
||||
TracksScreen::getInstance()->updatePlayerVotes();
|
||||
}
|
||||
} // receivePlayerVote
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -590,8 +595,11 @@ void ClientLobby::disconnectedPlayer(Event* event)
|
||||
// Use the friend icon to avoid an error-like message
|
||||
MessageQueue::add(MessageQueue::MT_FRIEND, msg);
|
||||
}
|
||||
TracksScreen::getInstance()->removeVote(host_id);
|
||||
TracksScreen::getInstance()->updatePlayerVotes();
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
{
|
||||
TracksScreen::getInstance()->removeVote(host_id);
|
||||
TracksScreen::getInstance()->updatePlayerVotes();
|
||||
}
|
||||
} // disconnectedPlayer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -640,7 +648,8 @@ void ClientLobby::connectionAccepted(Event* event)
|
||||
float auto_start_timer = data.getFloat();
|
||||
int state_frequency_in_server = data.getUInt32();
|
||||
NetworkConfig::get()->setStateFrequency(state_frequency_in_server);
|
||||
if (auto_start_timer != std::numeric_limits<float>::max())
|
||||
if (!GUIEngine::isNoGraphics() &&
|
||||
auto_start_timer != std::numeric_limits<float>::max())
|
||||
NetworkingLobby::getInstance()->setStartingTimerTo(auto_start_timer);
|
||||
m_server_enabled_chat = data.getUInt8() == 1;
|
||||
if (NetworkConfig::get()->getServerCapabilities().find("report_player") !=
|
||||
@ -731,8 +740,11 @@ void ClientLobby::handleServerInfo(Event* event)
|
||||
// Auto start info
|
||||
unsigned min_players = data.getUInt8();
|
||||
float start_timeout = data.getFloat();
|
||||
NetworkingLobby::getInstance()->initAutoStartTimer(grand_prix_started,
|
||||
min_players, start_timeout, max_player);
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
{
|
||||
NetworkingLobby::getInstance()->initAutoStartTimer(grand_prix_started,
|
||||
min_players, start_timeout, max_player);
|
||||
}
|
||||
|
||||
// MOTD
|
||||
core::stringw motd;
|
||||
@ -745,10 +757,12 @@ void ClientLobby::handleServerInfo(Event* event)
|
||||
if (total_lines[total_lines.size() - 1] == L'\n')
|
||||
total_lines.erase(total_lines.size() - 1);
|
||||
|
||||
NetworkingLobby::getInstance()->addMoreServerInfo(total_lines);
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
NetworkingLobby::getInstance()->addMoreServerInfo(total_lines);
|
||||
|
||||
bool server_config = data.getUInt8() == 1;
|
||||
NetworkingLobby::getInstance()->toggleServerConfigButton(server_config);
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
NetworkingLobby::getInstance()->toggleServerConfigButton(server_config);
|
||||
m_server_live_joinable = data.getUInt8() == 1;
|
||||
} // handleServerInfo
|
||||
|
||||
@ -821,7 +835,8 @@ void ClientLobby::updatePlayerList(Event* event)
|
||||
SFXManager::get()->quickSound("energy_bar_full");
|
||||
m_total_players = total_players;
|
||||
|
||||
NetworkingLobby::getInstance()->updatePlayers();
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
NetworkingLobby::getInstance()->updatePlayers();
|
||||
} // updatePlayerList
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -863,6 +878,8 @@ void ClientLobby::handleChat(Event* event)
|
||||
core::stringw message;
|
||||
event->data().decodeString16(&message);
|
||||
Log::info("ClientLobby", "%s", StringUtils::wideToUtf8(message).c_str());
|
||||
if (GUIEngine::isNoGraphics())
|
||||
return;
|
||||
if (message.size() > 0)
|
||||
{
|
||||
if (GUIEngine::getCurrentScreen() == NetworkingLobby::getInstance())
|
||||
@ -1003,10 +1020,14 @@ void ClientLobby::startSelection(Event* event)
|
||||
// In case the user opened a user info dialog
|
||||
GUIEngine::ModalDialog::dismiss();
|
||||
GUIEngine::ScreenKeyboard::dismiss();
|
||||
NetworkKartSelectionScreen* screen =
|
||||
NetworkKartSelectionScreen::getInstance();
|
||||
screen->setAvailableKartsFromServer(m_available_karts);
|
||||
screen->setLiveJoin(false);
|
||||
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
{
|
||||
NetworkKartSelectionScreen* screen =
|
||||
NetworkKartSelectionScreen::getInstance();
|
||||
screen->setAvailableKartsFromServer(m_available_karts);
|
||||
screen->setLiveJoin(false);
|
||||
}
|
||||
// In case of auto-connect or continue a grand prix, use random karts
|
||||
// (or previous kart) from server and go to track selection
|
||||
if ((NetworkConfig::get()->isAutoConnect() || skip_kart_screen) &&
|
||||
@ -1019,17 +1040,23 @@ 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();
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
{
|
||||
TracksScreen::getInstance()->setQuitServer();
|
||||
TracksScreen::getInstance()->setNetworkTracks();
|
||||
TracksScreen::getInstance()->push();
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!GUIEngine::isNoGraphics())
|
||||
{
|
||||
screen->push();
|
||||
NetworkKartSelectionScreen::getInstance()->push();
|
||||
}
|
||||
|
||||
TracksScreen *ts = TracksScreen::getInstance();
|
||||
ts->resetVote();
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
{
|
||||
TracksScreen *ts = TracksScreen::getInstance();
|
||||
ts->resetVote();
|
||||
}
|
||||
m_state.store(SELECTING_ASSETS);
|
||||
Log::info("ClientLobby", "Selection starts now");
|
||||
} // startSelection
|
||||
@ -1137,10 +1164,10 @@ void ClientLobby::backToLobby(Event *event)
|
||||
{
|
||||
auto lock = gp->acquireWorldDeletingMutex();
|
||||
ProtocolManager::lock()->findAndTerminate(PROTOCOL_CONTROLLER_EVENTS);
|
||||
RaceResultGUI::getInstance()->backToLobby();
|
||||
exitGameState();
|
||||
}
|
||||
else
|
||||
RaceResultGUI::getInstance()->backToLobby();
|
||||
exitGameState();
|
||||
|
||||
NetworkString &data = event->data();
|
||||
core::stringw msg;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "config/user_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "network/crypto.hpp"
|
||||
#include "network/event.hpp"
|
||||
#include "network/network.hpp"
|
||||
@ -356,7 +357,8 @@ void ConnectToServer::update(int ticks)
|
||||
{
|
||||
// Make sure lobby display the quick play server name
|
||||
assert(m_server);
|
||||
NetworkingLobby::getInstance()->setJoinedServer(m_server);
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
NetworkingLobby::getInstance()->setJoinedServer(m_server);
|
||||
break;
|
||||
}
|
||||
case DONE:
|
||||
|
@ -21,6 +21,9 @@
|
||||
|
||||
#include "input/input_manager.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/message_queue.hpp"
|
||||
#include "guiengine/screen_keyboard.hpp"
|
||||
#include "graphics/render_info.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/controller/controller.hpp"
|
||||
@ -33,9 +36,13 @@
|
||||
#include "network/protocols/game_events_protocol.hpp"
|
||||
#include "network/race_event_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/online/networking_lobby.hpp"
|
||||
#include "states_screens/race_result_gui.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
std::weak_ptr<LobbyProtocol> LobbyProtocol::m_lobby;
|
||||
|
||||
@ -251,3 +258,40 @@ Track* LobbyProtocol::getPlayingTrack() const
|
||||
ul.unlock();
|
||||
return track_manager->getTrack(track_ident);
|
||||
} // getPlayingTrack
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void LobbyProtocol::exitGameState()
|
||||
{
|
||||
bool create_gp_msg = false;
|
||||
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX &&
|
||||
race_manager->getTrackNumber() == race_manager->getNumOfTracks() - 1)
|
||||
{
|
||||
create_gp_msg = true;
|
||||
}
|
||||
|
||||
race_manager->clearNetworkGrandPrixResult();
|
||||
race_manager->exitRace();
|
||||
race_manager->setAIKartOverride("");
|
||||
|
||||
if (GUIEngine::isNoGraphics())
|
||||
{
|
||||
// No screen is ever created when no graphics is on
|
||||
StateManager::get()->enterMenuState();
|
||||
return;
|
||||
}
|
||||
|
||||
GUIEngine::ModalDialog::dismiss();
|
||||
GUIEngine::ScreenKeyboard::dismiss();
|
||||
RaceResultGUI::getInstance()->cleanupGPProgress();
|
||||
if (create_gp_msg)
|
||||
{
|
||||
core::stringw msg = _("Network grand prix has been finished.");
|
||||
MessageQueue::add(MessageQueue::MT_ACHIEVEMENT, msg);
|
||||
}
|
||||
|
||||
if (GUIEngine::getCurrentScreen() != NetworkingLobby::getInstance())
|
||||
{
|
||||
StateManager::get()->resetAndSetStack(
|
||||
NetworkConfig::get()->getResetScreens(true/*lobby*/).data());
|
||||
}
|
||||
} // exitGameState
|
||||
|
@ -149,6 +149,8 @@ protected:
|
||||
// ------------------------------------------------------------------------
|
||||
void addLiveJoiningKart(int kart_id, const RemoteKartInfo& rki,
|
||||
int live_join_util_ticks) const;
|
||||
// ------------------------------------------------------------------------
|
||||
void exitGameState();
|
||||
public:
|
||||
|
||||
/** Creates either a client or server lobby protocol as a singleton. */
|
||||
|
@ -49,8 +49,6 @@
|
||||
#include "online/request_manager.hpp"
|
||||
#include "online/xml_request.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/online/networking_lobby.hpp"
|
||||
#include "states_screens/race_result_gui.hpp"
|
||||
#include "tracks/check_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
@ -2055,7 +2053,7 @@ void ServerLobby::update(int ticks)
|
||||
!GameProtocol::emptyInstance())
|
||||
return;
|
||||
|
||||
RaceResultGUI::getInstance()->backToLobby();
|
||||
exitGameState();
|
||||
m_rs_state.store(RS_ASYNC_RESET);
|
||||
}
|
||||
|
||||
@ -2152,7 +2150,7 @@ void ServerLobby::update(int ticks)
|
||||
return;
|
||||
|
||||
// This will go back to lobby in server (and exit the current race)
|
||||
RaceResultGUI::getInstance()->backToLobby();
|
||||
exitGameState();
|
||||
// Reset for next state usage
|
||||
resetPeersReady();
|
||||
// Set the delay before the server forces all clients to exit the race
|
||||
|
@ -515,31 +515,6 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
return;
|
||||
} // eventCallback
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets up the gui to go back to the lobby. Can only be called in case of a
|
||||
* networked game.
|
||||
*/
|
||||
void RaceResultGUI::backToLobby()
|
||||
{
|
||||
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX &&
|
||||
race_manager->getTrackNumber() == race_manager->getNumOfTracks() - 1)
|
||||
{
|
||||
core::stringw msg = _("Network grand prix has been finished.");
|
||||
MessageQueue::add(MessageQueue::MT_ACHIEVEMENT, msg);
|
||||
}
|
||||
race_manager->clearNetworkGrandPrixResult();
|
||||
race_manager->exitRace();
|
||||
race_manager->setAIKartOverride("");
|
||||
GUIEngine::ModalDialog::dismiss();
|
||||
GUIEngine::ScreenKeyboard::dismiss();
|
||||
cleanupGPProgress();
|
||||
if (GUIEngine::getCurrentScreen() != NetworkingLobby::getInstance())
|
||||
{
|
||||
StateManager::get()->resetAndSetStack(
|
||||
NetworkConfig::get()->getResetScreens(true/*lobby*/).data());
|
||||
}
|
||||
} // backToLobby
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceResultGUI::displayCTFResults()
|
||||
{
|
||||
|
@ -193,7 +193,6 @@ private:
|
||||
void enableGPProgress();
|
||||
void addGPProgressWidget(GUIEngine::Widget* widget);
|
||||
void displayGPProgress();
|
||||
void cleanupGPProgress();
|
||||
void displayPostRaceInfo();
|
||||
void displayCTFResults();
|
||||
void displaySoccerResults();
|
||||
@ -217,9 +216,6 @@ public:
|
||||
Input::InputType type, int playerId) OVERRIDE;
|
||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
void backToLobby();
|
||||
|
||||
|
||||
friend class GUIEngine::ScreenSingleton<RaceResultGUI>;
|
||||
|
||||
/** Should not be called anymore. */
|
||||
@ -260,6 +256,7 @@ public:
|
||||
void setHighscore(int rank);
|
||||
|
||||
virtual void onConfirm() OVERRIDE;
|
||||
void cleanupGPProgress();
|
||||
}; // RaceResultGUI
|
||||
|
||||
#endif
|
||||
|
@ -152,8 +152,8 @@ void StateManager::resetActivePlayers()
|
||||
bool StateManager::throttleFPS()
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
return m_game_mode != GUIEngine::GAME &&
|
||||
GUIEngine::getCurrentScreen()->throttleFPS();
|
||||
return m_game_mode != GUIEngine::GAME && GUIEngine::getCurrentScreen() &&
|
||||
GUIEngine::getCurrentScreen()->throttleFPS();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user