extends Control signal choice_selected(choice_id: String) signal interview_continue_requested signal debrief_return_requested signal debrief_repeat_requested const CHOICE_NORMAL := preload("res://assets/ccs_cases_2/images/doctor/dialogue-choice-normal.png") const CHOICE_HOVER := preload("res://assets/ccs_cases_2/images/doctor/dialogue-choice-hover.png") const CHOICE_PRESSED := preload("res://assets/ccs_cases_2/images/doctor/dialogue-choice-pressed.png") const CHOICE_CROP := Rect2(80.0, 200.0, 1610.0, 485.0) const CHOICES_PER_PAGE := 4 const DIALOGUE_PAGE_MIN_CHARS := 32 const DIALOGUE_PAGE_MAX_CHARS := 82 const DIALOGUE_BUBBLE_MIN_HEIGHT := 130.0 const DIALOGUE_BUBBLE_MAX_HEIGHT := 240.0 const DIALOGUE_BUBBLE_VERTICAL_CHROME := 95.0 @onready var hour_hand: Node2D = $ClockMount/HourHand @onready var minute_hand: Node2D = $ClockMount/MinuteHand @onready var second_hand: Node2D = $ClockMount/SecondHand @onready var patient: TextureRect = $Patient @onready var dialogue_bubble: Control = $DialogueBubble @onready var dialogue_text: RichTextLabel = $DialogueBubble/Text @onready var dialogue_continue_hint: Label = $DialogueBubble/ContinueHint @onready var choice_area: Control = $DialogueChoiceArea @onready var choice_container: HBoxContainer = $DialogueChoiceArea/DialogueChoices @onready var choice_pager: HBoxContainer = $DialogueChoiceArea/ChoicePager @onready var previous_page_button: Button = $DialogueChoiceArea/ChoicePager/Previous @onready var page_label: Label = $DialogueChoiceArea/ChoicePager/Page @onready var next_page_button: Button = $DialogueChoiceArea/ChoicePager/Next @onready var computer_launcher: Button = $ComputerLauncher @onready var computer_overlay: Control = $ComputerOverlay @onready var computer_close_button: Button = $ComputerOverlay/Close @onready var vitals_launcher: Button = $ComputerOverlay/VitalsLauncher @onready var vitals_window: PanelContainer = $ComputerOverlay/VitalsWindow @onready var vitals_close_button: Button = $ComputerOverlay/VitalsWindow/Margin/Content/Header/Close @onready var vitals_header: HBoxContainer = $ComputerOverlay/VitalsWindow/Margin/Content/Header @onready var vitals_rows: GridContainer = $ComputerOverlay/VitalsWindow/Margin/Content/Rows @onready var vitals_empty: Label = $ComputerOverlay/VitalsWindow/Margin/Content/Empty @onready var medical_history_launcher: Button = $ComputerOverlay/MedicalHistoryLauncher @onready var medical_history_window: PanelContainer = $ComputerOverlay/MedicalHistoryWindow @onready var medical_history_header: HBoxContainer = $ComputerOverlay/MedicalHistoryWindow/Margin/Content/Header @onready var medical_history_close_button: Button = $ComputerOverlay/MedicalHistoryWindow/Margin/Content/Header/Close @onready var medical_history_text: Label = $ComputerOverlay/MedicalHistoryWindow/Margin/Content/Text var blink_tween: Tween var dialogue_tween: Tween var clock_seconds := 9.0 * 60.0 * 60.0 var debrief_panel: PanelContainer var experience_mode := "management" var pending_choices: Array = [] var available_choices: Array = [] var choice_page := 0 var dialogue_pages: Array[String] = [] var dialogue_page_index := 0 var dialogue_characters_per_second := 35.0 var dialogue_reveal_complete := false var dialogue_layout_generation := 0 var dialogue_input_enabled := true var computer_available := true var computer_drag_window: Control var computer_drag_offset := Vector2.ZERO var computer_window_z := 2 func _ready() -> void: previous_page_button.pressed.connect(_change_choice_page.bind(-1)) next_page_button.pressed.connect(_change_choice_page.bind(1)) computer_launcher.pressed.connect(open_computer) computer_close_button.pressed.connect(close_computer) vitals_launcher.pressed.connect(open_vitals) vitals_close_button.pressed.connect(close_vitals) medical_history_launcher.pressed.connect(open_medical_history) medical_history_close_button.pressed.connect(close_medical_history) vitals_header.gui_input.connect(_on_computer_window_header_input.bind(vitals_window, vitals_close_button)) medical_history_header.gui_input.connect(_on_computer_window_header_input.bind( medical_history_window, medical_history_close_button)) vitals_window.gui_input.connect(_on_computer_window_input.bind(vitals_window)) medical_history_window.gui_input.connect(_on_computer_window_input.bind(medical_history_window)) resized.connect(_resize_computer_windows) _style_vitals_window() _style_computer_window(medical_history_window) _resize_computer_windows() _update_clock() _schedule_patient_blink() hide_patient_dialogue() hide_dialogue_choices() func _process(_delta: float) -> void: pass func _update_clock() -> void: var hour_value := floori(clock_seconds / 3600.0) var minute_value := floori(fmod(clock_seconds, 3600.0) / 60.0) var second_value := fmod(clock_seconds, 60.0) var second := float(second_value) var minute := float(minute_value) + second / 60.0 var hour := float(hour_value % 12) + minute / 60.0 hour_hand.rotation = TAU * hour / 12.0 minute_hand.rotation = TAU * minute / 60.0 second_hand.rotation = TAU * second / 60.0 func configure_presentation( presentation: Dictionary, simulated_start: String, simulated_minute: int, vitals: Dictionary = {}, medical_history: String = "") -> void: if str(presentation.get("patientAssetKey", "")) != "patient_44_white_male": push_warning("Unsupported CCS patient asset key; using the office default.") var date_time := Time.get_datetime_dict_from_datetime_string(simulated_start, false) if not date_time.is_empty(): clock_seconds = float(int(date_time.get("hour", 9)) * 3600 + int(date_time.get("minute", 0)) * 60) clock_seconds += float(simulated_minute * 60) _update_clock() _render_vitals(vitals) medical_history_text.text = medical_history.strip_edges() \ if not medical_history.strip_edges().is_empty() \ else "No past medical history is available." func configure_experience_mode(value: String) -> void: experience_mode = value func _schedule_patient_blink() -> void: blink_tween = create_tween() blink_tween.tween_interval(randf_range(2.8, 5.2)) blink_tween.tween_method(_set_patient_blink, 0.0, 1.0, 0.075).set_trans( Tween.TRANS_SINE ).set_ease(Tween.EASE_IN) blink_tween.tween_interval(0.045) blink_tween.tween_method(_set_patient_blink, 1.0, 0.0, 0.10).set_trans( Tween.TRANS_SINE ).set_ease(Tween.EASE_OUT) blink_tween.tween_callback(_schedule_patient_blink) func _set_patient_blink(amount: float) -> void: patient.material.set_shader_parameter("blink_amount", amount) func show_patient_dialogue(text: String, characters_per_second: float = 35.0) -> void: if dialogue_tween and dialogue_tween.is_valid(): dialogue_tween.kill() dialogue_pages = _split_dialogue_pages(text) dialogue_page_index = 0 dialogue_characters_per_second = characters_per_second _show_dialogue_page() func _show_dialogue_page() -> void: if dialogue_tween and dialogue_tween.is_valid(): dialogue_tween.kill() if dialogue_pages.is_empty(): complete_response_transition() return dialogue_text.text = dialogue_pages[dialogue_page_index] dialogue_text.visible_ratio = 0.0 dialogue_reveal_complete = false dialogue_continue_hint.text = "Click to continue" dialogue_continue_hint.visible = true dialogue_bubble.visible = true dialogue_bubble.grab_focus() dialogue_layout_generation += 1 call_deferred("_prepare_dialogue_page", dialogue_layout_generation) func _prepare_dialogue_page(generation: int) -> void: if generation != dialogue_layout_generation or not dialogue_bubble.visible \ or dialogue_reveal_complete: return var measured_height := dialogue_text.get_content_height() + DIALOGUE_BUBBLE_VERTICAL_CHROME dialogue_bubble.size.y = clampf( measured_height, DIALOGUE_BUBBLE_MIN_HEIGHT, DIALOGUE_BUBBLE_MAX_HEIGHT) var reveal_duration := float(dialogue_text.text.length()) / maxf(dialogue_characters_per_second, 1.0) dialogue_tween = create_tween() dialogue_tween.tween_property(dialogue_text, "visible_ratio", 1.0, reveal_duration) dialogue_tween.finished.connect(_on_dialogue_reveal_finished) func hide_patient_dialogue() -> void: if dialogue_tween and dialogue_tween.is_valid(): dialogue_tween.kill() dialogue_layout_generation += 1 dialogue_bubble.visible = false dialogue_continue_hint.visible = false dialogue_pages = [] dialogue_page_index = 0 dialogue_reveal_complete = false pending_choices = [] func is_patient_dialogue_visible() -> bool: return dialogue_bubble.visible func configure_interview(node: Dictionary) -> void: computer_available = true computer_launcher.visible = not computer_overlay.visible if debrief_panel != null and is_instance_valid(debrief_panel): debrief_panel.queue_free() debrief_panel = null var next_choices: Array if bool(node.get("isTerminal", false)): next_choices = [{ "id": "__continue", "text": "Finish Interview" if experience_mode == "graphical_interview" else "Continue to Patient Management" }] else: next_choices = node.get("choices", []) hide_dialogue_choices() if bool(node.get("suppressPatientText", false)): hide_patient_dialogue() show_dialogue_choices(next_choices) return pending_choices = next_choices show_patient_dialogue(str(node.get("patientText", ""))) func complete_dialogue_reveal() -> void: if dialogue_reveal_complete: return if dialogue_tween and dialogue_tween.is_valid(): dialogue_tween.kill() dialogue_layout_generation += 1 dialogue_text.visible_ratio = 1.0 _on_dialogue_reveal_finished() func _on_dialogue_reveal_finished() -> void: dialogue_tween = null dialogue_reveal_complete = true dialogue_continue_hint.text = "Click to continue" dialogue_continue_hint.visible = true func advance_dialogue() -> void: if not dialogue_bubble.visible: return if not dialogue_reveal_complete: complete_dialogue_reveal() return if dialogue_page_index < dialogue_pages.size() - 1: dialogue_page_index += 1 _show_dialogue_page() return complete_response_transition() func complete_response_transition() -> void: var choices := pending_choices pending_choices = [] dialogue_bubble.visible = false dialogue_continue_hint.visible = false dialogue_pages = [] dialogue_page_index = 0 dialogue_reveal_complete = false show_dialogue_choices(choices) func _input(event: InputEvent) -> void: if computer_overlay.visible: return if _event_targets_computer_launcher(event): return if not dialogue_input_enabled or not dialogue_bubble.visible: return var should_advance := false if event is InputEventMouseButton: should_advance = event.button_index == MOUSE_BUTTON_LEFT and event.pressed \ and get_global_rect().has_point(event.position) elif event is InputEventScreenTouch: should_advance = event.pressed and get_global_rect().has_point(event.position) elif event is InputEventKey: should_advance = event.pressed and not event.echo \ and event.keycode in [KEY_ENTER, KEY_KP_ENTER, KEY_SPACE] if not should_advance: return advance_dialogue() get_viewport().set_input_as_handled() func set_dialogue_input_enabled(enabled: bool) -> void: dialogue_input_enabled = enabled func open_computer() -> void: if not computer_available or computer_overlay.visible: return computer_overlay.visible = true computer_launcher.visible = false if dialogue_tween and dialogue_tween.is_valid(): dialogue_tween.pause() computer_close_button.grab_focus() func close_computer() -> bool: if not computer_overlay.visible: return false close_vitals() close_medical_history() computer_overlay.visible = false computer_launcher.visible = computer_available if dialogue_tween and dialogue_tween.is_valid(): dialogue_tween.play() return true func is_computer_open() -> bool: return computer_overlay.visible func close_transient_overlay() -> bool: var top_window := _topmost_computer_window() if top_window == vitals_window: return close_vitals() if top_window == medical_history_window: return close_medical_history() return close_computer() func open_vitals() -> void: if not computer_overlay.visible: return vitals_window.visible = true _bring_computer_window_to_front(vitals_window) vitals_close_button.grab_focus() func close_vitals() -> bool: if not vitals_window.visible: return false if computer_drag_window == vitals_window: computer_drag_window = null vitals_window.visible = false return true func is_vitals_open() -> bool: return vitals_window.visible func open_medical_history() -> void: if not computer_overlay.visible: return medical_history_window.visible = true _bring_computer_window_to_front(medical_history_window) medical_history_close_button.grab_focus() func close_medical_history() -> bool: if not medical_history_window.visible: return false if computer_drag_window == medical_history_window: computer_drag_window = null medical_history_window.visible = false return true func is_medical_history_open() -> bool: return medical_history_window.visible func _render_vitals(vitals: Dictionary) -> void: for child in vitals_rows.get_children(): vitals_rows.remove_child(child) child.queue_free() var rows := _build_vital_rows(vitals) for row in rows: var name_label := Label.new() name_label.custom_minimum_size.x = 230.0 name_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL name_label.add_theme_font_size_override("font_size", 19) name_label.add_theme_color_override("font_color", Color(0.18, 0.25, 0.31)) name_label.text = "%s:" % str(row.get("label", "Vital sign")) vitals_rows.add_child(name_label) var value_label := Label.new() value_label.custom_minimum_size.x = 230.0 value_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL value_label.add_theme_font_size_override("font_size", 19) value_label.add_theme_color_override("font_color", Color(0.04, 0.09, 0.13)) value_label.text = str(row.get("value", "")) value_label.autowrap_mode = TextServer.AUTOWRAP_OFF value_label.clip_text = true vitals_rows.add_child(value_label) vitals_rows.visible = not rows.is_empty() vitals_empty.visible = rows.is_empty() func _build_vital_rows(vitals: Dictionary) -> Array[Dictionary]: var rows: Array[Dictionary] = [] var displayed := {} _append_vital(rows, displayed, vitals, "temperature", "Temperature") _append_vital(rows, displayed, vitals, "pulse", "Pulse") _append_vital(rows, displayed, vitals, "respirations", "Respiratory rate") var blood_pressure := str(vitals.get("bloodPressure", "")).strip_edges() if not blood_pressure.is_empty(): displayed["bloodPressure"] = true var pattern := RegEx.create_from_string("^\\s*([^/]+)\\s*/\\s*([0-9.]+)(.*)$") var matched := pattern.search(blood_pressure) if matched: var suffix := matched.get_string(3).strip_edges() var unit_suffix := " %s" % suffix if not suffix.is_empty() else "" rows.append({"label": "Blood pressure, systolic", "value": matched.get_string(1).strip_edges() + unit_suffix}) rows.append({"label": "Blood pressure, diastolic", "value": matched.get_string(2).strip_edges() + unit_suffix}) else: rows.append({"label": "Blood pressure", "value": blood_pressure}) _append_vital(rows, displayed, vitals, "oxygenSaturation", "Oxygen saturation") _append_vital(rows, displayed, vitals, "height", "Height") _append_vital(rows, displayed, vitals, "weight", "Weight") _append_vital(rows, displayed, vitals, "bmi", "Body Mass Index") var remaining_keys: Array = vitals.keys() remaining_keys.sort() for raw_key in remaining_keys: var key := str(raw_key) if not displayed.has(key): _append_vital(rows, displayed, vitals, key, _friendly_vital_name(key)) return rows func _append_vital( rows: Array[Dictionary], displayed: Dictionary, vitals: Dictionary, key: String, label: String) -> void: displayed[key] = true var value := str(vitals.get(key, "")).strip_edges() if not value.is_empty(): rows.append({"label": label, "value": value}) func _friendly_vital_name(key: String) -> String: var result := "" for index in key.length(): var character := key[index] if index > 0 and character == character.to_upper() and character != character.to_lower(): result += " " result += character return result.capitalize() func _style_vitals_window() -> void: _style_computer_window(vitals_window) func _style_computer_window(window: PanelContainer) -> void: var panel_style := StyleBoxFlat.new() panel_style.bg_color = Color(0.97, 0.98, 0.99, 0.98) panel_style.border_color = Color(0.12, 0.24, 0.34, 0.9) panel_style.set_border_width_all(3) panel_style.set_corner_radius_all(14) panel_style.shadow_color = Color(0.0, 0.0, 0.0, 0.35) panel_style.shadow_size = 18 window.add_theme_stylebox_override("panel", panel_style) func _resize_computer_windows() -> void: if vitals_window == null or medical_history_window == null: return var vitals_size := Vector2( minf(720.0, maxf(320.0, size.x - 48.0)), minf(540.0, maxf(360.0, size.y - 48.0))) _set_centered_window_rect(vitals_window, vitals_size, Vector2(-55.0, -25.0)) var history_size := Vector2( minf(660.0, maxf(320.0, size.x - 48.0)), minf(420.0, maxf(300.0, size.y - 48.0))) _set_centered_window_rect(medical_history_window, history_size, Vector2(55.0, 25.0)) func _set_centered_window_rect(window: Control, window_size: Vector2, offset: Vector2) -> void: window.offset_left = -window_size.x * 0.5 + offset.x window.offset_top = -window_size.y * 0.5 + offset.y window.offset_right = window_size.x * 0.5 + offset.x window.offset_bottom = window_size.y * 0.5 + offset.y _set_computer_window_position(window, window.position) func _on_computer_window_header_input( event: InputEvent, window: Control, close_button: Button) -> void: if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: if event.pressed: if close_button.get_global_rect().has_point(event.global_position): return computer_drag_window = window computer_drag_offset = event.global_position - window.global_position _bring_computer_window_to_front(window) else: computer_drag_window = null window.accept_event() elif event is InputEventMouseMotion and computer_drag_window == window: var target_global: Vector2 = event.global_position - computer_drag_offset _set_computer_window_position(window, target_global - global_position) window.accept_event() func _on_computer_window_input(event: InputEvent, window: Control) -> void: if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: _bring_computer_window_to_front(window) func _set_vitals_window_position(target: Vector2) -> void: _set_computer_window_position(vitals_window, target) func _set_medical_history_window_position(target: Vector2) -> void: _set_computer_window_position(medical_history_window, target) func _set_computer_window_position(window: Control, target: Vector2) -> void: var maximum := Vector2( maxf(0.0, size.x - window.size.x), maxf(0.0, size.y - window.size.y)) window.position = Vector2( clampf(target.x, 0.0, maximum.x), clampf(target.y, 0.0, maximum.y)) func _bring_computer_window_to_front(window: Control) -> void: computer_window_z += 1 window.z_index = computer_window_z func _topmost_computer_window() -> Control: var top_window: Control for window in [vitals_window, medical_history_window]: if window.visible and (top_window == null or window.z_index > top_window.z_index): top_window = window return top_window func _event_targets_computer_launcher(event: InputEvent) -> bool: if not computer_launcher.visible: return false if event is InputEventMouseButton: return event.button_index == MOUSE_BUTTON_LEFT \ and computer_launcher.get_global_rect().has_point(event.position) if event is InputEventScreenTouch: return computer_launcher.get_global_rect().has_point(event.position) return false func _split_dialogue_pages(text: String) -> Array[String]: var normalized := text.strip_edges() if normalized.is_empty(): return [] var pages: Array[String] = [] var current := "" for word in normalized.split(" ", false): var candidate := word if current.is_empty() else "%s %s" % [current, word] var has_natural_break := current.length() >= DIALOGUE_PAGE_MIN_CHARS \ and _ends_dialogue_phrase(word) if candidate.length() > DIALOGUE_PAGE_MAX_CHARS and not current.is_empty(): pages.append(current) current = word elif has_natural_break: pages.append(candidate) current = "" else: current = candidate if not current.is_empty(): pages.append(current) return pages func _ends_dialogue_phrase(word: String) -> bool: return word.ends_with(",") or word.ends_with(";") or word.ends_with(":") \ or word.ends_with(".") or word.ends_with("?") or word.ends_with("!") func set_choices_pending(pending: bool) -> void: for child in choice_container.get_children(): if child is BaseButton: child.disabled = pending previous_page_button.disabled = pending or choice_page <= 0 next_page_button.disabled = pending or choice_page >= _choice_page_count() - 1 func show_dialogue_choices(options: Array) -> void: hide_dialogue_choices() available_choices = options.duplicate(true) choice_page = 0 _render_choice_page() func _render_choice_page() -> void: _clear_choice_buttons() var page_count := _choice_page_count() if page_count == 0: choice_area.visible = false return choice_page = clampi(choice_page, 0, page_count - 1) var start_index := choice_page * CHOICES_PER_PAGE var end_index := mini(start_index + CHOICES_PER_PAGE, available_choices.size()) var visible_choice_count := end_index - start_index for index in range(start_index, end_index): var option: Dictionary = available_choices[index] var choice_id := str(option.get("id", "")) var option_text := str(option.get("text", "")) var button := TextureButton.new() button.set_meta("choice_id", choice_id) button.custom_minimum_size = Vector2( 0.0 if visible_choice_count == CHOICES_PER_PAGE else 350.0, 136.0) button.size_flags_horizontal = ( Control.SIZE_EXPAND_FILL if visible_choice_count == CHOICES_PER_PAGE else Control.SIZE_SHRINK_CENTER) button.ignore_texture_size = true button.stretch_mode = TextureButton.STRETCH_SCALE button.texture_normal = _crop_choice_texture(CHOICE_NORMAL) button.texture_hover = _crop_choice_texture(CHOICE_HOVER) button.texture_pressed = _crop_choice_texture(CHOICE_PRESSED) button.self_modulate = Color(1.0, 1.0, 1.0, 0.86) button.focus_mode = Control.FOCUS_ALL button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND button.mouse_entered.connect(_on_choice_hover.bind(button, true)) button.mouse_exited.connect(_on_choice_hover.bind(button, false)) button.button_down.connect(_on_choice_pressed_visual.bind(button, true)) button.button_up.connect(_on_choice_pressed_visual.bind(button, false)) button.pressed.connect(_on_dialogue_choice_pressed.bind(choice_id)) var label := Label.new() label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) label.offset_left = 28.0 label.offset_top = 12.0 label.offset_right = -28.0 label.offset_bottom = -12.0 label.mouse_filter = Control.MOUSE_FILTER_IGNORE label.add_theme_color_override("font_color", Color(0.055, 0.105, 0.145)) label.add_theme_font_size_override("font_size", _choice_font_size(option_text)) label.text = option_text label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART label.clip_text = true label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER button.add_child(label) choice_container.add_child(button) choice_pager.visible = page_count > 1 page_label.text = "Page %d of %d" % [choice_page + 1, page_count] previous_page_button.disabled = choice_page <= 0 next_page_button.disabled = choice_page >= page_count - 1 choice_area.visible = true choice_container.visible = true func hide_dialogue_choices() -> void: _clear_choice_buttons() available_choices = [] choice_page = 0 choice_container.visible = false choice_pager.visible = false choice_area.visible = false func _clear_choice_buttons() -> void: for child in choice_container.get_children(): choice_container.remove_child(child) child.queue_free() func _choice_page_count() -> int: return ceili(float(available_choices.size()) / float(CHOICES_PER_PAGE)) func _change_choice_page(direction: int) -> void: choice_page = clampi(choice_page + direction, 0, maxi(_choice_page_count() - 1, 0)) _render_choice_page() func _choice_font_size(text: String) -> int: if text.length() > 105: return 15 if text.length() > 75: return 16 return 17 func _crop_choice_texture(source: Texture2D) -> AtlasTexture: var cropped := AtlasTexture.new() cropped.atlas = source cropped.region = CHOICE_CROP cropped.filter_clip = true return cropped func _on_choice_hover(button: TextureButton, hovered: bool) -> void: button.self_modulate = ( Color(1.08, 1.05, 0.96, 0.94) if hovered else Color(1.0, 1.0, 1.0, 0.86) ) func _on_choice_pressed_visual(button: TextureButton, pressed: bool) -> void: button.position.y += 2.0 if pressed else -2.0 func _on_dialogue_choice_pressed(choice_id: String) -> void: if choice_id == "__continue": interview_continue_requested.emit() else: choice_selected.emit(choice_id) func show_debrief(debrief: Dictionary, score: Dictionary) -> void: computer_available = false close_computer() computer_launcher.visible = false hide_patient_dialogue() hide_dialogue_choices() if debrief_panel != null and is_instance_valid(debrief_panel): debrief_panel.queue_free() debrief_panel = PanelContainer.new() debrief_panel.name = "InterviewDebrief" debrief_panel.z_index = 50 debrief_panel.size = Vector2(870.0, 600.0) debrief_panel.position = (size - debrief_panel.size) * 0.5 var panel_style := StyleBoxFlat.new() panel_style.bg_color = Color(0.96, 0.95, 0.91, 0.97) panel_style.border_color = Color(0.12, 0.22, 0.28, 0.8) panel_style.set_border_width_all(2) panel_style.set_corner_radius_all(12) panel_style.set_content_margin_all(28.0) debrief_panel.add_theme_stylebox_override("panel", panel_style) add_child(debrief_panel) var content := VBoxContainer.new() content.add_theme_constant_override("separation", 16) debrief_panel.add_child(content) var heading := Label.new() heading.text = "Interview Debrief" heading.add_theme_font_size_override("font_size", 30) heading.add_theme_color_override("font_color", Color(0.055, 0.105, 0.145)) content.add_child(heading) var diagnosis := Label.new() diagnosis.text = str(debrief.get("likelyDiagnosis", "Interview complete")) diagnosis.add_theme_font_size_override("font_size", 23) diagnosis.add_theme_color_override("font_color", Color(0.12, 0.36, 0.27)) diagnosis.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART content.add_child(diagnosis) var summary := Label.new() summary.text = str(debrief.get("summary", "")) summary.add_theme_font_size_override("font_size", 18) summary.add_theme_color_override("font_color", Color(0.08, 0.12, 0.15)) summary.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART content.add_child(summary) var score_label := Label.new() score_label.text = "History coverage: %d%%" % int(round(float(score.get("percent", 0.0)))) score_label.add_theme_font_size_override("font_size", 20) content.add_child(score_label) var covered: Array[String] = [] var missed: Array[String] = [] for raw_criterion in score.get("criteria", []): var criterion: Dictionary = raw_criterion var title := str(criterion.get("title", "History topic")) if str(criterion.get("status", "")) == "credited": covered.append(title) elif str(criterion.get("status", "")) == "missed": missed.append(title) var coverage := Label.new() coverage.text = "Covered: %s\nMissed optional topics: %s" % [ ", ".join(covered), "None" if missed.is_empty() else ", ".join(missed)] coverage.add_theme_font_size_override("font_size", 16) coverage.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART content.add_child(coverage) var points := Label.new() var teaching_points: Array = debrief.get("teachingPoints", []) points.text = "Key points\n- " + "\n- ".join(teaching_points) if not teaching_points.is_empty() else "" points.add_theme_font_size_override("font_size", 17) points.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART points.size_flags_vertical = Control.SIZE_EXPAND_FILL content.add_child(points) var actions := HBoxContainer.new() actions.alignment = BoxContainer.ALIGNMENT_END actions.add_theme_constant_override("separation", 12) content.add_child(actions) var return_button := Button.new() return_button.text = "Return to Cases" return_button.custom_minimum_size = Vector2(190.0, 48.0) return_button.pressed.connect(func(): debrief_return_requested.emit()) actions.add_child(return_button) var repeat_button := Button.new() repeat_button.text = "Repeat Interview" repeat_button.custom_minimum_size = Vector2(190.0, 48.0) repeat_button.pressed.connect(func(): debrief_repeat_requested.emit()) actions.add_child(repeat_button)