1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-14 21:15:58 +00:00

Overhaul menu system

This commit is contained in:
ValliantStorme 2021-10-20 00:40:31 -05:00
parent 8d43475a2f
commit e41231da24
6 changed files with 71 additions and 21 deletions

View File

@ -14,6 +14,10 @@ config/name="godot_ship"
run/main_scene="res://scenes/Main.tscn"
config/icon="res://icon.png"
[autoload]
MessageBus="*res://script/game/Message Bus.gd"
[display]
window/size/width=640

View File

@ -1,21 +1,11 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scenes/Debug Menu.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/Gameplay.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/Title Screen.tscn" type="PackedScene" id=3]
[ext_resource path="res://scenes/Options.tscn" type="PackedScene" id=4]
[ext_resource path="res://script/game/Main.gd" type="Script" id=5]
[node name="Root" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Title Screen" parent="." instance=ExtResource( 3 )]
[node name="Game" parent="." instance=ExtResource( 2 )]
[node name="Options" parent="." instance=ExtResource( 4 )]
[node name="Debug Menu" parent="." instance=ExtResource( 1 )]

View File

@ -16,7 +16,6 @@ var menu_active = Transform2D(Vector2(1,0), Vector2(0,1), Vector2(0, 0))
func _ready():
debug_canvas = get_node("debug_canvas")
debug_transform = debug_canvas.get_transform()
return
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
@ -33,3 +32,9 @@ func _unhandled_input(event):
if event.is_action_pressed("ui_debug"):
# open debug menu
debug_active = !debug_active;
func _on_LineEdit_text_entered(new_text):
pass # Replace with function body.

View File

@ -0,0 +1,41 @@
extends Control
# Scenes
var title_screen
var gameplay
var options
var debug_menu
var debug_enabled = true
# Called when the node enters the scene tree for the first time.
func _ready():
# Connect to signals
MessageBus.connect("change_scene", self, "_on_change_scene")
MessageBus.connect("quit", self, "_on_quit_request")
MessageBus.connect("return_to_title", self, "_on_title_request")
# Create the scenes
title_screen = preload("res://scenes/Title Screen.tscn")
gameplay = preload("res://scenes/Gameplay.tscn")
options = preload("res://scenes/Options.tscn")
debug_menu = preload("res://scenes/Debug Menu.tscn")
if (debug_enabled):
add_child(debug_menu.instance())
_on_change_scene("Title")
func _on_change_scene(scene):
match scene:
"Singleplayer":
add_child(gameplay.instance())
"Multiplayer":
add_child(gameplay.instance())
"Options":
add_child(options.instance())
"Title":
add_child(title_screen.instance())
func _on_quit_request():
get_tree().quit()
func _on_title_request():
get_tree().change_scene("res://scenes/Options.tscn")

View File

@ -0,0 +1,8 @@
extends Node
# Ask for a scene change
signal change_scene(scene_name)
# Ask to quit the game
signal quit
# Ask to return to title screen
signal return_to_title

View File

@ -1,9 +1,7 @@
extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Declare member variables here:
# Called when the node enters the scene tree for the first time.
@ -17,13 +15,17 @@ func _ready():
func _on_Singleplayer_pressed():
get_tree().change_scene("res://scenes/Gameplay.tscn")
#get_tree().change_scene("res://scenes/Gameplay.tscn")
MessageBus.emit_signal("change_scene", "Singleplayer")
func _on_Multiplayer_pressed():
get_tree().change_scene("res://scenes/Gameplay.tscn")
#get_tree().change_scene("res://scenes/Gameplay.tscn")
MessageBus.emit_signal("change_scene", "Multiplayer")
func _on_Options_pressed():
get_tree().change_scene("res://scenes/Options.tscn")
#get_tree().change_scene("res://scenes/Options.tscn")
MessageBus.emit_signal("change_scene", "Options")
func _on_Quit_pressed():
get_tree().quit()
#get_tree().quit()
MessageBus.emit_signal("quit")