extends Control @onready var panel_container = $Background/HBoxContainer/MarginContainer/VBoxContainer/FaceMarginContainer/PanelContainer @onready var margin_container = $Background/HBoxContainer/MarginContainer/VBoxContainer/FaceMarginContainer/PanelContainer/MarginContainer @onready var patient_file = $Background/HBoxContainer/MarginContainer/VBoxContainer/FaceMarginContainer/PanelContainer/MarginContainer/FileContainer/PatientFile @onready var patient_file_title = $Background/HBoxContainer/MarginContainer/VBoxContainer/FaceMarginContainer/PanelContainer/MarginContainer/FileContainer/HBoxContainer/PatientFileTitle @onready var patient_recording = $Background/HBoxContainer/MarginContainer/VBoxContainer/FaceMarginContainer/PanelContainer/MarginContainer/RecordingContainer/Recording @onready var patient_recording_title = $Background/HBoxContainer/MarginContainer/VBoxContainer/FaceMarginContainer/PanelContainer/MarginContainer/RecordingContainer/HBoxContainer/RecordTitle @onready var face_zoom = $Background/HBoxContainer/MarginContainer/VBoxContainer/FaceMarginContainer/FaceZoom @onready var alone_controls = $Background/HBoxContainer/MarginContainer/VBoxContainer/ControlsMarginContainer/Alone @onready var patient_controls = $Background/HBoxContainer/MarginContainer/VBoxContainer/ControlsMarginContainer/Patient @onready var patient_texture = $Background/HBoxContainer/Desk/PatientTextureRect @onready var dialogue_resource: Resource @onready var balloon: Node @onready var patient_emotions : Dictionary # Called when the node enters the scene tree for the first time. func _ready() -> void: #Connecting signals alone_controls.get_node("PatientFile").pressed.connect(self._patient_file) alone_controls.get_node("Guidebook").pressed.connect(self._guidebook) alone_controls.get_node("CallNextPatient").pressed.connect(self._call_next_patient) patient_controls.get_node("PatientFile").pressed.connect(self._patient_file) patient_controls.get_node("Guidebook").pressed.connect(self._guidebook) patient_controls.get_node("PatientRecording").pressed.connect(self._patient_recording) patient_controls.get_node("Examine").pressed.connect(self._examine) #Hiding everything self.hide() for node in margin_container.get_children(): node.hide() panel_container.hide() face_zoom.hide() patient_controls.hide() patient_texture.hide() func gameplay_loop(patient_id): new_patient(patient_id) func new_patient(patient_id): #Connecting Signals patient_controls.get_node("Containment").pressed.connect(self._on_containment_pressed) patient_controls.get_node("PsychWard").pressed.connect(self._on_psych_ward_pressed) #Loading Patient Files var file_path: String = "res://Dialogues/Patients/patient_" + patient_id + "_file.txt" var file = FileAccess.open(file_path, FileAccess.READ) var file_content = file.get_as_text() patient_file.text = file_content patient_file_title.text = "\nPATIENT FILE #" + patient_id file.close() #Loading Patient Recording patient_recording.text = "" patient_recording_title.text = "\nPATIENT RECORDING #" + patient_id #Loading Patient Texture file_path = "res://Art/Patients/patient_" + patient_id + "/patient_" + patient_id + "_full.png" patient_texture.texture = load(file_path) #Loading Face Emotions var face: Resource var emotion_branch: Dictionary for emotion in ["neutral", "smiling", "angry", "scared", "sad"]: file_path = "res://Art/Patients/patient_" + patient_id + "/patient_" + patient_id + "_" + emotion + ".png" face = load(file_path) if face != null: emotion_branch = {emotion: face} patient_emotions.merge(emotion_branch) #Loading Default Face face_zoom.texture = patient_emotions["neutral"] #Loading Dialogue Resource var dialogue_resource_path = "res://Dialogues/Patients/patient_" + patient_id + ".dialogue" dialogue_resource = load(dialogue_resource_path) func _patient_file(): for node in margin_container.get_children(): node.hide() panel_container.show() face_zoom.hide() margin_container.get_node("FileContainer").show() func _guidebook(): for node in margin_container.get_children(): node.hide() panel_container.show() face_zoom.hide() margin_container.get_node("Rules").show() func _call_next_patient(): #Hiding and Showing appropriate scenes var scenes_to_hide = [alone_controls, panel_container] + margin_container.get_children() var scenes_to_show = [patient_controls,patient_texture,face_zoom] TransitionScreen.transition("big", scenes_to_hide, scenes_to_show) await TransitionScreen.transition_finished #Starting Dialogue start_balloon("start") func _patient_recording(): for node in margin_container.get_children(): node.hide() panel_container.show() face_zoom.hide() margin_container.get_node("RecordingContainer").show() func _recording_text(dialogue_line): var line = dialogue_line.text var character = dialogue_line.character var character_colour : String patient_recording.append_text("\n\n") #Adjusting Character Colour if character != "": if character == "You": character_colour = "[color=darkgreen]" else : character_colour = "[color=darkred]" patient_recording.append_text(character_colour + character + "[/color]\n") patient_recording.append_text(line) func _examine(): for node in margin_container.get_children(): node.hide() panel_container.hide() face_zoom.show() func _change_emotion(dialogue_line) -> void: var line_tag = dialogue_line.tags if line_tag.is_empty() == false: var new_emotion = line_tag[0] print("Emotion changed to ", new_emotion) face_zoom.texture = patient_emotions[new_emotion] func _on_containment_pressed(): #Asking for Confirmation UI.confirmation_text.text = "[center]Do you really want to send this patient to [color=darkred]Containment[/color] ?[/center]" UI.confirmation_yes.pressed.connect(send_to_containment, CONNECT_ONE_SHOT) UI.confirmation_no.pressed.connect(func(): UI.confirmation_yes.disconnect("pressed", send_to_containment)) UI.confirmation_dialog.show() TransitionScreen.mask.visible = true func _on_psych_ward_pressed(): #Asking for Confirmation UI.confirmation_text.text = "[center]Do you really want to send this patient to the [color=darkgreen]Psych Ward[/color] ?[/center]" UI.confirmation_yes.pressed.connect(send_to_psych_ward, CONNECT_ONE_SHOT) UI.confirmation_no.pressed.connect(func(): UI.confirmation_yes.disconnect("pressed", send_to_psych_ward)) UI.confirmation_dialog.show() TransitionScreen.mask.visible = true func send_to_containment(): #Disconnecting signals var containment_node = patient_controls.get_node("Containment") var psych_ward_node = patient_controls.get_node("PsychWard") if containment_node.is_connected("pressed", _on_containment_pressed): containment_node.disconnect("pressed", _on_containment_pressed) if psych_ward_node.is_connected("pressed", _on_psych_ward_pressed): psych_ward_node.disconnect("pressed", _on_psych_ward_pressed) start_balloon("containment") await DialogueManager.dialogue_ended clear_patient() func send_to_psych_ward(): #Disconnecting signals to prevent changing choice var containment_node = patient_controls.get_node("Containment") var psych_ward_node = patient_controls.get_node("PsychWard") if containment_node.is_connected("pressed", _on_containment_pressed): containment_node.disconnect("pressed", _on_containment_pressed) if psych_ward_node.is_connected("pressed", _on_psych_ward_pressed): psych_ward_node.disconnect("pressed", _on_psych_ward_pressed) start_balloon("psych_ward") await DialogueManager.dialogue_ended clear_patient() func start_balloon(start_title: String): #Freeing Previous Balloon and Disconnecting DialogueManager signals if is_instance_valid(balloon): balloon.queue_free() if DialogueManager.is_connected("got_dialogue", _change_emotion): DialogueManager.disconnect("got_dialogue", _change_emotion) if DialogueManager.is_connected("got_dialogue", _recording_text): DialogueManager.disconnect("got_dialogue", _recording_text) #Instantiating a custom balloon var Balloon: Resource = load("res://Dialogues/balloon_small.tscn") balloon = Balloon.instantiate() get_tree().current_scene.add_child(balloon) #Starting Dialogue and connecting DialogueManager signals DialogueManager.got_dialogue.connect(_change_emotion) DialogueManager.got_dialogue.connect(_recording_text) balloon.start(dialogue_resource, start_title) func clear_patient(): #Hiding and Showing appropriate scenes var scenes_to_hide = [patient_controls, patient_texture, face_zoom] + margin_container.get_children() var scenes_to_show = [alone_controls, panel_container] TransitionScreen.transition("big", scenes_to_hide, scenes_to_show) await TransitionScreen.transition_finished new_patient("564") # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass