PDA

View Full Version : Effects window - what am I missing?



AmadanNaBriona
April 20th, 2020, 23:59
Trying to duplicate the Effects window in the D&D 2E to adapt it for my ruleset, I literally copied the code from the former ruleset's utility_effects.xml in its entirety to mine, changing only the references to conditions (to point to the correct file for my ruleset).

But here is the 2E window:


34131

And here is mine:

34132

So what stupid-obvious thing am I missing to explain why the layout is different and wrong in mine?

Here's the 2E code for utility_effects.xml. The code in red is literally the only thing I have changed (to use the correct filename).


<?xml version="1.0" encoding="iso-8859-1"?>

<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->

<root>
<windowclass name="effectlist">
<frame>utilitybox3</frame>
<placement>
<size width="520" height="525" />
</placement>
<sizelimits>
<dynamic />
<minimum width="520" height="525" />
</sizelimits>
<playercontrol />
<nodelete />
<tooltip textres="library_recordtype_label_effect" />
<script>
function onInit()
local nHalf = math.ceil(#(DataCommon.conditions) / 2);
for i = 1, nHalf do
local sEffect1 = StringManager.capitalize(DataCommon.conditions[i]);
local c1 = createControl("button_effect", "condition_" .. i);
c1.setEffect(sEffect1);

if (nHalf + i &lt;= #(DataCommon.conditions)) then
local sEffect2 = StringManager.capitalize(DataCommon.conditions[nHalf + i]);
local c2 = createControl("button_effectright", "condition_" .. (nHalf + i));
c2.setEffect(sEffect2);
end
end
end
</script>
<sheetdata>
<windowtitlebar name="title">
<resource>library_recordtype_label_effect</resource>
</windowtitlebar>
<anchor_title_utilitybox3 name="contentanchor" />

<!-- Conditions -->
<label name="label_conditions">
<anchored to="contentanchor" width="170" height="20">
<top anchor="bottom"/>
<left />
</anchored>
<static textres="effect_label_conditions" />
<color>FFFFFF</color>
<center />
</label>

<genericcontrol name="buttonanchor">
<anchored to="contentanchor" width="170" height="0">
<top anchor="bottom" offset="15" />
<left />
</anchored>
</genericcontrol>

<!-- Custom -->
<label name="label_custom">
<anchored to="contentanchor" height="20">
<top anchor="bottom" />
<left offset="195" />
<right offset="-10" />
</anchored>
<static textres="effect_label_custom" />
<color>FFFFFF</color>
<center />
</label>

<list_effects name="list" />
<scrollbar_list />

<anchor_campaign2 />
<button_iedit_campaign />
<button_iadd_utility />
<filter_utility />

<resize_utilitybox3 />
<helper_effects />
<close_utilitybox3 />
</sheetdata>
</windowclass>

<windowclass name="effectsmall">
<margins control="0,0,0,2" />
<script file="utility/scripts/effect.lua" />
<sheetdata>
<buttoncontrol>
<anchored position="insidetopleft" offset="2,2" width="20" height="20" />
<icon normal="button_action_effect" pressed="button_action_effect_down" />
<script>
function onDragStart(button, x, y, draginfo)
return window.actionDrag(draginfo);
end

function onButtonPress(x, y)
return window.action();
end
</script>
</buttoncontrol>
<button_iconcycler name="apply">
<bounds>27,7,24,10</bounds>
<gmeditonly />
<parameters>
<icons>button_toggle_action|button_toggle_roll|button_tog gle_single</icons>
<values>action|roll|single</values>
<tooltipsres>effect_tooltip_applyone|effect_tooltip_applyroll|e ffect_tooltip_applysingle</tooltipsres>
<defaulticon>button_toggle_all</defaulticon>
<defaulttooltipres>effect_tooltip_applyall</defaulttooltipres>
</parameters>
</button_iconcycler>

<genericcontrol name="rightanchor">
<anchored height="0" width="0">
<top />
<right />
</anchored>
</genericcontrol>
<button_idelete name="idelete">
<anchored>
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
</button_idelete>
<buttonfield name="isgmonly">
<anchored width="20" height="20">
<top offset="3" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<gmvisibleonly />
<gmeditonly />
<state icon="visibilityon" tooltipres="effect_visibilityon" />
<state icon="visibilityoff" tooltipres="effect_visibilityoff" />
<gmvisibleonly />
</buttonfield>
<button_stringcycler name="unit">
<anchored width="30">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-10" />
</anchored>
<gmeditonly />
<parameters>
<defaultlabelres>effect_label_durunitrnd</defaultlabelres>
<labelsres>effect_label_durunitmin|effect_label_durunithr|eff ect_label_durunitday</labelsres>
<values>minute|hour|day</values>
</parameters>
<script>
function onDragStart(button, x, y, draginfo)
return window.actionDrag(draginfo);
end
</script>
</button_stringcycler>
<basicnumber name="duration">
<anchored width="20" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-10" />
</anchored>
<gmeditonly />
<min>0</min>
<default>1</default>
<script>
function onDragStart(button, x, y, draginfo)
return window.actionDrag(draginfo);
end
</script>
<tabtarget prev="label" />
</basicnumber>

<string_textlistitem name="label">
<anchored position="insidetopleft" offset="55,2" height="20">
<right parent="rightanchor" anchor="left" relation="relative" offset="-10" />
</anchored>
<gmeditonly />
<script>
function onDragStart(button, x, y, draginfo)
return window.actionDrag(draginfo);
end

function onDoubleClick(x, y)
return window.action();
end
</script>
<tabtarget next="duration" />
</string_textlistitem>
</sheetdata>
</windowclass>

</root>

AmadanNaBriona
April 21st, 2020, 02:08
Okay, what I was missing was template_utility.xml.

However, I am still unsure why it didn't just inherit that from CoreRPG, which has a template_utility.xml file that defines all the controls used here. Why did I need to manually copy most of it into my ruleset's own template_utility.xml?

celestian
April 21st, 2020, 03:14
This is one of the things that was legacy from 5E when I originally started. I do backport code for the most part but not always. In this case I did not and kept the original source. However after more detailed review I've updated the code so that is matches the 5E style more... so in your situation it would work.

I've altered the layout a little and this is why a 1:1 replacement would not have worked. I've created a more standardized method of doing that and it will show up in a few weeks. Look for it in the updates.

The style is something I've recently been become more familiar with (using merge/joins instead of flat template replacements).

Here is the new utility.effects.xml



<root>
<windowclass name="effectlist" merge="join">
<sizelimits>
<dynamic />
<minimum width="520" height="525" />
</sizelimits>
<placement>
<size width="520" height="525" />
</placement>
<sheetdata>
<list_effects name="list">
<anchored to="contentanchor">
<top anchor="bottom" relation="relative" offset="35" />
<left offset="195" />
<right offset="-10" />
<bottom parent="" offset="-75" />
</anchored>
</list_effects>
</sheetdata>
</windowclass>

<windowclass name="effectsmall" merge="join">
<sheetdata>
<button_effect_apply name="apply" insertbefore="rightanchor" />

<button_effect_units name="unit" insertbefore="duration" />
</sheetdata>
</windowclass>
</root>


Here is the new template_utility.xml



<?xml version="1.0" encoding="iso-8859-1"?>

<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->

<root>
<!-- Library - Master Index -->
<template name="button_forge_item">
<button_text_sm>
<anchored to="buttonanchor" width="50">
<top />
<left anchor="right" relation="relative" offset="5" />
</anchored>
<state textres="item_button_forge" />
<script>
function onButtonPress()
Interface.openWindow("forge_magicitem", "forge.magicitem");
end
</script>
</button_text_sm>
</template>

<!-- Calendar -->
<template name="anchor_calendar">
<genericcontrol name="contentframe">
<anchored>
<top parent="contentanchor" anchor="bottom" relation="relative" offset="5" />
<left offset="10" />
<right offset="-10" />
<bottom offset="-25" />
</anchored>
</genericcontrol>
</template>
<template name="anchor_calendarlog">
<genericcontrol>
<anchored height="0">
<top parent="title" anchor="bottom" offset="0" />
<left parent="" anchor="left" offset="30" />
<right parent="" anchor="right" offset="-30" />
</anchored>
<disabled />
</genericcontrol>
</template>

<!-- Library - Master Index -->
<template name="masterindex_anchor_bottom">
<genericcontrol>
<anchored height="0">
<bottom offset="-25" />
<left parent="" anchor="left" offset="35" />
<right parent="" anchor="right" offset="-40" />
</anchored>
<disabled />
</genericcontrol>
</template>

<!-- Modifiers -->
<template name="list_modifiers">
<list_utility>
<anchored to="contentanchor">
<top anchor="bottom" relation="relative" offset="20" />
<left offset="175" />
<right offset="-10" />
<bottom parent="" offset="-75" />
</anchored>
<frame name="groupbox" offset="15,15,20,15" />
<datasource>.</datasource>
<class>modifiersmall</class>
<script>
function onDrop(x, y, draginfo)
if User.isHost() then
if draginfo.getType() == "number" then
local w = addEntry(true);
if w then
w.label.setValue(draginfo.getDescription());
w.bonus.setValue(draginfo.getNumberData());
end
return true;
end
end
end
</script>
</list_utility>
</template>

<!-- Options -->
<template name="list_options">
<windowlist>
<anchored to="contentanchor">
<top anchor="bottom" relation="relative" offset="20" />
<left offset="5" />
<right offset="-10" />
<bottom parent="" offset="-75" />
</anchored>
<frame name="groupbox" offset="15,15,20,15" />
<class>options_group</class>
<skipempty />
<sortby>
<control>sort</control>
<control>label</control>
</sortby>
</windowlist>
</template>
</root>


That's the versions that will be showing up in future update but if you want to use them now they should work for you if I understand your goal.

AmadanNaBriona
April 21st, 2020, 17:19
Perfect, thanks!