PDA

View Full Version : Announcing a Developer's Toolbox



Minty23185Fresh
April 2nd, 2018, 19:05
THIS EXTENSION IS NO LONGER AVAILABLE.

While developing new extensions I constantly find myself having to dump data to the Debug console for analysis. It seems to be the only tool we have. I've also noticed that I usually need to dump the same data from project to project. I've started collecting my "data dumpers" in an external extension. I've thought of publishing it for a while, so now I've prettied it up a bit, and here it is.

I'm releasing it to public domain, for everyone's consumption and modification. My hope being that, if you have a couple routines sitting on the wayside you'll deem the DevTools toolbox worthy of including them, make the modifications and republish.

The current tools are:
1) dumpControlProperties: outputs a window control's properties (e.g. genericcontrol.getSize())
2) dumpDragData: outputs the contents of a dragdata or draginfo object
3) dumpNodeNames: (recursive) outputs the node names of a database subtree
4) dumpSupers: (recursive) outputs a super (or self) object's contents and any sub-super's contents
5) dumpWindowControls: outputs the names of all controls in a window object
6) dumpWindowlist: technically a window control, but handled separately, outputs the windows in a windowlist
7) runThis: put some code in here and divert execution to it (I use it for developing pattern matching strings)

Each of the routines have two or more arguments. The common arguments are:
1) the object being operated on, e.g. super, a window, a window control
2) an announcement: a string output at the beginning of the routine (I typically put the caller routine's name in here)
Information about other arguments is available in a "usage" preamble just above each method.
e.g. --[[ usage: DevTools.dumpWindowlist(windowlist, [sAnnounce], [bDumpSubWindows]);
Just copy and paste the part after "usage:" to your caller, and fill in the appropriate parameters.
(Hint: If your code editor supports code collapse as Notepad++ does, collapse the manager_tools.lua file to level one to see each function's preamble)

Which brings up the issue of using the extension (I believe it to be ruleset nonspecific.)
Personally I unzip the extension into a _DevTools folder. That way the folder is toward the top of my extension subfolder. I unzip the extension because I may want to look at the usage preambles, or make quick changes to tools, fix tools or use the runThis( ) tool.

I'll reserve the next post of this thread for some additional details.
(E.g. there is a chat slash handler and some of the individual tools might need some elucidation.)

Here is an example of part of the output from dumpControlProperties():


Runtime Notice: s'==DevTools==dumpControlProperties() | ' | s'Hello there, from MY Calling Method'
Runtime Notice: s'==DevTools==dumpControlProperties() | control=, type=' | windowcontrol = { x,y,w,h = 0,0,0,0 } | s'genericcontrol'
Runtime Notice: s'==DevTools==dumpProperty() | control property: icon = ' | s'dot_blue'
Runtime Notice: s'==DevTools==dumpProperty() | control property: hasIcon( ) = ' | bTRUE
Runtime Notice: s'==DevTools==dumpControlProperties() | ' | s'Inherited <windowcontrol> properties'
Runtime Notice: s'==DevTools==dumpControlProperties() | control=, type=' | windowcontrol = { x,y,w,h = 0,0,0,0 } | s'windowcontrol'
Runtime Notice: s'==DevTools==dumpProperty() | control property: anchored.height = ' | s'50'
Runtime Notice: s'==DevTools==dumpProperty() | control property: anchored.top.anchor = ' | s'bottom'
Runtime Notice: s'==DevTools==dumpProperty() | control property: anchored.top.offset = ' | s'17'
Runtime Notice: s'==DevTools==dumpProperty() | control property: anchored.top.parent = ' | s'columnanchor'
Runtime Notice: s'==DevTools==dumpProperty() | control property: anchored.top.relation = ' | s'relative'


I'll keep a subscription to this thread and polish things up as need be. Thanks for comments, criticisms, and hopefully additional content!

Minty23185Fresh
April 2nd, 2018, 19:08
Installation:
As with all extensions download it and drop it in your project's extensions folder. See this thread (https://www.fantasygrounds.com/wiki/index.php/Data_Files_Overview#Extensions) for more details.

Optionally, I'd suggest unzipping the extension into "code". Change the file type from .ext to .zip. Navigate into the .zip folder, copy the contents and navigate back out. Create a _DevTools subfolder in the extensions folder and paste the copied files into it. Then move the zip file into the _DevTools subfolder (this prevent havings two DevTools options in the FG Load Campaign screen).

The three manager files, that do the work of DevTools are:
1) manager_slash.lua: the slash handler (see below)
2) manager_tools.lua: the file that does the heavy lifting. All the tools are here.
3) manager_controls.lua: I envisioned the dumpControlProperties() tool to require much more code than it currently has, so the tool in manager_tools.lua redirects to here.

For information on individual tools see the manager_tools.lua file.
Collapsing the file with your code editor to the first level helps eliminate details. You should see each tool (method definition) preceded by a usage preamble. The collapsed preamble gives a little bit of information about the intent of the tool and arguments.
Two of the common arguments are:
1) the object being operated on, e.g. super, a window, a window control
2) an announcement: a string output at the beginning of the routine (I typically put the caller routine's name in here).


Use:
To access the tools simply ensure you included the DevTools as one of your employed extensions on the Load Campaign screen.
And then add a call from your code to the DevTools tool of choice:
Example of using dumpControlProperties() from the XML definition of a generic control:


<genericcontrol name="itemanchor">
<anchored width="0" height=0">
<top parent="columnanchor" anchor="bottom" relation="relative" offset="7" />
<left anchor="center" offset="-130" />
</anchored>
<icon>dot_blue</icon>
<disabled />
<script>
function onInit()
DevTools.dumpControlProperties(self, "My Code", "genericcontrol", true);
end
</script>
</genericcontrol>

I added the code highlighted in red. Note the syntax of the tool call.


Slash Handler:
When your project is running, you can direct output to Debug.chat or Debug.console (or any combination).

Entering /dt (or /devtools) in the chat input box provides a help list.
Typing /dt followed by an option direct DevTools output to that destination.
The options are: toNone, toChat, toConsole, toAll
So entering: /dt tonone turns off output.

The default is to have output toAll. You can change the default by editing the onInit() in the manager_tools.lua file.
Note: the slash handler command is not persistent. So if you want a permanent change, edit the onInit().


Specific tool information (As of April 2, 2018, v0.1.0):

dumpControlProperties():
This wasn't available until I decided to release DevTools. I wanted the tool, but just never got around to implementing it. I wrote and included the tools specifically for the published tool box so it hasn't been put through rigorous testing. One thing of note, and it is important! XML attributes are not exposed for dumping. The elements are, but not the attributes. In the example code above, the anchored height and width are attributes, the <icon> is an element. I plan on addressing this in another thread which I'll provide the link to. The only controls current enumerated are: genericcontrol, buttoncontrol, numbercontrol, stringcontrol, and windowcontrol.

Minty23185Fresh
April 2nd, 2018, 19:18
reserved for revision info

Bidmaron
April 3rd, 2018, 19:17
Man Minty this is awesome. Can’t wait to get back to Generators and put this to use. Now if I can just dig out of the hole my day job has me in....

Minty23185Fresh
April 4th, 2018, 05:43
Man Minty this is awesome...
Thank you, I hope it proves useful.

Minty23185Fresh
April 4th, 2018, 05:45
Now if I can just dig out of the hole my day job has me in....
I wish there was something in the toolkit for that. Maybe a ladder? A rope?

Minty23185Fresh
March 23rd, 2019, 16:17
Announcing a revision to my Developers Toolbox extension.

As I was working toward a viable ad-hoc, developer instantiated, dragdata (https://www.fantasygrounds.com/forums/showthread.php?48594-On-Demand-(pseudo)-dragdata-Object) object ("class"), I found the dragdata handling in the toolbox completely inadequate. I've updated the toolbox to output all property values of dragdata.

(The dump function for dragdata does not enforce type( ) checking so it also dumps the property values for my (pseudo) dragdata object.)

I'll publish the revised extension in post #1 of this thread.

Three of Swords
March 24th, 2019, 16:57
I keep telling myself I should roll up my sleeves and start learning how to modify extensions so they act how I want. If I ever do, this will prob be very useful. Thanks!

Johnny Opie
March 25th, 2019, 15:43
Thanks for the jump start on debugging Minty!