59 lines
1.4 KiB
Lua
59 lines
1.4 KiB
Lua
local love = assert( love )
|
|
local modal = require( "modal" )
|
|
local button = require( "button" )
|
|
local map = require( "map" )
|
|
local t = {}
|
|
|
|
local saveLocation = false
|
|
local floppy = love.graphics.newImage( "icons/save.png" )
|
|
floppy:setFilter( "nearest", "nearest" )
|
|
local saveButton = button.new{
|
|
group = "saveModal",
|
|
name = "save",
|
|
callback = function() map.save(); return t:stop() end,
|
|
visible = false,
|
|
icon = floppy,
|
|
x = love.graphics.getWidth() / 2 - 300,
|
|
y = love.graphics.getHeight() / 2 - 150,
|
|
w = 600,
|
|
h = 100,
|
|
}
|
|
|
|
local xIcon = love.graphics.newImage( "icons/x.png" )
|
|
xIcon:setFilter( "nearest", "nearest" )
|
|
local cancelButton = button.new{
|
|
group = "saveModal",
|
|
name = "cancel",
|
|
visible = false,
|
|
icon = xIcon,
|
|
callback = function() return t:stop() end,
|
|
x = love.graphics.getWidth() / 2 - 300,
|
|
y = love.graphics.getHeight() / 2,
|
|
w = 600,
|
|
h = 100
|
|
}
|
|
|
|
function t.start()
|
|
modal.start( t )
|
|
saveLocation = saveLocation or map.path
|
|
button.selected = saveButton
|
|
saveButton.name = "save to "..saveLocation
|
|
button.displayGroup( "saveModal", true )
|
|
end
|
|
|
|
function t.draw()
|
|
love.graphics.clear( 0,0,0,1 )
|
|
love.graphics.setColor( 1, 0, 0, 0.4 )
|
|
button:draw()
|
|
|
|
end
|
|
|
|
function t.directorydropped( path )
|
|
saveLocation = path
|
|
map.path = path
|
|
saveButton.name = "save to "..map.path
|
|
return love.filesystem.mount( path, "" )
|
|
end
|
|
|
|
|
|
return modal.new( t ) |