Log in

View Full Version : Unable to use extra columns in windowlist



Lithl
June 8th, 2009, 07:08
For the health levels on my Exalted character sheet, I'm trying to use a windowlist to accommodate for characters with more than 7 HLs through Ox Body Technique. The windowlist is basically working, but for some reason, I can only interact with the first column of healthboxes; even delete item always deletes the first one!

Adding HLs works perfectly. Deleting HLs always deleted the first item in the windowlist. Clicking the healthboxes in the first column works correctly; clicking healthboxes in the other 4 columns does nothing. :(

Here's the windowlist:

<genericcontrol name="wounds0group">
<anchored>
<to>healthframe</to>
<position>insidetopleft</position>
<offset>10,20</offset>
<size>
<width>143</width>
<height>50</height>
</size>
</anchored>
<frame>
<name>logogroup</name>
</frame>
</genericcontrol>

<windowlist name="wounds0list">
<anchored>
<to>wounds0group</to>
<position>insideright</position>
<offset>5,-10</offset>
<size>
<width>100</width>
</size>
</anchored>
<class>element_healthbox</class>
<datasource>.wounds0</datasource>
<allowcreate />
<allowdelete />
<columns>
<width>20</width>
<fillwidth />
</columns>
</windowlist>

And the element_healthbox:

<windowclass name="element_healthbox">
<sizelimits>
<minimum>
<height>15</height>
</minimum>
</sizelimits>
<sheetdata>
<healthbox name="healthlevel">
<anchored>
<left>
<anchor>left</anchor>
<offset>0</offset>
</left>
<top>
<anchor>top</anchor>
</top>
<size>
<width>15</width>
<height>15</height>
</size>
</anchored>
</healthbox>
</sheetdata>
</windowclass>

healthbox is a template from the nWoD ruleset:

<template name="healthbox">
<genericcontrol>
<stateicons>
<empty>indicator_boxempty</empty>
<slash>indicator_boxslash</slash>
<cross>indicator_boxcross</cross>
<asterisk>indicator_boxasterisk</asterisk>
</stateicons>
<script file="scripts/template_healthbox.lua" />
</genericcontrol>
</template>
And finally template_healthbox.lua

local sourcelessvalue = 0;

function setState(state)
local datavalue = 0;

if state ~= 4 then
datavalue = state;
end

if source then
source.setValue(datavalue);
else
sourcelessvalue = datavalue;
update();
end
end

function update()
if source then
if source.getValue() == 0 then
setIcon(stateicons[1].empty[1]);
elseif source.getValue() == 1 then
setIcon(stateicons[1].slash[1]);
elseif source.getValue() == 2 then
setIcon(stateicons[1].cross[1]);
else
setIcon(stateicons[1].asterisk[1]);
end
else
if sourcelessvalue == 0 then
setIcon(stateicons[1].empty[1]);
elseif sourcelessvalue == 1 then
setIcon(stateicons[1].slash[1]);
elseif sourcelessvalue == 2 then
setIcon(stateicons[1].cross[1]);
else
setIcon(stateicons[1].asterisk[1]);
end
end

if self.onValueChanged then
self.onValueChanged();
end
end

function getState()
if source then
local datavalue = source.getValue();
return datavalue;
else
return sourcelessvalue;
end
end

function onClickDown(button, x, y)
setState(getState() + 1);
end

function onInit()
setIcon(stateicons[1].empty[1]);

if not sourceless and window.getDatabaseNode() then
-- Get value from source node
if sourcename then
source = window.getDatabaseNode().createChild(sourcename[1], "number");
else
source = window.getDatabaseNode().createChild(getName(), "number");
end
if source then
source.onUpdate = update;
update();
end
else
-- Use internal value, initialize to checked if <checked /> is specified
if checked then
sourcelessvalue = 1;
update();
end
end
end

Lithl
June 10th, 2009, 02:06
Update: Deleting always deleted from the first in the row, not the first in the whole windowlist. Still no closer to figuring out the problem, though :(

Lithl
June 10th, 2009, 06:30
FWIW, I've given up on this specific problem, using a workaround. Since I can always access the first item in the column, my healthboxes are now listed vertically; my -1 and -2 wound penalty levels each have 2 windowlists, and I've got some lua script to make the windowlist pair act like just one list for add/remove item.