mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-23 05:58:26 +02:00
maybe smoother mobile scroll on installed mods
This commit is contained in:
@@ -2142,16 +2142,20 @@ local function buildModsPanel(imp, x, y, w, availH, m)
|
|||||||
+ math.floor(8 * m.s)
|
+ math.floor(8 * m.s)
|
||||||
local listTop = cy
|
local listTop = cy
|
||||||
|
|
||||||
-- One continuous list: every row is laid out, the region scroll moves
|
-- One continuous list: derive the rows that can touch the viewport before
|
||||||
-- through all of it, and only rows inside the region's viewport draw --
|
-- entering the loop. Drawing was already culled, but scanning every
|
||||||
-- so the per-frame cost stays bounded by the window, not the list.
|
-- installed row to discover that defeats the point on a large mod library.
|
||||||
local view = imp._tabRegionRect
|
local view = imp._tabRegionRect
|
||||||
local viewTop = view and view.y or listTop
|
local viewTop = view and view.y or listTop
|
||||||
local viewBot = view and (view.y + view.h) or (listTop + availH)
|
local viewBot = view and (view.y + view.h) or (listTop + availH)
|
||||||
for i = 1, #mods do
|
local stride = rowH + gap
|
||||||
|
local first = math.max(1,
|
||||||
|
math.ceil((viewTop - rowH - listTop) / stride) + 1)
|
||||||
|
local last = math.min(#mods,
|
||||||
|
math.floor((viewBot - listTop) / stride) + 1)
|
||||||
|
for i = first, last do
|
||||||
local mod = mods[i]
|
local mod = mods[i]
|
||||||
local ry = listTop + (i - 1) * (rowH + gap)
|
local ry = listTop + (i - 1) * (rowH + gap)
|
||||||
if ry + rowH >= viewTop and ry <= viewBot then
|
|
||||||
local rowKey = rowKeyFor(imp, "mod-row-", mod.id)
|
local rowKey = rowKeyFor(imp, "mod-row-", mod.id)
|
||||||
local isFullyDisabled = true
|
local isFullyDisabled = true
|
||||||
if mod.enabledByVersion then
|
if mod.enabledByVersion then
|
||||||
@@ -2261,7 +2265,6 @@ local function buildModsPanel(imp, x, y, w, availH, m)
|
|||||||
px, ly, PAL.detail)
|
px, ly, PAL.detail)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local contentH = #mods * rowH + (#mods - 1) * gap
|
local contentH = #mods * rowH + (#mods - 1) * gap
|
||||||
return (listTop + contentH + gap) - y
|
return (listTop + contentH + gap) - y
|
||||||
|
|||||||
@@ -4154,7 +4154,6 @@ function RomImporter:_refreshMods()
|
|||||||
end
|
end
|
||||||
self.mods = kept
|
self.mods = kept
|
||||||
end
|
end
|
||||||
self:_syncModUpdateInfo(false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Point the MODS panel at one game (or nil for all of them) and relist, so
|
-- Point the MODS panel at one game (or nil for all of them) and relist, so
|
||||||
@@ -4168,15 +4167,12 @@ function RomImporter:_ensureMods()
|
|||||||
if not self.mods then self:_refreshMods() end
|
if not self.mods then self:_refreshMods() end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Resolve cached (or freshly fetched) GitHub status for every mod that
|
-- Resolve GitHub status for every installed mod that declares a github field.
|
||||||
-- declares a github field. force=true bypasses the 6h cache on every repo.
|
-- This is deliberately opt-in: only the explicit "Check for updates" action
|
||||||
-- Results live on self.modUpdateInfo[id] = { status, latest, best, releases }.
|
-- calls it. Opening, scrolling, toggling, or relisting the MODS tab must not
|
||||||
-- ASYNC (was synchronous). This runs on every _refreshMods -- boot, and any
|
-- create a burst of release work behind the list. force=true bypasses the 6h
|
||||||
-- toggle or install -- and used to make one blocking curl call per mod with a
|
-- cache on every repo. Results live on self.modUpdateInfo[id] = {
|
||||||
-- github field, in a loop, on the render thread. A handful of mods was a
|
-- status, latest, best, releases } and resolve asynchronously across frames.
|
||||||
-- multi-second freeze of the whole launcher. Now each mod gets a handle and
|
|
||||||
-- they resolve together across later frames; a mod whose cache is still fresh
|
|
||||||
-- resolves on the first pump with no network at all.
|
|
||||||
function RomImporter:_syncModUpdateInfo(force)
|
function RomImporter:_syncModUpdateInfo(force)
|
||||||
local ModUpdate = require("src.mods.ModUpdate")
|
local ModUpdate = require("src.mods.ModUpdate")
|
||||||
self.modUpdateInfo = self.modUpdateInfo or {}
|
self.modUpdateInfo = self.modUpdateInfo or {}
|
||||||
|
|||||||
@@ -388,6 +388,35 @@ mdown = false
|
|||||||
LauncherView.update(gameImp, 0.016)
|
LauncherView.update(gameImp, 0.016)
|
||||||
love.mouse.isDown = nil
|
love.mouse.isDown = nil
|
||||||
|
|
||||||
|
-- Opening or relisting MODS is display work only. Release checks are an
|
||||||
|
-- explicit action, otherwise each installed GitHub mod creates background
|
||||||
|
-- work exactly when the player starts scrolling the panel.
|
||||||
|
do
|
||||||
|
local savedMods = package.loaded["src.mods.LauncherMods"]
|
||||||
|
local savedSaveData = package.loaded["src.core.SaveData"]
|
||||||
|
local listCalls, updateCalls = 0, 0
|
||||||
|
package.loaded["src.mods.LauncherMods"] = {
|
||||||
|
list = function()
|
||||||
|
listCalls = listCalls + 1
|
||||||
|
return { { id = "test", github = "owner/repo" } }
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
package.loaded["src.core.SaveData"] = {
|
||||||
|
loadOptions = function() return {} end,
|
||||||
|
isSafeMode = function() return false end,
|
||||||
|
}
|
||||||
|
local refreshImp = setmetatable({
|
||||||
|
modStraysChecked = true,
|
||||||
|
_syncModUpdateInfo = function() updateCalls = updateCalls + 1 end,
|
||||||
|
}, RomImporter)
|
||||||
|
refreshImp:_refreshMods()
|
||||||
|
eq(listCalls, 1, "relisting MODS still obtains its installed rows")
|
||||||
|
eq(updateCalls, 0,
|
||||||
|
"relisting MODS does not start release checks without the explicit button")
|
||||||
|
package.loaded["src.mods.LauncherMods"] = savedMods
|
||||||
|
package.loaded["src.core.SaveData"] = savedSaveData
|
||||||
|
end
|
||||||
|
|
||||||
local function read(path)
|
local function read(path)
|
||||||
local f = assert(io.open(path, "r"))
|
local f = assert(io.open(path, "r"))
|
||||||
local src = f:read("*a")
|
local src = f:read("*a")
|
||||||
|
|||||||
Reference in New Issue
Block a user