Sprite Properties Shows File Path Despite Preferences

Hi all,

When I go to Edit > Preferences > Files, uncheck the Show full file name path tick box, press the Apply button, press the OK button, then go to Sprite > Properties, a sprite’s file path is still displayed. This is assuming that the file is not a new, unsaved sprite. I tested in versions 1.2.34 and 1.3beta14 on Windows 10.

If this is not a bug, my suggestion would be to mask the file path out. A button could unmask it. Maybe whether or not the button is shown and the path is masked could depend on the preferences tick box.

I’m posting here, not on the Github issues page, because a stop-gap is possible with a Lua script. I left out a few things from the workaround; see notes below as to why.

The red square in the second image was edited in.

Thanks for considering.
Jeremy

local textLenLimit = 48
local sprite = app.activeSprite

if not sprite then return end

local appVersion = app.version
local versionMajor = appVersion.major
local versionMinor = appVersion.minor
local is13 = versionMajor > 0 and versionMinor > 2

local filename = sprite.filename
local ext = app.fs.fileExtension(filename)
local title = app.fs.fileTitle(filename)

local path = ""
local showFullPath = app.preferences.general.show_full_path
if showFullPath then
    path = app.fs.filePath(filename)
    if path and #path >= textLenLimit then
        path = string.sub(path, 1, textLenLimit) .. "..."
    end
end

local spec = sprite.spec

local colorMode = spec.colorMode
local colorModeStr = ""
if colorMode == ColorMode.RGB then
    colorModeStr = "RGB"
elseif colorMode == ColorMode.INDEXED then
    colorModeStr = "Indexed"
elseif colorMode == ColorMode.GRAY then
    colorModeStr = "Grayscale"
end

local colorSpace = spec.colorSpace
local csName = ""
if colorSpace then
    csName = colorSpace.name
    if csName and #csName >= textLenLimit then
        csName = string.sub(csName, 1, textLenLimit) .. "..."
    end
end

local palCount = #sprite.palettes[1]
local palCountStr = string.format("%d", palCount)

local sprPixelRatio = sprite.pixelRatio
local pixelWidth = sprPixelRatio.width
local pixelHeight = sprPixelRatio.height

local pxRatioStr = ""
if pixelWidth == 1 and pixelHeight == 1 then
    pxRatioStr = "Square Pixels (1:1)"
elseif pixelWidth == 2 and pixelHeight == 1 then
    pxRatioStr = "Double-wide Pixels (2:1)"
elseif pixelWidth == 1 and pixelHeight == 2 then
    pxRatioStr = "Double-high Pixels (1:2)"
end

local width = spec.width
local height = spec.height
local dimStr = string.format("%d x %d", width, height)

local frameCount = #sprite.frames
local frameStr = string.format("%d", frameCount)

local sprColorRef = nil
local sprColorVal = nil
if is13 then
    sprColorRef = sprite.color
    sprColorVal = Color(
        sprColorRef.red,
        sprColorRef.green,
        sprColorRef.blue,
        sprColorRef.alpha)
end

local sprUserData = ""
if is13 then
    sprUserData = sprite.data
end

local dlg = Dialog { title = "Sprite Properties +" }

if title and #title > 0 then
    dlg:label {
        id = "titleLabel",
        label = "Title:",
        text = title
    }
    dlg:newrow { always = false }
end

if ext and #ext > 0 then
    dlg:label {
        id = "extLabel",
        label = "Extension:",
        text = ext
    }
    dlg:newrow { always = false }
end

if path and #path > 0 then
    dlg:label {
        id = "pathLabel",
        label = "Path:",
        text = path
    }
    dlg:newrow { always = false }
end

if csName and #csName > 0 then
    dlg:label {
        id = "clrSpaceLabel",
        label = "Color Space:",
        text = csName
    }
    dlg:newrow { always = false }
end

if colorModeStr and #colorModeStr > 0 then
    dlg:label {
        id = "clrMdLabel",
        label = "Color Mode:",
        text = colorModeStr
    }
    dlg:newrow { always = false }
end

dlg:label {
    id = "palCountLabel",
    label = "Palette Length:",
    text = palCountStr
}
dlg:newrow { always = false }

dlg:label {
    id = "dimLabel",
    label = "Dimensions:",
    text = dimStr
}
dlg:newrow { always = false }

dlg:label {
    id = "frameLabel",
    label = "Frames:",
    text = frameStr
}
dlg:newrow { always = false }

if is13 then
    dlg:color {
        id = "sprColor",
        label = "Color:",
        color = sprColorVal
    }
    dlg:newrow { always = false }
end

if is13 then
    dlg:entry {
        id = "sprUserData",
        label = "User Data:",
        text = sprUserData,
        focus = false
    }
end

dlg:combobox {
    id = "pxAspectDropdown",
    label = "Pixel Aspect:",
    option = pxRatioStr,
    options = {
        "Square Pixels (1:1)",
        "Double-wide Pixels (2:1)",
        "Double-high Pixels (1:2)" }
}

dlg:button {
    id = "confirm",
    text = "&OK",
    focus = false,
    onclick = function()
        if sprite and app.activeSprite == sprite then
            local args = dlg.data
            local pxAspectStr = args.pxAspectDropdown
            local sprColor = args.sprColor
            local userData = args.sprUserData

            if pxAspectStr == "Double-wide Pixels (2:1)" then
                sprite.pixelRatio = Size(2, 1)
            elseif pxAspectStr == "Double-high Pixels (1:2)" then
                sprite.pixelRatio = Size(1, 2)
            elseif pxAspectStr == "Square Pixels (1:1)" then
                sprite.pixelRatio = Size(1, 1)
            end

            if is13 then
                sprite.color = sprColor
                sprite.data = userData
            end
            
            app.refresh()
        end
        dlg:close()
    end
}

dlg:button {
    id = "cancel",
    text = "&CANCEL",
    focus = true,
    onclick = function()
        dlg:close()
    end
}

dlg:show { wait = false }

Notes:

  1. Unlike the Sprite > Properties dialog, the user is able to perform other actions while the script’s dialog is open. That can include opening the script dialog before any sprite is open, while the home tab is in focus, closing a sprite after the script dialog is open, switching between sprites, or opening the default properties menu and applying changes. This script handles none of those actions gracefully. There is potential to handle them better, maybe with events for anyone who knows more about them.

  2. The file’s size in memory is not included. The default includes it in parentheses after the pixel dimensions.

  3. In version 1.3 beta, the default properties allows display toggle of the sprite’s tab color and user data with a button to the right of its file name. If desired, a dialog widget’s visible property can be changed with modify. Sprite user data and color cannot be changed in 1.2.34.

  4. Assigning or converting a sprite’s color space is its own deal imo. See this script if interested. I doubt there’s any technical reason why it can’t be combined with the above. Scripts which read or write to file require extra user permissions to work.

  5. Afaik, more than one unresolved bug is related to a sprite’s transparent color index. This property can be get and set by script; if interested, see the source code. I’m still debating how to design around this problem, that’s why I left it out.

  6. You could add all sorts of extra diagnostics, as discussed in this thread and likely other threads I couldn’t find. In this post, I’m only interested in replicating the default window’s properties minus omissions noted above.

  7. A keyboard shortcut can be assigned to a script by going to Edit > Keyboard shortcuts.