Permalink
Browse files

more tptmp mouse fixes, fix buttons and menusection buttons staying h…

…ighlighted sometimes
  • Loading branch information...
jacob1 committed Sep 22, 2015
1 parent f230ac8 commit 13a71b611aad717ecefa5c5b5b4e19445cc9e027
Showing with 36 additions and 16 deletions.
  1. +13 −5 src/gui/game/GameView.cpp
  2. +2 −0 src/gui/game/GameView.h
  3. +14 −11 src/gui/interface/Button.cpp
  4. +7 −0 src/lua/LuaScriptInterface.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 @@ class GameView::MenuAction: public ui::ButtonAction
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);
}
}
@@ -43,6 +43,7 @@ class GameView: public ui::Window
bool altBehaviour;
bool showHud;
bool showDebug;
int delayedActiveMenu;
bool wallBrush;
bool toolBrush;
bool decoBrush;
@@ -139,6 +140,7 @@ class GameView: public ui::Window
bool GetDebugHUD();
bool GetPlacingSave();
bool GetPlacingZoom();
void SetActiveMenuDelayed(int activeMenu) { delayedActiveMenu = activeMenu; }
bool CtrlBehaviour(){ return ctrlBehaviour; }
bool ShiftBehaviour(){ return shiftBehaviour; }
bool AltBehaviour(){ return altBehaviour; }
@@ -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
{
@@ -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;

0 comments on commit 13a71b6

Please sign in to comment.