diff --git a/binaries/data/mods/public/gui/session/session.xml b/binaries/data/mods/public/gui/session/session.xml index 7b242338dd..d37f920acb 100644 --- a/binaries/data/mods/public/gui/session/session.xml +++ b/binaries/data/mods/public/gui/session/session.xml @@ -928,44 +928,28 @@ size="0 100%-212 212 100%" type="image" sprite="mapPanel" - z="20" > + + + + + findIdleUnit(["Female", "Trade", "FishingBoat", "CitizenSoldier", "Healer"]); + Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle-highlight.png"; + Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle.png"; + Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle.png"; + Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle-highlight.png"; + + handleMinimapEvent(arguments[0]); - - - - - - - - - findIdleUnit(["Female", "Trade", "FishingBoat", "CitizenSoldier", "Healer"]); - - - findIdleUnit(["Female", "Trade", "FishingBoat", "CitizenSoldier", "Healer"]); - - - findIdleUnit(["Female", "Trade", "FishingBoat", "CitizenSoldier", "Healer"]); - - + diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 9683bfbe80..67f0a792c8 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -129,14 +129,9 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev) // pNearest will after this point at the hovered object, possibly NULL pNearest = FindObjectUnderMouse(); - // Is placed in the UpdateMouseOver function - //if (ev->ev.type == SDL_MOUSEMOTION && pNearest) - // pNearest->ScriptEvent("mousemove"); - // Now we'll call UpdateMouseOver on *all* objects, // we'll input the one hovered, and they will each // update their own data and send messages accordingly - GUI::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject, &IGUIObject::UpdateMouseOver, pNearest); @@ -232,10 +227,10 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev) GUI<>::RecurseObject(GUIRR_HIDDEN, m_BaseObject, &IGUIObject::ResetStates); - // It will have reset the mouse over of the current hovered, so we'll - // have to restore that - if (pNearest) - pNearest->m_MouseHovering = true; + // Since the hover state will have been reset, we reload it. + GUI::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject, + &IGUIObject::UpdateMouseOver, + pNearest); } } catch (PSERROR_GUI& e) diff --git a/source/gui/IGUIObject.h b/source/gui/IGUIObject.h index ba45610b61..48a6df1461 100644 --- a/source/gui/IGUIObject.h +++ b/source/gui/IGUIObject.h @@ -514,7 +514,7 @@ protected: // Pointer to parent IGUIObject *m_pParent; - + //This represents the last click time for each mouse button double m_LastClickTime[6]; diff --git a/source/gui/MiniMap.cpp b/source/gui/MiniMap.cpp index 76eb5567f9..8bae797faa 100644 --- a/source/gui/MiniMap.cpp +++ b/source/gui/MiniMap.cpp @@ -199,6 +199,21 @@ void CMiniMap::HandleMessage(SGUIMessage &Message) } // switch } +bool CMiniMap::MouseOver() +{ + // Get the mouse position. + CPos mousePos = GetMousePos(); + // Get the position of the center of the minimap. + CPos minimapCenter = CPos(m_CachedActualSize.left + m_CachedActualSize.GetWidth() / 2.0, m_CachedActualSize.bottom - m_CachedActualSize.GetHeight() / 2.0); + // Take the magnitude of the difference of the mouse position and minimap center. + double distFromCenter = sqrt(pow((mousePos.x - minimapCenter.x), 2) + pow((mousePos.y - minimapCenter.y), 2)); + // If the distance is less then the radius of the minimap (half the width) the mouse is over the minimap. + if (distFromCenter < m_CachedActualSize.GetWidth() / 2.0) + return true; + else + return false; +} + void CMiniMap::GetMouseWorldCoordinates(float& x, float& z) { // Determine X and Z according to proportion of mouse position and minimap diff --git a/source/gui/MiniMap.h b/source/gui/MiniMap.h index 3b56d3f0f1..1bb76d4150 100644 --- a/source/gui/MiniMap.h +++ b/source/gui/MiniMap.h @@ -39,6 +39,11 @@ protected: */ virtual void HandleMessage(SGUIMessage &Message); + /** + * @see IGUIObject#MouseOver() + */ + virtual bool MouseOver(); + // create the minimap textures void CreateTextures();