Force refresh Analyze and repaint preview on file switch
- Analyze now always calls refreshSource() to avoid stale image from a previously-active sprite, plus detailed diagnostics if it fails. - pvRefreshTimer now refreshes source image and repaints preview on any file change (not only when preset differs).
This commit is contained in:
parent
3366db0ad9
commit
1919ad8822
|
|
@ -1616,6 +1616,8 @@ openPreviewWindow = function()
|
||||||
local currentFile = app.sprite and app.sprite.filename or ""
|
local currentFile = app.sprite and app.sprite.filename or ""
|
||||||
if currentFile ~= lastSpriteFilename then
|
if currentFile ~= lastSpriteFilename then
|
||||||
lastSpriteFilename = currentFile
|
lastSpriteFilename = currentFile
|
||||||
|
-- Always refresh source when switching files
|
||||||
|
refreshSource()
|
||||||
-- Look up preset for this file
|
-- Look up preset for this file
|
||||||
local presetForFile = filePresetMap[currentFile] or "Default"
|
local presetForFile = filePresetMap[currentFile] or "Default"
|
||||||
if presetForFile ~= S.currentPreset then
|
if presetForFile ~= S.currentPreset then
|
||||||
|
|
@ -1641,6 +1643,8 @@ openPreviewWindow = function()
|
||||||
openMainDialog()
|
openMainDialog()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Always repaint preview on file change (even if preset is same)
|
||||||
|
pcall(function() previewDlg:repaint() end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
@ -2656,13 +2660,25 @@ openMainDialog = function()
|
||||||
text = "Analyze",
|
text = "Analyze",
|
||||||
visible = false,
|
visible = false,
|
||||||
onclick = function()
|
onclick = function()
|
||||||
if not S.sourceImage then
|
-- Always refresh to avoid stale image from a different sprite
|
||||||
refreshSource()
|
refreshSource()
|
||||||
end
|
|
||||||
if not S.sourceImage then
|
if not S.sourceImage then
|
||||||
app.alert("No source image. Open a sprite first.")
|
app.alert("No source image. Open a sprite first.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
-- Diagnostics
|
||||||
|
local diag = "mode=" .. S.gbAnalyzeMode ..
|
||||||
|
" tileW=" .. S.gbTileW .. " tileH=" .. S.gbTileH ..
|
||||||
|
" imgW=" .. tostring(S.sourceImage.width) ..
|
||||||
|
" imgH=" .. tostring(S.sourceImage.height)
|
||||||
|
if S.sourceImage.width == 0 or S.sourceImage.height == 0 then
|
||||||
|
app.alert("Source image has zero size. " .. diag)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if S.gbTileW < 1 or S.gbTileH < 1 then
|
||||||
|
app.alert("Bad tile size. " .. diag)
|
||||||
|
return
|
||||||
|
end
|
||||||
local usedTileW = S.gbTileW
|
local usedTileW = S.gbTileW
|
||||||
local usedTileH = S.gbTileH
|
local usedTileH = S.gbTileH
|
||||||
if S.gbAnalyzeMode == "tile" then
|
if S.gbAnalyzeMode == "tile" then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue