-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtab_shiparmory.dat
405 lines (336 loc) · 13.4 KB
/
tab_shiparmory.dat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains the definition of the "Armory" tab panel. This tab is where
the user selects weapons and armor for the character.
All public visual elements used with this tab panel start with the prefix "ar"
to associate them with the tab.
-->
<document signature="Hero Lab Data">
<!-- yRange portal
Presents a dynamic table where the user can add ranged weapons for the
character. This portal is identical to "arMelee" above, except that it
manages ranged weapons instead of melee weapons, resulting in a few minor
but important differences from the melee weapons table.
<portal
id="shWeapons"
style="tblInvis">
<table_fixed
component="Gear"
scrollable="no"
showtemplate="shWpnPick"
showsortset="explicit">
<list>component.WeaponStarship</list>
<headertitle><![CDATA[
@text = "Starship Weapons"
]]></headertitle>
</table_fixed>
</portal>
-->
<portal
id="shWeapons"
style="tblInvis">
<table_dynamic
component="Gear"
showtemplate="shWpnPick"
choosetemplate="shWpnThing"
showsortset="ShipWeapDeliv"
choosesortset="ShipWeapDeliv"
addpick="resAddWeapons"
showfrozenfixed="yes"
>
<list>component.WeaponStarship</list>
<candidate inheritlist="yes">!Equipment.Natural</candidate>
<autotag group="Helper" tag="AddedWeapon"/>
<titlebar><![CDATA[
@text = "Select Starship Weapons from the List Below"
]]></titlebar>
<headertitle><![CDATA[
@text = "Starship Weapons"
if (hero.child[resAddWeapons].field[resLeft].value <> 0) then
@text &= " - " & hero.child[resAddWeapons].field[resSummary].text
endif
]]></headertitle>
<additem><![CDATA[
@text = "Add New Starship Weapons"
]]></additem>
</table_dynamic>
</portal>
<!-- arWpnThing template
Derived from the SimpleItem template, this template includes the weapon
damage and purchase cost. It is specifically for showing things for the
user to select.
It would be reasonable to assume that we could designate the range as a
simple field-based label portal, but that won't work. If the weapon is a
melee weapon, it won't have the range field, so you'll get run-time errors
when Hero Lab tries to access the field associated with the portal. The
solution is to use a script-based label that properly checks whether the
weapon is ranged. If so, then the field can be safely accessed. If not,
then the text is left as empty.
-->
<template
id="shWpnThing"
name="Weapon Thing"
compset="Weapon"
marginhorz="3"
marginvert="2">
<portal
id="name"
style="lblNormal">
<label>
<labeltext><![CDATA[
@text = field[name].text
doneif (tagis[Weapon.NoDamage] = 0)
if (tagis[DmgEffect.?] <> 0) then
@text &= " (" & tagnames[DmgEffect.?,","] & ")"
endif
]]></labeltext>
</label>
</portal>
<position><![CDATA[
~set up our dimensions, with a width that we dictate; our width can vary
~between weapon types, since ranged weapons require extra space for the range
height = portal[name].height
~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 damage portal to the left of the cost; we want the damage to
~be centered in its own column relative to a centerpoint position
~perform portal[damage].centerpoint[horz,180]
~position the range portal to be centered in its own column relative to a
~centerpoint position
~perform portal[range].centerpoint[horz,260]
~position the name on the left and let it use all available space
portal[name].left = 0
portal[name].width = width
~ minimum(portal[name].width,portal[range].left - 10)
]]></position>
</template>
<!-- arWpnPick template
Derived from the SimpleItem template, this includes the weapon damage and
the gear button to move equipment between various containers. We also show
the range for ranged weapons. This template is specifically for showing the
weapons that the user has already purchased.
For more details, please see the "arWpnThing" template above.
-->
<template
id="shWpnPick"
name="Weapon Pick"
compset="Weapon"
marginhorz="3"
marginvert="3">
<portal
id="name"
style="lblLeft">
<label
field="name">
</label>
</portal>
<portal
id="quality"
style="lblBrightLeft">
<label>
<labeltext><![CDATA[
@text = "Qualities: " & field[wpShipWpnQuals].text
]]></labeltext>
</label>
</portal>
<portal
id="damage"
style="lblBrightLeft">
<label>
<labeltext><![CDATA[
var txt as string
var summ as string
var lng as number
summ = field[wpDamageSummary].text
lng = length(summ) - 2
if (compare(left(summ,2),"* ") = 0) then
txt = mid(summ,2,lng)
elseif (compare(left(summ,8),"Strength") = 0) then
txt = summ
else
txt = "Damage: " & summ
endif
@text = txt
]]></labeltext>
</label>
</portal>
<portal
id="range"
style="lblBrightLeft">
<label>
<labeltext><![CDATA[
@text = "Range: " & field[wpShipWpnRange].text
]]></labeltext>
</label>
</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>
<portal
id="wepSep"
style="sepHorz">
<separator
isvertical="no">
</separator>
</portal>
<position><![CDATA[
~center the portals vertically
perform portal[delete].centervert
perform portal[info].centervert
perform portal[quality].centervert
perform portal[damage].centervert
perform portal[range].centervert
perform portal[name].centervert
perform portal[wepSep].centervert
perform portal[wepSep].centerhorz
var top1 as number
var top2 as number
~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]
portal[info].top = 0
~position the name on the left and let it use all available space
portal[name].left = 0
portal[name].top = 0
portal[name].width = 250
top1 = portal[name].top
top2 = portal[info].bottom + 5
~position the range portal to the left of the info button
portal[range].top = top1
perform portal[range].alignrel[ltor,name,-8]
~position the portals on 2nd rows
portal[quality].top = top2
portal[damage].top = top2
~position the attack portal to the left of damage column; we want the
~attack to be centered in its own column relative to a centerpoint position
perform portal[damage].alignedge[left,0]
portal[damage].width = width/4
~.centerpoint[horz,210]
perform portal[quality].alignrel[ltor,damage,5]
portal[quality].width = width - portal[quality].left
~if this is not a energy weapon, hide the range portal
portal[range].visible = tagis[component.BaseWeaponShip]
portal[wepSep].top = portal[damage].bottom + 10
portal[wepSep].width = width/2
portal[wepSep].left = width/4
height = portal[wepSep].bottom + 5
]]></position>
</template>
<!-- armory layout
This layout orchestrates the display of the visual elements that comprise
the Armory tab. This amounts to three pairs of title and table so the user
can add melee weapons, ranged weapons, and armor/shields.
The interesting facet of this layout is that it contains three separate
tables that can vary in height, depending on what the user chooses to add
to the character. These tables need to adapt their sizes to make efficient
use of the available space. The "position" script accomplishes this goal.
The exact steps being taken are clearly commented within the script, but
the basic strategy is pretty simple. First the portals at the top are
position, then the armor/shields table is positioned at the bottom with
only two items visible. The remaining space is calculated and shared
between the two weapon tables. Once the weapons have been given as much
space as they need, the armor/shields table is enlarged to take up any
additional space that is leftover.
-->
<layout
id="sh_armory">
<portalref portal="shWeapons" taborder="10"/>
<!-- This script sizes and positions the layout and its child visual elements. -->
<position><![CDATA[
~determine the gap to use between tables
var gap as number
gap = 13
if (hero.child[resAddWeapons].field[resLeft].value = 0) then
portal[shWeapons].freeze = 1
endif
~set the width of all tables to the full width of the layout
portal[shWeapons].width = width
~position the armor/shield table at the bottom, allowing for at most two rows
~portal[arDefense].maxrows = 2
~portal[arDefense].top = height - portal[arDefense].height
~position the melee table at the top
portal[shWeapons].top = 0
~set the heights of the two weapon tables to use all the space available
portal[shWeapons].height = height
~determine how much space we have left for the two tables; be sure to exclude
~the extra title and the extra spacing we'll use inbetween
~NOTE! If a value of 10 is added to the bottom coordinate of a portal, the
~net value will yield an actual GAP of one less. For example, if the bottom
~is at pixel 15, that pixel is part of the physical height of the portal. If
~you add 10 to that position for the next portal, it starts on pixel 25, so
~pixel 25 is part of the next portal. That means that pixels 16 through 24
~represent the dead space inbetween, which is a span of 9 pixels. We have to
~factor this detail in when adjusting the space remaining by our gaps.
~var remain as number
~remain = portal[arDefense].top - portal[arMelee].top
~remain -= (gap - 1) * 2
~if the height of both tables exceeds what we have left, we need to divvy up
~that space between the two tables
~if (portal[arMelee].height + portal[shWeapons].height > remain) then
~if the melee table is less than half the space, limit the ranged table
~to whatever space is leftover
~ if (portal[arMelee].height < remain / 2) then
~ portal[shWeapons].height = remain - portal[arMelee].height
~if the ranged table is less than half the space, limit the melee table
~to whatever space is leftover
~elseif (portal[shWeapons].height < remain / 2) then
~ portal[arMelee].height = remain - portal[shWeapons].height
~otherwise, both tables are larger than half the space, so we need to limit
~the height of both of them
~NOTE! If we just divide the remaining amount by two and set both tables to
~that height, we could end up with both tables being truncated by more than
~a half item, with the combined height being a full item short of taking up
~the full space. So we have to set the height of one table to half the
~remaining space, then subtract that table's final height from our remaining
~space, and finally set that as the height for the second table.
~else
~ portal[shWeapons].height = remain / 2
~ portal[arMelee].height = remain - portal[shWeapons].height
~ endif
~endif
~position the ranged weapons table beneath the melee table
~portal[shWeapons].top = portal[arMelee].bottom + gap
~position the armor/shields table beneath the ranged weapons table
~NOTE! we already positioned this table, but the above logic could result in
~a gap between the tables, so we close that gap by repositioning again
~portal[arDefense].top = portal[shWeapons].bottom + gap
~set the height of the armor/shields table to the whatever height is left;
~if the armor list is long and the weapon lists are short, this will show as
~much armor as there is remaining room to accommodate
~portal[arDefense].height = height - portal[arDefense].top
]]></position>
</layout>
<!-- armory panel
This is the "Armory" panel shown within Hero Lab. Since we want this panel
to appear first within the second grouping (equipment), we assign it an
"order" of 210.
The logic for this panel is similar to the logic for the preceeding panels,
so please refer to those panels for more details.
-->
<panel
id="sh_armory"
name="Starship Weapons"
marginhorz="5"
marginvert="5"
order="210">
<live>!HideTab.armory & ShowTab.Starship</live>
<layoutref layout="sh_armory"/>
<position><![CDATA[
]]></position>
</panel>
</document>