Add officer portrait defaults

This commit is contained in:
2026-06-18 03:45:39 +09:00
parent 2166ea51ef
commit 1b264081ea
8 changed files with 73 additions and 18 deletions

View File

@@ -2492,10 +2492,14 @@ func _normalize_dialogue_line(line) -> Dictionary:
var text := str(line.get("text", ""))
if text.is_empty():
return {}
var speaker := str(line.get("speaker", ""))
var portrait := str(line.get("portrait", ""))
if portrait.is_empty():
portrait = data_catalog.get_portrait_for_speaker(speaker)
return {
"speaker": str(line.get("speaker", "")),
"speaker": speaker,
"text": text,
"portrait": str(line.get("portrait", ""))
"portrait": portrait
}
return {}

View File

@@ -110,6 +110,17 @@ func get_class_def(class_id: String) -> Dictionary:
return _get_dict(classes, class_id).duplicate(true)
func get_portrait_for_speaker(speaker_name: String) -> String:
var normalized_speaker := _normalized_speaker_name(speaker_name)
if normalized_speaker.is_empty():
return ""
for officer_id in officers.keys():
var officer := _get_dict(officers, officer_id)
if _normalized_speaker_name(str(officer.get("name", ""))) == normalized_speaker:
return str(officer.get("portrait", ""))
return ""
func _load_json_object(path: String) -> Dictionary:
if not FileAccess.file_exists(path):
push_error("Missing data file: %s" % path)
@@ -132,6 +143,10 @@ func _get_dict(source: Dictionary, key) -> Dictionary:
return {}
func _normalized_speaker_name(value: String) -> String:
return value.strip_edges().to_lower()
func _merged_equipment(base_equipment, override_equipment) -> Dictionary:
var result := {}
if typeof(base_equipment) == TYPE_DICTIONARY: