PDA

View Full Version : List within list, wheels within wheels ;)



LilCthulhu
December 25th, 2009, 19:43
Hi,

Just a quick question, so far a lot of the stuff has been pretty straightforward and the time spent on developing the Cortex ruleset has been rewarding ;) I haven't try the following in any way, spend too much time with the family, but before attacking the following task, anybody can give me pointers ?

I have a list of skills as such



Skill Specialization Die
Melee Combat d6
Melee Combat Dagger d8
Melee Combat Sword d8
Pilot d6
Pilot Airplane d8


And would prefer something like this :



Skill / Specialization Die
Melee Combat d6
Dagger d8
Sword d8
Pilot d6
Airplane d10


Is it as simple as putting another field in my skill item list and that field being my specialization windowlist ? Will the second list be automatically bound to db as the first ? and each specialilization properly linked to it's skill ?

Foen
December 26th, 2009, 06:12
You could achieve the same thing without nested lists by changing the layout of the list items so that the specialization name starts further to the left, and selectively hiding the skill name if the entry has a specialization.

Say you have three fields on the window class for the skill (called name, specialization, and die) then your current window class definition might look a bit like:


<windowclass name="skilllistitem">
<sheetdata>
<stringfield name="name">
<bounds>0,0,100,18</bounds>
</stringfield>
<stringfield name="specialization">
<bounds>0,100,100,18</bounds>
</stringfield>
<stringfield name="die">
<bounds>0,200,40,18</bounds>
</stringfield>
</sheetdata>
</windowclass>

Your revised window class definition could look like:


<windowclass name="skilllistitem">
<script>
function redraw()
if specialization.getValue()=="" then
name.setVisible(false);
specialization.setVisible(true);
else
name.setVisible(true);
specialization.setVisible(false);
end
end

function onInit()
redraw();
end
</script>
<sheetdata>
<stringfield name="name">
<bounds>0,0,100,18</bounds>
</stringfield>
<stringfield name="specialization">
<bounds>0,40,100,18</bounds>
<script>
function onValueChanged()
window.redraw();
end
</script>
</stringfield>
<stringfield name="die">
<bounds>0,140,40,18</bounds>
</stringfield>
</sheetdata>
</windowclass>

Hope that helps

Foen

LilCthulhu
December 26th, 2009, 07:05
Hi Foen,

Thanks for the quick answer, I actually had something like that, actually resizing the fields (therefore hiding it with a lenght of 0) depending on whether it was a skill or specialization ;) Your solution to use the setVisible() is more elegant !

I'm not yet fully aware of all the methods, and try to find the proper one when I have achieved the task I'm trying to do..

This solution works of course, but I find that as soon as the specialization becomes "" again, two skills with the same name appears in the list... and I find that a little bit not pretty ;)

I am almost there adding a second list as a field to the item in the first list. The second list is there, in the database... but not in the screen and I wonder why ... as if a windowlist could not be within a field in itself. I know subitems are created, but it's like if the first list or second list is not "automatically adjusting itself..."

LilCthulhu
December 26th, 2009, 07:17
Hi Foen,

Well just found out why... my anchoring was off and I don't know why, but your window.redraw() push me somewhere else, I understood that the achoring must have been bad... and there it was ;) Thanks a lot ;)

Foen
December 26th, 2009, 07:20
Your way is better, though harder. I'm glad you got what you wanted and made it work.

Cheers

Foen