Skip to content

Commit

Permalink
Merge pull request #177 from DRincs-Productions/173-paste-next-dialog…
Browse files Browse the repository at this point in the history
…ue-function-for-pixivnjson

glueEnabled
  • Loading branch information
BlackRam-oss authored Aug 10, 2024
2 parents 16ebaf6 + 4ea7f31 commit e586e9a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/classes/LabelJson.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clearChoiceMenuOptions, clearDialogue, setChoiceMenuOptions, setDialogue } from "../functions"
import { clearChoiceMenuOptions, clearDialogue, setChoiceMenuOptions, setDialogue, setFlag } from "../functions"
import { LabelProps } from "../interface"
import { GameStepManager } from "../managers"
import { GameStepManager, GameStorageManager } from "../managers"
import { StepLabelJsonType } from "../types"
import { LabelIdType } from "../types/LabelIdType"
import { StepLabelType } from "../types/StepLabelType"
Expand Down Expand Up @@ -48,6 +48,12 @@ export default class LabelJson<T extends {} = {}> extends LabelAbstract<LabelJso
clearChoiceMenuOptions()
}

if (step.glueEnabled) {
setFlag(GameStorageManager.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY, true)
}
else if (step.glueEnabled === false) {
setFlag(GameStorageManager.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY, false)
}
if (step.dialog) {
setDialogue(step.dialog)
}
Expand Down
10 changes: 10 additions & 0 deletions src/functions/DialogueUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DialogueHistory } from "../interface";
import { GameStepManager, GameStorageManager } from "../managers";
import { Close, HistoryChoiceMenuOption } from "../types";
import { ChoiceMenuOptionsType } from "../types/ChoiceMenuOptionsType";
import { getFlag, setFlag } from "./FlagsUtility";

/**
* Set the dialogue to be shown in the game
Expand Down Expand Up @@ -48,6 +49,15 @@ export function setDialogue<TCharacter extends CharacterBaseModel = CharacterBas
dialogue = props
}

if (getFlag(GameStorageManager.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)) {
let glueDialogue = getDialogue<TDialogue>()
if (glueDialogue) {
dialogue.text = `${glueDialogue.text}${dialogue.text}`
dialogue = glueDialogue
}
setFlag(GameStorageManager.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY, false)
}

GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY, dialogue as DialogueData)
GameStorageManager.setVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY, GameStepManager.lastStepIndex)
}
Expand Down
5 changes: 5 additions & 0 deletions src/managers/StorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export default class GameStorageManager {
* The key of the flags memory
*/
FLAGS_CATEGORY_KEY: "___flags___",
/**
* This variable is used to add the next dialog text into the current dialog memory.
* This value was added to introduce Ink Glue functionality https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#glue
*/
ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY: "___glue___",
}
}
/**
Expand Down
5 changes: 5 additions & 0 deletions src/types/StepLabelJsonType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ type StepLabelJsonType = {
*/
text: string,
} | string
/**
* This variable is used to add the next dialog text into the current dialog memory.
* This value was added to introduce Ink Glue functionality https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#glue
*/
glueEnabled?: boolean
/**
* Variable used to open a label.
*/
Expand Down

0 comments on commit e586e9a

Please sign in to comment.