diff --git a/src/blupi.cxx b/src/blupi.cxx index ea41442..1b2c498 100644 --- a/src/blupi.cxx +++ b/src/blupi.cxx @@ -241,7 +241,8 @@ Update (void) g_pEvent->DecorAutoShift (); g_pDecor->Build (clip, posMouse); // build the environment - g_pDecor->NextPhase (1); // rebuild the map sometimes + g_pEvent->PlayMove (posMouse); + g_pDecor->NextPhase (1); // rebuild the map sometimes } if (phase == EV_PHASE_BUILD) @@ -260,6 +261,13 @@ Update (void) g_pEvent->DemoStep (); // start automatically (eventually) the demo } + SDL_Event event = {0}; + event.type = SDL_MOUSEMOTION; + event.motion.x = posMouse.x; + event.motion.y = posMouse.y; + g_pEvent->EventButtons (event, posMouse); + g_pEvent->MouseSprite (posMouse); + g_pEvent->DrawButtons (); g_lastPhase = phase; diff --git a/src/button.cxx b/src/button.cxx index 7e74a8e..7a09128 100644 --- a/src/button.cxx +++ b/src/button.cxx @@ -274,16 +274,8 @@ CButton::TreatEvent (const SDL_Event & event) pos.x = event.button.x; pos.y = event.button.y; - if (MouseUp (pos)) - { - /* Simulate a mouse move in order to restore the mouse hover state. */ - SDL_Event ev = {0}; - ev.type = SDL_MOUSEMOTION; - ev.motion.x = pos.x; - ev.motion.y = pos.y; - SDL_PushEvent (&ev); + if (MouseUp (pos)) // (*) return false; - } // (*) break; } diff --git a/src/event.cxx b/src/event.cxx index f69b73e..79a75bb 100644 --- a/src/event.cxx +++ b/src/event.cxx @@ -5824,10 +5824,7 @@ CEvent::TreatEventBase (const SDL_Event & event) case SDLK_RCTRL: m_keymod |= KMOD_CTRL; if (m_phase == EV_PHASE_BUILD) - { m_bFillMouse = true; - MouseSprite (GetMousePos ()); - } else m_bFillMouse = false; return true; @@ -5893,7 +5890,6 @@ CEvent::TreatEventBase (const SDL_Event & event) case SDLK_RCTRL: m_keymod &= ~KMOD_CTRL; m_bFillMouse = false; - MouseSprite (GetMousePos ()); return true; } break; @@ -5907,8 +5903,6 @@ CEvent::TreatEventBase (const SDL_Event & event) pos.x = event.button.x; pos.y = event.button.y; - MouseSprite (pos); - //? DecorAutoShift(pos); if (EventButtons (event, pos)) return true; if (m_phase == EV_PHASE_BUILD) @@ -5929,7 +5923,6 @@ CEvent::TreatEventBase (const SDL_Event & event) m_oldMousePos = pos; - MouseSprite (pos); if (EventButtons (event, pos)) return true; if (m_phase == EV_PHASE_BUILD) @@ -5938,10 +5931,7 @@ CEvent::TreatEventBase (const SDL_Event & event) return true; } if (m_phase == EV_PHASE_PLAY) - { - if (PlayMove (pos)) - return true; - } + return true; break; case SDL_MOUSEBUTTONUP: diff --git a/src/event.h b/src/event.h index bd8df67..2554ab3 100644 --- a/src/event.h +++ b/src/event.h @@ -150,18 +150,19 @@ public: void SetWindowSize (Uint8 newScale); void SetUpdateVersion (const std::string & version); + bool EventButtons (const SDL_Event & event, Point pos); + bool PlayMove (Point pos); + static void PushUserEvent (Sint32 code, void * data = nullptr); protected: void DrawTextCenter (const char * text, Sint32 x, Sint32 y, Sint32 font = 0); bool CreateButtons (Sint32 phase); - bool EventButtons (const SDL_Event & event, Point pos); bool MouseOnButton (Point pos); Sint32 SearchPhase (Uint32 phase); void DecorShift (Sint32 dx, Sint32 dy); bool PlayDown (Point pos, const SDL_Event & event); - bool PlayMove (Point pos); bool PlayUp (Point pos); Language GetStartLanguage ();