3 Attachment(s)
Icon Cycler Button (Enhanced)
@Moon Wizard: As promised here is the code that I suggested earlier in this thread.
Recap: I complained that the control (template) does not have a "defaultvalue" parameter setting, that corresponds with the defaulticon and defaulttooltip parameters. The control falls back on a "defaultvalue" of "". Which I believe is a shortcoming. The developer should be able to set that value to something more meaningful to the control's context. An example: in the CoreRPG ruleset the button_iconrecycler template is employed by the button_effect_apply template. In that template there is a <defaulticon> of "button_toggle_all", with the <defaulttooltipres> of "effect_tooltip_applyall". The way the template is currently defined, the corresponding <value> for this icon is "". I believe the developer should be able to set the default <value> to a value they wish, for example, "all" in this context. (The other <values> employed in the control are "action", "roll" and "single".) Currently the developer defines n+1 icons (the <icons> + a <defaulticon>), n+1 tooltips (the <tooltips> + a <defaulttooltip>), but only n values (there is no <defaultvalue> parameter).
Remedy: I suggested that the control be modified to include a <defaultvalue> parameter. After looking at the lua code I decided to go a different route. Instead I suggest the <defaulticon> and consequently the <defaulttooltip> (or <defaulttooltipres>) be optional <parameters>. Right now they're mandatory and if the developer does not define them, when the form containing the icon cycler control comes up the control appears to be invisible (because there is no icon defined for that initial state). By allowing the "default" parameters to be optional, the developer can use a set of <icons>, a set of <values> and a set of <tooltips> that correspond one-to-one with what's presented on screen and in code.
Attached is the lua code (as text file ICC_button_iconcycler.txt) that I am submitting for replacement of the existing CoreRPG ruleset code. I have also attached the ruleset lua (as a text file) for convenience. If one diff's the two files, one sees that the new code employs one new function (bottom of the file) and 7 changes (typically setting the cycleindex equal to the value returned by the new function). The new function returns 1 if there is no <defaulticon> defined or 0 if there is. these two values correspond to the indexes into the icons[ ], values[ ], and tooltips[ ] tables. Without a <defaulticon> there is no [0]-th element in each of the tables.
Should this modification not adopted into the ruleset there is a tiny extension attached that defines and employs the modified .lua file. I release all copyright of the code to whomever may wish to employ it. The extension provides proof of concept using the CoreRPG Combat Tracker Faction iconcycler. As is, when dropped into a project the behavior of the Faction control in the Combat Tracker behaves exactly as if the extension were not being used. One can go in and uncomment the second <includefile> recitation in the extension.xml file and then the Faction control will cycle through "foe", "neutral" and "friend" because <defaulticon> is not used in the faction template in ICC_template_common.xml.
Thanks in advance for your consideration.