Show game buttonbar only when more than one game is present

This commit is contained in:
BlockMen 2015-11-29 00:08:22 +01:00
parent 50a8757f3e
commit ea85bf9d50
2 changed files with 54 additions and 40 deletions

View File

@ -55,6 +55,7 @@ local function singleplayer_refresh_gamebar()
end
end
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})
@ -83,6 +84,15 @@ local function singleplayer_refresh_gamebar()
end
btnbar:add_button(btn_name, text, image, tooltip)
end
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
local function get_formspec(tabview, name, tabdata)
@ -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
if buttonbar then
buttonbar:show()
end
else
menudata.worldlist:set_filtercriteria(nil)
if buttonbar then
buttonbar:hide()
end
core.set_topleft_text("")
mm_texture.update(new_tab,nil)
end

View File

@ -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");
}