dcearth/savemodal.lua

59 lines
1.4 KiB
Lua
Raw Permalink 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 = {}
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{
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 )
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-13 16:26:34 +00:00
saveButton.name = "save to "..saveLocation
2024-04-29 01:21:32 +00:00
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
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
return love.filesystem.mount( path, "" )
end
return modal.new( t )