Skip to content

Commit

Permalink
Make creating a world take you to the world menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Alzter committed May 12, 2023
1 parent f86dbfa commit cec260f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
8 changes: 6 additions & 2 deletions SourceCode/scenes/leveleditor/menus/CreateWorld.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ onready var world_name_container = $VBoxContainer/WorldProperties/WorldName

onready var create_world_button = $VBoxContainer/CreateWorldButton

signal show_world_menu

func _on_CreateWorldMenu_about_to_show():
world_name.text = ""
author_name.text = ""
Expand All @@ -24,9 +26,11 @@ func _on_CreateWorldButton_pressed():

if created_world == OK:
var world_folder = UserLevels.get_world_folder_from_name(world_name.text)
hide()

var worldmap_scene_path = UserLevels.get_worldmap_filepath_for_world(world_folder)
Global.load_level_editor_with_level(worldmap_scene_path)
emit_signal("show_world_menu", world_folder)
#var worldmap_scene_path = UserLevels.get_worldmap_filepath_for_world(world_folder)
#Global.load_level_editor_with_level(worldmap_scene_path)
else:
error_dialog.popup()

Expand Down
1 change: 0 additions & 1 deletion SourceCode/scenes/leveleditor/menus/CreateWorld.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[ext_resource path="res://theme/FontGiant.tres" type="DynamicFont" id=4]

[node name="CreateWorldMenu" type="PopupDialog"]
visible = true
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 20.0
Expand Down
13 changes: 13 additions & 0 deletions SourceCode/scenes/leveleditor/menus/MainMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extends Control
onready var menu_main = $MainMenu
onready var menu_create_world = $CreateWorldMenu
onready var menu_open_world = $OpenWorldMenu
onready var menu_world = $WorldMenu

onready var button_world_create = $MainMenu/VBoxContainer/WorldCreate
onready var button_world_open = $MainMenu/VBoxContainer/WorldOpen
Expand All @@ -13,6 +14,8 @@ func _ready():
Scoreboard.hide()
Music.stop_all()
button_world_create.grab_focus()

menu_create_world.connect("show_world_menu", self, "open_world_menu")


func _on_WorldCreate_pressed():
Expand Down Expand Up @@ -48,3 +51,13 @@ func _on_CreateWorldMenu_popup_hide():
func _on_OpenWorldMenu_popup_hide():
menu_main.show()
button_world_open.grab_focus()

func _on_WorldMenu_popup_hide():
menu_main.show()
button_world_open.grab_focus()

# Opens the world menu for a specified world.
func open_world_menu(world_folder_name : String):
UserLevels.current_world = world_folder_name
menu_main.hide()
menu_world.popup()
24 changes: 14 additions & 10 deletions SourceCode/scenes/leveleditor/menus/MainMenu.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]

[ext_resource path="res://theme/FontBig.tres" type="DynamicFont" id=1]
[ext_resource path="res://theme/default_theme.tres" type="Theme" id=2]
[ext_resource path="res://scenes/layers/Background/SnowBackground.tscn" type="PackedScene" id=3]
[ext_resource path="res://scenes/leveleditor/menus/MainMenu.gd" type="Script" id=4]
[ext_resource path="res://scenes/leveleditor/menus/CreateWorld.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenes/leveleditor/menus/OpenWorld.tscn" type="PackedScene" id=6]
[ext_resource path="res://scenes/leveleditor/menus/WorldMenu.tscn" type="PackedScene" id=7]

[node name="LevelEditorMenu" type="Control"]
anchor_right = 1.0
Expand All @@ -31,7 +32,7 @@ margin_bottom = -25.0
custom_constants/separation = 15

[node name="Label" type="RichTextLabel" parent="MainMenu/VBoxContainer"]
margin_right = 372.0
margin_right = 1012.0
margin_bottom = 30.0
custom_fonts/normal_font = ExtResource( 1 )
bbcode_enabled = true
Expand All @@ -41,21 +42,21 @@ fit_content_height = true

[node name="HSeparator" type="HSeparator" parent="MainMenu/VBoxContainer"]
margin_top = 45.0
margin_right = 372.0
margin_right = 1012.0
margin_bottom = 55.0
custom_constants/separation = 10

[node name="WorldCreate" type="Button" parent="MainMenu/VBoxContainer"]
margin_top = 70.0
margin_right = 372.0
margin_right = 1012.0
margin_bottom = 120.0
rect_min_size = Vector2( 0, 50 )
focus_neighbour_bottom = NodePath("../WorldOpen")
text = "Create World"

[node name="WorldOpen" type="Button" parent="MainMenu/VBoxContainer"]
margin_top = 135.0
margin_right = 372.0
margin_right = 1012.0
margin_bottom = 185.0
rect_min_size = Vector2( 0, 50 )
focus_neighbour_top = NodePath("../WorldCreate")
Expand All @@ -64,14 +65,14 @@ text = "Open World"

[node name="SpaceFiller" type="Control" parent="MainMenu/VBoxContainer"]
margin_top = 200.0
margin_right = 372.0
margin_bottom = 244.0
margin_right = 1012.0
margin_bottom = 484.0
size_flags_vertical = 3

[node name="ExitToMenu" type="Button" parent="MainMenu/VBoxContainer"]
margin_top = 259.0
margin_right = 372.0
margin_bottom = 309.0
margin_top = 499.0
margin_right = 1012.0
margin_bottom = 549.0
rect_min_size = Vector2( 0, 50 )
focus_neighbour_top = NodePath("../WorldOpen")
text = "Exit"
Expand All @@ -82,6 +83,8 @@ text = "Exit"

[node name="SnowBG" parent="." instance=ExtResource( 3 )]

[node name="WorldMenu" parent="." instance=ExtResource( 7 )]

[connection signal="mouse_entered" from="MainMenu/VBoxContainer/WorldCreate" to="." method="_on_WorldCreate_mouse_entered"]
[connection signal="pressed" from="MainMenu/VBoxContainer/WorldCreate" to="." method="_on_WorldCreate_pressed"]
[connection signal="mouse_entered" from="MainMenu/VBoxContainer/WorldOpen" to="." method="_on_WorldOpen_mouse_entered"]
Expand All @@ -90,3 +93,4 @@ text = "Exit"
[connection signal="pressed" from="MainMenu/VBoxContainer/ExitToMenu" to="." method="_on_ExitToMenu_pressed"]
[connection signal="popup_hide" from="CreateWorldMenu" to="." method="_on_CreateWorldMenu_popup_hide"]
[connection signal="popup_hide" from="OpenWorldMenu" to="." method="_on_OpenWorldMenu_popup_hide"]
[connection signal="popup_hide" from="WorldMenu" to="." method="_on_WorldMenu_popup_hide"]
1 change: 0 additions & 1 deletion SourceCode/scenes/leveleditor/menus/OpenLevel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
[ext_resource path="res://scenes/leveleditor/menus/DeleteLevelDialog.tscn" type="PackedScene" id=5]

[node name="SelectLevelDialog" type="PopupDialog"]
visible = true
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 10.0
Expand Down
1 change: 0 additions & 1 deletion SourceCode/scenes/leveleditor/menus/WorldMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[ext_resource path="res://scenes/leveleditor/menus/OpenLevel.tscn" type="PackedScene" id=5]

[node name="WorldMenu" type="PopupDialog"]
visible = true
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 20.0
Expand Down

0 comments on commit cec260f

Please sign in to comment.