extends Control #DeskAssets @onready var patient_file = $LowerHalf/Computer/Margin/ComputerScreen/ComputerTabs/FileContainer/PatientFile @onready var patient_file_title = $LowerHalf/Computer/Margin/ComputerScreen/ComputerTabs/FileContainer/PatientFileTitle @onready var patient_recording = $LowerHalf/Computer/Margin/ComputerScreen/ComputerTabs/Recording @onready var patient = $UpperHalf/ControlGlass/Patient @onready var next_patient = $LowerHalf/Computer/Margin/NextPatient @onready var end_day = $LowerHalf/Computer/Margin/EndDay @onready var green_button = $LowerHalf/GreenButton @onready var red_button = $LowerHalf/RedButton @onready var journal = $LowerHalf/Journal/JournalButton @onready var journal_layer = $LowerHalf/JournalLayer @onready var release = $LowerHalf/DecisionScreen/MarginContainer/HBoxContainer/Release @onready var terminate = $LowerHalf/DecisionScreen/MarginContainer/HBoxContainer/Terminate @onready var patient_color: Color @onready var computer_tabs = $LowerHalf/Computer/Margin/ComputerScreen/ComputerTabs @onready var computer_screen = $LowerHalf/Computer/Margin/ComputerScreen2 @onready var tab_patient_file = $LowerHalf/Computer/Margin/ComputerScreen/Tabs/PatientFile @onready var tab_rules = $LowerHalf/Computer/Margin/ComputerScreen/Tabs/Rules @onready var tab_recording = $LowerHalf/Computer/Margin/ComputerScreen/Tabs/Recording @onready var middle_screen = $LowerHalf/MiddleScreen/MarginContainer/MiddleInfo @onready var console_screen = $LowerHalf/ConsoleScreen/Margin/ConsoleText #RoomAssets @onready var shutter_top = $RoomAssets/ShutterTop @onready var shutter_bot = $RoomAssets/ShutterBot @onready var shutters_animation = $RoomAssets/ShuttersAnimation @onready var backroom = $RoomAssets/Backroom @onready var red_backroom = $RoomAssets/RedBackroom @onready var green_backroom = $RoomAssets/GreenBackroom #DialogueAssets @onready var patient_dialogue_resource: Resource @onready var end_of_day_dialogue_resource = load("res://Dialogues/end_of_day.dialogue") @onready var balloon: Node @onready var patient_emotions : Dictionary var main: Node var accurate_diagnoses = 0 func _ready() -> void: #Referencing main node main = get_parent() #Connecting signals next_patient.get_node("CallNextPatient").pressed.connect(self._on_call_next_patient_pressed) green_button.pressed.connect(self._on_green_button_pressed) red_button.pressed.connect(self._on_red_button_pressed) journal.pressed.connect(self._on_journal_pressed) journal_layer.get_node("JournalOpen/JournalMargin/PageArea/LeftPage/CloseManual").pressed.connect(self._on_close_manual_pressed) tab_patient_file.pressed.connect(self._on_tab_patient_file_pressed) tab_rules.pressed.connect(self._on_tab_rules_pressed) tab_recording.pressed.connect(self._on_tab_recording_pressed) Globals.console_message.connect(self.console_display) Globals.response_chosen.connect(self._on_response_chosen) #Hiding RoomAssets for room_asset in [shutter_top, shutter_bot, backroom, red_backroom, green_backroom]: room_asset.hide() #Hiding ComputerScreen, DialogueText and JournalOpen var nodes_to_hide = [next_patient, end_day, computer_screen, console_screen, journal_layer] + computer_tabs.get_children() for node in nodes_to_hide: node.hide() #Setting up Decision screen release.text = Globals.colorize("RELEASE", "web_gray") terminate.text = Globals.colorize("TERMINATE", "web_gray") for tab_button in [tab_patient_file, tab_rules, tab_recording]: #Hiding Tabs tab_button.hide() for button in [green_button, red_button]: #Disabling Buttons button.set_disabled(true) patient.hide() #Hiding Patient self.hide() #Hiding ScreeningDesk func new_patient(): Patient.new_patient() patient_file.text = Patient.file_text patient_file_title.text = Patient.file_title patient_recording.text = "" patient.texture = Patient.image func _on_call_next_patient_pressed(): #Brings in next patient and sets up the desk controls #Hiding the computer screen var scenes_to_hide = [next_patient] for scenes in scenes_to_hide: scenes.hide() #ShuttersIncoming shutters_animation.play("incoming") shutter_top.show() shutter_bot.show() await shutters_animation.animation_finished #Showing the Patient and the Backroom var scenes_to_show = [patient, backroom] for scene in scenes_to_show: scene.show() #Opening Shutters shutters_animation.play("open") await shutters_animation.animation_finished #Activating Buttons green_button.set_disabled(false) red_button.set_disabled(false) #Coloring Release and Terminate release.text = Globals.colorize("RELEASE", "dark_green") terminate.text = Globals.colorize("TERMINATE", "dark_red") #Starting Dialogue and hiding console screen console_screen.hide() main.start_balloon("test", Patient.dialogue_resource, "start") #Showing Computer Tabs and showing Patient File by default for node in [tab_patient_file, tab_rules, tab_recording]: node.show() node.set_mouse_filter(Control.MOUSE_FILTER_STOP) computer_tabs.get_node("FileContainer").show() func _recording_text(dialogue_line): #Records the dialogues var line = dialogue_line.text var character = dialogue_line.character patient_recording.append_text("\n\n") patient_recording.append_text("[color=red]" + character + "[/color]" + "\n") patient_recording.append_text(line) func _on_response_chosen(response): #Adds protagonist responses to the recording tab patient_recording.append_text("\n\n") patient_recording.append_text("[color=green]You[/color]" + "\n") patient_recording.append_text(response.text) func _on_tab_patient_file_pressed(): #Shows the patient file tab #Highlighting pressed tab button and unpressing the others tab_patient_file.set_pressed(true) tab_patient_file.set_mouse_filter(Control.MOUSE_FILTER_IGNORE) for tab_button in [tab_rules, tab_recording]: tab_button.set_pressed(false) tab_button.set_mouse_filter(Control.MOUSE_FILTER_STOP) #Showing desired tab and hiding the others for node in computer_tabs.get_children(): node.hide() computer_tabs.get_node("FileContainer").show() func _on_tab_rules_pressed(): #Shows the rules tab #Highlighting pressed tab button and unpressing the others tab_rules.set_pressed(true) tab_rules.set_mouse_filter(Control.MOUSE_FILTER_IGNORE) for tab_button in [tab_patient_file, tab_recording]: tab_button.set_pressed(false) tab_button.set_mouse_filter(Control.MOUSE_FILTER_STOP) #Showing desired tab and hiding the others for node in computer_tabs.get_children(): node.hide() computer_tabs.get_node("Rules").show() func _on_tab_recording_pressed(): #Shows the recording tab #Highlighting pressed tab button and unpressing the others tab_recording.set_pressed(true) tab_recording.set_mouse_filter(Control.MOUSE_FILTER_IGNORE) for tab_button in [tab_patient_file, tab_rules]: tab_button.set_pressed(false) tab_button.set_mouse_filter(Control.MOUSE_FILTER_STOP) #Showing desired tab and hiding the others for node in computer_tabs.get_children(): node.hide() computer_tabs.get_node("Recording").show() func _change_emotion(dialogue_line) -> void: #Change emotions following dialogue tags var line_tag = dialogue_line.tags if line_tag.is_empty() == false: var new_emotion = line_tag[0] patient.texture = Patient.emotions[String(new_emotion)] print("Emotion changed to ", new_emotion) func _on_green_button_pressed(): #Releases the patient release.text = Globals.colorize("RELEASE", "green") #Highlighting the decision #Greening the vibe green_backroom.show() patient.modulate = Color(0.4,1,0.4,1) clear_patient("release") #Clearing the patient func _on_red_button_pressed(): #Terminates the patient terminate.text = Globals.colorize("TERMINATE", "red") #Highlighting the decision #Redding the vibe red_backroom.show() patient.modulate = Color(1,0,0,1) clear_patient("terminate") #Clearing the patient func _on_journal_pressed(): #Shows the journal journal_layer.show() func _on_close_manual_pressed(): #Hides the journal journal_layer.hide() func clear_patient(choice:String): #Clears patient and transitions towards next patient or end of day #Hiding computer tabs screen and console screen for node in [tab_patient_file, tab_rules, tab_recording, console_screen] + computer_tabs.get_children(): node.hide() #Disabling Buttons green_button.set_mouse_filter(Control.MOUSE_FILTER_IGNORE) red_button.set_mouse_filter(Control.MOUSE_FILTER_IGNORE) #Setting up computer and console messages var message: Array[String] message.resize(3) if choice == "release": message[0] = Globals.colorize("- ASSESSMENT MADE -\n\n- LOADING RELEASE PROTOCOL... -", "green_yellow") message[1] = Globals.colorize("- RELEASING SUBJECT -", "green_yellow") message[2] = "EVALUATION RECORDED" + "\n\nPATIENT STATUS: " + Globals.colorize("HUMAN", "green") + "\n\nUPDATING DATABASE...\n\n" + Globals.colorize("INITIATING RELEASE SEQUENCE", "green_yellow") elif choice == "terminate": message[0] = Globals.colorize("- ASSESSMENT MADE -\n\n- LOADING TERMINATION PROTOCOL... -", "orange_red") message[1] = Globals.colorize("- TERMINATING SUBJECT -", "orange_red") message[2] = "EVALUATION RECORDED" + "\n\nPATIENT STATUS: " + Globals.colorize("ABNORMAL", "red") + "\n\nUPDATING DATABASE...\n\n" + Globals.colorize("INITIATING TERMINATION SEQUENCE", "orange_red") console_display(message[0]) computer_display(message[2]) #Final Patient Dialogue main.start_balloon("test", Patient.dialogue_resource, choice) await DialogueManager.dialogue_ended #Updating middle screen info and accurate_diagnoses value if (Patient.abnormal == true and choice == "terminate") or (Patient.abnormal == false and choice == "release"): accurate_diagnoses += 1 update_middle_screen(Globals.day_count, Globals.floor_count, accurate_diagnoses, Globals.diagnoses_quota) #Showing second console message console_display(message[1]) #Closing Shutters shutters_animation.play("close") await shutters_animation.animation_finished #Hiding the cell and restoring the patient's original color for scene in [patient, backroom, red_backroom, green_backroom]: scene.hide() patient.modulate = Patient.original_color #Hiding Computer screen and resetting Console screen once the animation is done shutters_animation.play(choice) await shutters_animation.animation_finished console_display(Globals.directives) computer_screen.hide() #Updating patient count Globals.patient_count += 1 if Globals.patient_count <= Globals.daily_patient_limit: print("daily_limit not reached") else: print("daily_limit reached") if Globals.patient_count <= Globals.daily_patient_limit: #Setting Up Next Patient new_patient() next_patient.show() else: Globals.patient_count = 1 end_day.show() #Reenabling mouse filter and resetting buttons for button in [green_button, red_button]: button.set_mouse_filter(Control.MOUSE_FILTER_STOP) button.set_pressed(false) button.set_disabled(true) #Resetting decision screen release.text = Globals.colorize("RELEASE", "web_gray") terminate.text = Globals.colorize("TERMINATE", "web_gray") func console_display(message): #Displays a message on the console screen var text = message text = text.replace("\\n", "\n") #Replaces litteral backslashes by actual newlines (necessary because of Dialogue Manager) console_screen.text = text console_screen.show() func computer_display(message): #Displays a message on the computer screen var text = message text = text.replace("\\n", "\n") #Replaces litteral backslashes by actual newlines (necessary because of Dialogue Manager) computer_screen.text = text computer_screen.show() func update_middle_screen(day_count, floor_count, diagnoses_count, diagnoses_quota): #Updates Middle Screen Info var day = Globals.colorize(str(day_count), "dark_orange") var floor = Globals.colorize(str(floor_count), "dark_orange") var diagnoses = Globals.colorize(str(diagnoses_count) + "/" + str(diagnoses_quota), "dark_orange") var text = "DAY: " + day + "\n\nFLOOR: " + floor + "\n\nACCURATE DIAGNOSES: " + diagnoses middle_screen.text = text