Make updates menu searchable, make qi plugin a little more friendly.
This commit is contained in:
parent
226c1cf6b4
commit
cae062b142
17 changed files with 611 additions and 342 deletions
|
@ -1164,8 +1164,7 @@ SET(FTE_PLUG_QI true CACHE BOOL "Compile Quake-Injnector plugin.")
|
|||
IF(FTE_PLUG_QI)
|
||||
ADD_LIBRARY(plug_qi MODULE
|
||||
plugins/plugin.c
|
||||
plugins/qi/qi.c
|
||||
plugins/emailnot/md5.c
|
||||
plugins/qi/qi.c
|
||||
plugins/jabber/xml.c
|
||||
)
|
||||
SET_TARGET_PROPERTIES(plug_qi PROPERTIES COMPILE_DEFINITIONS "FTEPLUGIN;${FTE_LIB_DEFINES}")
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -364,7 +364,7 @@ int dotofs;
|
|||
|
||||
static void MenuTooltipChange(emenu_t *menu, const char *text)
|
||||
{
|
||||
unsigned int MAX_CHARS=1024;
|
||||
unsigned int MAX_CHARS=2048;
|
||||
menutooltip_t *mtt;
|
||||
if (menu->tooltip)
|
||||
{
|
||||
|
@ -2081,13 +2081,14 @@ menuoption_t *M_PrevSelectableItem(emenu_t *m, menuoption_t *old, qboolean wrap)
|
|||
|
||||
void M_Complex_Key(emenu_t *currentmenu, int key, int unicode)
|
||||
{
|
||||
menuoption_t *mi;
|
||||
if (!currentmenu)
|
||||
return; //erm...
|
||||
|
||||
M_CheckMouseMove(currentmenu);
|
||||
|
||||
if (currentmenu->key)
|
||||
if (currentmenu->key(key, currentmenu))
|
||||
if (currentmenu->key(currentmenu, key, unicode))
|
||||
return;
|
||||
|
||||
if (currentmenu->selecteditem && currentmenu->selecteditem->common.type == mt_custom && (key == K_DOWNARROW || key == K_KP_DOWNARROW || key == K_GP_DPAD_DOWN || key == K_GP_LEFT_THUMB_DOWN || key == K_GP_DIAMOND_CONFIRM || key == K_GP_DIAMOND_ALTCONFIRM || key == K_UPARROW || key == K_KP_UPARROW || key == K_GP_DPAD_UP || key == K_GP_LEFT_THUMB_UP || key == K_TAB || key == K_MWHEELUP || key == K_MWHEELDOWN || key == K_PGUP || key == K_PGDN))
|
||||
|
@ -2206,28 +2207,31 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode)
|
|||
|
||||
case K_MWHEELUP:
|
||||
case K_MWHEELDOWN:
|
||||
if (currentmenu->mouseitem)
|
||||
mi = currentmenu->mouseitem;
|
||||
if (!mi)
|
||||
mi = currentmenu->selecteditem;
|
||||
if (mi)
|
||||
{
|
||||
qboolean handled = false;
|
||||
switch(currentmenu->mouseitem->common.type)
|
||||
switch(mi->common.type)
|
||||
{
|
||||
case mt_combo:
|
||||
if (mousecursor_x >= currentmenu->xpos + currentmenu->mouseitem->common.posx + currentmenu->mouseitem->combo.captionwidth + 3*8)
|
||||
if (mousecursor_x >= currentmenu->xpos + mi->common.posx + mi->combo.captionwidth + 3*8)
|
||||
{
|
||||
MC_Combo_Key(¤tmenu->mouseitem->combo, key);
|
||||
MC_Combo_Key(&mi->combo, key);
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
case mt_checkbox:
|
||||
if (mousecursor_x >= currentmenu->xpos + currentmenu->mouseitem->common.posx + currentmenu->mouseitem->check.textwidth + 3*8)
|
||||
if (mousecursor_x >= currentmenu->xpos + mi->common.posx + mi->check.textwidth + 3*8)
|
||||
{
|
||||
MC_CheckBox_Key(¤tmenu->mouseitem->check, currentmenu, key);
|
||||
MC_CheckBox_Key(&mi->check, currentmenu, key);
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
case mt_custom:
|
||||
if (currentmenu->mouseitem->custom.key)
|
||||
handled = currentmenu->mouseitem->custom.key(¤tmenu->mouseitem->custom, currentmenu, key, unicode);
|
||||
if (mi->custom.key)
|
||||
handled = mi->custom.key(&mi->custom, currentmenu, key, unicode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2235,7 +2239,7 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode)
|
|||
|
||||
if (handled)
|
||||
{
|
||||
currentmenu->selecteditem = currentmenu->mouseitem;
|
||||
currentmenu->selecteditem = mi;
|
||||
if (currentmenu->cursoritem)
|
||||
currentmenu->cursoritem->common.posy = currentmenu->selecteditem->common.posy + (currentmenu->selecteditem->common.height-currentmenu->cursoritem->common.height)/2;
|
||||
break;
|
||||
|
@ -2326,7 +2330,7 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode)
|
|||
|
||||
|
||||
|
||||
qboolean MC_Main_Key (int key, emenu_t *menu) //here purly to restart demos.
|
||||
qboolean MC_Main_Key (emenu_t *menu, int key, unsigned int unicode) //here purly to restart demos.
|
||||
{
|
||||
if (key == K_ESCAPE || key == K_GP_BACK || key == K_GP_DIAMOND_CANCEL || key == K_MOUSE2)
|
||||
{
|
||||
|
|
|
@ -765,7 +765,7 @@ static void SL_PostDraw (emenu_t *menu)
|
|||
}
|
||||
}
|
||||
}
|
||||
static qboolean SL_Key (int key, emenu_t *menu)
|
||||
static qboolean SL_Key (emenu_t *menu, int key, unsigned int unicode)
|
||||
{
|
||||
serverlist_t *info = (serverlist_t*)(menu + 1);
|
||||
|
||||
|
@ -1370,7 +1370,7 @@ static void M_QuickConnect_PreDraw(emenu_t *menu)
|
|||
}
|
||||
}
|
||||
|
||||
static qboolean M_QuickConnect_Key (int key, emenu_t *menu)
|
||||
static qboolean M_QuickConnect_Key (emenu_t *menu, int key, unsigned int unicode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1183,7 +1183,7 @@ void Com_CompleateOSFileName(char *name)
|
|||
strcpy(name, compleatenamename);
|
||||
}
|
||||
|
||||
qboolean M_Media_Key (int key, emenu_t *menu)
|
||||
qboolean M_Media_Key (emenu_t *menu, int key, unsigned int unicode)
|
||||
{
|
||||
int dir;
|
||||
if (key == K_ESCAPE || key == K_GP_BACK || key == K_MOUSE2)
|
||||
|
|
|
@ -449,7 +449,7 @@ typedef struct {
|
|||
soundcardinfo_t *card;
|
||||
} audiomenuinfo_t;
|
||||
|
||||
qboolean M_Audio_Key (int key, struct emenu_s *menu)
|
||||
qboolean M_Audio_Key (struct emenu_s *menu, int key, unsigned int unicode)
|
||||
{
|
||||
int i;
|
||||
audiomenuinfo_t *info = menu->data;
|
||||
|
|
|
@ -57,7 +57,7 @@ void M_Script_Remove (emenu_t *menu)
|
|||
|
||||
M_Script_Option(menu, "cancel", false);
|
||||
}
|
||||
qboolean M_Script_Key (int key, emenu_t *menu)
|
||||
qboolean M_Script_Key (struct emenu_s *menu, int key, unsigned int unicode)
|
||||
{
|
||||
if (menu->selecteditem && menu->selecteditem->common.type == mt_edit)
|
||||
return false;
|
||||
|
|
|
@ -1081,7 +1081,7 @@ void M_Help_Draw (emenu_t *m)
|
|||
R2D_ScalePic ((vid.width-width)/2, (vid.height-height)/2, width, height, pic);
|
||||
}
|
||||
}
|
||||
qboolean M_Help_Key (int key, emenu_t *m)
|
||||
qboolean M_Help_Key (struct emenu_s *m, int key, unsigned int unicode)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
|
|
|
@ -329,7 +329,7 @@ struct emenu_s {
|
|||
|
||||
void (*reset) (struct emenu_s *); //called after a video mode switch / shader reload.
|
||||
void (*remove) (struct emenu_s *);
|
||||
qboolean (*key) (int key, struct emenu_s *); //true if key was handled
|
||||
qboolean (*key) (struct emenu_s *, int key, unsigned int unicode); //true if key was handled
|
||||
void (*predraw) (struct emenu_s *);
|
||||
void (*postdraw) (struct emenu_s *);
|
||||
menuoption_t *options;
|
||||
|
|
|
@ -789,7 +789,7 @@ typedef struct
|
|||
} gamepath[8];
|
||||
struct manpack_s //FIXME: this struct should be replaced with packagemanager info instead.
|
||||
{
|
||||
int type;
|
||||
enum manifestdeptype_e type;
|
||||
char *path; //the 'pure' name
|
||||
char *prefix;
|
||||
qboolean crcknown; //if the crc was specified
|
||||
|
|
|
@ -4896,6 +4896,8 @@ static void FS_ReloadPackFilesFlags(unsigned int reloadflags)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!FS_GamedirIsOkay(dir))
|
||||
continue;
|
||||
FS_AddGameDirectory(&oldpaths, dir, reloadflags, fl);
|
||||
}
|
||||
}
|
||||
|
@ -4912,15 +4914,6 @@ static void FS_ReloadPackFilesFlags(unsigned int reloadflags)
|
|||
char *dir = fs_manifest->gamepath[i].path;
|
||||
if (dir && !(fs_manifest->gamepath[i].flags&GAMEDIR_BASEGAME))
|
||||
{
|
||||
//don't allow leading dots, hidden files are evil.
|
||||
//don't allow complex paths. those are evil too.
|
||||
if (!*dir || *dir == '.' || !strcmp(dir, ".") || strstr(dir, "..") || strstr(dir, "/")
|
||||
|| strstr(dir, "\\") || strstr(dir, ":") )
|
||||
{
|
||||
Con_Printf ("Gamedir should be a single filename, not a path\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < countof(fs_manifest->gamepath); j++)
|
||||
{
|
||||
char *dir2 = fs_manifest->gamepath[j].path;
|
||||
|
@ -4930,12 +4923,28 @@ static void FS_ReloadPackFilesFlags(unsigned int reloadflags)
|
|||
if (j < countof(fs_manifest->gamepath))
|
||||
continue; //already loaded above. don't mess up gameonly_gamedir.
|
||||
|
||||
fl = SPF_EXPLICIT;
|
||||
if (!(fs_manifest->gamepath[i].flags&GAMEDIR_READONLY))
|
||||
fl |= SPF_WRITABLE;
|
||||
if (fs_manifest->gamepath[i].flags&GAMEDIR_PRIVATE)
|
||||
fl |= SPF_PRIVATE;
|
||||
if (fs_manifest->gamepath[i].flags&GAMEDIR_QSHACK)
|
||||
fl |= SPF_QSHACK;
|
||||
|
||||
if (*dir == '*')
|
||||
{
|
||||
{ //just in case... shouldn't be needed.
|
||||
dir++;
|
||||
fl |= GAMEDIR_PRIVATE;
|
||||
}
|
||||
|
||||
if (fs_manifest->gamepath[i].flags & GAMEDIR_SPECIAL)
|
||||
; //don't.
|
||||
else
|
||||
{
|
||||
FS_AddGameDirectory(&oldpaths, dir, reloadflags, SPF_EXPLICIT|SPF_WRITABLE);
|
||||
//don't use evil gamedir names.
|
||||
if (!FS_GamedirIsOkay(dir))
|
||||
continue;
|
||||
FS_AddGameDirectory(&oldpaths, dir, reloadflags, fl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7259,6 +7268,7 @@ static void FS_ChangeMod_f(void)
|
|||
int packages = 0;
|
||||
const char *arg = "?";
|
||||
qboolean okay = false;
|
||||
char *dir = NULL;
|
||||
|
||||
if (Cmd_IsInsecure())
|
||||
return;
|
||||
|
@ -7302,6 +7312,11 @@ static void FS_ChangeMod_f(void)
|
|||
arg = Cmd_Argv(i++);
|
||||
packagespaths[packages-1].subpath = Z_StrDup(arg);
|
||||
}
|
||||
else if (!strcmp(arg, "dir"))
|
||||
{
|
||||
arg = Cmd_Argv(i++);
|
||||
Z_StrDupPtr(&dir, arg);
|
||||
}
|
||||
else if (!strcmp(arg, "map"))
|
||||
{
|
||||
Z_Free(fs_loadedcommand);
|
||||
|
@ -7324,13 +7339,14 @@ static void FS_ChangeMod_f(void)
|
|||
}
|
||||
|
||||
if (okay)
|
||||
COM_Gamedir("", packagespaths);
|
||||
COM_Gamedir(dir?dir:"", packagespaths);
|
||||
else
|
||||
{
|
||||
Con_Printf("unsupported args: %s\n", arg);
|
||||
Z_Free(fs_loadedcommand);
|
||||
fs_loadedcommand = NULL;
|
||||
}
|
||||
Z_Free(dir);
|
||||
|
||||
for (i = 0; i < packages; i++)
|
||||
{
|
||||
|
|
|
@ -90,7 +90,7 @@ void Menu_Download_Update(void);
|
|||
typedef struct
|
||||
{
|
||||
char *description;
|
||||
void (*Update) (const char *url, vfsfile_t *out);
|
||||
void (*Update) (const char *url, vfsfile_t *out, qboolean favourcache);
|
||||
#define plugupdatesourcefuncs_name "UpdateSource"
|
||||
} plugupdatesourcefuncs_t;
|
||||
qboolean PM_RegisterUpdateSource(void *module, plugupdatesourcefuncs_t *funcs);
|
||||
|
|
|
@ -971,6 +971,7 @@ static qhandle_t QDECL Plug_FS_Open(const char *fname, qhandle_t *outhandle, int
|
|||
#ifndef WEBCLIENT
|
||||
f = NULL;
|
||||
#else
|
||||
Con_DPrintf("Plugin %s requesting %s\n", currentplug->name, fname);
|
||||
handle = Plug_NewStreamHandle(STREAM_WEB);
|
||||
pluginstreamarray[handle].dl = HTTP_CL_Get(fname, NULL, Plug_DownloadComplete);
|
||||
pluginstreamarray[handle].dl->user_num = handle;
|
||||
|
|
|
@ -1570,7 +1570,10 @@ void DL_Close(struct dl_download *dl)
|
|||
#ifdef MULTITHREAD
|
||||
dl->threadenable = false;
|
||||
if (dl->threadctx)
|
||||
{
|
||||
Sys_WaitOnThread(dl->threadctx);
|
||||
dl->threadctx = NULL;
|
||||
}
|
||||
#endif
|
||||
if (dl->file && dl->file->seekstyle < SS_PIPE)
|
||||
VFS_SEEK(dl->file, 0);
|
||||
|
|
|
@ -136,7 +136,7 @@ struct dl_download
|
|||
/*not used internally by the backend, but used by HTTP_CL_Get/thread wrapper*/
|
||||
struct dl_download *next;
|
||||
qboolean (*notifystarted) (struct dl_download *dl, char *mimetype); //mime can be null for some protocols, read dl->totalsize for size. false if the mime just isn't acceptable.
|
||||
void (*notifycomplete) (struct dl_download *dl);
|
||||
void (*notifycomplete) (struct dl_download *dl); //lets the requester know that the download context is complete and the handle is no longer valid.
|
||||
};
|
||||
|
||||
vfsfile_t *VFSPIPE_Open(int refs, qboolean seekable); //refs should be 1 or 2, to say how many times it must be closed before its actually closed, so both ends can close separately
|
||||
|
|
|
@ -730,7 +730,7 @@ void SV_Map_f (void)
|
|||
sv.mapchangelocked = false;
|
||||
}
|
||||
else
|
||||
PM_LoadMap(mangled, sep);
|
||||
PM_LoadMap(mangled, va("%s %s\n", Cmd_Argv(0), COM_QuotedString(sep, expanded, sizeof(expanded), false)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1003,7 +1003,10 @@ void SV_Map_f (void)
|
|||
if (!isrestart)
|
||||
{
|
||||
if (q3singleplayer)
|
||||
{
|
||||
Cvar_ForceSet(gametype, "2");//singleplayer
|
||||
Cvar_ForceSet(&deathmatch, "0");//for non-q3 type stuff to not get confused..
|
||||
}
|
||||
else if (gametype->value == 2)
|
||||
Cvar_ForceSet(gametype, "");//force to ffa deathmatch
|
||||
}
|
||||
|
|
|
@ -516,6 +516,8 @@ static void QI_AddPackages(xmltree_t *qifile)
|
|||
}
|
||||
static void QI_RunMap(xmltree_t *qifile, const char *map)
|
||||
{
|
||||
char gamedir[65];
|
||||
char buf[256];
|
||||
if (!qifile)
|
||||
{
|
||||
return;
|
||||
|
@ -527,10 +529,35 @@ static void QI_RunMap(xmltree_t *qifile, const char *map)
|
|||
if (!*map || strchr(map, '\\') || strchr(map, '\"') || strchr(map, '\n') || strchr(map, ';'))
|
||||
map = "";
|
||||
|
||||
strcpy(gamedir, "id1");
|
||||
{
|
||||
char descbuf[1024];
|
||||
xmltree_t *tech = XML_ChildOfTree(qifile, "techinfo", 0);
|
||||
const char *cmdline = XML_GetChildBody(tech, "commandline", "");
|
||||
while (cmdline)
|
||||
{
|
||||
cmdline = cmdfuncs->ParseToken(cmdline, descbuf, sizeof(descbuf), NULL);
|
||||
if (!strcmp(descbuf, "-game"))
|
||||
cmdline = cmdfuncs->ParseToken(cmdline, gamedir, sizeof(gamedir), NULL);
|
||||
else if (!strcmp(descbuf, "-hipnotic") || !strcmp(descbuf, "-rogue") || !strcmp(descbuf, "-quoth"))
|
||||
{
|
||||
if (!*gamedir)
|
||||
strcpy(gamedir, descbuf+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmdfuncs->AddText("fs_changemod spmap \"", false);
|
||||
cmdfuncs->AddText(map, false);
|
||||
cmdfuncs->AddText("\"", false);
|
||||
cmdfuncs->AddText("fs_changemod", false);
|
||||
if (*gamedir)
|
||||
{
|
||||
cmdfuncs->AddText(" dir ", false);
|
||||
cmdfuncs->AddText(cmdfuncs->QuotedString(gamedir, buf, sizeof(buf), false), false);
|
||||
}
|
||||
if (map && *map)
|
||||
{
|
||||
cmdfuncs->AddText(" spmap ", false);
|
||||
cmdfuncs->AddText(cmdfuncs->QuotedString(map, buf, sizeof(buf), false), false);
|
||||
}
|
||||
QI_AddPackages(qifile);
|
||||
// Con_Printf("Command: %s\n", cmd);
|
||||
cmdfuncs->AddText("\n", false);
|
||||
|
@ -548,13 +575,13 @@ void VARGS VFS_PRINTF(vfsfile_t *vf, const char *format, ...)
|
|||
|
||||
VFS_PUTS(vf, string);
|
||||
}
|
||||
static void QI_WriteUpdateList(vfsfile_t *pminfo)
|
||||
static void QI_WriteUpdateList(xmltree_t *database, vfsfile_t *pminfo)
|
||||
{
|
||||
xmltree_t *file;
|
||||
char descbuf[1024], *d, *nl;
|
||||
|
||||
if (thedatabase)
|
||||
for (file = thedatabase->child; file; file = file->sibling)
|
||||
if (database)
|
||||
for (file = database->child; file; file = file->sibling)
|
||||
{
|
||||
const char *id = XML_GetParameter(file, "id", "unnamed");
|
||||
const char *rating = XML_GetParameter(file, "rating", "");
|
||||
|
@ -937,7 +964,7 @@ static void QDECL QI_Tick(double realtime, double gametime)
|
|||
else
|
||||
{
|
||||
VFS_PRINTF(packagemanager, "version 3\n");
|
||||
QI_WriteUpdateList(packagemanager);
|
||||
QI_WriteUpdateList(thedatabase, packagemanager);
|
||||
}
|
||||
VFS_CLOSE(packagemanager);
|
||||
packagemanager = NULL;
|
||||
|
@ -981,8 +1008,48 @@ static void QI_ExecuteCommand_f(void)
|
|||
QI_RefreshMapList(true);
|
||||
}
|
||||
|
||||
void QI_GenPackages(const char *url, vfsfile_t *pipe)
|
||||
void QI_GenPackages(const char *url, vfsfile_t *pipe, qboolean favourcache)
|
||||
{
|
||||
if (thedatabase)
|
||||
{ //already read it?... fine.
|
||||
VFS_PRINTF(pipe, "version 3\n");
|
||||
QI_WriteUpdateList(thedatabase, pipe);
|
||||
VFS_CLOSE(pipe);
|
||||
return;
|
||||
}
|
||||
else if (favourcache)
|
||||
{ //just read the cached copy from disk. use the menu to update it.
|
||||
xmltree_t *t = NULL;
|
||||
qhandle_t fd = -1;
|
||||
int ofs = 0;
|
||||
|
||||
int flen = filefuncs->Open("**plugconfig", &fd, 1);
|
||||
if (flen >= 0)
|
||||
{
|
||||
qbyte *file = malloc(flen+1);
|
||||
file[flen] = 0;
|
||||
filefuncs->Read(fd, file, flen);
|
||||
filefuncs->Close(fd);
|
||||
|
||||
do
|
||||
{
|
||||
if (t)
|
||||
XML_Destroy(t);
|
||||
t = XML_Parse(file, &ofs, flen, false, "");
|
||||
} while(t && !t->child);
|
||||
free(file);
|
||||
|
||||
VFS_PRINTF(pipe, "version 3\n");
|
||||
QI_WriteUpdateList(t, pipe);
|
||||
|
||||
if (t)
|
||||
XML_Destroy(t);
|
||||
VFS_CLOSE(pipe);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//fill it in once we've got it...
|
||||
if (packagemanager)
|
||||
VFS_CLOSE(packagemanager);
|
||||
packagemanager = pipe;
|
||||
|
|
Loading…
Reference in a new issue