PDA

View Full Version : Controlling the size of a subwindow.



Tenian
August 3rd, 2008, 01:16
So in my magic item display class, I decided to use subwindows to determine what stats are displayed (i.e. there's a sub window with all the weapon stats crit,damage,etc and a different sub window with all the armor stats AC, etc).

The problem is I haven't been able to control the size of the subwindows. I've tried using the <placement> tag (with <size>, <minimum> etc) to no avail.

I'm sure it's obvious and I'm just stupid :) As usual.

Foen
August 3rd, 2008, 06:53
I think this isn't quite straightforward, as there are two objects to consider here: the 'subwindow' control; and the 'windowclass' rendered in the subwindow.

The subwindow control is basically a placeholder, which defines the location of a subwindow and its class.

The rendered window class is stretched to fill the subwindow control.

I think, therefore, that you need to change the subwindow anchoring/bounds and not the window class placement etc.

For examples of this in the d20 ruleset, take a look at adventure_npcs.xml. There is an ultimate 'parent' window class (called 'npc') and a window class for each tab (for example 'npc_combat'), with a subwindow control (in this case 'combat') which binds the 'npc_combat' window class to the 'npc' window class.

The size of 'npc_combat' is given by the 'combat' subwindow control, not by anything on 'npc_combat' itself.


This window class contains the layout for combat data
<windowclass name="npc_combat">
<datasource>npc</datasource>
<script>
...
</script>
<sheetdata>
...
</sheetdata>
</windowclass>

This window class contains the layout for the npc in total
<windowclass name="npc">
...
<sheetdata>
...
This subwindow control binds the npc_combat window
class to the npc window class. It dictates the size of
npc_combat.
<subwindow name="combat">
<anchored>
<to>tabcontentframe</to>
<position>over</position>
<offset>-15,-7</offset>
</anchored>
<class>npc_combat</class>
</subwindow>
...
</sheetdata>
</windowclass>


I hope that helps.

Stuart

Tenian
August 3rd, 2008, 22:04
Ultimately subwindows were not useful for what I was trying to do.

I did manage to size it correctly...shortly before abandoning using them.

Foen
August 3rd, 2008, 22:11
*grins*

Foen

Tenian
August 4th, 2008, 01:13
Hey Foen, I finished the changes I was trying to make by toggling the magic items between three types.


And I had to pester you a lot less this time! :)

Foen
August 4th, 2008, 06:27
Sounds like your ruleset is shaping up. What elements do you still have to finish?

Foen

Tenian
August 4th, 2008, 11:11
I think all that is left for magic items is the highlighting/double click on a few fields. JPG does this with powers. If the text contains 2d6 fire damage you can double click it and get [power name] [dice roll] fire damage.

Magic items (weapons specifically) have 2 fields this should be applied to. Critical and Damage. Since JPG did all the hard work, I assume it will just be a simple matter of applying the correct scripts to those fields.

Other than that, I'd like to revisit the tables I did for weapons, armor, equip and see if I can't make them chew up less CPU. It bothers me that it spikes the CPU when you call up one of these tables. There is nothing to them really. Just some nested window lists with fields. The only actual script code is the 4 or 5 lines that turns the item name into a link.

Beyond those, I'm not sure what I'd add. I might actually have to build an adventure and run a few sessions to find out what's missing. Despite all the time I've put into the modules and now the ruleset, I've only actually been in 2 game sessions, both as a player. :)

Tenian
August 4th, 2008, 23:27
I used this thread (https://www.fantasygrounds.com/forums/showthread.php?t=6015) to locate the section of the code where JPG does this. His version seems a bit more advanced as he highlights a section of a large block of text and double clicking just rolls the highlighted portion.

For example: "This weapon deals 4d8 fire damage against squirrels or 1d4 frost damage against badgers." Would highlight the 4d8 fire damage on mouse over or the 1d4 frost damage when you mouse over it. Double clicking with either of those highlighted does the roll.

Anyhow, I located the script he was using to do this and tied my critical and damage sections into them. They now work as expected.

That just leaves the mystery CPU, I think.