mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-21 05:00:43 +02:00
CLOSES #1603
This commit is contained in:
@@ -1260,6 +1260,7 @@ function Game:applyOptions(opts)
|
||||
-- after VideoMode: a faithful-resolution lock is an exact window size, so
|
||||
-- it has to be the last word on the window (it drops fullscreen to hold)
|
||||
require("src.core.FaithfulRes").applyOptions(opts)
|
||||
require("src.core.ScreenPosition").applyOptions(opts)
|
||||
-- normalizes a nil/garbage cap to the 60 default, so old saves with no
|
||||
-- fpsCap key pace at the standard rate (issue #88)
|
||||
require("src.core.FrameCap").applyOptions(opts)
|
||||
|
||||
+3
-1
@@ -1660,8 +1660,9 @@ function Game2:drawScene(w, h)
|
||||
-- row to opt into the step-down half, so CENTERED is the whole rule
|
||||
-- here.
|
||||
local s = self.world:fitScale()
|
||||
local ox, oy = Chrome.fitOrigin(w, h, s)
|
||||
G.push()
|
||||
G.translate(math.floor((w - 160 * s) / 2), math.floor((h - 144 * s) / 2))
|
||||
G.translate(ox, oy)
|
||||
G.scale(s, s)
|
||||
self.stack:draw()
|
||||
G.pop()
|
||||
@@ -1982,6 +1983,7 @@ function Game2:applyOptions()
|
||||
haptics = options.haptics,
|
||||
})
|
||||
require("src.core.VideoMode").applyOptions(options)
|
||||
require("src.core.ScreenPosition").applyOptions(options)
|
||||
require("src.core.FrameCap").applyOptions(options)
|
||||
require("src.world.gen2.BorderFill").applyOptions(options)
|
||||
local GBCFX = require("src.render.GBCFX")
|
||||
|
||||
@@ -285,6 +285,7 @@ function SaveData.defaultOptions()
|
||||
-- lock the window to an exact 160x144 multiple, 1..4 (0 = OFF); see
|
||||
-- src/core/FaithfulRes.lua. Ignored on mobile.
|
||||
faithfulRes = 0,
|
||||
screenPos = "center",
|
||||
-- hard render frame-rate cap; render-only pacing (issue #88, FrameCap.lua)
|
||||
fpsCap = 60,
|
||||
-- graphics performance tier: auto | high | balanced | low. "auto"
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
local ScreenPosition = {}
|
||||
|
||||
ScreenPosition.MODES = { "center", "upper", "top" }
|
||||
ScreenPosition.DEFAULT = "center"
|
||||
ScreenPosition.mode = ScreenPosition.DEFAULT
|
||||
|
||||
local LABELS = { center = "CENTER", upper = "UPPER", top = "TOP" }
|
||||
|
||||
function ScreenPosition.normalize(v)
|
||||
if LABELS[v] then return v end
|
||||
return ScreenPosition.DEFAULT
|
||||
end
|
||||
|
||||
function ScreenPosition.label(v)
|
||||
return LABELS[ScreenPosition.normalize(v)]
|
||||
end
|
||||
|
||||
function ScreenPosition.cycle(v, dir)
|
||||
v = ScreenPosition.normalize(v)
|
||||
local modes = ScreenPosition.MODES
|
||||
local cur = 1
|
||||
for i, mode in ipairs(modes) do
|
||||
if mode == v then cur = i break end
|
||||
end
|
||||
return modes[(cur - 1 + (dir or 1)) % #modes + 1]
|
||||
end
|
||||
|
||||
function ScreenPosition.setMode(v)
|
||||
ScreenPosition.mode = ScreenPosition.normalize(v)
|
||||
end
|
||||
|
||||
function ScreenPosition.applyOptions(opts)
|
||||
ScreenPosition.setMode(opts and opts.screenPos)
|
||||
end
|
||||
|
||||
function ScreenPosition.safeTop()
|
||||
local ok, SafeArea = pcall(require, "src.core.SafeArea")
|
||||
if not ok then return 0 end
|
||||
local okr, _, y = pcall(SafeArea.rect)
|
||||
if not okr then return 0 end
|
||||
return math.max(0, tonumber(y) or 0)
|
||||
end
|
||||
|
||||
function ScreenPosition.skinActive(w, h)
|
||||
local ok, TouchSkin = pcall(require, "src.core.TouchSkin")
|
||||
if not ok or type(TouchSkin.viewport) ~= "function" then return false end
|
||||
local okv, x = pcall(TouchSkin.viewport, w, h)
|
||||
return okv and x ~= nil
|
||||
end
|
||||
|
||||
function ScreenPosition.lift(viewH, contentH, safeTop)
|
||||
if ScreenPosition.mode == "center" then return 0 end
|
||||
viewH = tonumber(viewH) or 0
|
||||
contentH = tonumber(contentH) or 0
|
||||
local slack = viewH - contentH
|
||||
if slack <= 0 then return 0 end
|
||||
local centered = math.floor(slack / 2)
|
||||
local target = ScreenPosition.mode == "top" and 0 or math.floor(slack / 4)
|
||||
safeTop = math.floor(tonumber(safeTop) or 0)
|
||||
if safeTop > 0 and target < safeTop then
|
||||
target = math.min(safeTop, centered)
|
||||
end
|
||||
return centered - target
|
||||
end
|
||||
|
||||
return ScreenPosition
|
||||
@@ -288,6 +288,7 @@ Save.DEFAULT_OPTIONS = {
|
||||
musicFilter = 0, -- low-pass steps, 0 = off
|
||||
haptics = "light",
|
||||
touchControls = { enabled = true },
|
||||
screenPos = "center",
|
||||
}
|
||||
|
||||
function Save.defaultOptions()
|
||||
@@ -308,7 +309,7 @@ end
|
||||
Save.OPTIONS_KEY = "gold"
|
||||
|
||||
local SHARED_KEYS = {
|
||||
touchControls = true, haptics = true,
|
||||
touchControls = true, haptics = true, screenPos = true,
|
||||
mods = true, modsByVersion = true, modsGen2 = true,
|
||||
modOptions = true, modProfiles = true, modProfilesSeeded = true,
|
||||
activeProfile = true,
|
||||
|
||||
Reference in New Issue
Block a user