Page 5 of 6

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 1:15 pm
by andylegate
Sure......give me a few

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 1:22 pm
by D'Lanor
Hang on, it may be my error after all. I am going to try something. But go ahead and add the debugging print anyway.

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 1:25 pm
by andylegate
Done. Here's what it said this time:

(01/30 15:23:26) __init__CampbravoBookGUI v.1
(01/30 15:23:30) CampbravoBookGUI: OnFirstUpdate called
(01/30 15:23:37) CampbravoBookGUI: OnNotify called
(01/30 15:23:37) Someone clicked on object welcomebk
(01/30 15:23:37) It was you
(01/30 15:23:37) CampbravoBookGUI: OnNotify called


So, yah, I've got the object named right. :?

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 1:42 pm
by D'Lanor
I guess I never tested it with less than 2 books. :oops: The quick workaround for now is to add a dummy book until I have made the code smarter.

Code: Select all

ageBooks = ('welcomebk', 'dummy')
bookPages = (['cbjournal1'], ['dummy'])

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 1:54 pm
by andylegate
Okay! I'll give it a try here in a few. I got to take Wendy out, she's barking at me, and when a Basset Hound has to go, they have to go!

BTW-- while waiting, and out of curiosity. I emptied out my pak file, and put my old Campbravo.py in it, the one that uses the uam.showbook junk.
Went into blender and changed the click file name, etc.


er....it worked! Journal popped up, opened up and read just fine.

BUT! D'Lanor, I've got like 4 books in my Age, and I would MUCH rather use your stuff.

So give me a few. BRB.

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 2:22 pm
by andylegate
SUCCESS!!!!!!!!!!!!!! YeeeeeeHAAAAAWWWWWWW!

Okay, I didn't use your Dummy books. Like I said, I've got 4 books in my Age, 2 Journals, and 2 notebooks. So I added my Assignment Book.

Bingo! Both books pop up and work!

this is great! As I need to add two more books too.

Oh, last question. Uhm, how do I tell it to present a different texture for each book when it pops up?

You've got this in the CampbravoPageDefs:

Code: Select all

# BookDef sets cover and margins of the book. The cover can be the same texture as used for the book object itself.
BookDef = '<cover src="welcomebook"><margin right=32 left=32>'


Uhm, this allows for only one book cover when it pops up.

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 2:44 pm
by D'Lanor
Yes, I am afraid that cannot be changed easily. Support for multiple books was a last minute addition and I didn't think about different covers. And like many last minute additions it messed a few things up that were working fine before.

I am going to do an overhaul soon to address those issues.

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 2:46 pm
by andylegate
Do you think putting in <cover src="Your_Texture"> in the journals would work?

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 2:56 pm
by D'Lanor
You could change IOpenBook like this:

Code: Select all

    def IOpenBook(self, bkPages = None, forceOwned = 0):
        global ourBook
        global bkLinks
        print ('%s: IOpenBook: Page request for %s' % (self.__class__.__name__, bkPages))
        if (type(bkPages) == type(None)):
            return
        #PageDef = CampbravoPageDefs.BookDef + CampbravoPageDefs.BookFont
        PageCount = xLinkingBookDefs.kFirstLinkPanelID
        bkLinks = []
        for bkPage in bkPages:
            if (not bkPage in CampbravoPageDefs.LinkDestinations):
                print ('skipping %s because definition does not exist' % bkPage)
                continue
            # setting up the destination from the definition
            params = CampbravoPageDefs.LinkDestinations[bkPage]
            (bkAge, spawnPoint, spTitle, linkRule,) = params
            alink = 1
            if (type(bkAge) != type(None) and forceOwned):
                print ('ownership check for %s book' % bkAge)
                vault = ptVault()
                ainfo = ptAgeInfoStruct()
                ainfo.setAgeFilename(bkAge)
                alink = vault.getOwnedAgeLink(ainfo)
            if alink:
                print ('showing page for %s' % bkAge)
                if (type(bkAge) != type(None)):
                    t = (PageCount, bkAge, spawnPoint, spTitle, linkRule)
                    bkLinks.append(t)
                    PageDef = CampbravoPageDefs.BookPages[bkPage] % (PageCount) + '<pb>'
                else:
                    PageDef = CampbravoPageDefs.BookPages[bkPage] + '<pb>'
                PageCount = PageCount + 1
            else:
                print ('No %s book on your shelf so we are not showing the link' % bkAge)
        if (PageCount == xLinkingBookDefs.kFirstLinkPanelID):
            print 'no pages created'
            return
        print ('linkingpages created: %d' % (len(bkLinks)))
        PageDef = PageDef[:-4]
        ourBook = ptBook(PageDef, self.key)
        ourBook.setSize(1.0, 1.0)
        ourBook.setGUI('BkBook')
        ourBook.show(0) # 0 = closed book, 1 = open book

And then put the cover plus font definitions in front of the definition in CampbravoPageDefs.BookPages

Re: Dynamic Book Template

Posted: Wed Jan 30, 2008 3:10 pm
by andylegate
Hey, I'll give it a whirl. Now that the books are working, this shouldn't be that hard (he says as an evil laugh can be heard from far, far away....) :D