From 03b5771e8f629622ef0428f1858b7a9ca5c47091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0imek?= Date: Mon, 23 May 2022 12:24:05 -0700 Subject: [PATCH 1/2] Fix mouse clicking around interface if IFACE_BAR_MODE is enabled (#12) See #3 --- src/game_mouse.cc | 19 +++++++++++++++++-- src/game_mouse.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/game_mouse.cc b/src/game_mouse.cc index f62fb21..053c456 100644 --- a/src/game_mouse.cc +++ b/src/game_mouse.cc @@ -831,6 +831,22 @@ void gameMouseRefresh() } } +bool gameMouseClickOnInterfaceBar() +{ + Rect interfaceBarWindowRect; + windowGetRect(gInterfaceBarWindow, &interfaceBarWindowRect); + + int interfaceBarWindowRectLeft = 0; + int interfaceBarWindowRectRight = _scr_size.right; + + if (gInterfaceBarMode) { + interfaceBarWindowRectLeft = interfaceBarWindowRect.left; + interfaceBarWindowRectRight = interfaceBarWindowRect.right; + } + + return _mouse_click_in(interfaceBarWindowRectLeft, interfaceBarWindowRect.top, interfaceBarWindowRectRight, interfaceBarWindowRect.bottom); +} + // 0x44BFA8 void _gmouse_handle_event(int mouseX, int mouseY, int mouseState) { @@ -852,8 +868,7 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState) } } - // TODO: allow clicking to the left and right of the INTERFACE_BAR if gInterfaceBarMode is enabled - if (!_mouse_click_in(0, 0, _scr_size.right - _scr_size.left, _scr_size.bottom - _scr_size.top - INTERFACE_BAR_HEIGHT)) { + if (gameMouseClickOnInterfaceBar()) { return; } diff --git a/src/game_mouse.h b/src/game_mouse.h index 5c70a19..2f68658 100644 --- a/src/game_mouse.h +++ b/src/game_mouse.h @@ -186,5 +186,6 @@ int _gmouse_3d_move_to(int x, int y, int elevation, Rect* a4); int gameMouseHandleScrolling(int x, int y, int cursor); void _gmouse_remove_item_outline(Object* object); int objectIsDoor(Object* object); +bool gameMouseClickOnInterfaceBar(); #endif /* GAME_MOUSE_H */ From 2d54e41fdbdfa7ff678bb133b4e0dac8e524d3fa Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Mon, 23 May 2022 22:41:54 +0300 Subject: [PATCH 2/2] Fix tile border calculation See #9 --- src/tile.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tile.cc b/src/tile.cc index b07e749..5a22307 100644 --- a/src/tile.cc +++ b/src/tile.cc @@ -401,8 +401,12 @@ int tileInit(TileData** a1, int squareGridWidth, int squareGridHeight, int hexGr // 0x4B11E4 void _tile_set_border(int windowWidth, int windowHeight, int hexGridWidth, int hexGridHeight) { + // TODO: Borders, scroll blockers and tile system overall were designed + // with 640x480 in mind, so using windowWidth and windowHeight is + // meaningless for calculating borders. For now keep borders for original + // resolution. int v1 = tileFromScreenXY(-320, -240, 0); - int v2 = tileFromScreenXY(-320, windowHeight + 240, 0); + int v2 = tileFromScreenXY(-320, ORIGINAL_ISO_WINDOW_HEIGHT + 240, 0); _tile_border = abs(hexGridWidth - 1 - v2 % hexGridWidth - _tile_x) + 6; dword_66BBC8 = abs(_tile_y - v1 / hexGridWidth) + 7;