瀏覽代碼

Documented debug module. Let's say this part is more or less done for now.

Eiyeron Fulmincendii 8 年之前
父節點
當前提交
0885f395e6

+ 8 - 0
debug_overlay/console/commands.lua

@@ -1,3 +1,11 @@
+--[[
+    Debug console built-in commands
+    @author : Eiyeron Fulmincendii
+
+    cls : clears the console log
+    help (aliases : ls) : displays the list of registered commands and display their help.
+]]--
+
 Commands = {
     cls = {
         fun = function(console)

+ 15 - 0
debug_overlay/console/init.lua

@@ -1,3 +1,18 @@
+--[[
+    Debug console class
+    @author : Eiyeron Fulmincendii
+
+    A Quake-like console to display a log and input some registerable commands.
+
+    Note that the log can be filtered by verbosity, from INFO to ERROR.
+
+    To register a command, call register command
+        debug_overlay.console:registerCommand("my function", function(<arguments>) end, "This command does ...")
+    The help string is optional but is useful for the help/ls command.
+
+    A few commands are already built-in, please check commands.lua to see them.
+]]--
+
 require("imgui")
 local class =  require("class")
 local DebugWindow = require("debug_overlay.debugwindow")

+ 12 - 0
debug_overlay/debugwindow.lua

@@ -1,3 +1,15 @@
+--[[
+    Debug window base class
+    @author : Eiyeron Fulmincendii
+
+    A small class to make sure that a few variables exist.
+    To create a new debug window, create a class that derives from it and create a render() function
+    local MyDebugWindow = class(DebugWindow)
+    function MyDebugWindow:render()
+    end
+
+    It is very suggested to use imgui-love module as this module has been designed with it in mind.
+]]--
 local class, object =  require("class"), require("class.object")
 
 local DebugWindow = class(object)

+ 7 - 0
debug_overlay/graphs/init.lua

@@ -1,3 +1,10 @@
+--[[
+    Debug resource graph class
+    @author : Eiyeron Fulmincendii
+
+    A Flixel-like graph class to show some graphs related to CPU and Memory usage.
+]]--
+
 require("imgui")
 local class =  require("class")
 local DebugWindow = require("debug_overlay.debugwindow")

+ 43 - 1
debug_overlay/init.lua

@@ -1,4 +1,47 @@
+--[[
+    Debug Overlay module
+    @author : Eiyeron Fulmincendii
 
+    The debug overlay is targeting to be a relatively agnositc debug framework for Love2D based on love-imgui.
+    Requiring for now a custom class implementation and love-imgui.
+
+    It is very suggested to use imgui-love module as this module has been designed with it in mind.
+
+
+    Modulable, th overlay create a menubar on the top of the game screen containing the different debug menus registered to
+    the system. One being already registered containing
+        - FPS and CPU/MEM usage graphs
+        - an interactive console à-la Quake
+        - a variable watch.
+
+    Usage
+    -----
+
+    Create an instance like this:
+        debug_overlay = require("debug_overlay"):new()
+
+    In love.draw, before imgui.Render(), call your instance's render function:
+        function love.draw()
+            <snip>
+            debug_overlay:render()
+            imgui.Render();
+        end
+
+    To register a new window, create a class derived from DebugWindow (check debugwindow.lua and debug_overlay/graphs/init.lua for an example)
+        local MyDebugWindow = class(DebugWindow)
+    Note : to add a shortcut to the window in the menubar, add this line in your window's init function:
+    function MyDebugWindow:init()
+        <snip>
+        self.shortcut = "f4"
+        <snip>
+    end
+
+    And to register your debug windows in a menu:
+        debug_overlay:register_menu("Menu button name", {WindowName=MyDebugWindow_Instance})
+    (I use somemthing like this : )
+        debug_overlay:register_menu("Menu button name", require("mydebugwindow"):new())
+
+]]--
 -- If not debug then returning a blank class.
 if not _G.ENABLE_DEBUG_OVERLAY then
     local void = {}
@@ -9,7 +52,6 @@ if not _G.ENABLE_DEBUG_OVERLAY then
         __call = function() return void end
         }
     setmetatable(void, mt)
-    print(void)
     return void
 end
 

+ 11 - 0
debug_overlay/watch/init.lua

@@ -1,3 +1,14 @@
+--[[
+    Debug variable watch class
+    @author : Eiyeron Fulmincendii
+
+    A Flixel-like watch class to be able to track down variables and check them in real time.
+    Add a variable to watch over like this:
+        debug_overlay.watch:add(my_object, "name of object member")
+
+    Note that if the member is destroyed or unreadable, the variable will be automatically removed.
+]]--
+
 local class =  require("class")
 local DebugWindow = require("debug_overlay.debugwindow")