mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Refactor ContentDB integration (#14507)
This commit is contained in:
parent
cc1bfc6d03
commit
284f6d3682
12 changed files with 1356 additions and 1244 deletions
53
builtin/mainmenu/content/dlg_overwrite.lua
Normal file
53
builtin/mainmenu/content/dlg_overwrite.lua
Normal file
|
@ -0,0 +1,53 @@
|
|||
--Minetest
|
||||
--Copyright (C) 2018-24 rubenwardy
|
||||
--
|
||||
--This program is free software; you can redistribute it and/or modify
|
||||
--it under the terms of the GNU Lesser General Public License as published by
|
||||
--the Free Software Foundation; either version 2.1 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
--but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
--GNU Lesser General Public License for more details.
|
||||
--
|
||||
--You should have received a copy of the GNU Lesser General Public License along
|
||||
--with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
function get_formspec(data)
|
||||
local package = data.package
|
||||
|
||||
return confirmation_formspec(
|
||||
fgettext("\"$1\" already exists. Would you like to overwrite it?", package.name),
|
||||
'install', fgettext("Overwrite"),
|
||||
'cancel', fgettext("Cancel"))
|
||||
end
|
||||
|
||||
|
||||
local function handle_submit(this, fields)
|
||||
local data = this.data
|
||||
if fields.cancel then
|
||||
this:delete()
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.install then
|
||||
this:delete()
|
||||
data.callback()
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function create_confirm_overwrite(package, callback)
|
||||
assert(type(package) == "table")
|
||||
assert(type(callback) == "function")
|
||||
|
||||
local dlg = dialog_create("data", get_formspec, handle_submit, nil)
|
||||
dlg.data.package = package
|
||||
dlg.data.callback = callback
|
||||
return dlg
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue