Skip to content

Commit

Permalink
Add Blur to the Main Menu and implement the rest of the UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Makosai committed Jan 1, 2024
1 parent d9648f3 commit 256f91a
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 7 deletions.
72 changes: 66 additions & 6 deletions scenes/main_menu/main_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ func _ready():
_prepare_sound()
pass

func play_game():
GameManager.current_ui = GameManager.UI_TYPES.PLAY
var err = get_tree().change_scene_to_packed(packed_scene_reia)

if err != Error.OK:
print("There was a problem loading the scene.")

func _prepare_background():
%Character.get_node("AnimationPlayer").play("IdleR")

Expand All @@ -24,12 +31,10 @@ func _prepare_sound():
### Main Functions
###
func _on_play_pressed():
GameManager.current_ui = GameManager.UI_TYPES.PLAY
var err = get_tree().change_scene_to_packed(packed_scene_reia)

if err != Error.OK:
print("There was a problem loading the scene.")

disable_all_roots()
%PlayChoice.show()
%Blur.show()


func _on_settings_pressed():
%Main.visible = false
Expand Down Expand Up @@ -63,6 +68,9 @@ func disable_all_roots():
%Settings.visible = false
%Controls.visible = false
%Volume.visible = false
%PlayChoice.visible = false
%OnlineForm.visible = false
%Blur.visible = false


func _on_master_volume_changed(value: float):
Expand Down Expand Up @@ -97,3 +105,55 @@ func update_volumes():
%DialogueVolume.value = SoundManager.get_dialogue_volume()
%DialogueVolumeLabel.text = volume_to_perc(SoundManager.get_dialogue_volume())


#region Play Choice
func _on_online_button_pressed():
disable_all_roots()
%OnlineForm.show()
%Blur.show()
(%PlayerName as TextEdit).grab_focus()

func _on_offline_button_pressed():
MultiplayerManager.instance.status = MultiplayerManager.Status.OFFLINE
play_game()

func _on_play_choice_back_button_pressed():
disable_all_roots()
%Main.show()
#endregion

#region Online Form
func _on_player_name_text_changed():
var final_text := ""
var player_name := %PlayerName as TextEdit

var regex = RegEx.new()
regex.compile("[a-zA-Z0-9 ]{0,20}")

var regex_match = regex.search_all(player_name.text)
if regex_match:
final_text = regex_match[0].get_string()

player_name.text = final_text
player_name.set_caret_column(player_name.text.length())
MultiplayerManager.instance.player_name = player_name.text

var cnb = (%ConfirmNameButton as Button)

if player_name.text.length() <= 0:
cnb.disabled = true
else:
cnb.disabled = false

func _on_confirm_name_button_pressed():
var player_name := (%PlayerName as TextEdit).text
if player_name.length() > 0 && player_name.length() <= 20:
MultiplayerManager.instance.player_name = player_name
MultiplayerManager.instance.status = MultiplayerManager.Status.CLIENT
play_game()

func _on_online_form_back_button_pressed():
disable_all_roots()
%PlayChoice.show()
%Blur.show()
#endregion
110 changes: 109 additions & 1 deletion scenes/main_menu/main_menu.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[gd_scene load_steps=10 format=3 uid="uid://cqxplnocmdh0f"]
[gd_scene load_steps=11 format=3 uid="uid://cqxplnocmdh0f"]

[ext_resource type="LightmapGIData" uid="uid://hhl6lqi7s8us" path="res://scenes/main_menu/main_menu.lmbake" id="1_28juw"]
[ext_resource type="Script" path="res://scenes/main_menu/main_menu.gd" id="1_3638y"]
[ext_resource type="Environment" uid="uid://my6k5ee2qus7" path="res://scenes/reia/reia_day.tres" id="2_ofhs3"]
[ext_resource type="AudioStream" uid="uid://bjmsfaw5a1nh5" path="res://assets/audio/menu/forest_theme_v1.wav" id="3_3o1dl"]
[ext_resource type="Shader" path="res://rsc/shaders/drop_shadow.gdshader" id="6_7rsuc"]
[ext_resource type="PackedScene" uid="uid://dsy7bxowv7qkc" path="res://rsc/interface/blur.tscn" id="6_f0shj"]
[ext_resource type="PackedScene" uid="uid://cykr5gmvdm7xf" path="res://assets/characters/player/female_player.glb" id="7_g5ofp"]
[ext_resource type="Texture2D" uid="uid://djunt32arj3g2" path="res://rsc/icons/logo_a_flat_white_68.svg" id="7_p8u4n"]
[ext_resource type="PackedScene" uid="uid://ci266clm01pqr" path="res://rsc/scenes/1_main_menu/changelog.tscn" id="9_haptq"]
Expand Down Expand Up @@ -111,6 +112,9 @@ omni_range = 10.0

[node name="UI" type="Node" parent="."]

[node name="Blur" parent="UI" instance=ExtResource("6_f0shj")]
unique_name_in_owner = true

[node name="Menu" type="Control" parent="UI"]
layout_mode = 3
anchors_preset = 15
Expand Down Expand Up @@ -142,6 +146,104 @@ grow_horizontal = 2
grow_vertical = 2
metadata/_edit_lock_ = true

[node name="PlayChoice" type="Control" parent="UI/Menu/Selectors"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="CenterContainer" type="CenterContainer" parent="UI/Menu/Selectors/PlayChoice"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="VBoxContainer" type="VBoxContainer" parent="UI/Menu/Selectors/PlayChoice/CenterContainer"]
layout_mode = 2
theme_override_constants/separation = 80

[node name="HBoxContainer" type="HBoxContainer" parent="UI/Menu/Selectors/PlayChoice/CenterContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 40

[node name="OnlineButton" type="Button" parent="UI/Menu/Selectors/PlayChoice/CenterContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
theme_type_variation = &"FlatWhiteButton"
theme_override_font_sizes/font_size = 40
text = "Multiplayer (Online)"

[node name="OfflineButton" type="Button" parent="UI/Menu/Selectors/PlayChoice/CenterContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
theme_type_variation = &"FlatWhiteButton"
theme_override_font_sizes/font_size = 40
text = "Singleplayer (Offline)"

[node name="PlayChoiceBackButton" type="Button" parent="UI/Menu/Selectors/PlayChoice/CenterContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
theme_type_variation = &"FlatWhiteButton"
theme_override_font_sizes/font_size = 40
text = "Back"

[node name="OnlineForm" type="Control" parent="UI/Menu/Selectors"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="CenterContainer" type="CenterContainer" parent="UI/Menu/Selectors/OnlineForm"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="VBoxContainer" type="VBoxContainer" parent="UI/Menu/Selectors/OnlineForm/CenterContainer"]
layout_mode = 2
theme_override_constants/separation = 20

[node name="Label" type="Label" parent="UI/Menu/Selectors/OnlineForm/CenterContainer/VBoxContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 32
text = "Enter a name to Play Online"

[node name="PlayerName" type="TextEdit" parent="UI/Menu/Selectors/OnlineForm/CenterContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
placeholder_text = "Player name"
scroll_smooth = true
scroll_fit_content_height = true

[node name="HBoxContainer" type="HBoxContainer" parent="UI/Menu/Selectors/OnlineForm/CenterContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 40

[node name="OnlineFormBackButton" type="Button" parent="UI/Menu/Selectors/OnlineForm/CenterContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 32
text = "Back"

[node name="ConfirmNameButton" type="Button" parent="UI/Menu/Selectors/OnlineForm/CenterContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 1.5
theme_override_font_sizes/font_size = 32
text = "Confirm"

[node name="Margins" type="MarginContainer" parent="UI/Menu/Selectors"]
layout_mode = 1
anchors_preset = 2
Expand Down Expand Up @@ -408,6 +510,12 @@ alignment = 0

[node name="Changelog" parent="UI" instance=ExtResource("9_haptq")]

[connection signal="pressed" from="UI/Menu/Selectors/PlayChoice/CenterContainer/VBoxContainer/HBoxContainer/OnlineButton" to="." method="_on_online_button_pressed"]
[connection signal="pressed" from="UI/Menu/Selectors/PlayChoice/CenterContainer/VBoxContainer/HBoxContainer/OfflineButton" to="." method="_on_offline_button_pressed"]
[connection signal="pressed" from="UI/Menu/Selectors/PlayChoice/CenterContainer/VBoxContainer/PlayChoiceBackButton" to="." method="_on_play_choice_back_button_pressed"]
[connection signal="text_changed" from="UI/Menu/Selectors/OnlineForm/CenterContainer/VBoxContainer/PlayerName" to="." method="_on_player_name_text_changed"]
[connection signal="pressed" from="UI/Menu/Selectors/OnlineForm/CenterContainer/VBoxContainer/HBoxContainer/OnlineFormBackButton" to="." method="_on_online_form_back_button_pressed"]
[connection signal="pressed" from="UI/Menu/Selectors/OnlineForm/CenterContainer/VBoxContainer/HBoxContainer/ConfirmNameButton" to="." method="_on_confirm_name_button_pressed"]
[connection signal="pressed" from="UI/Menu/Selectors/Margins/Main/Play" to="." method="_on_play_pressed"]
[connection signal="pressed" from="UI/Menu/Selectors/Margins/Main/Settings" to="." method="_on_settings_pressed"]
[connection signal="pressed" from="UI/Menu/Selectors/Margins/Main/Exit" to="." method="_on_exit_pressed"]
Expand Down

0 comments on commit 256f91a

Please sign in to comment.