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), altBehaviour(false),
showHud(true), showHud(true),
showDebug(false), showDebug(false),
delayedActiveMenu(0),
wallBrush(false), wallBrush(false),
toolBrush(false), toolBrush(false),
decoBrush(false), decoBrush(false),
@ -482,7 +483,7 @@ public:
void MouseEnterCallback(ui::Button * sender) void MouseEnterCallback(ui::Button * sender)
{ {
if(!needsClick && !v->GetMouseDown()) if(!needsClick && !v->GetMouseDown())
v->c->SetActiveMenu(menuID); v->SetActiveMenuDelayed(menuID);
} }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
@ -1081,10 +1082,17 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
} }
} }
mouseInZoom = newMouseInZoom; mouseInZoom = newMouseInZoom;
if (delayedActiveMenu)
{
c->SetActiveMenu(delayedActiveMenu);
delayedActiveMenu = 0;
}
} }
void GameView::OnMouseDown(int x, int y, unsigned button) void GameView::OnMouseDown(int x, int y, unsigned button)
{ {
ui::Point mouseDownPoint = ui::Point(x, y);
if (altBehaviour && !shiftBehaviour && !ctrlBehaviour) if (altBehaviour && !shiftBehaviour && !ctrlBehaviour)
button = BUTTON_MIDDLE; button = BUTTON_MIDDLE;
if (!(zoomEnabled && !zoomCursorFixed)) if (!(zoomEnabled && !zoomCursorFixed))
@ -1093,12 +1101,12 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
{ {
if (button == BUTTON_LEFT && selectPoint1.X == -1) if (button == BUTTON_LEFT && selectPoint1.X == -1)
{ {
selectPoint1 = c->PointTranslate(ui::Point(x, y)); selectPoint1 = c->PointTranslate(mouseDownPoint);
selectPoint2 = selectPoint1; selectPoint2 = selectPoint1;
} }
return; 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) if (button == BUTTON_LEFT)
toolIndex = 0; toolIndex = 0;
@ -1110,11 +1118,11 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
c->HistorySnapshot(); c->HistorySnapshot();
if (drawMode == DrawRect || drawMode == DrawLine) if (drawMode == DrawRect || drawMode == DrawLine)
{ {
drawPoint1 = c->PointTranslate(ui::Point(x, y)); drawPoint1 = c->PointTranslate(mouseDownPoint);
} }
if (drawMode == DrawPoints) if (drawMode == DrawPoints)
{ {
lastPoint = currentPoint = c->PointTranslate(ui::Point(x, y)); lastPoint = currentPoint = c->PointTranslate(mouseDownPoint);
c->DrawPoints(toolIndex, lastPoint, currentPoint, false); c->DrawPoints(toolIndex, lastPoint, currentPoint, false);
} }
} }

View File

@ -43,6 +43,7 @@ private:
bool altBehaviour; bool altBehaviour;
bool showHud; bool showHud;
bool showDebug; bool showDebug;
int delayedActiveMenu;
bool wallBrush; bool wallBrush;
bool toolBrush; bool toolBrush;
bool decoBrush; bool decoBrush;
@ -139,6 +140,7 @@ public:
bool GetDebugHUD(); bool GetDebugHUD();
bool GetPlacingSave(); bool GetPlacingSave();
bool GetPlacingZoom(); bool GetPlacingZoom();
void SetActiveMenuDelayed(int activeMenu) { delayedActiveMenu = activeMenu; }
bool CtrlBehaviour(){ return ctrlBehaviour; } bool CtrlBehaviour(){ return ctrlBehaviour; }
bool ShiftBehaviour(){ return shiftBehaviour; } bool ShiftBehaviour(){ return shiftBehaviour; }
bool AltBehaviour(){ return altBehaviour; } bool AltBehaviour(){ return altBehaviour; }

View File

@ -83,19 +83,22 @@ void Button::Draw(const Point& screenPos)
ui::Colour borderColour = Appearance.BorderInactive; ui::Colour borderColour = Appearance.BorderInactive;
ui::Colour backgroundColour = Appearance.BackgroundInactive; ui::Colour backgroundColour = Appearance.BackgroundInactive;
if(Enabled) if (Enabled)
{ {
if(isButtonDown || (isTogglable && toggle)) if (isMouseInside)
{ {
textColour = Appearance.TextActive; if (isButtonDown || (isTogglable && toggle))
borderColour = Appearance.BorderActive; {
backgroundColour = Appearance.BackgroundActive; textColour = Appearance.TextActive;
} borderColour = Appearance.BorderActive;
else if (isMouseInside) backgroundColour = Appearance.BackgroundActive;
{ }
textColour = Appearance.TextHover; else
borderColour = Appearance.BorderHover; {
backgroundColour = Appearance.BackgroundHover; textColour = Appearance.TextHover;
borderColour = Appearance.BorderHover;
backgroundColour = Appearance.BackgroundHover;
}
} }
else else
{ {

View File

@ -3217,12 +3217,19 @@ bool LuaScriptInterface::OnMouseDown(int x, int y, unsigned button)
button = 4; button = 4;
luacon_mousedown = true; luacon_mousedown = true;
luacon_mousebutton = button; luacon_mousebutton = button;
luacon_mousex = x;
luacon_mousey = y;
return luacon_mouseevent(x, y, button, LUACON_MDOWN, 0); return luacon_mouseevent(x, y, button, LUACON_MDOWN, 0);
} }
bool LuaScriptInterface::OnMouseUp(int x, int y, unsigned button, char type) bool LuaScriptInterface::OnMouseUp(int x, int y, unsigned button, char type)
{ {
luacon_mousebutton = 0; luacon_mousebutton = 0;
if (type != 1)
{
luacon_mousex = x;
luacon_mousey = y;
}
if (button == 3) if (button == 3)
button = 4; button = 4;