2024-07-23 06:15:11 +00:00
|
|
|
--Modal for setting save options.
|
2024-04-29 01:21:32 +00:00
|
|
|
local love = assert( love )
|
2024-07-18 20:00:51 +00:00
|
|
|
local modal = require( "ui.modal" )
|
|
|
|
local button = require( "ui.button" )
|
|
|
|
local map = require( "map.map" )
|
2024-07-23 06:15:11 +00:00
|
|
|
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
|
2024-04-29 02:44:18 +00:00
|
|
|
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",
|
2024-07-23 06:15:11 +00:00
|
|
|
align = "left",
|
|
|
|
callback = function() save:start() end,
|
2024-04-29 01:21:32 +00:00
|
|
|
visible = false,
|
2024-04-29 02:44:18 +00:00
|
|
|
icon = floppy,
|
2024-07-23 06:15:11 +00:00
|
|
|
w = 400 - button.x,
|
|
|
|
h = 64,
|
|
|
|
y = 0,
|
2024-04-29 01:21:32 +00:00
|
|
|
}
|
|
|
|
|
2024-04-29 02:44:18 +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,
|
2024-07-23 06:15:11 +00:00
|
|
|
name = " cancel",
|
|
|
|
align = "left",
|
2024-04-29 01:21:32 +00:00
|
|
|
visible = false,
|
2024-04-29 02:44:18 +00:00
|
|
|
icon = xIcon,
|
2024-04-29 01:21:32 +00:00
|
|
|
callback = function() return t:stop() end,
|
2024-07-23 06:15:11 +00:00
|
|
|
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
|
2024-07-23 06:15:11 +00:00
|
|
|
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 )
|
2024-07-23 06:15:11 +00:00
|
|
|
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
|
2024-07-23 06:15:11 +00:00
|
|
|
saveButton.name = " save to "..map.path
|
2024-04-29 01:21:32 +00:00
|
|
|
return love.filesystem.mount( path, "" )
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return modal.new( t )
|