FG Spreadshirt Swag
Page 1 of 2 12 Last
  1. #1

    Locking down Subwindows under CoreRPG

    I have an NPC sheet with multiple tabs (3 to be exact). I was wondering if anyone could help me out here. I need to lock down every one of the tabs upon hitting the "lock" button. I found an example in the 4E ruleset, but it's too case specific to help (well for me anyway ). Any help with this would be greatly appreciated.

    Regards,
    SF
    Aliens.... Go fig?

  2. #2
    I do something similar in my Locations Extension - you could have a look at that and see if it helps

    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  3. #3
    Thanks I'll take a look at it.

    Edit: O.k. Where am I supposed to look? I don't see a "locking icon" in the extension. Could you point me to the right spot?
    I'd optimally like this to be mini scripts that can be inserted inline the XML code IP. Otherwise a script will do.

    Cheers,
    SF
    Last edited by S Ferguson; November 18th, 2014 at 15:37.
    Aliens.... Go fig?

  4. #4
    Quote Originally Posted by S Ferguson View Post
    Thanks I'll take a look at it.

    Edit: O.k. Where am I supposed to look? I don't see a "locking icon" in the extension. Could you point me to the right spot?
    I'd optimally like this to be mini scripts that can be inserted inline the XML code IP. Otherwise a script will do.

    Cheers,
    SF
    OK, follow along using the files as I call them out:

    We'll use the Town Record as an example, but (almost) all of the Place Records in the Locations Extension uses the same concepts, logic, etc.

    OK, the definition for the Lock Button is on Line 147 of the 'xTownsWindowClasses.xml' file.

    This calls the 'tLocationButtonRecordLocked' template definition found on Line 1064 of the 'xLocationsTemplates.xml' file. You'll note that this template is defined from another template called 'button_record_locked'. 'button_record_locked' is a template defined somewhere in the CoreRPG - you can tell this because all of my templates start with the letter "t" and are named in Camel-Case.

    You'll note that the 'tLocationButtonRecordLocked' template has a name attribute of "locked" (see Line 1065). This means that every instance of this template will have a name of "locked" unless explicitly over-written. This also means that in the Database under each Town Record there is a Node called "locked".

    So, if you take a look at Line 27 of the 'xTownsWindowClasses.xml' file you'll see that, as part of the form's onInit() function, we define a handler function 'fpOnLockChanged' linked to each Town Records' "locked" Node which will get called each time the "locked" Node is updated (the "onUpdate" part of the command).

    'fpOnLockChanged()' is found on Line 42 of 'xTownsWindowClasses.xml' and we can see straight away that it calls the 'fpStateChanged()' function, which is on Line 46.

    'fpStateChanged()' simply calls an update function for each of the subwindows of the main Towns Window ('wcTown'). It doesn't really matter that I'm using subwindows - the logic is still the same. Let's take the swMain subwinow's update function ('swMain.subwindow.fpUpdate()') as an example.

    The windowclass called by 'swMain' is 'wcTownMain' (see Line 80-81 of 'xTownsWindowClasses.xml').

    Looking at 'wcTownMain' we can see that there is a script file ('lsTownMain.lua') associated with 'wcTownMain' (see Line 192 of 'xTownsWindowClasses.xml').

    Looking at Line 34 of 'lsTownMain.lua' we fine 'fpUpdate()'. Looking at Line 35 we can see a Boolean variable ('bReadOnly') is assigned either 'true' or 'false' depending upon if the Town Record's node in the Database is Read-Only or not.

    Finally, if you look through the rest of the 'fpUpdate()' function you'll see that we use bReadOnly to turn on and off various windowcontrols and their functionality - you can do the same thing to enable/disable the "onClick()" functions on your Tabs (or whatever they are called), effectively unlocking/locking them.

    Long, I know, but pretty clear (I hope)

    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  5. #5
    Exceptionally clear. Thank you.

    Edit: I thought I recognized that naming convention from somewhere. I don't know. When it comes to programming I'm more comfortable with LISP naming convention - type in exactly what the function does. <<sigh>> I miss those days.

    Cheers,
    SF
    Last edited by S Ferguson; November 18th, 2014 at 16:57.
    Aliens.... Go fig?

  6. #6
    Actually, I wrote that post as the last thing I did before switching off the light and going to sleep last night - I can sumerise it a bit better:

    Steps To Provide WindowControl Locking In CoreRPG
    1. Register a handler function in the WindowClass's onInit() function to be called when a specific Node in the Database changes.
    2. Have a ButtonControl in the WindowClass that modifies the Node in the Database referred to in Step (1).
    3. When the ButtonControl is Clicked, the value of the Node in the Database changes and therefore the handler function is called.
    4. Have the handler function call the DB.isReadOnly() function on the WindowClass's Node and store the result in a Boolean Variable.
    5. In the handler function use the Boolean Variable to turn on/off whatever functionality of whatever WindowControls (within the WindowClass) you like.


    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  7. #7
    Does it have to be on all of the Windowclasses of just the "titled" entries? Work with me here. I'm rather slow at FG XML - it doesn't follow the official guidelines.


    Cheers,

    SF
    Aliens.... Go fig?

  8. #8
    Quote Originally Posted by S Ferguson View Post
    Does it have to be on all of the Windowclasses of just the "titled" entries? Work with me here. I'm rather slow at FG XML - it doesn't follow the official guidelines.


    Cheers,

    SF
    Tell me an XML Implementation that does

    If I understand the question properly then only on the WindowClass (and thus the subwindows) that you want to lock down - if you only want to lock down the Tabs then that would only be the Windowclass that defines the tabs, not any subwindows called/linked to those tabs.

    Yeah?

    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  9. #9
    Got it. Thanks.

    Cheers,
    SF
    Aliens.... Go fig?

  10. #10
    What would the handler function look like in it's barest possible form? For some reason I'm drawing a blank on how to implement the DB.isReadOnly() command into my inline script.

    Regards,
    SF

    The code I have so far is:

    function onInit()
    update();
    onLockChanged()
    DB.addHandler(DB.getPath(getDatabaseNode(), "locked"), "onUpdate", onLockChanged);
    end

    function onClose()
    DB.removeHandler(DB.getPath(getDatabaseNode(), "locked"), "onUpdate", onLockChanged);
    end

    function onLockChanged()

    if npc_notes then
    npc_notes.update();
    end
    ...
    end

    The update function just does some bookkeeping. I'm working with NPC Notes in this particular example.
    Last edited by S Ferguson; November 27th, 2014 at 16:22.
    Aliens.... Go fig?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in