fixed some bugs The Typening caused
This commit is contained in:
74
Scenes/Menus/MainMenu/main_menu.gd
Normal file
74
Scenes/Menus/MainMenu/main_menu.gd
Normal file
@ -0,0 +1,74 @@
|
||||
class_name MainMenu extends Control
|
||||
|
||||
@export var bg_level: Level
|
||||
|
||||
var confirmation_popup_scene: PackedScene = preload("res://Scenes/Menus/confirmation_popup.tscn")
|
||||
var text_input_popup_scene: PackedScene = preload("res://Scenes/Menus/text_input_popup.tscn")
|
||||
var multiplayer_lobby_scene_path: String = "res://Scenes/multiplayer_lobby.tscn"
|
||||
var options_menu_scene: PackedScene = preload("res://Scenes/Menus/options_menu.tscn")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$ProfileEditor/VBoxContainer/HBoxContainer/DisplayName.text = Data.player_profile.display_name
|
||||
bg_level.a_star_graph_3d.make_grid()
|
||||
bg_level.a_star_graph_3d.find_path()
|
||||
bg_level.a_star_graph_3d.build_random_maze(50)
|
||||
bg_level.a_star_graph_3d.place_random_towers(20)
|
||||
bg_level.a_star_graph_3d.disable_all_tower_frames()
|
||||
Game.level = bg_level
|
||||
var new_wave: Dictionary = WaveManager.generate_wave(400, bg_level.enemy_pool)
|
||||
for spawn: EnemySpawner in bg_level.enemy_spawns:
|
||||
spawn.enemy_died_callback = enemy_died
|
||||
spawn.enemy_reached_goal_callback = damage_goal
|
||||
spawn.enemy_spawned.connect(increase_enemy_count)
|
||||
spawn.spawn_wave(new_wave)
|
||||
|
||||
|
||||
#these exist purely to make the enemies that spawn on the main menu happy
|
||||
func enemy_died(_some_arg: Enemy) -> void:
|
||||
pass
|
||||
func damage_goal(_some_arg1: int, _some_arg2: int) -> void:
|
||||
pass
|
||||
func increase_enemy_count() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_display_name_edit_pressed() -> void:
|
||||
var popup: TextInputPopup = text_input_popup_scene.instantiate() as TextInputPopup
|
||||
popup.set_popup(Data.player_profile.display_name, "Display Name", "Confirm")
|
||||
popup.completed.connect(change_profile_display_name)
|
||||
add_child(popup)
|
||||
|
||||
|
||||
func change_profile_display_name(display_name: String) -> void:
|
||||
$ProfileEditor/VBoxContainer/HBoxContainer/DisplayName.text = display_name
|
||||
Data.player_profile.set_display_name(display_name)
|
||||
|
||||
|
||||
func _on_quit_button_pressed() -> void:
|
||||
var popup: ConfirmationPopup = confirmation_popup_scene.instantiate() as ConfirmationPopup
|
||||
popup.set_popup("Are you sure you want to quit?", "Yes", "No")
|
||||
popup.completed.connect(quit_game)
|
||||
add_child(popup)
|
||||
|
||||
|
||||
func quit_game(confirmation: bool) -> void:
|
||||
if confirmation:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func _on_play_button_pressed() -> void:
|
||||
Game.scene_switch_to_singleplayer_lobby()
|
||||
|
||||
|
||||
func _on_options_button_pressed() -> void:
|
||||
var menu: OptionsMenu = options_menu_scene.instantiate()
|
||||
add_child(menu)
|
||||
|
||||
|
||||
func _on_multiplayer_button_pressed() -> void:
|
||||
Game.scene_switch_to_multiplayer_lobby()
|
||||
|
||||
|
||||
func _on_button_mouse_entered() -> void:
|
||||
$AudioStreamPlayer.play()
|
145
Scenes/Menus/MainMenu/main_menu.tscn
Normal file
145
Scenes/Menus/MainMenu/main_menu.tscn
Normal file
@ -0,0 +1,145 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://8yv7excojcg0"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://b6a0ip4p72tgx" path="res://new_theme.tres" id="1_p1cib"]
|
||||
[ext_resource type="Script" path="res://Scenes/Menus/MainMenu/main_menu.gd" id="2_ivytu"]
|
||||
[ext_resource type="Texture2D" uid="uid://lvvnrb5jugum" path="res://Assets/Textures/logo_title.png" id="3_8jkeb"]
|
||||
[ext_resource type="PackedScene" uid="uid://y1qa1g3ic8sp" path="res://Worlds/GreenPlanet/Levels/first_level.tscn" id="3_l8r4a"]
|
||||
[ext_resource type="AudioStream" uid="uid://dknygn5eyuhxt" path="res://shot1.wav" id="5_4c4cl"]
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_5u75i"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_2jyua"]
|
||||
random_pitch = 1.1
|
||||
streams_count = 1
|
||||
stream_0/stream = ExtResource("5_4c4cl")
|
||||
stream_0/weight = 1.0
|
||||
|
||||
[node name="MainMenu" type="Control" node_paths=PackedStringArray("bg_level")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_p1cib")
|
||||
script = ExtResource("2_ivytu")
|
||||
bg_level = NodePath("SubViewport/GridMap")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("ViewportTexture_5u75i")
|
||||
|
||||
[node name="TextureRect2" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -627.0
|
||||
offset_top = 73.0
|
||||
offset_right = 1293.0
|
||||
offset_bottom = 1153.0
|
||||
grow_horizontal = 2
|
||||
scale = Vector2(0.67, 0.67)
|
||||
texture = ExtResource("3_8jkeb")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="MainControls" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 130.0
|
||||
offset_top = -188.0
|
||||
offset_right = 143.0
|
||||
offset_bottom = -80.0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="PlayButton" type="Button" parent="MainControls"]
|
||||
layout_mode = 2
|
||||
text = "Play"
|
||||
|
||||
[node name="MultiplayerButton" type="Button" parent="MainControls"]
|
||||
layout_mode = 2
|
||||
text = "Multiplayer"
|
||||
|
||||
[node name="OptionsButton" type="Button" parent="MainControls"]
|
||||
layout_mode = 2
|
||||
text = "Options
|
||||
"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="MainControls"]
|
||||
layout_mode = 2
|
||||
text = "Quit
|
||||
"
|
||||
|
||||
[node name="ProfileEditor" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -429.0
|
||||
offset_top = -140.0
|
||||
offset_right = -55.0
|
||||
offset_bottom = -40.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="ProfileEditor"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="ProfileEditor/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Display Name
|
||||
"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="ProfileEditor/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DisplayName" type="Label" parent="ProfileEditor/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Dummy Name"
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="ProfileEditor/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 29
|
||||
theme_override_constants/margin_top = 2
|
||||
theme_override_constants/margin_right = 31
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="DisplayNameEdit" type="Button" parent="ProfileEditor/VBoxContainer/HBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Change"
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="."]
|
||||
size = Vector2i(1920, 1080)
|
||||
|
||||
[node name="GridMap" parent="SubViewport" instance=ExtResource("3_l8r4a")]
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
stream = SubResource("AudioStreamRandomizer_2jyua")
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="AudioListener3D" type="AudioListener3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 100, 0)
|
||||
current = true
|
||||
|
||||
[connection signal="mouse_entered" from="MainControls/PlayButton" to="." method="_on_button_mouse_entered"]
|
||||
[connection signal="pressed" from="MainControls/PlayButton" to="." method="_on_play_button_pressed"]
|
||||
[connection signal="mouse_entered" from="MainControls/MultiplayerButton" to="." method="_on_button_mouse_entered"]
|
||||
[connection signal="pressed" from="MainControls/MultiplayerButton" to="." method="_on_multiplayer_button_pressed"]
|
||||
[connection signal="mouse_entered" from="MainControls/OptionsButton" to="." method="_on_button_mouse_entered"]
|
||||
[connection signal="pressed" from="MainControls/OptionsButton" to="." method="_on_options_button_pressed"]
|
||||
[connection signal="mouse_entered" from="MainControls/QuitButton" to="." method="_on_button_mouse_entered"]
|
||||
[connection signal="pressed" from="MainControls/QuitButton" to="." method="_on_quit_button_pressed"]
|
||||
[connection signal="mouse_entered" from="ProfileEditor/VBoxContainer/HBoxContainer/MarginContainer/DisplayNameEdit" to="." method="_on_button_mouse_entered"]
|
||||
[connection signal="pressed" from="ProfileEditor/VBoxContainer/HBoxContainer/MarginContainer/DisplayNameEdit" to="." method="_on_display_name_edit_pressed"]
|
Reference in New Issue
Block a user