Save/Load rework

This commit is contained in:
2026-03-01 14:10:51 +01:00
parent d4a533bf17
commit b24addcee6
42 changed files with 1315 additions and 154 deletions
+7
View File
@@ -77,3 +77,10 @@ func _on_response_chosen(response): #Adds protagonist responses to the recording
recording.append_text("\n\n")
recording.append_text("[color=green]You[/color]" + "\n")
recording.append_text(response.text)
#Resets to initial state
func reset():
for node in tab_list + screen_list + [screen, next_patient_button]:
node.hide()
+6
View File
@@ -13,3 +13,9 @@ func display(message):
text_to_display = text_to_display.replace("\\n", "\n") #Replaces litteral backslashes by actual newlines (necessary because of Dialogue Manager)
text = text_to_display
show()
#Resets to initial state
func reset():
text = ""
hide()
+7
View File
@@ -12,3 +12,10 @@ func _on_green_button_pressed():
decision_made.emit("release")
set_toggle_mode(true)
set_pressed_no_signal(true)
#Resets to initial state
func reset():
set_mouse_filter(Control.MOUSE_FILTER_STOP)
set_disabled(true)
set_toggle_mode(false)
set_pressed(false)
+5
View File
@@ -42,3 +42,8 @@ func update_journal(floor_count:int):
for symptom in symptoms_detailed[i]:
symptoms_page += "\n\n" + symptom
journal_symptoms.text = symptoms_page
#Resets to initial state
func reset():
hide()
+6 -2
View File
@@ -2,8 +2,6 @@ extends TextureRect
func _ready() -> void:
#Hiding
hide()
@@ -16,3 +14,9 @@ func _change_emotion(dialogue_line) -> void:
var new_emotion = line_tag[0]
texture = Patient.emotions[String(new_emotion)]
print("Patient emotion changed to ", new_emotion)
#Resets to initial state
func reset():
modulate = Patient.original_color
hide()
+52 -8
View File
@@ -24,7 +24,10 @@ var symptoms_arrays: Array[Array] = [
["VISUAL HALLUCINATIONS", "HETERO-AGRESSIVE BEHAVIOUR"]
]
#Lists of possible patients sorted by floor
var patient_list : Array[Dictionary]
var og_patient_list : Array[Dictionary]
var patient_list: Array[Dictionary]
var og_its_patient_list = ["its_01"]
var its_patient_list = []
#Supervisor file path
var supervisor_name = "loeveth"
@@ -36,8 +39,10 @@ func _ready() -> void:
marker.resize(100)
marker.fill(0)
#Setting up patient list
#Setting up patient lists
og_patient_list.resize(len(symptoms_arrays))
patient_list.resize(len(symptoms_arrays))
its_patient_list = og_its_patient_list
original_color = texture.modulate #Saving original modulation color to reset it after modification
@@ -58,6 +63,11 @@ func new_patient(patient_id):
var file_path: String
#Updating Global variables
Globals.patient_id = patient_id
Globals.patients_seen.append(patient_id)
print("Patients seen list: " + str(Globals.patients_seen))
#Loading Patient Files
var config := ConfigFile.new()
file_path = "res://Dialogues/Patients/patient_" + patient_id + "_file.cfg"
@@ -151,11 +161,12 @@ func sort_patients():
break
if symptom_matched:
for k in range(j, symptoms_arrays.size()):
patient_list[k].merge({patient_id: j+1}) # Adds the patient to every floor compatible
og_patient_list[k].merge({patient_id: j+1}) # Adds the patient to every floor compatible
symptom_matched = false
break
for i in range(len(patient_list)):
patient_list[i] = og_patient_list[i]
print("Floor " + str(i) + " possible patients: " + str(patient_list[i]))
@@ -186,16 +197,30 @@ func generate_patient_id() -> String: #Generates a patient ID
var floor_index = -Globals.floor_count -1
print("Floor Index: " + str(floor_index))
var patient_id = weighted_random(patient_list[floor_index]) #Picks a random patient depending on floor, with weighted odds
for j in range(len(patient_list)):
if len(patient_list[j]) > 1:
patient_list[j].erase(patient_id) #Removes picked patient from unseen patients list
print("Updated Floor " + str(j) + " list: " + str(patient_list[j]))
#Removes picked patient from patients list
for i in range(len(patient_list)):
if len(patient_list[i]) > 1:
patient_list[i].erase(patient_id)
print("Updated Floor " + str(i) + " list: " + str(patient_list[i]))
return patient_id
func generate_its_patient_id() -> String: #Generates an ITS patient ID
#Generating ITS patient ID
var its_patient_id = its_patient_list.pick_random()
print("ITS Patient selected: " + str(its_patient_id))
#Remove picked ITS patient from ITS patient list
if len(its_patient_list) > 1:
its_patient_list.erase(its_patient_id)
print("Updated ITS Patient list: " + str(its_patient_list))
return its_patient_id
func next_patient() -> String: #Decides next patient ID
var next_patient_id: String
@@ -204,6 +229,8 @@ func next_patient() -> String: #Decides next patient ID
-2:
if Globals.patient_count == 0:
next_patient_id = "its_00"
elif Globals.its_patient_count < 1:
next_patient_id = generate_its_patient_id()
else:
next_patient_id = generate_patient_id()
_:
@@ -211,4 +238,21 @@ func next_patient() -> String: #Decides next patient ID
return next_patient_id
func update_patient_list():
#Erasing patients already seen from patient lists
for patient_id in Globals.patients_seen:
for i in range(len(patient_list)):
if len(patient_list[i]) > 1:
patient_list[i].erase(patient_id)
#Erasing its patients already seen from its patient list
for its_patient_id in Globals.its_patients_seen:
if len(its_patient_list) > 1:
its_patient_list.erase(its_patient_id)
for j in range(len(patient_list)):
print("Loaded Floor " + str(j) + " list: " + str(patient_list[j]))
print("Loaded ITS Patient list: " + str(its_patient_list))
+10 -2
View File
@@ -4,11 +4,19 @@ signal decision_made
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
self.pressed.connect(self._on_green_button_pressed)
self.pressed.connect(self._on_red_button_pressed)
set_disabled(true)
func _on_green_button_pressed():
func _on_red_button_pressed():
if Globals.buttons_activated:
decision_made.emit("terminate")
set_toggle_mode(true)
set_pressed_no_signal(true)
#Resets to initial state
func reset():
set_mouse_filter(Control.MOUSE_FILTER_STOP)
set_disabled(true)
set_toggle_mode(false)
set_pressed(false)
+5
View File
@@ -9,3 +9,8 @@ func _ready() -> void:
func _on_release_display(message:String):
text = message
#Resets to initial state
func reset():
text = Globals.colorize("RELEASE", "web_gray")
+24
View File
@@ -0,0 +1,24 @@
extends Control
@onready var glass = $Glass
@onready var cell_wall = $CellWall
@onready var room = $Room
@onready var backwall = $Backwall
@onready var backwall_animation = $Backwall/BackwallAnimation
@onready var cell_top = $CellTop
@onready var cell_bot = $CellBot
@onready var cell_animation = $CellAnimation
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
#Resets to initial state
func reset():
cell_wall.modulate = Patient.original_color
for node in [cell_wall, cell_top, cell_bot]:
node.hide()
for node in [glass, room, backwall]:
node.show()
+1
View File
@@ -0,0 +1 @@
uid://bh5yd5cxceg24
+47 -57
View File
@@ -13,13 +13,7 @@ extends Control
@onready var computer = $LowerHalf/Computer
@onready var middle_screen = $LowerHalf/MiddleScreen/MarginContainer/MiddleScreen
@onready var console_screen = $LowerHalf/Console/Margin/ConsoleScreen
#RoomAssets
@onready var cell_top = $RoomAssets/CellTop
@onready var cell_bot = $RoomAssets/CellBot
@onready var cell_animation = $RoomAssets/CellAnimation
@onready var cell_wall = $RoomAssets/CellWall
@onready var backwall_animation = $RoomAssets/Backwall/BackwallAnimation
@onready var room_assets = $RoomAssets
#DialogueAssets
@onready var patient_dialogue_resource: Resource
@@ -44,35 +38,30 @@ func _ready() -> void:
Globals.clear_patient.connect(self._on_clear_patient)
Globals.color_change.connect(self._on_color_change)
#Hiding and showing appropriate RoomAssets
for room_asset in [cell_top, cell_bot, cell_wall]:
room_asset.hide()
for room_asset in [$RoomAssets/Glass, $RoomAssets/Room, $RoomAssets/Backwall]:
room_asset.show()
#$RoomAssets/Backwall.position = Vector2(0, -2700)
room_assets.reset()
hide() #Hiding ScreeningDesk
message_array.resize(3) #Setting up message array
#Selecting next patient
func new_patient():
var new_id = Patient.next_patient()
Patient.new_patient("its_01") #Line for testing purposes
#Patient.new_patient(new_id) #Line for generating new patient
#Patient.new_patient("its_01") #Line for testing purposes
Patient.new_patient(new_id) #Line for generating new patient
computer.patient_file.text = Patient.file_text
computer.recording.text = ""
patient.texture = Patient.image
#Setting up UI
computer.next_patient_button.show()
console_screen.display(Globals.directives)
func _on_call_next_patient_pressed(): #Brings in next patient and sets up the desk controls
#Selecting next_patient
new_patient()
#Hiding the next_patient button
var scenes_to_hide = [computer.next_patient_button, supervisor]
for scenes in scenes_to_hide:
@@ -86,19 +75,21 @@ func _on_call_next_patient_pressed(): #Brings in next patient and sets up the de
console_screen.display(message)
#Shutters entry animation
cell_animation.play("incoming")
cell_top.show()
cell_bot.show()
await cell_animation.animation_finished
room_assets.cell_animation.play("incoming")
room_assets.cell_top.show()
room_assets.cell_bot.show()
await room_assets.cell_animation.animation_finished
#Showing the Patient and the Backroom
var scenes_to_show = [patient, cell_wall]
var scenes_to_show = [patient, room_assets.cell_wall]
for scene in scenes_to_show:
scene.show()
#Opening Shutters
cell_animation.play("open")
await cell_animation.animation_finished
room_assets.cell_animation.play("open")
await room_assets.cell_animation.animation_finished
room_assets.cell_top.hide()
room_assets.cell_bot.hide()
#Activating Buttons
green_button.set_disabled(false)
@@ -162,37 +153,29 @@ func _on_clear_patient(choice:String):
console_screen.display(message_array[1])
#Closing Shutters
cell_animation.play("close")
await cell_animation.animation_finished
room_assets.cell_top.show()
room_assets.cell_bot.show()
room_assets.cell_animation.play("close")
await room_assets.cell_animation.animation_finished
#Hiding the cell and restoring the backroom and patient's original colors
for scene in [patient, cell_wall]:
scene.hide()
patient.modulate = Patient.original_color
cell_wall.modulate = Patient.original_color
#Hiding patient and cell_wall
for node in [patient, room_assets.cell_wall]:
node.hide()
#Hiding Computer screen and resetting Console screen once the animation is done
cell_animation.play(choice)
await cell_animation.animation_finished
computer.screen.hide()
console_screen.hide()
#Playing release or terminate cell animation
room_assets.cell_animation.play(choice)
await room_assets.cell_animation.animation_finished
#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_toggle_mode(false)
button.set_disabled(true)
#Resetting decision screen
release.text = Globals.colorize("RELEASE", "web_gray")
terminate.text = Globals.colorize("TERMINATE", "web_gray")
#Resetting the scene
reset()
#Descending Floor if diagnoses_quota reached
if accurate_diagnoses == Globals.diagnoses_quota:
descend_floor()
else:
new_patient()
#Setting up UI
computer.next_patient_button.show()
console_screen.display(Globals.directives)
func _on_color_change(color: String): #Modulating backroom and patient colors
@@ -205,7 +188,7 @@ func _on_color_change(color: String): #Modulating backroom and patient colors
"green":
new_color = Color(0.5,1,0.5,1)
patient.modulate = new_color
cell_wall.modulate = new_color
room_assets.cell_wall.modulate = new_color
print("Color changed to: " + str(new_color))
@@ -219,10 +202,10 @@ func descend_floor(): #Descends to next floor
console_screen.display(message)
#Descending animation
backwall_animation.play("going_down_1")
await backwall_animation.animation_finished
backwall_animation.play("going_down_2")
await backwall_animation.animation_finished
room_assets.backwall_animation.play("going_down_1")
await room_assets.backwall_animation.animation_finished
room_assets.backwall_animation.play("going_down_2")
await room_assets.backwall_animation.animation_finished
#Updating middle screen info
Globals.floor_count -= 1
@@ -244,6 +227,13 @@ func descend_floor(): #Descends to next floor
supervisor.dialogue("interfloor_" + str(-Globals.floor_count-1))
await supervisor.dialogue_finished
#Setting up new patient
new_patient()
#Setting up UI
computer.next_patient_button.show()
console_screen.display(Globals.directives)
#Resets to initial state
func reset():
for node in [patient, supervisor, journal_layer, computer, console_screen, release, terminate,
green_button, red_button, room_assets]:
node.reset()
+3 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=59 format=3 uid="uid://chytk2cctjk3x"]
[gd_scene load_steps=60 format=3 uid="uid://chytk2cctjk3x"]
[ext_resource type="Script" uid="uid://b3ms0imu0umn8" path="res://Scenes/screening_desk/screening_desk.gd" id="1_1s7k3"]
[ext_resource type="Script" uid="uid://dcax2vggaexnr" path="res://Scenes/screening_desk/journal_layer.gd" id="3_8gteb"]
@@ -39,6 +39,7 @@
[ext_resource type="Texture2D" uid="uid://q34mpgfv5upt" path="res://Art/Rooms/screening_room/backwall_extended.png" id="28_w70jd"]
[ext_resource type="Texture2D" uid="uid://cqwn5qo7kab4x" path="res://Art/Rooms/screening_room/cell_bot.png" id="29_43vqp"]
[ext_resource type="Texture2D" uid="uid://c6ary7qg7jhc6" path="res://Art/Rooms/screening_room/decision_screen.png" id="29_cobue"]
[ext_resource type="Script" uid="uid://bh5yd5cxceg24" path="res://Scenes/screening_desk/room_assets.gd" id="34_7jdsc"]
[sub_resource type="Theme" id="Theme_63o5x"]
RichTextLabel/fonts/normal_font = ExtResource("14_0pvwy")
@@ -953,6 +954,7 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
script = ExtResource("34_7jdsc")
[node name="Glass" type="TextureRect" parent="RoomAssets"]
modulate = Color(1, 1, 1, 0.078431375)
+7
View File
@@ -101,3 +101,10 @@ func _change_emotion(dialogue_line) -> void:
var new_emotion = line_tag[0]
texture = Patient.emotions[String(new_emotion)]
print("Supervisor emotion changed to ", new_emotion)
#Resets to initial state
func reset():
hide_spray()
await hide_done
hide()
+5
View File
@@ -9,3 +9,8 @@ func _ready() -> void:
func _on_terminate_display(message:String):
text = message
#Resets to initial state
func reset():
text = Globals.colorize("TERMINATE", "web_gray")