2024-07-18 20:00:51 +00:00
|
|
|
local love = assert( love )
|
|
|
|
local modal = require( "ui.modal" )
|
|
|
|
local button = require( "ui.button" )
|
|
|
|
local map = require( "map.map" )
|
|
|
|
local t = {}
|
|
|
|
|
|
|
|
local loadLocation = false
|
|
|
|
local folder = love.graphics.newImage( "icons/load.png" )
|
|
|
|
folder:setFilter( "nearest", "nearest" )
|
|
|
|
local loadButton = button.new{
|
2024-07-20 03:09:53 +00:00
|
|
|
group = t,
|
2024-07-18 20:00:51 +00:00
|
|
|
name = "load",
|
|
|
|
callback = function()
|
|
|
|
if not loadLocation then return end
|
|
|
|
map.load( loadLocation )
|
|
|
|
return t:stop() end,
|
|
|
|
visible = false,
|
|
|
|
icon = folder,
|
|
|
|
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{
|
2024-07-20 03:09:53 +00:00
|
|
|
group = t,
|
2024-07-18 20:00:51 +00:00
|
|
|
name = "cancel load",
|
|
|
|
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 )
|
|
|
|
loadLocation = loadLocation or map.path
|
|
|
|
button.selected = loadButton
|
|
|
|
loadButton.name = "save to "..loadLocation
|
2024-07-20 03:09:53 +00:00
|
|
|
button.displayGroup( t, true )
|
2024-07-18 20:00:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function t.draw()
|
|
|
|
love.graphics.clear( 0,0,0,1 )
|
|
|
|
love.graphics.setColor( 0, 0, 1, 0.4 )
|
|
|
|
button:draw()
|
|
|
|
end
|
|
|
|
|
|
|
|
function t.directorydropped( path )
|
|
|
|
loadLocation = path
|
|
|
|
map.path = path
|
|
|
|
loadButton.name = "load from "..map.path
|
|
|
|
return love.filesystem.mount( path, "" )
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return modal.new( t )
|