Skip to content

Commit

Permalink
feat(gui): hide crosshair when menu is open & replace textedit by a l…
Browse files Browse the repository at this point in the history
…ineedit
  • Loading branch information
florianvazelle committed Aug 8, 2022
1 parent 950217e commit bcf194b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 25 deletions.
Binary file added assets/fonts/box_pixies.ttf
Binary file not shown.
58 changes: 34 additions & 24 deletions scenes/gui/menu.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]

[ext_resource path="res://scripts/gui/menu.gd" type="Script" id=1]
[ext_resource path="res://assets/gui/title.png" type="Texture" id=2]
[ext_resource path="res://assets/fonts/box_pixies.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://assets/sounds/ui_open.wav" type="AudioStream" id=3]
[ext_resource path="res://scripts/gui/description.gd" type="Script" id=4]

[sub_resource type="DynamicFont" id=1]
size = 35
font_data = ExtResource( 2 )

[node name="Menu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
Expand Down Expand Up @@ -34,32 +38,38 @@ margin_top = 16.0
margin_right = -16.0
margin_bottom = -16.0

[node name="TextureRect" type="TextureRect" parent="Panel/VBoxContainer"]
[node name="Label" type="Label" parent="Panel/VBoxContainer"]
margin_right = 368.0
margin_bottom = 50.0
rect_min_size = Vector2( 0, 50 )
texture = ExtResource( 2 )
expand = true
stretch_mode = 5
margin_bottom = 32.0
custom_fonts/font = SubResource( 1 )
text = "Marbles"
align = 1
uppercase = true

[node name="Input" type="TextEdit" parent="Panel/VBoxContainer"]
[node name="Spacer" type="Control" parent="Panel/VBoxContainer"]
margin_top = 36.0
margin_right = 368.0
margin_bottom = 44.0
rect_min_size = Vector2( 0, 8 )

[node name="Input" type="LineEdit" parent="Panel/VBoxContainer"]
unique_name_in_owner = true
margin_top = 54.0
margin_top = 48.0
margin_right = 368.0
margin_bottom = 86.0
rect_min_size = Vector2( 0, 32 )
margin_bottom = 72.0
placeholder_text = "Write one or more names separated by commas."

[node name="Spacer" type="Control" parent="Panel/VBoxContainer"]
margin_top = 90.0
[node name="Spacer2" type="Control" parent="Panel/VBoxContainer"]
margin_top = 76.0
margin_right = 368.0
margin_bottom = 98.0
margin_bottom = 84.0
rect_min_size = Vector2( 0, 8 )

[node name="StartButton" type="Button" parent="Panel/VBoxContainer"]
unique_name_in_owner = true
margin_top = 102.0
margin_top = 88.0
margin_right = 368.0
margin_bottom = 134.0
margin_bottom = 120.0
rect_min_size = Vector2( 0, 32 )
text = "Start"

Expand All @@ -83,23 +93,23 @@ text = "Restart"

[node name="QuitButton" type="Button" parent="Panel/VBoxContainer"]
unique_name_in_owner = true
margin_top = 138.0
margin_top = 124.0
margin_right = 368.0
margin_bottom = 170.0
margin_bottom = 156.0
rect_min_size = Vector2( 0, 32 )
text = "Quit"

[node name="Spacer2" type="Control" parent="Panel/VBoxContainer"]
margin_top = 174.0
[node name="Spacer3" type="Control" parent="Panel/VBoxContainer"]
margin_top = 160.0
margin_right = 368.0
margin_bottom = 182.0
margin_bottom = 168.0
rect_min_size = Vector2( 0, 8 )

[node name="Description" type="Label" parent="Panel/VBoxContainer"]
self_modulate = Color( 0.47451, 0.47451, 0.47451, 1 )
margin_top = 186.0
margin_top = 172.0
margin_right = 368.0
margin_bottom = 200.0
margin_bottom = 186.0
text = "Mechanical Flower"
align = 1
script = ExtResource( 4 )
Expand Down
2 changes: 2 additions & 0 deletions scenes/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 5.23546
shadow_enabled = true

[node name="CrosshairContainer" type="CenterContainer" parent="."]
unique_name_in_owner = true
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
Expand Down
2 changes: 1 addition & 1 deletion scripts/gui/menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var _mode: int = State.MODE_START
var _last_action: int = Action.ACTION_NOOP

onready var _open_sound := get_node("%OpenSound") as AudioStreamPlayer
onready var _input := get_node("%Input") as TextEdit
onready var _input := get_node("%Input") as LineEdit
onready var _start_button := get_node("%StartButton") as Button
onready var _resume_button := get_node("%ResumeButton") as Button
onready var _restart_button := get_node("%RestartButton") as Button
Expand Down
5 changes: 5 additions & 0 deletions scripts/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var _time := 0.0
onready var _player_spawn := get_node("%PlayerSpawn") as Spatial
onready var _pause_menu := get_node("%Menu") as Control
onready var _race := get_node("%Race") as Spatial
onready var _crosshair := get_node("%CrosshairContainer") as CenterContainer


func _ready() -> void:
Expand Down Expand Up @@ -141,11 +142,13 @@ func set_mode(mode, target_marble = null):

if _mode == State.MODE_FOCUS:
print("Switch to focus mode")
_crosshair.hide()
replace_camera(_focus_camera, [_fly_camera, _rotation_camera])
_focus_camera.set_target(target_marble)

elif _mode == State.MODE_MARBLE:
print("Switch to marble mode")
_crosshair.show()
# If no marbles exists, create one for each name
if marble_count == 0:
for name in _pause_menu.get_names():
Expand All @@ -156,11 +159,13 @@ func set_mode(mode, target_marble = null):
elif _mode == State.MODE_START:
print("Switch to pause mode")
_pause_menu.open_start_menu()
_crosshair.hide()
replace_camera(_rotation_camera, [_focus_camera, _fly_camera])

elif _mode == State.MODE_PAUSE:
print("Switch to pause mode")
_pause_menu.open_pause_menu()
_crosshair.hide()
replace_camera(_rotation_camera, [_focus_camera, _fly_camera])


Expand Down

0 comments on commit bcf194b

Please sign in to comment.