mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-19 10:31:08 +00:00
Add filename tab-completion for "playdemo" and "record" commands
git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1219 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
b791f5379d
commit
917d8a4544
6 changed files with 112 additions and 10 deletions
|
@ -206,6 +206,9 @@ void CL_Stop_f (void)
|
||||||
cls.demofile = NULL;
|
cls.demofile = NULL;
|
||||||
cls.demorecording = false;
|
cls.demorecording = false;
|
||||||
Con_Printf ("Completed demo\n");
|
Con_Printf ("Completed demo\n");
|
||||||
|
|
||||||
|
// ericw -- update demo tab-completion list
|
||||||
|
DemoList_Rebuild ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -2083,6 +2083,7 @@ static void COM_Game_f (void)
|
||||||
R_NewGame ();
|
R_NewGame ();
|
||||||
}
|
}
|
||||||
ExtraMaps_NewGame ();
|
ExtraMaps_NewGame ();
|
||||||
|
DemoList_Rebuild ();
|
||||||
|
|
||||||
Con_Printf("\"game\" changed to \"%s\"\n", COM_SkipPath(com_gamedir));
|
Con_Printf("\"game\" changed to \"%s\"\n", COM_SkipPath(com_gamedir));
|
||||||
Con_Printf("enter \"exec quake.rc\" to load new configs\n");
|
Con_Printf("enter \"exec quake.rc\" to load new configs\n");
|
||||||
|
|
|
@ -815,6 +815,7 @@ typedef struct filelist_item_s
|
||||||
|
|
||||||
extern filelist_item_t *extralevels;
|
extern filelist_item_t *extralevels;
|
||||||
extern filelist_item_t *modlist;
|
extern filelist_item_t *modlist;
|
||||||
|
extern filelist_item_t *demolist;
|
||||||
|
|
||||||
typedef struct arg_completion_type_s
|
typedef struct arg_completion_type_s
|
||||||
{
|
{
|
||||||
|
@ -826,7 +827,9 @@ static const arg_completion_type_t arg_completion_types[] =
|
||||||
{
|
{
|
||||||
{ "map ", &extralevels },
|
{ "map ", &extralevels },
|
||||||
{ "changelevel ", &extralevels },
|
{ "changelevel ", &extralevels },
|
||||||
{ "game ", &modlist }
|
{ "game ", &modlist },
|
||||||
|
{ "record ", &demolist },
|
||||||
|
{ "playdemo ", &demolist }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int num_arg_completion_types =
|
static const int num_arg_completion_types =
|
||||||
|
|
|
@ -858,6 +858,7 @@ void Host_Init (void)
|
||||||
M_Init ();
|
M_Init ();
|
||||||
ExtraMaps_Init (); //johnfitz
|
ExtraMaps_Init (); //johnfitz
|
||||||
Modlist_Init (); //johnfitz
|
Modlist_Init (); //johnfitz
|
||||||
|
DemoList_Init (); //ericw
|
||||||
VID_Init ();
|
VID_Init ();
|
||||||
IN_Init ();
|
IN_Init ();
|
||||||
TexMgr_Init (); //johnfitz
|
TexMgr_Init (); //johnfitz
|
||||||
|
|
|
@ -103,6 +103,18 @@ void FileList_Add (const char *name, filelist_item_t **list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void FileList_Clear (filelist_item_t **list)
|
||||||
|
{
|
||||||
|
filelist_item_t *blah;
|
||||||
|
|
||||||
|
while (*list)
|
||||||
|
{
|
||||||
|
blah = (*list)->next;
|
||||||
|
Z_Free(*list);
|
||||||
|
*list = blah;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
filelist_item_t *extralevels;
|
filelist_item_t *extralevels;
|
||||||
|
|
||||||
void ExtraMaps_Add (const char *name)
|
void ExtraMaps_Add (const char *name)
|
||||||
|
@ -180,16 +192,9 @@ void ExtraMaps_Init (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtraMaps_Clear (void)
|
static void ExtraMaps_Clear (void)
|
||||||
{
|
{
|
||||||
filelist_item_t *blah;
|
FileList_Clear(&extralevels);
|
||||||
|
|
||||||
while (extralevels)
|
|
||||||
{
|
|
||||||
blah = extralevels->next;
|
|
||||||
Z_Free(extralevels);
|
|
||||||
extralevels = blah;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtraMaps_NewGame (void)
|
void ExtraMaps_NewGame (void)
|
||||||
|
@ -299,6 +304,92 @@ void Modlist_Init (void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
//ericw -- demo list management
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
filelist_item_t *demolist;
|
||||||
|
|
||||||
|
static void DemoList_Clear (void)
|
||||||
|
{
|
||||||
|
FileList_Clear (&demolist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemoList_Rebuild (void)
|
||||||
|
{
|
||||||
|
DemoList_Clear ();
|
||||||
|
DemoList_Init ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Factor out to a general-purpose file searching function
|
||||||
|
void DemoList_Init (void)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
WIN32_FIND_DATA fdat;
|
||||||
|
HANDLE fhnd;
|
||||||
|
#else
|
||||||
|
DIR *dir_p;
|
||||||
|
struct dirent *dir_t;
|
||||||
|
#endif
|
||||||
|
char filestring[MAX_OSPATH];
|
||||||
|
char demname[32];
|
||||||
|
char ignorepakdir[32];
|
||||||
|
searchpath_t *search;
|
||||||
|
pack_t *pak;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// we don't want to list the demos in id1 pakfiles,
|
||||||
|
// because these are not "add-on" demos
|
||||||
|
q_snprintf (ignorepakdir, sizeof(ignorepakdir), "/%s/", GAMENAME);
|
||||||
|
|
||||||
|
for (search = com_searchpaths; search; search = search->next)
|
||||||
|
{
|
||||||
|
if (*search->filename) //directory
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
q_snprintf (filestring, sizeof(filestring), "%s/*.dem", search->filename);
|
||||||
|
fhnd = FindFirstFile(filestring, &fdat);
|
||||||
|
if (fhnd == INVALID_HANDLE_VALUE)
|
||||||
|
continue;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
COM_StripExtension(fdat.cFileName, demname, sizeof(demname));
|
||||||
|
FileList_Add (demname, &demolist);
|
||||||
|
} while (FindNextFile(fhnd, &fdat));
|
||||||
|
FindClose(fhnd);
|
||||||
|
#else
|
||||||
|
q_snprintf (filestring, sizeof(filestring), "%s/", search->filename);
|
||||||
|
dir_p = opendir(filestring);
|
||||||
|
if (dir_p == NULL)
|
||||||
|
continue;
|
||||||
|
while ((dir_t = readdir(dir_p)) != NULL)
|
||||||
|
{
|
||||||
|
if (q_strcasecmp(COM_FileGetExtension(dir_t->d_name), "dem") != 0)
|
||||||
|
continue;
|
||||||
|
COM_StripExtension(dir_t->d_name, demname, sizeof(demname));
|
||||||
|
FileList_Add (demname, &demolist);
|
||||||
|
}
|
||||||
|
closedir(dir_p);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else //pakfile
|
||||||
|
{
|
||||||
|
if (!strstr(search->pack->filename, ignorepakdir))
|
||||||
|
{ //don't list standard id demos
|
||||||
|
for (i = 0, pak = search->pack; i < pak->numfiles; i++)
|
||||||
|
{
|
||||||
|
if (!strcmp(COM_FileGetExtension(pak->files[i].name), "dem"))
|
||||||
|
{
|
||||||
|
COM_StripExtension(pak->files[i].name, demname, sizeof(demname));
|
||||||
|
FileList_Add (demname, &demolist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
Host_Mods_f -- johnfitz
|
Host_Mods_f -- johnfitz
|
||||||
|
|
|
@ -294,6 +294,9 @@ void Host_WriteConfiguration (void);
|
||||||
|
|
||||||
void ExtraMaps_Init (void);
|
void ExtraMaps_Init (void);
|
||||||
void Modlist_Init (void);
|
void Modlist_Init (void);
|
||||||
|
void DemoList_Init (void);
|
||||||
|
|
||||||
|
void DemoList_Rebuild (void);
|
||||||
|
|
||||||
extern int current_skill; // skill level for currently loaded level (in case
|
extern int current_skill; // skill level for currently loaded level (in case
|
||||||
// the user changes the cvar while the level is
|
// the user changes the cvar while the level is
|
||||||
|
|
Loading…
Reference in a new issue