dcearth/ui/savemodal.lua

61 lines
1.4 KiB
Lua
Raw Normal View History

--Modal for setting save options.
2024-04-29 01:21:32 +00:00
local love = assert( love )
local modal = require( "ui.modal" )
local button = require( "ui.button" )
local map = require( "map.map" )
local save = require( "ui.saveprogress" )
local t = { w = love.graphics.getWidth(), h = 200 }
2024-04-29 01:21:32 +00:00
2024-07-13 16:26:34 +00:00
local saveLocation = false
local floppy = love.graphics.newImage( "icons/save.png" )
floppy:setFilter( "nearest", "nearest" )
2024-04-29 01:21:32 +00:00
local saveButton = button.new{
2024-07-20 03:09:53 +00:00
group = t,
2024-04-29 01:21:32 +00:00
name = "save",
align = "left",
callback = function() save:start() end,
2024-04-29 01:21:32 +00:00
visible = false,
icon = floppy,
w = 400 - button.x,
h = 64,
y = 0,
2024-04-29 01:21:32 +00:00
}
local xIcon = love.graphics.newImage( "icons/x.png" )
xIcon:setFilter( "nearest", "nearest" )
2024-04-29 01:21:32 +00:00
local cancelButton = button.new{
2024-07-20 03:09:53 +00:00
group = t,
name = " cancel",
align = "left",
2024-04-29 01:21:32 +00:00
visible = false,
icon = xIcon,
2024-04-29 01:21:32 +00:00
callback = function() return t:stop() end,
y = 68,
w = 400 - button.x,
h = 64,
2024-04-29 01:21:32 +00:00
}
function t.start()
modal.start( t )
2024-07-13 16:26:34 +00:00
saveLocation = saveLocation or map.path
2024-04-29 01:21:32 +00:00
button.selected = saveButton
saveButton.name = " save to "..saveLocation
2024-07-20 03:09:53 +00:00
button.displayGroup( t, false, true )
2024-04-29 01:21:32 +00:00
end
function t.draw()
love.graphics.clear( 0,0,0,1 )
love.graphics.setColor( 1, 1, 1, 0.9 )
2024-04-29 01:21:32 +00:00
button:draw()
end
2024-07-13 16:26:34 +00:00
function t.directorydropped( path )
2024-04-29 01:21:32 +00:00
saveLocation = path
map.path = path
saveButton.name = " save to "..map.path
2024-04-29 01:21:32 +00:00
return love.filesystem.mount( path, "" )
end
return modal.new( t )