Thread: Gizmo confusion
View Single Post
TCArknight
Senior Member
 
Join Date: Jan 2007
Location: NW Arkansas
Posts: 1,321

Old April 9th, 2013, 06:17 AM
Ok, I'm running into issues for the Gadget gizmos.

in the Game system, a gadget is an item the character has. This gadget has a Story point Value, and can contain several traits.

I have the gadgets entity and components
Code:
  <!-- An entity for the Gadget -->
  <entity
    id="entGadget"
    form="frmGadget">
    <bootstrap thing="GadgetHelp"/>
    </entity>

  <!-- Gadget component
        Each Gadget derives from this component
  -->
  <component
    id="Gadget"
    name="Gadget"
    autocompset="no">
    
    <!-- Each skill needs its own identity tag so existing skills can be identified during advancement -->
    <identity group="HasGadget"/>
    
    <!-- Every skill begins at a level 3 for gaining availability of an Area of Expertise -->
    <tag group="Equipment" tag="IsGadget"/>
    
    <!-- set the appropriate candidate expression -->
    <eval index="1" phase="Final" priority="1000" name="aoeHelp Expr">
      <![CDATA[
      
      var myId as string
      myId = tagids[Gadget.?," & "]
      
      call SetGadExpr
      ]]></eval>
    
    <!-- Each gadge that is added by the user costs story points -->
    <eval index="2" phase="Setup" priority="5000"><![CDATA[
      ~we must ignore bootstrapped abilities from races and abilities added via advances
      if (isuser + origin.ishero >= 2) then
        var stCost as number
        
        if (tagis[StoryCost.?] <> 0) then
          stCost = tagvalue[StoryCost.?]
          
          hero.child[resStP].field[resSpent].value += stCost
          endif
          
        endif
      ]]></eval>
      
    <!-- Track the skill on the actor -->
    <eval index="3" phase="Setup" priority="5000"><![CDATA[
      perform forward[HasGadget.?]
      
      ]]></eval>

      
    </component>
    
  <!-- Gadget Helper component
        Each Gadget Gizmo derives from this component
  -->
  
  <component
    id="GadgetHelp"
    name="Gadget Helper">

    <!-- Selection Tag Expressions -->
    <field
      id="GadgetExpr"
      name="Gadget Tag Expression"
      type="derived"
      maxlength="500">
      </field>

    </component>
Gadgets tab:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- This file contains the definition of the "Gadget" tab panel. This tab is where
      the user selects general Gadget (non-weapons) for the character.

      All public visual elements used with this tab panel start with the prefix "gr"
      to associate them with the tab.
-->

