Proper swap, generic mouse confinment and win

This commit is contained in:
Rendo 2025-12-12 16:49:20 +05:00
commit 5df5633c27
16 changed files with 136 additions and 96 deletions

20
gui/mouse_confiner.gd Normal file
View file

@ -0,0 +1,20 @@
extends Node
var global_mode: Input.MouseMode = Input.MouseMode.MOUSE_MODE_VISIBLE
var borrowed_visibiles: int = 0
func set_global_mode(to: Input.MouseMode) -> void:
global_mode = to
Input.mouse_mode = to
borrowed_visibiles = 0
func borrow() -> void:
borrowed_visibiles += 1
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func stop_borrow() -> void:
if borrowed_visibiles == 0:
return
borrowed_visibiles -= 1
if borrowed_visibiles == 0:
Input.mouse_mode = global_mode