more tptmp mouse fixes, fix buttons and menusection buttons staying highlighted sometimes

This commit is contained in:
jacob1 2015-09-22 19:59:31 -04:00
parent f230ac8945
commit 13a71b611a
4 changed files with 36 additions and 16 deletions

View File

@ -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);
}
}

View File

@ -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; }

View File

@ -83,20 +83,23 @@ 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)
{
if (isButtonDown || (isTogglable && toggle))
{
textColour = Appearance.TextActive;
borderColour = Appearance.BorderActive;
backgroundColour = Appearance.BackgroundActive;
}
else if (isMouseInside)
else
{
textColour = Appearance.TextHover;
borderColour = Appearance.BorderHover;
backgroundColour = Appearance.BackgroundHover;
}
}
else
{
textColour = Appearance.TextInactive;

View File

@ -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;