Add user progress dashboard
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
extends Control
|
||||
|
||||
const Brand := preload("res://scripts/ui/medmind_style.gd")
|
||||
|
||||
var values: PackedFloat32Array = []
|
||||
var dark := true
|
||||
|
||||
|
||||
func set_values(next_values: Array, dark_mode: bool) -> void:
|
||||
values = PackedFloat32Array(next_values)
|
||||
dark = dark_mode
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var left := 42.0
|
||||
var top := 12.0
|
||||
var right := size.x - 12.0
|
||||
var bottom := size.y - 28.0
|
||||
var grid := Color("24314b") if dark else Color("dbe3ef")
|
||||
var muted := Brand.muted_color(dark)
|
||||
for percentage in [0, 25, 50, 75, 100]:
|
||||
var y: float = bottom - (bottom - top) * float(percentage) / 100.0
|
||||
draw_line(Vector2(left, y), Vector2(right, y), grid, 1.0)
|
||||
draw_string(Brand.font, Vector2(4, y + 4), str(percentage), HORIZONTAL_ALIGNMENT_LEFT, 34, 11, muted)
|
||||
var target_y: float = bottom - (bottom - top) * 0.70
|
||||
draw_dashed_line(Vector2(left, target_y), Vector2(right, target_y), Brand.ROYAL_BLUE, 5.0, 2.0)
|
||||
if values.is_empty():
|
||||
return
|
||||
var points := PackedVector2Array()
|
||||
var count: int = values.size()
|
||||
for index in range(count):
|
||||
var x: float = left if count == 1 else lerpf(left, right, float(index) / float(count - 1))
|
||||
var y: float = bottom - (bottom - top) * clampf(values[index], 0.0, 100.0) / 100.0
|
||||
points.append(Vector2(x, y))
|
||||
if points.size() > 1:
|
||||
draw_polyline(points, Brand.ROYAL_BLUE, 2.5, true)
|
||||
for point in points:
|
||||
draw_circle(point, 3.5, Brand.PURPLE)
|
||||
draw_circle(point, 2.0, Color.WHITE)
|
||||
Reference in New Issue
Block a user