basic main menu

This commit is contained in:
Antti Hakkarainen 2023-02-16 22:48:26 +02:00
parent 523f7888da
commit 8b437f6598
16 changed files with 370 additions and 128 deletions

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=9 format=3 uid="uid://b1bahdquscsym"]
[gd_scene load_steps=10 format=3 uid="uid://b1bahdquscsym"]
[ext_resource type="Script" path="res://scripts/Main.gd" id="1_ysxum"]
[ext_resource type="Script" path="res://scripts/ChunkHandler.gd" id="2_6cequ"]
[ext_resource type="PackedScene" uid="uid://bflqpejouge8r" path="res://scenes/MainMenu.tscn" id="2_wfpe2"]
[ext_resource type="Script" path="res://scripts/Control.gd" id="3_1t1c8"]
[ext_resource type="PackedScene" uid="uid://2we3txfr812u" path="res://scenes/Camera_zoom_2d.tscn" id="4_rx82t"]
[ext_resource type="Script" path="res://scripts/EntityPlacer.gd" id="5_8jju5"]
@ -12,10 +13,15 @@
[node name="Main" type="Node2D"]
script = ExtResource("1_ysxum")
[node name="ChunkHandler" type="Node2D" parent="."]
[node name="MainMenu" parent="." instance=ExtResource("2_wfpe2")]
[node name="Game" type="Node2D" parent="."]
visible = false
[node name="ChunkHandler" type="Node2D" parent="Game"]
script = ExtResource("2_6cequ")
[node name="CameraZoom2D" parent="." instance=ExtResource("4_rx82t")]
[node name="CameraZoom2D" parent="Game" instance=ExtResource("4_rx82t")]
position = Vector2(1272, 720)
ignore_rotation = false
limit_left = 0
@ -26,22 +32,23 @@ limit_smoothed = true
rotation_smoothing_enabled = true
editor_draw_limits = true
[node name="MapBackground" type="Sprite2D" parent="."]
[node name="MapBackground" type="Sprite2D" parent="Game"]
z_index = -1
centered = false
script = ExtResource("8_ron2j")
[node name="UILayer" type="CanvasLayer" parent="."]
[node name="UILayer" type="CanvasLayer" parent="Game"]
process_mode = 1
visible = false
[node name="EntityPlacer" type="Control" parent="UILayer"]
[node name="EntityPlacer" type="Control" parent="Game/UILayer"]
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("5_8jju5")
[node name="Control" type="Control" parent="UILayer"]
[node name="Control" type="Control" parent="Game/UILayer"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@ -52,7 +59,7 @@ mouse_filter = 1
script = ExtResource("3_1t1c8")
metadata/_edit_use_anchors_ = true
[node name="ConstructionPanel" type="Panel" parent="UILayer/Control"]
[node name="ConstructionPanel" type="Panel" parent="Game/UILayer/Control"]
custom_minimum_size = Vector2(500, 100)
layout_mode = 1
anchors_preset = 5
@ -63,42 +70,42 @@ offset_right = 250.0
offset_bottom = 100.0
grow_horizontal = 2
[node name="button_residental" type="Button" parent="UILayer/Control/ConstructionPanel"]
[node name="button_residental" type="Button" parent="Game/UILayer/Control/ConstructionPanel"]
layout_mode = 0
offset_right = 8.0
offset_bottom = 8.0
[node name="button_commercial" type="Button" parent="UILayer/Control/ConstructionPanel"]
[node name="button_commercial" type="Button" parent="Game/UILayer/Control/ConstructionPanel"]
layout_mode = 0
offset_right = 8.0
offset_bottom = 8.0
[node name="button_industrial" type="Button" parent="UILayer/Control/ConstructionPanel"]
[node name="button_industrial" type="Button" parent="Game/UILayer/Control/ConstructionPanel"]
layout_mode = 0
offset_right = 8.0
offset_bottom = 8.0
[node name="button_roads" type="Button" parent="UILayer/Control/ConstructionPanel"]
[node name="button_roads" type="Button" parent="Game/UILayer/Control/ConstructionPanel"]
layout_mode = 0
offset_right = 8.0
offset_bottom = 8.0
[node name="button_demolish" type="Button" parent="UILayer/Control/ConstructionPanel"]
[node name="button_demolish" type="Button" parent="Game/UILayer/Control/ConstructionPanel"]
layout_mode = 0
offset_right = 8.0
offset_bottom = 8.0
[node name="button_services" type="Button" parent="UILayer/Control/ConstructionPanel"]
[node name="button_services" type="Button" parent="Game/UILayer/Control/ConstructionPanel"]
layout_mode = 0
offset_right = 8.0
offset_bottom = 8.0
[node name="button_social" type="Button" parent="UILayer/Control/ConstructionPanel"]
[node name="button_social" type="Button" parent="Game/UILayer/Control/ConstructionPanel"]
layout_mode = 0
offset_right = 8.0
offset_bottom = 8.0
[node name="DebugContainer" type="GridContainer" parent="UILayer/Control"]
[node name="DebugContainer" type="GridContainer" parent="Game/UILayer/Control"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
@ -108,10 +115,10 @@ offset_top = 24.0
offset_bottom = 424.0
grow_horizontal = 0
[node name="DebugInfo" type="Label" parent="UILayer/Control/DebugContainer"]
[node name="DebugInfo" type="Label" parent="Game/UILayer/Control/DebugContainer"]
layout_mode = 2
[node name="Minimap" type="Panel" parent="UILayer/Control"]
[node name="Minimap" type="Panel" parent="Game/UILayer/Control"]
clip_contents = true
custom_minimum_size = Vector2(512, 512)
layout_mode = 1
@ -127,32 +134,33 @@ grow_vertical = 0
mouse_filter = 1
script = ExtResource("5_rg28x")
[node name="CameraMarker" type="Sprite2D" parent="UILayer/Control/Minimap"]
[node name="CameraMarker" type="Sprite2D" parent="Game/UILayer/Control/Minimap"]
z_index = 1
position = Vector2(-32, 0)
centered = false
script = ExtResource("7_6krn1")
[node name="MinimapSprite" type="Sprite2D" parent="UILayer/Control/Minimap"]
[node name="MinimapSprite" type="Sprite2D" parent="Game/UILayer/Control/Minimap"]
texture_repeat = 1
centered = false
[connection signal="set_camera_position" from="." to="CameraZoom2D" method="_on_set_camera_position"]
[connection signal="worldgen_ready" from="." to="ChunkHandler" method="_on_main_worldgen_ready"]
[connection signal="worldgen_ready" from="." to="CameraZoom2D" method="_on_main_worldgen_ready"]
[connection signal="worldgen_ready" from="." to="UILayer/Control/Minimap" method="_on_main_worldgen_ready"]
[connection signal="worldgen_ready" from="." to="UILayer/Control/Minimap/CameraMarker" method="_on_main_worldgen_ready"]
[connection signal="chunk_stats" from="ChunkHandler" to="UILayer/Control" method="_on_chunk_handler_chunk_stats"]
[connection signal="camera_rotation_changed" from="CameraZoom2D" to="UILayer/Control/Minimap/CameraMarker" method="_on_camera_zoom_2d_camera_rotation_changed"]
[connection signal="camera_zoom_changed" from="CameraZoom2D" to="UILayer/Control/Minimap/CameraMarker" method="_on_camera_zoom_2d_camera_zoom_changed"]
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_residental" to="UILayer/Control" method="_on_button_residental_pressed"]
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_commercial" to="UILayer/Control" method="_on_button_commercial_pressed"]
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_industrial" to="UILayer/Control" method="_on_button_industrial_pressed"]
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_roads" to="UILayer/Control" method="_on_button_roads_pressed"]
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_demolish" to="UILayer/Control" method="_on_button_demolish_pressed"]
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_services" to="UILayer/Control" method="_on_button_services_pressed"]
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_social" to="UILayer/Control" method="_on_button_social_pressed"]
[connection signal="mouse_entered" from="UILayer/Control/Minimap" to="UILayer/Control/Minimap" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="UILayer/Control/Minimap" to="UILayer/Control/Minimap" method="_on_mouse_exited"]
[connection signal="set_camera_position" from="UILayer/Control/Minimap" to="CameraZoom2D" method="_on_set_camera_position"]
[connection signal="set_map_background_texture" from="UILayer/Control/Minimap" to="MapBackground" method="_on_minimap_set_map_background_texture"]
[connection signal="set_camera_position" from="." to="Game/CameraZoom2D" method="_on_set_camera_position"]
[connection signal="worldgen_ready" from="." to="Game/ChunkHandler" method="_on_main_worldgen_ready"]
[connection signal="worldgen_ready" from="." to="Game/CameraZoom2D" method="_on_main_worldgen_ready"]
[connection signal="worldgen_ready" from="." to="Game/UILayer/Control" method="_on_main_worldgen_ready"]
[connection signal="worldgen_ready" from="." to="Game/UILayer/Control/Minimap" method="_on_main_worldgen_ready"]
[connection signal="worldgen_ready" from="." to="Game/UILayer/Control/Minimap/CameraMarker" method="_on_main_worldgen_ready"]
[connection signal="chunk_stats" from="Game/ChunkHandler" to="Game/UILayer/Control" method="_on_chunk_handler_chunk_stats"]
[connection signal="camera_rotation_changed" from="Game/CameraZoom2D" to="Game/UILayer/Control/Minimap/CameraMarker" method="_on_camera_zoom_2d_camera_rotation_changed"]
[connection signal="camera_zoom_changed" from="Game/CameraZoom2D" to="Game/UILayer/Control/Minimap/CameraMarker" method="_on_camera_zoom_2d_camera_zoom_changed"]
[connection signal="pressed" from="Game/UILayer/Control/ConstructionPanel/button_residental" to="Game/UILayer/Control" method="_on_button_residental_pressed"]
[connection signal="pressed" from="Game/UILayer/Control/ConstructionPanel/button_commercial" to="Game/UILayer/Control" method="_on_button_commercial_pressed"]
[connection signal="pressed" from="Game/UILayer/Control/ConstructionPanel/button_industrial" to="Game/UILayer/Control" method="_on_button_industrial_pressed"]
[connection signal="pressed" from="Game/UILayer/Control/ConstructionPanel/button_roads" to="Game/UILayer/Control" method="_on_button_roads_pressed"]
[connection signal="pressed" from="Game/UILayer/Control/ConstructionPanel/button_demolish" to="Game/UILayer/Control" method="_on_button_demolish_pressed"]
[connection signal="pressed" from="Game/UILayer/Control/ConstructionPanel/button_services" to="Game/UILayer/Control" method="_on_button_services_pressed"]
[connection signal="pressed" from="Game/UILayer/Control/ConstructionPanel/button_social" to="Game/UILayer/Control" method="_on_button_social_pressed"]
[connection signal="mouse_entered" from="Game/UILayer/Control/Minimap" to="Game/UILayer/Control/Minimap" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="Game/UILayer/Control/Minimap" to="Game/UILayer/Control/Minimap" method="_on_mouse_exited"]
[connection signal="set_camera_position" from="Game/UILayer/Control/Minimap" to="Game/CameraZoom2D" method="_on_set_camera_position"]
[connection signal="set_map_background_texture" from="Game/UILayer/Control/Minimap" to="Game/MapBackground" method="_on_minimap_set_map_background_texture"]

View file

@ -1,11 +1,9 @@
[gd_scene load_steps=3 format=3 uid="uid://bflqpejouge8r"]
[gd_scene load_steps=5 format=3 uid="uid://bflqpejouge8r"]
[sub_resource type="ImageTexture" id="ImageTexture_qii6u"]
[sub_resource type="LabelSettings" id="LabelSettings_tb1vr"]
font_size = 64
outline_size = 20
outline_color = Color(0, 0, 0, 1)
[ext_resource type="Script" path="res://scripts/MainMenuBar.gd" id="1_50qd7"]
[ext_resource type="Theme" uid="uid://clswkwdkqsx87" path="res://themes/mainmenu_button_theme.tres" id="1_jy0t0"]
[ext_resource type="Texture2D" uid="uid://ccbum282wlrrj" path="res://art/backgrounds/mainmenu_background.png" id="2_7rmv5"]
[ext_resource type="Texture2D" uid="uid://jsnvlmenolg8" path="res://art/logos/mainmenu_logo.png" id="3_etjlt"]
[node name="MainMenu" type="Control"]
layout_mode = 3
@ -15,48 +13,70 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MenuBackground" type="Sprite2D" parent="."]
position = Vector2(-2, -3.99994)
scale = Vector2(2566, 1448)
texture = SubResource("ImageTexture_qii6u")
flip_h = true
[node name="MarginContainer" type="MarginContainer" parent="."]
[node name="MainMenuBar" type="GridContainer" parent="."]
layout_mode = 0
offset_right = 2560.0
offset_bottom = 1440.0
[node name="MenuBar" type="VSplitContainer" parent="MarginContainer"]
layout_mode = 2
offset_left = 1050.0
offset_top = 515.0
offset_right = 1530.0
offset_bottom = 1155.0
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/v_separation = 32
script = ExtResource("1_50qd7")
metadata/_edit_use_anchors_ = true
[node name="Menu_NewGame" type="Label" parent="MarginContainer/MenuBar"]
[node name="Menu_NewGame" type="Button" parent="MainMenuBar"]
layout_mode = 2
text = "New Game"
label_settings = SubResource("LabelSettings_tb1vr")
theme = ExtResource("1_jy0t0")
text = " New Game"
alignment = 0
[node name="Menu_LoadGame" type="Label" parent="MarginContainer/MenuBar"]
[node name="Menu_LoadGame" type="Button" parent="MainMenuBar"]
layout_mode = 2
text = "Load Game"
label_settings = SubResource("LabelSettings_tb1vr")
theme = ExtResource("1_jy0t0")
text = " Load Game"
alignment = 0
[node name="Menu_ResumeGame" type="Label" parent="MarginContainer/MenuBar"]
[node name="Menu_ResumeGame" type="Button" parent="MainMenuBar"]
layout_mode = 2
text = "Resume Game"
label_settings = SubResource("LabelSettings_tb1vr")
size_flags_horizontal = 0
size_flags_vertical = 0
theme = ExtResource("1_jy0t0")
text = " Resume Game "
alignment = 0
[node name="Menu_Options" type="Label" parent="MarginContainer/MenuBar"]
[node name="Menu_Options" type="Button" parent="MainMenuBar"]
layout_mode = 2
text = "Options"
label_settings = SubResource("LabelSettings_tb1vr")
size_flags_horizontal = 0
theme = ExtResource("1_jy0t0")
text = " Options "
[node name="Menu_Credits" type="Label" parent="MarginContainer/MenuBar"]
[node name="Menu_Credits" type="Button" parent="MainMenuBar"]
layout_mode = 2
text = "Credits"
label_settings = SubResource("LabelSettings_tb1vr")
theme = ExtResource("1_jy0t0")
text = " Credits"
alignment = 0
[node name="Menu_ExitGame" type="Label" parent="MarginContainer/MenuBar"]
[node name="Menu_ExitGame" type="Button" parent="MainMenuBar"]
layout_mode = 2
text = "Exit Game"
label_settings = SubResource("LabelSettings_tb1vr")
theme = ExtResource("1_jy0t0")
text = " Exit Game"
alignment = 0
[node name="MenuBackground" type="Sprite2D" parent="."]
z_index = -1
position = Vector2(1320, 736)
texture = ExtResource("2_7rmv5")
[node name="MenuLogo" type="Sprite2D" parent="."]
position = Vector2(856, 592)
rotation = -1.5708
scale = Vector2(0.547831, 0.547831)
texture = ExtResource("3_etjlt")
[connection signal="pressed" from="MainMenuBar/Menu_NewGame" to="MainMenuBar" method="_on_menu_new_game_pressed"]
[connection signal="pressed" from="MainMenuBar/Menu_LoadGame" to="MainMenuBar" method="_on_menu_load_game_pressed"]
[connection signal="pressed" from="MainMenuBar/Menu_ResumeGame" to="MainMenuBar" method="_on_menu_resume_game_pressed"]
[connection signal="pressed" from="MainMenuBar/Menu_Options" to="MainMenuBar" method="_on_menu_options_pressed"]
[connection signal="pressed" from="MainMenuBar/Menu_Credits" to="MainMenuBar" method="_on_menu_credits_pressed"]
[connection signal="pressed" from="MainMenuBar/Menu_ExitGame" to="MainMenuBar" method="_on_menu_exit_game_pressed"]