1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Enable the gamebar on Android (#12354)

This commit is contained in:
ROllerozxa 2022-07-17 15:45:30 +02:00 committed by GitHub
parent 4648d8f499
commit f090471022
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 104 additions and 146 deletions

View file

@ -15,9 +15,6 @@
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-- cf. tab_local, the gamebar already provides game selection so we hide the list from here
local hide_gamelist = PLATFORM ~= "Android"
local function table_to_flags(ftable)
-- Convert e.g. { jungles = true, caves = false } to "jungles,nocaves"
local str = {}
@ -111,14 +108,11 @@ local function create_world_formspec(dialogdata)
local flags = dialogdata.flags
local game, gameidx = pkgmgr.find_by_gameid(gameid)
if game == nil and hide_gamelist then
local game = pkgmgr.find_by_gameid(gameid)
if game == nil then
-- should never happen but just pick the first game
game = pkgmgr.get_game(1)
gameidx = 1
core.settings:set("menu_last_game", game.id)
elseif game == nil then
gameidx = 0
end
local disallowed_mapgen_settings = {}
@ -296,17 +290,6 @@ local function create_world_formspec(dialogdata)
label_spflags = "label[0,"..y_start..";" .. fgettext("Mapgen-specific flags") .. "]"
end
-- Warning if only devtest is installed
local devtest_only = ""
local gamelist_height = 2.3
if #pkgmgr.games == 1 and pkgmgr.games[1].id == "devtest" then
devtest_only = "box[0,0;5.8,1.7;#ff8800]" ..
"textarea[0.4,0.1;6,1.8;;;"..
fgettext("Development Test is meant for developers.") .. "]" ..
"button[1,1;4,0.5;world_create_open_cdb;" .. fgettext("Install another game") .. "]"
gamelist_height = 0.5
end
local retval =
"size[12.25,7,true]" ..
@ -329,13 +312,14 @@ local function create_world_formspec(dialogdata)
"label[0,2;" .. fgettext("Mapgen") .. "]"..
"dropdown[0,2.5;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]"
if not hide_gamelist or devtest_only ~= "" then
-- Warning if only devtest is installed
if #pkgmgr.games == 1 and pkgmgr.games[1].id == "devtest" then
retval = retval ..
"label[0,3.35;" .. fgettext("Game") .. "]"..
"textlist[0,3.85;5.8,"..gamelist_height..";games;" ..
pkgmgr.gamelist() .. ";" .. gameidx .. ";false]" ..
"container[0,4.5]" ..
devtest_only ..
"container[0,3.5]" ..
"box[0,0;5.8,1.7;#ff8800]" ..
"textarea[0.4,0.1;6,1.8;;;"..
fgettext("Development Test is meant for developers.") .. "]" ..
"button[1,1;4,0.5;world_create_open_cdb;" .. fgettext("Install another game") .. "]" ..
"container_end[]"
end
@ -371,13 +355,7 @@ local function create_world_buttonhandler(this, fields)
fields["key_enter"] then
local worldname = fields["te_world_name"]
local game, gameindex
if hide_gamelist then
game, gameindex = pkgmgr.find_by_gameid(core.settings:get("menu_last_game"))
else
gameindex = core.get_textlist_index("games")
game = pkgmgr.get_game(gameindex)
end
local game, gameindex = pkgmgr.find_by_gameid(core.settings:get("menu_last_game"))
local message
if game == nil then
@ -426,9 +404,7 @@ local function create_world_buttonhandler(this, fields)
if message == nil then
core.settings:set("menu_last_game", game.id)
if this.data.update_worldlist_filter then
menudata.worldlist:set_filtercriteria(game.id)
end
menudata.worldlist:set_filtercriteria(game.id)
menudata.worldlist:refresh()
core.settings:set("mainmenu_last_selected_world",
menudata.worldlist:raw_index_by_uid(worldname))
@ -486,13 +462,12 @@ local function create_world_buttonhandler(this, fields)
end
function create_create_world_dlg(update_worldlistfilter)
function create_create_world_dlg()
local retval = dialog_create("sp_create_world",
create_world_formspec,
create_world_buttonhandler,
nil)
retval.data = {
update_worldlist_filter = update_worldlistfilter,
worldname = "",
-- settings the world is created with:
seed = core.settings:get("fixed_map_seed") or "",