Disable in game menu to avoid timer desync if not racing in network game

This commit is contained in:
Benau
2018-07-12 07:16:37 +08:00
parent 11d9090039
commit 7e2d25d4a9
2 changed files with 22 additions and 5 deletions

View File

@@ -95,8 +95,12 @@ void RacePausedDialog::loadedFromFile()
{
GUIEngine::RibbonWidget* choice_ribbon =
getWidget<GUIEngine::RibbonWidget>("choiceribbon");
#ifdef DEBUG
const bool success = choice_ribbon->deleteChild("restart");
assert(success);
#else
choice_ribbon->deleteChild("restart");
#endif
}
// Remove "endrace" button for types not (yet?) implemented
// Also don't show it unless the race has started. Prevents finishing in
@@ -230,6 +234,20 @@ void RacePausedDialog::beforeAddingWidgets()
int index = choice_ribbon->findItemNamed("newrace");
if (index != -1)
choice_ribbon->setItemVisible(index, !showSetupNewRace);
// Disable in game menu to avoid timer desync if not racing in network
// game
if (NetworkConfig::get()->isNetworking() &&
World::getWorld()->getPhase() != WorldStatus::RACE_PHASE)
{
index = choice_ribbon->findItemNamed("help");
if (index != -1)
choice_ribbon->setItemVisible(index, false);
index = choice_ribbon->findItemNamed("options");
if (index != -1)
choice_ribbon->setItemVisible(index, false);
}
}
// ----------------------------------------------------------------------------

View File

@@ -34,7 +34,7 @@ class RacePausedDialog : public GUIEngine::ModalDialog
{
protected:
virtual void loadedFromFile();
virtual void loadedFromFile() OVERRIDE;
public:
/**
@@ -42,10 +42,9 @@ public:
*/
RacePausedDialog(const float percentWidth, const float percentHeight);
virtual ~RacePausedDialog();
void onEnterPressedInternal();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
virtual void onEnterPressedInternal() OVERRIDE;
GUIEngine::EventPropagation processEvent(const std::string& eventSource)
OVERRIDE;
virtual void beforeAddingWidgets() OVERRIDE;
};