2 --Copyright (C) 2023 Gregor Parzefall
4 --This program is free software; you can redistribute it and/or modify
5 --it under the terms of the GNU Lesser General Public License as published by
6 --the Free Software Foundation; either version 2.1 of the License, or
7 --(at your option) any later version.
9 --This program is distributed in the hope that it will be useful,
10 --but WITHOUT ANY WARRANTY; without even the implied warranty of
11 --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 --GNU Lesser General Public License for more details.
14 --You should have received a copy of the GNU Lesser General Public License along
15 --with this program; if not, write to the Free Software Foundation, Inc.,
16 --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 -- This whole file can be removed after a while.
20 -- It was only directly useful for upgrades from 5.7.0 to 5.8.0, but
21 -- maybe some odd fellow directly upgrades from 5.6.1 to 5.9.0 in the future...
22 -- see <https://github.com/minetest/minetest/pull/13850> in case it's not obvious
25 local SETTING_NAME
= "no_mtg_notification"
27 function check_reinstall_mtg()
28 -- used to be in minetest.conf
29 if core
.settings
:get_bool(SETTING_NAME
) then
30 cache_settings
:set_bool(SETTING_NAME
, true)
31 core
.settings
:remove(SETTING_NAME
)
34 if cache_settings
:get_bool(SETTING_NAME
) then
38 local games
= core
.get_games()
39 for _
, game
in ipairs(games
) do
40 if game
.id
== "minetest" then
41 cache_settings
:set_bool(SETTING_NAME
, true)
46 local mtg_world_found
= false
47 local worlds
= core
.get_worlds()
48 for _
, world
in ipairs(worlds
) do
49 if world
.gameid
== "minetest" then
50 mtg_world_found
= true
54 if not mtg_world_found
then
55 cache_settings
:set_bool(SETTING_NAME
, true)
59 local maintab
= ui
.find_by_name("maintab")
61 local dlg
= create_reinstall_mtg_dlg()
62 dlg
:set_parent(maintab
)
68 local function get_formspec(dialogdata
)
69 local markup
= table.concat({
70 "<big>", fgettext("Minetest Game is no longer installed by default"), "</big>\n",
71 fgettext("For a long time, the Minetest engine shipped with a default game called \"Minetest Game\". " ..
72 "Since Minetest 5.8.0, Minetest ships without a default game."), "\n",
73 fgettext("If you want to continue playing in your Minetest Game worlds, you need to reinstall Minetest Game."),
77 "formspec_version[6]",
79 "hypertext[0.375,0.375;12.05,5.2;text;", minetest
.formspec_escape(markup
), "]",
80 "container[0.375,5.825]",
81 "style[dismiss;bgcolor=red]",
82 "button[0,0;4,0.8;dismiss;", fgettext("Dismiss"), "]",
83 "button[4.25,0;8,0.8;reinstall;", fgettext("Reinstall Minetest Game"), "]",
88 local function buttonhandler(this
, fields
)
89 if fields
.reinstall
then
90 -- Don't set "no_mtg_notification" here so that the dialog will be shown
91 -- again if downloading MTG fails for whatever reason.
94 local maintab
= ui
.find_by_name("maintab")
96 local dlg
= create_store_dlg(nil, "minetest/minetest")
97 dlg
:set_parent(maintab
)
104 if fields
.dismiss
then
105 cache_settings
:set_bool("no_mtg_notification", true)
111 local function eventhandler(event
)
112 if event
== "DialogShow" then
113 mm_game_theme
.set_engine()
115 elseif event
== "MenuQuit" then
116 -- Don't allow closing the dialog with ESC, but still allow exiting
124 function create_reinstall_mtg_dlg()
125 local dlg
= dialog_create("dlg_reinstall_mtg", get_formspec
,
126 buttonhandler
, eventhandler
)