Fix GDScript ternary and shadowed-identifier warnings in dashboard scripts

Godot's static checker can't unify a float branch with a null branch in
a ternary, so point_value() now uses explicit if/return; renaming the
local sign variable to sign_prefix avoids shadowing the builtin sign().
This commit is contained in:
hz
2026-07-26 18:28:55 -05:00
parent 548b519d44
commit 23d573e221
2 changed files with 10 additions and 6 deletions
+6 -2
View File
@@ -99,9 +99,13 @@ func _draw() -> void:
static func point_value(point: Dictionary, series_mode: String) -> Variant:
if series_mode == "accuracy":
return float(point.get("accuracy", 0)) if int(point.get("total", 0)) > 0 else null
if int(point.get("total", 0)) > 0:
return float(point.get("accuracy", 0))
return null
var value: Variant = point.get("questionBankRating", null)
return null if value == null else float(value)
if value == null:
return null
return float(value)
static func axis_bounds(series_points: Array, series_mode: String) -> Vector2:
+4 -4
View File
@@ -229,8 +229,8 @@ func _render_rating_card(key: String, sparkline: Control, accent: Color, rating_
if delta_value != null:
var delta := int(delta_value)
var arrow := "↗" if delta >= 0 else "↘"
var sign := "+" if delta >= 0 else ""
trend_text = "%s %s%d this week" % [arrow, sign, delta]
var sign_prefix := "+" if delta >= 0 else ""
trend_text = "%s %s%d this week" % [arrow, sign_prefix, delta]
trend_color = Brand.SUCCESS if delta >= 0 else Brand.MAGENTA
if percentile_value != null:
caption = "Top %d%% of users" % int(percentile_value)
@@ -269,8 +269,8 @@ func _render_accuracy_card(data: Dictionary) -> void:
if delta_value != null:
var delta := int(delta_value)
var arrow := "↗" if delta >= 0 else "↘"
var sign := "+" if delta >= 0 else ""
trend_text = "%s %s%d%% vs last 100" % [arrow, sign, delta]
var sign_prefix := "+" if delta >= 0 else ""
trend_text = "%s %s%d%% vs last 100" % [arrow, sign_prefix, delta]
trend_color = Brand.SUCCESS if delta >= 0 else Brand.MAGENTA
_set_stat_card("accuracy", "%d%%" % accuracy, trend_text, trend_color, "Last %d questions" % int(data.get("accuracySampleSize", 0)))
accuracy_progress_bar.value = accuracy