2021-02-17 02:17:28 -08:00
|
|
|
/*
|
2020-04-07 05:46:23 -07:00
|
|
|
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
2019-08-31 19:18:15 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
2019-01-16 08:43:50 -08:00
|
|
|
|
2020-09-05 23:37:36 -07:00
|
|
|
/* the menu specific variables */
|
|
|
|
CWidget fn_customgame;
|
|
|
|
CFrame customgame_frMods;
|
|
|
|
CModList customgame_lbMods;
|
|
|
|
CScrollbar customgame_sbMods;
|
|
|
|
CDialog customgame_dlgWait;
|
|
|
|
|
|
|
|
CMainButton customgame_btnActivate;
|
|
|
|
CMainButton customgame_btnInstall;
|
|
|
|
CMainButton customgame_btnVisit;
|
|
|
|
CMainButton customgame_btnRefresh;
|
|
|
|
CMainButton customgame_btnDeactivate;
|
|
|
|
CMainButton customgame_btnDone;
|
|
|
|
|
|
|
|
int
|
|
|
|
game_getpackageid(string pkgname)
|
|
|
|
{
|
|
|
|
string f;
|
|
|
|
|
|
|
|
for (int i = 0; (getpackagemanagerinfo(i, GPMI_NAME)); i++) {
|
|
|
|
string name;
|
|
|
|
name = getpackagemanagerinfo(i, GPMI_NAME);
|
|
|
|
|
|
|
|
/* Spike started randomly putting version numbers into package names */
|
|
|
|
f = sprintf("%s=%s", pkgname, getpackagemanagerinfo(i, GPMI_VERSION));
|
|
|
|
|
|
|
|
if (name == f) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no package id whatsoever */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-01-23 05:54:31 -08:00
|
|
|
/* 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);
|
2021-01-23 16:54:14 -08:00
|
|
|
|
|
|
|
if (id == -1)
|
|
|
|
continue;
|
|
|
|
|
2021-01-23 05:54:31 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-01-23 15:11:08 -08:00
|
|
|
int
|
|
|
|
game_updateinstallcount(void)
|
|
|
|
{
|
2021-02-08 04:35:15 -08:00
|
|
|
int count = 0;
|
2021-01-23 15:11:08 -08:00
|
|
|
|
2021-01-23 15:13:01 -08:00
|
|
|
/* always return something positive when no packages are defined */
|
|
|
|
if (games[gameinfo_current].pkgname == "") {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-01-23 15:11:08 -08:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2021-01-23 05:54:31 -08:00
|
|
|
#if 0
|
2020-09-05 23:37:36 -07:00
|
|
|
/* get installing id */
|
|
|
|
void
|
|
|
|
game_getinstallcache(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
filestream fs_cache;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
fs_cache = fopen("mcache.dat", FILE_READ);
|
|
|
|
|
|
|
|
if (fs_cache >= 0) {
|
|
|
|
g_iModInstallCache = (int)stof(fgets(fs_cache));
|
|
|
|
g_strModInstallCache = fgets(fs_cache);
|
|
|
|
fclose(fs_cache);
|
|
|
|
} else {
|
|
|
|
g_iModInstallCache = -1;
|
|
|
|
g_strModInstallCache = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
print(sprintf("id: %i, name: %s\n", ret, g_strModInstallCache));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write installing id */
|
|
|
|
void
|
|
|
|
game_writeinstallcache(int id, string gamedir)
|
|
|
|
{
|
|
|
|
filestream fs_cache;
|
|
|
|
|
|
|
|
fs_cache = fopen("mcache.dat", FILE_WRITE);
|
|
|
|
g_iModInstallCache = id;
|
|
|
|
g_strModInstallCache = gamedir;
|
|
|
|
|
|
|
|
if (fs_cache >= 0) {
|
|
|
|
fputs(fs_cache, sprintf("%i\n",id));
|
|
|
|
fputs(fs_cache, gamedir);
|
|
|
|
fclose(fs_cache);
|
|
|
|
}
|
|
|
|
}
|
2021-01-23 05:54:31 -08:00
|
|
|
#endif
|
2020-09-05 23:37:36 -07:00
|
|
|
|
2020-03-31 16:08:01 -07:00
|
|
|
/* local game/mod info parsing */
|
2020-06-30 23:31:16 -07:00
|
|
|
void
|
|
|
|
games_set(int id)
|
2019-03-19 12:01:24 -07:00
|
|
|
{
|
|
|
|
gameinfo_current = id;
|
|
|
|
setwindowcaption(games[id].game);
|
|
|
|
cvar_set("com_fullgamename", games[id].game);
|
|
|
|
}
|
|
|
|
|
2020-06-30 23:31:16 -07:00
|
|
|
void
|
|
|
|
games_init(void)
|
2019-01-18 12:05:42 -08:00
|
|
|
{
|
2019-09-02 06:53:13 -07:00
|
|
|
int id;
|
2019-01-18 12:05:42 -08:00
|
|
|
float county;
|
|
|
|
string gamedirname;
|
|
|
|
string gamedescription;
|
|
|
|
gameinfo_count = 0;
|
|
|
|
|
2019-09-02 06:53:13 -07:00
|
|
|
for (id = 0; (gamedirname = getgamedirinfo(id, 0)); id++) {
|
2020-04-01 03:27:45 -07:00
|
|
|
/* skip any manifest (or modinfo) without cvars setting things */
|
|
|
|
if (getgamedirinfo(id, 2) == "") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-01-18 12:05:42 -08:00
|
|
|
gameinfo_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gameinfo_count) {
|
2019-09-02 06:53:13 -07:00
|
|
|
print("^1FATAL ERROR: NO VALID MOD DIRECTORIES FOUND!\n");
|
2019-01-18 12:05:42 -08:00
|
|
|
crash();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
games = memalloc(sizeof(gameinfo_t) * gameinfo_count);
|
|
|
|
|
2020-04-02 13:43:37 -07:00
|
|
|
if (!games)
|
|
|
|
error(sprintf("Attempting to allocate mod data for %i entries failed\n", gameinfo_count));
|
|
|
|
|
2019-09-02 06:53:13 -07:00
|
|
|
for (id = 0; (gamedirname = getgamedirinfo(id, 0)); id++) {
|
2020-04-01 03:27:45 -07:00
|
|
|
gamedescription = getgamedirinfo(id, 2);
|
|
|
|
|
|
|
|
/* CONT: skip any manifest (or modinfo) without cvars setting things */
|
|
|
|
if (gamedescription == "") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-01-18 17:21:44 -08:00
|
|
|
county = tokenize_console(gamedescription);
|
2019-09-02 06:53:13 -07:00
|
|
|
|
2019-01-18 12:05:42 -08:00
|
|
|
/* Fill in the defaults */
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].game = gamedirname;
|
|
|
|
games[id].gamedir = gamedirname;
|
|
|
|
games[id].url_info = "";
|
|
|
|
games[id].url_dl = "";
|
|
|
|
games[id].version = "1.0";
|
|
|
|
games[id].size = 0;
|
2020-04-12 06:50:42 -07:00
|
|
|
games[id].type = "Both";
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].nomodels = 0;
|
2021-02-17 02:28:09 -08:00
|
|
|
games[id].nosprays = 0;
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].mpentity = "info_player_deathmatch";
|
|
|
|
games[id].gamedll = "progs.dat";
|
|
|
|
games[id].startmap = "c0a0";
|
|
|
|
games[id].trainingmap = "t0a0";
|
|
|
|
games[id].cldll = 1;
|
2020-04-12 06:50:42 -07:00
|
|
|
games[id].hlversion = "1000";
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].svonly = 0;
|
2020-03-31 16:08:01 -07:00
|
|
|
games[id].installed = 1;
|
2020-08-06 14:26:51 -07:00
|
|
|
games[id].chatroom = gamedirname;
|
2020-09-05 23:52:10 -07:00
|
|
|
games[id].readme = "readme.txt";
|
2020-09-05 23:37:36 -07:00
|
|
|
games[id].pkgid = -1;
|
2019-01-18 12:05:42 -08:00
|
|
|
|
2020-04-12 06:50:42 -07:00
|
|
|
for (int i = 0; i < county; i++) {
|
|
|
|
switch(argv(i)) {
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_game":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].game = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_gamedir":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].gamedir = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_fallback_dir":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].fallback_dir = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_url_info":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].url_info = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_url_dl":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].url_dl = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_version":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].version = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_size":
|
|
|
|
games[id].size = (int)stof(argv(i+1));
|
2019-09-02 06:53:13 -07:00
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_svonly":
|
|
|
|
games[id].svonly = (int)stof(argv(i+1));
|
2019-09-02 06:53:13 -07:00
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_cldll":
|
|
|
|
games[id].cldll = (int)stof(argv(i+1));
|
2019-09-02 06:53:13 -07:00
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_type":
|
2020-04-03 04:36:42 -07:00
|
|
|
switch (strtolower(argv(i+1))) {
|
|
|
|
case "multiplayer_only":
|
2020-09-05 23:37:36 -07:00
|
|
|
case "multiplayer only":
|
2020-04-03 04:36:42 -07:00
|
|
|
case "mp":
|
|
|
|
case "multi":
|
|
|
|
case "multiplayer":
|
|
|
|
games[id].type = "Multiplayer";
|
|
|
|
break;
|
|
|
|
case "singleplayer_only":
|
2020-09-05 23:37:36 -07:00
|
|
|
case "singleplayer only":
|
2020-04-03 04:36:42 -07:00
|
|
|
case "sp":
|
|
|
|
case "single":
|
|
|
|
case "singleplayer":
|
|
|
|
games[id].type = "Singleplayer";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
games[id].type = "Both";
|
|
|
|
}
|
2019-09-02 06:53:13 -07:00
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_hlversion":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].hlversion = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_nomodels":
|
|
|
|
games[id].nomodels = (int)stof(argv(i+1));
|
2019-09-02 06:53:13 -07:00
|
|
|
break;
|
2021-02-17 02:28:09 -08:00
|
|
|
case "gameinfo_nosprays":
|
|
|
|
games[id].nosprays = (int)stof(argv(i+1));
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_mpentity":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].mpentity = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_gamedll":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].gamedll = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_startmap":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].startmap = argv(i+1);
|
|
|
|
break;
|
2020-04-01 03:27:45 -07:00
|
|
|
case "gameinfo_trainingmap":
|
2019-09-02 06:53:13 -07:00
|
|
|
games[id].trainingmap = argv(i+1);
|
|
|
|
break;
|
2020-08-06 14:26:51 -07:00
|
|
|
case "gameinfo_pkgname":
|
|
|
|
games[id].pkgname = argv(i+1);
|
2020-09-05 23:37:36 -07:00
|
|
|
games[id].pkgid = game_getpackageid(games[id].pkgname);
|
2020-08-06 14:26:51 -07:00
|
|
|
break;
|
2021-03-05 15:23:59 -08:00
|
|
|
case "gameinfo_pkgfile":
|
|
|
|
games[id].pkgfile = argv(i+1);
|
|
|
|
break;
|
2020-08-06 14:26:51 -07:00
|
|
|
case "gameinfo_chatroom":
|
|
|
|
games[id].chatroom = argv(i+1);
|
2020-04-12 06:50:42 -07:00
|
|
|
break;
|
2020-09-05 23:52:10 -07:00
|
|
|
case "gameinfo_readme":
|
|
|
|
games[id].readme = argv(i+1);
|
2021-03-05 15:23:59 -08:00
|
|
|
break;
|
|
|
|
case "gameinfo_introvideo":
|
|
|
|
games[id].introvideo = argv(i+1);
|
2020-09-05 23:52:10 -07:00
|
|
|
break;
|
2019-09-02 06:53:13 -07:00
|
|
|
default:
|
|
|
|
break;
|
2019-01-18 12:05:42 -08:00
|
|
|
}
|
|
|
|
}
|
2020-10-06 05:27:44 -07:00
|
|
|
if (games[id].gamedir == cvar_string("gameinfo_gamedir")) {
|
2019-09-02 06:53:13 -07:00
|
|
|
games_set(id);
|
2019-01-18 12:05:42 -08:00
|
|
|
}
|
|
|
|
}
|
2019-09-02 06:53:13 -07:00
|
|
|
|
2021-01-23 05:54:31 -08:00
|
|
|
#if 0
|
2020-09-05 23:37:36 -07:00
|
|
|
game_getinstallcache();
|
2021-01-23 05:54:31 -08:00
|
|
|
#endif
|
2020-09-05 23:37:36 -07:00
|
|
|
|
2019-01-18 12:05:42 -08:00
|
|
|
if (gameinfo_current == -1) {
|
2019-09-02 06:53:13 -07:00
|
|
|
print("^1FATAL ERROR: NO MODINFO.TXT FOR CURRENT MOD FOUND!\n");
|
2019-01-18 12:05:42 -08:00
|
|
|
crash();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-23 05:54:31 -08:00
|
|
|
#if 0
|
2020-09-05 23:37:36 -07:00
|
|
|
void
|
|
|
|
customgame_installstart(int gameid)
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
count = tokenize(games[gameid].pkgname);
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
int pkgid = game_getpackageid(argv(i));
|
|
|
|
localcmd(sprintf("pkg add %s\n", argv(i)));
|
|
|
|
print(sprintf("Marking package %s for install.\n",
|
|
|
|
argv(i)));
|
|
|
|
}
|
2019-01-18 12:05:42 -08:00
|
|
|
|
2020-09-05 23:37:36 -07:00
|
|
|
game_writeinstallcache(gameid, games[gameid].gamedir);
|
|
|
|
localcmd("pkg apply\n");
|
|
|
|
print("Starting installation of custom game packages\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
customgame_installend(void)
|
|
|
|
{
|
|
|
|
int gid = g_iModInstallCache;
|
|
|
|
print("install-end!\n");
|
|
|
|
|
|
|
|
localcmd(sprintf("fs_changegame %s http://www.frag-net.com/mods/%s.fmf\n", g_strModInstallCache, g_strModInstallCache));
|
|
|
|
game_writeinstallcache(-1, g_strModInstallCache);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
customgame_installframe(void)
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
float perc;
|
|
|
|
float c;
|
|
|
|
int loading;
|
|
|
|
|
|
|
|
/* graphical frame */
|
|
|
|
customgame_dlgWait.Draw();
|
|
|
|
WField_Static(162, 180, "Installing mod data...", 320, 260,
|
|
|
|
col_prompt_text, 1.0f, 2, font_label_p);
|
|
|
|
|
|
|
|
/* download percentage */
|
|
|
|
perc = 0.0f;
|
|
|
|
loading = FALSE;
|
|
|
|
|
|
|
|
/* a game can have multiple packages associated */
|
|
|
|
id = g_iModInstallCache;
|
|
|
|
c = tokenize(games[id].pkgname);
|
|
|
|
|
|
|
|
/* go through all invididual packages */
|
|
|
|
for (float i = 0; i < c; i++) {
|
|
|
|
string st;
|
|
|
|
int pkgid;
|
|
|
|
|
|
|
|
/* package query */
|
|
|
|
pkgid = game_getpackageid(argv(i));
|
|
|
|
st = getpackagemanagerinfo(pkgid, GPMI_INSTALLED);
|
|
|
|
|
|
|
|
/* filter out statuses so we can calculate percentage */
|
|
|
|
switch (st) {
|
|
|
|
case "":
|
|
|
|
case "pending":
|
|
|
|
case "enabled":
|
|
|
|
case "present":
|
|
|
|
case "corrupt":
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
perc += stof(st);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all packages need to be 'enabled', else fail to end */
|
|
|
|
if (st != "enabled")
|
|
|
|
loading = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* display download percentage we calculated */
|
|
|
|
perc = perc / c;
|
2020-09-05 23:52:10 -07:00
|
|
|
WField_Static(162, 220, sprintf("%d%%", perc), 320, 260,
|
|
|
|
[1,1,1], 1.0f, 2, font_label_p);
|
2020-09-06 00:10:28 -07:00
|
|
|
WField_Static(162, 260, "Service provided by frag-net.com through archive.org", 320, 260,
|
2020-09-05 23:52:10 -07:00
|
|
|
[1,1,1], 1.0f, 2, font_label);
|
2020-09-05 23:37:36 -07:00
|
|
|
|
|
|
|
/* not everything has been downloaded */
|
|
|
|
if (loading == TRUE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
customgame_installend();
|
|
|
|
}
|
2021-01-23 05:54:31 -08:00
|
|
|
#endif
|
2019-01-18 12:05:42 -08:00
|
|
|
|
2020-06-30 23:31:16 -07:00
|
|
|
void
|
|
|
|
customgame_btnactivate_start(void)
|
2019-01-18 12:05:42 -08:00
|
|
|
{
|
|
|
|
int nextgame = customgame_lbMods.GetSelected();
|
2019-01-18 17:21:44 -08:00
|
|
|
|
2019-03-19 12:01:24 -07:00
|
|
|
games_set(nextgame);
|
2019-03-24 08:27:36 -07:00
|
|
|
|
2020-10-06 05:27:44 -07:00
|
|
|
#if 1
|
2021-01-23 05:54:31 -08:00
|
|
|
localcmd(sprintf("fs_changegame %s %s.fmf\nfs_changegame %s -\n", games[nextgame].gamedir, games[nextgame].gamedir, games[nextgame].gamedir));
|
2020-04-06 17:47:21 -07:00
|
|
|
#else
|
2020-03-31 16:08:01 -07:00
|
|
|
/* some games/mods inherit other directories */
|
2019-03-24 08:27:36 -07:00
|
|
|
if (games[nextgame].fallback_dir) {
|
|
|
|
localcmd(sprintf("gamedir \"%s;%s\"\n", games[nextgame].fallback_dir, games[nextgame].gamedir));
|
|
|
|
} else {
|
|
|
|
localcmd(sprintf("gamedir \"%s\"\n", games[nextgame].gamedir));
|
|
|
|
}
|
2020-04-06 17:47:21 -07:00
|
|
|
#endif
|
2019-03-24 08:27:36 -07:00
|
|
|
|
2020-10-06 05:27:44 -07:00
|
|
|
localcmd("stopmusic\nsnd_restart\nwait\nvid_reload\n");
|
|
|
|
localcmd("menu_restart\n");
|
|
|
|
localcmd("menu_customgame\n");
|
|
|
|
localcmd("menu_musicstart\n");
|
2020-03-31 16:08:01 -07:00
|
|
|
}
|
2020-06-30 23:31:16 -07:00
|
|
|
|
2021-01-23 05:54:31 -08:00
|
|
|
/* download the .fmf and switch games immediately */
|
2020-06-30 23:31:16 -07:00
|
|
|
void
|
|
|
|
customgame_btninstall_start(void)
|
2020-03-31 16:08:01 -07:00
|
|
|
{
|
2021-01-23 05:54:31 -08:00
|
|
|
#if 0
|
2020-09-05 23:37:36 -07:00
|
|
|
int id = customgame_lbMods.GetSelected();
|
|
|
|
string st;
|
|
|
|
|
|
|
|
st = getpackagemanagerinfo(games[id].pkgid, GPMI_INSTALLED);
|
|
|
|
|
|
|
|
print(st);
|
|
|
|
print("\n");
|
|
|
|
|
|
|
|
if (st != "enabled") {
|
|
|
|
customgame_installstart(id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
game_writeinstallcache(id, games[id].gamedir);
|
|
|
|
customgame_installend();
|
2021-01-23 05:54:31 -08:00
|
|
|
#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
|
2019-01-18 12:05:42 -08:00
|
|
|
}
|
2020-06-30 23:31:16 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
customgame_btndeactivate_start(void)
|
2019-01-18 12:05:42 -08:00
|
|
|
{
|
2020-10-06 05:27:44 -07:00
|
|
|
localcmd(sprintf("fs_changegame %s %s.fmf\n", GAME_DIR, GAME_DIR));
|
2020-03-30 14:48:13 -07:00
|
|
|
localcmd("stopmusic\nsnd_restart\nwait\nvid_reload\n");
|
2019-09-02 06:53:13 -07:00
|
|
|
localcmd("menu_restart\n");
|
|
|
|
localcmd("menu_customgame\n");
|
2020-10-06 05:27:44 -07:00
|
|
|
localcmd("menu_musicstart\n");
|
2019-01-18 12:05:42 -08:00
|
|
|
}
|
|
|
|
|
2020-06-30 23:31:16 -07:00
|
|
|
void
|
|
|
|
customgame_btndone_start(void)
|
2019-01-18 12:05:42 -08:00
|
|
|
{
|
|
|
|
static void customgame_btndone_end(void) {
|
|
|
|
g_menupage = PAGE_MAIN;
|
|
|
|
}
|
|
|
|
localsound("../media/launch_dnmenu1.wav");
|
|
|
|
header.SetStartEndPos(45,45,70,348);
|
|
|
|
header.SetStartEndSize(460,80,156,26);
|
|
|
|
header.m_lerp = 0.0f;
|
|
|
|
header.m_visible = TRUE;
|
|
|
|
header.SetHeader(HEAD_CUSTOM);
|
|
|
|
header.SetExecute(customgame_btndone_end);
|
|
|
|
}
|
2020-06-30 23:31:16 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
customgame_sbmods_changed(int val)
|
2019-01-28 18:40:14 -08:00
|
|
|
{
|
|
|
|
customgame_lbMods.SetScroll(val);
|
|
|
|
}
|
2019-01-18 12:05:42 -08:00
|
|
|
|
2020-06-30 23:31:16 -07:00
|
|
|
void
|
|
|
|
customgame_lbmods_changed(void)
|
2020-03-31 16:08:01 -07:00
|
|
|
{
|
|
|
|
int gid = customgame_lbMods.GetSelected();
|
|
|
|
|
|
|
|
if (games[gid].installed == TRUE) {
|
|
|
|
customgame_btnActivate.SetExecute(customgame_btnactivate_start);
|
|
|
|
customgame_btnInstall.SetExecute(__NULL__);
|
|
|
|
} else {
|
|
|
|
customgame_btnActivate.SetExecute(__NULL__);
|
|
|
|
customgame_btnInstall.SetExecute(customgame_btninstall_start);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-30 23:31:16 -07:00
|
|
|
void
|
|
|
|
menu_customgame_init(void)
|
2018-12-27 14:53:24 -08:00
|
|
|
{
|
2019-01-18 12:05:42 -08:00
|
|
|
fn_customgame = spawn(CWidget);
|
2020-03-31 16:08:01 -07:00
|
|
|
customgame_dlgWait = spawn(CDialog);
|
2019-01-18 12:05:42 -08:00
|
|
|
|
|
|
|
customgame_btnActivate = spawn(CMainButton);
|
|
|
|
customgame_btnActivate.SetImage(BTN_ACTIVATE);
|
|
|
|
customgame_btnActivate.SetPos(15,140);
|
|
|
|
customgame_btnActivate.SetExecute(customgame_btnactivate_start);
|
|
|
|
Widget_Add(fn_customgame, customgame_btnActivate);
|
|
|
|
|
|
|
|
customgame_btnInstall = spawn(CMainButton);
|
|
|
|
customgame_btnInstall.SetImage(BTN_INSTALL);
|
|
|
|
customgame_btnInstall.SetPos(15,172);
|
|
|
|
Widget_Add(fn_customgame, customgame_btnInstall);
|
|
|
|
|
|
|
|
customgame_btnVisit = spawn(CMainButton);
|
|
|
|
customgame_btnVisit.SetImage(BTN_VISITWEB);
|
|
|
|
customgame_btnVisit.SetPos(15,204);
|
|
|
|
Widget_Add(fn_customgame, customgame_btnVisit);
|
|
|
|
|
|
|
|
customgame_btnRefresh = spawn(CMainButton);
|
|
|
|
customgame_btnRefresh.SetImage(BTN_REFRESHLIST);
|
|
|
|
customgame_btnRefresh.SetPos(15,236);
|
2020-03-31 16:08:01 -07:00
|
|
|
customgame_btnRefresh.SetExecute(ModServer_Refresh);
|
2019-01-18 12:05:42 -08:00
|
|
|
Widget_Add(fn_customgame, customgame_btnRefresh);
|
|
|
|
|
|
|
|
customgame_btnDeactivate = spawn(CMainButton);
|
|
|
|
customgame_btnDeactivate.SetImage(BTN_DEACTIVATE);
|
|
|
|
customgame_btnDeactivate.SetPos(15,300);
|
|
|
|
customgame_btnDeactivate.SetExecute(customgame_btndeactivate_start);
|
|
|
|
Widget_Add(fn_customgame, customgame_btnDeactivate);
|
|
|
|
|
|
|
|
customgame_btnDone = spawn(CMainButton);
|
|
|
|
customgame_btnDone.SetImage(BTN_DONE);
|
|
|
|
customgame_btnDone.SetPos(15,332);
|
|
|
|
customgame_btnDone.SetExecute(customgame_btndone_start);
|
|
|
|
Widget_Add(fn_customgame, customgame_btnDone);
|
|
|
|
|
|
|
|
customgame_frMods = spawn(CFrame);
|
|
|
|
customgame_frMods.SetPos(141,156);
|
|
|
|
customgame_frMods.SetSize(463,289);
|
|
|
|
Widget_Add(fn_customgame, customgame_frMods);
|
|
|
|
|
|
|
|
customgame_lbMods = spawn(CModList);
|
|
|
|
customgame_lbMods.SetPos(144,159);
|
|
|
|
customgame_lbMods.SetSize(457,283);
|
2020-03-31 16:08:01 -07:00
|
|
|
customgame_lbMods.SetChanged(customgame_lbmods_changed);
|
2019-01-18 12:05:42 -08:00
|
|
|
Widget_Add(fn_customgame, customgame_lbMods);
|
2019-01-28 18:40:14 -08:00
|
|
|
|
|
|
|
customgame_sbMods = spawn(CScrollbar);
|
|
|
|
customgame_sbMods.SetPos(141+463,156);
|
|
|
|
customgame_sbMods.SetItemheight(29);
|
|
|
|
customgame_sbMods.SetHeight(289);
|
|
|
|
customgame_sbMods.SetCallback(customgame_sbmods_changed);
|
2020-10-08 03:03:52 -07:00
|
|
|
customgame_sbMods.SetMax(gameinfo_count);
|
2019-01-28 18:40:14 -08:00
|
|
|
Widget_Add(fn_customgame, customgame_sbMods);
|
2018-12-27 14:53:24 -08:00
|
|
|
}
|
|
|
|
|
2020-06-30 23:31:16 -07:00
|
|
|
void
|
|
|
|
menu_customgame_draw(void)
|
2018-12-27 14:53:24 -08:00
|
|
|
{
|
2020-12-30 08:19:21 -08:00
|
|
|
Header_Draw(HEAD_CUSTOM);
|
2019-01-18 12:05:42 -08:00
|
|
|
Widget_Draw(fn_customgame);
|
|
|
|
|
2019-01-28 18:40:14 -08:00
|
|
|
WLabel_Static(155, 143, m_reslbl[IDS_MODLIST_TYPE], 11, 11, [1,1,1],
|
2019-01-18 12:05:42 -08:00
|
|
|
1.0f, 0, font_arial);
|
2019-01-28 18:40:14 -08:00
|
|
|
WLabel_Static(201, 143, m_reslbl[IDS_MODLIST_NAME], 11, 11, [1,1,1],
|
2019-01-18 12:05:42 -08:00
|
|
|
1.0f, 0, font_arial);
|
2019-01-28 18:40:14 -08:00
|
|
|
WLabel_Static(321, 143, m_reslbl[IDS_MODLIST_VERSION], 11, 11, [1,1,1],
|
2019-01-18 12:05:42 -08:00
|
|
|
1.0f, 0, font_arial);
|
2019-01-28 18:40:14 -08:00
|
|
|
WLabel_Static(371, 143, m_reslbl[IDS_MODLIST_SIZE], 11, 11, [1,1,1],
|
2019-01-18 12:05:42 -08:00
|
|
|
1.0f, 0, font_arial);
|
2019-01-28 18:40:14 -08:00
|
|
|
WLabel_Static(421, 143, m_reslbl[IDS_MODLIST_RATING], 11, 11, [1,1,1],
|
2019-01-18 12:05:42 -08:00
|
|
|
1.0f, 0, font_arial);
|
2019-01-28 18:40:14 -08:00
|
|
|
WLabel_Static(471, 143, m_reslbl[IDS_MODLIST_INSTALLED], 11, 11, [1,1,1],
|
2019-01-18 12:05:42 -08:00
|
|
|
1.0f, 0, font_arial);
|
2019-01-28 18:40:14 -08:00
|
|
|
WLabel_Static(521, 143, m_reslbl[IDS_MODLIST_SERVERS], 11, 11, [1,1,1],
|
2019-01-18 12:05:42 -08:00
|
|
|
1.0f, 0, font_arial);
|
2019-01-28 18:40:14 -08:00
|
|
|
WLabel_Static(571, 143, m_reslbl[IDS_MODLIST_PLAYERS], 11, 11, [1,1,1],
|
2019-01-18 12:05:42 -08:00
|
|
|
1.0f, 0, font_arial);
|
2020-03-31 16:08:01 -07:00
|
|
|
|
|
|
|
if (g_iModServerLoading) {
|
|
|
|
customgame_dlgWait.Draw();
|
|
|
|
WField_Static(162, 180, m_reslbl[IDS_MODREQ_TITLE], 320, 260,
|
|
|
|
col_prompt_text, 1.0f, 2, font_label_p);
|
|
|
|
}
|
2021-01-23 05:54:31 -08:00
|
|
|
|
2020-03-31 16:08:01 -07:00
|
|
|
customgame_sbMods.SetMax(gameinfo_count-1); /* don't show our current game */
|
2020-09-05 23:37:36 -07:00
|
|
|
|
2021-01-23 05:54:31 -08:00
|
|
|
#if 0
|
2020-09-05 23:37:36 -07:00
|
|
|
if (g_iModInstallCache >= 0) {
|
|
|
|
customgame_installframe();
|
|
|
|
}
|
2021-01-23 05:54:31 -08:00
|
|
|
#endif
|
2018-12-27 14:53:24 -08:00
|
|
|
}
|
|
|
|
|
2020-06-30 23:31:16 -07:00
|
|
|
void
|
|
|
|
menu_customgame_input(float evtype, float scanx, float chary, float devid)
|
2018-12-27 14:53:24 -08:00
|
|
|
{
|
2021-01-23 05:54:31 -08:00
|
|
|
Widget_Input(fn_customgame, evtype, scanx, chary, devid);
|
2018-12-27 14:53:24 -08:00
|
|
|
}
|