I wrote this years ago to help me debugging IceUI. Now I decided to share it with all my fellow widget developers.
It registers a global WG.Inspect(table) function that will render the given table as shown in this screenshot:
You can click on nearly all values to do stuff. Subtables will be inspected using the same method, functions will be called (no parameters possible atm though; it then shows if the call was successful and a table with the return values or the error message), bools will be toggled, strings and numbers will be opened in a little popup to show the actual number (not rounded to three digits) or in case the text is to long to be readable in the inspector.
You can scroll using the "Scroll up" and "Scroll down" buttons or simply by using the mouse wheel.
The back button is just like in a browser. It takes you to the previous view.
All the other buttons are shortcuts to tables. WM is IceUIs window manager, the profile buttons are for profiling IceUI code (needs to be enabled first). The only button useful for you is probably "Widgets" which shows all activated widgets (inspectable).
It's also nice to inspect UnitDefs or the Spring table to have a list of all callouts.
If you don't have IceUI, just download the attached archive and extract it into your widgets directory. Then use WG.Inspect(table) in your widget.
If you already have IceUI, enable debugMode.debugMode in gui_IceUI.lua line 47, press F11 ingame and select "Inspector" under "IceUI Windows". If you can see the window onscreen, you can start calling WG.Inspect(table) in your own widget.
It will also recheck the table every few seconds for any changes and will update the view.
Please let me know if you were able to use this and if you have any suggestions.
Table Inspector
Moderator: Moderators
Table Inspector
- Attachments
-
- IceUI r83 (Inspector only).7z
- (599.7 KiB) Downloaded 19 times
Last edited by MelTraX on 30 Aug 2009, 11:13, edited 1 time in total.
Re: Table Inspector
Make it standalone? Nice idea though, if I'm understanding what it is. Diagnostic widgets like this and Profiler are a long time coming.
Re: Table Inspector
I wrote a GUI framework for a reason, you know? Just delete all lua files in Widgets/IceUI/ (not its subdirs) except inspector.lua if you want it stand-alone.
edit: I attached an inspector only version of IceUI to the first post. Everything is set up and it doesn't touch the rest of your GUI.
edit: I attached an inspector only version of IceUI to the first post. Everything is set up and it doesn't touch the rest of your GUI.
Re: Table Inspector
Just for fun I wrote this little widget that puts all the parameters given to callins into an inspectable table.
Enable this widget when the IceUI Inspector is running and you'll get a list of all callouts and a list of all callins called since the widget was activated with the parameters to the latest call, the number of calls so far and the game frame of the latest call.
Actually thank mongus for asking me about KeyPress(). :D
Enable this widget when the IceUI Inspector is running and you'll get a list of all callouts and a list of all callins called since the widget was activated with the parameters to the latest call, the number of calls so far and the game frame of the latest call.
Code: Select all
function widget:GetInfo()
return {
name = "Call-In/Out Inspector",
desc = "Inspects parameters to all call-ins and lists all call-outs.",
author = "MelTraX",
date = "2009-09-01",
license = "GNU GPL, v2 or later",
layer = 10,
enabled = true, -- loaded by default?
handler = true
}
end
local functions = {}
function widget:Initialize()
functions['Call-Ins'] = {}
functions['Call-Outs'] = {}
for i,v in pairs(Spring) do
if type(v) == 'function' then
functions['Call-Outs'][i] = v
end
end
for i,v in pairs(widgetHandler) do
if string.sub(i, -4, -1) == "List" and type(v) == "table" and i ~= "orderList" then
local callin = string.sub(i, 0, -5)
if type(widget[callin]) ~= 'function' then
widget[callin] = function(self, ...)
if type(functions['Call-Ins'][callin]) == 'nil' then
functions['Call-Ins'][callin] = { calls=0 }
end
for k,v in ipairs({...}) do
functions['Call-Ins'][callin][k] = v
end
functions['Call-Ins'][callin].calls = functions['Call-Ins'][callin].calls + 1
functions['Call-Ins'][callin].frame = Spring.GetGameFrame()
end
widgetHandler:UpdateWidgetCallIn(callin, widget)
end
end
end
WG.Inspect(functions)
end