Connect graphical CCS interviews to cases
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
extends Control
|
||||
|
||||
signal dialogue_choice_selected(index: int, text: String)
|
||||
signal choice_selected(choice_id: String)
|
||||
signal interview_continue_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")
|
||||
@@ -22,11 +23,8 @@ var dialogue_tween: Tween
|
||||
func _ready() -> void:
|
||||
_update_clock()
|
||||
_schedule_patient_blink()
|
||||
show_patient_dialogue("Hello, doctor.")
|
||||
show_dialogue_choices([
|
||||
"What brings you in today?",
|
||||
"How are you feeling today?",
|
||||
])
|
||||
show_patient_dialogue("Loading patient interview...")
|
||||
hide_dialogue_choices()
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
@@ -91,12 +89,28 @@ func _resize_dialogue_bubble() -> void:
|
||||
dialogue_bubble.size.y = target_height
|
||||
|
||||
|
||||
func show_dialogue_choices(options: Array[String]) -> void:
|
||||
func configure_interview(node: Dictionary) -> void:
|
||||
show_patient_dialogue(str(node.get("patientText", "")))
|
||||
if bool(node.get("isTerminal", false)):
|
||||
show_dialogue_choices([{"id": "__continue", "text": "Continue to Patient Management"}])
|
||||
else:
|
||||
show_dialogue_choices(node.get("choices", []))
|
||||
|
||||
|
||||
func set_choices_pending(pending: bool) -> void:
|
||||
for child in choice_container.get_children():
|
||||
if child is BaseButton:
|
||||
child.disabled = pending
|
||||
|
||||
|
||||
func show_dialogue_choices(options: Array) -> void:
|
||||
hide_dialogue_choices()
|
||||
var stack_height := options.size() * 97.0 + 8.0
|
||||
choice_container.offset_top = -4.0 - stack_height
|
||||
for index in options.size():
|
||||
var option_text := options[index]
|
||||
var option: Dictionary = options[index]
|
||||
var choice_id := str(option.get("id", ""))
|
||||
var option_text := str(option.get("text", ""))
|
||||
var button := TextureButton.new()
|
||||
button.custom_minimum_size = Vector2(420.0, 105.0)
|
||||
button.ignore_texture_size = true
|
||||
@@ -111,7 +125,7 @@ func show_dialogue_choices(options: Array[String]) -> void:
|
||||
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(index, option_text))
|
||||
button.pressed.connect(_on_dialogue_choice_pressed.bind(choice_id))
|
||||
|
||||
var label := Label.new()
|
||||
label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
@@ -156,6 +170,8 @@ 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(index: int, option_text: String) -> void:
|
||||
dialogue_choice_selected.emit(index, option_text)
|
||||
hide_dialogue_choices()
|
||||
func _on_dialogue_choice_pressed(choice_id: String) -> void:
|
||||
if choice_id == "__continue":
|
||||
interview_continue_requested.emit()
|
||||
else:
|
||||
choice_selected.emit(choice_id)
|
||||
|
||||
Reference in New Issue
Block a user