Add debug callbacks - #54
Conversation
|
This is good. I'll have to run some tests before pulling, just to be sure there's no overhead, or it's worth it even if there is. It might be a bit before I do another sprint, though. Happy to hear from others if they want to take a crack at seeing how this runs/works on device. |
|
If there is overhead you could always check |
…stream PR NobleRobot#54, adapted) Scenes now get a drawDebug() callback, a debugColor property, and enableDebug()/disableDebug() methods. Debug drawing is enabled on scene enter and disabled on scene exit, and is guarded by playdate.isSimulator so there is no overhead on hardware, where playdate.debugDraw is not rendered anyway. Adapted from upstream PR NobleRobot#54 (fixes upstream issue NobleRobot#53) with corrections: debugColor defaults to a {r, g, b, a} table (the PR's Graphics.kColorWhite default crashed table.unpack), disableDebug() sets playdate.debugDraw to nil instead of an empty function so the runtime skips the call, and it no longer resets Noble.showFPS on scene exit. Co-authored-by: GammaGames <GammaGames@users.noreply.github.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Hand-patch the LDoc-generated HTML (as done in d781092 for NobleSprite.html) to cover changes the earlier commits missed: - Noble.html: add the missing sidebar index entry for Noble.performTransition (the body entry was added in 50be77b, but the function was undiscoverable from the nav). - Noble.GameData.html: add sidebar and body entries for resetFromDisk() and resetAllFromDisk() (added in 7aa010a, upstream PR NobleRobot#85). - Noble.Transition.html: replace the stale "panelImage property is locked" notes for DipToBlack/DipToWhite with tilePattern and point their See references at DipTile; add the new DipTile submodule and its defaultProperties table (47f83cf, upstream PR NobleRobot#92); document the per-invocation callback properties on the onStart/onMidpoint/ onHoldTimeElapsed/onComplete entries (50be77b). - NobleScene.html: add the debugColor property, enableDebug/ disableDebug methods, and drawDebug callback (b587cd8, upstream PR NobleRobot#54), plus the gameWillTerminate/deviceWillSleep/deviceWillLock/ deviceDidUnlock callbacks (b034f38, upstream issue NobleRobot#55). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…stream PR NobleRobot#54, adapted) Scenes now get a drawDebug() callback, a debugColor property, and enableDebug()/disableDebug() methods. Debug drawing is enabled on scene enter and disabled on scene exit, and is guarded by playdate.isSimulator so there is no overhead on hardware, where playdate.debugDraw is not rendered anyway. Adapted from upstream PR NobleRobot#54 (fixes upstream issue NobleRobot#53) with corrections: debugColor defaults to a {r, g, b, a} table (the PR's Graphics.kColorWhite default crashed table.unpack), disableDebug() sets playdate.debugDraw to nil instead of an empty function so the runtime skips the call, and it no longer resets Noble.showFPS on scene exit. Co-authored-by: GammaGames <GammaGames@users.noreply.github.com>
Hand-patch the LDoc-generated HTML (as done in d781092 for NobleSprite.html) to cover changes the earlier commits missed: - Noble.html: add the missing sidebar index entry for Noble.performTransition (the body entry was added in 50be77b, but the function was undiscoverable from the nav). - Noble.GameData.html: add sidebar and body entries for resetFromDisk() and resetAllFromDisk() (added in 7aa010a, upstream PR NobleRobot#85). - Noble.Transition.html: replace the stale "panelImage property is locked" notes for DipToBlack/DipToWhite with tilePattern and point their See references at DipTile; add the new DipTile submodule and its defaultProperties table (47f83cf, upstream PR NobleRobot#92); document the per-invocation callback properties on the onStart/onMidpoint/ onHoldTimeElapsed/onComplete entries (50be77b). - NobleScene.html: add the debugColor property, enableDebug/ disableDebug methods, and drawDebug callback (b587cd8, upstream PR NobleRobot#54), plus the gameWillTerminate/deviceWillSleep/deviceWillLock/ deviceDidUnlock callbacks (b034f38, upstream issue NobleRobot#55).
|
I integrated this into my local tree (it's a great feature — fixes #53) and hit a couple of issues worth flagging:
FWIW, here's the shape I ended up with locally: NobleScene.debugColor = {1, 0, 0, 1}
function NobleScene:enableDebug()
if (playdate.isSimulator) then
playdate.setDebugDrawColor(table.unpack(self.debugColor))
playdate.debugDraw = function()
self:drawDebug()
end
end
end
function NobleScene:disableDebug()
playdate.debugDraw = nil
endwith |
Fixes #53
Is
playdate.debugDrawcalled on hardware? I don't have a devices so I can't test