mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Replace {get,clear}filenames with fnlist functions in build.c, menus.c and osdcmds.c
git-svn-id: https://svn.eduke32.com/eduke32@2556 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
a7f6f3bacc
commit
0c5c58cbbb
3 changed files with 52 additions and 88 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "osd.h"
|
||||
#include "cache1d.h"
|
||||
#include "editor.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "baselayer.h"
|
||||
#ifdef RENDERTYPEWIN
|
||||
|
@ -114,8 +115,8 @@ char *testplay_addparam = 0;
|
|||
static char boardfilename[BMAX_PATH], selectedboardfilename[BMAX_PATH];
|
||||
//extern char levelname[BMAX_PATH]; // in astub.c XXX: clean up this mess!!!
|
||||
|
||||
static CACHE1D_FIND_REC *finddirs=NULL, *findfiles=NULL, *finddirshigh=NULL, *findfileshigh=NULL;
|
||||
static int32_t numdirs=0, numfiles=0;
|
||||
static fnlist_t fnlist;
|
||||
static CACHE1D_FIND_REC *finddirshigh=NULL, *findfileshigh=NULL;
|
||||
static int32_t currentlist=0;
|
||||
|
||||
//static int32_t repeatcountx, repeatcounty;
|
||||
|
@ -227,7 +228,6 @@ static int32_t insert_sprite_common(int32_t sucksect, int32_t dax, int32_t day);
|
|||
static void correct_ornamented_sprite(int32_t i, int32_t hitw);
|
||||
|
||||
static int32_t getfilenames(const char *path, const char *kind);
|
||||
static void clearfilenames(void);
|
||||
|
||||
void clearkeys(void) { Bmemset(keystatus,0,sizeof(keystatus)); }
|
||||
|
||||
|
@ -8847,29 +8847,16 @@ const char *getstring_simple(const char *querystr, const char *defaultstr, int32
|
|||
return buf+qrylen;
|
||||
}
|
||||
|
||||
static void clearfilenames(void)
|
||||
{
|
||||
klistfree(finddirs);
|
||||
klistfree(findfiles);
|
||||
finddirs = findfiles = NULL;
|
||||
numfiles = numdirs = 0;
|
||||
}
|
||||
|
||||
static int32_t getfilenames(const char *path, const char *kind)
|
||||
{
|
||||
CACHE1D_FIND_REC *r;
|
||||
const int32_t addflags = (!pathsearchmode && grponlymode ? CACHE1D_OPT_NOSTACK : 0);
|
||||
|
||||
clearfilenames();
|
||||
finddirs = klistpath(path,"*",CACHE1D_FIND_DIR|CACHE1D_FIND_DRIVE|(!pathsearchmode&&grponlymode?CACHE1D_OPT_NOSTACK:0));
|
||||
findfiles = klistpath(path,kind,CACHE1D_FIND_FILE|(!pathsearchmode&&grponlymode?CACHE1D_OPT_NOSTACK:0));
|
||||
for (r = finddirs; r; r=r->next) numdirs++;
|
||||
for (r = findfiles; r; r=r->next) numfiles++;
|
||||
fnlist_getnames(&fnlist, path, kind, addflags|CACHE1D_FIND_DRIVE, addflags);
|
||||
|
||||
finddirshigh = fnlist.finddirs;
|
||||
findfileshigh = fnlist.findfiles;
|
||||
currentlist = (findfileshigh != NULL);
|
||||
|
||||
finddirshigh = finddirs;
|
||||
findfileshigh = findfiles;
|
||||
currentlist = 0;
|
||||
if (findfileshigh) currentlist = 1;
|
||||
//initprintf("path=%s || kind=%s || numfiles=%d, numdirs=%d\n", path, kind, numfiles, numdirs);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -8892,7 +8879,7 @@ static int32_t menuselect_auto(int32_t direction) // 20080104: jump to next (dir
|
|||
Bcorrectfilename(selectedboardfilename, 1);
|
||||
|
||||
getfilenames(selectedboardfilename, "*.map");
|
||||
if (numfiles==0)
|
||||
if (fnlist.numfiles==0)
|
||||
return -2;
|
||||
|
||||
boardbasename = Bstrrchr(boardfilename,'/'); // PK
|
||||
|
@ -8906,7 +8893,7 @@ static int32_t menuselect_auto(int32_t direction) // 20080104: jump to next (dir
|
|||
break;
|
||||
|
||||
if (!findfileshigh)
|
||||
findfileshigh=findfiles;
|
||||
findfileshigh = fnlist.findfiles;
|
||||
|
||||
if (direction)
|
||||
{
|
||||
|
@ -8960,7 +8947,7 @@ static int32_t menuselect(void)
|
|||
break;
|
||||
|
||||
if (!findfileshigh)
|
||||
findfileshigh=findfiles;
|
||||
findfileshigh = fnlist.findfiles;
|
||||
|
||||
_printmessage16("Select map file with arrow keys and enter.");
|
||||
|
||||
|
@ -8981,7 +8968,8 @@ static int32_t menuselect(void)
|
|||
|
||||
printext16(halfxdim16-(8*Bstrlen(buffer)/2), 4, editorcolors[12],editorcolors[0],buffer,0);
|
||||
|
||||
Bsnprintf(buffer,sizeof(buffer)-1,"(%d dirs, %d files) %s",numdirs,numfiles,selectedboardfilename);
|
||||
Bsnprintf(buffer,sizeof(buffer)-1,"(%d dirs, %d files) %s",
|
||||
fnlist.numdirs, fnlist.numfiles, selectedboardfilename);
|
||||
buffer[sizeof(buffer)-1] = 0;
|
||||
|
||||
printext16(8,ydim16-8-1,editorcolors[8],editorcolors[0],buffer,0);
|
||||
|
@ -9061,7 +9049,7 @@ static int32_t menuselect(void)
|
|||
|
||||
{
|
||||
// JBF 20040208: seek to first name matching pressed character
|
||||
CACHE1D_FIND_REC *seeker = currentlist ? findfiles : finddirs;
|
||||
CACHE1D_FIND_REC *seeker = currentlist ? fnlist.findfiles : fnlist.finddirs;
|
||||
if (keystatus[0xc7]||keystatus[0xcf]) // home/end
|
||||
{
|
||||
while (keystatus[0xcf]?seeker->next:seeker->prev)
|
||||
|
@ -9151,7 +9139,7 @@ static int32_t menuselect(void)
|
|||
}
|
||||
else if (ch == 9)
|
||||
{
|
||||
if ((currentlist == 0 && findfiles) || (currentlist == 1 && finddirs))
|
||||
if ((currentlist == 0 && fnlist.findfiles) || (currentlist == 1 && fnlist.finddirs))
|
||||
currentlist = 1-currentlist;
|
||||
}
|
||||
else if (keystatus[0xc8] /*(ch == 75) || (ch == 72)*/)
|
||||
|
|
|
@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "premap.h"
|
||||
#include "demo.h"
|
||||
#include "crc32.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -43,10 +44,20 @@ static int32_t last_zero,last_fifty,last_onehundred,last_twoohtwo,last_threehund
|
|||
|
||||
static char menunamecnt;
|
||||
|
||||
static CACHE1D_FIND_REC *finddirs=NULL, *findfiles=NULL, *finddirshigh=NULL, *findfileshigh=NULL;
|
||||
static int32_t numdirs=0, numfiles=0;
|
||||
static fnlist_t fnlist;
|
||||
static CACHE1D_FIND_REC *finddirshigh=NULL, *findfileshigh=NULL;
|
||||
static int32_t currentlist=0;
|
||||
|
||||
static void set_findhighs(void)
|
||||
{
|
||||
finddirshigh = fnlist.finddirs;
|
||||
findfileshigh = fnlist.findfiles;
|
||||
currentlist = 0;
|
||||
if (findfileshigh)
|
||||
currentlist = 1;
|
||||
}
|
||||
|
||||
|
||||
static int32_t function, whichkey;
|
||||
static int32_t changesmade, newvidmode, curvidmode, newfullscreen;
|
||||
static int32_t vidsets[16] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
|
||||
|
@ -569,32 +580,6 @@ static void M_DisplaySaveGameList(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void clearfilenames(void)
|
||||
{
|
||||
klistfree(finddirs);
|
||||
klistfree(findfiles);
|
||||
finddirs = findfiles = NULL;
|
||||
numfiles = numdirs = 0;
|
||||
}
|
||||
|
||||
static int32_t getfilenames(const char *path, char kind[])
|
||||
{
|
||||
CACHE1D_FIND_REC *r;
|
||||
|
||||
clearfilenames();
|
||||
finddirs = klistpath(path,"*",CACHE1D_FIND_DIR);
|
||||
findfiles = klistpath(path,kind,CACHE1D_FIND_FILE);
|
||||
for (r = finddirs; r; r=r->next) numdirs++;
|
||||
for (r = findfiles; r; r=r->next) numfiles++;
|
||||
|
||||
finddirshigh = finddirs;
|
||||
findfileshigh = findfiles;
|
||||
currentlist = 0;
|
||||
if (findfileshigh) currentlist = 1;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
extern int32_t g_quitDeadline;
|
||||
|
||||
void G_CheckPlayerColor(int32_t *color, int32_t prev_color)
|
||||
|
@ -2183,7 +2168,10 @@ cheat_for_port_credits:
|
|||
case 101:
|
||||
if (boardfilename[0] == 0) strcpy(boardfilename, "./");
|
||||
Bcorrectfilename(boardfilename,1);
|
||||
getfilenames(boardfilename,"*.map");
|
||||
|
||||
fnlist_getnames(&fnlist, boardfilename, "*.map", 0, 0);
|
||||
set_findhighs();
|
||||
|
||||
ChangeToMenu(102);
|
||||
KB_FlushKeyboardQueue();
|
||||
case 102:
|
||||
|
@ -2200,7 +2188,7 @@ cheat_for_port_credits:
|
|||
|
||||
{
|
||||
// JBF 20040208: seek to first name matching pressed character
|
||||
CACHE1D_FIND_REC *seeker = currentlist ? findfiles : finddirs;
|
||||
CACHE1D_FIND_REC *seeker = currentlist ? fnlist.findfiles : fnlist.finddirs;
|
||||
if ((KB_KeyPressed(sc_Home)|KB_KeyPressed(sc_End)) > 0)
|
||||
{
|
||||
while (seeker && (KB_KeyPressed(sc_End)?seeker->next:seeker->prev))
|
||||
|
@ -2361,7 +2349,8 @@ cheat_for_port_credits:
|
|||
|
||||
if (x == -1)
|
||||
{
|
||||
clearfilenames();
|
||||
fnlist_clearnames(&fnlist);
|
||||
|
||||
boardfilename[0] = 0;
|
||||
if ((g_netServer || ud.multimode > 1))
|
||||
{
|
||||
|
@ -2396,7 +2385,8 @@ cheat_for_port_credits:
|
|||
}
|
||||
else ChangeToMenu(110);
|
||||
}
|
||||
clearfilenames();
|
||||
|
||||
fnlist_clearnames(&fnlist);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -5164,7 +5154,9 @@ VOLUME_ALL_40x:
|
|||
if (menunamecnt == 0)
|
||||
{
|
||||
// getfilenames("SUBD");
|
||||
getfilenames(".","*.MAP");
|
||||
fnlist_getnames(&fnlist, ".", "*.MAP", 0, 0);
|
||||
set_findhighs();
|
||||
|
||||
if (menunamecnt == 0)
|
||||
ChangeToMenu(600);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "osd.h"
|
||||
#include "osdfuncs.h"
|
||||
#include "gamedef.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
@ -161,47 +162,28 @@ static int32_t osdcmd_changelevel(const osdfuncparm_t *parm)
|
|||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static CACHE1D_FIND_REC *findfiles = NULL;
|
||||
static int32_t numfiles = 0;
|
||||
|
||||
static void clearfilenames(void)
|
||||
{
|
||||
klistfree(findfiles);
|
||||
findfiles = NULL;
|
||||
numfiles = 0;
|
||||
}
|
||||
|
||||
static int32_t getfilenames(char *path)
|
||||
{
|
||||
CACHE1D_FIND_REC *r;
|
||||
|
||||
clearfilenames();
|
||||
findfiles = klistpath(path,"*.MAP",CACHE1D_FIND_FILE);
|
||||
for (r = findfiles; r; r=r->next) numfiles++;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int32_t osdcmd_map(const osdfuncparm_t *parm)
|
||||
{
|
||||
int32_t i;
|
||||
CACHE1D_FIND_REC *r;
|
||||
char filename[256];
|
||||
char filename[BMAX_PATH];
|
||||
|
||||
if (parm->numparms != 1)
|
||||
{
|
||||
CACHE1D_FIND_REC *r;
|
||||
fnlist_t fnlist = FNLIST_INITIALIZER;
|
||||
int32_t maxwidth = 0;
|
||||
|
||||
getfilenames("/");
|
||||
fnlist_getnames(&fnlist, "/", "*.MAP", -1, 0);
|
||||
|
||||
for (r=findfiles; r!=NULL; r=r->next)
|
||||
maxwidth = max((unsigned)maxwidth,Bstrlen(r->name));
|
||||
for (r=fnlist.findfiles; r; r=r->next)
|
||||
maxwidth = max((unsigned)maxwidth, Bstrlen(r->name));
|
||||
|
||||
if (maxwidth > 0)
|
||||
{
|
||||
int32_t x = 0, count = 0;
|
||||
maxwidth += 3;
|
||||
OSD_Printf(OSDTEXT_RED "Map listing:\n");
|
||||
for (r=findfiles; r!=NULL; r=r->next)
|
||||
for (r=fnlist.findfiles; r; r=r->next)
|
||||
{
|
||||
OSD_Printf("%-*s",maxwidth,r->name);
|
||||
x += maxwidth;
|
||||
|
@ -213,9 +195,11 @@ static int32_t osdcmd_map(const osdfuncparm_t *parm)
|
|||
}
|
||||
}
|
||||
if (x) OSD_Printf("\n");
|
||||
OSD_Printf(OSDTEXT_RED "Found %d maps\n",numfiles);
|
||||
OSD_Printf(OSDTEXT_RED "Found %d maps\n", fnlist.numfiles);
|
||||
}
|
||||
|
||||
fnlist_clearnames(&fnlist);
|
||||
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue