diff --git a/app/components/Console.tscn b/app/components/Console.tscn index 69be1423..6abbc7ce 100644 --- a/app/components/Console.tscn +++ b/app/components/Console.tscn @@ -50,5 +50,6 @@ custom_constants/vseparation = 30 [node name="Close" type="Button" parent="GridContainer/MarginContainer/GridContainer"] margin_right = 40.0 margin_bottom = 28.0 +mouse_default_cursor_shape = 2 theme_type_variation = "IconButton" text = "  " diff --git a/app/components/Editor.tscn b/app/components/Editor.tscn index ab0b2b9a..4de0ee18 100644 --- a/app/components/Editor.tscn +++ b/app/components/Editor.tscn @@ -64,6 +64,7 @@ custom_constants/vseparation = 30 margin_right = 40.0 margin_bottom = 28.0 rect_pivot_offset = Vector2( 138, 238 ) +mouse_default_cursor_shape = 2 theme_type_variation = "IconButton" text = "  " script = ExtResource( 3 ) @@ -73,6 +74,7 @@ margin_top = 58.0 margin_right = 40.0 margin_bottom = 86.0 mouse_filter = 1 +mouse_default_cursor_shape = 2 theme_type_variation = "IconButton" text = "  " script = ExtResource( 3 ) diff --git a/app/components/Settings.tscn b/app/components/Settings.tscn index 416ce684..c8762548 100644 --- a/app/components/Settings.tscn +++ b/app/components/Settings.tscn @@ -35,6 +35,7 @@ text = " " margin_top = 25.0 margin_right = 46.0 margin_bottom = 62.0 +mouse_default_cursor_shape = 2 theme_type_variation = "IconButton" text = "  " @@ -72,6 +73,7 @@ alignment = 2 margin_left = 784.0 margin_right = 824.0 margin_bottom = 28.0 +mouse_default_cursor_shape = 2 theme_type_variation = "IconButton" text = "  " @@ -115,6 +117,7 @@ custom_constants/separation = 20 [node name="Save" type="Button" parent="Window/MainContainer/RowContainer/NewLevelContainer/HBoxContainer/HBoxContainer"] margin_right = 188.0 margin_bottom = 82.0 +mouse_default_cursor_shape = 2 size_flags_horizontal = 3 text = " Save " @@ -122,6 +125,7 @@ text = " Save " margin_left = 208.0 margin_right = 445.0 margin_bottom = 82.0 +mouse_default_cursor_shape = 2 text = " Cancel " [node name="Label" type="Label" parent="Window/MainContainer/RowContainer/NewLevelContainer"] @@ -146,6 +150,7 @@ margin_left = 180.0 margin_right = 397.0 margin_bottom = 37.0 focus_mode = 0 +mouse_default_cursor_shape = 2 enabled_focus_mode = 0 [node name="Label8" type="Label" parent="Window/MainContainer/RowContainer/SettingsContainer"] @@ -158,6 +163,7 @@ text = " Player Color" margin_left = 607.0 margin_right = 824.0 margin_bottom = 37.0 +mouse_default_cursor_shape = 2 [node name="Label4" type="Label" parent="Window/MainContainer/RowContainer/SettingsContainer"] margin_top = 63.0 @@ -170,6 +176,7 @@ margin_left = 180.0 margin_top = 62.0 margin_right = 397.0 margin_bottom = 101.0 +mouse_default_cursor_shape = 2 size_flags_horizontal = 3 [node name="Label3" type="Label" parent="Window/MainContainer/RowContainer/SettingsContainer"] @@ -201,6 +208,7 @@ margin_left = 99.0 margin_right = 148.0 margin_bottom = 39.0 focus_mode = 0 +mouse_default_cursor_shape = 2 theme_type_variation = "MonoButton" text = " ↑ " @@ -209,6 +217,7 @@ margin_left = 168.0 margin_right = 217.0 margin_bottom = 39.0 focus_mode = 0 +mouse_default_cursor_shape = 2 theme_type_variation = "MonoButton" text = " ↓ " @@ -240,6 +249,7 @@ margin_left = 99.0 margin_right = 148.0 margin_bottom = 39.0 focus_mode = 0 +mouse_default_cursor_shape = 2 theme_type_variation = "MonoButton" text = " ↑ " @@ -248,6 +258,7 @@ margin_left = 168.0 margin_right = 217.0 margin_bottom = 39.0 focus_mode = 0 +mouse_default_cursor_shape = 2 theme_type_variation = "MonoButton" text = " ↓ " @@ -280,6 +291,7 @@ margin_left = 99.0 margin_right = 148.0 margin_bottom = 39.0 focus_mode = 0 +mouse_default_cursor_shape = 2 theme_type_variation = "MonoButton" text = " ↑ " @@ -288,6 +300,7 @@ margin_left = 168.0 margin_right = 217.0 margin_bottom = 39.0 focus_mode = 0 +mouse_default_cursor_shape = 2 theme_type_variation = "MonoButton" text = " ↓ " @@ -303,6 +316,7 @@ margin_top = 190.0 margin_right = 229.0 margin_bottom = 227.0 focus_mode = 0 +mouse_default_cursor_shape = 2 size_flags_horizontal = 0 theme_type_variation = "MonoButton" text = " ✓ " @@ -379,6 +393,7 @@ margin_left = 422.0 margin_right = 676.0 margin_bottom = 39.0 focus_mode = 0 +mouse_default_cursor_shape = 2 size_flags_horizontal = 3 text = " Connect " diff --git a/app/scenes/GUI.tscn b/app/scenes/GUI.tscn index 07dde516..a2962146 100644 --- a/app/scenes/GUI.tscn +++ b/app/scenes/GUI.tscn @@ -169,36 +169,40 @@ margin_bottom = 1080.0 focus_mode = 2 custom_styles/bg = SubResource( 8 ) -[node name="GridContainer" type="GridContainer" parent="RightPanel"] +[node name="Overlay" type="GridContainer" parent="RightPanel"] margin_left = -2.0 margin_right = 959.0 margin_bottom = 1080.0 +mouse_filter = 2 theme = ExtResource( 6 ) columns = 2 -[node name="Label" type="Label" parent="RightPanel/GridContainer"] -margin_right = 887.0 +[node name="Label" type="Label" parent="RightPanel/Overlay"] +margin_right = 882.0 margin_bottom = 53.0 size_flags_horizontal = 3 size_flags_vertical = 1 -[node name="MarginContainer" type="MarginContainer" parent="RightPanel/GridContainer"] -margin_left = 891.0 +[node name="MarginContainer" type="MarginContainer" parent="RightPanel/Overlay"] +margin_left = 886.0 margin_right = 961.0 margin_bottom = 53.0 +mouse_filter = 2 custom_constants/margin_right = 35 custom_constants/margin_top = 25 -[node name="GridContainer" type="GridContainer" parent="RightPanel/GridContainer/MarginContainer"] +[node name="GridContainer" type="GridContainer" parent="RightPanel/Overlay/MarginContainer"] margin_top = 25.0 margin_right = 40.0 margin_bottom = 53.0 rect_pivot_offset = Vector2( -911, -78 ) +mouse_filter = 2 custom_constants/vseparation = 30 -[node name="Close" type="Button" parent="RightPanel/GridContainer/MarginContainer/GridContainer"] +[node name="Close" type="Button" parent="RightPanel/Overlay/MarginContainer/GridContainer"] margin_right = 40.0 margin_bottom = 28.0 +mouse_default_cursor_shape = 2 theme_type_variation = "IconButton" text = "  " diff --git a/app/scenes/MainViewport.gdns b/app/scenes/MainViewport.gdns deleted file mode 100644 index 951a1a0f..00000000 --- a/app/scenes/MainViewport.gdns +++ /dev/null @@ -1,8 +0,0 @@ -[gd_resource type="NativeScript" load_steps=2 format=2] - -[ext_resource path="res://nimlib.gdnlib" type="GDNativeLibrary" id=1] - -[resource] -resource_name = "MainViewport" -class_name = "MainViewport" -library = ExtResource( 1 ) diff --git a/app/scenes/game.tscn b/app/scenes/game.tscn index 73f3d299..f4f24941 100644 --- a/app/scenes/game.tscn +++ b/app/scenes/game.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://scenes/world.tscn" type="PackedScene" id=1] [ext_resource path="res://components/Game.gdns" type="Script" id=2] [ext_resource path="res://scenes/GUI.tscn" type="PackedScene" id=3] -[ext_resource path="res://scenes/MainViewport.gdns" type="Script" id=4] [node name="Game" type="Spatial"] script = ExtResource( 2 ) @@ -13,7 +12,6 @@ anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 2 stretch = true -script = ExtResource( 4 ) [node name="Viewport" type="Viewport" parent="ViewportContainer"] size = Vector2( 1920, 1080 ) diff --git a/src/enu.nim b/src/enu.nim index 8410c066..0760e9a6 100644 --- a/src/enu.nim +++ b/src/enu.nim @@ -6,7 +6,7 @@ import core, game import ui/[ editor, console, toolbar, action_button, preview_maker, markdown_label, - right_panel, settings, virtual_joystick, main_viewport, gui, floating_button + right_panel, settings, virtual_joystick, gui, floating_button ] import nodes/[ diff --git a/src/models/states.nim b/src/models/states.nim index 8293ddf3..6acfbf5c 100644 --- a/src/models/states.nim +++ b/src/models/states.nim @@ -11,7 +11,10 @@ log_scope: # only one flag from the group is active at a time const groups = @[ - {EditorFocused, ConsoleFocused, DocsFocused, SettingsFocused}, + { + EditorFocused, ConsoleFocused, DocsFocused, SettingsFocused, + ViewportFocused + }, {ReticleVisible, BlockTargetVisible}, {Playing, Flying} ] diff --git a/src/nodes/player_node.nim b/src/nodes/player_node.nim index f6cba218..8a2571de 100644 --- a/src/nodes/player_node.nim +++ b/src/nodes/player_node.nim @@ -294,7 +294,9 @@ gdobj PlayerNode of KinematicBody: self.aim_ray.translation + self.camera.project_ray_normal(mouse_pos) * ray_length - self.world_ray.cast_to = cast_to + self.world_ray.cast_to = + if ViewportFocused in state.local_flags: cast_to else: cast_from + self.world_ray.translation = cast_from self.aim_target.update(self.world_ray) else: diff --git a/src/types.nim b/src/types.nim index 62471014..1b50ab28 100644 --- a/src/types.nim +++ b/src/types.nim @@ -29,6 +29,7 @@ type ConsoleFocused DocsFocused SettingsFocused + ViewportFocused Playing Flying God diff --git a/src/ui/gui.nim b/src/ui/gui.nim index debe76f8..187d3ee2 100644 --- a/src/ui/gui.nim +++ b/src/ui/gui.nim @@ -2,10 +2,36 @@ import pkg/godot import godotapi/ [control, input_event_screen_touch, input_event_screen_drag, scene_tree] -import core +import core, nodes/player_node, gdutils gdobj GUI of Control: + method ready() = + self.bind_signals self, + "mouse_entered", "mouse_exited", "focus_entered", "focus_exited" + + method on_mouse_entered() = + state.push_flag ViewportFocused + + method on_mouse_exited() = + state.pop_flag ViewportFocused + + method on_focus_entered() = + state.push_flag ViewportFocused + + 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) diff --git a/src/ui/main_viewport.nim b/src/ui/main_viewport.nim deleted file mode 100644 index 7d967577..00000000 --- a/src/ui/main_viewport.nim +++ /dev/null @@ -1,7 +0,0 @@ -import pkg/godot -import godotapi/[viewport_container, input_event] -import core, nodes/player_node - -gdobj MainViewport of ViewportContainer: - method input*(event: InputEvent) = - (state.nodes.player as PlayerNode).viewport_input(event) diff --git a/src/ui/right_panel.nim b/src/ui/right_panel.nim index 140e18d9..307cb6c8 100644 --- a/src/ui/right_panel.nim +++ b/src/ui/right_panel.nim @@ -91,6 +91,8 @@ gdobj RightPanel of MarginContainer: self.ghost() elif CommandMode.removed: self.unghost() + find("Overlay", Control).set_mouse_filter_recursive(MOUSE_FILTER_IGNORE) + find("Close", Control).mouse_filter = MOUSE_FILTER_STOP method on_close() = state.open_sign = nil