Show game buttonbar only when more than one game is present
This commit is contained in:
parent
50a8757f3e
commit
ea85bf9d50
@ -55,33 +55,43 @@ local function singleplayer_refresh_gamebar()
|
||||
end
|
||||
end
|
||||
|
||||
local btnbar = buttonbar_create("game_button_bar",
|
||||
game_buttonbar_button_handler,
|
||||
{x=-0.3,y=5.65}, "horizontal", {x=12.4,y=1.15})
|
||||
if #gamemgr.games > 1 then
|
||||
local btnbar = buttonbar_create("game_button_bar",
|
||||
game_buttonbar_button_handler,
|
||||
{x=-0.3,y=5.65}, "horizontal", {x=12.4,y=1.15})
|
||||
|
||||
for i=1,#gamemgr.games,1 do
|
||||
local btn_name = "game_btnbar_" .. gamemgr.games[i].id
|
||||
for i=1,#gamemgr.games,1 do
|
||||
local btn_name = "game_btnbar_" .. gamemgr.games[i].id
|
||||
|
||||
local image = nil
|
||||
local text = nil
|
||||
local tooltip = core.formspec_escape(gamemgr.games[i].name)
|
||||
local image = nil
|
||||
local text = nil
|
||||
local tooltip = core.formspec_escape(gamemgr.games[i].name)
|
||||
|
||||
if gamemgr.games[i].menuicon_path ~= nil and
|
||||
gamemgr.games[i].menuicon_path ~= "" then
|
||||
image = core.formspec_escape(gamemgr.games[i].menuicon_path)
|
||||
else
|
||||
if gamemgr.games[i].menuicon_path ~= nil and
|
||||
gamemgr.games[i].menuicon_path ~= "" then
|
||||
image = core.formspec_escape(gamemgr.games[i].menuicon_path)
|
||||
else
|
||||
|
||||
local part1 = gamemgr.games[i].id:sub(1,5)
|
||||
local part2 = gamemgr.games[i].id:sub(6,10)
|
||||
local part3 = gamemgr.games[i].id:sub(11)
|
||||
local part1 = gamemgr.games[i].id:sub(1,5)
|
||||
local part2 = gamemgr.games[i].id:sub(6,10)
|
||||
local part3 = gamemgr.games[i].id:sub(11)
|
||||
|
||||
text = part1 .. "\n" .. part2
|
||||
if part3 ~= nil and
|
||||
part3 ~= "" then
|
||||
text = text .. "\n" .. part3
|
||||
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
|
||||
btnbar:add_button(btn_name, text, image, tooltip)
|
||||
|
||||
else
|
||||
mm_texture.update("singleplayer", gamemgr.games[1])
|
||||
core.set_topleft_text(gamemgr.games[1].name)
|
||||
core.setting_set("menu_last_game",gamemgr.games[1].id)
|
||||
menudata.worldlist:set_filtercriteria(gamemgr.games[1].id)
|
||||
local index = filterlist.get_current_index(menudata.worldlist,
|
||||
tonumber(core.setting_get("mainmenu_last_selected_world")))
|
||||
end
|
||||
end
|
||||
|
||||
@ -216,9 +226,9 @@ local function main_button_handler(this, fields, name, tabdata)
|
||||
end
|
||||
|
||||
local function on_change(type, old_tab, new_tab)
|
||||
local buttonbar = ui.find_by_name("game_button_bar")
|
||||
local buttonbar --= ui.find_by_name("game_button_bar")
|
||||
|
||||
if ( buttonbar == nil ) then
|
||||
if (buttonbar == nil) then
|
||||
singleplayer_refresh_gamebar()
|
||||
buttonbar = ui.find_by_name("game_button_bar")
|
||||
end
|
||||
@ -231,10 +241,14 @@ local function on_change(type, old_tab, new_tab)
|
||||
core.set_topleft_text(game.name)
|
||||
mm_texture.update("singleplayer",game)
|
||||
end
|
||||
buttonbar:show()
|
||||
if buttonbar then
|
||||
buttonbar:show()
|
||||
end
|
||||
else
|
||||
menudata.worldlist:set_filtercriteria(nil)
|
||||
buttonbar:hide()
|
||||
if buttonbar then
|
||||
buttonbar:hide()
|
||||
end
|
||||
core.set_topleft_text("")
|
||||
mm_texture.update(new_tab,nil)
|
||||
end
|
||||
|
@ -42,7 +42,7 @@ bool getGameMinetestConfig(const std::string &game_path, Settings &conf)
|
||||
|
||||
bool getGameConfig(const std::string &game_path, Settings &conf)
|
||||
{
|
||||
std::string conf_path = game_path + DIR_DELIM + "blockplanet.conf";
|
||||
std::string conf_path = game_path + DIR_DELIM + "game.conf";
|
||||
return conf.readConfigFile(conf_path.c_str());
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ std::vector<SubgameSpec> getAvailableGames()
|
||||
return specs;
|
||||
}
|
||||
|
||||
#define LEGACY_GAMEID "minetest"
|
||||
#define LEGACY_GAMEID "blockplanet"
|
||||
|
||||
bool getWorldExists(const std::string &world_path)
|
||||
{
|
||||
@ -215,8 +215,8 @@ std::string getWorldGameId(const std::string &world_path, bool can_be_legacy)
|
||||
if(!conf.exists("gameid"))
|
||||
return "";
|
||||
// The "mesetint" gameid has been discarded
|
||||
if(conf.get("gameid") == "mesetint")
|
||||
return "minetest";
|
||||
if(conf.get("gameid") == "minetest_next" || conf.get("gameid") == "minetest_game")
|
||||
return "blockplanet";
|
||||
return conf.get("gameid");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user