From e2077a0d93be8b2dd48f1ee680809420f1f690d7 Mon Sep 17 00:00:00 2001 From: hop311 Date: Sun, 3 Mar 2024 16:39:08 +0000 Subject: Add types to GDScript for-loop variables --- game/src/Game/Menu/LobbyMenu/LobbyMenu.gd | 2 +- game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd | 6 ++---- game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd | 2 +- game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd | 4 ++-- game/src/Game/Menu/OptionMenu/ResolutionSelector.gd | 6 +++--- game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd | 2 +- game/src/Game/Menu/OptionMenu/VolumeGrid.gd | 2 +- game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd | 6 +++--- 8 files changed, 14 insertions(+), 16 deletions(-) (limited to 'game/src/Game/Menu') 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() -- cgit v1.2.3-56-ga3b1