1
0

Add "hide_game = true" option to game.conf (#152)

This commit is contained in:
luk3yx 2023-11-06 02:42:27 +13:00 committed by mckaygerhard
parent 1538e5bc99
commit 0eb18780e4
6 changed files with 26 additions and 11 deletions

View File

@ -104,14 +104,19 @@ function menudata.init_tabs()
tab_name_selected = "content", tab_name_selected = "content",
is_open_cdb = true, is_open_cdb = true,
on_click = function(this) on_click = function(this)
if #pkgmgr.games > 1 or (pkgmgr.games[1] and pkgmgr.games[1].id ~= "default") then -- 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") this:set_tab("content")
else return
local dialog = create_store_dlg() end
end
-- Otherwise open the store dialog
local dialog = create_store_dlg("game")
dialog:set_parent(this) dialog:set_parent(this)
this:hide() this:hide()
dialog:show() dialog:show()
end
end, end,
}) })

View File

@ -908,6 +908,7 @@ function pkgmgr.update_gamelist()
-- Update default_game_idx -- Update default_game_idx
for i, game in ipairs(pkgmgr.games) do for i, game in ipairs(pkgmgr.games) do
if game.id == "default" then if game.id == "default" then
-- Used by tab_local
pkgmgr.default_game_idx = i pkgmgr.default_game_idx = i
break break
end end

View File

@ -32,7 +32,7 @@ local function get_formspec(tabview, name, tabdata)
packages_raw = {} packages_raw = {}
local i = 0 local i = 0
for _, game in ipairs(pkgmgr.games) do for _, game in ipairs(pkgmgr.games) do
if game.id ~= "default" then if not game.hidden then
i = i + 1 i = i + 1
packages_raw[i] = game packages_raw[i] = game
end end

View File

@ -144,13 +144,17 @@ SubgameSpec findSubgame(const std::string &id)
if (conf.exists("moddable")) if (conf.exists("moddable"))
moddable = conf.getBool("moddable"); moddable = conf.getBool("moddable");
bool hide_game = false;
if (conf.exists("hide_game"))
hide_game = conf.getBool("hide_game");
std::string menuicon_path; std::string menuicon_path;
#ifndef SERVER #ifndef SERVER
menuicon_path = getImagePath( menuicon_path = getImagePath(
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png"); game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
#endif #endif
return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name, 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) SubgameSpec findWorldSubgame(const std::string &world_path)

View File

@ -36,6 +36,7 @@ struct SubgameSpec
std::set<std::string> addon_mods_paths; std::set<std::string> addon_mods_paths;
std::string menuicon_path; std::string menuicon_path;
bool moddable; bool moddable;
bool hidden;
SubgameSpec(const std::string &id = "", const std::string &path = "", SubgameSpec(const std::string &id = "", const std::string &path = "",
const std::string &gamemods_path = "", const std::string &gamemods_path = "",
@ -44,11 +45,11 @@ struct SubgameSpec
const std::string &name = "", const std::string &name = "",
const std::string &menuicon_path = "", const std::string &menuicon_path = "",
const std::string &author = "", int release = 0, const std::string &author = "", int release = 0,
const bool moddable = true) : const bool moddable = true, const bool hidden = false) :
id(id), id(id),
name(name), author(author), release(release), path(path), name(name), author(author), release(release), path(path),
gamemods_path(gamemods_path), addon_mods_paths(addon_mods_paths), gamemods_path(gamemods_path), addon_mods_paths(addon_mods_paths),
menuicon_path(menuicon_path), moddable(moddable) menuicon_path(menuicon_path), moddable(moddable), hidden(hidden)
{ {
} }

View File

@ -330,6 +330,10 @@ int ModApiMainMenu::l_get_games(lua_State *L)
lua_pushboolean(L, game.moddable); lua_pushboolean(L, game.moddable);
lua_settable(L, top_lvl2); 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_pushstring(L, "addon_mods_paths");
lua_newtable(L); lua_newtable(L);
int table2 = lua_gettop(L); int table2 = lua_gettop(L);