From 587f157c58fae93fa456c2c71fa741de8ac255f4 Mon Sep 17 00:00:00 2001 From: Ivan Mogilko Date: Thu, 11 Apr 2024 16:00:40 +0300 Subject: [PATCH] BASS: use Interact cursor mode instead of Walk --- BASS/Game.agf | 4 ++-- BASS/GlobalScript.asc | 10 +++++++++- BASS/TwoClickHandler.asc | 18 ++++++++++++++++++ BASS/TwoClickHandler.ash | 1 + 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/BASS/Game.agf b/BASS/Game.agf index aeff620..e491990 100644 --- a/BASS/Game.agf +++ b/BASS/Game.agf @@ -1960,7 +1960,7 @@ 0 0 0 - 2061 + 0 Walk to True 0 @@ -1986,7 +1986,7 @@ 0 0 2 - 0 + 2061 Interact True 0 diff --git a/BASS/GlobalScript.asc b/BASS/GlobalScript.asc index 7652a1d..aed8dbf 100644 --- a/BASS/GlobalScript.asc +++ b/BASS/GlobalScript.asc @@ -65,6 +65,12 @@ function game_start() // optionally reverse the left and right mouse buttons //TwoClickHandler.ReversedClicks = true; + + // The primary cursor mode in this template is Interact. + // When it's on, clicking on something will result either in Interact + // or Lookat action, depending on the mouse button pressed + // (see TwoClickHandler script for details). + TwoClickHandler.DefaultCursorMode = eModeInteract; // Auto-save on the save slot 999 SetRestartPoint(); @@ -78,7 +84,8 @@ function game_start() function open_gui(GUI* gui_to_open) { TwoClickHandler.Close(); - mouse.UseModeGraphic(eModeWalkto); + // Switch to the "pointer" cursor look temporarily, while gui is on + mouse.UseModeGraphic(eModePointer); gui_to_open.Visible = true; } @@ -86,6 +93,7 @@ function open_gui(GUI* gui_to_open) function close_gui(GUI *gui_to_close) { gui_to_close.Visible = false; + // Switch back to default cursor graphic mouse.UseDefaultGraphic(); } diff --git a/BASS/TwoClickHandler.asc b/BASS/TwoClickHandler.asc index db5ece9..e04f24c 100644 --- a/BASS/TwoClickHandler.asc +++ b/BASS/TwoClickHandler.asc @@ -1,6 +1,19 @@ +// default cursor mode to switch to when the previous one has to be cancelled +CursorMode defaultCursorMode; // label to use for text actions Label* action; +CursorMode set_DefaultCursorMode(static TwoClickHandler, CursorMode mode) +{ + defaultCursorMode = mode; + mouse.Mode = mode; +} + +CursorMode get_DefaultCursorMode(static TwoClickHandler) +{ + return defaultCursorMode; +} + void set_ActionLabel(static TwoClickHandler, Label* label) { action = label; @@ -142,6 +155,7 @@ function do_room_action(MouseButton button) { // right click to deselect inventory item player.ActiveInventory = null; + mouse.Mode = defaultCursorMode; } } } @@ -157,6 +171,7 @@ function do_room_action(MouseButton button) { // right click to deselect inventory item player.ActiveInventory = null; + mouse.Mode = defaultCursorMode; } } } @@ -187,6 +202,7 @@ function do_inventory_action(MouseButton button, InventoryItem* item) { // left click item on itself to deselect it player.ActiveInventory = null; + mouse.Mode = defaultCursorMode; } } else @@ -200,6 +216,7 @@ function do_inventory_action(MouseButton button, InventoryItem* item) { // right click to deselect inventory item player.ActiveInventory = null; + mouse.Mode = defaultCursorMode; } } } @@ -293,6 +310,7 @@ function on_event(EventType event, int data) else if (player.ActiveInventory != null) { player.ActiveInventory = null; + mouse.Mode = defaultCursorMode; } } } diff --git a/BASS/TwoClickHandler.ash b/BASS/TwoClickHandler.ash index 19cd5f8..7750a01 100644 --- a/BASS/TwoClickHandler.ash +++ b/BASS/TwoClickHandler.ash @@ -46,6 +46,7 @@ // pumpkins. struct TwoClickHandler { + import static attribute CursorMode DefaultCursorMode; import static attribute Label* ActionLabel; import static attribute GUI* InventoryGUI; import static attribute bool ReversedClicks;