Fix Sta mode: no auto-size window, lazy refresh on sprite change only
- calcPreviewSize ignores Sta mode, uses All sizing (no giant window) - Refresh timer in Sta only calls refreshSource when sprite version or frame changes, not every 0.5s - Initial refreshSource on entering Sta mode
This commit is contained in:
parent
b2a333405a
commit
ca3f760d87
|
|
@ -1314,15 +1314,14 @@ openPreviewWindow = function()
|
||||||
S.previewSingleIdx = 1
|
S.previewSingleIdx = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- calcPreviewSize helper
|
-- calcPreviewSize helper (Sta mode excluded — uses last All/One size)
|
||||||
local function calcPreviewSize()
|
local function calcPreviewSize()
|
||||||
local z = pvZoom()
|
local z
|
||||||
if S.previewMode == "static" then
|
if S.previewMode == "static" then
|
||||||
-- Static mode: show full sprite canvas
|
-- Don't try to auto-size for Sta; fall through to All sizing
|
||||||
if app.sprite then
|
z = S.previewZoomAll
|
||||||
return app.sprite.width * z, app.sprite.height * z
|
else
|
||||||
end
|
z = pvZoom()
|
||||||
return 120, 40
|
|
||||||
end
|
end
|
||||||
local ptw = S.tileW * z
|
local ptw = S.tileW * z
|
||||||
local pth = S.tileH * z
|
local pth = S.tileH * z
|
||||||
|
|
@ -1384,6 +1383,7 @@ openPreviewWindow = function()
|
||||||
end
|
end
|
||||||
elseif S.previewMode == "single" then
|
elseif S.previewMode == "single" then
|
||||||
S.previewMode = "static"
|
S.previewMode = "static"
|
||||||
|
refreshSource() -- ensure source image is ready
|
||||||
else
|
else
|
||||||
S.previewMode = "all"
|
S.previewMode = "all"
|
||||||
end
|
end
|
||||||
|
|
@ -1586,18 +1586,25 @@ openPreviewWindow = function()
|
||||||
}
|
}
|
||||||
previewTimer:start()
|
previewTimer:start()
|
||||||
|
|
||||||
|
local pvStaLastVersion = 0 -- track sprite version to detect edits
|
||||||
|
local pvStaLastFrame = 0
|
||||||
|
|
||||||
pvRefreshTimer = Timer{
|
pvRefreshTimer = Timer{
|
||||||
interval = 0.5,
|
interval = 0.5,
|
||||||
ontick = function()
|
ontick = function()
|
||||||
local prevImg = S.sourceImage
|
|
||||||
refreshSource()
|
|
||||||
refreshLockFile()
|
refreshLockFile()
|
||||||
-- In static mode, only repaint if source image changed
|
|
||||||
if S.previewMode == "static" then
|
if S.previewMode == "static" then
|
||||||
if S.sourceImage ~= prevImg then
|
-- Only refresh source and repaint when sprite actually changed
|
||||||
|
local curVer = app.sprite and app.sprite.version or 0
|
||||||
|
local curFrame = app.frame and app.frame.frameNumber or 0
|
||||||
|
if curVer ~= pvStaLastVersion or curFrame ~= pvStaLastFrame then
|
||||||
|
pvStaLastVersion = curVer
|
||||||
|
pvStaLastFrame = curFrame
|
||||||
|
refreshSource()
|
||||||
pcall(function() previewDlg:repaint() end)
|
pcall(function() previewDlg:repaint() end)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
refreshSource()
|
||||||
pcall(function() previewDlg:repaint() end)
|
pcall(function() previewDlg:repaint() end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue