Menu-FN: Change the way we install custom game data. It should be way more

stable and consistent now.
This commit is contained in:
Marco Cawthorne 2021-01-23 14:54:31 +01:00
parent dbb53d151a
commit 178f988167
5 changed files with 103 additions and 23 deletions

View File

@ -4,7 +4,7 @@ copy_mod()
{
mkdir ./_release/"$1"
cp -R ./"$1"/data.pk3dir ./_release/"$1"/data.pk3dir
#cp ./"$1".fmf ./_release/"$1".fmf
cp ./"$1".fmf ./_release/"$1".fmf
rm ./_release/"$1"/data.pk3dir/*.lno
}
@ -42,6 +42,7 @@ copy_file logos/fte.png
touch ./_release/fteqw_goes_here
mv ./_release/doc/release-readme ./_release/README
cp ./valve.fmf ./_release/default.fmf
cp ./installed.lst ./_release/installed.lst
rm -rf ./_release/platform/test_maps.pk3dir
# build the tarball

View File

@ -82,6 +82,7 @@ m_init(void)
print(LICENSE_TEXT);
print("\n\n");
registercommand("menu_updates");
registercommand("menu_customgame");
registercommand("map_background");
registercommand("menu_musicstart");
@ -116,12 +117,10 @@ m_init(void)
Music_MenuStart();
}
if (autocvar_menu_updating || !autocvar_menu_installedpackages) {
if (game_updatesavailable() == 1 || autocvar_menu_updating) {
shaderforname("logo_avi", "{\n{\nvideomap av:media/logo.avi\n}\n}");
g_menupage = PAGE_UPDATES;
}
if (g_iModInstallCache >= 0) {
g_menupage = PAGE_CUSTOMGAME;
}
Menu_AutoScale();
Menu_GammaHack();
@ -131,7 +130,6 @@ m_init(void)
void
Menu_RendererRestarted(string rendererdesc)
{
print("Menu_REndereresrsatr\n");
Menu_AutoScale();
Menu_GammaHack();
}
@ -218,6 +216,13 @@ m_draw(vector screensize)
0.5f, 0, font_console);
main_draw();
/* HACK! after a custom game switches .fmf files, we need to force restart
* our menu. I'm so, so sorry. No, RendererRestarted doesn't see fs_game
* fast enough either. */
if (cvar_string("fs_game") != games[gameinfo_current].gamedir) {
localcmd("menu_restart\n");
}
oldtime = time;
}
@ -308,6 +313,10 @@ m_consolecommand(string cmd)
case "menu_musicloop":
Music_ParseLoop(argv(1));
break;
case "menu_updates":
g_menupage = PAGE_UPDATES;
m_intro_skip();
break;
case "menu_customgame":
g_menupage = PAGE_CUSTOMGAME;
m_intro_skip();

View File

