extends Control class_name ReloadRing ## The reload arc, drawn around the reticle. ## ## Like Crosshair it owns the full rect and centres itself in `size` rather than ## sitting at a zero-sized PRESET_CENTER: a control that draws before the ## viewport has sized it lands in the top-left corner, and only a later redraw ## moves it — which, for something that redraws on a value change, can be never. var progress: float = 0.0: set(val): var v := clampf(val, 0.0, 1.0) if is_equal_approx(v, progress): return progress = v queue_redraw() var radius: float = 16.0 var thickness: float = 4.0 var color: Color = Color(1.0, 1.0, 1.0, 0.8) func _ready() -> void: mouse_filter = Control.MOUSE_FILTER_IGNORE # Offsets too — see the note in ui/crosshair.gd. set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) resized.connect(queue_redraw) func _draw() -> void: if progress <= 0.0 or progress >= 1.0: return var mid := size * 0.5 # Ink track first, wider than the arc, so the ring reads over a bright # skybox the same way every other element in this UI does. The old version # used 40% black, which vanished against pale concrete. draw_arc(mid, radius, 0, TAU, 48, UITheme.INK, thickness + 4.0, true) draw_arc(mid, radius, 0, TAU, 48, UITheme.INK_SOFT, thickness, true) # The charged part, sweeping from twelve o'clock. draw_arc(mid, radius, -PI / 2.0, -PI / 2.0 + TAU * progress, 48, color, thickness, true)