Skip to content

Commit

Permalink
Remove game selector panel
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Aug 6, 2019
1 parent 69e80ff commit b5177bf
Showing 1 changed file with 15 additions and 96 deletions.
111 changes: 15 additions & 96 deletions builtin/mainmenu/tab_local.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,82 +16,11 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


local enable_gamebar = PLATFORM ~= "Android"
local current_game, singleplayer_refresh_gamebar
if enable_gamebar then
function current_game()
local last_game_id = core.settings:get("menu_last_game")
local game, index = pkgmgr.find_by_gameid(last_game_id)

return game
end

function singleplayer_refresh_gamebar()
local function current_game()
local last_game_id = core.settings:get("menu_last_game")
local game, index = pkgmgr.find_by_gameid(last_game_id)

local old_bar = ui.find_by_name("game_button_bar")

if old_bar ~= nil then
old_bar:delete()
end

local function game_buttonbar_button_handler(fields)
for key,value in pairs(fields) do
for j=1,#pkgmgr.games,1 do
if ("game_btnbar_" .. pkgmgr.games[j].id == key) then
mm_texture.update("singleplayer", pkgmgr.games[j])
core.set_topleft_text(pkgmgr.games[j].name)
core.settings:set("menu_last_game",pkgmgr.games[j].id)
menudata.worldlist:set_filtercriteria(pkgmgr.games[j].id)
local index = filterlist.get_current_index(menudata.worldlist,
tonumber(core.settings:get("mainmenu_last_selected_world")))
if not index or index < 1 then
local selected = core.get_textlist_index("sp_worlds")
if selected ~= nil and selected < #menudata.worldlist:get_list() then
index = selected
else
index = #menudata.worldlist:get_list()
end
end
menu_worldmt_legacy(index)
return true
end
end
end
end

local btnbar = buttonbar_create("game_button_bar",
game_buttonbar_button_handler,
{x=-0.3,y=5.9}, "horizontal", {x=12.4,y=1.15})

for i=1,#pkgmgr.games,1 do
local btn_name = "game_btnbar_" .. pkgmgr.games[i].id

local image = nil
local text = nil
local tooltip = core.formspec_escape(pkgmgr.games[i].name)

if pkgmgr.games[i].menuicon_path ~= nil and
pkgmgr.games[i].menuicon_path ~= "" then
image = core.formspec_escape(pkgmgr.games[i].menuicon_path)
else

local part1 = pkgmgr.games[i].id:sub(1,5)
local part2 = pkgmgr.games[i].id:sub(6,10)
local part3 = pkgmgr.games[i].id:sub(11)

text = part1 .. "\n" .. part2
if part3 ~= nil and
part3 ~= "" then
text = text .. "\n" .. part3
end
end
btnbar:add_button(btn_name, text, image, tooltip)
end
end
else
function current_game()
return nil
end
return game
end

local function get_formspec(tabview, name, tabdata)
Expand Down Expand Up @@ -291,29 +220,19 @@ local function main_button_handler(this, fields, name, tabdata)
end
end

local on_change
if enable_gamebar then
function on_change(type, old_tab, new_tab)
if (type == "ENTER") then
local game = current_game()

if game then
menudata.worldlist:set_filtercriteria(game.id)
core.set_topleft_text(game.name)
mm_texture.update("singleplayer",game)
end
local function on_change(type, old_tab, new_tab)
if type == "ENTER" then
local game = current_game()

singleplayer_refresh_gamebar()
ui.find_by_name("game_button_bar"):show()
else
menudata.worldlist:set_filtercriteria(nil)
local gamebar = ui.find_by_name("game_button_bar")
if gamebar then
gamebar:hide()
end
core.set_topleft_text("")
mm_texture.update(new_tab,nil)
if game then
menudata.worldlist:set_filtercriteria(game.id)
core.set_topleft_text(game.name)
mm_texture.update("singleplayer",game)
end
else
menudata.worldlist:set_filtercriteria(nil)
core.set_topleft_text("")
mm_texture.update(new_tab,nil)
end
end

Expand Down

0 comments on commit b5177bf

Please sign in to comment.