Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - Authoring Kit (http://forums.wolflair.com/forumdisplay.php?f=58)
-   -   Output table not varying? (http://forums.wolflair.com/showthread.php?t=62605)

TCArknight May 23rd, 2019 06:47 PM

Output table not varying?
 
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>

In the zWeapPick template:
Code:

    <portal
      id="notes"
      style="outTinyLt">
      <output_label
            field="wpNotes"
      ismultiline="yes">
        </output_label>
      </portal>

Position Script:
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>

But, the weapons don't become multi-line even if the wpNotes is much longer than a single output line. as seen below....

Thoughts, suggestions?
THanks!
TC

TCArknight May 24th, 2019 08:07 AM

1 Attachment(s)
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

Having that lets the notes output vary, but it seems crude.... I can work with it though. :)

Mathias May 28th, 2019 06:55 AM

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
lineheight is not a pixel-based number. It is the number of lines of text to allow within a text portal. So it's normally used in cases where you want to allow a maximum of 3 lines of text, and cut off anything else, or where you always want to show 2 lines, even if the text in this particular item would only require 1, because you want it to match with all the rest of the uses of this portal where it'll usually need 2 lines.

TCArknight May 28th, 2019 10:23 AM

Thanks Mathias, I’ll try that when I get a chance.

TCArknight June 4th, 2019 09:56 AM

Mathias,

Thanks! That worked just fine. I’ll keep that in mind going forward.

TC

Mathias June 4th, 2019 11:48 AM

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.

TCArknight June 4th, 2019 12:22 PM

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?

Mathias June 4th, 2019 12:52 PM

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.


All times are GMT -8. The time now is 07:01 AM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.