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.
Printable View
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.
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.
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.
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:
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.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
Calls to
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.Code:Interface.findWindow ("charsheet_main", <lots of failed tries at field here> );
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...
Came back nil.Code:Debug.console(window.main.subwindow);
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?
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 :)