Senior Member
Join Date: Jan 2007
Location: NW Arkansas
Posts: 1,321
|
Howdy!
I have a table of weapons where every weapon is coming out with two lines, when the notes portal should be multiline and make each weapon a different height: Code:
<!-- zWeapon portal This is a table of all Weapons carried by the actor. Weapons use the same template for both the contents and the header across the top. See the template for more details on this. --> <portal id="zWeapon" style="outNormal"> <output_table component="WeaponBase" showtemplate="zWeapPick" headertemplate="zWeapPick" showsortset="Armory" varyheight="yes"> <list><![CDATA[ !component.MagicItem ]]></list> </output_table> </portal> Code:
<portal id="notes" style="outTinyLt"> <output_label field="wpNotes" ismultiline="yes"> </output_label> </portal> Code:
<position><![CDATA[ ~our height is based on the tallest portal within ~if (field[wpNotes].isempty = 0) then ~set out portal height to automatically size as needed perform portal[notes].autoheight notify "portal - " & portal[notes].height ~our height is the height of our portal ~height = portal[notes].bottom height = portal[name].height + portal[notes].height + 5 notify "overall - " & height ~else ~height = portal[name].height + 5 ~endif ~place the name and indicators at the top, and the notes underneath portal[name].top = 0 perform portal[badstr].alignrel[btob,name,0] perform portal[special].alignrel[ttob,name,0] perform portal[notes].alignrel[ttob,name,0] ~position the other portals with the same baseline as the name; since they ~use a smaller font, they will have a smaller height, so centering them will ~make them appear to float up relative to the name perform portal[attack].alignrel[btob,name,0] perform portal[damage].alignrel[btob,name,0] perform portal[ap].alignrel[btob,name,0] perform portal[range].alignrel[btob,name,0] perform portal[dots].alignrel[btob,name,0] ~establish suitable fixed widths for the various columns of data portal[attack].width = 135 portal[damage].width = 195 portal[ap].width = 50 portal[range].width = 225 ~ portal[notes].width = width ~assign the name the remaining horizontal space ~Note: We must also account for a gap of 5 between portals. portal[name].width = width - 4 * 5 portal[name].width -= portal[attack].width + portal[damage].width portal[name].width -= portal[ap].width + portal[range].width ~position our columns now, except for the name portal[attack].left = portal[name].right + 5 perform portal[damage].alignrel[ltor,attack,5] perform portal[ap].alignrel[ltor,damage,5] perform portal[range].alignrel[ltor,ap,5] portal[special].left = portal[name].left + 10 portal[notes].left = portal[special].right ~setup to track our position when positioning portals along the x-axis var x as number x = 0 ~if the weapon satisfies the minimum strength requirement, hide the bitmap, ~else position it on the left if (tagis[Helper.BadStrReq] = 0) then portal[badstr].visible = 0 else portal[badstr].left = 0 x = portal[badstr].right endif ~if there are no special details for the weapon, hide the bitmap if (field[wpNotes].isempty = 1) then portal[special].visible = 0 portal[notes].visible = 0 endif ~shrink the space for the name based on the presence of the two bitmaps portal[name].width -= portal[badstr].width * portal[badstr].visible ~ portal[name].width -= portal[special].width * portal[special].visible ~size the name to fit the available space, then reposition it at the baseline ~Note: This is needed since smaller text will have the same top position. perform portal[name].sizetofit[36] perform portal[name].autoheight perform portal[name].alignrel[btob,attack,0] ~recalculate the width of the name based on the sized font ~Note: This is needed so we can determine the span for the row of dots. ~Note: We must also cap the name portal to its previous width, just in case ~ the "sizetofit" didn't shrink the name far enough to fully fit. var limit as number limit = portal[name].width perform portal[name].autowidth if (portal[name].width > limit) then portal[name].width = limit endif ~position the name and special details indicator portals horizontally now portal[name].left = x x = portal[name].right ~ if (portal[special].visible <> 0) then ~ portal[special].left = x ~ x = portal[special].right ~ endif ~extend the dots from the right of the name across to the attack portal if (x > portal[attack].left - 10) then portal[dots].visible = 0 else portal[dots].left = x + 5 portal[dots].width = portal[attack].left - 5 - portal[dots].left endif ]]></position> Thoughts, suggestions? THanks! TC Working on - |
#1 |
Senior Member
Join Date: Jan 2007
Location: NW Arkansas
Posts: 1,321
|
I did find a workaround with the positioning, but it seems crude:
Code:
var myLength as number var myHeight as number myLength = length(field[wpNotes].text) myHeight = myLength / 75 myHeight = round(myHeight,0,1) ~set out portal height to automatically size as needed portal[notes].lineheight = myHeight ~place the name and indicators at the top, and the notes underneath portal[name].top = 0 perform portal[badstr].alignrel[btob,name,0] portal[special].top = portal[name].bottom + 5 portal[notes].top = portal[name].bottom + 5 ~our height is the height of our portal height = portal[notes].bottom Working on - |
#2 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
Try setting the width that the portal is allowed before the autoheight command - it'll probably be something simple like
Code:
portal[notes].width = width |
#3 |
Senior Member
Join Date: Jan 2007
Location: NW Arkansas
Posts: 1,321
|
Mathias,
Thanks! That worked just fine. I’ll keep that in mind going forward. TC Working on - |
#5 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
I was thinking about the details, and I realized what happened, and I wanted to explain that in case anyone looks up this thread in the future. When HL creates a text portal, the initial width of that portal is just enough to fit the text in that portal, but it doesn't try to multiline that text, even on a multiline field. So what would happen is that initially, the width of the portal is set to a very wide amount, probably wider than the space this template is fitting into on the character sheet. So, when you just told it to auto-height it, it checked whether the text needed to wrap, found it didn't, and set the height of that portal to the height needed to show a single line of text (which is the same value it was at before the autoheight). Once the width was set to the right amount, then when it checked where the text needed to wrap in the multiline, it found the wrapping you expected it to have and it calculated the right height to display all the lines that are needed.
|
#6 |
Senior Member
Join Date: Jan 2007
Location: NW Arkansas
Posts: 1,321
|
Thank you Mathias.
That definitely helps understand what was going on. I’ll better know what to look for when come across something similar. Does this process only apply regarding the output portals or is it a similar situation for UI portals as well? Working on - |
#7 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
It's a general thing - portals are given their own default sizes, based on their contents, which is independent of the template they're being displayed in, which means you can end up with situations where a portal is wider than can actually be displayed.
|
#8 |
|
|