Varsuuk
February 18th, 2021, 18:08
Looking at:
https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644511/Ruleset+-+Templates+for+code+re-use
\
I cannot seem to figure out a basic thing. I want to redo a windowclass laying things out differently.
My initial plan was to copy the one in MoreCore then to modify with delete or replace the ones I needed to adjust.
This worked so far, eventually I'll decide if should depart completely or do join/replace/delete type edits.
When I got to the XP, XP-Needed and Level controls (number+widget) I wanted to center the widget label. I looked and found the template in MoreCore's template_campaign.xml:
<template name="number_labeled">
<basicnumber>
<frame mergerule="replace" name="fielddark" offset="4,2,4,2" />
<font>sheettext</font>
<lineoffset default="on">1</lineoffset>
<script>
labelwidget = nil;
function onInit()
if labelres then
labelwidget = addTextWidget("sheetlabelinline", string.upper(Interface.getString(labelres[1])));
else
labelwidget = addTextWidget("sheetlabelinline", string.upper(label[1]));
end
if labelwidget then
local w,h = labelwidget.getSize();
labelwidget.setPosition("bottomleft", w/2, h/2-4);
end
end
</script>
</basicnumber>
</template>
NOTE: I am working on an older FG/MoreCore since I do not regularly update on my dev box.
I am sure I just don't understand the whole XML rules as "simple" as they seem to be.
In all versions of the documentation - I often get confused with the terms used to describe the parent/child base/derived relationships and I often think that it is saying the thing you are USING (preexisting definition) needs to have "replace", for example, for it to work - I'm just still all confused. Normally, I have gotten the far by just ... trying stuff until works way I expect then I do it that way.
Right now, my first attempt was to take one of the controls and simply add (nothing was there before) the <script> section, taking it from the template just so I can test the layout before engaging in "merges":
<number_labeled name="exp">
<anchored to="weight" position="right" offset="10,0" width="60" />
<labelres>char_label_experience</labelres>
<script>
labelwidget = nil
function onInit()
if labelres then
labelwidget = addTextWidget("sheetlabelinline", string.upper(Interface.getString(labelres[1])))
else
labelwidget = addTextWidget("sheetlabelinline", string.upper(label[1]))
end
if labelwidget then
local w,h = labelwidget.getSize()
labelwidget.setPosition("bottom", 0, h/2-2)
end
end
</script>
</number_labeled>
That worked the way I wanted. So, I figure instead of copy-pasting that <script> to each of the 3 places I needed it, let me just modify the template by deriving a new one from it. BUT, before I did that, let me test copying and modifying the original just to make sure I understand stuff and to limit changes per iteration. I've been bitten by doing too much then having trouble finding a culprit when it stopped working.
So I tried changing the next one:
<number_labeled name="expneeded">
<anchored to="exp" position="right" offset="5,0" width="60" />
<labelres>char_label_expneeded</labelres>
</number_labeled>
to:
<number_labeled2 name="expneeded" merge="replace">
<anchored to="exp" position="right" offset="5,0" width="60" />
<labelres>char_label_expneeded</labelres>
</number_labeled2>
It does NOT work (meaning the updated script is no used) - the control and widget appear as if it was the original <number_labeled> template.
Any idea what I am doing wrong? I mean, I can just use the explicit (copy paste :( ) script but...
https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644511/Ruleset+-+Templates+for+code+re-use
\
I cannot seem to figure out a basic thing. I want to redo a windowclass laying things out differently.
My initial plan was to copy the one in MoreCore then to modify with delete or replace the ones I needed to adjust.
This worked so far, eventually I'll decide if should depart completely or do join/replace/delete type edits.
When I got to the XP, XP-Needed and Level controls (number+widget) I wanted to center the widget label. I looked and found the template in MoreCore's template_campaign.xml:
<template name="number_labeled">
<basicnumber>
<frame mergerule="replace" name="fielddark" offset="4,2,4,2" />
<font>sheettext</font>
<lineoffset default="on">1</lineoffset>
<script>
labelwidget = nil;
function onInit()
if labelres then
labelwidget = addTextWidget("sheetlabelinline", string.upper(Interface.getString(labelres[1])));
else
labelwidget = addTextWidget("sheetlabelinline", string.upper(label[1]));
end
if labelwidget then
local w,h = labelwidget.getSize();
labelwidget.setPosition("bottomleft", w/2, h/2-4);
end
end
</script>
</basicnumber>
</template>
NOTE: I am working on an older FG/MoreCore since I do not regularly update on my dev box.
I am sure I just don't understand the whole XML rules as "simple" as they seem to be.
In all versions of the documentation - I often get confused with the terms used to describe the parent/child base/derived relationships and I often think that it is saying the thing you are USING (preexisting definition) needs to have "replace", for example, for it to work - I'm just still all confused. Normally, I have gotten the far by just ... trying stuff until works way I expect then I do it that way.
Right now, my first attempt was to take one of the controls and simply add (nothing was there before) the <script> section, taking it from the template just so I can test the layout before engaging in "merges":
<number_labeled name="exp">
<anchored to="weight" position="right" offset="10,0" width="60" />
<labelres>char_label_experience</labelres>
<script>
labelwidget = nil
function onInit()
if labelres then
labelwidget = addTextWidget("sheetlabelinline", string.upper(Interface.getString(labelres[1])))
else
labelwidget = addTextWidget("sheetlabelinline", string.upper(label[1]))
end
if labelwidget then
local w,h = labelwidget.getSize()
labelwidget.setPosition("bottom", 0, h/2-2)
end
end
</script>
</number_labeled>
That worked the way I wanted. So, I figure instead of copy-pasting that <script> to each of the 3 places I needed it, let me just modify the template by deriving a new one from it. BUT, before I did that, let me test copying and modifying the original just to make sure I understand stuff and to limit changes per iteration. I've been bitten by doing too much then having trouble finding a culprit when it stopped working.
So I tried changing the next one:
<number_labeled name="expneeded">
<anchored to="exp" position="right" offset="5,0" width="60" />
<labelres>char_label_expneeded</labelres>
</number_labeled>
to:
<number_labeled2 name="expneeded" merge="replace">
<anchored to="exp" position="right" offset="5,0" width="60" />
<labelres>char_label_expneeded</labelres>
</number_labeled2>
It does NOT work (meaning the updated script is no used) - the control and widget appear as if it was the original <number_labeled> template.
Any idea what I am doing wrong? I mean, I can just use the explicit (copy paste :( ) script but...