PDA

View Full Version : Reassigning Anchors to new elements in Extension



Tielc
May 19th, 2018, 15:48
I am trying to modify and create an extension where I want to move some fields by attaching them to a new field I've created. However, when I add the anchor tags in my extension for an existing field like the following where curhp is a new text field


<number_curhp name="curhp">
<anchored to="healthtitle" width="40" height="30">
<top anchor="bottom" offset="15" />
<right anchor="center" offset="-70" />
</anchored>
<font>reference-b-large</font>
<description textres="char_tooltip_hpcurrent" />
<min value="0" />
<script>
function onValueChanged()
window.onHealthChanged();
end
</script>
</number_curhp>

<label_charfieldtop name="label_curhp">
<anchored to="curhp" offset="0,15" />
<static textres="char_label_hpcurrent" />
</label_charfieldtop>

<number_dropadd name="hp">
<anchored to="curhp" position="righthigh" offset="15,0" width="40" height="30"/>
</number_dropadd>


I get the following error message x 4

Ruleset Error: window: Control (hp) anchoring to uncalculated control (curhp) in windowclass (charsheet_main)
Ruleset Error: window: Control (hp) anchoring to uncalculated control (curhp) in windowclass (charsheet_main)
Ruleset Error: window: Control (hp) anchoring to uncalculated control (curhp) in windowclass (charsheet_main)
Ruleset Error: window: Control (hp) anchoring to uncalculated control (curhp) in windowclass (charsheet_main)

Additionally, I'm going to want to move an HP label that exists on the character sheet, but it hasn't been named. Is there a way to retrieve this element without it having been named?

damned
May 19th, 2018, 16:32
if you remove your hp code does the rest of it anchor properly?

Can you add a Debug.console() to the hpcur script in an oninit and see if it is executing before the hp anchor warnings.

--

For the other - request from the devs to name the object.
In the meantime you will need to copy the whole windowclass if the element is not named.

Trenloe
May 19th, 2018, 17:09
The XML tag <number_curhp> control needs to be the name of a valid FG control or control template.

Tielc
May 19th, 2018, 17:28
The XML tag <number_curhp> control needs to be the name of a valid FG control or control template.

I have a control template for for number_curhp based off from number_chartotal

I've added the debug script to both elements, it looks like the hp element is loading before the curhp element, even though I'm changing the anchors in my Extension after the curhp element has been created.


Ruleset Error: window: Control (hp) anchoring to uncalculated control (curhp) in windowclass (charsheet_main)
Ruleset Error: window: Control (hp) anchoring to uncalculated control (curhp) in windowclass (charsheet_main)
Runtime Notice: s'hp is loaded'
Runtime Notice: s'curhp is loaded'
Ruleset Error: window: Control (hp) anchoring to uncalculated control (curhp) in windowclass (charsheet_main)
Ruleset Error: window: Control (hp) anchoring to uncalculated control (curhp) in windowclass (charsheet_main)

Tielc
May 19th, 2018, 17:30
I'm wondering if I could run an onInit script in the curhp element to change the anchors there.

Tielc
May 19th, 2018, 17:30
Also, any thoughts how to move this unnamed element from the record_char_main.xml?

<label>
<anchored to="wounds" position="lefthigh" offset="15,5" />
<static textres="hp" />
</label>

Trenloe
May 19th, 2018, 17:42
Also, any thoughts how to move this unnamed element from the record_char_main.xml?

<label>
<anchored to="wounds" position="lefthigh" offset="15,5" />
<static textres="hp" />
</label>


See damned's reply:


For the other - request from the devs to name the object.
In the meantime you will need to copy the whole windowclass if the element is not named.

Trenloe
May 19th, 2018, 17:46
I have a control template for for number_curhp based off from number_chartotal

I've added the debug script to both elements, it looks like the hp element is loading before the curhp element, even though I'm changing the anchors in my Extension after the curhp element has been created.
Use the insertbefore merge command to make sure that curhp is inserted in the final merged windowclass before the controls anchored on it.

To see some examples, search the 5E ruleset for insertbefore

damned
May 20th, 2018, 01:11
Use the insertbefore merge command to make sure that curhp is inserted in the final merged windowclass before the controls anchored on it.

To see some examples, search the 5E ruleset for insertbefore

Cool - Id not see that before!

Tielc
May 20th, 2018, 01:17
For the other - request from the devs to name the object.

What is the correct or proper way to go about this?

damned
May 20th, 2018, 01:49
What is the correct or proper way to go about this?

Sometimes its plain luck - hoping Moon Wizard spies your post - otherwise send an email to [email protected] subject="Missing Label Name" Attn: Moon Wizard with enough detail that he doesnt have to go searching...

Tielc
May 20th, 2018, 01:56
Great, thank you! I sent the message noting the specific file in it's location in the ruleset, as well as the specific line number and a description of it's purpose.

Tielc
May 20th, 2018, 01:56
Use the insertbefore merge command to make sure that curhp is inserted in the final merged windowclass before the controls anchored on it.

To see some examples, search the 5E ruleset for insertbefore

Thank you for this! Made more sense once I searched for it for sure. Works like a charm!

Trenloe
May 20th, 2018, 04:51
Works like a charm!
Great! Glad to hear it worked. :)

Varsuuk
July 26th, 2020, 04:55
OMG - Thank you. A quick search of FG forums FTW. I just added a "duplicate" control that takes the place of the AC in CT when AAC is enabled then goes back to normal AC if disabled etc. Figured out how to do setAnchor and setAnchorWidth to take care of this but the new one was reporting the "uncalculated control" until saw this and realized it is because I added the new control which an EXISTING control had to "relative" off of. So if in the "leaf" xml I added insertbefore="health" it let health use the new (defenceAAC) control properly where it previously only know of "defense")

**shakes fist at Damned* for all my typos (RIGHT-o's really) when I type "defense" in code. (I like to kid my Canadian, UK and Aussie friends :) )

Wish could + ya Trenloe, you beautiful poster of Truths and FG Goodness.