Add "hide_game = true" option to game.conf (#152)
This commit is contained in:
parent
1538e5bc99
commit
0eb18780e4
@ -104,14 +104,19 @@ function menudata.init_tabs()
|
||||
tab_name_selected = "content",
|
||||
is_open_cdb = true,
|
||||
on_click = function(this)
|
||||
if #pkgmgr.games > 1 or (pkgmgr.games[1] and pkgmgr.games[1].id ~= "default") then
|
||||
this:set_tab("content")
|
||||
else
|
||||
local dialog = create_store_dlg()
|
||||
dialog:set_parent(this)
|
||||
this:hide()
|
||||
dialog:show()
|
||||
-- Show the content tab if no hidden games are installed
|
||||
for _, game in ipairs(pkgmgr.games) do
|
||||
if not game.hidden then
|
||||
this:set_tab("content")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Otherwise open the store dialog
|
||||
local dialog = create_store_dlg("game")
|
||||
dialog:set_parent(this)
|
||||
this:hide()
|
||||
dialog:show()
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -908,6 +908,7 @@ function pkgmgr.update_gamelist()
|
||||
-- Update default_game_idx
|
||||
for i, game in ipairs(pkgmgr.games) do
|
||||
if game.id == "default" then
|
||||
-- Used by tab_local
|
||||
pkgmgr.default_game_idx = i
|
||||
break
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ local function get_formspec(tabview, name, tabdata)
|
||||
packages_raw = {}
|
||||
local i = 0
|
||||
for _, game in ipairs(pkgmgr.games) do
|
||||
if game.id ~= "default" then
|
||||
if not game.hidden then
|
||||
i = i + 1
|
||||
packages_raw[i] = game
|
||||
end
|
||||
|
@ -144,13 +144,17 @@ SubgameSpec findSubgame(const std::string &id)
|
||||
if (conf.exists("moddable"))
|
||||
moddable = conf.getBool("moddable");
|
||||
|
||||
bool hide_game = false;
|
||||
if (conf.exists("hide_game"))
|
||||
hide_game = conf.getBool("hide_game");
|
||||
|
||||
std::string menuicon_path;
|
||||
#ifndef SERVER
|
||||
menuicon_path = getImagePath(
|
||||
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
|
||||
#endif
|
||||
return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name,
|
||||
menuicon_path, game_author, game_release, moddable);
|
||||
menuicon_path, game_author, game_release, moddable, hide_game);
|
||||
}
|
||||
|
||||
SubgameSpec findWorldSubgame(const std::string &world_path)
|
||||
|
@ -36,6 +36,7 @@ struct SubgameSpec
|
||||
std::set<std::string> addon_mods_paths;
|
||||
std::string menuicon_path;
|
||||
bool moddable;
|
||||
bool hidden;
|
||||
|
||||
SubgameSpec(const std::string &id = "", const std::string &path = "",
|
||||
const std::string &gamemods_path = "",
|
||||
@ -44,11 +45,11 @@ struct SubgameSpec
|
||||
const std::string &name = "",
|
||||
const std::string &menuicon_path = "",
|
||||
const std::string &author = "", int release = 0,
|
||||
const bool moddable = true) :
|
||||
const bool moddable = true, const bool hidden = false) :
|
||||
id(id),
|
||||
name(name), author(author), release(release), path(path),
|
||||
gamemods_path(gamemods_path), addon_mods_paths(addon_mods_paths),
|
||||
menuicon_path(menuicon_path), moddable(moddable)
|
||||
menuicon_path(menuicon_path), moddable(moddable), hidden(hidden)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -330,6 +330,10 @@ int ModApiMainMenu::l_get_games(lua_State *L)
|
||||
lua_pushboolean(L, game.moddable);
|
||||
lua_settable(L, top_lvl2);
|
||||
|
||||
lua_pushstring(L, "hidden");
|
||||
lua_pushboolean(L, game.hidden);
|
||||
lua_settable(L, top_lvl2);
|
||||
|
||||
lua_pushstring(L, "addon_mods_paths");
|
||||
lua_newtable(L);
|
||||
int table2 = lua_gettop(L);
|
||||
|
Loading…
x
Reference in New Issue
Block a user