tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
177 stars 41 forks source link

Update `Dialog` static methods #228

Closed tmedwards closed 2 months ago

tmedwards commented 1 year ago

Add new Dialog static methods:

/*
    Prepares the dialog for use.
    Returns `Dialog` for further chaining.
*/
Dialog.create(title?: string, classNames?: string) → Dialog

/*
    Empties the dialog's body container.
    Returns `Dialog` for further chaining.
*/
Dialog.empty() → Dialog

/*
    Renders the specified passage and appends it to the dialog's body container.
    Returns `Dialog` for further chaining.
*/
Dialog.wikiPassage(name: string) → Dialog

Deprecate existing Dialog static methods:

greyelf commented 1 year ago

So Dialog.wikiPassage(name) would replace the need for doing Dialog.wiki(Story.get(name).processText())?

tmedwards commented 1 year ago

Correct.

tmedwards commented 1 year ago

Edited opening post.

Notably, added Dialog.create() to the additions, as a replacement for Dialog.setup(). The only difference being the returned value, so you can chain all the way through. E.g.:

Dialog
    .create('Inventory', 'inventory')
    .wikiPassage('PC Inventory')
    .open();