Playing with extended widescreen support again. I was able to get the lungfish POV looking better with the widescreen patch. I don't know if I like this solution as it's quite nasty but it does prove it works at least. This'd also be the first proper Lua-side hook in Astralathe.
To make this possible I install a hook onto the game's "AddSpriteHandle" function that allows an extra parameter specifying if the graphic is meant to be fullscreen and doing some special processing that ignores the X, Y and scale params and just forces it fullscreen.
The hook is also hardcoded so that it recognises images from the base game that must be fullscreen (just this one right now) and forces the fullscreen flag on them. This is not pretty but it does mean I don't have to touch or ship the original code file.
When widescreen fixes are disabled Astralathe just installs a dummy hook that still takes the extra param but doesn't do anything with it to ensure compatibility (I don't know if this is necessary though)
There's a lot of reasons the code isn't pretty aside the hardcoded hack but the principle is there. Unfortunately it also means I'm doing this awful crap:
function HookedAddSpriteHandle(tex, x, y, a, xs, ys, rot, show, uvx, uvy, r, g, b, bFullscreen)
-- ...
if not a then
return _AddSpriteHandle(tex, x, y)
elseif not xs then
return _AddSpriteHandle(tex, x, y, a)
elseif not ys then
return _AddSpriteHandle(tex, x, y, a, xs)
elseif not rot then
return _AddSpriteHandle(tex, x, y, a, xs, ys)
elseif not show then
return _AddSpriteHandle(tex, x, y, a, xs, ys, rot)
elseif not uvx then
return _AddSpriteHandle(tex, x, y, a, xs, ys, rot, show)
elseif not uvy then
return _AddSpriteHandle(tex, x, y, a, xs, ys, rot, show, uvx)
elseif not r then
return _AddSpriteHandle(tex, x, y, a, xs, ys, rot, show, uvx, uvy)
elseif not g then
return _AddSpriteHandle(tex, x, y, a, xs, ys, rot, show, uvx, uvy, r)
elseif not b then
return _AddSpriteHandle(tex, x, y, a, xs, ys, rot, show, uvx, uvy, r, g)
else
return _AddSpriteHandle(tex, x, y, a, xs, ys, rot, show, uvx, uvy, r, g, b)
end
endBecause the original C binding changes functionality depending on the number of arguments passed to it (actual arg count, so nil still counts) and if I'm wrapping around it and passing everything then things change and shit breaks. I don't know if there's a nicer way to go about this in Lua 4.0. Maybe if I just check each arg and set them to the default they're gonna be slammed to anyway but I dunno if that'd really be any better than this.