From db21f9ad7dfc61fe71ccbd2a3ee14942470d77f4 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Sat, 27 Jun 2020 15:24:29 -0700 Subject: [PATCH] Mouse click and rubber band now work in game. --- code/redalert/display.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/code/redalert/display.cpp b/code/redalert/display.cpp index 4d3e3a9..9392b04 100644 --- a/code/redalert/display.cpp +++ b/code/redalert/display.cpp @@ -3111,6 +3111,19 @@ int DisplayClass::TacticalClass::Action(unsigned flags, KeyNumType & key) x = Get_Mouse_X(); y = Get_Mouse_Y(); +// jmarshall + int tileX, tileY; + int screenX, screenY; + + screenX = x; + screenY = y; + if (!CellClass::ScreenCoordsToIsoTile(x, y, tileX, tileY)) { + return 0; + } + x = tileX * CELL_PIXEL_W; + y = tileY * CELL_PIXEL_H; +// jmarshall end + bool edge = (y == 0 || x == 0 || x == SeenBuff.Get_Width()-1 || y == SeenBuff.Get_Height()-1); COORDINATE coord = Map.Pixel_To_Coord(x, y); CELL cell = Coord_Cell(coord); @@ -3291,7 +3304,7 @@ int DisplayClass::TacticalClass::Action(unsigned flags, KeyNumType & key) */ if (!edge && (flags & LEFTPRESS)) { Map.Mouse_Left_Up(cell, shadow, object, action); - Map.Mouse_Left_Press(x, y); + Map.Mouse_Left_Press(screenX, screenY); } /* @@ -3300,7 +3313,7 @@ int DisplayClass::TacticalClass::Action(unsigned flags, KeyNumType & key) ** and flag the map to redraw it. */ if (flags & LEFTHELD) { - Map.Mouse_Left_Held(x, y); + Map.Mouse_Left_Held(screenX, screenY); } }