diff --git a/app/scenes/GUI.tscn b/app/scenes/GUI.tscn index 73ae1de7..260e2076 100644 --- a/app/scenes/GUI.tscn +++ b/app/scenes/GUI.tscn @@ -253,6 +253,7 @@ __meta__ = { } [node name="LeftStick" parent="." instance=ExtResource( 13 )] +visible = false anchor_left = 0.12 anchor_top = 0.7 anchor_right = 0.12 @@ -262,5 +263,6 @@ margin_top = 0.0 margin_right = 0.0 margin_bottom = 0.0 rect_min_size = Vector2( 200, 200 ) +visibility_mode = 0 [editable path="GridContainer/Settings"] diff --git a/src/ui/editor.nim b/src/ui/editor.nim index e8d80656..9dac345b 100644 --- a/src/ui/editor.nim +++ b/src/ui/editor.nim @@ -92,7 +92,9 @@ gdobj Editor of MarginContainer: self.touch_timer = get_mono_time() + 0.5.seconds else: self.touch_timer = MonoTime.high - elif event of InputEventScreenDrag and self.scroll_state == Idle: + elif EditorVisible in state.local_flags and + CommandMode notin state.local_flags and event of InputEventScreenDrag and + self.scroll_state == Idle: self.get_tree.set_input_as_handled() method unhandled_input*(event: InputEvent) = diff --git a/src/ui/gui.nim b/src/ui/gui.nim index 187d3ee2..e4f0b3b7 100644 --- a/src/ui/gui.nim +++ b/src/ui/gui.nim @@ -5,9 +5,13 @@ import import core, nodes/player_node, gdutils gdobj GUI of Control: + var left_stick: Control method ready() = self.bind_signals self, "mouse_entered", "mouse_exited", "focus_entered", "focus_exited" + self.left_stick = find("LeftStick", Control) + state.local_flags.changes: + self.left_stick.visible = TouchControls in state.local_flags method on_mouse_entered() = state.push_flag ViewportFocused @@ -21,17 +25,7 @@ gdobj GUI of Control: method on_focus_exited() = state.pop_flag ViewportFocused - method gui_input(event: InputEvent) = - (state.nodes.player as PlayerNode).viewport_input(event) - self.accept_event() - method input(event: InputEvent) = - if host_os == "ios": - (state.nodes.player as PlayerNode).viewport_input(event) - else: - if event of InputEventKey: - (state.nodes.player as PlayerNode).viewport_input(event) - if event of InputEventScreenTouch: let event = event as InputEventScreenTouch let index = byte(event.index) @@ -44,3 +38,10 @@ gdobj GUI of Control: let index = byte(event.index) if index in state.ignored_touches: self.get_tree().set_input_as_handled() + return + + if TouchControls in state.local_flags: + (state.nodes.player as PlayerNode).viewport_input(event) + else: + if event of InputEventKey: + (state.nodes.player as PlayerNode).viewport_input(event)