aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-03-03 17:39:08 +0100
committer hop311 <hop3114@gmail.com>2024-03-03 17:39:08 +0100
commite2077a0d93be8b2dd48f1ee680809420f1f690d7 (patch)
treebacc8f4094eff5514a94b3852e9cec9c28391669 /game/src/Game
parent9ee1940ac3d15aa4c0a87b84d1c4ab8958184f63 (diff)
Add types to GDScript for-loop variablesfor-loop-types
Diffstat (limited to 'game/src/Game')
-rw-r--r--game/src/Game/Autoload/Argument/ArgumentParser.gd12
-rw-r--r--game/src/Game/Autoload/Resolution.gd2
-rw-r--r--game/src/Game/Autoload/SaveManager.gd2
-rw-r--r--game/src/Game/GameSession/Topbar.gd4
-rw-r--r--game/src/Game/GlobalClass/Localisation.gd4
-rw-r--r--game/src/Game/LocaleButton.gd2
-rw-r--r--game/src/Game/Menu/LobbyMenu/LobbyMenu.gd2
-rw-r--r--game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd6
-rw-r--r--game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd2
-rw-r--r--game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd4
-rw-r--r--game/src/Game/Menu/OptionMenu/ResolutionSelector.gd6
-rw-r--r--game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd2
-rw-r--r--game/src/Game/Menu/OptionMenu/VolumeGrid.gd2
-rw-r--r--game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd6
-rw-r--r--game/src/Game/MusicConductor/MusicConductor.gd6
-rw-r--r--game/src/Game/MusicConductor/MusicPlayer.gd2
-rw-r--r--game/src/Game/Theme/StyleBoxCombinedTexture.gd6
17 files changed, 34 insertions, 36 deletions
diff --git a/game/src/Game/Autoload/Argument/ArgumentParser.gd b/game/src/Game/Autoload/Argument/ArgumentParser.gd
index 1b68cad..4ce8b64 100644
--- a/game/src/Game/Autoload/Argument/ArgumentParser.gd
+++ b/game/src/Game/Autoload/Argument/ArgumentParser.gd
@@ -78,7 +78,7 @@ func _set_argument_setting() -> void:
var argument_dictionary : Dictionary = {}
if ProjectSettings.has_setting(argument_setting_path):
argument_dictionary = ProjectSettings.get_setting_with_override(argument_setting_path)
- for option in option_array:
+ for option : ArgumentOption in option_array:
argument_dictionary[option.name] = option.default_value
_parse_argument_list(argument_dictionary, OS.get_cmdline_args())
@@ -125,7 +125,7 @@ func _parse_value(arg_name : StringName, value_string : String, type : Variant.T
TYPE_RECT2I:
push_warning("Value type '%s' may not be supported." % type)
var data_array := value_string.lstrip("(").rstrip(")").split(",", false)
- for index in range(data_array.size()):
+ for index : int in data_array.size():
data_array[index] = " " + data_array[index].strip_edges()
match type:
TYPE_VECTOR2:
@@ -210,7 +210,7 @@ func _add_argument(dictionary : Dictionary, option : ArgumentOption, argument :
func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray, is_game_args : bool = false) -> Dictionary:
var current_key : String = ""
var current_option : ArgumentOption = null
- for arg in arg_list:
+ for arg : String in arg_list:
if current_option != null:
if not arg.begins_with("-"):
var result : Variant = _parse_value(current_key, arg, current_option.type)
@@ -230,7 +230,7 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray,
# Support for Unix shorthand of multiple boolean arguments
# eg: "-abc" means a == true, b == true, c == true
if arg.length() > 1 and arg[0] != "-" and arg[1] != "=":
- for c in arg:
+ for c : String in arg:
if not ((c >= "a" and c <= "z") or (c >= "A" and c <= "Z")):
push_warning("Parsing shorthand alias containing '%s', perhaps you meant '--%s'? Skipping argument." % [c, arg])
break
@@ -263,7 +263,7 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray,
if key.length() > 2 and key.begins_with("-"):
key = key.substr(1)
- for o in option_array:
+ for o : ArgumentOption in option_array:
if key == o.name or o.aliases.any(func(v : StringName) -> bool: return key == v):
current_option = o
break
@@ -311,7 +311,7 @@ Options:
"usage: %s [options]" % OS.get_executable_path().get_file()
]
)
- for option in option_array:
+ for option : ArgumentOption in option_array:
print_rich(" --%s%s%s" % [
(option.name + (",-%s" % (",-".join(option.aliases)) if option.aliases.size() > 0 else "")).rpad(45),
("Type: %s - Default Value: %s" % [option.get_type_string(), option.default_value]).rpad(45),
diff --git a/game/src/Game/Autoload/Resolution.gd b/game/src/Game/Autoload/Resolution.gd
index 9dddb29..c25c9fd 100644
--- a/game/src/Game/Autoload/Resolution.gd
+++ b/game/src/Game/Autoload/Resolution.gd
@@ -29,7 +29,7 @@ var _regex : RegEx
func _ready() -> void:
assert(minimum_resolution.x > 0 and minimum_resolution.y > 0, "Minimum resolution must be positive!")
- for resolution_value in _starting_resolutions:
+ for resolution_value : Vector2i in _starting_resolutions:
add_resolution(resolution_value)
assert(not _resolutions.is_empty(), "No valid starting resolutions!")
diff --git a/game/src/Game/Autoload/SaveManager.gd b/game/src/Game/Autoload/SaveManager.gd
index eead63c..688e163 100644
--- a/game/src/Game/Autoload/SaveManager.gd
+++ b/game/src/Game/Autoload/SaveManager.gd
@@ -16,7 +16,7 @@ func _ready() -> void:
DirAccess.make_dir_recursive_absolute(saves_dir_path)
var saves_dir := DirAccess.open(saves_dir_path)
- for file in saves_dir.get_files():
+ for file : String in saves_dir.get_files():
var save := SaveResource.new()
save.load_save(saves_dir_path.path_join(file))
add_or_replace_save(save, true)
diff --git a/game/src/Game/GameSession/Topbar.gd b/game/src/Game/GameSession/Topbar.gd
index 82dd4d3..b61af28 100644
--- a/game/src/Game/GameSession/Topbar.gd
+++ b/game/src/Game/GameSession/Topbar.gd
@@ -67,7 +67,7 @@ func _ready() -> void:
NationManagement.Screen.DIPLOMACY : ^"./topbar/topbarbutton_diplomacy",
NationManagement.Screen.MILITARY : ^"./topbar/topbarbutton_military"
}
- for screen in screen_nodepaths:
+ for screen : NationManagement.Screen in screen_nodepaths:
var button : Button = get_button_from_nodepath(screen_nodepaths[screen])
if button:
button.pressed.connect(
@@ -127,5 +127,5 @@ func _on_decrease_speed_button_pressed() -> void:
GameSingleton.decrease_speed()
func _on_update_active_nation_management_screen(active_screen : NationManagement.Screen) -> void:
- for screen in _nation_management_buttons:
+ for screen : NationManagement.Screen in _nation_management_buttons:
_nation_management_button_textures[screen].set_icon_index(1 + int(screen == active_screen))
diff --git a/game/src/Game/GlobalClass/Localisation.gd b/game/src/Game/GlobalClass/Localisation.gd
index 78afb69..25232ef 100644
--- a/game/src/Game/GlobalClass/Localisation.gd
+++ b/game/src/Game/GlobalClass/Localisation.gd
@@ -4,12 +4,12 @@ extends RefCounted
# REQUIREMENTS
# * SS-59, SS-60, SS-61
static func get_default_locale() -> String:
- var locales := TranslationServer.get_loaded_locales()
+ var locales : PackedStringArray = TranslationServer.get_loaded_locales()
var default_locale := OS.get_locale()
if default_locale in locales:
return default_locale
var default_language := OS.get_locale_language()
- for locale in locales:
+ for locale : String in locales:
if locale.begins_with(default_language):
return default_language
return ProjectSettings.get_setting("internationalization/locale/fallback", "en_GB")
diff --git a/game/src/Game/LocaleButton.gd b/game/src/Game/LocaleButton.gd
index e315330..8dc6b06 100644
--- a/game/src/Game/LocaleButton.gd
+++ b/game/src/Game/LocaleButton.gd
@@ -53,7 +53,7 @@ func load_setting(file : ConfigFile) -> void:
reset_setting()
func _select_locale_by_string(locale : String) -> bool:
- for idx in item_count:
+ for idx : int in item_count:
if get_item_metadata(idx) == locale:
selected = idx
return true
diff --git a/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd b/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd
index cc681ba..f747727 100644
--- a/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd
+++ b/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd
@@ -21,7 +21,7 @@ signal start_date_selected(index : int)
@export var delete_dialog : ConfirmationDialog
func filter_for_tag(tag : StringName) -> void:
- for child in game_select_save_list.get_children():
+ for child : Control in game_select_save_list.get_children():
if tag == &"":
child.show()
else:
diff --git a/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd
index 646c694..b50ee28 100644
--- a/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd
+++ b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd
@@ -29,8 +29,7 @@ func set_text(value : StringName) -> void:
func _get_minimum_size() -> Vector2:
var result := Vector2()
- for child in get_children():
- child = child as Control
+ for child : Control in get_children():
if child == null or not child.visible:
continue
if child.top_level:
@@ -82,8 +81,7 @@ func _notification(what : int) -> void:
_size -= style.get_minimum_size()
offset += style.get_offset()
- for child in get_children():
- child = child as Control
+ for child : Control in get_children():
if child == null or not child.is_visible_in_tree() or child.top_level:
continue
diff --git a/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd b/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd
index 3be8c2c..f3c7b22 100644
--- a/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd
+++ b/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd
@@ -8,7 +8,7 @@ extends SettingOptionButton
var default_value : float = GuiScale.error_guiscale
func _find_guiscale_index_by_value(value : float) -> int:
- for item_index in item_count:
+ for item_index : int in item_count:
if get_item_metadata(item_index) == value:
return item_index
return -1
diff --git a/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd b/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd
index a535f17..44f89f0 100644
--- a/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd
+++ b/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd
@@ -2,7 +2,7 @@ extends SettingRevertButton
func _setup_button() -> void:
clear()
- for screen_index in DisplayServer.get_screen_count():
+ for screen_index : int in DisplayServer.get_screen_count():
# Placeholder option text awaiting _update_monitor_options_text()
add_item(str(screen_index + 1))
_update_monitor_options_text()
@@ -14,7 +14,7 @@ func _notification(what : int) -> void:
_update_monitor_options_text()
func _update_monitor_options_text() -> void:
- for index in get_item_count():
+ for index : int in get_item_count():
set_item_text(index, tr("OPTIONS_VIDEO_MONITOR").format({ "index": Localisation.tr_number(index + 1) }))
func _on_option_selected(index : int, by_user : bool) -> void:
diff --git a/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
index 1a21211..dfaae37 100644
--- a/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
+++ b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
@@ -6,7 +6,7 @@ extends SettingRevertButton
@export var default_value : Vector2i = Resolution.error_resolution
func _find_resolution_index_by_value(value : Vector2i) -> int:
- for item_index in item_count:
+ for item_index : int in item_count:
if get_item_metadata(item_index) == value:
return item_index
return -1
@@ -16,7 +16,7 @@ func _sync_resolutions() -> void:
default_selected = -1
selected = -1
var current_resolution := Resolution.get_current_resolution()
- for resolution_value in Resolution.get_resolution_value_list():
+ for resolution_value : Vector2i in Resolution.get_resolution_value_list():
# Placeholder option text awaiting _update_resolution_options_text()
add_item(str(resolution_value))
set_item_metadata(item_count - 1, resolution_value)
@@ -40,7 +40,7 @@ func _notification(what : int) -> void:
_update_resolution_options_text()
func _update_resolution_options_text() -> void:
- for index in get_item_count():
+ for index : int in get_item_count():
var resolution_value : Vector2i = get_item_metadata(index)
var format_dict := { "width": resolution_value.x, "height": resolution_value.y }
format_dict["name"] = tr("OPTIONS_VIDEO_RESOLUTION_{width}x{height}".format(format_dict))
diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd
index a972ed6..44bcada 100644
--- a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd
+++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd
@@ -40,7 +40,7 @@ func _set_value_from_file(load_value : Variant) -> void:
if _valid_index(load_int):
selected = load_int
return
- for item_index in item_count:
+ for item_index : int in item_count:
if load_string == get_item_text(item_index):
selected = item_index
return
diff --git a/game/src/Game/Menu/OptionMenu/VolumeGrid.gd b/game/src/Game/Menu/OptionMenu/VolumeGrid.gd
index cce231f..e9c59d5 100644
--- a/game/src/Game/Menu/OptionMenu/VolumeGrid.gd
+++ b/game/src/Game/Menu/OptionMenu/VolumeGrid.gd
@@ -40,7 +40,7 @@ func add_volume_row(bus_name : String, bus_index : int) -> HSlider:
# REQUIREMENTS
# * UI-22
func _ready() -> void:
- for bus_index in AudioServer.bus_count:
+ for bus_index : int in AudioServer.bus_count:
add_volume_row(AudioServer.get_bus_name(bus_index), bus_index)
func _notification(what : int) -> void:
diff --git a/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd
index bff0bb5..66706b9 100644
--- a/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd
+++ b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd
@@ -15,7 +15,7 @@ var is_save_menu : bool = true
var _id_to_tag : Array[StringName] = []
func filter_for_tag(tag : StringName) -> void:
- for child in _scroll_list.get_children():
+ for child : Control in _scroll_list.get_children():
if tag == &"":
child.show()
else:
@@ -44,7 +44,7 @@ func show_for_save() -> void:
func _build_save_list() -> void:
_tag_selection_tab.add_tab("SAVELOADMENU_TABSELECTIONTABBAR_ALL")
- for save_name in SaveManager._save_dictionary:
+ for save_name : StringName in SaveManager._save_dictionary:
var save : SaveResource = SaveManager._save_dictionary[save_name]
var save_node := _create_save_node(save)
_scroll_list.add_child(save_node)
@@ -60,7 +60,7 @@ func _create_save_node(resource : SaveResource) -> Control:
return save_node
func _queue_clear_scroll_list() -> void:
- for child in _scroll_list.get_children():
+ for child : Node in _scroll_list.get_children():
child.queue_free()
_tag_selection_tab.clear_tabs()
_id_to_tag.clear()
diff --git a/game/src/Game/MusicConductor/MusicConductor.gd b/game/src/Game/MusicConductor/MusicConductor.gd
index abfc52f..b4b660a 100644
--- a/game/src/Game/MusicConductor/MusicConductor.gd
+++ b/game/src/Game/MusicConductor/MusicConductor.gd
@@ -23,9 +23,9 @@ var is_music_player_visible : bool = true
var _has_startup_happened : bool = false
-func get_all_song_names() -> Array[String]:
- var songNames : Array[String] = []
- for si in _available_songs:
+func get_all_song_names() -> PackedStringArray:
+ var songNames : PackedStringArray = []
+ for si : SongInfo in _available_songs:
songNames.append(si.song_name)
return songNames
diff --git a/game/src/Game/MusicConductor/MusicPlayer.gd b/game/src/Game/MusicConductor/MusicPlayer.gd
index 949f423..17285dc 100644
--- a/game/src/Game/MusicConductor/MusicPlayer.gd
+++ b/game/src/Game/MusicConductor/MusicPlayer.gd
@@ -10,7 +10,7 @@ extends Control
var _is_user_dragging_progress_slider : bool = false
func _ready() -> void:
- for songName in MusicConductor.get_all_song_names():
+ for songName : String in MusicConductor.get_all_song_names():
_song_selector_button.add_item(songName, _song_selector_button.item_count)
_on_song_set(MusicConductor.get_current_song_index())
MusicConductor.song_started.connect(_on_song_set)
diff --git a/game/src/Game/Theme/StyleBoxCombinedTexture.gd b/game/src/Game/Theme/StyleBoxCombinedTexture.gd
index db54da4..1d68363 100644
--- a/game/src/Game/Theme/StyleBoxCombinedTexture.gd
+++ b/game/src/Game/Theme/StyleBoxCombinedTexture.gd
@@ -7,13 +7,13 @@ var texture_settings : Array[TextureSetting] = []:
get: return texture_settings.duplicate()
set(v):
texture_settings = v
- for setting in texture_settings:
+ for setting : TextureSetting in texture_settings:
setting.changed.connect(emit_changed)
emit_changed()
func _get_draw_rect(rect : Rect2) -> Rect2:
var combined_rect : Rect2 = Rect2()
- for setting in texture_settings:
+ for setting : TextureSetting in texture_settings:
if combined_rect.position.x > setting.expand_margin_left:
combined_rect.position.x = setting.expand_margin_left
if combined_rect.position.y > setting.expand_margin_top:
@@ -25,7 +25,7 @@ func _get_draw_rect(rect : Rect2) -> Rect2:
return rect.grow_individual(combined_rect.position.x, combined_rect.position.y, combined_rect.end.x, combined_rect.end.y)
func _draw(to_canvas_item : RID, rect : Rect2) -> void:
- for setting in texture_settings:
+ for setting : TextureSetting in texture_settings:
if setting == null or setting.texture == null:
continue
var inner_rect : Rect2 = rect