mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-15 07:41:21 +02:00
feat(mods): expose opt-in final-frame output hooks
This commit is contained in:
@@ -434,7 +434,8 @@ local GEN2_HOOKS = {
|
||||
-- pointer with the touch overlay given first refusal, the palette zone list
|
||||
-- handed to the present pass, the letterbox and the HUD rect.
|
||||
"input.step", "input.pointer",
|
||||
"render.zones", "render.compose", "render.letterbox", "render.hud",
|
||||
"render.zones", "render.compose", "render.output_enabled", "render.output",
|
||||
"render.letterbox", "render.hud",
|
||||
}
|
||||
|
||||
local function assertShared(name, sites, kind)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
local Game2 = require("src.core.Game2")
|
||||
local Runtime = require("src.mods.Runtime")
|
||||
local Hooks = require("src.mods.Hooks")
|
||||
|
||||
local savedHooks = Runtime.hooks
|
||||
local hooks = Hooks.new()
|
||||
Runtime.hooks = hooks
|
||||
|
||||
local received
|
||||
hooks:wrap("render.output", function(_, context)
|
||||
received = context
|
||||
return true
|
||||
end, 0, "test")
|
||||
hooks:wrap("render.output_enabled", function() return false end, 0, "test")
|
||||
|
||||
local canvas = love.graphics.newCanvas(640, 480)
|
||||
local presentCalls = 0
|
||||
local game = setmetatable({
|
||||
frameFit = function() return 3, 80, 24, 1, 480, 432 end,
|
||||
presentCanvas = function() presentCalls = presentCalls + 1 return canvas end,
|
||||
drawScene = function() end,
|
||||
drawHud = function() end,
|
||||
}, Game2)
|
||||
|
||||
Game2.draw(game)
|
||||
T.eq(received, nil, "a disabled Gold output hook does not run")
|
||||
T.eq(presentCalls, 0, "a disabled Gold output hook keeps the direct path")
|
||||
|
||||
hooks:wrap("render.output_enabled", function() return true end, 10, "test")
|
||||
Game2.draw(game)
|
||||
T.check(received ~= nil, "Gold raises render.output for an enabled subscriber")
|
||||
T.eq(received and received.canvas, canvas,
|
||||
"Gold hands render.output the finished present canvas")
|
||||
T.eq(received and received.generation, 2,
|
||||
"Gold identifies the output context without changing Gen 1")
|
||||
T.eq(received and received.gameX, 80, "Gold output carries the fitted game X")
|
||||
T.eq(received and received.gameY, 24, "Gold output carries the fitted game Y")
|
||||
T.eq(received and received.gameWidth, 480,
|
||||
"Gold output carries the fitted game width")
|
||||
T.eq(received and received.gameHeight, 432,
|
||||
"Gold output carries the fitted game height")
|
||||
|
||||
Runtime.hooks = savedHooks
|
||||
T.finish("gen2 render output seam")
|
||||
Reference in New Issue
Block a user