#5 REVERT ME ripping out skeleton of modal switching that was accidentally included in the wrong commit

This commit is contained in:
betalars 2026-06-03 14:56:24 +02:00
parent 43c9de575c
commit 2a53e4be5a
2 changed files with 2 additions and 62 deletions

View File

@ -303,66 +303,6 @@ func queue_for_stage(target: Object, index: int = 1):
#endregion #endregion
#region input set handling
func _input(event: InputEvent) -> void:
if event is InputEventKey or event is InputEventMouse or event is InputEventMouseMotion or event is InputEventScreenTouch:
last_input_source = InputSource.KEYBOARD_MOUSE
if event is InputEventJoypadButton or event is InputEventJoypadMotion:
last_input_source = InputSource.JOYPAD
signal game_context_updated(new: GameContext)
signal input_device_updated(new: InputSource)
enum InputSource {
INVALID = -1,
KEYBOARD_MOUSE,
JOYPAD
}
var last_input_source : InputSource = InputSource.INVALID:
set(new_source):
if new_source != last_input_source:
if new_source == InputSource.KEYBOARD_MOUSE:
_awaiting_mouse_input = false
_update_mouse_mode()
else:
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
last_input_source = new_source
input_device_updated.emit(new_source)
enum GameContext {
## Player moves about in the world.
WALK,
## Player interacts with a menu.
MENU,
## Player is in a special menu, but has not moved their mouse yet. Is never set to [current_context], but changes behavior of [update_mouse_mode].
LISTEN
}
var current_context: GameContext = GameContext.MENU:
set(new_context):
if new_context != current_context:
if new_context == GameContext.WALK:
current_context = GameContext.WALK
else:
current_context = GameContext.MENU
_awaiting_mouse_input = new_context == GameContext.LISTEN
if last_input_source == InputSource.KEYBOARD_MOUSE:
_update_mouse_mode()
game_context_updated.emit()
var _awaiting_mouse_input: bool = false
func _update_mouse_mode():
if current_context == GameContext.WALK:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
elif _awaiting_mouse_input:
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
#endregion
#region utility functions #region utility functions
func get_room_id(if_game_active = false) -> Room.ids: func get_room_id(if_game_active = false) -> Room.ids:

View File

@ -210,8 +210,8 @@ func _on_controller_disconnect(_input_handle) -> void:
State.last_input_source = State.InputSource.KEYBOARD_MOUSE State.last_input_source = State.InputSource.KEYBOARD_MOUSE
func _on_set_change(new_context: State.GameContext) -> void: func _on_set_change(new_context) -> void:
current_action_set = action_set_ids["game_control_actios"] if new_context == State.GameContext.WALK else action_set_ids["menu_control_actions"] current_action_set = action_set_ids["game_control_actios"] if new_context == 0 else action_set_ids["menu_control_actions"]
func _preload_glyphs() -> void: func _preload_glyphs() -> void: