Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dsrw committed Aug 23, 2024
1 parent a942e15 commit c38470e
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 29 deletions.
1 change: 1 addition & 0 deletions app/components/Console.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "  "
2 changes: 2 additions & 0 deletions app/components/Editor.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 )
15 changes: 15 additions & 0 deletions app/components/Settings.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "  "

Expand Down Expand Up @@ -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 = "  "

Expand Down Expand Up @@ -115,13 +117,15 @@ 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 "

[node name="Cancel" type="Button" parent="Window/MainContainer/RowContainer/NewLevelContainer/HBoxContainer/HBoxContainer"]
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"]
Expand All @@ -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"]
Expand All @@ -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
Expand All @@ -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"]
Expand Down Expand Up @@ -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 = " ↑ "

Expand All @@ -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 = " ↓ "

Expand Down Expand Up @@ -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 = " ↑ "

Expand All @@ -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 = " ↓ "

Expand Down Expand Up @@ -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 = " ↑ "

Expand All @@ -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 = " ↓ "

Expand All @@ -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 = " ✓ "
Expand Down Expand Up @@ -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 "

Expand Down
18 changes: 11 additions & 7 deletions app/scenes/GUI.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "  "

Expand Down
8 changes: 0 additions & 8 deletions app/scenes/MainViewport.gdns

This file was deleted.

4 changes: 1 addition & 3 deletions app/scenes/game.tscn
Original file line number Diff line number Diff line change
@@ -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 )
Expand All @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/enu.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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/[
Expand Down
5 changes: 4 additions & 1 deletion src/models/states.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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}
]
Expand Down
4 changes: 3 additions & 1 deletion src/nodes/player_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type
ConsoleFocused
DocsFocused
SettingsFocused
ViewportFocused
Playing
Flying
God
Expand Down
28 changes: 27 additions & 1 deletion src/ui/gui.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions src/ui/main_viewport.nim

This file was deleted.

2 changes: 2 additions & 0 deletions src/ui/right_panel.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c38470e

Please sign in to comment.