From GamingWiki
Jump to: navigation, search
 
(30 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
 
   Total number of columns in our table:
 
   Total number of columns in our table:
-->{{#vardefine: columns | {{{columns|4}}} }}<!--
+
-->{{#vardefine: columns | {{{columns|6}}} }}<!--
 +
 
 +
  HEADER
 +
 
 +
  If there is a header specified, we create a full-width TH tag.
 +
-->{{#if:{{{header<includeonly>|</includeonly>}}}|<nowiki />
 +
! colspan="{{#var:columns}}" {{!}} {{{header}}}
 +
}}<!--
 +
 
  
 
   SUBHEAD
 
   SUBHEAD
Line 13: Line 21:
 
-->}}<!--
 
-->}}<!--
 
-->{{#vardefine: subheadcols | <!--
 
-->{{#vardefine: subheadcols | <!--
   -->{{#ifeq: {{{subhead|M_NUL}}}  | M_NUL |0| {{#expr:{{#var:columns}}-{{#var:rheadcols}}}} }}<!--
+
   -->{{#ifeq: {{{subhead|<includeonly>M_NUL</includeonly>}}}  | M_NUL |0| {{#expr:{{#var:columns}}-{{#var:rheadcols}}}} }}<!--
 
-->}}<!--
 
-->}}<!--
  
-->{{#ifeq: {{#var:subheadcols}} |0||<nowiki />
+
-->{{#if:{{{header<includeonly>|</includeonly>}}}|{{Character sheet/section subhead|{{{header}}}| columns = {{#var:columns}} }} }}<!--
 +
-->{{#ifeq: {{#var:subheadcols}} |0| |<nowiki />
 
{{!}}-
 
{{!}}-
 
{{!}} colspan="{{#var:subheadcols}}" class="subhead" {{!}} {{{subhead}}}<!--
 
{{!}} colspan="{{#var:subheadcols}}" class="subhead" {{!}} {{{subhead}}}<!--
   -->{{#ifeq: {{#var:rheadcols}} |0||<nowiki />
+
   -->{{#ifeq: {{#var:rheadcols}} |0| |<nowiki />
 
{{!}} colspan="{{#var:rheadcols}}" class="shaded" {{!}} {{{righthead}}}<!--
 
{{!}} colspan="{{#var:rheadcols}}" class="shaded" {{!}} {{{righthead}}}<!--
 
   -->}}<!--
 
   -->}}<!--
 
-->}}<!--
 
-->}}<!--
  
-->
 
|- <!--
 
  
 
   DATA
 
   DATA
 +
 +
We may have one, two or three label-data pairs (left, centre, right).
 +
We construct a hash, datalinehash, which maps each row number to data for the given row. The row data are serialized hashes. To generate these sub-hashes we look through all of the args to this template and find the ones that end in numbers. These are then saved as properties of the corresponding entry in datalinehash.
  
 
-->{{#hashdefine: datalinehash }}<!--
 
-->{{#hashdefine: datalinehash }}<!--
 
-->{{#forargs: | keynum | value | <!--
 
-->{{#forargs: | keynum | value | <!--
  -->{{#vardefine: key | {{#rmatch: {{#var:keynum}} | (\D+)(\d+) | $1 }}}}<!--
 
  -->{{#vardefine: num | {{#rmatch: {{#var:keynum}} | (\D+)(\d+) | $2 }}}}<!--
 
  
   --><nowiki />
+
      Split the param (keynum) into a key name and a line number:
{{!}}-
+
   -->{{#vardefine: key | {{#rmatch: {{#var:keynum}} | (\D+)(\d+) | $1 }} }}<!--
{{!}} {{#var:num}}/{{#var:key}}
+
  -->{{#vardefine: num | {{#rmatch: {{#var:keynum}} | (\D+)(\d+) | $2 }} }}<!--
{{!}} colspan="3" {{!}} {{#var:value}} <!--
 
  
 
   -->{{#hashdefine: singledataline | {{#hashvalue: datalinehash | {{#var:num}} }} | ,css, | ;css; }}<!--
 
   -->{{#hashdefine: singledataline | {{#hashvalue: datalinehash | {{#var:num}} }} | ,css, | ;css; }}<!--
Line 48: Line 55:
 
   -->{{#hashreset: singledataline}}<!--
 
   -->{{#hashreset: singledataline}}<!--
 
-->}}<!-- end forargs
 
-->}}<!-- end forargs
 +
 +
Now datalinehash should look something like:
 +
 +
  1 => "label;css;some label,css,data;css;data for line 1"
 +
  2 => "llabel;css;left-side label,css,ldata;css;line 2 left,css,rdata;css;line 2 right"
 +
  etc.
 +
  
 
   Now each value of datalinehash can be parsed into a new hash. We want it sorted by
 
   Now each value of datalinehash can be parsed into a new hash. We want it sorted by
 
   key, so we use a key array.
 
   key, so we use a key array.
-->{{#hashtoarray:xxxdummy|datalinehash|datalinekeys}}<!--
+
-->{{#hashtoarray: |datalinehash|datalinekeys}}<!--
 +
 
 
-->{{#arraysort:datalinekeys|asc}}<!--
 
-->{{#arraysort:datalinekeys|asc}}<!--
-->{{#hashprint: datalinehash || %%%% | @@@@ | <!--
+
-->{{#hashprint: datalinehash | | %%%% | @@@@ | <!--
 
   -->{{#hashdefine: thedataline | @@@@ | ,css, | ;css; }}<!--
 
   -->{{#hashdefine: thedataline | @@@@ | ,css, | ;css; }}<!--
  
 
   The width of the data cell depends on the presence of a label  
 
   The width of the data cell depends on the presence of a label  
   and/or an rdata
+
   and/or an rdata. Let's count how many groups are present.
   -->{{#vardefine: labelcols | {{#ifeq: {{#hashvalue: thedataline | label |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
+
   -->{{#vardefine: groupcount | 0 }}<!--
   -->{{#vardefine: rdatacols | {{#ifeq: {{#hashvalue: thedataline | rdata |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
+
  -->{{#ifeq: {{#hashvalue: thedataline | llabel |M_NUL}}-{{#hashvalue: thedataline | ldata |M_NUL}} | <!--
  -->{{#vardefine: datacols | {{#expr:{{#var:columns}}-{{#var:labelcols}}-{{#var:rdatacols}} }} }}<!--
+
      --> M_NUL-M_NUL || {{#vardefine: groupcount | {{#expr: {{#var:groupcount}}+1}} }} <!--
  -->{{#ifeq:{{#hashvalue: thedataline | data }}-{{#var:labelcols}}-{{#var:rdatacols}}|-0-0||<!--
+
  -->}}<!--
 +
  -->{{#ifeq: {{#hashvalue: thedataline | label |M_NUL}}-{{#hashvalue: thedataline | data |M_NUL}} | <!--
 +
      --> M_NUL-M_NUL || {{#vardefine: groupcount | {{#expr: {{#var:groupcount}}+1}} }} <!--
 +
   -->}}<!--
 +
  -->{{#ifeq: {{#hashvalue: thedataline | clabel |M_NUL}}-{{#hashvalue: thedataline | cdata |M_NUL}} | <!--
 +
      --> M_NUL-M_NUL || {{#vardefine: groupcount | {{#expr: {{#var:groupcount}}+1}} }} <!--
 +
  -->}}<!--
 +
  -->{{#ifeq: {{#hashvalue: thedataline | rlabel |M_NUL}}-{{#hashvalue: thedataline | rdata |M_NUL}} | <!--
 +
      --> M_NUL-M_NUL || {{#vardefine: groupcount | {{#expr: {{#var:groupcount}}+1}} }} <!--
 +
  -->}}<!--
 +
 
 +
    If there are no groups, do nothing.
 +
  -->{{#ifeq:{{#var:groupcount}}|0||<!--
 +
 
 +
        Here we're assuming there are 6 columns total.
 +
        @todo remove this assumption
 +
      -->{{#vardefine:groupcols|<!--
 +
        -->{{#switch: {{#var:groupcount}} | 1 = 6 | 2 = 3 | 3 = 2 | 6 }}<!--
 +
      -->}}<!--
 +
 
 +
      -->{{#vardefine: llabelcols | {{#ifeq: {{#hashvalue: thedataline | llabel |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 +
      -->{{#vardefine: labelcols  | {{#ifeq: {{#hashvalue: thedataline | label |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 +
      -->{{#vardefine: clabelcols | {{#ifeq: {{#hashvalue: thedataline | clabel |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 +
      -->{{#vardefine: rlabelcols | {{#ifeq: {{#hashvalue: thedataline | rlabel |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 +
 
 +
      -->{{#vardefine: ldatacols | <!--
 +
        -->{{#ifeq: {{#hashvalue: thedataline | ldata |M_NUL}} | M_NUL | 0 | <!--
 +
            -->{{#expr:{{#var:groupcols}}-{{#var:llabelcols}} }} <!--
 +
        -->}}<!--
 +
      -->}}<!--
 +
      -->{{#vardefine: rdatacols | <!--
 +
        -->{{#ifeq: {{#hashvalue: thedataline | rdata |M_NUL}} | M_NUL | 0 | <!--
 +
            -->{{#expr:{{#var:groupcols}}-{{#var:rlabelcols}} }} <!--
 +
        -->}}<!--
 +
      -->}}<!--
 +
      -->{{#vardefine: cdatacols  | {{#expr:{{#var:columns}}-{{#var:labelcols}}-{{#var:clabelcols}}-{{#var:llabelcols}}-{{#var:ldatacols}}-{{#var:rlabelcols}}-{{#var:rdatacols}} }} }}<!--
 +
      -->{{#vardefine: datacols  | {{#var:cdatacols}} }}<!--
  
 
       --><nowiki />
 
       --><nowiki />
 
{{!}}- <!--
 
{{!}}- <!--
  
       -->{{#ifeq: {{#var: labelcols | 0 ||<nowiki />
+
       -->{{#ifeq: {{#var: llabelcols}} | 0 | |<nowiki />
{{!}} class="{{#hashvalue: thedataline | labelclass | shaded}}" {{!}} {{#hashvalue: thedataline | label }} <!--
+
{{!}} class="{{#hashvalue: thedataline | labelclass | shaded}} {{#hashvalue: thedataline | llabelclass }} llabel" <!--
 +
  --> {{!}} {{#hashvalue: thedataline | llabel }} <!--
 +
      -->}}<!--
 +
 
 +
      -->{{#ifeq: {{#var: ldatacols}} | 0 | |<nowiki />
 +
{{!}} class="{{#hashvalue: thedataline|dataclass|}} {{#hashvalue: thedataline | ldataclass }} ldata" <!--
 +
  --> colspan="{{#var:ldatacols}}" <!--
 +
  --> {{!}} {{#hashvalue: thedataline | ldata }} <!--
 +
      -->}}<!--
 +
 
 +
      -->{{#ifeq: {{#var: clabelcols}}{{#var: labelcols}} | 00 | |<nowiki />
 +
{{!}} class="{{#hashvalue: thedataline | labelclass | shaded}} {{#hashvalue: thedataline | clabelclass }} clabel" <!--
 +
  --> {{!}} {{#hashvalue: thedataline | label }}{{#hashvalue: thedataline | clabel }} <!--
 +
      -->}}<!--
 +
 
 +
      -->{{#ifeq: {{#var: cdatacols}} | 0 |<!--
 +
        -->{{#ifeq: {{#var: datacols}} | 0 | |<nowiki />
 +
{{!}} class="{{#hashvalue: thedataline|dataclass|}} {{#hashvalue: thedataline | cdataclass }} cdata" <!--
 +
  --> colspan="{{#var:datacols}}" <!--
 +
  --> {{!}} {{#hashvalue: thedataline | data }}{{#hashvalue: thedataline | cdata }} <!--
 +
        -->}}<!--
 +
      --> |<nowiki />
 +
{{!}} class="{{#hashvalue: thedataline|dataclass|}} {{#hashvalue: thedataline | cdataclass }} cdata" <!--
 +
  --> colspan="{{#var:cdatacols}}" <!--
 +
  --> {{!}} {{#hashvalue: thedataline | data }}{{#hashvalue: thedataline | cdata }} <!--
 
       -->}}<!--
 
       -->}}<!--
  
       --><nowiki />
+
       -->{{#ifeq: {{#var: rlabelcols}} | 0 | |<nowiki />
{{!}} class="{{#hashvalue: thedataline|dataclass|}}" colspan="{{#var:datacols}}" {{!}} {{#hashvalue: thedataline | data }} <!--
+
{{!}} class="{{#hashvalue: thedataline | labelclass | shaded}} {{#hashvalue: thedataline | rlabelclass }} rlabel" <!--
 +
  --> {{!}} {{#hashvalue: thedataline | rlabel }} <!--
 +
      -->}}<!--
  
       -->{{#ifeq: {{#var: rdatacols | 0 ||<nowiki />
+
       -->{{#ifeq: {{#var: rdatacols}} | 0 | |<nowiki />
{{!}} class="{{#hashvalue: thedataline|dataclass|}}" {{!}} {{#hashvalue: thedataline | rdata }} <!--
+
{{!}} class="{{#hashvalue: thedataline|dataclass|}} {{#hashvalue: thedataline | rdataclass }} rdata" <!--
 +
  --> colspan="{{#var:rdatacols}}" <!--
 +
  --> {{!}} {{#hashvalue: thedataline | rdata }} <!--
 
       -->}}<!--
 
       -->}}<!--
   -->}}<!-- end ifeq
+
 
 +
   -->}}<!-- end ifeq for existence of groups
 
   -->{{#hashreset: thedataline }}<!--
 
   -->{{#hashreset: thedataline }}<!--
-->| datalinekeys }}<!-- end hashprint datalinehash
+
-->}}<!-- end hashprint datalinehash
 
-->{{#hashreset: datalinehash }}<!--
 
-->{{#hashreset: datalinehash }}<!--
 +
-->{{#arrayreset:datalinekeys }}<!--
  
 
-->
 
-->

Latest revision as of 01:49, 22 August 2014

{{{header}}}
{{{subhead}}}