From 48f404518f2106563dff358c7fcbd9a4bcc39a5d Mon Sep 17 00:00:00 2001 From: hz Date: Thu, 23 Jul 2026 14:30:48 -0500 Subject: [PATCH] Fix GDScript editor warnings (shadowed vars, unused param, integer division) Renames locals/params that shadowed base-class properties (Node.name, Control.size, BoxContainer.alignment), prefixes an intentionally-unused parameter, and annotates a deliberate integer division so the console stays clean during development. --- scripts/autoload/flashcard_service.gd | 4 ++-- scripts/ui/ccs_player.gd | 11 ++++++----- scripts/ui/flashcard_prefill_dialog.gd | 2 +- scripts/ui/flashcards_study.gd | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/autoload/flashcard_service.gd b/scripts/autoload/flashcard_service.gd index 005db90..4686199 100644 --- a/scripts/autoload/flashcard_service.gd +++ b/scripts/autoload/flashcard_service.gd @@ -237,8 +237,8 @@ func fetch_counts() -> void: _enqueue_json("GET", "/counts", "", func(parsed): counts_changed.emit(parsed if typeof(parsed) == TYPE_DICTIONARY else {}), "counts") -func create_deck(name: String, description: String) -> void: - _enqueue_json("POST", "/decks", JSON.stringify({"name": name, "description": description}), +func create_deck(deck_name: String, description: String) -> void: + _enqueue_json("POST", "/decks", JSON.stringify({"name": deck_name, "description": description}), func(_parsed): fetch_decks(), "decks") diff --git a/scripts/ui/ccs_player.gd b/scripts/ui/ccs_player.gd index 2c025b3..7015e93 100644 --- a/scripts/ui/ccs_player.gd +++ b/scripts/ui/ccs_player.gd @@ -296,9 +296,9 @@ func _build_footer() -> void: add_child(status) -func _footer_label(alignment: HorizontalAlignment) -> Label: +func _footer_label(h_align: HorizontalAlignment) -> Label: var label := Label.new() - label.horizontal_alignment = alignment + label.horizontal_alignment = h_align label.size_flags_horizontal = Control.SIZE_EXPAND_FILL label.add_theme_font_size_override("font_size", 14) Brand.apply_font(label) @@ -912,6 +912,7 @@ func _simulated_time_text(minute: int, include_day: bool = true) -> String: func _elapsed_simulated_text(minutes: int) -> String: + @warning_ignore("integer_division") return "%d Days %02d Hrs %02d Mins" % [minutes / 1440, (minutes % 1440) / 60, minutes % 60] @@ -980,9 +981,9 @@ func _zoom(delta: float) -> void: func _apply_text_scale() -> void: for label in clinical_labels: - var size := maxi(12, int(round(float(label.get_meta("ccs_base_font_size", 16)) * CCSService.text_scale))) - label.add_theme_font_size_override("normal_font_size", size) - label.add_theme_font_size_override("bold_font_size", size) + var font_size := maxi(12, int(round(float(label.get_meta("ccs_base_font_size", 16)) * CCSService.text_scale))) + label.add_theme_font_size_override("normal_font_size", font_size) + label.add_theme_font_size_override("bold_font_size", font_size) func _report() -> void: diff --git a/scripts/ui/flashcard_prefill_dialog.gd b/scripts/ui/flashcard_prefill_dialog.gd index d2ca0a1..c873bbb 100644 --- a/scripts/ui/flashcard_prefill_dialog.gd +++ b/scripts/ui/flashcard_prefill_dialog.gd @@ -99,7 +99,7 @@ func _field_label(text: String) -> Label: return label -func open_for_question(question: Dictionary, current_answer: Dictionary) -> void: +func open_for_question(question: Dictionary, _current_answer: Dictionary) -> void: var stem := str(question.get("stem", "")).strip_edges() var lead_in := str(question.get("lead_in", "")).strip_edges() front_input.text = "%s\n\n%s" % [stem, lead_in] if not lead_in.is_empty() else stem diff --git a/scripts/ui/flashcards_study.gd b/scripts/ui/flashcards_study.gd index c135cb7..65988cd 100644 --- a/scripts/ui/flashcards_study.gd +++ b/scripts/ui/flashcards_study.gd @@ -597,7 +597,7 @@ func _refresh_deck_panel() -> void: if deck_ring == null: return var dark := UIThemeService.is_dark_mode() - var name := "All decks" + var deck_name := "All decks" var total := 0 var mastered := 0 var is_system := false @@ -609,12 +609,12 @@ func _refresh_deck_panel() -> void: for summary in decks: var deck: Dictionary = summary.get("deck", {}) if str(deck.get("id", "")) == deck_id: - name = str(deck.get("name", "Deck")) + deck_name = str(deck.get("name", "Deck")) total = int(summary.get("total", 0)) mastered = int(summary.get("mastered", 0)) is_system = bool(deck.get("isSystem", false)) break - deck_name_label.text = name + deck_name_label.text = deck_name deck_system_badge.visible = is_system var fraction := float(mastered) / float(total) if total > 0 else 0.0 deck_ring.configure(fraction, "%d%%" % roundi(fraction * 100.0), "Mastery", Brand.ROYAL_BLUE, dark)