From 7687afadd5a14370d2a355b9d9d2fb3d998ac850 Mon Sep 17 00:00:00 2001 From: Mayberry Date: Wed, 8 May 2024 12:29:47 -0400 Subject: [PATCH 1/4] Add support for pages in hints --- src/open_dread_rando/files/schema.json | 5 ++++- src/open_dread_rando/misc_patches/text_patches.py | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/open_dread_rando/files/schema.json b/src/open_dread_rando/files/schema.json index 08ddf7588..fc9bf0506 100644 --- a/src/open_dread_rando/files/schema.json +++ b/src/open_dread_rando/files/schema.json @@ -290,7 +290,10 @@ "pattern": "[A-Z]+?_[0-9]+" }, "text": { - "type": "string" + "type": "array", + "items": { + "type": "string" + } } }, "required": [ diff --git a/src/open_dread_rando/misc_patches/text_patches.py b/src/open_dread_rando/misc_patches/text_patches.py index f119727a9..c5c765e9c 100644 --- a/src/open_dread_rando/misc_patches/text_patches.py +++ b/src/open_dread_rando/misc_patches/text_patches.py @@ -59,12 +59,16 @@ def patch_hints(editor: PatcherEditor, hints: list[dict]): # update hint text hint_id = f"DIAG_ADAM_{hint['hint_id']}" - string_key = f"{hint_id}_PAGE_1" + + pages = { + f"{hint_id}_PAGE_{i + 1}": hint + for i, hint in enumerate(hint["text"]) + } usable.tCaptionList = { - hint_id: [string_key] + hint_id: list(pages) or [f"{hint_id}_PAGE_1"] } - patch_text(editor, string_key, hint["text"]) + apply_text_patches(editor, pages) _PROJECT_MEMBERS = { From 492a37beef2ec958b4fcd5f32dfab15b2e93d463 Mon Sep 17 00:00:00 2001 From: Mayberry Date: Wed, 8 May 2024 12:35:00 -0400 Subject: [PATCH 2/4] Fix tests --- tests/test_files/april_fools_patcher.json | 44 +++++++++++++++----- tests/test_files/starter_preset_patcher.json | 44 +++++++++++++++----- 2 files changed, 66 insertions(+), 22 deletions(-) diff --git a/tests/test_files/april_fools_patcher.json b/tests/test_files/april_fools_patcher.json index 4b2a7c835..cef0ee023 100644 --- a/tests/test_files/april_fools_patcher.json +++ b/tests/test_files/april_fools_patcher.json @@ -3528,7 +3528,9 @@ "actor": "PRP_CV_AccessPoint002" }, "hint_id": "CAVE_2", - "text": "Can you guess where a {c1}Progressive Suit{c0} goes?|That's right! It goes in the {c5}Cataris{c0} hole!" + "text": [ + "Can you guess where a {c1}Progressive Suit{c0} goes?|That's right! It goes in the {c5}Cataris{c0} hole!" + ] }, { "accesspoint_actor": { @@ -3537,7 +3539,9 @@ "actor": "PRP_CV_AccessPoint001" }, "hint_id": "CAVE_1", - "text": "Can you guess where the {c1}Power Bomb{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!" + "text": [ + "Can you guess where the {c1}Power Bomb{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!" + ] }, { "accesspoint_actor": { @@ -3546,7 +3550,9 @@ "actor": "accesspoint" }, "hint_id": "MAGMA_1", - "text": "Can you guess where the {c1}Wave Beam{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!" + "text": [ + "Can you guess where the {c1}Wave Beam{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!" + ] }, { "accesspoint_actor": { @@ -3555,7 +3561,9 @@ "actor": "accesspoint_000" }, "hint_id": "MAGMA_2", - "text": "Can you guess where the {c1}Wide Beam{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!" + "text": [ + "Can you guess where the {c1}Wide Beam{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!" + ] }, { "accesspoint_actor": { @@ -3564,7 +3572,9 @@ "actor": "accesspoint_000" }, "hint_id": "LAB_1", - "text": "Can you guess where the {c1}Spider Magnet{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!" + "text": [ + "Can you guess where the {c1}Spider Magnet{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!" + ] }, { "accesspoint_actor": { @@ -3573,7 +3583,9 @@ "actor": "accesspoint_001" }, "hint_id": "LAB_2", - "text": "{c4}A joke hint.{c0}" + "text": [ + "{c4}A joke hint.{c0}" + ] }, { "accesspoint_actor": { @@ -3582,7 +3594,9 @@ "actor": "accesspoint_000" }, "hint_id": "AQUA_1", - "text": "Can you guess where the {c1}Screw Attack{c0} goes?|That's right! It goes in the {c5}Burenia{c0} hole!" + "text": [ + "Can you guess where the {c1}Screw Attack{c0} goes?|That's right! It goes in the {c5}Burenia{c0} hole!" + ] }, { "accesspoint_actor": { @@ -3591,7 +3605,9 @@ "actor": "accesspoint_001" }, "hint_id": "AQUA_2", - "text": "Can you guess where a {c1}Progressive Bomb{c0} goes?|That's right! It goes in the {c5}Burenia{c0} hole!" + "text": [ + "Can you guess where a {c1}Progressive Bomb{c0} goes?|That's right! It goes in the {c5}Burenia{c0} hole!" + ] }, { "accesspoint_actor": { @@ -3600,7 +3616,9 @@ "actor": "accesspoint_000" }, "hint_id": "SANC_1", - "text": "Can you guess where the {c1}Storm Missile{c0} goes?|That's right! It goes in the {c5}Ferenia{c0} hole!" + "text": [ + "Can you guess where the {c1}Storm Missile{c0} goes?|That's right! It goes in the {c5}Ferenia{c0} hole!" + ] }, { "accesspoint_actor": { @@ -3609,7 +3627,9 @@ "actor": "accesspoint_000" }, "hint_id": "FOREST_1", - "text": "Can you guess where the {c1}Flash Shift{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!" + "text": [ + "Can you guess where the {c1}Flash Shift{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!" + ] }, { "accesspoint_actor": { @@ -3618,7 +3638,9 @@ "actor": "accesspoint_000" }, "hint_id": "SHIP_1", - "text": "Can you guess where a {c1}Progressive Suit{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!" + "text": [ + "Can you guess where a {c1}Progressive Suit{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!" + ] } ], "text_patches": { diff --git a/tests/test_files/starter_preset_patcher.json b/tests/test_files/starter_preset_patcher.json index da808d65e..f057d61d7 100644 --- a/tests/test_files/starter_preset_patcher.json +++ b/tests/test_files/starter_preset_patcher.json @@ -3592,7 +3592,9 @@ "actor": "PRP_CV_AccessPoint002" }, "hint_id": "CAVE_2", - "text": "A {c1}Progressive Beam{c0} can be found in {c5}Cataris{c0}." + "text": [ + "A {c1}Progressive Beam{c0} can be found in {c5}Cataris{c0}." + ] }, { "accesspoint_actor": { @@ -3601,7 +3603,9 @@ "actor": "PRP_CV_AccessPoint001" }, "hint_id": "CAVE_1", - "text": "A {c1}Progressive Beam{c0} can be found in {c5}Artaria{c0}." + "text": [ + "A {c1}Progressive Beam{c0} can be found in {c5}Artaria{c0}." + ] }, { "accesspoint_actor": { @@ -3610,7 +3614,9 @@ "actor": "accesspoint" }, "hint_id": "MAGMA_1", - "text": "A {c1}Progressive Bomb{c0} can be found in {c5}Artaria{c0}." + "text": [ + "A {c1}Progressive Bomb{c0} can be found in {c5}Artaria{c0}." + ] }, { "accesspoint_actor": { @@ -3619,7 +3625,9 @@ "actor": "accesspoint_000" }, "hint_id": "MAGMA_2", - "text": "A {c1}Progressive Suit{c0} can be found in {c5}Ghavoran{c0}." + "text": [ + "A {c1}Progressive Suit{c0} can be found in {c5}Ghavoran{c0}." + ] }, { "accesspoint_actor": { @@ -3628,7 +3636,9 @@ "actor": "accesspoint_000" }, "hint_id": "LAB_1", - "text": "A {c1}Progressive Spin{c0} can be found in {c5}Burenia{c0}." + "text": [ + "A {c1}Progressive Spin{c0} can be found in {c5}Burenia{c0}." + ] }, { "accesspoint_actor": { @@ -3637,7 +3647,9 @@ "actor": "accesspoint_001" }, "hint_id": "LAB_2", - "text": "The {c1}Grapple Beam{c0} can be found in {c5}Burenia{c0}." + "text": [ + "The {c1}Grapple Beam{c0} can be found in {c5}Burenia{c0}." + ] }, { "accesspoint_actor": { @@ -3646,7 +3658,9 @@ "actor": "accesspoint_000" }, "hint_id": "AQUA_1", - "text": "The {c1}Storm Missile{c0} can be found in {c5}Cataris{c0}." + "text": [ + "The {c1}Storm Missile{c0} can be found in {c5}Cataris{c0}." + ] }, { "accesspoint_actor": { @@ -3655,7 +3669,9 @@ "actor": "accesspoint_001" }, "hint_id": "AQUA_2", - "text": "The {c1}Power Bomb{c0} can be found in {c5}Dairon{c0}." + "text": [ + "The {c1}Power Bomb{c0} can be found in {c5}Dairon{c0}." + ] }, { "accesspoint_actor": { @@ -3664,7 +3680,9 @@ "actor": "accesspoint_000" }, "hint_id": "SANC_1", - "text": "A {c1}Progressive Bomb{c0} can be found in {c5}Dairon{c0}." + "text": [ + "A {c1}Progressive Bomb{c0} can be found in {c5}Dairon{c0}." + ] }, { "accesspoint_actor": { @@ -3673,7 +3691,9 @@ "actor": "accesspoint_000" }, "hint_id": "FOREST_1", - "text": "The {c1}Spider Magnet{c0} can be found in {c5}Artaria{c0}." + "text": [ + "The {c1}Spider Magnet{c0} can be found in {c5}Artaria{c0}." + ] }, { "accesspoint_actor": { @@ -3682,7 +3702,9 @@ "actor": "accesspoint_000" }, "hint_id": "SHIP_1", - "text": "The {c1}Screw Attack{c0} can be found in {c5}Ferenia{c0}." + "text": [ + "The {c1}Screw Attack{c0} can be found in {c5}Ferenia{c0}." + ] } ], "text_patches": { From c1e1746828d232b6acb3f6f50a16bc35361f32a4 Mon Sep 17 00:00:00 2001 From: Mayberry Date: Mon, 20 May 2024 12:51:41 -0400 Subject: [PATCH 3/4] Allow strings in hint text --- src/open_dread_rando/files/schema.json | 2 +- src/open_dread_rando/misc_patches/text_patches.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/open_dread_rando/files/schema.json b/src/open_dread_rando/files/schema.json index fc9bf0506..5ef94a85b 100644 --- a/src/open_dread_rando/files/schema.json +++ b/src/open_dread_rando/files/schema.json @@ -290,7 +290,7 @@ "pattern": "[A-Z]+?_[0-9]+" }, "text": { - "type": "array", + "type": ["string", "array"], "items": { "type": "string" } diff --git a/src/open_dread_rando/misc_patches/text_patches.py b/src/open_dread_rando/misc_patches/text_patches.py index c5c765e9c..71d2c7538 100644 --- a/src/open_dread_rando/misc_patches/text_patches.py +++ b/src/open_dread_rando/misc_patches/text_patches.py @@ -60,9 +60,14 @@ def patch_hints(editor: PatcherEditor, hints: list[dict]): # update hint text hint_id = f"DIAG_ADAM_{hint['hint_id']}" + hint_text = hint["text"] + + if isinstance(hint_text, str): + hint_text = [hint_text] + pages = { f"{hint_id}_PAGE_{i + 1}": hint - for i, hint in enumerate(hint["text"]) + for i, hint in enumerate(hint_text) } usable.tCaptionList = { From 0becc9f9f4fc27bb909d6536cf525413a4c9f7b0 Mon Sep 17 00:00:00 2001 From: Mayberry Date: Thu, 23 May 2024 17:46:31 -0400 Subject: [PATCH 4/4] Add schema description for hints text field --- src/open_dread_rando/files/schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/open_dread_rando/files/schema.json b/src/open_dread_rando/files/schema.json index 5ef94a85b..e7c261d33 100644 --- a/src/open_dread_rando/files/schema.json +++ b/src/open_dread_rando/files/schema.json @@ -293,7 +293,8 @@ "type": ["string", "array"], "items": { "type": "string" - } + }, + "description": "If a string, the Adam dialogue will be replaced with a single page containing the string. If an array, a page will be created for each element." } }, "required": [