Skip to content

Commit

Permalink
BASS: use Interact cursor mode instead of Walk
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Apr 14, 2024
1 parent 496c485 commit 587f157
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions BASS/Game.agf
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@
<HotspotX>0</HotspotX>
<HotspotY>0</HotspotY>
<ID>0</ID>
<Image>2061</Image>
<Image>0</Image>
<Name xml:space="preserve">Walk to</Name>
<StandardMode>True</StandardMode>
<View>0</View>
Expand All @@ -1986,7 +1986,7 @@
<HotspotX>0</HotspotX>
<HotspotY>0</HotspotY>
<ID>2</ID>
<Image>0</Image>
<Image>2061</Image>
<Name>Interact</Name>
<StandardMode>True</StandardMode>
<View>0</View>
Expand Down
10 changes: 9 additions & 1 deletion BASS/GlobalScript.asc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -78,14 +84,16 @@ 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;
}

// hide a GUI
function close_gui(GUI *gui_to_close)
{
gui_to_close.Visible = false;
// Switch back to default cursor graphic
mouse.UseDefaultGraphic();
}

Expand Down
18 changes: 18 additions & 0 deletions BASS/TwoClickHandler.asc
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -142,6 +155,7 @@ function do_room_action(MouseButton button)
{
// right click to deselect inventory item
player.ActiveInventory = null;
mouse.Mode = defaultCursorMode;
}
}
}
Expand All @@ -157,6 +171,7 @@ function do_room_action(MouseButton button)
{
// right click to deselect inventory item
player.ActiveInventory = null;
mouse.Mode = defaultCursorMode;
}
}
}
Expand Down Expand Up @@ -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
Expand All @@ -200,6 +216,7 @@ function do_inventory_action(MouseButton button, InventoryItem* item)
{
// right click to deselect inventory item
player.ActiveInventory = null;
mouse.Mode = defaultCursorMode;
}
}
}
Expand Down Expand Up @@ -293,6 +310,7 @@ function on_event(EventType event, int data)
else if (player.ActiveInventory != null)
{
player.ActiveInventory = null;
mouse.Mode = defaultCursorMode;
}
}
}
1 change: 1 addition & 0 deletions BASS/TwoClickHandler.ash
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 587f157

Please sign in to comment.