dcearth/savemodal.lua

58 lines
1.3 KiB
Lua
Raw Normal View History

2024-04-29 01:21:32 +00:00
local love = assert( love )
local modal = require( "modal" )
local button = require( "button" )
local map = require( "map" )
local t = {}
local saveLocation = map.path
local floppy = love.graphics.newImage( "icons/save.png" )
floppy:setFilter( "nearest", "nearest" )
2024-04-29 01:21:32 +00:00
local saveButton = button.new{
group = "saveModal",
name = "save",
callback = function() map.save(); return t:stop() end,
visible = false,
icon = floppy,
2024-05-02 00:32:07 +00:00
x = love.graphics.getWidth() / 2 - 300,
y = love.graphics.getHeight() / 2 - 150,
2024-05-02 00:32:07 +00:00
w = 600,
2024-04-29 01:21:32 +00:00
h = 100,
}
local xIcon = love.graphics.newImage( "icons/x.png" )
xIcon:setFilter( "nearest", "nearest" )
2024-04-29 01:21:32 +00:00
local cancelButton = button.new{
group = "saveModal",
name = "cancel",
visible = false,
icon = xIcon,
2024-04-29 01:21:32 +00:00
callback = function() return t:stop() end,
2024-05-02 00:32:07 +00:00
x = love.graphics.getWidth() / 2 - 300,
y = love.graphics.getHeight() / 2,
2024-05-02 00:32:07 +00:00
w = 600,
2024-04-29 01:21:32 +00:00
h = 100
}
function t.start()
modal.start( t )
button.selected = saveButton
saveButton.name = "save to "..map.path
button.displayGroup( "saveModal", true )
end
function t.draw()
love.graphics.clear( 0,0,0,1 )
love.graphics.setColor( 1, 0, 0, 0.4 )
2024-04-29 01:21:32 +00:00
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 )