aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Autoload
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-12-24 19:23:18 +0100
committer GitHub <noreply@github.com>2023-12-24 19:23:18 +0100
commitd26c990d9a5596a3ef3b32ba1cb0f99950cd6d34 (patch)
tree1b99c935438692bb2ebadeac412b990c82089b65 /game/src/Game/Autoload
parent50b0b935b0bf0724f40b5140aca85d1830a8b1b3 (diff)
parentb6413251a866c76538869b84ed1c9b9852f7c507 (diff)
Merge pull request #178 from Spartan322/add-menu-type-hints
Diffstat (limited to 'game/src/Game/Autoload')
-rw-r--r--game/src/Game/Autoload/Argument/ArgumentOption.gd12
-rw-r--r--game/src/Game/Autoload/Argument/ArgumentParser.gd22
-rw-r--r--game/src/Game/Autoload/Events.gd2
-rw-r--r--game/src/Game/Autoload/Events/Options.gd2
-rw-r--r--game/src/Game/Autoload/GameLoader.gd2
-rw-r--r--game/src/Game/Autoload/GuiScale.gd6
-rw-r--r--game/src/Game/Autoload/Resolution.gd4
-rw-r--r--game/src/Game/Autoload/SaveManager.gd2
-rw-r--r--game/src/Game/Autoload/SoundManager.gd6
-rw-r--r--game/src/Game/Autoload/WindowOverride.gd6
10 files changed, 33 insertions, 31 deletions
diff --git a/game/src/Game/Autoload/Argument/ArgumentOption.gd b/game/src/Game/Autoload/Argument/ArgumentOption.gd
index f98b19c..a9b7000 100644
--- a/game/src/Game/Autoload/Argument/ArgumentOption.gd
+++ b/game/src/Game/Autoload/Argument/ArgumentOption.gd
@@ -17,10 +17,10 @@ extends Resource
TYPE_COLOR: default_value = Color()
_: default_value = null
notify_property_list_changed()
-var default_value
+var default_value : Variant
@export var description : String
-func _init(_name = "", _type = TYPE_NIL, _description = "", default = null):
+func _init(_name := "", _type := TYPE_NIL, _description := "", default : Variant = null) -> void:
name = _name
type = _type
if default != null and typeof(default) == type:
@@ -41,15 +41,17 @@ func get_type_string() -> StringName:
TYPE_COLOR: return "color"
return "<invalid type>"
-func _get(property):
+func _get(property : StringName) -> Variant:
if property == "default_value": return default_value
+ return null
-func _set(property, value):
+func _set(property : StringName, value : Variant) -> bool:
if property == "default_value":
default_value = value
return true
+ return false
-func _get_property_list():
+func _get_property_list() -> Array[Dictionary]:
var properties := []
properties.append({
diff --git a/game/src/Game/Autoload/Argument/ArgumentParser.gd b/game/src/Game/Autoload/Argument/ArgumentParser.gd
index b012215..b3e8632 100644
--- a/game/src/Game/Autoload/Argument/ArgumentParser.gd
+++ b/game/src/Game/Autoload/Argument/ArgumentParser.gd
@@ -46,7 +46,7 @@ const color_name_array : PackedStringArray =[
func has_argument_support(arg_name : StringName, include_aliases : bool = false) -> bool:
return option_array.any(
- func(opt):
+ func(opt : ArgumentOption) -> bool:
if include_aliases and arg_name in opt.aliases:
return true
return opt.name == arg_name
@@ -54,7 +54,7 @@ func has_argument_support(arg_name : StringName, include_aliases : bool = false)
func get_argument(arg_name : StringName, default_val : Variant = null) -> Variant:
if ProjectSettings.has_setting(argument_setting_path):
- var arg_setting = ProjectSettings.get_setting_with_override(argument_setting_path)
+ var arg_setting : Variant = ProjectSettings.get_setting_with_override(argument_setting_path)
if not arg_setting is Dictionary:
push_error("Argument setting is not a dictionary.")
return default_val
@@ -64,7 +64,7 @@ func get_argument(arg_name : StringName, default_val : Variant = null) -> Varian
func set_argument(arg_name : StringName, value : Variant) -> void:
if ProjectSettings.has_setting(argument_setting_path):
- var arg_setting = null
+ var arg_setting : Variant = null
arg_setting = ProjectSettings.get_setting_with_override(argument_setting_path)
if not arg_setting is Dictionary:
push_error("Argument setting is not a dictionary.")
@@ -124,7 +124,7 @@ func _parse_value(arg_name : StringName, value_string : String, type : Variant.T
TYPE_RECT2, \
TYPE_RECT2I:
push_warning("Value type '%s' may not be supported." % type)
- var data_array = value_string.lstrip("(").rstrip(")").split(",", false)
+ var data_array := value_string.lstrip("(").rstrip(")").split(",", false)
for index in range(data_array.size()):
data_array[index] = " " + data_array[index].strip_edges()
match type:
@@ -206,7 +206,7 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray)
var current_option : ArgumentOption = null
for arg in arg_list:
if current_option != null and not arg.begins_with("-"):
- var result = _parse_value(current_key, arg, current_option.type)
+ var result : Variant = _parse_value(current_key, arg, current_option.type)
if result != null:
dictionary[current_option.name] = result
current_option = null
@@ -229,8 +229,8 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray)
push_warning("Parsing shorthand alias containing '%s', perhaps you meant '--%s'? Skipping argument." % [c, arg])
break
var alias_found := false
- for o in option_array:
- if o.aliases.any(func(v): return c == v):
+ for o : ArgumentOption in option_array:
+ if o.aliases.any(func(v : StringName) -> bool: return c == v):
if o.type == TYPE_BOOL:
dictionary[o.name] = true
else:
@@ -258,7 +258,7 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray)
key = key.substr(1)
for o in option_array:
- if key == o.name or o.aliases.any(func(v): return key == v):
+ if key == o.name or o.aliases.any(func(v : StringName) -> bool: return key == v):
current_option = o
break
@@ -268,7 +268,7 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray)
current_key = key
if first_equal > -1:
- var arg_result = _parse_value(key, value, current_option.type)
+ var arg_result : Variant = _parse_value(key, value, current_option.type)
if arg_result != null:
dictionary[current_option.name] = arg_result
current_option = null
@@ -279,7 +279,7 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray)
return dictionary
-func _print_help():
+func _print_help() -> void:
var project_name : StringName = ProjectSettings.get_setting_with_override(&"application/config/name")
var project_version : String = _GIT_INFO_.tag
var project_hash : String = _GIT_INFO_.short_hash
@@ -310,7 +310,7 @@ Options:
option.description
])
-func _ready():
+func _ready() -> void:
if Engine.is_editor_hint(): return
_set_argument_setting()
GameDebug._singleton = GameDebug.new()
diff --git a/game/src/Game/Autoload/Events.gd b/game/src/Game/Autoload/Events.gd
index da29adb..4f38f61 100644
--- a/game/src/Game/Autoload/Events.gd
+++ b/game/src/Game/Autoload/Events.gd
@@ -5,5 +5,5 @@ extends Node
var Options: OptionsEventsObject
-func _init():
+func _init() -> void:
Options = OptionsEventsObject.new()
diff --git a/game/src/Game/Autoload/Events/Options.gd b/game/src/Game/Autoload/Events/Options.gd
index 726960b..f3fd706 100644
--- a/game/src/Game/Autoload/Events/Options.gd
+++ b/game/src/Game/Autoload/Events/Options.gd
@@ -31,6 +31,6 @@ var _settings_file := ConfigFile.new()
# * SS-9
# * UIFUN-7, UIFUN-12
# * FS-562
-func _init():
+func _init() -> void:
if FileAccess.file_exists(_settings_file_path):
_settings_file.load(_settings_file_path)
diff --git a/game/src/Game/Autoload/GameLoader.gd b/game/src/Game/Autoload/GameLoader.gd
index 8c14c7e..000ee20 100644
--- a/game/src/Game/Autoload/GameLoader.gd
+++ b/game/src/Game/Autoload/GameLoader.gd
@@ -2,5 +2,5 @@ extends Node
var ShaderManager : ShaderManagerClass
-func _init():
+func _init() -> void:
ShaderManager = ShaderManagerClass.new()
diff --git a/game/src/Game/Autoload/GuiScale.gd b/game/src/Game/Autoload/GuiScale.gd
index d364ff5..b8af59c 100644
--- a/game/src/Game/Autoload/GuiScale.gd
+++ b/game/src/Game/Autoload/GuiScale.gd
@@ -18,9 +18,9 @@ var _guiscales: Dictionary
#Similar to Resolution.gd, but we don't bother checking for strings from files
#and we have floats instead of vector2 integers
-func _ready():
+func _ready() -> void:
assert(minimum_guiscale > 0, "Minimum gui scale must be positive")
- for guiscale_value in _starting_guiscales:
+ for guiscale_value : float in _starting_guiscales:
add_guiscale(guiscale_value, _starting_guiscales[guiscale_value])
assert(not _guiscales.is_empty(), "No valid starting gui scales!")
@@ -43,7 +43,7 @@ func add_guiscale(guiscale_value: float, guiscale_name: StringName=&"") -> bool:
#returns floats
func get_guiscale_value_list() -> Array:
var list := _guiscales.keys()
- list.sort_custom(func(a, b): return a > b)
+ list.sort_custom(func(a : float, b : float) -> bool: return a > b)
return list
func get_guiscale_display_name(guiscale_value : float) -> StringName:
diff --git a/game/src/Game/Autoload/Resolution.gd b/game/src/Game/Autoload/Resolution.gd
index 73169fb..9dddb29 100644
--- a/game/src/Game/Autoload/Resolution.gd
+++ b/game/src/Game/Autoload/Resolution.gd
@@ -27,7 +27,7 @@ var _resolutions : Array[Vector2i]
const _regex_pattern : String = "(\\d+)\\s*[xX,]\\s*(\\d+)"
var _regex : RegEx
-func _ready():
+func _ready() -> void:
assert(minimum_resolution.x > 0 and minimum_resolution.y > 0, "Minimum resolution must be positive!")
for resolution_value in _starting_resolutions:
add_resolution(resolution_value)
@@ -53,7 +53,7 @@ func get_resolution_value_list() -> Array[Vector2i]:
var list : Array[Vector2i] = []
# Return a sorted copy instead of a reference to the private array
list.append_array(_resolutions)
- list.sort_custom(func(a, b): return a > b)
+ list.sort_custom(func(a : Vector2i, b : Vector2i) -> bool: return a > b)
return list
func get_resolution_value_from_string(resolution_string : String) -> Vector2i:
diff --git a/game/src/Game/Autoload/SaveManager.gd b/game/src/Game/Autoload/SaveManager.gd
index fb7806b..eead63c 100644
--- a/game/src/Game/Autoload/SaveManager.gd
+++ b/game/src/Game/Autoload/SaveManager.gd
@@ -10,7 +10,7 @@ var current_session_tag : StringName
var _save_dictionary : Dictionary = {}
var _dirty_save : SaveResource
-func _ready():
+func _ready() -> void:
var saves_dir_path : String = ProjectSettings.get_setting_with_override(save_directory_setting)
assert(saves_dir_path != null, "'%s' setting could not be found." % save_directory_setting)
diff --git a/game/src/Game/Autoload/SoundManager.gd b/game/src/Game/Autoload/SoundManager.gd
index c58ce1a..a8a8e80 100644
--- a/game/src/Game/Autoload/SoundManager.gd
+++ b/game/src/Game/Autoload/SoundManager.gd
@@ -11,9 +11,9 @@ var _bus_to_stream_player : Dictionary = {}
# REQUIREMENTS:
# * SND-10
-func _ready():
- var dir = DirAccess.open(_audio_directory_path)
- for fname in dir.get_files():
+func _ready() -> void:
+ var dir := DirAccess.open(_audio_directory_path)
+ for fname : String in dir.get_files():
match fname.get_extension():
"ogg", "wav", "mp3":
_loaded_sound[fname.get_basename()] = load(_audio_directory_path.path_join(fname)) # SND-10
diff --git a/game/src/Game/Autoload/WindowOverride.gd b/game/src/Game/Autoload/WindowOverride.gd
index 837570e..578aee0 100644
--- a/game/src/Game/Autoload/WindowOverride.gd
+++ b/game/src/Game/Autoload/WindowOverride.gd
@@ -2,11 +2,11 @@ extends Node
const VideoOptions = preload("res://src/Game/Menu/OptionMenu/VideoTab.tscn")
-func _init():
+func _init() -> void:
var window_id := DisplayServer.get_window_list()[0]
DisplayServer.window_set_size(Vector2(1280.0, 720.0), window_id)
-func _ready():
+func _ready() -> void:
if ArgumentParser.get_argument(&"help"): return
_on_SceneTree_idle()
# Hack to ensure Video Options load
@@ -15,7 +15,7 @@ func _ready():
add_child(video)
video.queue_free()
-func _on_SceneTree_idle():
+func _on_SceneTree_idle() -> void:
var window := get_window()
window.set_mode(Window.MODE_FULLSCREEN)
await get_tree().process_frame