diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 36ab0ab94..a04d9aab0 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -159,6 +159,7 @@ GameView::GameView(): altBehaviour(false), showHud(true), showDebug(false), + delayedActiveMenu(0), wallBrush(false), toolBrush(false), decoBrush(false), @@ -482,7 +483,7 @@ public: void MouseEnterCallback(ui::Button * sender) { if(!needsClick && !v->GetMouseDown()) - v->c->SetActiveMenu(menuID); + v->SetActiveMenuDelayed(menuID); } void ActionCallback(ui::Button * sender) { @@ -1081,10 +1082,17 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy) } } mouseInZoom = newMouseInZoom; + + if (delayedActiveMenu) + { + c->SetActiveMenu(delayedActiveMenu); + delayedActiveMenu = 0; + } } void GameView::OnMouseDown(int x, int y, unsigned button) { + ui::Point mouseDownPoint = ui::Point(x, y); if (altBehaviour && !shiftBehaviour && !ctrlBehaviour) button = BUTTON_MIDDLE; if (!(zoomEnabled && !zoomCursorFixed)) @@ -1093,12 +1101,12 @@ void GameView::OnMouseDown(int x, int y, unsigned button) { if (button == BUTTON_LEFT && selectPoint1.X == -1) { - selectPoint1 = c->PointTranslate(ui::Point(x, y)); + selectPoint1 = c->PointTranslate(mouseDownPoint); selectPoint2 = selectPoint1; } return; } - if (currentMouse.X >= 0 && currentMouse.X < XRES && currentMouse.Y >= 0 && currentMouse.Y < YRES) + if (mouseDownPoint.X >= 0 && mouseDownPoint.X < XRES && mouseDownPoint.Y >= 0 && mouseDownPoint.Y < YRES) { if (button == BUTTON_LEFT) toolIndex = 0; @@ -1110,11 +1118,11 @@ void GameView::OnMouseDown(int x, int y, unsigned button) c->HistorySnapshot(); if (drawMode == DrawRect || drawMode == DrawLine) { - drawPoint1 = c->PointTranslate(ui::Point(x, y)); + drawPoint1 = c->PointTranslate(mouseDownPoint); } if (drawMode == DrawPoints) { - lastPoint = currentPoint = c->PointTranslate(ui::Point(x, y)); + lastPoint = currentPoint = c->PointTranslate(mouseDownPoint); c->DrawPoints(toolIndex, lastPoint, currentPoint, false); } } diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index 040292dd9..f7a9acef9 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -43,6 +43,7 @@ private: bool altBehaviour; bool showHud; bool showDebug; + int delayedActiveMenu; bool wallBrush; bool toolBrush; bool decoBrush; @@ -139,6 +140,7 @@ public: bool GetDebugHUD(); bool GetPlacingSave(); bool GetPlacingZoom(); + void SetActiveMenuDelayed(int activeMenu) { delayedActiveMenu = activeMenu; } bool CtrlBehaviour(){ return ctrlBehaviour; } bool ShiftBehaviour(){ return shiftBehaviour; } bool AltBehaviour(){ return altBehaviour; } diff --git a/src/gui/interface/Button.cpp b/src/gui/interface/Button.cpp index 60ea98a63..13b270780 100644 --- a/src/gui/interface/Button.cpp +++ b/src/gui/interface/Button.cpp @@ -83,19 +83,22 @@ void Button::Draw(const Point& screenPos) ui::Colour borderColour = Appearance.BorderInactive; ui::Colour backgroundColour = Appearance.BackgroundInactive; - if(Enabled) + if (Enabled) { - if(isButtonDown || (isTogglable && toggle)) + if (isMouseInside) { - textColour = Appearance.TextActive; - borderColour = Appearance.BorderActive; - backgroundColour = Appearance.BackgroundActive; - } - else if (isMouseInside) - { - textColour = Appearance.TextHover; - borderColour = Appearance.BorderHover; - backgroundColour = Appearance.BackgroundHover; + if (isButtonDown || (isTogglable && toggle)) + { + textColour = Appearance.TextActive; + borderColour = Appearance.BorderActive; + backgroundColour = Appearance.BackgroundActive; + } + else + { + textColour = Appearance.TextHover; + borderColour = Appearance.BorderHover; + backgroundColour = Appearance.BackgroundHover; + } } else { diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index cafd2efd2..3b36475ce 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -3217,12 +3217,19 @@ bool LuaScriptInterface::OnMouseDown(int x, int y, unsigned button) button = 4; luacon_mousedown = true; luacon_mousebutton = button; + luacon_mousex = x; + luacon_mousey = y; return luacon_mouseevent(x, y, button, LUACON_MDOWN, 0); } bool LuaScriptInterface::OnMouseUp(int x, int y, unsigned button, char type) { luacon_mousebutton = 0; + if (type != 1) + { + luacon_mousex = x; + luacon_mousey = y; + } if (button == 3) button = 4;