Menu-FN: Add WEBMENU define, to get rid of all the filesystem
searches related to mods and packages for potential web builds
This commit is contained in:
parent
76b26fd3af
commit
be0df99c8d
7 changed files with 196 additions and 138 deletions
|
@ -106,6 +106,8 @@ typedef struct
|
|||
var int gameinfo_current = -1;
|
||||
int gameinfo_count;
|
||||
gameinfo_t *games;
|
||||
|
||||
#ifndef WEBMENU
|
||||
string(float id, float b) getgamedirinfo = #0;
|
||||
string(int packageidx, int desiredfield) getpackagemanagerinfo = #0;
|
||||
|
||||
|
@ -141,6 +143,7 @@ typedef struct
|
|||
} update_t;
|
||||
int update_count;
|
||||
update_t *updates;
|
||||
#endif
|
||||
|
||||
int g_menupage;
|
||||
|
||||
|
|
|
@ -252,13 +252,14 @@ m_draw(vector screensize)
|
|||
|
||||
main_draw();
|
||||
|
||||
#ifndef WEBMENU
|
||||
/* 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(sprintf("gameinfo_gamedir %s\nmenu_restart\n", cvar_string("fs_game")));
|
||||
}
|
||||
|
||||
#endif
|
||||
oldtime = time;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
/* the menu specific variables */
|
||||
#ifndef WEBMENU
|
||||
CWidget fn_customgame;
|
||||
CFrame customgame_frMods;
|
||||
CModList customgame_lbMods;
|
||||
|
@ -133,6 +134,7 @@ game_updateinstallcount(void)
|
|||
/* everything is installed */
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* local game/mod info parsing */
|
||||
void
|
||||
|
@ -143,6 +145,7 @@ games_set(int id)
|
|||
cvar_set("com_fullgamename", games[id].game);
|
||||
}
|
||||
|
||||
#ifndef WEBMENU
|
||||
void
|
||||
customgame_liblist_parse(int id, string strKey, string strValue)
|
||||
{
|
||||
|
@ -461,9 +464,93 @@ games_check_liblist(int id, string gamedirname)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
void
|
||||
customgame_btnactivate_start(void)
|
||||
{
|
||||
int nextgame = customgame_lbMods.GetSelected();
|
||||
|
||||
games_set(nextgame);
|
||||
|
||||
#if 0
|
||||
localcmd(sprintf("gamedir %s %s.fmf\nfs_changegame %s -\n", games[nextgame].gamedir, games[nextgame].gamedir, games[nextgame].gamedir));
|
||||
#else
|
||||
if (games[nextgame].info_type == GAMEINFO_MANIFEST)
|
||||
localcmd(sprintf("gamedir %s %s.fmf\nfs_changegame %s -\n", games[nextgame].gamedir, games[nextgame].gamedir, games[nextgame].gamedir));
|
||||
else if (games[nextgame].info_type == GAMEINFO_LIBLIST) {
|
||||
/* some games/mods inherit other directories */
|
||||
if (games[nextgame].fallback_dir) {
|
||||
localcmd(sprintf("gamedir \"logos;platform;%s;%s;%s\"\n", games[nextgame].base_dir, games[nextgame].fallback_dir, games[nextgame].gamedir));
|
||||
} else {
|
||||
localcmd(sprintf("gamedir \"logos;platform;%s;%s\"\n", games[nextgame].base_dir, games[nextgame].gamedir));
|
||||
}
|
||||
} else
|
||||
localcmd(sprintf("gamedir \"logos;platform;%s;%s\"\n", games[nextgame].base_dir, games[nextgame].gamedir));
|
||||
#endif
|
||||
|
||||
localcmd("stopmusic\nsnd_restart\nwait\nvid_reload\n");
|
||||
localcmd("menu_restart\n");
|
||||
localcmd("menu_customgame\n");
|
||||
localcmd("menu_musicstart\n");
|
||||
}
|
||||
|
||||
/* download the .fmf and switch games immediately */
|
||||
void
|
||||
customgame_btninstall_start(void)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
void
|
||||
customgame_btndeactivate_start(void)
|
||||
{
|
||||
localcmd(sprintf("gamedir %s\n", GAME_DIR));
|
||||
localcmd("stopmusic\nsnd_restart\nwait\nvid_reload\n");
|
||||
localcmd("menu_restart\n");
|
||||
localcmd("menu_customgame\n");
|
||||
localcmd("menu_musicstart\n");
|
||||
}
|
||||
|
||||
void
|
||||
customgame_btndone_start(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
customgame_sbmods_changed(int val)
|
||||
{
|
||||
customgame_lbMods.SetScroll(val);
|
||||
}
|
||||
|
||||
void
|
||||
customgame_lbmods_changed(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
games_init(void)
|
||||
{
|
||||
#ifndef WEBMENU
|
||||
int id;
|
||||
int foundself = 0;
|
||||
string gamedirname;
|
||||
|
@ -549,93 +636,41 @@ games_init(void)
|
|||
crash();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
customgame_btnactivate_start(void)
|
||||
{
|
||||
int nextgame = customgame_lbMods.GetSelected();
|
||||
|
||||
games_set(nextgame);
|
||||
|
||||
#if 0
|
||||
localcmd(sprintf("gamedir %s %s.fmf\nfs_changegame %s -\n", games[nextgame].gamedir, games[nextgame].gamedir, games[nextgame].gamedir));
|
||||
#else
|
||||
if (games[nextgame].info_type == GAMEINFO_MANIFEST)
|
||||
localcmd(sprintf("gamedir %s %s.fmf\nfs_changegame %s -\n", games[nextgame].gamedir, games[nextgame].gamedir, games[nextgame].gamedir));
|
||||
else if (games[nextgame].info_type == GAMEINFO_LIBLIST) {
|
||||
/* some games/mods inherit other directories */
|
||||
if (games[nextgame].fallback_dir) {
|
||||
localcmd(sprintf("gamedir \"logos;platform;%s;%s;%s\"\n", games[nextgame].base_dir, games[nextgame].fallback_dir, games[nextgame].gamedir));
|
||||
} else {
|
||||
localcmd(sprintf("gamedir \"logos;platform;%s;%s\"\n", games[nextgame].base_dir, games[nextgame].gamedir));
|
||||
}
|
||||
} else
|
||||
localcmd(sprintf("gamedir \"logos;platform;%s;%s\"\n", games[nextgame].base_dir, games[nextgame].gamedir));
|
||||
int id = 0;
|
||||
string gamedirname = cvar_string("game");
|
||||
gameinfo_count++;
|
||||
games = memalloc(sizeof(gameinfo_t) * gameinfo_count);
|
||||
/* Fill in the defaults */
|
||||
games[id].game = gamedirname;
|
||||
games[id].gamedir = gamedirname;
|
||||
games[id].base_dir = GAME_DIR;
|
||||
games[id].url_info = "";
|
||||
games[id].url_dl = "";
|
||||
games[id].version = "1.0";
|
||||
games[id].size = 0;
|
||||
games[id].type = "Both";
|
||||
games[id].nomodels = 0;
|
||||
games[id].nosprays = 0;
|
||||
games[id].mpentity = "info_player_deathmatch";
|
||||
games[id].gamedll = "progs.dat";
|
||||
games[id].startmap = "map c0a0\n";
|
||||
games[id].trainingmap = "map t0a0\n";
|
||||
games[id].cldll = 1;
|
||||
games[id].hlversion = "1000";
|
||||
games[id].svonly = 0;
|
||||
games[id].installed = 1;
|
||||
games[id].chatroom = gamedirname;
|
||||
games[id].readme = "readme.txt";
|
||||
games[id].pkgid = -1;
|
||||
games[id].steambg = 0;
|
||||
#endif
|
||||
|
||||
localcmd("stopmusic\nsnd_restart\nwait\nvid_reload\n");
|
||||
localcmd("menu_restart\n");
|
||||
localcmd("menu_customgame\n");
|
||||
localcmd("menu_musicstart\n");
|
||||
}
|
||||
|
||||
/* download the .fmf and switch games immediately */
|
||||
void
|
||||
customgame_btninstall_start(void)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
void
|
||||
customgame_btndeactivate_start(void)
|
||||
{
|
||||
localcmd(sprintf("gamedir %s\n", GAME_DIR));
|
||||
localcmd("stopmusic\nsnd_restart\nwait\nvid_reload\n");
|
||||
localcmd("menu_restart\n");
|
||||
localcmd("menu_customgame\n");
|
||||
localcmd("menu_musicstart\n");
|
||||
}
|
||||
|
||||
void
|
||||
customgame_btndone_start(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
customgame_sbmods_changed(int val)
|
||||
{
|
||||
customgame_lbMods.SetScroll(val);
|
||||
}
|
||||
|
||||
void
|
||||
customgame_lbmods_changed(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
menu_customgame_init(void)
|
||||
{
|
||||
#ifndef WEBMENU
|
||||
fn_customgame = spawn(CWidget);
|
||||
customgame_dlgWait = spawn(CDialog);
|
||||
|
||||
|
@ -691,11 +726,13 @@ menu_customgame_init(void)
|
|||
customgame_sbMods.SetCallback(customgame_sbmods_changed);
|
||||
customgame_sbMods.SetMax(gameinfo_count);
|
||||
Widget_Add(fn_customgame, customgame_sbMods);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
menu_customgame_draw(void)
|
||||
{
|
||||
#ifndef WEBMENU
|
||||
Header_Draw(HEAD_CUSTOM);
|
||||
Widget_Draw(fn_customgame);
|
||||
|
||||
|
@ -723,10 +760,13 @@ menu_customgame_draw(void)
|
|||
}
|
||||
|
||||
customgame_sbMods.SetMax(gameinfo_count-1); /* don't show our current game */
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
menu_customgame_input(float evtype, float scanx, float chary, float devid)
|
||||
{
|
||||
#ifndef WEBMENU
|
||||
Widget_Input(fn_customgame, evtype, scanx, chary, devid);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -373,6 +373,7 @@ menu_main_draw(void)
|
|||
WLabel_Static(235, 440, m_reslbl[IDS_MAIN_QUITHELP], HELPTXT_SIZE, HELPTXT_SIZE,
|
||||
col_help,1.0f, 0, font_label);
|
||||
} else {
|
||||
#ifndef WEBMENU
|
||||
/* Don't even attempt to display the logo.avi otherwise */
|
||||
if (games[gameinfo_current].steambg == 0 && checkcommand("ffmpeg_videobitrate")) {
|
||||
drawpic([g_menuofs[0],g_menuofs[1] + 70], g_bmp[LOGO_AVI],
|
||||
|
@ -385,7 +386,7 @@ menu_main_draw(void)
|
|||
drawpic([g_menuofs[0] + 320 - (ofs[0] / 2),g_menuofs[1] + 48], g_bmp[LOGO_STATIC],
|
||||
ofs, [1,1,1], 1.0f);
|
||||
}
|
||||
|
||||
#endif
|
||||
Widget_Draw(fn_main);
|
||||
WLabel_Static(235, 216, m_reslbl[IDS_MAIN_NEWGAMEHELP], HELPTXT_SIZE, HELPTXT_SIZE,
|
||||
col_help,1.0f, 0, font_label);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#define FN_UPDATE_IMGURL "http://www.frag-net.com/dl/img/%s.jpg"
|
||||
|
||||
#ifndef WEBMENU
|
||||
enum
|
||||
{
|
||||
GPMI_NAME, // name of the package, for use with the pkg command.
|
||||
|
@ -125,61 +126,6 @@ up_sbupdates_changed(int val)
|
|||
up_lbUpdates.SetScroll(val);
|
||||
}
|
||||
|
||||
/* Init */
|
||||
void
|
||||
menu_updates_init(void)
|
||||
{
|
||||
fn_updates = spawn(CWidget);
|
||||
|
||||
up_btnDone = spawn(CMainButton);
|
||||
up_btnDone.SetImage(BTN_DONE);
|
||||
up_btnDone.SetExecute(up_btndone_start);
|
||||
up_btnDone.SetPos(50,420+13);
|
||||
Widget_Add(fn_updates, up_btnDone);
|
||||
|
||||
up_btnApply = spawn(CMainButton);
|
||||
up_btnApply.SetImage(BTN_UPDATE);
|
||||
up_btnApply.SetExecute(up_btnapply_start);
|
||||
up_btnApply.SetPos(350+96,420+30);
|
||||
Widget_Add(fn_updates, up_btnApply);
|
||||
|
||||
up_btnInstall = spawn(CMainButton);
|
||||
up_btnInstall.SetImage(BTN_INSTALL);
|
||||
up_btnInstall.SetExecute(up_btninstall_start);
|
||||
up_btnInstall.SetPos(350,420);
|
||||
Widget_Add(fn_updates, up_btnInstall);
|
||||
|
||||
up_btnDelete = spawn(CMainButton);
|
||||
up_btnDelete.SetImage(BTN_DELETE);
|
||||
up_btnDelete.SetExecute(up_btnremove_start);
|
||||
up_btnDelete.SetPos(350+200,420);
|
||||
Widget_Add(fn_updates, up_btnDelete);
|
||||
|
||||
up_frUpdates = spawn(CFrame);
|
||||
up_frUpdates.SetPos(50,160);
|
||||
up_frUpdates.SetSize(200+50,250);
|
||||
Widget_Add(fn_updates, up_frUpdates);
|
||||
|
||||
up_lbUpdates = spawn(CUpdateList);
|
||||
up_lbUpdates.SetPos(53,163);
|
||||
up_lbUpdates.SetSize(194+50,244);
|
||||
up_lbUpdates.SetChanged(up_lbupdates_changed);
|
||||
up_lbUpdates.SetDClicked(up_toggleinstall);
|
||||
Widget_Add(fn_updates, up_lbUpdates);
|
||||
|
||||
up_sbUpdates = spawn(CScrollbar);
|
||||
up_sbUpdates.SetPos(53+194+50,160);
|
||||
up_sbUpdates.SetItemheight(18);
|
||||
up_sbUpdates.SetHeight(250);
|
||||
up_sbUpdates.SetCallback(up_sbupdates_changed);
|
||||
up_sbUpdates.SetMax(0);
|
||||
Widget_Add(fn_updates, up_sbUpdates);
|
||||
|
||||
up_frPreview = spawn(CFrame);
|
||||
up_frPreview.SetPos(350,160);
|
||||
up_frPreview.SetSize(256+6,128+6);
|
||||
Widget_Add(fn_updates, up_frPreview);
|
||||
}
|
||||
|
||||
void
|
||||
menu_updates_refresh(void)
|
||||
|
@ -270,11 +216,72 @@ menu_updates_refresh(void)
|
|||
up_lbUpdates.SetMax(update_count);
|
||||
up_lbUpdates.SetSelected(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Init */
|
||||
void
|
||||
menu_updates_init(void)
|
||||
{
|
||||
#ifndef WEBMENU
|
||||
fn_updates = spawn(CWidget);
|
||||
|
||||
up_btnDone = spawn(CMainButton);
|
||||
up_btnDone.SetImage(BTN_DONE);
|
||||
up_btnDone.SetExecute(up_btndone_start);
|
||||
up_btnDone.SetPos(50,420+13);
|
||||
Widget_Add(fn_updates, up_btnDone);
|
||||
|
||||
up_btnApply = spawn(CMainButton);
|
||||
up_btnApply.SetImage(BTN_UPDATE);
|
||||
up_btnApply.SetExecute(up_btnapply_start);
|
||||
up_btnApply.SetPos(350+96,420+30);
|
||||
Widget_Add(fn_updates, up_btnApply);
|
||||
|
||||
up_btnInstall = spawn(CMainButton);
|
||||
up_btnInstall.SetImage(BTN_INSTALL);
|
||||
up_btnInstall.SetExecute(up_btninstall_start);
|
||||
up_btnInstall.SetPos(350,420);
|
||||
Widget_Add(fn_updates, up_btnInstall);
|
||||
|
||||
up_btnDelete = spawn(CMainButton);
|
||||
up_btnDelete.SetImage(BTN_DELETE);
|
||||
up_btnDelete.SetExecute(up_btnremove_start);
|
||||
up_btnDelete.SetPos(350+200,420);
|
||||
Widget_Add(fn_updates, up_btnDelete);
|
||||
|
||||
up_frUpdates = spawn(CFrame);
|
||||
up_frUpdates.SetPos(50,160);
|
||||
up_frUpdates.SetSize(200+50,250);
|
||||
Widget_Add(fn_updates, up_frUpdates);
|
||||
|
||||
up_lbUpdates = spawn(CUpdateList);
|
||||
up_lbUpdates.SetPos(53,163);
|
||||
up_lbUpdates.SetSize(194+50,244);
|
||||
up_lbUpdates.SetChanged(up_lbupdates_changed);
|
||||
up_lbUpdates.SetDClicked(up_toggleinstall);
|
||||
Widget_Add(fn_updates, up_lbUpdates);
|
||||
|
||||
up_sbUpdates = spawn(CScrollbar);
|
||||
up_sbUpdates.SetPos(53+194+50,160);
|
||||
up_sbUpdates.SetItemheight(18);
|
||||
up_sbUpdates.SetHeight(250);
|
||||
up_sbUpdates.SetCallback(up_sbupdates_changed);
|
||||
up_sbUpdates.SetMax(0);
|
||||
Widget_Add(fn_updates, up_sbUpdates);
|
||||
|
||||
up_frPreview = spawn(CFrame);
|
||||
up_frPreview.SetPos(350,160);
|
||||
up_frPreview.SetSize(256+6,128+6);
|
||||
Widget_Add(fn_updates, up_frPreview);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Drawing */
|
||||
void
|
||||
menu_updates_draw(void)
|
||||
{
|
||||
#ifndef WEBMENU
|
||||
static int old_enabled;
|
||||
|
||||
float fl = 0;
|
||||
|
@ -355,10 +362,13 @@ menu_updates_draw(void)
|
|||
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
menu_updates_input(float evtype, float scanx, float chary, float devid)
|
||||
{
|
||||
#ifndef WEBMENU
|
||||
Widget_Input(fn_updates, evtype, scanx, chary, devid);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WEBMENU
|
||||
#define MODSERVER_REQ_LIST 100
|
||||
#define MODSERVER_REQ_ITEM 101
|
||||
|
||||
|
@ -214,3 +215,4 @@ ModServer_URI_Callback(float id, float code, string data, int resourcebytes)
|
|||
print(sprintf("^1ModServer_URI_Callback^7: Unknown request id %d with code %d\n", id, code));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define ML_COL_3 [240,180,20] / 255 // Other
|
||||
#define ML_COL_4 [200,200,200] / 255 // Grey Info
|
||||
|
||||
|
||||
#ifndef WEBMENU
|
||||
class CUpdateList:CWidget
|
||||
{
|
||||
int m_size[2];
|
||||
|
@ -229,3 +229,4 @@ CUpdateList::GetSelectedItem(void)
|
|||
}
|
||||
return m_entries[m_selected];
|
||||
}*/
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue