diff --git a/asset/audio/peiyin/c02_吕萍_01_梦楼.mp3 b/asset/audio/peiyin/c02_吕萍_01_梦楼.mp3 new file mode 100755 index 00000000..fb51ef9a Binary files /dev/null and b/asset/audio/peiyin/c02_吕萍_01_梦楼.mp3 differ diff --git a/asset/audio/peiyin/ogg/c02_吕萍_01_梦楼.ogg b/asset/audio/peiyin/ogg/c02_吕萍_01_梦楼.ogg new file mode 100644 index 00000000..0044356c Binary files /dev/null and b/asset/audio/peiyin/ogg/c02_吕萍_01_梦楼.ogg differ diff --git a/asset/dialogue/c01.en.translation b/asset/dialogue/c01.en.translation index 9117625d..a3e0be88 100644 Binary files a/asset/dialogue/c01.en.translation and b/asset/dialogue/c01.en.translation differ diff --git a/asset/dialogue/c01.zh_Hans.translation b/asset/dialogue/c01.zh_Hans.translation index bd625502..3049cf50 100644 Binary files a/asset/dialogue/c01.zh_Hans.translation and b/asset/dialogue/c01.zh_Hans.translation differ diff --git a/asset/dialogue/c02.en.translation b/asset/dialogue/c02.en.translation index 96922629..4ff31d6e 100644 Binary files a/asset/dialogue/c02.en.translation and b/asset/dialogue/c02.en.translation differ diff --git a/asset/dialogue/c02.zh_Hans.translation b/asset/dialogue/c02.zh_Hans.translation index 10fb582a..a08ee5e5 100644 Binary files a/asset/dialogue/c02.zh_Hans.translation and b/asset/dialogue/c02.zh_Hans.translation differ diff --git a/asset/dialogue/inspect_content.csv b/asset/dialogue/inspect_content.csv new file mode 100644 index 00000000..fa0f0915 --- /dev/null +++ b/asset/dialogue/inspect_content.csv @@ -0,0 +1,5 @@ +keys,zh_Hans,_character,_notes,_tags +t344c97cf2c,据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。,,, +tdb119a3714,有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。,,, +ta750647b12,《申报》,,, +t736cca4563,民国五年一月十三日,,, diff --git a/asset/dialogue/inspect_content.dialogue b/asset/dialogue/inspect_content.dialogue new file mode 100644 index 00000000..b27b5824 --- /dev/null +++ b/asset/dialogue/inspect_content.dialogue @@ -0,0 +1,6 @@ +~ c02_鼠疫海报 +据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。 [ID:t344c97cf2c] +有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。 [ID:tdb119a3714] +《申报》 [ID:ta750647b12] +民国五年一月十三日 [ID:t736cca4563] +=> END \ No newline at end of file diff --git a/asset/dialogue/inspect_content.zh_Hans.translation b/asset/dialogue/inspect_content.zh_Hans.translation new file mode 100644 index 00000000..01bbfdb5 Binary files /dev/null and b/asset/dialogue/inspect_content.zh_Hans.translation differ diff --git a/asset/dialogue/item_description.csv b/asset/dialogue/item_description.csv index 1c59f80e..7aaac76b 100644 --- a/asset/dialogue/item_description.csv +++ b/asset/dialogue/item_description.csv @@ -1,5 +1,11 @@ keys,zh_Hans,en,_character,_notes,_tags -notes_纸条,(纸条),,,, [#item] +ui_退出,退出,Exit,,, +ui_阅读,阅读,Read,,, +ui_收起,收起,Hold,,, +prop_小猫玩具的脑袋,小猫玩具的脑袋,Catty's Head,,, +prop_绳子,绳子,Rope,,, +prop_1012钥匙,1012钥匙,1012 Key,,, +notes_纸条,(纸条),,,, notes_锁住了,(锁住了),,,, notes_打不开,(打不开),,,, notes_干掉的血迹,(干掉的血迹),,,, @@ -8,15 +14,14 @@ notes_无法触碰,(无法触碰),,,, notes_挂画,(挂画),,,, notes_相框,(相框),,,, notes_寻人启事,(寻人启事),,,, -c01_在这儿吗,“在这儿吗......”,,,, c01_纸包钥匙,(一张纸条包着钥匙),,,, c02_绳子剪刀,(绳子和剪刀),,,, -c02_似乎是寻人启事,(似乎是一张寻人启事),,,, -c02_寻人启示,(脸的部分被撕掉了,看不清),,,, +c02_寻人启事1,(似乎是一张寻人启事),,,, +c02_寻人启事2,(脸的部分被撕掉了,看不清),,,, c02_玩具缺脑袋,(这个玩具缺了个脑袋),,,, c02_卫生宣传画,(几张卫生宣传画),,,, -(一个老鼠洞),(一个老鼠洞),,,, -c02_老鼠洞,(在这种楼里挺常见的),,,, +c02_老鼠洞1,(一个老鼠洞),,,, +c02_老鼠洞2,(在这种楼里挺常见的),,,, c02_十几年前的报纸,(十几年前的报纸),,,, c02_又是寻人启示,(又是那张寻人启示),,,, c02_墙上的海报被撕掉了,(墙上的海报被撕掉了),,,, @@ -50,6 +55,7 @@ c02_锁开了,(锁开了),,,, c02_口袋里有东西,(口袋里有东西),,,, c02_雾太大,(雾太大了,看不清路),,,, c02_八音盒,(是个八音盒),,,, +=>en,=>en,,,, c02_祝女儿早日康复,(祝女儿早日康复),,,, c02_图案一样,(这图案和我手臂上的一摸一样),,,, c01_获得令牌,令牌,,获得,,[#item] diff --git a/asset/dialogue/item_description.dialogue b/asset/dialogue/item_description.dialogue index 48655ce0..4c82c60e 100644 --- a/asset/dialogue/item_description.dialogue +++ b/asset/dialogue/item_description.dialogue @@ -1,62 +1,221 @@ -~ notes_文本 -# notes +# UI +~ UI +退出 [ID:ui_退出] +阅读 [ID:ui_阅读] +收起 [ID:ui_收起] +=> END! + +~ Prop +小猫玩具的脑袋 [ID:prop_小猫玩具的脑袋] +绳子 [ID:prop_绳子] +1012钥匙 [ID:prop_1012钥匙] +=> END! + +# notes 通用 +~ notes_纸条 (纸条) [ID:notes_纸条] -(锁住了) [ID:notes_锁住了] -(打不开) [ID:notes_打不开] + => END + +~ notes_锁住了 +(锁住了)[ID:notes_锁住了] + => END + +~ notes_打不开 +(打不开)[ID:notes_打不开] + => END + +~ notes_干掉的血迹 (干掉的血迹) [ID:notes_干掉的血迹] + => END + +~ notes_有什么东西 (有什么东西) [ID:notes_有什么东西] + => END + +~ notes_无法触碰 (无法触碰) [ID:notes_无法触碰] + => END + +~ notes_挂画 (挂画) [ID:notes_挂画] + => END + +~ notes_相框 (相框) [ID:notes_相框] + => END + +~ notes_寻人启事 (寻人启事) [ID:notes_寻人启事] + => END + # c01 -“在这儿吗......” [ID:c01_在这儿吗] +~ c01_纸包钥匙 (一张纸条包着钥匙) [ID:c01_纸包钥匙] + => END + # c02 +~ c02_绳子剪刀 (绳子和剪刀) [ID:c02_绳子剪刀] -(似乎是一张寻人启事) [ID:c02_似乎是寻人启事] -(脸的部分被撕掉了,看不清) [ID:c02_寻人启示] + => END + +~ c02_寻人启事 +(似乎是一张寻人启事) [ID:c02_寻人启事1] +(脸的部分被撕掉了,看不清) [ID:c02_寻人启事2] + => END + +~ c02_玩具缺脑袋 (这个玩具缺了个脑袋) [ID:c02_玩具缺脑袋] + => END + +~ c02_卫生宣传画 (几张卫生宣传画) [ID:c02_卫生宣传画] -(一个老鼠洞) -(在这种楼里挺常见的) [ID:c02_老鼠洞] + => END + +~ c02_老鼠洞 +(一个老鼠洞)[ID:c02_老鼠洞1] +(在这种楼里挺常见的) [ID:c02_老鼠洞2] + => END + +~ c02_十几年前的报纸 (十几年前的报纸) [ID:c02_十几年前的报纸] + => END + +~ c02_又是寻人启示 (又是那张寻人启示) [ID:c02_又是寻人启示] + => END + +~ c02_墙上的海报被撕掉了 (墙上的海报被撕掉了) [ID:c02_墙上的海报被撕掉了] + => END + +~ c02_井臭 (井里有一股臭味) [ID:c02_井臭] + => END + +~ c02_中药材 (车上放了一些中药材) [ID:c02_中药材] + => END + +~ c02_排队 (排队的人堵住了上楼的路) [ID:c02_排队] + => END + +~ c02_不要出去 (最好还是先不要出去) [ID:c02_不要出去] + => END + +~ c02_太阳 (太阳快落山了) [ID:c02_太阳] + => END + +~ c02_民国六年1015 (民国六年十月十五日) [ID:c02_民国六年1015] + => END + +~ c02_一个洞 (一个洞,里面好像还有空间) [ID:c02_一个洞] + => END + +~ c02_工具箱 (工具箱) [ID:c02_工具箱] + => END + +~ c02_找到有用的东西 (应该能找到有用的东西) [ID:c02_找到有用的东西] + => END + +~ c02_公寓告示 (公寓告示) [ID:c02_公寓告示] + => END + +~ c02_通往里间的门 (通往里间的门) [ID:c02_通往里间的门] + => END + +~ c02_花名册 (花名册) [ID:c02_花名册] + => END + +~ c02_罪 (罪) [ID:c02_罪] + => END + +~ c02_门上有什么东西 (门上有什么东西) [ID:c02_门上有什么东西] + => END + +~ c02_奠 (奠) [ID:c02_奠] + => END + +~ c02_寻夏小蝉 (失踪的小孩名叫夏小蝉) [ID:c02_寻夏小蝉] + => END + +~ c02_小猫干尸 (小猫的尸体已经干了) [ID:c02_小猫干尸] + => END + +~ c02_几块大洋 (几块大洋) [ID:c02_几块大洋] + => END + +~ c02_死老鼠 (死掉的老鼠) [ID:c02_死老鼠] + => END + +~ c02_石缝开花 (石缝里开了几束花) [ID:c02_石缝开花] + => END + +~ c02_石壁空间 (石壁另一头好像还有空间) [ID:c02_石壁空间] + => END + +~ c02_民国六年1221 (民国六年十二月二十一日) [ID:c02_民国六年1221] + => END + +~ c02_患者感谢信 (一些患者的感谢信) [ID:c02_患者感谢信] + => END + +~ c02_被撕掉的书 (一本被撕掉的书) [ID:c02_被撕掉的书] + => END + +~ c02_里面有什么东西 (里面有什么东西) [ID:c02_里面有什么东西] + => END + +~ c02_戏台上的诗 (戏台上面刻了一首诗) [ID:c02_戏台上的诗] + => END + +~ c02_锁开了 (锁开了) [ID:c02_锁开了] + => END + +~ c02_口袋里有东西 (口袋里有东西) [ID:c02_口袋里有东西] + => END + +~ c02_雾太大 (雾太大了,看不清路) [ID:c02_雾太大] + => END + +~ c02_八音盒 (是个八音盒) [ID:c02_八音盒] +=>en + +~ c02_祝女儿早日康复 (祝女儿早日康复) [ID:c02_祝女儿早日康复] + => END + +~ c02_图案一样 (这图案和我手臂上的一摸一样) [ID:c02_图案一样] -# c03 -=> END + => END + # 获得道具 ~ c01_获得令牌 diff --git a/asset/dialogue/item_description.en.translation b/asset/dialogue/item_description.en.translation index c829566f..66302494 100644 Binary files a/asset/dialogue/item_description.en.translation and b/asset/dialogue/item_description.en.translation differ diff --git a/asset/dialogue/item_description.zh_Hans.translation b/asset/dialogue/item_description.zh_Hans.translation index d9f328cc..d8894fae 100644 Binary files a/asset/dialogue/item_description.zh_Hans.translation and b/asset/dialogue/item_description.zh_Hans.translation differ diff --git a/asset/dialogue/names.en.translation b/asset/dialogue/names.en.translation index 54b57e6e..03d5511e 100644 Binary files a/asset/dialogue/names.en.translation and b/asset/dialogue/names.en.translation differ diff --git a/asset/dialogue/names.zh_Hans.translation b/asset/dialogue/names.zh_Hans.translation index 9f47d89b..1c69e475 100644 Binary files a/asset/dialogue/names.zh_Hans.translation and b/asset/dialogue/names.zh_Hans.translation differ diff --git a/manager/config_manager/global_config.gd b/manager/config_manager/global_config.gd index 2d581fa7..05f87731 100644 --- a/manager/config_manager/global_config.gd +++ b/manager/config_manager/global_config.gd @@ -7,6 +7,7 @@ const DEBUG = true const RES_FILE_FORMAT = ".tres" ## layers +const CANVAS_LAYER_DIALOG = 13 const CANVAS_LAYER_UI = 12 const CANVAS_LAYER_PROP_INSPECTOR = 11 const CANVAS_LAYER_SHADING = 10 diff --git a/manager/deploy/scene/scene_manager.gd b/manager/deploy/scene/scene_manager.gd index 63c7d953..d947a754 100644 --- a/manager/deploy/scene/scene_manager.gd +++ b/manager/deploy/scene/scene_manager.gd @@ -28,6 +28,12 @@ func freeze_player(lock_time: float, animation := ""): else: printerr("Player node not found") +func release_player(): + var player = get_player() + if player: + player.release_player() + else: + printerr("Player node not found") func set_camera_boundary(rect: Rect2) -> void: var camera_marker = CameraFocusMarker @@ -71,12 +77,12 @@ func pop_dialog( printerr("Dialog node not found") -func pop_note(note: String, note_color := "white", duration := 2.5) -> void: - var dialog_node = get_node_or_null("/root/Main/UILayer/Dialog") - if dialog_node: - dialog_node.append_note(note, note_color, duration) - else: - printerr("Dialog node not found") +# func pop_note(note: String, note_color := "white", duration := 2.5) -> void: +# var dialog_node = get_node_or_null("/root/Main/UILayer/Dialog") +# if dialog_node: +# dialog_node.append_note(note, note_color, duration) +# else: +# printerr("Dialog node not found") func get_inspector() -> PropInspector: diff --git a/project.godot b/project.godot index 0f19aeac..10079e1d 100644 --- a/project.godot +++ b/project.godot @@ -146,7 +146,7 @@ toggle_journal={ [internationalization] locale/translations=PackedStringArray("res://asset/dialogue/c01.en.translation", "res://asset/dialogue/c01.zh_Hans.translation", "res://asset/dialogue/c02.en.translation", "res://asset/dialogue/c02.zh_Hans.translation", "res://asset/dialogue/item_description.en.translation", "res://asset/dialogue/item_description.zh_Hans.translation", "res://asset/dialogue/names.en.translation", "res://asset/dialogue/names.zh_Hans.translation") -locale/translations_pot_files=PackedStringArray("res://asset/dialogue/item_description.dialogue", "res://asset/dialogue/c01.dialogue", "res://asset/dialogue/c02.dialogue") +locale/translations_pot_files=PackedStringArray("res://asset/dialogue/item_description.dialogue", "res://asset/dialogue/c01.dialogue", "res://asset/dialogue/c02.dialogue", "res://asset/dialogue/inspect_content.dialogue") locale/test="zh-Hans" locale/fallback="zh" diff --git a/scene/dialog/balloon.gd b/scene/dialog/balloon.gd index 95075287..58b70717 100755 --- a/scene/dialog/balloon.gd +++ b/scene/dialog/balloon.gd @@ -125,6 +125,7 @@ var dialogue_line: DialogueLine: # await get_tree().create_timer(time).timeout func _ready() -> void: + layer = GlobalConfig.CANVAS_LAYER_DIALOG balloon.hide() Engine.get_singleton("DialogueManager").mutated.connect(_on_mutated) diff --git a/scene/entity/local_inspectable.gd b/scene/entity/local_inspectable.gd index 8b9139a6..5f2254ad 100644 --- a/scene/entity/local_inspectable.gd +++ b/scene/entity/local_inspectable.gd @@ -1,3 +1,4 @@ +@tool extends Sprite2D # @export var entity_config: EntityConfig: @@ -7,9 +8,13 @@ extends Sprite2D enum { STATUS_NORAML, STATUS_INSPECTING_COVER, STATUS_INSPECTING_NOTES } @export var entity_name: String = "" -@export var entity_title: String = "" @export var texture_cover: Texture2D -@export_multiline var inspection_note: String = "" +@export_enum("none", "c01", "c02", "c03", "c04", "c05", "c06") var editor_filter := "none": + set(val): + editor_filter = val + if is_node_ready(): + notify_property_list_changed() +var content_key: String = "" @onready var sprite2d = %AnimatedSoundSprite2D as AnimatedSoundSprite2D @onready var sign_mark = %Sign as Sign @@ -20,8 +25,19 @@ enum { STATUS_NORAML, STATUS_INSPECTING_COVER, STATUS_INSPECTING_NOTES } @onready var content_label = %ContentLabel as Label @onready var tip_label = %TipLabel as Label -var tip_cover = "Q: 退出 E: 阅读" -var tip_notes = "Q: 退出 E: 收起" +var tip_cover = "Q: " + tr("ui_退出") + " " + "E: " + tr("ui_阅读") +var tip_notes = "Q: " + tr("ui_退出") + " " + "E: " + tr("ui_收起") + +static var content_dialogue = ( + preload("res://asset/dialogue/inspect_content.dialogue") as DialogueResource +) +static var content_titles = "" + + +static func _static_init() -> void: + # preload all titles from content_dialogue + content_titles = ",".join(content_dialogue.titles.keys()) + var status := STATUS_NORAML var blinking_tween: Tween @@ -33,7 +49,7 @@ func _ready() -> void: sign_mark.interacted.connect(_on_interacted) sign_mark.cancel.connect(_on_cancel) - content_label.text = inspection_note + content_label.text = _get_tr_content() content_label.modulate.a = 0.0 tip_label.text = tip_cover tip_label.modulate.a = 0.0 @@ -41,6 +57,20 @@ func _ready() -> void: cover_rect.texture = texture_cover +func _get_tr_content(): + if content_key == "": + return "" + var inspection_note = "" + # get note content + var line_id = content_dialogue.titles.get(content_key) + while line_id and line_id != "end": + var line = content_dialogue.lines[line_id] + if line.has("text"): + inspection_note += tr(line.get("text")) + "\n" + line_id = line.get("next_id") + return inspection_note + + func _on_interacted() -> void: # 1s 内锁定交互,留给镜头复位时间 if Time.get_ticks_msec() - inspected_time < 1500: @@ -91,7 +121,43 @@ func _on_cancel(_body = null): blinking_tween.kill() tween.parallel().tween_property(tip_label, "modulate:a", 0.0, 0.15) SceneManager.focus_player_and_reset_zoom(1.0) - var player = SceneManager.get_player() - if player: - player.release_player() + SceneManager.release_player() sign_mark.show_sign = true + + +func _set(property: StringName, value: Variant) -> bool: + if property == "content_key": + content_key = value + content_label.text = _get_tr_content() + return true + return false + + +func _get(property: StringName) -> Variant: + if property == "content_key": + return content_key + return null + + +func _get_property_list() -> Array[Dictionary]: # only show notes_ properties in editor + if Engine.is_editor_hint() and editor_filter and editor_filter != "none": + var filted_titles = content_dialogue.titles.keys().filter(_filter_property) + return [ + { + "name": "note_key", + "type": TYPE_STRING, + "hint": PROPERTY_HINT_ENUM, + "hint_string": ",".join(filted_titles) + } + ] + return [ + { + "name": "content_key", + "type": TYPE_STRING, + "hint": PROPERTY_HINT_ENUM_SUGGESTION, + "hint_string": content_titles + } + ] + +func _filter_property(property: StringName) -> bool: + return property.find(editor_filter) >= 0 \ No newline at end of file diff --git a/scene/entity/note.gd b/scene/entity/note.gd index ff3f7f22..c366d623 100644 --- a/scene/entity/note.gd +++ b/scene/entity/note.gd @@ -1,14 +1,35 @@ +@tool extends Sprite2D -# @export var title := "" -@export var notes := [] as Array[String] -@export var dialogs := [] as Array[String] +@export_enum("items", "c01", "c02", "c03", "c04", "c05", "c06") var dialogue := "items": + set(val): + dialogue = val + match dialogue: + "items": + dialogue_res = dialogue_items + "c01": + dialogue_res = dialogue_c01 + "c02": + dialogue_res = dialogue_c02 + if is_node_ready(): + notify_property_list_changed() +var note_key := "" +@export_enum("none", "notes", "c01", "c02", "c03", "c04", "c05", "c06") var editor_filter := "notes": + set(val): + editor_filter = val + if is_node_ready(): + notify_property_list_changed() @onready var sign_mark = %Sign as Sign @onready var area2d = %Area2D as Area2D -var played_time = 0 +var dialogue_items = preload("res://asset/dialogue/item_description.dialogue") +var dialogue_c01 = preload("res://asset/dialogue/c01.dialogue") +var dialogue_c02 = preload("res://asset/dialogue/c02.dialogue") +var dialogue_res = dialogue_items + +var interacting = false var mutex = Mutex.new() @@ -20,32 +41,69 @@ func _ready() -> void: func _on_interacted() -> void: - if notes.is_empty(): + if interacting: return - var note_time = notes.size() * 2.0 - # 0.5s 内锁定播放 - mutex.lock() - if Time.get_ticks_msec() - played_time < note_time * 1000 + 500: - mutex.unlock() + if not note_key: + printerr("Note key is not set") return - # show note - played_time = Time.get_ticks_msec() - mutex.unlock() %Sfx.play() SceneManager.focus_node(self) CameraFocusMarker.tween_zoom(1.1, 1.5) - for note in notes: - SceneManager.pop_note(note, "white", 2.0) + DialogueManager.show_dialogue_balloon(dialogue_res, note_key) # TODO note viewing animation - SceneManager.freeze_player(note_time, "") - get_tree().create_timer(note_time - 0.5).timeout.connect( - SceneManager.focus_player_and_reset_zoom - ) + SceneManager.freeze_player(0, "") + interacting = true + DialogueManager.dialogue_ended.connect(_on_dialogue_ended, CONNECT_ONE_SHOT) + # for note in notes: + # SceneManager.pop_note(note, "white", 2.0) + + +func _set(property: StringName, value: Variant) -> bool: + if property == "note_key": + note_key = value + return true + return false + + +func _get(property: StringName) -> Variant: + if property == "note_key": + return note_key + elif property == "dialogue_res": + return dialogue_res + return null + + +func _get_property_list() -> Array[Dictionary]: + # only show notes_ properties in editor + var titles = "" + if Engine.is_editor_hint() and editor_filter and editor_filter != "none": + var filted_titles = dialogue_res.titles.keys().filter(_filter_property) + titles = ",".join(filted_titles) + else: + titles = ",".join(dialogue_res.titles.keys()) + return [ + { + "name": "note_key", + "type": TYPE_STRING, + "hint": PROPERTY_HINT_ENUM_SUGGESTION, + "hint_string": titles + } + ] + + +func _filter_property(property: StringName) -> bool: + return property.find(editor_filter) >= 0 + + +func _on_dialogue_ended(_res): + interacting = false + SceneManager.release_player() + SceneManager.focus_player_and_reset_zoom() func _on_cancel(_body = null): - pass + interacting = false func _reset(_body): - pass + interacting = false diff --git a/scene/entity/note.tscn b/scene/entity/note.tscn index c97f0e18..d700caf9 100644 --- a/scene/entity/note.tscn +++ b/scene/entity/note.tscn @@ -12,7 +12,8 @@ size = Vector2(40, 60) [node name="Note" type="Sprite2D"] script = ExtResource("1_3igk8") -notes = Array[String]([]) +editor_filter = "notes_" +note_key = "" [node name="Sfx" parent="." instance=ExtResource("2_qocmg")] unique_name_in_owner = true diff --git a/scene/entity/old/inspectable.gd b/scene/entity/old/inspectable.gd index d3c11509..8ef15716 100644 --- a/scene/entity/old/inspectable.gd +++ b/scene/entity/old/inspectable.gd @@ -5,15 +5,15 @@ extends Sprite2D # entity_config = value @export var entity_name: String = "" -@export var entity_title: String = "" +@export var note_key: String = "" @export var texture_cover: Texture2D @export var texture_note: Texture2D -@export_multiline var inspection_note: String = "" @onready var sprite2d = %AnimatedSoundSprite2D as AnimatedSoundSprite2D @onready var sign_mark = %Sign as Sign @onready var area2d = %Area2D as Area2D +var content_res = preload("res://asset/dialogue/inspect_content.dialogue") as DialogueResource var inspecting = false @@ -41,10 +41,21 @@ func _on_interacted() -> void: inspector.quit.connect(_on_quit_inspector) if not texture_note: texture_note = texture_cover + var inspection_note = _get_tr_content() inspector.pop_inspection(texture_cover, texture_note, inspection_note) inspecting = true sign_mark.show_sign = false +func _get_tr_content(): + var inspection_note = "" + # get note content + var line_id = content_res.titles.get(note_key) + while line_id and line_id != "end": + var line = content_res.lines[line_id] + if line.has("text"): + inspection_note += tr(line.get("text")) + "\n" + line_id = line.get("next_id") + return inspection_note func _on_quit_inspector(): var inspector = SceneManager.get_inspector() diff --git a/scene/ground/scene/c02/s00_demo.tscn b/scene/ground/scene/c02/s00_demo.tscn deleted file mode 100644 index cba130d0..00000000 --- a/scene/ground/scene/c02/s00_demo.tscn +++ /dev/null @@ -1,51 +0,0 @@ -[gd_scene load_steps=10 format=3 uid="uid://e381spnutx62"] - -[ext_resource type="PackedScene" uid="uid://dayyx4jerj7io" path="res://scene/ground/ground.tscn" id="1_klnwh"] -[ext_resource type="Script" path="res://config/deploy/scene_config.gd" id="2_kijni"] -[ext_resource type="PackedScene" uid="uid://0sofmhrl358m" path="res://scene/entity/npc.tscn" id="2_upqk5"] -[ext_resource type="PackedScene" uid="uid://jr1yd46wm5je" path="res://scene/entity/note.tscn" id="3_heu4h"] -[ext_resource type="PackedScene" uid="uid://wyj4qdjyn4ql" path="res://scene/entity/old/inspectable.tscn" id="5_pirce"] -[ext_resource type="PackedScene" uid="uid://bnf3lkcbpx1ar" path="res://scene/entity/ambush.tscn" id="6_fiskb"] -[ext_resource type="PackedScene" uid="uid://bj4ufua0b0k34" path="res://scene/entity/hd_entity.tscn" id="7_l4pco"] -[ext_resource type="Texture2D" uid="uid://b0gti8fx40hph" path="res://asset/art/scene/c01/s04_旧版序章/e_树.png" id="8_6dlbe"] - -[sub_resource type="Resource" id="Resource_dcaa4"] -resource_local_to_scene = true -script = ExtResource("2_kijni") -player_y_fixed = true -player_y = 45 -footstep_type = "concrete" -bgm = "" - -[node name="S00" type="Node2D"] - -[node name="Ground" parent="." instance=ExtResource("1_klnwh")] -scene_config = SubResource("Resource_dcaa4") - -[node name="Npc" parent="Ground/DeployLayer" index="0" instance=ExtResource("2_upqk5")] -position = Vector2(465, 23) - -[node name="Note" parent="Ground/DeployLayer" index="1" instance=ExtResource("3_heu4h")] -position = Vector2(268, -36) -notes = Array[String](["(门牌号: 1012)", "(似乎是用血来写的)"]) - -[node name="Inspectable" parent="Ground/DeployLayer" index="2" instance=ExtResource("5_pirce")] -position = Vector2(376, 36) - -[node name="Ambush" parent="Ground/DeployLayer" index="3" instance=ExtResource("6_fiskb")] -position = Vector2(567, 28) -hook_cg = "c02_胖子说话" - -[node name="HdEntity" parent="Ground/DeployLayer" index="4" node_paths=PackedStringArray("sprite_ref") instance=ExtResource("7_l4pco")] -position = Vector2(259, 52) -sprite_name = "tree" -texture = ExtResource("8_6dlbe") -sprite_ref = NodePath("../../SubViewportContainer/SubViewport/HdLayer/tree") - -[node name="PortalLeft" parent="Ground/DeployLayer" index="5"] -target_portal = "right" - -[node name="PortalRight" parent="Ground/DeployLayer" index="6"] -target_portal = "left" - -[editable path="Ground"] diff --git a/scene/ground/scene/c02/s01_街道.tscn b/scene/ground/scene/c02/s01_街道.tscn index c7342a29..59fd9ea9 100644 --- a/scene/ground/scene/c02/s01_街道.tscn +++ b/scene/ground/scene/c02/s01_街道.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=8 format=3 uid="uid://bbs7yy5aofw1v"] +[gd_scene load_steps=7 format=3 uid="uid://bbs7yy5aofw1v"] [ext_resource type="PackedScene" uid="uid://dayyx4jerj7io" path="res://scene/ground/ground.tscn" id="1_gdcov"] [ext_resource type="Script" path="res://config/deploy/scene_config.gd" id="2_j6mie"] [ext_resource type="Texture2D" uid="uid://kc4726andgy2" path="res://asset/art/scene/c02/s01_街道/bg_公寓入口.png" id="2_ni1a4"] [ext_resource type="PackedScene" uid="uid://jr1yd46wm5je" path="res://scene/entity/note.tscn" id="3_6lnxd"] -[ext_resource type="PackedScene" uid="uid://wyj4qdjyn4ql" path="res://scene/entity/old/inspectable.tscn" id="5_g5fsn"] [ext_resource type="PackedScene" uid="uid://bnf3lkcbpx1ar" path="res://scene/entity/ambush.tscn" id="6_vgxa0"] [sub_resource type="Resource" id="Resource_p1xa1"] @@ -33,10 +32,14 @@ target_portal = "left" [node name="Note" parent="Ground/DeployLayer" index="2" instance=ExtResource("3_6lnxd")] position = Vector2(250, -22) -notes = Array[String](["(似乎是一张寻人启示)", "(脸的部分被撕掉了,打不开)"]) +editor_filter = "c02" +note_key = "c02_寻人启事" -[node name="Inspectable" parent="Ground/DeployLayer" index="3" instance=ExtResource("5_g5fsn")] -position = Vector2(311, -7) +[node name="Note门口" parent="Ground/DeployLayer" index="3" instance=ExtResource("3_6lnxd")] +position = Vector2(311, -27) +dialogue = "c02" +editor_filter = "c02" +note_key = "c02_s01_menpai" [node name="Ambush" parent="Ground/DeployLayer" index="4" instance=ExtResource("6_vgxa0")] position = Vector2(135, 56) diff --git a/scene/ground/scene/c02/s02_走道.tscn b/scene/ground/scene/c02/s02_走道.tscn index 9fe1aa0c..df4de6d1 100644 --- a/scene/ground/scene/c02/s02_走道.tscn +++ b/scene/ground/scene/c02/s02_走道.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=16 format=3 uid="uid://brck77w81fhvc"] +[gd_scene load_steps=15 format=3 uid="uid://brck77w81fhvc"] [ext_resource type="PackedScene" uid="uid://dayyx4jerj7io" path="res://scene/ground/ground.tscn" id="1_wrr6r"] [ext_resource type="Script" path="res://config/deploy/scene_config.gd" id="2_757mj"] [ext_resource type="Texture2D" uid="uid://c4647gof464ws" path="res://asset/art/scene/c02/s02_走道/bg_过道.png" id="2_cn1s8"] [ext_resource type="PackedScene" uid="uid://jr1yd46wm5je" path="res://scene/entity/note.tscn" id="3_fy0o1"] [ext_resource type="PackedScene" uid="uid://wyj4qdjyn4ql" path="res://scene/entity/old/inspectable.tscn" id="5_nhtbp"] -[ext_resource type="Texture2D" uid="uid://do8quqgkrwahj" path="res://asset/art/scene/c02/s02_走道/ux_进门鼠疫海报wz.png" id="6_4pcq0"] [ext_resource type="PackedScene" uid="uid://bnf3lkcbpx1ar" path="res://scene/entity/ambush.tscn" id="6_70vqn"] [ext_resource type="Texture2D" uid="uid://ds4yw1wqelhm1" path="res://asset/art/scene/c02/s02_走道/ux_进门鼠疫海报yz.png" id="7_wdwbi"] [ext_resource type="Texture2D" uid="uid://dd0sn5e4hwq5m" path="res://asset/art/scene/c02/s02_走道/e_纸人.png" id="7_xsghn"] @@ -46,31 +45,15 @@ target_portal = "left" [node name="几张卫生宣传画" parent="Ground/DeployLayer" index="2" instance=ExtResource("3_fy0o1")] position = Vector2(275, -30) -notes = Array[String](["(几张卫生宣传画)"]) +dialogue = null +editor_filter = "c01" -[node name="鼠疫海报" parent="Ground/DeployLayer" index="3" instance=ExtResource("5_nhtbp")] -position = Vector2(441, -20) -flip_h = true -entity_title = "(鼠疫海报)" -texture_cover = ExtResource("6_4pcq0") -texture_note = ExtResource("7_wdwbi") -inspection_note = "据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。 -有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。 - -《申报》 -民国五年一月十三日" - -[node name="鼠疫海报local" parent="Ground/DeployLayer" index="4" instance=ExtResource("12_0fckv")] -position = Vector2(387, -25) -entity_title = "鼠疫海报" +[node name="鼠疫海报" parent="Ground/DeployLayer" index="3" instance=ExtResource("12_0fckv")] +position = Vector2(440, -21) texture_cover = ExtResource("7_wdwbi") -inspection_note = "据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。 -有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。 +content_key = "c02_鼠疫海报" -《申报》 -民国五年一月十三日" - -[node name="纸人" parent="Ground/DeployLayer" index="5" instance=ExtResource("5_nhtbp")] +[node name="纸人" parent="Ground/DeployLayer" index="4" instance=ExtResource("5_nhtbp")] position = Vector2(601, 44) texture = ExtResource("7_xsghn") flip_h = true @@ -82,11 +65,11 @@ collision_mask = 0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/DeployLayer/纸人/StaticBody2D"] shape = SubResource("RectangleShape2D_0xrg2") -[node name="Ambush" parent="Ground/DeployLayer" index="6" instance=ExtResource("6_70vqn")] +[node name="Ambush" parent="Ground/DeployLayer" index="5" instance=ExtResource("6_70vqn")] position = Vector2(502, 56) hook_cg = "c02_胖子说话" -[node name="HdEntity" parent="Ground/DeployLayer" index="7" node_paths=PackedStringArray("sprite_ref") instance=ExtResource("10_3c313")] +[node name="HdEntity" parent="Ground/DeployLayer" index="6" node_paths=PackedStringArray("sprite_ref") instance=ExtResource("10_3c313")] position = Vector2(147, 75) sprite_name = "car" texture = ExtResource("11_x0h3x") diff --git a/scene/ground/scene/c02/s03_院子切换.tscn b/scene/ground/scene/c02/s03_院子切换.tscn index 0a5bbc6b..042a014a 100644 --- a/scene/ground/scene/c02/s03_院子切换.tscn +++ b/scene/ground/scene/c02/s03_院子切换.tscn @@ -45,7 +45,6 @@ position = Vector2(465, 23) [node name="Note" parent="Ground/DeployLayer" index="3" instance=ExtResource("3_6x7xl")] position = Vector2(268, -36) -notes = Array[String](["(门牌号: 1012)", "(似乎是用血来写的)"]) [node name="Inspectable" parent="Ground/DeployLayer" index="4" instance=ExtResource("5_0xh53")] position = Vector2(376, 36) diff --git a/scene/hud/prop_hud.gd b/scene/hud/prop_hud.gd index 28db4eda..bdf5b92b 100644 --- a/scene/hud/prop_hud.gd +++ b/scene/hud/prop_hud.gd @@ -6,14 +6,13 @@ class_name PropHud extends Control set(value): if value: add_item = false - add_prop_item(item_name, item_title, item_texture) -@export var item_name: String -@export var item_title: String + add_prop_item(item_key, item_texture) +@export var item_key: String @export_file("*.png") var item_texture: String @export_group("Inventory") @export var inventory: PropInventory @export_group("UI-UX") -@export var display_time := 1.5 # 不包含渐入渐出(约 0.6s)的时长 +@export var display_time := 1.5 # 不包含渐入渐出(约 0.6s)的时长 @export var locked := false @export var selected := false: set(value): @@ -81,8 +80,8 @@ func _load_texture_cache() -> void: return cached_inventory_textures.clear() for i in inventory.items: - if i and i.name and i.texture_path: - cached_inventory_textures[i.name] = load(i.texture_path) + if i and i.key and i.texture_path: + cached_inventory_textures[i.key] = load(i.texture_path) func _update_prop_display_with_texture(): @@ -96,11 +95,11 @@ func _update_prop_display_with_texture(): prop.texture = null push_error("PropItem is null! index=" + str(inventory.current_index)) return - if item.name in cached_inventory_textures: - prop.texture = cached_inventory_textures[item.name] + if item.key in cached_inventory_textures: + prop.texture = cached_inventory_textures[item.key] else: prop.texture = null - title_label.text = item.title + title_label.text = tr(item.key) func on_left_pressed() -> void: @@ -163,6 +162,7 @@ func _unhandled_input(event: InputEvent) -> void: on_right_pressed() get_viewport().set_input_as_handled() + func _input(event: InputEvent) -> void: if locked: return @@ -202,9 +202,9 @@ func _toggle_btn_ability(v: bool) -> void: right_btn.disabled = !v -func add_prop_item(prop_name: String, prop_title: String, texture_path: String) -> void: - if not inventory or not prop_name or not texture_path: +func add_prop_item(prop_key: String, texture_path: String) -> void: + if not inventory or not prop_key or not texture_path: return - inventory.add_item(prop_name, prop_title, texture_path) + inventory.add_item(prop_key, texture_path) _load_texture_cache() _update_prop_display_with_texture() diff --git a/scene/hud/prop_inventory.gd b/scene/hud/prop_inventory.gd index e2baf2f7..4ffae452 100644 --- a/scene/hud/prop_inventory.gd +++ b/scene/hud/prop_inventory.gd @@ -4,10 +4,9 @@ class_name PropInventory extends Resource @export var current_index := 0 -func add_item(name: String, prop_title: String, texture_path: String) -> void: +func add_item(prop_key: String, texture_path: String) -> void: var item = PropItem.new() - item.name = name - item.title = prop_title + item.key = prop_key item.texture_path = texture_path items.push_back(item) emit_changed() diff --git a/scene/hud/prop_item.gd b/scene/hud/prop_item.gd index 16364819..4962fe41 100644 --- a/scene/hud/prop_item.gd +++ b/scene/hud/prop_item.gd @@ -1,6 +1,5 @@ class_name PropItem extends Resource # unique name -@export var name := "" -@export var title := "" +@export var key := "" @export_file("*.png") var texture_path := "" diff --git a/scene/main.gd b/scene/main.gd index 69b683c8..43fec8fa 100644 --- a/scene/main.gd +++ b/scene/main.gd @@ -1,9 +1,9 @@ extends Node2D -@export var scene_config: SceneConfig: +@export var locale := "": set(val): - scene_config = val - _load_scene_config() + TranslationServer.set_locale(val) + locale = val func _ready() -> void: @@ -12,12 +12,3 @@ func _ready() -> void: $UILayer.layer = GlobalConfig.CANVAS_LAYER_UI %ColorRectTop.visible = true %ColorRectBottom.visible = true - _load_scene_config() - DialogueManager.show_dialogue_balloon( - preload("res://asset/dialogue/c01.dialogue"), "c01_s01_heiwu" - ) - - -func _load_scene_config() -> void: - if !scene_config: - return diff --git a/scene/main.tscn b/scene/main.tscn index 52d5fb52..fab6e548 100644 --- a/scene/main.tscn +++ b/scene/main.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=11 format=3 uid="uid://dygvcmykn02n8"] +[gd_scene load_steps=10 format=3 uid="uid://dygvcmykn02n8"] [ext_resource type="Script" path="res://scene/main.gd" id="1_pks84"] [ext_resource type="PackedScene" uid="uid://3gk1gxwanw24" path="res://scene/shading/shading_layer.tscn" id="2_d1re1"] -[ext_resource type="PackedScene" uid="uid://dmkt1roqc4he7" path="res://scene/dialog/dialog.tscn" id="3_prpss"] [ext_resource type="PackedScene" uid="uid://dc778gsjfr3ky" path="res://scene/hud/prop_hud.tscn" id="4_t7gb2"] [ext_resource type="PackedScene" uid="uid://5g07x6q7wwr1" path="res://scene/notification/notification.tscn" id="5_3gg5t"] [ext_resource type="PackedScene" uid="uid://cekhj65axie0p" path="res://scene/popup/prop_inspector.tscn" id="5_ux0rw"] @@ -13,14 +12,13 @@ [node name="Main" type="Node2D"] script = ExtResource("1_pks84") +locale = "en" [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = ExtResource("9_jsof5") [node name="GroundLoader" parent="." instance=ExtResource("10_8rc5n")] position = Vector2(1, 0) -ignore_archive = true -current_scene = "c02_s02" [node name="MainPlayer" parent="." instance=ExtResource("6_6geb0")] unique_name_in_owner = true @@ -67,12 +65,6 @@ grow_vertical = 0 mouse_filter = 2 color = Color(0, 0, 0, 1) -[node name="Dialog" parent="UILayer" instance=ExtResource("3_prpss")] -offset_left = -230.0 -offset_top = -70.0 -offset_right = 230.0 -metadata/_edit_use_anchors_ = true - [node name="Notification" parent="UILayer" instance=ExtResource("5_3gg5t")] offset_left = -12.0 offset_top = -2.0 @@ -82,6 +74,7 @@ metadata/_edit_use_anchors_ = true [node name="PropHUD" parent="UILayer" instance=ExtResource("4_t7gb2")] scale = Vector2(0.24, 0.24) +item_key = null metadata/_edit_use_anchors_ = true [node name="Journal" parent="." instance=ExtResource("10_durpa")] diff --git a/scene/popup/prop_inspector.gd b/scene/popup/prop_inspector.gd index e6e61555..142f1007 100644 --- a/scene/popup/prop_inspector.gd +++ b/scene/popup/prop_inspector.gd @@ -38,9 +38,7 @@ func _hide(): blinking_tween.stop() tween.parallel().tween_property(tip_label, "modulate:a", 0.0, 0.15) tween.tween_callback(_post_hide) - var player = SceneManager.get_player() - if player: - player.release_player() + SceneManager.release_player() func _post_hide():