Xbozon / storyteller

A small modification that allows you to present the story in the game as an open book.
Apache License 2.0
16 stars 9 forks source link

go to page #60

Open Benjaneer opened 1 year ago

Benjaneer commented 1 year ago

you know me, if I'd figured it out by now I'd just give you the answer... I'm trying to figure out how to make it open to (or go to if in the same journal) a given page when links are clicked. I know it's going to have to be an overload of one of the on event handlers or function but I haven't figured it out yet, if I do I'll let you know... (basically deactivate all and activate the one in question plus the preceding one if odd or the following if even) (pretty sure the function to overload is (JournalSheet) GoToPage, but I haven't gotten it to work so I might be wrong)

Benjaneer commented 1 year ago

goToPage is invoked when the list item is clicked on the ToC, but not when links are clicked. changing the display on pages isn't enough to make them switch properly, it'd probably be best if it triggered the turn or flip but I haven't figured out how to do that yet.

Benjaneer commented 1 year ago

AHHA! on _render if I try to use pageId from options (first if available) instead of data._id then it should go to the intended page, and these trigger on clicking of links both in the same journal and from others... (I'm going to try this out)

Benjaneer commented 1 year ago

and you already have the logic I need for page flip in _render :D

Benjaneer commented 1 year ago

holy crap, I got the links to work... for some reason the ToC isn't, but links are more important I think

modified the ToC a little in story-sheet.html: \

  • offset handlebar helper in main.js: Handlebars.registerHelper("offset", function(value) { return parseInt(value) + 2; });

    added this to the end of _render: if (options.pageId != undefined) { this.goToPage(options.pageId); };

    then added this function to the end of the StorySheet class: goToPage(pageId) { let targetPage = document.querySelector('.directory-item[data-page-id="' + pageId + '"]'); if (targetPage == null) { targetPage = document.querySelector('.journal-entry-page[data-page-id="' + pageId + '"]').closest('.page-wrapper'); }; let targetPageNum = Math.floor(Number(targetPage.getAttribute("page"))/2); let pageList = targetPage.closest(.journal-entry-pages).children[0]; let journalId = pageList.getAttribute("id").split('-')[1]; let curentPageNum = Math.floor($('#story-' + journalId).turn("page")/2); if (curentPageNum<targetPageNum) { for (let i=curentPageNum; i<targetPageNum; i++) { $('#story-' + journalId).turn("next"); }; }; if (curentPageNum>targetPageNum) { for (let i=curentPageNum; i>targetPageNum; i--) { $('#story-' + journalId).turn("previous"); }; }; } }

    let me know if you'd rather have a merge request

  • Benjaneer commented 1 year ago

    ok a little wierdness, the ToC links work if, and only if, I open the book on the ToC page, still all the other links work so, progress...

    Xbozon commented 1 year ago

    @Benjaneer First of all, thank you for supporting my modification despite the fact that I am almost completely missing.

    I took a preliminary look, it looks working, however if you don't mind, if you can make it out as MR, I think I could test it in the next few days and release a new version.

    This functionality has been sorely missed, thanks for your contribution.

    Benjaneer commented 1 year ago

    I opened a pull request? not sure how that's different from a merge request... :\ also I find you quite reasonably responsive :) this is my favorite mod (followed by polyglot)

    ViridiumRP commented 12 months ago

    Hey there! I love this module so much. Is there any update on how to get this to work? I'd love to be able to jump to different chapters via the journal menu.