From 085607e022e367be29d14fd35d6ca6c337b120e9 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sun, 24 Jan 2021 00:11:08 +0100 Subject: [PATCH] Menu-FN: Show the updater only when we've got 0/X packages installed for the current game. --- src/menu-fn/entry.cpp | 2 +- src/menu-fn/m_customgame.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/menu-fn/entry.cpp b/src/menu-fn/entry.cpp index c4112ff4..a37dbe59 100644 --- a/src/menu-fn/entry.cpp +++ b/src/menu-fn/entry.cpp @@ -117,7 +117,7 @@ m_init(void) Music_MenuStart(); } - if (game_updatesavailable() == 1 || autocvar_menu_updating) { + if (game_updateinstallcount() == 0 || autocvar_menu_updating) { shaderforname("logo_avi", "{\n{\nvideomap av:media/logo.avi\n}\n}"); g_menupage = PAGE_UPDATES; } diff --git a/src/menu-fn/m_customgame.cpp b/src/menu-fn/m_customgame.cpp index c77702a5..b831d1cb 100644 --- a/src/menu-fn/m_customgame.cpp +++ b/src/menu-fn/m_customgame.cpp @@ -90,6 +90,42 @@ game_updatesavailable(void) return 0; } +int +game_updateinstallcount(void) +{ + int count; + + /* look for the valid packages in the gameinfo pkgname */ + int pkgcount = tokenize(games[gameinfo_current].pkgname); + + for (int i = 0i; i < pkgcount; i++) { + int id = game_getpackageid(argv(i)); + string status = getpackagemanagerinfo(id, GPMI_INSTALLED); + + switch (status) { + case "": + break; + case "pending": + break; + case "enabled": + count++; + break; + case "present": + count++; + break; + case "corrupt": + count++; + break; + default: + /* we're currently installing stuff */ + break; + } + } + + /* everything is installed */ + return count; +} + #if 0 /* get installing id */ void