Expand CCS patient history

This commit is contained in:
hz
2026-08-09 23:59:28 -05:00
parent d349998d12
commit 33b55753cb
8 changed files with 306 additions and 75 deletions
+115 -33
View File
@@ -38,6 +38,11 @@ const DIALOGUE_BUBBLE_VERTICAL_CHROME := 95.0
@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
@@ -54,8 +59,9 @@ var dialogue_reveal_complete := false
var dialogue_layout_generation := 0
var dialogue_input_enabled := true
var computer_available := true
var vitals_dragging := false
var vitals_drag_offset := Vector2.ZERO
var computer_drag_window: Control
var computer_drag_offset := Vector2.ZERO
var computer_window_z := 2
func _ready() -> void:
@@ -65,10 +71,17 @@ func _ready() -> void:
computer_close_button.pressed.connect(close_computer)
vitals_launcher.pressed.connect(open_vitals)
vitals_close_button.pressed.connect(close_vitals)
vitals_header.gui_input.connect(_on_vitals_header_gui_input)
resized.connect(_resize_vitals_window)
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()
_resize_vitals_window()
_style_computer_window(medical_history_window)
_resize_computer_windows()
_update_clock()
_schedule_patient_blink()
hide_patient_dialogue()
@@ -93,7 +106,7 @@ func _update_clock() -> void:
func configure_presentation(
presentation: Dictionary, simulated_start: String, simulated_minute: int,
vitals: Dictionary = {}) -> void:
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)
@@ -102,6 +115,9 @@ func configure_presentation(
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:
@@ -284,6 +300,7 @@ 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():
@@ -296,25 +313,28 @@ func is_computer_open() -> bool:
func close_transient_overlay() -> bool:
if close_vitals():
return true
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 or vitals_window.visible:
if not computer_overlay.visible:
return
vitals_window.visible = true
vitals_launcher.visible = false
_bring_computer_window_to_front(vitals_window)
vitals_close_button.grab_focus()
func close_vitals() -> bool:
if not vitals_window.visible:
return false
vitals_dragging = false
if computer_drag_window == vitals_window:
computer_drag_window = null
vitals_window.visible = false
vitals_launcher.visible = true
return true
@@ -322,6 +342,27 @@ 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)
@@ -399,6 +440,10 @@ func _friendly_vital_name(key: String) -> String:
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)
@@ -406,46 +451,83 @@ func _style_vitals_window() -> void:
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
vitals_window.add_theme_stylebox_override("panel", panel_style)
window.add_theme_stylebox_override("panel", panel_style)
func _resize_vitals_window() -> void:
if vitals_window == null:
func _resize_computer_windows() -> void:
if vitals_window == null or medical_history_window == null:
return
var window_size := Vector2(
var vitals_size := Vector2(
minf(720.0, maxf(320.0, size.x - 48.0)),
minf(540.0, maxf(360.0, size.y - 48.0)))
vitals_window.offset_left = -window_size.x * 0.5
vitals_window.offset_top = -window_size.y * 0.5
vitals_window.offset_right = window_size.x * 0.5
vitals_window.offset_bottom = window_size.y * 0.5
_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 _on_vitals_header_gui_input(event: InputEvent) -> void:
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 vitals_close_button.get_global_rect().has_point(event.global_position):
if close_button.get_global_rect().has_point(event.global_position):
return
vitals_dragging = true
vitals_drag_offset = event.global_position - vitals_window.global_position
computer_drag_window = window
computer_drag_offset = event.global_position - window.global_position
_bring_computer_window_to_front(window)
else:
vitals_dragging = false
vitals_header.accept_event()
elif event is InputEventMouseMotion and vitals_dragging:
var target_global: Vector2 = event.global_position - vitals_drag_offset
_set_vitals_window_position(target_global - global_position)
vitals_header.accept_event()
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 - vitals_window.size.x),
maxf(0.0, size.y - vitals_window.size.y))
vitals_window.position = 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