Add Sta (static) preview mode: shows raw sprite canvas
- Preview mode now cycles All → One → Sta - Sta mode renders the full sprite without animations, with its own zoom - Fit button disabled in Sta mode - Mode toggle no longer closes/reopens window (preserves position)
This commit is contained in:
parent
68557e2a21
commit
00511eb8c1
|
|
@ -47,6 +47,7 @@ local S = {
|
|||
animSpeed = DEFAULT_ANIM_SPEED,
|
||||
previewZoomAll = DEFAULT_PREVIEW_ZOOM,
|
||||
previewZoomOne = DEFAULT_PREVIEW_ZOOM,
|
||||
previewZoomSta = DEFAULT_PREVIEW_ZOOM,
|
||||
sourceZoom = DEFAULT_SOURCE_ZOOM,
|
||||
animFrame = 0,
|
||||
currentAnim = 1, -- index into animNames
|
||||
|
|
@ -115,7 +116,7 @@ local S = {
|
|||
-- Preview layout configuration
|
||||
previewLayout = "auto", -- "auto", "fixedCols", "fixedRows"
|
||||
previewLayoutValue = 2, -- number for fixed cols/rows
|
||||
previewMode = "all", -- "all" or "single"
|
||||
previewMode = "all", -- "all", "single", or "static"
|
||||
previewSingleIdx = 1, -- which animation to show in single mode
|
||||
-- Current preset
|
||||
currentPreset = "Default",
|
||||
|
|
@ -412,6 +413,7 @@ local function saveMaster()
|
|||
f:write("previewMode=" .. S.previewMode .. "\n")
|
||||
f:write("previewZoomAll=" .. S.previewZoomAll .. "\n")
|
||||
f:write("previewZoomOne=" .. S.previewZoomOne .. "\n")
|
||||
f:write("previewZoomSta=" .. S.previewZoomSta .. "\n")
|
||||
f:write("previewSingleIdx=" .. S.previewSingleIdx .. "\n")
|
||||
-- File associations
|
||||
for filepath, preset in pairs(filePresetMap) do
|
||||
|
|
@ -439,6 +441,7 @@ local function loadMaster()
|
|||
if k == "previewMode" then S.previewMode = v end
|
||||
if k == "previewZoomAll" then S.previewZoomAll = tonumber(v) or DEFAULT_PREVIEW_ZOOM end
|
||||
if k == "previewZoomOne" then S.previewZoomOne = tonumber(v) or DEFAULT_PREVIEW_ZOOM end
|
||||
if k == "previewZoomSta" then S.previewZoomSta = tonumber(v) or DEFAULT_PREVIEW_ZOOM end
|
||||
if k == "previewSingleIdx" then S.previewSingleIdx = tonumber(v) or 1 end
|
||||
if k == "presetNames" and v ~= "" then
|
||||
knownPresetNames = {}
|
||||
|
|
@ -750,6 +753,7 @@ end
|
|||
-- Get current preview zoom based on mode
|
||||
local function pvZoom()
|
||||
if S.previewMode == "single" then return S.previewZoomOne end
|
||||
if S.previewMode == "static" then return S.previewZoomSta end
|
||||
return S.previewZoomAll
|
||||
end
|
||||
|
||||
|
|
@ -1303,6 +1307,13 @@ openPreviewWindow = function()
|
|||
-- calcPreviewSize helper
|
||||
local function calcPreviewSize()
|
||||
local z = pvZoom()
|
||||
if S.previewMode == "static" then
|
||||
-- Static mode: show full sprite canvas
|
||||
if app.sprite then
|
||||
return app.sprite.width * z, app.sprite.height * z
|
||||
end
|
||||
return 120, 40
|
||||
end
|
||||
local ptw = S.tileW * z
|
||||
local pth = S.tileH * z
|
||||
local cellW = ptw + PV_MARGIN * 2
|
||||
|
|
@ -1345,9 +1356,15 @@ openPreviewWindow = function()
|
|||
end
|
||||
}
|
||||
|
||||
local function getModeLabel()
|
||||
if S.previewMode == "single" then return "One"
|
||||
elseif S.previewMode == "static" then return "Sta"
|
||||
else return "All" end
|
||||
end
|
||||
|
||||
previewDlg:button{
|
||||
id = "pvToggleMode",
|
||||
text = S.previewMode == "all" and "All" or "One",
|
||||
text = getModeLabel(),
|
||||
onclick = function()
|
||||
if S.previewMode == "all" then
|
||||
S.previewMode = "single"
|
||||
|
|
@ -1355,19 +1372,27 @@ openPreviewWindow = function()
|
|||
if S.previewSingleIdx < 1 then S.previewSingleIdx = 1 end
|
||||
if S.previewSingleIdx > #S.animNames then S.previewSingleIdx = #S.animNames end
|
||||
end
|
||||
elseif S.previewMode == "single" then
|
||||
S.previewMode = "static"
|
||||
else
|
||||
S.previewMode = "all"
|
||||
end
|
||||
-- Close and reopen to resize canvas
|
||||
pcall(function() previewDlg:close() end)
|
||||
openPreviewWindow()
|
||||
-- Update button text, label visibility, and Fit enabled state
|
||||
pcall(function()
|
||||
previewDlg:modify{ id = "pvToggleMode", text = getModeLabel() }
|
||||
previewDlg:modify{ id = "pvAnimName", visible = (S.previewMode == "single") }
|
||||
previewDlg:modify{ id = "pvFit", enabled = (S.previewMode ~= "static") }
|
||||
end)
|
||||
previewDlg:repaint()
|
||||
end
|
||||
}
|
||||
|
||||
previewDlg:button{
|
||||
id = "pvFit",
|
||||
text = "Fit",
|
||||
enabled = (S.previewMode ~= "static"),
|
||||
onclick = function()
|
||||
if S.previewMode == "static" then return end
|
||||
-- Close and reopen to refit
|
||||
pcall(function() previewDlg:close() end)
|
||||
openPreviewWindow()
|
||||
|
|
@ -1381,6 +1406,26 @@ openPreviewWindow = function()
|
|||
autoscaling = false,
|
||||
onpaint = function(ev)
|
||||
local gc = ev.context
|
||||
|
||||
-- Static mode: render full sprite canvas
|
||||
if S.previewMode == "static" then
|
||||
if S.sourceImage then
|
||||
local z = pvZoom()
|
||||
local sw = S.sourceImage.width * z
|
||||
local sh = S.sourceImage.height * z
|
||||
if S.useBgColor then
|
||||
gc.color = S.bgColor
|
||||
gc:fillRect(Rectangle(0, 0, sw, sh))
|
||||
else
|
||||
drawCheckerboard(gc, sw, sh, z, 0, 0)
|
||||
end
|
||||
gc:drawImage(S.sourceImage,
|
||||
Rectangle(0, 0, S.sourceImage.width, S.sourceImage.height),
|
||||
Rectangle(0, 0, sw, sh))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local na = #S.animNames
|
||||
if na == 0 then return end
|
||||
|
||||
|
|
@ -1447,6 +1492,7 @@ openPreviewWindow = function()
|
|||
end
|
||||
end,
|
||||
onmousedown = function(ev)
|
||||
if S.previewMode == "static" then return end
|
||||
-- In single mode: L-click=prev anim, R-click=next anim
|
||||
if S.previewMode == "single" then
|
||||
if ev.button == MouseButton.LEFT then
|
||||
|
|
@ -1476,6 +1522,8 @@ openPreviewWindow = function()
|
|||
local dz = ev.deltaY < 0 and 1 or -1
|
||||
if S.previewMode == "single" then
|
||||
S.previewZoomOne = math.max(1, math.min(MAX_PREVIEW_ZOOM, S.previewZoomOne + dz))
|
||||
elseif S.previewMode == "static" then
|
||||
S.previewZoomSta = math.max(1, math.min(MAX_PREVIEW_ZOOM, S.previewZoomSta + dz))
|
||||
else
|
||||
S.previewZoomAll = math.max(1, math.min(MAX_PREVIEW_ZOOM, S.previewZoomAll + dz))
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue