extends VBoxContainer const Style := preload("res://scripts/ui/ui_style.gd") var main: Control var list: VBoxContainer var prediction: Label func _ready() -> void: set_anchors_preset(Control.PRESET_FULL_RECT); add_theme_constant_override("separation", 12) var back := Button.new(); back.text = "< Profile"; back.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN; back.pressed.connect(func(): main.show_screen("profile")); add_child(back) var title := Label.new(); title.text = "CCS Case History"; Style.set_label(title, 32, Style.TEXT); add_child(title) prediction = Label.new(); prediction.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART; Style.set_label(prediction, 16, Style.CYAN); add_child(prediction) var scroll := ScrollContainer.new(); scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL; add_child(scroll) list = VBoxContainer.new(); list.size_flags_horizontal = Control.SIZE_EXPAND_FILL; list.add_theme_constant_override("separation", 8); scroll.add_child(list) CCSService.history_changed.connect(_render) CCSService.prediction_changed.connect(_render_prediction) func on_show(_payload: Variant = null) -> void: CCSService.load_history(); CCSService.load_prediction() func _render() -> void: for child in list.get_children(): child.queue_free() if CCSService.history.is_empty(): var empty := Label.new(); empty.text = "No case attempts yet."; Style.set_label(empty, 16, Style.MUTED); list.add_child(empty); return for item in CCSService.history: var button := Button.new(); button.alignment = HORIZONTAL_ALIGNMENT_LEFT var score: Variant = item.get("score", null) button.text = "%s\n%s | %s%s" % [item.get("caseTitle", "Case"), str(item.get("mode", "")).capitalize(), str(item.get("state", "")).capitalize(), " | %d%%" % int(round(float(score))) if score != null else ""] button.disabled = str(item.get("state", "")) == "abandoned" button.pressed.connect(_open.bind(str(item.get("id", "")), str(item.get("state", "")))); list.add_child(button) func _open(id: String, state: String) -> void: main.show_screen("ccs_review" if state == "completed" else "ccs_player", id) func _render_prediction() -> void: var data: Dictionary = CCSService.prediction if data.get("combinedPredictedScore", null) != null: prediction.text = "Provisional combined prediction: %d (range %d-%d) | CCS %.0f%% from %d first timed cases" % [data.get("combinedPredictedScore", 0), data.get("rangeLow", 0), data.get("rangeHigh", 0), data.get("ccsScore", 0), data.get("contributingCases", 0)] elif data.get("ccsScore", null) != null: prediction.text = "CCS performance: %.0f%% from %d first timed cases. Complete a Day 1 simulation for a combined prediction." % [data.get("ccsScore", 0), data.get("contributingCases", 0)] else: prediction.text = "Complete timed CCS cases to begin estimating CCS performance."