@ -28,10 +28,6 @@ CMainButton customgame_btnRefresh;
CMainButton customgame_btnDeactivate;
CMainButton customgame_btnDone;
/* get package id */
var int g_iModInstallCache;
var string g_strModInstallCache;
int
game_getpackageid(string pkgname)
{
@ -53,6 +49,48 @@ game_getpackageid(string pkgname)
return -1;
}
/* return 1 if any of the packages are pending, installing, or corrupt */
int
game_updatesavailable(void)
{
/* 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 "":
if (updates[id].installed == "") {
return 1;
} else if (updates[id].installed == "pending") {
return 1;
}
break;
case "pending":
return 1;
break;
case "enabled":
break;
case "present":
return 1;
break;
case "corrupt":
return 1;
break;
default:
/* we're currently installing stuff */
return 1;
break;
}
}
/* everything is installed */
return 0;
}
#if 0
/* get installing id */
void
game_getinstallcache(void)
@ -91,6 +129,7 @@ game_writeinstallcache(int id, string gamedir)
fclose(fs_cache);
}
}
#endif
/* local game/mod info parsing */
void
@ -247,7 +286,9 @@ games_init(void)
}
}
#if 0
game_getinstallcache();
#endif
if (gameinfo_current == -1) {
print("^1FATAL ERROR: NO MODINFO.TXT FOR CURRENT MOD FOUND!\n");
@ -256,6 +297,7 @@ games_init(void)
}
}
#if 0
void
customgame_installstart(int gameid)
{
@ -344,6 +386,7 @@ customgame_installframe(void)
customgame_installend();
}
#endif
void
customgame_btnactivate_start(void)
@ -353,7 +396,7 @@ customgame_btnactivate_start(void)
games_set(nextgame);
#if 1
localcmd(sprintf("fs_changegame %s %s.fmf\n", games[nextgame].gamedir, games[nextgame].gamedir));
localcmd(sprintf("fs_changegame %s %s.fmf\nfs_changegame %s -\n", games[nextgame].gamedir, games[nextgame].gamedir, games[nextgame].gamedir));
#else
/* some games/mods inherit other directories */
if (games[nextgame].fallback_dir) {
@ -369,9 +412,11 @@ customgame_btnactivate_start(void)
localcmd("menu_musicstart\n");
}
/* download the .fmf and switch games immediately */
void
customgame_btninstall_start(void)
{
#if 0
int id = customgame_lbMods.GetSelected();
string st;
@ -387,6 +432,10 @@ customgame_btninstall_start(void)
game_writeinstallcache(id, games[id].gamedir);
customgame_installend();
#else
int nextgame = customgame_lbMods.GetSelected();
localcmd(sprintf("fs_changegame %s http://www.frag-net.com/mods/%s.fmf\n", games[nextgame].gamedir, games[nextgame].gamedir));
#endif
}
void
@ -522,16 +571,18 @@ menu_customgame_draw(void)
WField_Static(162, 180, m_reslbl[IDS_MODREQ_TITLE], 320, 260,
col_prompt_text, 1.0f, 2, font_label_p);
}
customgame_sbMods.SetMax(gameinfo_count-1); /* don't show our current game */
#if 0
if (g_iModInstallCache >= 0) {
customgame_installframe();
}
#endif
}
void
menu_customgame_input(float evtype, float scanx, float chary, float devid)
{
if (g_iModInstallCache == -1)
Widget_Input(fn_customgame, evtype, scanx, chary, devid);
Widget_Input(fn_customgame, evtype, scanx, chary, devid);
}

View File

@ -276,6 +276,8 @@ menu_updates_refresh(void)
void
menu_updates_draw(void)
{
static int old_enabled;
float fl = 0;
if (!g_updates_initialized) {
@ -283,15 +285,12 @@ menu_updates_draw(void)
/* query until 1 package is ready */
for (int i = 0; (getpackagemanagerinfo(i, GPMI_NAME)); i++) {
string cat = getpackagemanagerinfo(i, GPMI_CATEGORY);
if (cat == "Plugins/") {
continue;
}
if (cat == "Mod/") {
continue;
}
string installed = getpackagemanagerinfo(i, GPMI_INSTALLED);
/* increment to keep track */
if (installed == "enabled")
old_enabled++;
pkg_ready = 1;
break;
}
if (pkg_ready == 1) {
@ -340,6 +339,21 @@ menu_updates_draw(void)
WLabel_Static(350, 143, "Preview:", 11, 11, [1,1,1],
1.0f, 0, font_arial);
/* check if we've got any more packages than upon init */
int new_packages;
for (int i = 0; (getpackagemanagerinfo(i, GPMI_NAME)); i++) {
string installed = getpackagemanagerinfo(i, GPMI_INSTALLED);
/* increment to keep track */
if (installed == "enabled")
new_packages++;
}
if (old_enabled != new_packages) {
old_enabled = new_packages;
localcmd("menu_restart\nmenu_updates\n");
}
if (g_updates_previewpic)
drawpic([g_menuofs[0]+350+3,g_menuofs[1]+160+3], g_updates_previewpic, [256,128], [1,1,1], 1.0f);
}

View File

@ -87,13 +87,13 @@ CUpdateList::Draw(void)
}
break;
case "pending":
colo = [0.5,0.5,0.5];
colo *= [0.5,0.5,0.5];
break;
case "enabled":
colo = colo;
break;
case "present":
colo = colo;
colo = colo * [0.5,0.5,0.5];
break;
case "corrupt":
colo = [1,0,0] * sin(time);
@ -114,6 +114,11 @@ CUpdateList::Draw(void)
colo = [1,0,0];
else
colo = [0,0,0];
} else if (updates[i].installed == "in") {
if ((time*2) & 1)
colo = [1,1,0];
else
colo = [0,0,0];
}
/* Game */