1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-15 05:25:57 +00:00

Radical debug menu overhaul + Options overhaul

This commit is contained in:
John 2021-10-21 05:22:42 -05:00
parent f74ad64865
commit 7f0b58de70
13 changed files with 1454 additions and 81 deletions

View File

@ -1,16 +0,0 @@
extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

43
godot_ship/debug.tres Normal file
View File

@ -0,0 +1,43 @@
[gd_resource type="Theme" format=2]
[resource]
resource_name = "Debug Theme"
TextEdit/colors/background_color = Color( 0, 0.117647, 0.152941, 1 )
TextEdit/colors/bookmark_color = Color( 0.0784314, 0.490196, 0.980392, 1 )
TextEdit/colors/brace_mismatch_color = Color( 1, 0.2, 0.2, 1 )
TextEdit/colors/breakpoint_color = Color( 0.8, 0.8, 0.4, 0.2 )
TextEdit/colors/caret_background_color = Color( 0, 0, 0, 1 )
TextEdit/colors/caret_color = Color( 0.88, 0.88, 0.88, 1 )
TextEdit/colors/code_folding_color = Color( 0.8, 0.8, 0.8, 0.8 )
TextEdit/colors/completion_background_color = Color( 0.17, 0.16, 0.2, 1 )
TextEdit/colors/completion_existing_color = Color( 0.87, 0.87, 0.87, 0.13 )
TextEdit/colors/completion_font_color = Color( 0.67, 0.67, 0.67, 1 )
TextEdit/colors/completion_scroll_color = Color( 1, 1, 1, 1 )
TextEdit/colors/completion_selected_color = Color( 0.26, 0.26, 0.27, 1 )
TextEdit/colors/current_line_color = Color( 0.25098, 0.25098, 0.258824, 0.8 )
TextEdit/colors/executing_line_color = Color( 0.2, 0.8, 0.2, 0.4 )
TextEdit/colors/font_color = Color( 0.611765, 0.760784, 0.764706, 1 )
TextEdit/colors/font_color_readonly = Color( 0.611765, 0.760784, 0.764706, 1 )
TextEdit/colors/font_color_selected = Color( 0, 0, 0, 1 )
TextEdit/colors/function_color = Color( 0.4, 0.64, 0.81, 1 )
TextEdit/colors/line_number_color = Color( 0.67, 0.67, 0.67, 0.4 )
TextEdit/colors/mark_color = Color( 1, 0.4, 0.4, 0.4 )
TextEdit/colors/member_variable_color = Color( 0.9, 0.31, 0.35, 1 )
TextEdit/colors/number_color = Color( 0.92, 0.58, 0.2, 1 )
TextEdit/colors/safe_line_number_color = Color( 0.67, 0.78, 0.67, 0.6 )
TextEdit/colors/selection_color = Color( 0.49, 0.49, 0.49, 1 )
TextEdit/colors/symbol_color = Color( 0.94, 0.94, 0.94, 1 )
TextEdit/colors/word_highlighted_color = Color( 0.8, 0.9, 0.9, 0.15 )
TextEdit/constants/completion_lines = 7
TextEdit/constants/completion_max_width = 50
TextEdit/constants/completion_scroll_width = 3
TextEdit/constants/line_spacing = 4
TextEdit/fonts/font = null
TextEdit/icons/fold = null
TextEdit/icons/folded = null
TextEdit/icons/space = null
TextEdit/icons/tab = null
TextEdit/styles/completion = null
TextEdit/styles/focus = null
TextEdit/styles/normal = null
TextEdit/styles/read_only = null

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@ config/icon="res://icon.png"
[autoload] [autoload]
MessageBus="*res://script/game/Message Bus.gd" MessageBus="*res://script/game/Message Bus.gd"
OptionsController="*res://script/options/OptionsController.gd"
[display] [display]

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://main.tres" type="Theme" id=1] [ext_resource path="res://main.tres" type="Theme" id=1]
[ext_resource path="res://script/debug/debug_menu.gd" type="Script" id=2] [ext_resource path="res://script/debug/debug_menu.gd" type="Script" id=2]
[ext_resource path="res://script/debug/In.gd" type="Script" id=3] [ext_resource path="res://script/debug/In.gd" type="Script" id=3]
[ext_resource path="res://script/debug/Out.gd" type="Script" id=4] [ext_resource path="res://script/debug/Out.gd" type="Script" id=4]
[ext_resource path="res://debug.tres" type="Theme" id=5]
[node name="Debug" type="Control"] [node name="Debug" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@ -31,6 +32,7 @@ margin_right = 640.0
margin_bottom = 144.0 margin_bottom = 144.0
grow_vertical = 0 grow_vertical = 0
rect_min_size = Vector2( 0, 144 ) rect_min_size = Vector2( 0, 144 )
theme = ExtResource( 5 )
readonly = true readonly = true
syntax_highlighting = true syntax_highlighting = true
fold_gutter = true fold_gutter = true

View File

@ -2,7 +2,7 @@
[ext_resource path="res://script/game/Main.gd" type="Script" id=5] [ext_resource path="res://script/game/Main.gd" type="Script" id=5]
[node name="Root" type="Control"] [node name="Main" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
script = ExtResource( 5 ) script = ExtResource( 5 )

View File

@ -11,7 +11,7 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="TextureRect" type="TextureRect" parent="."] [node name="Background" type="TextureRect" parent="."]
margin_right = 40.0 margin_right = 40.0
margin_bottom = 40.0 margin_bottom = 40.0
texture = ExtResource( 1 ) texture = ExtResource( 1 )
@ -20,7 +20,7 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="RichTextLabel" type="RichTextLabel" parent="."] [node name="MenuLabel" type="RichTextLabel" parent="."]
margin_left = 294.0 margin_left = 294.0
margin_top = 68.0 margin_top = 68.0
margin_right = 346.0 margin_right = 346.0
@ -32,7 +32,7 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Slider Container" type="VBoxContainer" parent="."] [node name="Sliders" type="VBoxContainer" parent="."]
margin_left = 216.0 margin_left = 216.0
margin_top = 128.0 margin_top = 128.0
margin_right = 424.0 margin_right = 424.0
@ -42,10 +42,10 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="SFX Setting" type="Node2D" parent="Slider Container"] [node name="SFX Setting" type="Node2D" parent="Sliders"]
position = Vector2( 0, 8 ) position = Vector2( 0, 8 )
[node name="SFX Label" type="Label" parent="Slider Container/SFX Setting"] [node name="SFX Label" type="Label" parent="Sliders/SFX Setting"]
margin_top = -8.0 margin_top = -8.0
margin_right = 64.0 margin_right = 64.0
margin_bottom = 8.0 margin_bottom = 8.0
@ -57,19 +57,26 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="SFX Slider" type="HSlider" parent="Slider Container/SFX Setting"] [node name="SFX Slider" type="HSlider" parent="Sliders/SFX Setting"]
margin_left = 64.0 margin_left = 64.0
margin_top = -8.0 margin_top = -8.0
margin_right = 208.0 margin_right = 208.0
margin_bottom = 8.0 margin_bottom = 8.0
focus_neighbour_left = NodePath("../../../Back")
focus_neighbour_top = NodePath("../../../Back")
focus_neighbour_bottom = NodePath("../../Volume Setting/Volume Slider")
focus_next = NodePath("../../Volume Setting/Volume Slider")
focus_previous = NodePath("../../../Back")
step = 10.0
tick_count = 11
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Volume Setting" type="Node2D" parent="Slider Container"] [node name="Volume Setting" type="Node2D" parent="Sliders"]
position = Vector2( 0, 24 ) position = Vector2( 0, 24 )
[node name="Volume Label" type="Label" parent="Slider Container/Volume Setting"] [node name="Volume Label" type="Label" parent="Sliders/Volume Setting"]
margin_top = -8.0 margin_top = -8.0
margin_right = 64.0 margin_right = 64.0
margin_bottom = 8.0 margin_bottom = 8.0
@ -81,39 +88,50 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Volume Slider" type="HSlider" parent="Slider Container/Volume Setting"] [node name="Volume Slider" type="HSlider" parent="Sliders/Volume Setting"]
margin_left = 64.0 margin_left = 64.0
margin_top = -8.0 margin_top = -8.0
margin_right = 208.0 margin_right = 208.0
margin_bottom = 8.0 margin_bottom = 8.0
focus_neighbour_top = NodePath("../../SFX Setting/SFX Slider")
focus_neighbour_bottom = NodePath("../../../Theme Select")
focus_next = NodePath("../../../Theme Select")
focus_previous = NodePath("../../SFX Setting/SFX Slider")
step = 10.0
tick_count = 11
ticks_on_borders = true
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="HBoxContainer" type="HBoxContainer" parent="."] [node name="Buttons" type="HBoxContainer" parent="."]
margin_left = 216.0 margin_left = 216.0
margin_top = 160.0 margin_top = 160.0
margin_right = 424.0 margin_right = 424.0
margin_bottom = 184.0 margin_bottom = 184.0
focus_neighbour_left = NodePath("../Back")
focus_neighbour_top = NodePath("../Sliders/Volume Setting/Volume Slider")
focus_next = NodePath("../Back")
focus_previous = NodePath("../Sliders/Volume Setting/Volume Slider")
__meta__ = { __meta__ = {
"_edit_lock_": true, "_edit_lock_": true,
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Button" type="Button" parent="HBoxContainer"] [node name="Light" type="Button" parent="Buttons"]
margin_right = 102.0 margin_right = 102.0
margin_bottom = 24.0 margin_bottom = 24.0
rect_min_size = Vector2( 102, 0 ) rect_min_size = Vector2( 102, 0 )
text = "Light Mode" text = "Light Mode"
[node name="Button2" type="Button" parent="HBoxContainer"] [node name="Dark" type="Button" parent="Buttons"]
margin_left = 106.0 margin_left = 106.0
margin_right = 208.0 margin_right = 208.0
margin_bottom = 24.0 margin_bottom = 24.0
rect_min_size = Vector2( 102, 0 ) rect_min_size = Vector2( 102, 0 )
text = "Dark Mode" text = "Dark Mode"
[node name="Button" type="Button" parent="."] [node name="Back" type="Button" parent="."]
margin_left = 16.0 margin_left = 16.0
margin_top = 16.0 margin_top = 16.0
margin_right = 28.0 margin_right = 28.0
@ -124,4 +142,8 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"] [connection signal="value_changed" from="Sliders/SFX Setting/SFX Slider" to="." method="_on_SFX_Slider_value_changed"]
[connection signal="value_changed" from="Sliders/Volume Setting/Volume Slider" to="." method="_on_Volume_Slider_value_changed"]
[connection signal="pressed" from="Buttons/Light" to="." method="_on_Light_pressed"]
[connection signal="pressed" from="Buttons/Dark" to="." method="_on_Dark_pressed"]
[connection signal="pressed" from="Back" to="." method="_on_Button_pressed"]

View File

@ -11,7 +11,7 @@ var debug_active = false
var menu_position = 0.0 var menu_position = 0.0
var menu_velocity = 4 var menu_velocity = 4
onready var present_working_node = get_node("/root") onready var present_working_node = get_node("/root/Main")
# positions when the menu is hidden/active # positions when the menu is hidden/active
var menu_hidden = Transform2D(Vector2(1,0), Vector2(0,1), Vector2(0,-170)) var menu_hidden = Transform2D(Vector2(1,0), Vector2(0,1), Vector2(0,-170))
@ -28,6 +28,7 @@ func _ready():
debug_transform = debug_canvas.get_transform() debug_transform = debug_canvas.get_transform()
debug_output = get_node("debug_canvas/VBoxContainer/TextEdit") debug_output = get_node("debug_canvas/VBoxContainer/TextEdit")
command_help([""]) command_help([""])
debug_print_line("> ")
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
@ -54,11 +55,11 @@ func _input(event):
func _on_LineEdit_text_entered(line): func _on_LineEdit_text_entered(line):
emit_signal("clear_in") emit_signal("clear_in")
debug_print_line("") debug_print_line(line + "\n")
var command = line.split(' ', true, 1) var command = line.split(' ', true, 1)
match command[0]: match command[0]:
"start", "s": "start", "open", "o":
command_start(command) command_start(command)
"stop", "kill", "k": "stop", "kill", "k":
command_stop(command) command_stop(command)
"list", "ls", "l": "list", "ls", "l":
@ -79,6 +80,7 @@ func _on_LineEdit_text_entered(line):
command_cd(command) command_cd(command)
_: _:
debug_print_line("Command not recognized.\n") debug_print_line("Command not recognized.\n")
debug_print_line("> ")
func debug_print_line(string): func debug_print_line(string):
emit_signal("print_text", string.c_unescape()) emit_signal("print_text", string.c_unescape())
@ -88,25 +90,35 @@ func debug_print_line(string):
# start: Loads scene from res://scenes/*.tscn by filename, and starts it # start: Loads scene from res://scenes/*.tscn by filename, and starts it
func command_start (command): func command_start (command):
if command.size() > 1: if command.size() > 1:
MessageBus.emit_signal("start_tcsn", command[1]) var pack = load("res://scenes/" + command[1] + ".tscn");
present_working_node.add_child(pack.instance());
debug_print_line("start '" + command[1] + "'\n") debug_print_line("start '" + command[1] + "'\n")
else: else:
debug_print_line("Usage: start scene") debug_print_line("Usage: start scene")
# stop: Stops scene by name of root node. # stop: kills a child of current working node
func command_stop (command): func command_stop (command):
if command.size() > 1: if command.size() > 1:
if command[1] != "Debug": var node = present_working_node.find_node(command[1], false, false)
debug_print_line("kill '" + command[1] + "'\n") if node:
MessageBus.emit_signal("kill_scene", command[1]) if String(node.get_path()).match("*Debug*"):
debug_print_line("YOU DIDN'T SAY THE MAGIC WORD!\n")
else:
node.queue_free()
debug_print_line(command[1] + " killed\n")
else: else:
debug_print_line("YOU DIDN'T SAY THE MAGIC WORD!\n") debug_print_line(command[0] + ": " + command[1] + " not found.\n")
else: else:
debug_print_line("Usage: kill scene") debug_print_line("Usage: kill name\n")
# list: Lists names of active scenes (children of Root) # list: Lists children of node
func command_list (_command): func command_list (command):
var children = present_working_node.get_children() var node = null
if (command.size() > 1):
node = complete_path(command[1])
if (!node):
node = present_working_node
var children = node.get_children()
var names = [] var names = []
for i in range (children.size()): for i in range (children.size()):
names.append(children[i].name) names.append(children[i].name)
@ -120,8 +132,10 @@ func command_restart (_command):
func command_print(command): func command_print(command):
if command.size() > 1: if command.size() > 1:
debug_print_line(command[1] + "\n") debug_print_line(command[1] + "\n")
else:
debug_print_line("\n")
# emit: emits a message onto the MessageBus (!Extremely Danger!) # emit: emits a message onto the MessageBus
func command_emit (command): func command_emit (command):
var mbus_signal = command[1].split(' ', true, 1) var mbus_signal = command[1].split(' ', true, 1)
match mbus_signal.size(): match mbus_signal.size():
@ -137,22 +151,17 @@ func command_emit (command):
func command_clear (_command): func command_clear (_command):
emit_signal("clear_out"); emit_signal("clear_out");
# pwd: print the current working node's path
func command_pwd (_command): func command_pwd (_command):
debug_print_line("pwd\n" + String(present_working_node.get_path()) + "\n") debug_print_line(String(present_working_node.get_path()) + "\n")
# cd: change the current working node
func command_cd (command): func command_cd (command):
if command.size() > 1: if command.size() > 1:
var path var node = complete_path(command[1])
if command[1].is_abs_path():
path = command[1]
else: #convert to absolute path
path = String(present_working_node.get_path()) + "/" + command[1]
var node = get_node(path)
if node: if node:
debug_print_line("cd " + command[1] + "\n")
present_working_node = node present_working_node = node
else: else:
debug_print_line ('change node: node not found.\n') debug_print_line ('cn: no such node: ' + command[1] + '\n')
else: else:
debug_print_line("") debug_print_line("")
pass pass
@ -160,23 +169,22 @@ func command_cd (command):
# help: Prints help dialogue # help: Prints help dialogue
func command_help (command): func command_help (command):
if (command.size() == 1): if (command.size() == 1):
debug_print_line("Ship's Commander V 0.1\n") debug_print_line("Valid commands:\nhelp, start, stop, list, restart, print, emit, clear, pwn, cn\n")
debug_print_line("Valid commands:\nstart, stop, list, restart, print, emit, clear, help\n")
else: else:
debug_print_line(command[1]) debug_print_line(command[1])
match command[1]: match command[1]:
"start", "s": "start", "open", "o":
debug_print_line(" filename\nAliases: 'start', 's'\n") debug_print_line(" filename\nAliases: 'start', 'open', 'o'\n")
debug_print_line("Loads and runs the scene filename.tscn\n") debug_print_line("Load add the scene filename.tscn as child\n")
"stop", "kill", "k": "stop", "kill", "k":
debug_print_line(" scene\nAliases: 'stop', 'kill', 'k'\n") debug_print_line(" name\nAliases: 'stop', 'kill', 'k'\n")
debug_print_line("Kills an active scene whose name matches node.\n") debug_print_line("Kill node with matching name\n")
"list", "ls", "l": "list", "ls", "l":
debug_print_line("\nAliases: 'list', 'ls', 'l'\n") debug_print_line(" [path]\nAliases: 'list', 'ls', 'l'\n")
debug_print_line("Lists the currently active scenes\n") debug_print_line("List node children\n")
"restart", "killall": "restart", "killall":
debug_print_line("\nAliases: 'restart', 'killall'\n") debug_print_line("\nAliases: 'restart', 'killall'\n")
debug_print_line("Kills the current scene tree and plants a new Root.\n") debug_print_line("Kill the current scene tree and plant a new Root.\n")
"print", "p": "print", "p":
debug_print_line(" string\nAliases: 'print', 'p'\n") debug_print_line(" string\nAliases: 'print', 'p'\n")
debug_print_line("Prints a string to the in-game debug console\n") debug_print_line("Prints a string to the in-game debug console\n")
@ -189,6 +197,20 @@ func command_help (command):
"help", "h": "help", "h":
debug_print_line(" [command]\nAliases: 'help', 'h'\n") debug_print_line(" [command]\nAliases: 'help', 'h'\n")
debug_print_line("Prints information about a command.\n") debug_print_line("Prints information about a command.\n")
"pwd", "pwn":
debug_print_line("\nAliases: 'pwn', 'pwd'\n")
debug_print_line("Prints the Present Working Node.\n")
"cd", "cn":
debug_print_line(" path/to/node\nAliases: 'cn', 'cd'\n")
debug_print_line("Change the Present Working Node.\n")
_: _:
debug_print_line(command[1] + "\nIsn't a valid command\n") debug_print_line(command[1] + "\nIsn't a valid command\n")
debug_print_line("\n")
# Completes a relative or absolute path, and returns the node it refers to
func complete_path(path):
if path.is_rel_path(): # convert to absolute path
path = String(present_working_node.get_path()) + "/" + path
var node = get_node(path)
if node:
return node
return null

View File

@ -8,8 +8,7 @@ extends Control
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
grab_focus() if find_next_valid_focus(): find_next_valid_focus().grab_focus()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta): #func _process(delta):

View File

@ -58,13 +58,10 @@ func _on_scene_start_by_name(scene):
# Kills all child nodes with name matching `scene` # Kills all child nodes with name matching `scene`
func _on_scene_kill(scene): func _on_scene_kill(scene):
var c = get_children() var node = find_node(scene, false, false)
for i in range (c.size()): if node :
if c[i].name == scene: node.queue_free()
c[i].queue_free() MessageBus.emit_signal("print_console", String(node.name) + " killed.\n".c_unescape())
MessageBus.emit_signal("print_console", String(c[i].name) + " killed.\n".c_unescape())
return true
return false
func _on_scene_list(): func _on_scene_list():
var children = get_children() var children = get_children()

View File

@ -1,10 +1,33 @@
extends Control extends Control
onready var sound_slider = find_node("SFX Slider", true, true)
onready var music_slider = find_node("Volume Slider", true, true)
onready var theme_buttons = find_node("Buttons", true, true).get_children()
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
find_next_valid_focus().grab_focus() find_next_valid_focus().grab_focus()
sound_slider.value = OptionsController.get_sfx_volume()
music_slider.value = OptionsController.get_mus_volume()
func _on_Button_pressed(): func _on_Button_pressed():
queue_free() queue_free()
MessageBus.emit_signal("change_scene", "Title") MessageBus.emit_signal("change_scene", "Title")
func _on_SFX_Slider_value_changed(value):
OptionsController.set_sfx_vol(value)
func _on_Volume_Slider_value_changed(value):
OptionsController.set_mus_vol(value)
func _on_Light_pressed():
OptionsController.set_theme("light")
func _on_Dark_pressed():
OptionsController.set_theme("dark")

View File

@ -0,0 +1,36 @@
extends Node
# signals
# Subscribe to these if you want to be notified about changes to the volume
signal change_theme (theme)
signal change_mus_volume (volume)
signal change_sfx_volume (volume)
# Option variables
var theme = "dark"
var mus_vol = 100
var sfx_vol = 100
func _ready():
pass
# Setters
func set_theme(theme_name):
match theme_name:
"dark","light":
theme = String(theme_name)
emit_signal("change_theme", theme)
func set_mus_vol(volume):
mus_vol = volume
emit_signal("change_mus_volume", mus_vol)
func set_sfx_vol(volume):
sfx_vol = volume
emit_signal("change_sfx_volume", sfx_vol)
# Getters
func get_theme():
return theme
func get_mus_volume():
return mus_vol
func get_sfx_volume():
return sfx_vol

View File

@ -1,9 +1,5 @@
extends Control extends Control
# Declare member variables here:
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
$VBoxContainer/Singleplayer.grab_focus() $VBoxContainer/Singleplayer.grab_focus()