<document signature="Hero Lab Data">


  <!-- grGadget portal
        Presents a dynamic table where the user can add Gadget for the character.

        We use separate templates for selecting Gadget and showing the Gadget that has
        been chosen. Each of these appears further below.

        We use an "additem" script to simply prompt the user to add Gadget.

        The "buytemplate" and "selltemplate" attributes hook in the logic for
        properly buying and selling Gadget for cash.

        We use a "headertitle" script to place a suitable title above the table.

        The "list" tag expression restricts everything to only equipment (e.g. no
        weapons). The "candidate" tag expression is omitted, resulting in the same
        contents as the "list" tag expression.
  -->
  <portal
    id="grGadget"
    style="tblNormal">
    <table_dynamic
      component="Gadget"
      showtemplate="grGtPick"
      choosetemplate="grGtThing">
      <list>component.Gadget</list>
      <titlebar><![CDATA[
        @text = "Select Gadget" 
        ]]></titlebar>
      <headertitle><![CDATA[
        @text = "Gadgets"
        ]]></headertitle>
      <additem><![CDATA[
        @text = "Add New Gadget"
        ]]></additem>
      </table_dynamic>
    </portal>


  <!-- grGtThing template
        Derived from the SimpleItem template, this includes the purchase cost and
        the lotsize of the item to be purchased.
  -->
  <template
    id="grGtThing"
    name="Gadget Thing"
    compset="Equipment"
    marginhorz="3"
    marginvert="2">

    <portal
      id="name"
      style="lblNormal">
      <label>
        <labeltext><![CDATA[
          @text = field[name].text
          ]]></labeltext>
        </label>
      </portal>

    <portal
      id="cost"
      style="lblNormal">
      <label>
        <labeltext><![CDATA[
          @text = tagvalue[StoryCost.?]
          ]]></labeltext>
        </label>
      </portal>

    <position><![CDATA[
      ~set up our dimensions, with a width that we dictate
      height = portal[name].height
      width = 250

      ~if this is a "sizing" calculation, we're done
      doneif (issizing <> 0)

      ~position the cost portal on the far right
      perform portal[cost].alignedge[right,0]

      ~position the name on the left and let it use all available space
      portal[name].left = 0
      portal[name].width = minimum(portal[name].width,portal[cost].left - 10)
      ]]></position>

    </template>


  <!-- grGtPick template
        Derived from the SimpleItem template, this includes the Gadget button to move
        equipment between various containers.
  -->
  <template
    id="grGtPick"
    name="Gadget Pick"
    compset="Equipment"
    marginhorz="3"
    marginvert="3">

    <portal
      id="name"
      style="lblLeft"
      showinvalid="yes">
      <label
        field="name">
        </label>
      </portal>

    <portal
      id="username"
      style="editNormal">
      <edit
        field="UserName"
        maxlength="100">
        </edit>
      </portal>
    
    <portal
      id="edit"
      style="actEdit"
      tiptext="Edit Gadget">
      <action
        action="edit"
        buttontext="">
        </action>
      </portal>
      
    <portal
      id="info"
      style="actInfo">
      <action
        action="info">
        </action>
      <mouseinfo/>
      </portal>

    <portal
      id="delete"
      style="actDelete"
      tiptext="Click to delete this equipment">
      <action
        action="delete">
        </action>
      </portal>

    <position><![CDATA[
      ~set up our height based on our tallest portal
      height = portal[info].height

      ~if this is a "sizing" calculation, we're done
      doneif (issizing <> 0)

      ~center the portals vertically
      perform portal[name].centervert
      perform portal[username].centervert
      perform portal[edit].centervert
      perform portal[info].centervert
      perform portal[delete].centervert

      ~position the delete portal on the far right
      perform portal[delete].alignedge[right,0]

      ~position the info portal to the left of the delete button
      perform portal[info].alignrel[rtol,delete,-8]

      ~position the info portal to the left of the delete button
      perform portal[edit].alignrel[rtol,info,-8]
      
      ~position the name on the left and let it use all available space
      var limit as number
      limit = portal[edit].left - 8
      portal[name].left = 0
      portal[name].width = minimum(portal[name].width,limit)

      ~if this is a "custom" Gadget pick, show an edit portal instead of the name
      var nextleft as number
      if (tagis[Helper.CustomItem] <> 0) then
        portal[name].visible = 0
        portal[username].left = portal[name].left
        portal[username].width = minimum(200,limit)
        nextleft = portal[username].right
      else
        portal[username].visible = 0
        nextleft = portal[name].right
        endif
      nextleft += 5

      ~if the Gadget can't be deleted (i.e. it's been auto-added instead of user-added,
      ~set the style to indicate that behavior to the user
      if (candelete = 0) then
        perform portal[name].setstyle[lblAuto]
        endif
      ]]></position>

    </template>


  <!-- Gadget layout
        This layout orchestrates the display of the visual elements that comprise
        the Gadget tab. This amounts to a title and a table that allow the user to
        add Gadget to the character.

        The logic for this layout is similar to preceeding tabs, so please refer
        to those tabs for more details.
  -->
  <layout
    id="gadget">
    <portalref portal="grGadget" taborder="10"/>

    <!-- This script sizes and positions the layout and its child visual elements. -->
    <position><![CDATA[
      ~position and size the table to span the full layout
      perform portal[grGadget].autoplace
      ]]></position>

    </layout>


  <!-- Gadget panel
        This is the "Gadget" panel shown within Hero Lab. Since we want this panel to
        appear second within the second grouping (equipment), we assign it an
        "order" of 220.

        The logic for this panel is similar to the logic for the preceeding panels,
        so please refer to those panels for more details.
    <live>!HideTab.gadget</live>
  -->
  <panel
    id="gadget"
    name="Gadget"
    marginhorz="5"
    marginvert="5"
    order="220">
    <layoutref layout="gadget"/>
    <position><![CDATA[
      ]]></position>
    </panel>

  </document>
Gadget thing:
Code:
  <thing
    id="gad51stBla"
    name="51st Century Blaster"
    compset="Gadget"
    isunique="yes"
    description="Handy gun (damage 4/L/L) that deletes and restores walls and other items digitally, as used by River Song.">
    <tag group="Gadget" tag="Major"/>
    <tag group="StoryCost" tag="2"/>
    <child entity="entGadget">
      <bootstrap thing="abDelete"/>
      <bootstrap thing="abDelete"/>
      <bootstrap thing="abRestrict"/>
      <bootstrap thing="abRestrict"/>
      </child>
    </thing>
<continued next post>
TCArknight is offline   #17 Reply With Quote