Make pause button working when watching ghost replay

This commit is contained in:
Deve 2018-09-19 22:06:24 +02:00
parent 9f3bc471d8
commit 2c79b02088
2 changed files with 26 additions and 18 deletions

View File

@ -388,25 +388,26 @@ void MultitouchDevice::updateAxisY(float value)
*/ */
void MultitouchDevice::handleControls(MultitouchButton* button) void MultitouchDevice::handleControls(MultitouchButton* button)
{ {
if (m_controller == NULL) if (!isGameRunning())
return; return;
if (button->type == MultitouchButtonType::BUTTON_STEERING) if (button->type == MultitouchButtonType::BUTTON_ESCAPE)
{
updateAxisX(button->axis_x);
updateAxisY(button->axis_y);
}
else if (button->type == MultitouchButtonType::BUTTON_UP_DOWN)
{
updateAxisY(button->axis_y);
}
else if (button->type == MultitouchButtonType::BUTTON_ESCAPE)
{ {
StateManager::get()->escapePressed(); StateManager::get()->escapePressed();
} }
else
if (m_controller != NULL && !race_manager->isWatchingReplay())
{ {
if (button->action != PA_BEFORE_FIRST) if (button->type == MultitouchButtonType::BUTTON_STEERING)
{
updateAxisX(button->axis_x);
updateAxisY(button->axis_y);
}
else if (button->type == MultitouchButtonType::BUTTON_UP_DOWN)
{
updateAxisY(button->axis_y);
}
else if (button->action != PA_BEFORE_FIRST)
{ {
int value = button->pressed ? Input::MAX_VALUE : 0; int value = button->pressed ? Input::MAX_VALUE : 0;
m_controller->action(button->action, value); m_controller->action(button->action, value);
@ -416,6 +417,15 @@ void MultitouchDevice::handleControls(MultitouchButton* button)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool MultitouchDevice::isGameRunning()
{
return StateManager::get()->getGameState() == GUIEngine::GAME &&
!GUIEngine::ModalDialog::isADialogActive() &&
!GUIEngine::ScreenKeyboard::isActive();
}
// ----------------------------------------------------------------------------
void MultitouchDevice::updateController() void MultitouchDevice::updateController()
{ {
if (m_player == NULL) if (m_player == NULL)
@ -427,10 +437,7 @@ void MultitouchDevice::updateController()
// Handle multitouch events only when race is running. It avoids to process // Handle multitouch events only when race is running. It avoids to process
// it when pause dialog is active during the race. And there is no reason // it when pause dialog is active during the race. And there is no reason
// to use it for GUI navigation. // to use it for GUI navigation.
if (StateManager::get()->getGameState() != GUIEngine::GAME || if (!isGameRunning())
GUIEngine::ModalDialog::isADialogActive() ||
GUIEngine::ScreenKeyboard::isActive() ||
race_manager->isWatchingReplay())
{ {
m_controller = NULL; m_controller = NULL;
return; return;

View File

@ -94,6 +94,7 @@ private:
float getSteeringFactor(float value); float getSteeringFactor(float value);
void handleControls(MultitouchButton* button); void handleControls(MultitouchButton* button);
bool isGameRunning();
public: public:
/** The array that contains data for all multitouch input events */ /** The array that contains data for all multitouch input events */