Ticket #850: Ticket_850_V2.patch
File Ticket_850_V2.patch, 26.4 KB (added by , 12 years ago) |
---|
-
source/gui/IGUIScrollBar.cpp
76 76 m_Pos = m_ScrollRange - m_ScrollSpace; 77 77 } 78 78 79 void IGUIScrollBar::ResetMouseStates() 80 { 81 IGUIObject::ResetMouseStates(); 82 SetBarPressed(false); 83 } 84 79 85 void IGUIScrollBar::HandleMessage(SGUIMessage &Message) 80 86 { 81 87 switch (Message.type) … … 120 126 m_BarPressed = true; 121 127 m_BarPressedAtPos = mouse; 122 128 m_PosWhenPressed = m_Pos; 129 m_IsCapturing = true; 123 130 } 124 131 else 125 132 // if button-minus is pressed … … 159 166 case GUIM_MOUSE_RELEASE_LEFT: 160 167 m_ButtonMinusPressed = false; 161 168 m_ButtonPlusPressed = false; 169 m_BarPressed = false; 170 m_IsCapturing = false; 162 171 break; 163 172 164 173 default: -
source/gui/IGUIButtonBehavior.cpp
48 48 break; 49 49 50 50 m_Pressed = true; 51 m_IsCapturing = true; 51 52 } break; 52 53 53 54 case GUIM_MOUSE_DBLCLICK_LEFT: 54 55 case GUIM_MOUSE_RELEASE_LEFT: 55 56 { 57 // Don't caputre anymore if the mouse button is released, regardless of the circumstances 58 m_IsCapturing = false; 59 56 60 bool enabled; 57 61 GUI<bool>::GetSetting(this, "enabled", enabled); 58 62 59 63 if (!enabled) 60 64 break; 61 65 62 if (m_Pressed )66 if (m_Pressed && m_MouseHovering) 63 67 { 64 m_Pressed = false;65 68 if (Message.type == GUIM_MOUSE_RELEASE_LEFT) 66 69 { 67 70 // Button was clicked … … 77 80 SendEvent(GUIM_DOUBLE_PRESSED, "doublepress"); 78 81 } 79 82 } 83 m_Pressed = false; 80 84 } break; 81 85 82 86 default: … … 116 120 else return color; 117 121 } 118 122 123 void IGUIButtonBehavior::ResetMouseStates() 124 { 125 IGUIObject::ResetMouseStates(); 126 m_Pressed = false; 127 } 128 119 129 void IGUIButtonBehavior::DrawButton(const CRect &rect, 120 130 const float &z, 121 131 CGUISpriteInstance& sprite, -
source/gui/IGUIScrollBarOwner.cpp
40 40 } 41 41 } 42 42 43 void IGUIScrollBarOwner::Reset States()43 void IGUIScrollBarOwner::ResetMouseStates() 44 44 { 45 IGUIObject::Reset States();45 IGUIObject::ResetMouseStates(); 46 46 47 47 std::vector<IGUIScrollBar*>::iterator it; 48 48 for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it) 49 49 { 50 (*it)-> SetBarPressed(false);50 (*it)->ResetMouseStates(); 51 51 } 52 52 } 53 53 … … 78 78 79 79 void IGUIScrollBarOwner::HandleMessage(SGUIMessage &Message) 80 80 { 81 m_IsCapturing = false; 81 82 std::vector<IGUIScrollBar*>::iterator it; 82 83 for (it=m_ScrollBars.begin(); it!=m_ScrollBars.end(); ++it) 83 84 { 84 85 (*it)->HandleMessage(Message); 86 if((*it)->IsCapturing()) 87 { 88 m_IsCapturing = true; 89 } 85 90 } 86 91 } 87 92 -
source/gui/CList.h
72 72 virtual ~CList(); 73 73 74 74 /** 75 * @see IGUIObject#Reset States()75 * @see IGUIObject#ResetMouseStates() 76 76 */ 77 virtual void Reset States() { IGUIScrollBarOwner::ResetStates(); }77 virtual void ResetMouseStates() { IGUIScrollBarOwner::ResetMouseStates(); } 78 78 79 79 /** 80 80 * Adds an item last to the list. -
source/gui/GUIutil.h
80 80 /// const version 81 81 static const IGUIObject * GetObjectPointer(const CGUI &GUIinstance, const CStr& Object); 82 82 83 /// Wrapper for Reset States83 /// Wrapper for ResetMouseStates 84 84 static void QueryResetting(IGUIObject *pObject); 85 85 86 86 static void HandleMessage(IGUIObject *pObject, SGUIMessage &message); -
source/gui/CGUI.cpp
115 115 } 116 116 } 117 117 118 // Update m_MousePos (for delayed mouse button events) 119 CPos oldMousePos = m_MousePos; 120 if (ev->ev.type == SDL_MOUSEBUTTONDOWN || ev->ev.type == SDL_MOUSEBUTTONUP) 121 { 122 m_MousePos = CPos((float)ev->ev.button.x, (float)ev->ev.button.y); 123 } 124 125 // Only one object can be hovered 118 // Only one object can be active either because it's capturing input or because it's hovered. 119 // Capturing takes precedence. 120 IGUIObject *pActive = NULL; 126 121 IGUIObject *pNearest = NULL; 127 122 128 123 // TODO Gee: (2004-09-08) Big TODO, don't do the below if the SDL_Event is something like a keypress! … … 130 125 { 131 126 PROFILE( "mouse events" ); 132 127 // TODO Gee: Optimizations needed! 133 // th ese two recursive function arequite overhead heavy.128 // this recursive function is quite overhead heavy. 134 129 135 130 // pNearest will after this point at the hovered object, possibly NULL 136 131 pNearest = FindObjectUnderMouse(); 137 138 // Is placed in the UpdateMouseOver function139 //if (ev->ev.type == SDL_MOUSEMOTION && pNearest)140 // pNearest->ScriptEvent("mousemove");141 142 // Now we'll call UpdateMouseOver on *all* objects,143 // we'll input the one hovered, and they will each144 // update their own data and send messages accordingly145 132 146 GUI<IGUIObject*>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject, 147 &IGUIObject::UpdateMouseOver, 148 pNearest); 133 // If no GUIObject is capturing mouse input, the nearest one under the mouse(if any) becomes active 134 if(m_pCapturingGUIObject == NULL) 135 { 136 pActive = pNearest; 137 // Now we'll call UpdateMouseOver on *all* objects, 138 // we'll input the one hovered, and they will each 139 // update their own data and send messages accordingly 140 GUI<IGUIObject*>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject, 141 &IGUIObject::UpdateMouseOver, 142 pNearest); 143 } 144 else 145 { 146 pActive = m_pCapturingGUIObject; 147 // Capturing mouse input also means that ONLY the capturing object must receive MouseOver events 148 pActive->UpdateMouseOver(pNearest); 149 } 149 150 150 151 if (ev->ev.type == SDL_MOUSEBUTTONDOWN) 151 152 { … … 153 154 { 154 155 case SDL_BUTTON_LEFT: 155 156 // Focus the clicked object (or focus none if nothing clicked on) 156 SetFocusedObject(p Nearest);157 SetFocusedObject(pActive); 157 158 158 if (p Nearest)159 if (pActive) 159 160 { 160 ret = p Nearest->SendEvent(GUIM_MOUSE_PRESS_LEFT, "mouseleftpress");161 ret = pActive->SendEvent(GUIM_MOUSE_PRESS_LEFT, "mouseleftpress"); 161 162 } 162 163 break; 163 164 164 165 case SDL_BUTTON_RIGHT: 165 if (p Nearest)166 if (pActive) 166 167 { 167 ret = p Nearest->SendEvent(GUIM_MOUSE_PRESS_RIGHT, "mouserightpress");168 ret = pActive->SendEvent(GUIM_MOUSE_PRESS_RIGHT, "mouserightpress"); 168 169 } 169 170 break; 170 171 171 172 case SDL_BUTTON_WHEELDOWN: // wheel down 172 if (p Nearest)173 if (pActive) 173 174 { 174 ret = p Nearest->SendEvent(GUIM_MOUSE_WHEEL_DOWN, "mousewheeldown");175 ret = pActive->SendEvent(GUIM_MOUSE_WHEEL_DOWN, "mousewheeldown"); 175 176 } 176 177 break; 177 178 178 179 case SDL_BUTTON_WHEELUP: // wheel up 179 if (p Nearest)180 if (pActive) 180 181 { 181 ret = p Nearest->SendEvent(GUIM_MOUSE_WHEEL_UP, "mousewheelup");182 ret = pActive->SendEvent(GUIM_MOUSE_WHEEL_UP, "mousewheelup"); 182 183 } 183 184 break; 184 185 … … 192 193 switch (ev->ev.button.button) 193 194 { 194 195 case SDL_BUTTON_LEFT: 195 if (p Nearest)196 if (pActive) 196 197 { 197 double timeElapsed = timer_Time() - p Nearest->m_LastClickTime[SDL_BUTTON_LEFT];198 p Nearest->m_LastClickTime[SDL_BUTTON_LEFT] = timer_Time();199 198 double timeElapsed = timer_Time() - pActive->m_LastClickTime[SDL_BUTTON_LEFT]; 199 pActive->m_LastClickTime[SDL_BUTTON_LEFT] = timer_Time(); 200 200 201 //Double click? 201 202 if (timeElapsed < SELECT_DBLCLICK_RATE) 202 203 { 203 ret = p Nearest->SendEvent(GUIM_MOUSE_DBLCLICK_LEFT, "mouseleftdoubleclick");204 ret = pActive->SendEvent(GUIM_MOUSE_DBLCLICK_LEFT, "mouseleftdoubleclick"); 204 205 } 205 206 else 206 207 { 207 ret = p Nearest->SendEvent(GUIM_MOUSE_RELEASE_LEFT, "mouseleftrelease");208 ret = pActive->SendEvent(GUIM_MOUSE_RELEASE_LEFT, "mouseleftrelease"); 208 209 } 209 210 } 210 211 break; 211 212 case SDL_BUTTON_RIGHT: 212 if (p Nearest)213 if (pActive) 213 214 { 214 double timeElapsed = timer_Time() - p Nearest->m_LastClickTime[SDL_BUTTON_RIGHT];215 p Nearest->m_LastClickTime[SDL_BUTTON_RIGHT] = timer_Time();216 215 double timeElapsed = timer_Time() - pActive->m_LastClickTime[SDL_BUTTON_RIGHT]; 216 pActive->m_LastClickTime[SDL_BUTTON_RIGHT] = timer_Time(); 217 217 218 //Double click? 218 219 if (timeElapsed < SELECT_DBLCLICK_RATE) 219 220 { 220 ret = p Nearest->SendEvent(GUIM_MOUSE_DBLCLICK_RIGHT, "mouserightdoubleclick");221 ret = pActive->SendEvent(GUIM_MOUSE_DBLCLICK_RIGHT, "mouserightdoubleclick"); 221 222 } 222 223 else 223 224 { 224 ret = p Nearest->SendEvent(GUIM_MOUSE_RELEASE_RIGHT, "mouserightrelease");225 ret = pActive->SendEvent(GUIM_MOUSE_RELEASE_RIGHT, "mouserightrelease"); 225 226 } 226 227 } 227 228 break; 228 229 } 229 230 230 // Reset all states on all visible objects 231 GUI<>::RecurseObject(GUIRR_HIDDEN, m_BaseObject, 232 &IGUIObject::ResetStates); 231 } 233 232 234 // It will have reset the mouse over of the current hovered, so we'll235 // have to restore that236 if (pNearest)237 pNearest->m_MouseHovering = true;233 // Check if the active object is (still) capturing input 234 if(pActive && pActive->IsCapturing()) 235 { 236 m_pCapturingGUIObject = pActive; 238 237 } 238 else 239 { 240 m_pCapturingGUIObject = NULL; 241 } 239 242 } 240 243 catch (PSERROR_GUI& e) 241 244 { … … 261 264 } 262 265 } 263 266 264 // Restore m_MousePos (for delayed mouse button events)265 if (ev->ev.type == SDL_MOUSEBUTTONDOWN || ev->ev.type == SDL_MOUSEBUTTONUP)266 {267 m_MousePos = oldMousePos;268 }269 270 267 // Handle keys for input boxes 271 268 if (GetFocusedObject()) 272 269 { … … 382 379 NULL, NULL, NULL, NULL 383 380 }; 384 381 385 CGUI::CGUI() : m_MouseButtons(0), m_FocusedObject(NULL), m_ InternalNameNumber(0)382 CGUI::CGUI() : m_MouseButtons(0), m_FocusedObject(NULL), m_pCapturingGUIObject(NULL), m_InternalNameNumber(0) 386 383 { 387 384 m_BaseObject = new CGUIDummyObject; 388 385 m_BaseObject->SetGUI(this); … … 512 509 m_Icons.clear(); 513 510 } 514 511 512 void CGUI::SetInactive() 513 { 514 // This GUIObject won't reveive events anymore until it's active again. 515 // This means that e.g. buttons would keep showing tooltips until then. 516 // We reset the mouse-position and the mouse-states of all GUIObjects 517 // when leaving the GUIPage to avoid this. 518 m_MousePos = CPos(); 519 GUI<>::RecurseObject(GUIRR_HIDDEN, m_BaseObject, &IGUIObject::ResetMouseStates); 520 } 521 522 void CGUI::SetActive(CPos MousePos) 523 { 524 m_IsActive = true; 525 // The mouse position would be set correctly after the first mousemotion event. 526 // That's too late if e.g. the mouse is already on a button and the user clicks before moving it. 527 m_MousePos = MousePos; 528 } 529 515 530 void CGUI::UpdateResolution() 516 531 { 517 532 // Update ALL cached -
source/gui/IGUIObject.h
390 390 void SetParent(IGUIObject *pParent) { m_pParent = pParent; } 391 391 392 392 /** 393 * Reset internal state of this object 394 */ 395 virtual void ResetStates() 393 * Reset all internal states of this object which are related to the mouse. 394 * TODO: There are some edge-cases with keyboard-events also which are currently not handled. 395 */ 396 virtual void ResetMouseStates() 396 397 { 397 398 m_MouseHovering = false; 399 m_IsCapturing = false; 398 400 } 399 401 400 402 public: … … 456 458 InReaction SendEvent(EGUIMessageType type, const CStr& EventName); 457 459 458 460 /** 461 * Check if the object reqires the mouse input to be caputred. 462 * 463 * @return true if capturing, false if not 464 */ 465 virtual bool IsCapturing() { return m_IsCapturing; } 466 467 /** 459 468 * Execute the script for a particular action. 460 469 * Does nothing if no script has been registered for that action. 461 470 * The mouse coordinates will be passed as the first argument. … … 551 560 // Is mouse hovering the object? used with the function MouseOver() 552 561 bool m_MouseHovering; 553 562 563 // Is GUIObject is currently capturing mouse input? Used with the function IsCapturing() 564 bool m_IsCapturing; 565 554 566 /** 555 567 * Settings pool, all an object's settings are located here 556 568 * If a derived object has got more settings that the base -
source/gui/CCheckBox.h
64 64 virtual ~CCheckBox(); 65 65 66 66 /** 67 * @see IGUIObject#Reset States()67 * @see IGUIObject#ResetMouseStates() 68 68 */ 69 virtual void Reset States() { IGUIButtonBehavior::ResetStates(); }69 virtual void ResetMouseStates() { IGUIButtonBehavior::ResetMouseStates(); } 70 70 71 71 /** 72 72 * @see IGUIObject#HandleMessage() -
source/gui/MiniMap.h
39 39 40 40 // create the minimap textures 41 41 void CreateTextures(); 42 43 virtual void ResetMouseStates(); 42 44 43 45 // rebuild the terrain texture map 44 46 void RebuildTerrainTexture(); … … 57 59 58 60 //Whether or not the mouse is currently down 59 61 bool m_Clicking; 60 bool m_Hovering;61 62 62 63 // minimap texture handles 63 64 GLuint m_TerrainTexture; -
source/gui/IGUIScrollBar.h
146 146 * The class does not provide all functionality to the scroll-bar, many 147 147 * things the parent of the scroll-bar, must provide. Like a combo-box. 148 148 */ 149 class IGUIScrollBar 149 class IGUIScrollBar : virtual public IGUIObject 150 150 { 151 friend class IGUIScrollBarOwner; 152 151 153 public: 152 154 IGUIScrollBar(); 153 155 virtual ~IGUIScrollBar(); … … 330 332 * Call every time m_Pos has been updated. 331 333 */ 332 334 void UpdatePosBoundaries(); 335 336 /** 337 * Overload of the BaseClass IGUIObject 338 */ 339 virtual void ResetMouseStates(); 333 340 334 341 protected: 335 342 //@} -
source/gui/CInput.h
72 72 virtual ~CInput(); 73 73 74 74 /** 75 * @see IGUIObject#Reset States()75 * @see IGUIObject#ResetMouseStates() 76 76 */ 77 virtual void Reset States() { IGUIScrollBarOwner::ResetStates(); }77 virtual void ResetMouseStates() { IGUIScrollBarOwner::ResetMouseStates(); } 78 78 79 79 // Check where the mouse is hovering, and get the appropriate text position. 80 80 // return is the text-position index. -
source/gui/IGUIButtonBehavior.h
108 108 109 109 protected: 110 110 /** 111 * @see IGUIObject#Reset States()111 * @see IGUIObject#ResetMouseStates() 112 112 */ 113 virtual void ResetStates() 114 { 115 m_MouseHovering = false; 116 m_Pressed = false; 117 } 113 virtual void ResetMouseStates(); 118 114 119 115 /** 120 116 * Everybody knows how a button works, you don't simply press it, -
source/gui/GUIManager.cpp
72 72 73 73 void CGUIManager::PushPage(const CStrW& pageName, CScriptVal initData) 74 74 { 75 CPos MousePos; 76 if(m_PageStack.size() > 0) 77 { 78 // Get the mouse position from the last active page 79 MousePos = m_PageStack.back().gui->GetMousePos(); 80 m_PageStack.back().gui->SetInactive(); 81 } 82 75 83 m_PageStack.push_back(SGUIPage()); 76 84 m_PageStack.back().name = pageName; 77 85 m_PageStack.back().initData = CScriptValRooted(m_ScriptInterface.GetContext(), initData); 78 86 LoadPage(m_PageStack.back()); 87 m_PageStack.back().gui->SetActive(MousePos); 79 88 } 80 89 81 90 void CGUIManager::PopPage() … … 86 95 return; 87 96 } 88 97 98 // Get the mouse position from the last active page before removing it 99 CPos MousePos = m_PageStack.back().gui->GetMousePos(); 89 100 m_PageStack.pop_back(); 101 m_PageStack.back().gui->SetActive(MousePos); 90 102 } 91 103 92 104 void CGUIManager::DisplayMessageBox(int width, int height, const CStrW& title, const CStrW& message) -
source/gui/IGUIScrollBarOwner.h
60 60 */ 61 61 class IGUIScrollBarOwner : virtual public IGUIObject 62 62 { 63 friend class IGUIScrollBar;64 65 63 public: 66 64 IGUIScrollBarOwner(); 67 65 virtual ~IGUIScrollBarOwner(); … … 74 72 virtual void HandleMessage(SGUIMessage &Message); 75 73 76 74 /** 77 * @see IGUIObject#Reset States()75 * @see IGUIObject#ResetMouseStates() 78 76 */ 79 virtual void Reset States();77 virtual void ResetMouseStates(); 80 78 81 79 /** 82 80 * Interface for the m_ScrollBar to use. -
source/gui/GUIutil.cpp
277 277 278 278 void CInternalCGUIAccessorBase::QueryResetting(IGUIObject *pObject) 279 279 { 280 GUI<>::RecurseObject(0, pObject, &IGUIObject::Reset States);280 GUI<>::RecurseObject(0, pObject, &IGUIObject::ResetMouseStates); 281 281 } 282 282 283 283 void CInternalCGUIAccessorBase::HandleMessage(IGUIObject *pObject, SGUIMessage &message) -
source/gui/CButton.h
63 63 virtual ~CButton(); 64 64 65 65 /** 66 * @see IGUIObject#Reset States()66 * @see IGUIObject#ResetMouseStates() 67 67 */ 68 virtual void Reset States() { IGUIButtonBehavior::ResetStates(); }68 virtual void ResetMouseStates() { IGUIButtonBehavior::ResetMouseStates(); } 69 69 70 70 /** 71 71 * @see IGUIObject#HandleMessage() -
source/gui/IGUIObject.cpp
40 40 //------------------------------------------------------------------- 41 41 // Constructor / Destructor 42 42 //------------------------------------------------------------------- 43 IGUIObject::IGUIObject() : 44 m_pGUI(NULL), 43 IGUIObject::IGUIObject() : 44 m_pGUI(NULL), 45 45 m_pParent(NULL), 46 46 m_MouseHovering(false), 47 m_IsCapturing(false), 47 48 m_JSObject(NULL) 48 49 { 49 50 AddSetting(GUIST_bool, "enabled"); -
source/gui/MiniMap.cpp
28 28 #include "graphics/TerrainTextureEntry.h" 29 29 #include "graphics/TerrainTextureManager.h" 30 30 #include "graphics/TerritoryTexture.h" 31 #include "maths/Vector2D.h" 31 32 #include "lib/ogl.h" 32 33 #include "lib/external_libraries/sdl.h" 33 34 #include "lib/bits.h" … … 59 60 AddSetting(GUIST_CStrW, "tooltip"); 60 61 AddSetting(GUIST_CStr, "tooltip_style"); 61 62 m_Clicking = false; 62 m_Hovering = false;63 63 } 64 64 65 65 CMiniMap::~CMiniMap() … … 73 73 { 74 74 case GUIM_MOUSE_PRESS_LEFT: 75 75 { 76 if (m_ Hovering)76 if (m_MouseHovering) 77 77 { 78 78 SetCameraPos(); 79 79 m_Clicking = true; 80 m_IsCapturing = true; 80 81 } 81 82 break; 82 83 } 83 84 case GUIM_MOUSE_RELEASE_LEFT: 84 85 { 85 if(m_ Hovering && m_Clicking)86 if(m_MouseHovering && m_Clicking) 86 87 { 87 88 SetCameraPos(); 88 89 } 89 90 m_Clicking = false; 91 m_IsCapturing = false; 90 92 break; 91 93 } 92 94 case GUIM_MOUSE_DBLCLICK_LEFT: 93 95 { 94 if(m_ Hovering && m_Clicking)96 if(m_MouseHovering && m_Clicking) 95 97 { 96 98 SetCameraPos(); 97 99 } … … 100 102 } 101 103 case GUIM_MOUSE_ENTER: 102 104 { 103 m_ Hovering = true;105 m_MouseHovering = true; 104 106 break; 105 107 } 106 108 case GUIM_MOUSE_LEAVE: 107 109 { 108 m_Clicking = false; 109 m_Hovering = false; 110 m_MouseHovering = false; 110 111 break; 111 112 } 112 113 case GUIM_MOUSE_RELEASE_RIGHT: … … 121 122 } 122 123 case GUIM_MOUSE_MOTION: 123 124 { 124 if (m_ Hovering && m_Clicking)125 if (m_Clicking) 125 126 { 126 127 SetCameraPos(); 127 128 } … … 139 140 140 141 void CMiniMap::GetMouseWorldCoordinates(float& x, float& z) 141 142 { 142 // Determine X and Z according to proportion of mouse position and minimap143 144 143 CPos mousePos = GetMousePos(); 144 float MinimapRadius = m_CachedActualSize.GetWidth() / 2.0f; 145 CVector2D CornerToMouse; // Vector from the bottom left corner of the minimap to the mouse-position 146 CVector2D CenterToCorner; // Vector from the center to the bottom left corner or the minimap; 147 CVector2D CenterToMouse; // Vector from the center of the minimap to the mouse (will be clamped at the minimap bounds) 145 148 146 float px = (mousePos.x - m_CachedActualSize.left) / m_CachedActualSize.GetWidth(); 147 float py = (m_CachedActualSize.bottom - mousePos.y) / m_CachedActualSize.GetHeight(); 149 CornerToMouse.X = (mousePos.x - m_CachedActualSize.left); 150 CornerToMouse.Y = (m_CachedActualSize.bottom - mousePos.y); 151 CenterToCorner.X = CenterToCorner.Y = -MinimapRadius; 152 CenterToMouse = CornerToMouse + CenterToCorner; 148 153 154 // Clamp CenterToMouse at a length of the minimap radius 155 if(CenterToMouse.Length() > MinimapRadius) 156 { 157 float ShrinkFactor = MinimapRadius / CenterToMouse.Length(); 158 CenterToMouse.X = CenterToMouse.X * ShrinkFactor; 159 CenterToMouse.Y = CenterToMouse.Y * ShrinkFactor; 160 } 161 162 // Recalculate CenterToMouse using the other two vectors. 163 // It is now still pointing in the same direction (towards the mouse pointer), but clamped 164 CornerToMouse = (-CenterToCorner) + CenterToMouse; 165 166 // Determine X and Z according to proportion of mouse position and minimap 167 float px = CornerToMouse.X / m_CachedActualSize.GetWidth(); 168 float py = CornerToMouse.Y / m_CachedActualSize.GetHeight(); 149 169 float angle = GetAngle(); 150 170 151 171 // Scale world coordinates for shrunken square map … … 448 468 RebuildTerrainTexture(); 449 469 } 450 470 471 void CMiniMap::ResetMouseStates() 472 { 473 IGUIObject::ResetMouseStates(); 474 m_Clicking = false; 475 } 451 476 452 477 void CMiniMap::RebuildTerrainTexture() 453 478 { -
source/gui/CText.h
65 65 virtual ~CText(); 66 66 67 67 /** 68 * @see IGUIObject#Reset States()68 * @see IGUIObject#ResetMouseStates() 69 69 */ 70 virtual void Reset States() { IGUIScrollBarOwner::ResetStates(); }70 virtual void ResetMouseStates() { IGUIScrollBarOwner::ResetMouseStates(); } 71 71 72 72 /** 73 73 * Test if mouse position is over an icon -
source/gui/CGUI.h
167 167 * within the GUI. 168 168 */ 169 169 void Destroy(); 170 171 172 /** 173 * Sets if the GUI is on the currently active GUIPage. 174 */ 175 void SetInactive(); 176 177 /** 178 * Sets if the GUI is on the currently active GUIPage. 179 * 180 * @param MousePos Current position of the mouse 181 */ 182 void SetActive(CPos MousePos); 183 184 /** 185 * Some simply get-functions 186 */ 187 CPos GetMousePos() const { return m_MousePos; }; 188 bool IsActive() const {return m_IsActive; }; 189 170 190 171 191 /** 172 192 * The replacement of Process(), handles an SDL_Event_ … … 645 665 * as followed, the value will increment. 646 666 */ 647 667 int m_InternalNameNumber; 668 669 /** 670 * Value indicating if the GUI is on the currently active GUIPage. 671 */ 672 bool m_IsActive; 648 673 649 674 /** 650 675 * Function pointers to functions that constructs … … 677 702 678 703 // Icons 679 704 std::map<CStr, SGUIIcon> m_Icons; 705 706 // GUIObject capturing the mouse input 707 IGUIObject *m_pCapturingGUIObject; 680 708 }; 681 709 682 710 #endif -
source/graphics/Camera.cpp
308 308 309 309 // Clamp the water intersection to within the map's bounds, so that 310 310 // we'll always return a valid position on the map 311 ssize_t mapSize = g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide();312 if (gotWater)313 {314 waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)*CELL_SIZE));315 waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)*CELL_SIZE));316 }317 311 318 312 if (gotTerrain) 319 313 { -
binaries/data/mods/public/gui/pregame/mainmenu.js
14 14 15 15 // initialize currentSubmenuType with placeholder to avoid null when switching 16 16 currentSubmenuType = "submenuSinglePlayer"; 17 18 EnableUserReport(Engine.IsUserReportEnabled()); 17 19 } 18 20 19 21 var t0 = new Date; … … 140 142 141 143 if (Engine.IsUserReportEnabled()) 142 144 { 143 getGUIObjectByName("userReportDisabled").hidden = true; 144 getGUIObjectByName("userReportEnabled").hidden = false; 145 146 getGUIObjectByName("userReportEnabledText").caption = 147 userReportEnabledText.replace(/\$status/, 148 formatUserReportStatus(Engine.GetUserReportStatus())); 145 getGUIObjectByName("userReportEnabledText").caption = userReportEnabledText.replace(/\$status/, 146 formatUserReportStatus(Engine.GetUserReportStatus())); 149 147 } 150 else151 {152 getGUIObjectByName("userReportDisabled").hidden = false;153 getGUIObjectByName("userReportEnabled").hidden = true;154 }155 148 } 156 149 150 function EnableUserReport(Enabled) 151 { 152 getGUIObjectByName("userReportDisabled").hidden = Enabled; 153 getGUIObjectByName("userReportEnabled").hidden = !Enabled; 154 Engine.SetUserReportEnabled(Enabled); 155 } 157 156 157 158 158 /* 159 159 * MENU FUNCTIONS 160 160 */ -
binaries/data/mods/public/gui/pregame/mainmenu.xml
97 97 </object> 98 98 <object type="button" style="StoneButton" size="8 100%-36 146 100%-8"> 99 99 Enable feedback 100 <action on="Press">En gine.SetUserReportEnabled(true);</action>100 <action on="Press">EnableUserReport(true);</action> 101 101 </object> 102 102 <object type="button" style="StoneButton" size="100%-146 100%-36 100%-8 100%-8"> 103 103 Technical details … … 149 149 150 150 <object type="button" style="StoneButton" size="8 100%-36 146 100%-8"> 151 151 Disable feedback 152 <action on="Press">En gine.SetUserReportEnabled(false);</action>152 <action on="Press">EnableUserReport(false);</action> 153 153 </object> 154 154 <object type="button" style="StoneButton" size="100%-146 100%-36 100%-8 100%-8"> 155 155 Technical details