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

Partial refactor of debug menu and Main script

This commit is contained in:
John 2021-10-29 17:39:46 -05:00
parent 909773a65b
commit 05ddde9788
2 changed files with 24 additions and 22 deletions

View File

@ -141,18 +141,21 @@ func _on_LineEdit_text_entered(line):
debug_print_line("> ")
# History_related helper functions:
# history_append: add a line of text to the history
# params: text: line of text (unparsed command) to add to history
# returns: void
func history_append(text):
history.resize(history_pos + 2)
history[history_pos] = text
history_pos += 1
func history_move(direction):
if history_pos + direction < 0:
pass
elif history_pos + direction >= history.size():
pass
else:
history_pos += direction;
# history_move: Traverse the history and update the user input box
# params: rel_pos: amount to move, relative to the current history_pos
# returns: void
func history_move(rel_pos):
var new_pos = history_pos + rel_pos
if new_pos >= 0 and new_pos < history.size():
history_pos = new_pos;
if history[history_pos]:
emit_signal("history_event", history[history_pos])
else:
@ -205,6 +208,8 @@ func get_canonical(alias):
return null
# get_usage: Construct the usage string for a command
# params: alias: alias of a command
# returns: usage string for the command, formatted for printing
func get_usage(alias):
return "Usage: " + alias + helptext[parse(alias)][0] + "\n"
@ -335,6 +340,7 @@ func command_call(command):
else:
debug_print_line(get_usage(command[0]))
# history: print the command history
func command_history(_command):
var lnum = 0
for line in history:
@ -343,6 +349,7 @@ func command_history(_command):
lnum += 1
debug_print_line("history_pos = " + String(history_pos) + "\n")
# perf: Print the value of a Godot Engine performance counter
func command_perf(command):
if command.size() > 1:
var stat = perf(command[1])

View File

@ -1,10 +1,10 @@
extends Control
# Scenes
var title_screen
var gameplay
var options
var debug_menu
onready var title_screen = preload("res://scenes/Title Screen.tscn")
onready var gameplay = preload("res://scenes/Gameplay.tscn" )
onready var options = preload("res://scenes/Options.tscn" )
onready var debug_menu = preload("res://scenes/Debug Menu.tscn" )
var debug_enabled = true
var start_fullscreen = false
@ -13,17 +13,12 @@ var start_fullscreen = false
func _ready():
# Connect to signals
var _errno = 0;
_errno += MessageBus.connect("start_tcsn", self, "_on_scene_start_by_name")
_errno += MessageBus.connect("change_scene", self, "_on_scene_start")
_errno += MessageBus.connect("kill_scene", self, "_on_scene_kill")
_errno += MessageBus.connect("list_scenes", self, "_on_scene_list")
_errno += MessageBus.connect("quit", self, "_on_quit_request")
_errno += 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")
_errno += MessageBus.connect("start_tcsn" , self, "_on_scene_start_by_name")
_errno += MessageBus.connect("change_scene" , self, "_on_scene_start" )
_errno += MessageBus.connect("kill_scene" , self, "_on_scene_kill" )
_errno += MessageBus.connect("list_scenes" , self, "_on_scene_list" )
_errno += MessageBus.connect("quit" , self, "_on_quit_request" )
_errno += MessageBus.connect("return_to_title", self, "_on_title_request" )
# go fullscreen
if start_fullscreen:
OS.window_fullscreen = true