DICE PACKS BUNDLE
Page 1 of 3 123 Last
  1. #1

    Can you change anchor points in onInit()?

    Is it possible to add or subtract x,y cords to XML named controls In an onInit() function?

    Seems I’d have more flexibility as opposed to my current method of overriding them in XML with adjusted anchor points.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    Have a look at the windowcontrol API reference in the Wiki. Look at setAnchor, setAnchoredWidth, setAnchoredHeight or setStaticBounds: https://fantasygroundsunity.atlassia.../windowcontrol

    Note that you can usually do most of what is possible using normal XML properties. If you're inserting or removing controls, look at using relative anchoring - this is specifically designed to allow dynamic resizing. More info here: https://fantasygroundsunity.atlassia...gets#Anchoring
    Last edited by Trenloe; July 9th, 2020 at 07:56.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    Quote Originally Posted by Trenloe View Post
    Have a look at the windowcontrol API reference in the Wiki. Look at setAnchor, setAnchoredWidth, setAnchoredHeight or setStaticBounds: https://fantasygroundsunity.atlassia.../windowcontrol

    Note that you can usually do most of what is possible using normal XML properties. If you're inserting or removing controls, look at using relative anchoring - this is specifically designed to allow dynamic resizing. More info here: https://fantasygroundsunity.atlassia...gets#Anchoring
    Unfortunately, the way character sheets are defined you have to redo them to take advantage of relative anchoring - which currently they are all hardcoded in the places I need to move (at least in 5e). I'd also prefer to try (maybe not possible to do what I want we'll see) to force my gap in programmatically (your first suggestion) for the space I need and also to make it optional depending on active states and host/player display version of the sheet.

    But your tip gives me the hint I needed to experiment with, so thanks. Worst case scenario I end up working with what I've currently got overriding XML in the XML.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  4. #4
    Quote Originally Posted by Trenloe View Post
    Have a look at the windowcontrol API reference in the Wiki. Look at setAnchor, setAnchoredWidth, setAnchoredHeight or setStaticBounds: https://fantasygroundsunity.atlassia.../windowcontrol

    Note that you can usually do most of what is possible using normal XML properties. If you're inserting or removing controls, look at using relative anchoring - this is specifically designed to allow dynamic resizing. More info here: https://fantasygroundsunity.atlassia...gets#Anchoring
    I'm having trouble finding the window for the controls I want to change. The issue is that I want to do this when my window has an onInit.

    But at that level I'm on the 'charsheet' window class level, and the actual things I want to change anchor points on are in 'charsheet_main' class level. I can't seem to find the window 'charsheet_main' (buried in tabs?) nor can I find the actual controls under it which are really what I'm after. I'd add onInit to the controls themselves but some already have logic for that and I really don't wish to override and copy them - just want to change the anchor points and disturb that code as little as I possibly can.

    I've tried the Interface.findWindow code - trying to guess what I need to give it and no luck. I'm also at the window (charsheet.<specific ID>) and can directly access windows using raw text up to window.tab.tabs[1] - then I get totally lost and can't get past that level guessing at additional text. If you have any lesson or pointer on how to find windows buried in a charsheet window under charsheet_main windows class I'd like to know.

    Thanks for any info you can pass on.
    Last edited by SilentRuin; July 9th, 2020 at 18:56.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    Quote Originally Posted by SilentRuin View Post
    I can't seem to find the window 'charsheet_main' (buried in tabs?) nor can I find the actual controls under it which are really what I'm after.
    What can't you "find"? What are we referring to there? The "charsheet_main" windowclass definition in the FG XML? Or the windowinstance within LUA code?

    "charsheet_main" is defined in campaign\record_char_main.xml and has a <script> section (which is where you could run onInit code from).

    To get at the windowinstance from outside of it's scope, you can use something like window.main.subwindow (I haven't tested this). Some info here: https://fantasygroundsunity.atlassia...9259/subwindow
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  6. #6
    Quote Originally Posted by Trenloe View Post
    What can't you "find"? What are we referring to there? The "charsheet_main" windowclass definition in the FG XML? Or the windowinstance within LUA code?

    "charsheet_main" is defined in campaign\record_char_main.xml and has a <script> section (which is where you could run onInit code from).

    To get at the windowinstance from outside of it's scope, you can use something like window.main.subwindow (I haven't tested this). Some info here: https://fantasygroundsunity.atlassia...9259/subwindow
    Per the context of the discussion and the statements previously - in the lua code.

    I'm handed the window for charsheet as I stated. Then:

    Code:
    	Debug.console(window);
    -- WINDOW = { class = charsheet, node = charsheet.id-00001, x,y,w,h = 658,241,525,620 }
    
    	Debug.console(window.main);
    -- CONTROL_CONTAINER = { name = s'main', x,y,w,h = 15,89,0,0 }
    
    	Debug.console(window.main.charsheet_main);
    -- nil
    
    	Debug.console(window.tabs.tab[1]);
    -- { s'icon' = { #1 = s'tab_main' }, s'subwindow' = { #1 = s'main' } }
    
    	Debug.console(window.tabs.tab[1].charsheet_main);
    -- nil
    As you can see from above results I can't find the charsheet_main which has my results (keeping in mind I have XML overrides of its anchor points per past conversation - just want to do this in the code instead). I can find parts leading up to it but I'm lost how to get up to the actual window that will allow me to reference controls and set anchors in the code from where I'm starting.

    Calls to
    Code:
    Interface.findWindow ("charsheet_main", <lots of failed tries at field here> );
    Also just got nill back. As I stated I am at the charsheet window level for the particular displayed sheet when I enter this onInit I'm trying to do all this in. I just don't understand the syntax to get where I want to go. Usually its dead simple - I'm at the window I want to be in - or I have a straight shot at it with no issues. Not so in tab land.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    Quote Originally Posted by SilentRuin View Post
    As you can see from above results I can't find the charsheet_main which has my results (keeping in mind I have XML overrides of its anchor points per past conversation - just want to do this in the code instead).
    Have you tried what I suggested? window.main.subwindow

    EDIT: See the subwindow link I provided above, the descriptive text includes: "A reference to the contained windowinstance object is available from the script environment of the parent subwindow control through the variable subwindow." It also mentions "Using the positioning and sizing functions for the contained windowinstance may have unpredictable results." so keep that in mind - see the paragraph after for recommendations.

    "charsheet_main" is the windowclass used to create a windowinstance, but it is not the name of the windowcontrol/variable containing that instance.
    Last edited by Trenloe; July 9th, 2020 at 19:40.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  8. #8
    Quote Originally Posted by Trenloe View Post
    Have you tried what I suggested? window.main.subwindow

    EDIT: See the subwindow link I provided above, the descriptive text includes: "A reference to the contained windowinstance object is available from the script environment of the parent subwindow control through the variable subwindow." It also mentions "Using the positioning and sizing functions for the contained windowinstance may have unpredictable results." so keep that in mind - see the paragraph after for recommendations.

    "charsheet_main" is the windowclass used to create a windowinstance, but it is not the name of the windowcontrol/variable containing that instance.
    Added below...
    Code:
    	Debug.console(window.main.subwindow);
    Came back nil.

    Is there a way to just print out every window member? For sure that would be an awesome debug tool if nothing else.

    I suppose I can go to the actual control I want - yank out that window - then... I can I go back one window like I do in DB searches? Where I just use ".." or XPATH stuff like that?
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    Try main.subwindow
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  10. #10
    Quote Originally Posted by Trenloe View Post
    Try main.subwindow
    nil.

    I really appreciate your help here as you've forced me to trial and error trying to avoid this altogether.

    The thing I love about snipe hunts, is you learn stuff by trying to find the unfindable.

    window.main.setAnchor("top", "name", "bottom", "relative", 45);

    That actually saves me all my XML multiple overrides and I no longer care how to find the guys I was overriding. Why? Because sub_charsheet is a template.

    And now that I realize that - I found it and saw where I could do all I wanted in the above statement. Which once again, reaffirms my fiery all consuming hatred of templates May I never make my code so unreadable in the name of re-usability!

    So thank you again for forcing me to think outside the box I trapped myself in.

    And the thing I hate about snipe hunts?

    AHHHHHHHHHHHHHHHHHHH!!!!!!!!!

    That about sums it up. Thanks again
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

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
  •  
FG Spreadshirt Swag

Log in

Log in