#5 REVERT ME ripping out skeleton of modal switching that was accidentally included in the wrong commit
This commit is contained in:
parent
43c9de575c
commit
fedec3def9
|
|
@ -303,66 +303,6 @@ func queue_for_stage(target: Object, index: int = 1):
|
|||
|
||||
#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
|
||||
|
||||
func get_room_id(if_game_active = false) -> Room.ids:
|
||||
|
|
|
|||
|
|
@ -210,8 +210,8 @@ func _on_controller_disconnect(_input_handle) -> void:
|
|||
State.last_input_source = State.InputSource.KEYBOARD_MOUSE
|
||||
|
||||
|
||||
func _on_set_change(new_context: State.GameContext) -> void:
|
||||
current_action_set = action_set_ids["game_control_actios"] if new_context == State.GameContext.WALK else action_set_ids["menu_control_actions"]
|
||||
func _on_set_change(new_context) -> void:
|
||||
current_action_set = action_set_ids["game_control_actios"] if new_context == 0 else action_set_ids["menu_control_actions"]
|
||||
|
||||
|
||||
func _preload_glyphs() -> void:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ func _ready() -> void:
|
|||
func _on_help_pressed() -> void:
|
||||
OS.shell_open("https://findahelpline.com/")
|
||||
|
||||
var last_mouse_mode: Input.MouseMode
|
||||
var last_mouse_mode
|
||||
func appear() -> void:
|
||||
if State.save_game:
|
||||
State.save_game.save_to_file(get_tree().root.get_texture())
|
||||
|
|
|
|||
Loading…
Reference in New Issue