Let the network game keep going even race paused dialog shown

This commit is contained in:
Benau 2018-04-20 13:30:17 +08:00
parent e5c991e3d2
commit 0c33803159
3 changed files with 24 additions and 12 deletions

View File

@ -30,6 +30,7 @@
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/render_info.hpp"
#include "guiengine/modaldialog.hpp"
#include "io/file_manager.hpp"
#include "input/device_manager.hpp"
#include "input/keyboard_device.hpp"
@ -660,6 +661,8 @@ void World::terminateRace()
results->clearHighscores();
}
// In case someone opened paused race dialog in network game
GUIEngine::ModalDialog::dismiss();
results->push();
WorldStatus::terminateRace();
} // terminateRace

View File

@ -346,15 +346,6 @@ void RewindManager::rewindTo(int rewind_ticks, int now_ticks)
// Now start the rewind with the full state:
world->setTicks(exact_rewind_ticks);
// Need to exit loop if in-game menu is open, since world clock
// will not be increased while the game is paused
if (World::getWorld()->getPhase() == WorldStatus::IN_GAME_MENU_PHASE)
{
m_is_rewinding = false;
history->setReplayHistory(is_history);
return;
}
// Get the (first) full state to which we have to rewind
RewindInfo *current = m_rewind_queue.getCurrent();
assert(current->isState());

View File

@ -19,6 +19,8 @@
#include <string>
#include "audio/music_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/scalable_font.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
@ -57,16 +59,32 @@ RacePausedDialog::RacePausedDialog(const float percentWidth,
loadFromFile("race_paused_dialog.stkgui");
}
World::getWorld()->schedulePause(WorldStatus::IN_GAME_MENU_PHASE);
IconButtonWidget* back_btn = getWidget<IconButtonWidget>("backbtn");
back_btn->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
if (NetworkConfig::get()->isNetworking())
{
music_manager->pauseMusic();
SFXManager::get()->pauseAll();
}
else
{
World::getWorld()->schedulePause(WorldStatus::IN_GAME_MENU_PHASE);
}
} // RacePausedDialog
// ----------------------------------------------------------------------------
RacePausedDialog::~RacePausedDialog()
{
World::getWorld()->scheduleUnpause();
if (NetworkConfig::get()->isNetworking())
{
music_manager->resumeMusic();
SFXManager::get()->resumeAll();
}
else
{
World::getWorld()->scheduleUnpause();
}
} // ~RacePausedDialog
// ----------------------------------------------------------------------------