Page 2 of 2

Re: bugs in showMessageBox

Posted: Wed Feb 22, 2017 5:11 pm
by zorg
CherryBit wrote: Wed Feb 22, 2017 2:19 pm
Positive07 wrote: Wed Feb 22, 2017 1:45 pm Do you wanna save before quitting?
Yes / No / Cancel

[...]
Just to be pedantic: using "Yes"/"No" choices for dialogs is poor UX design and requires the user to read and think more. Using actions ("Save", "Don't Save") as the button labels is much clearer and allows the user to make choices with less reading. It may seem minor but users are easily frustrated, especially when you're forcing them to make a choice.
If you do want to be pedantic, then realize the choice is still there, you basically just hinted semantic sugar all over it; i'm truly sorry though, you thinking the current generation lacking the necessary capacity to understand a simple multiple-choice question with the most basic answer words.

Re: bugs in showMessageBox

Posted: Wed Feb 22, 2017 9:37 pm
by akt
Positive07 wrote: Wed Feb 22, 2017 1:45 pm Also there is lua-nativefiledialog which I have compiled and used fine with LÖVE.
Thanks for that info -- I'll give it a try. Do you have a working project or .love file I could download to see it in action?

Re: bugs in showMessageBox

Posted: Wed Feb 22, 2017 11:25 pm
by Positive07
Nope, I have actually erased my dll... Not sure why. I should compile it again, it was pretty useful and nice. I need to recompile anyway since I have moved to a 64bits system since then

Re: bugs in showMessageBox

Posted: Thu Feb 23, 2017 10:49 pm
by akt
Ok, I've got nativefiledialog working on my Macs (using LOVE 0.9.2 on Mac OS 10.6 and LOVE 0.10.2 on Mac OS 10.12). I had to fix a few bugs so I've put the resulting nfd.so on my website in case other folks want to use it. (It would be great if somebody could make their nfd.dll file available and save me the hassle of having to build it! hint hint...)

At the top of my main.lua file I do this:

Code: Select all

maindir = love.filesystem.getRealDirectory("main.lua")
if love.system.getOS() == "OS X" then
    package.cpath = maindir.."/nfd-mac/?.so;"..package.cpath
elseif love.system.getOS() == "Windows" then
    package.cpath = maindir.."/nfd-win/?.dll;"..package.cpath   -- TODO: build nfd.dll!!!
elseif love.system.getOS() == "Linux" then
    package.cpath = maindir.."/nfd-gtk/?.so;"..package.cpath    -- TODO: build nfd.so for GTK-3!!!
end

local nfd = require("nfd")      -- native open/save file dialogs

-- initial directory for nfd.open and nfd.save
initdir = love.filesystem.getSaveDirectory()
Then I call nfd.open like this:

Code: Select all

function OpenGame()
    -- let user open a previously saved game
    local filepath = nfd.open("cc", initdir)
    
    -- clear any keypressed events (happens on Mac OS 10.12)
    love.event.clear()

    if not filepath then
        return    -- user hit Cancel button
    end
    
    -- strip off filename and set initdir for the next nfd.open/nfd.save call
    initdir = filepath:gsub("[^/\\]+$","")

    ReadGame(filepath)
end
And nfd.save like this:

Code: Select all

function SaveGame()
    -- let user save the current game in a specified file and location
    local filepath = nfd.save("cc", initdir)
    
    --  clear any keypressed events (happens on Mac OS 10.12)
    love.event.clear()
    
    if not filepath then
        return false    -- user hit Cancel button
    end

    -- strip off filename and set initdir for the next nfd.open/nfd.save call
    initdir = filepath:gsub("[^/\\]+$","")

    WriteGame(filepath)
    return true
end
Note the need to call love.event.clear() to remove any keypressed events. Presumably due to the same Mac-specific bug that's in showMessageBox.