MostTornBrain
March 20th, 2022, 20:58
Hi,
I made a very small extension that will allow adding formatted-text annotations to any "misc" numeric field on the character sheet. I find over time I often will forget where the values I entered for "misc" actually came from, so this allows one to enter a description, or a link to a section of the rules, etc.
I tested this with PFRPG 1E, but I think it should work with any ruleset as it is adding behavior to the number field from the CoreRPG.
This was mostly done as a learning exercise to get myself more familiar with different features within the FGU Lua scripting environment, but I think others might find it useful.
The extension works by overriding the "basicnumber" template and looks for any writeable fields on a charsheet that contain the string "misc" as part of the name. All of those detected fields will get some extra logic applied to add a small widget in the corner as a visual indication of whether an annotation has been attached or not. Also, the field will have a tooltip of the note's plain text if it exists. One can then add annotations to such misc fields by CTRL-clicking on the field. This will bring up a formatted-text editor and behind the scenes the contents will be saved to part of the charactersheet XML.
Here are some screenshots showing what this looks like in operation:
52096
In the above image, the small triangle in the lower right of a field indicates it can be annotated. If the triangle has a blue halo, it means it currently has a note attached. (I reused the combobox icon so hopefully this will coexist with any themes as it should piggyback on the combobox icon changes made for any theme.)
Here's a screenshot showing the hovertext tooltip of an annotation.
52097
Here's a screenshot showing the formatted-text editor (mostly styled after the MOTD windowclass).
52098
Feedback is welcomed. I figured this out with lots of trial and error, so if you notice I did anything in a less than ideal way, feel free to let me know. I tried to do as much of the parsing and caching of values "up-front" as possible during the initial display of the character sheet to hopefully reduce the processing overhead of adding custom handling to all the "misc" fields.
One potentially "quirky" thing is how I set the title of the formatted-text editor when annotating a field. I use the name of the misc field from the node. In most cases the title ends up self-explanatory (such as "saves.fortitude.misc"), but for the misc fields for all the skills, having a title like "skillist.id-00025.misc" isn't very descriptive. :-D Hopefully one remembers what field they were annotating in this case.
This is currently on github - under MIT license: https://github.com/MostTornBrain/MiscAnnotations
It is also freely available on the Forge: https://forge.fantasygrounds.com/shop/items/567/view
If someone else wants to repurpose this code into an existing extension or do something better with it, feel free.
Cheers,
Brian
I made a very small extension that will allow adding formatted-text annotations to any "misc" numeric field on the character sheet. I find over time I often will forget where the values I entered for "misc" actually came from, so this allows one to enter a description, or a link to a section of the rules, etc.
I tested this with PFRPG 1E, but I think it should work with any ruleset as it is adding behavior to the number field from the CoreRPG.
This was mostly done as a learning exercise to get myself more familiar with different features within the FGU Lua scripting environment, but I think others might find it useful.
The extension works by overriding the "basicnumber" template and looks for any writeable fields on a charsheet that contain the string "misc" as part of the name. All of those detected fields will get some extra logic applied to add a small widget in the corner as a visual indication of whether an annotation has been attached or not. Also, the field will have a tooltip of the note's plain text if it exists. One can then add annotations to such misc fields by CTRL-clicking on the field. This will bring up a formatted-text editor and behind the scenes the contents will be saved to part of the charactersheet XML.
Here are some screenshots showing what this looks like in operation:
52096
In the above image, the small triangle in the lower right of a field indicates it can be annotated. If the triangle has a blue halo, it means it currently has a note attached. (I reused the combobox icon so hopefully this will coexist with any themes as it should piggyback on the combobox icon changes made for any theme.)
Here's a screenshot showing the hovertext tooltip of an annotation.
52097
Here's a screenshot showing the formatted-text editor (mostly styled after the MOTD windowclass).
52098
Feedback is welcomed. I figured this out with lots of trial and error, so if you notice I did anything in a less than ideal way, feel free to let me know. I tried to do as much of the parsing and caching of values "up-front" as possible during the initial display of the character sheet to hopefully reduce the processing overhead of adding custom handling to all the "misc" fields.
One potentially "quirky" thing is how I set the title of the formatted-text editor when annotating a field. I use the name of the misc field from the node. In most cases the title ends up self-explanatory (such as "saves.fortitude.misc"), but for the misc fields for all the skills, having a title like "skillist.id-00025.misc" isn't very descriptive. :-D Hopefully one remembers what field they were annotating in this case.
This is currently on github - under MIT license: https://github.com/MostTornBrain/MiscAnnotations
It is also freely available on the Forge: https://forge.fantasygrounds.com/shop/items/567/view
If someone else wants to repurpose this code into an existing extension or do something better with it, feel free.
Cheers,
Brian