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,
|
animSpeed = DEFAULT_ANIM_SPEED,
|
||||||
previewZoomAll = DEFAULT_PREVIEW_ZOOM,
|
previewZoomAll = DEFAULT_PREVIEW_ZOOM,
|
||||||
previewZoomOne = DEFAULT_PREVIEW_ZOOM,
|
previewZoomOne = DEFAULT_PREVIEW_ZOOM,
|
||||||
|
previewZoomSta = DEFAULT_PREVIEW_ZOOM,
|
||||||
sourceZoom = DEFAULT_SOURCE_ZOOM,
|
sourceZoom = DEFAULT_SOURCE_ZOOM,
|
||||||
animFrame = 0,
|
animFrame = 0,
|
||||||
currentAnim = 1, -- index into animNames
|
currentAnim = 1, -- index into animNames
|
||||||
|
|
@ -115,7 +116,7 @@ local S = {
|
||||||
-- Preview layout configuration
|
-- Preview layout configuration
|
||||||
previewLayout = "auto", -- "auto", "fixedCols", "fixedRows"
|
previewLayout = "auto", -- "auto", "fixedCols", "fixedRows"
|
||||||
previewLayoutValue = 2, -- number for fixed cols/rows
|
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
|
previewSingleIdx = 1, -- which animation to show in single mode
|
||||||
-- Current preset
|
-- Current preset
|
||||||
currentPreset = "Default",
|
currentPreset = "Default",
|
||||||
|
|
@ -412,6 +413,7 @@ local function saveMaster()
|
||||||
f:write("previewMode=" .. S.previewMode .. "\n")
|
f:write("previewMode=" .. S.previewMode .. "\n")
|
||||||
f:write("previewZoomAll=" .. S.previewZoomAll .. "\n")
|
f:write("previewZoomAll=" .. S.previewZoomAll .. "\n")
|
||||||
f:write("previewZoomOne=" .. S.previewZoomOne .. "\n")
|
f:write("previewZoomOne=" .. S.previewZoomOne .. "\n")
|
||||||
|
f:write("previewZoomSta=" .. S.previewZoomSta .. "\n")
|
||||||
f:write("previewSingleIdx=" .. S.previewSingleIdx .. "\n")
|
f:write("previewSingleIdx=" .. S.previewSingleIdx .. "\n")
|
||||||
-- File associations
|
-- File associations
|
||||||
for filepath, preset in pairs(filePresetMap) do
|
for filepath, preset in pairs(filePresetMap) do
|
||||||
|
|
@ -439,6 +441,7 @@ local function loadMaster()
|
||||||
if k == "previewMode" then S.previewMode = v end
|
if k == "previewMode" then S.previewMode = v end
|
||||||
if k == "previewZoomAll" then S.previewZoomAll = tonumber(v) or DEFAULT_PREVIEW_ZOOM 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 == "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 == "previewSingleIdx" then S.previewSingleIdx = tonumber(v) or 1 end
|
||||||
if k == "presetNames" and v ~= "" then
|
if k == "presetNames" and v ~= "" then
|
||||||
knownPresetNames = {}
|
knownPresetNames = {}
|
||||||
|
|
@ -750,6 +753,7 @@ end
|
||||||
-- Get current preview zoom based on mode
|
-- Get current preview zoom based on mode
|
||||||
local function pvZoom()
|
local function pvZoom()
|
||||||
if S.previewMode == "single" then return S.previewZoomOne end
|
if S.previewMode == "single" then return S.previewZoomOne end
|
||||||
|
if S.previewMode == "static" then return S.previewZoomSta end
|
||||||
return S.previewZoomAll
|
return S.previewZoomAll
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -1303,6 +1307,13 @@ openPreviewWindow = function()
|
||||||
-- calcPreviewSize helper
|
-- calcPreviewSize helper
|
||||||
local function calcPreviewSize()
|
local function calcPreviewSize()
|
||||||
local z = pvZoom()
|
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 ptw = S.tileW * z
|
||||||
local pth = S.tileH * z
|
local pth = S.tileH * z
|
||||||
local cellW = ptw + PV_MARGIN * 2
|
local cellW = ptw + PV_MARGIN * 2
|
||||||
|
|
@ -1345,9 +1356,15 @@ openPreviewWindow = function()
|
||||||
end
|
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{
|
previewDlg:button{
|
||||||
id = "pvToggleMode",
|
id = "pvToggleMode",
|
||||||
text = S.previewMode == "all" and "All" or "One",
|
text = getModeLabel(),
|
||||||
onclick = function()
|
onclick = function()
|
||||||
if S.previewMode == "all" then
|
if S.previewMode == "all" then
|
||||||
S.previewMode = "single"
|
S.previewMode = "single"
|
||||||
|
|
@ -1355,19 +1372,27 @@ openPreviewWindow = function()
|
||||||
if S.previewSingleIdx < 1 then S.previewSingleIdx = 1 end
|
if S.previewSingleIdx < 1 then S.previewSingleIdx = 1 end
|
||||||
if S.previewSingleIdx > #S.animNames then S.previewSingleIdx = #S.animNames end
|
if S.previewSingleIdx > #S.animNames then S.previewSingleIdx = #S.animNames end
|
||||||
end
|
end
|
||||||
|
elseif S.previewMode == "single" then
|
||||||
|
S.previewMode = "static"
|
||||||
else
|
else
|
||||||
S.previewMode = "all"
|
S.previewMode = "all"
|
||||||
end
|
end
|
||||||
-- Close and reopen to resize canvas
|
-- Update button text, label visibility, and Fit enabled state
|
||||||
pcall(function() previewDlg:close() end)
|
pcall(function()
|
||||||
openPreviewWindow()
|
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
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
previewDlg:button{
|
previewDlg:button{
|
||||||
id = "pvFit",
|
id = "pvFit",
|
||||||
text = "Fit",
|
text = "Fit",
|
||||||
|
enabled = (S.previewMode ~= "static"),
|
||||||
onclick = function()
|
onclick = function()
|
||||||
|
if S.previewMode == "static" then return end
|
||||||
-- Close and reopen to refit
|
-- Close and reopen to refit
|
||||||
pcall(function() previewDlg:close() end)
|
pcall(function() previewDlg:close() end)
|
||||||
openPreviewWindow()
|
openPreviewWindow()
|
||||||
|
|
@ -1381,6 +1406,26 @@ openPreviewWindow = function()
|
||||||
autoscaling = false,
|
autoscaling = false,
|
||||||
onpaint = function(ev)
|
onpaint = function(ev)
|
||||||
local gc = ev.context
|
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
|
local na = #S.animNames
|
||||||
if na == 0 then return end
|
if na == 0 then return end
|
||||||
|
|
||||||
|
|
@ -1447,6 +1492,7 @@ openPreviewWindow = function()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
onmousedown = function(ev)
|
onmousedown = function(ev)
|
||||||
|
if S.previewMode == "static" then return end
|
||||||
-- In single mode: L-click=prev anim, R-click=next anim
|
-- In single mode: L-click=prev anim, R-click=next anim
|
||||||
if S.previewMode == "single" then
|
if S.previewMode == "single" then
|
||||||
if ev.button == MouseButton.LEFT then
|
if ev.button == MouseButton.LEFT then
|
||||||
|
|
@ -1476,6 +1522,8 @@ openPreviewWindow = function()
|
||||||
local dz = ev.deltaY < 0 and 1 or -1
|
local dz = ev.deltaY < 0 and 1 or -1
|
||||||
if S.previewMode == "single" then
|
if S.previewMode == "single" then
|
||||||
S.previewZoomOne = math.max(1, math.min(MAX_PREVIEW_ZOOM, S.previewZoomOne + dz))
|
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
|
else
|
||||||
S.previewZoomAll = math.max(1, math.min(MAX_PREVIEW_ZOOM, S.previewZoomAll + dz))
|
S.previewZoomAll = math.max(1, math.min(MAX_PREVIEW_ZOOM, S.previewZoomAll + dz))
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue