Auroriax / PuzzleScriptPlus

Puzzlescript Plus: Open Source HTML5 Puzzle Game Engine (with lots of extra functionality)
https://auroriax.github.io/PuzzleScript/
34 stars 4 forks source link

Mouse: guaranteed down/drag/up order, hover, canvas leave detection #55

Open Auroriax opened 1 year ago

Auroriax commented 1 year ago

A number of options:

Hover should probably be straightforward to implement and explain.

Auroriax commented 1 year ago

(If there are multiple events triggered, they're resolved in this order)

mouse_up (L/R) - Triggered when button is released (inside or outside canvas, when outside canvas on the last hovered tile) or other mouse button press triggers.

mouse_down - Mouse click INSIDE canvas

mouse_hover - When mouse moves to a different tile INSIDE canvas. ONLY when no other buttons are held or released this turn. Doesn't work on mobile.

mouse_focus - Cursor moved into a different tile tile INSIDE canvas. Similar to mouse_hover except that it doesn't matter if the mouse is currently dragging (triggers for both L/R buttons), or not dragging at all. Only works on mobile when the mouse is down.

mouse_drag (L/R) - Only if the respective cursor is down, INSIDE or OUTSIDE (along border) different tile on the canvas, if there's more than one tile between last and current drag position, automatically trigger movement for each tile.

TODO:

click -> onlyTriggerWhenCursorIsInsideCanvas AlwaysAllow, OnlyInsideCanvas, ResolveAsPath, drag / click / release

Auroriax commented 1 year ago

The core problem is that mouse controls are inconsistent. Ideally I'd like there to be a guaranteed press/drag/release order, but in reality there are a lot of edge cases (both mouse buttons pressed, held mouse moving onto canvas, using CTRL to get right click behavior, etc). As for leaving the canvas, there should probably be a prelude flag so that the old behavior is still the default one, so that old games don't break.