1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-15 05:25:57 +00:00
This commit is contained in:
tommy-l-ngo 2021-10-31 20:23:58 -05:00
commit 448f3a0262
5 changed files with 91 additions and 28 deletions

View File

@ -0,0 +1,41 @@
[preset.0]
name="Windows Desktop x64"
platform="Windows Desktop"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../../godot_ship.exe"
script_export_mode=1
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
binary_format/64_bits=true
binary_format/embed_pck=false
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
codesign/enable=false
codesign/identity_type=0
codesign/identity=""
codesign/password=""
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PoolStringArray( )
application/icon=""
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""

View File

@ -1,10 +1,7 @@
extends Control extends Control
var debug_output
var debug_line = 0
var debug_canvas var debug_canvas
var debug_transform
var debug_active = false var debug_active = false
var menu_position = 0.0 var menu_position = 0.0
@ -35,6 +32,8 @@ var helptext = {
"command_restart": ["", "Kill the current scene tree and plant a new Root.\n" ], "command_restart": ["", "Kill the current scene tree and plant a new Root.\n" ],
"command_exit": ["", "Quits the program.\n" ], "command_exit": ["", "Quits the program.\n" ],
"command_empty": ["", "No Operation.\n" ],
} }
# List of debug commands accessed by alias # List of debug commands accessed by alias
@ -60,7 +59,9 @@ var commands = {
["restart", "killall"]: "command_restart", ["restart", "killall"]: "command_restart",
["exit", "quit"]: "command_exit", ["exit", "quit"]: "command_exit",
}
[""]: "command_empty"
}
onready var present_working_node = get_node("/root/Main") onready var present_working_node = get_node("/root/Main")
@ -84,8 +85,6 @@ signal history_event(text)
# returns: void # returns: void
func _ready(): func _ready():
debug_canvas = get_node("debug_canvas") debug_canvas = get_node("debug_canvas")
debug_transform = debug_canvas.get_transform()
debug_output = get_node("debug_canvas/VBoxContainer/TextEdit")
command_help([""]) command_help([""])
debug_print_line("> ") debug_print_line("> ")
@ -129,6 +128,7 @@ func _input(event):
# params: line: Line of text entered by user # params: line: Line of text entered by user
# returns: void # returns: void
func _on_LineEdit_text_entered(line): func _on_LineEdit_text_entered(line):
if line != "":
history_append(line) history_append(line)
emit_signal("clear_in") emit_signal("clear_in")
debug_print_line(line + "\n") debug_print_line(line + "\n")
@ -147,6 +147,7 @@ func _on_LineEdit_text_entered(line):
func history_append(text): func history_append(text):
history.resize(history_pos + 2) history.resize(history_pos + 2)
history[history_pos] = text history[history_pos] = text
history[history_pos + 1] = ""
history_pos += 1 history_pos += 1
# history_move: Traverse the history and update the user input box # history_move: Traverse the history and update the user input box
@ -220,7 +221,7 @@ func command_start (command):
if command.size() > 1: if command.size() > 1:
var pack = load("res://scenes/" + command[1] + ".tscn"); var pack = load("res://scenes/" + command[1] + ".tscn");
present_working_node.add_child(pack.instance()); present_working_node.add_child(pack.instance());
debug_print_line("start '" + command[1] + "'\n") debug_print_line("started '" + command[1] + "'\n")
else: else:
debug_print_line(get_usage(command[0])) debug_print_line(get_usage(command[0]))
@ -333,8 +334,8 @@ func command_call(command):
debug_print_line("We're sorry, but your call could not be completed as dialed.\n" debug_print_line("We're sorry, but your call could not be completed as dialed.\n"
+ "Please hang up and try your call again.\n") + "Please hang up and try your call again.\n")
return return
if (call_ret): if (call_ret != null):
debug_print_line("'" + String(call_ret) + "'\n") debug_print_line(String(call_ret) + "\n")
else: else:
debug_print_line("null\n") debug_print_line("null\n")
else: else:
@ -347,7 +348,7 @@ func command_history(_command):
if line: if line:
debug_print_line(String(lnum) + ": " + line + "\n") debug_print_line(String(lnum) + ": " + line + "\n")
lnum += 1 lnum += 1
debug_print_line("history_pos = " + String(history_pos) + "\n") #debug_print_line("history_pos = " + String(history_pos) + "\n")
# perf: Print the value of a Godot Engine performance counter # perf: Print the value of a Godot Engine performance counter
func command_perf(command): func command_perf(command):
@ -375,3 +376,7 @@ func perf(attribute):
"resources": "resources":
return Performance.get_monitor(Performance.OBJECT_RESOURCE_COUNT) return Performance.get_monitor(Performance.OBJECT_RESOURCE_COUNT)
return "" return ""
# empty: No command
func command_empty(_command):
pass

View File

@ -42,7 +42,7 @@ func _process(_delta):
# Creates a new instance of each menu scene # Creates a new instance of each menu scene
func _on_scene_start(scene): func _on_scene_start(scene):
print ("_on_scene_start(",scene,")") #print ("_on_scene_start(",scene,")")
match scene: match scene:
"Singleplayer": "Singleplayer":
add_child (gameplay.instance()) add_child (gameplay.instance())

View File

@ -7,27 +7,27 @@ 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():
OptionsController.load_options()
find_next_valid_focus().grab_focus() find_next_valid_focus().grab_focus()
sound_slider.value = OptionsController.get_sfx_volume() sound_slider.value = OptionsController.get_sfx_volume()
music_slider.value = OptionsController.get_mus_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): func _on_SFX_Slider_value_changed(value):
OptionsController.set_sfx_vol(value) OptionsController.set_sfx_vol(value)
OptionsController.save_options()
func _on_Volume_Slider_value_changed(value): func _on_Volume_Slider_value_changed(value):
OptionsController.set_mus_vol(value) OptionsController.set_mus_vol(value)
OptionsController.save_options()
func _on_Light_pressed(): func _on_Light_pressed():
OptionsController.set_theme("light") OptionsController.set_theme("light")
OptionsController.save_options()
func _on_Dark_pressed(): func _on_Dark_pressed():
OptionsController.set_theme("dark") OptionsController.set_theme("dark")
OptionsController.save_options()

View File

@ -7,12 +7,14 @@ signal change_mus_volume (volume)
signal change_sfx_volume (volume) signal change_sfx_volume (volume)
# Option variables # Option variables
var f = File.new()
var options_file = "user://options.save"
var theme = "dark" var theme = "dark"
var mus_vol = 100 var mus_vol = 100
var sfx_vol = 100 var sfx_vol = 100
func _ready(): func _ready():
pass load_options()
# Setters # Setters
func set_theme(theme_name): func set_theme(theme_name):
@ -27,6 +29,21 @@ func set_sfx_vol(volume):
sfx_vol = volume sfx_vol = volume
emit_signal("change_sfx_volume", sfx_vol) emit_signal("change_sfx_volume", sfx_vol)
#Option Save File
func save_options():
f.open(options_file, File.WRITE)
f.store_var(theme)
f.store_var(mus_vol)
f.store_var(sfx_vol)
f.close()
func load_options():
if f.file_exists(options_file):
f.open(options_file, File.READ)
theme = f.get_var()
mus_vol = f.get_var()
sfx_vol = f.get_var()
f.close()
# Getters # Getters
func get_theme(): func get_theme():
return theme return theme