Skip to content

Commit

Permalink
Merge pull request #319 from MayberryZoom/hint-pages
Browse files Browse the repository at this point in the history
Add support for pages in hints
  • Loading branch information
henriquegemignani authored May 23, 2024
2 parents 5a73eca + 0becc9f commit af6675d
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 26 deletions.
6 changes: 5 additions & 1 deletion src/open_dread_rando/files/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@
"pattern": "[A-Z]+?_[0-9]+"
},
"text": {
"type": "string"
"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": [
Expand Down
15 changes: 12 additions & 3 deletions src/open_dread_rando/misc_patches/text_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,21 @@ 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"

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)
}

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 = {
Expand Down
44 changes: 33 additions & 11 deletions tests/test_files/april_fools_patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand Down
44 changes: 33 additions & 11 deletions tests/test_files/starter_preset_patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand Down

0 comments on commit af6675d

Please sign in to comment.