diff --git a/polymer/build/include/osd.h b/polymer/build/include/osd.h index 6dc298059..b421db688 100644 --- a/polymer/build/include/osd.h +++ b/polymer/build/include/osd.h @@ -43,6 +43,8 @@ char *OSD_GetFmt(char *ptr); char *OSD_GetTextPtr(void); char *OSD_GetFmtPtr(void); +int OSD_GetCols(void); + // initializes things void OSD_Init(void); diff --git a/polymer/build/src/osd.c b/polymer/build/src/osd.c index d6ba4c893..2f2b4d22f 100644 --- a/polymer/build/src/osd.c +++ b/polymer/build/src/osd.c @@ -194,6 +194,11 @@ char *OSD_GetFmt(char *ptr) return (ptr - &osdtext[0] + &osdfmt[0]); } +int OSD_GetCols(void) +{ + return osdcols; +} + int OSD_GetTextMode(void) { return osdtextmode; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 06be9fe5c..a80525a89 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -464,7 +464,7 @@ const char *keyw[] = "loadmapstate", // 327 "clearmapstate", // 328 "scriptsize", // 329 - "definegamename", // 330 + "setgamename", // 330 "cmenu", // 331 "gettimedate", // 332 "activatecheat", // 333 @@ -4554,7 +4554,7 @@ repeatcase: skill_names[j][i] = '\0'; return 0; - case CON_DEFINEGAMENAME: + case CON_SETGAMENAME: { char gamename[32]; scriptptr--; diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index b81ee78d1..aabf8bc0a 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -840,7 +840,7 @@ enum keywords CON_LOADMAPSTATE, // 327 CON_CLEARMAPSTATE, // 328 CON_SCRIPTSIZE, // 329 - CON_DEFINEGAMENAME, // 330 + CON_SETGAMENAME, // 330 CON_CMENU, // 331 CON_GETTIMEDATE, // 332 CON_ACTIVATECHEAT, // 333 diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index fd3f26671..23b042ef2 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -169,12 +169,63 @@ static int osdcmd_changelevel(const osdfuncparm_t *parm) return OSDCMD_OK; } +static CACHE1D_FIND_REC *findfiles = NULL; +static int numfiles = 0; + +static void clearfilenames(void) +{ + klistfree(findfiles); + findfiles = NULL; + numfiles = 0; +} + +static int 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 int osdcmd_map(const osdfuncparm_t *parm) { int i; + CACHE1D_FIND_REC *r; char filename[256]; - if (parm->numparms != 1) return OSDCMD_SHOWHELP; + if (parm->numparms != 1) + { + int maxwidth = 0; + + getfilenames("/"); + + for (r=findfiles; r!=NULL; r=r->next) + maxwidth = max((unsigned)maxwidth,Bstrlen(r->name)); + + if (maxwidth > 0) + { + int x = 0, count = 0; + maxwidth += 3; + OSD_Printf(OSDTEXT_RED "Map listing:\n"); + for (r=findfiles; r!=NULL; r=r->next) + { + OSD_Printf("%-*s",maxwidth,r->name); + x += maxwidth; + count++; + if (x > OSD_GetCols() - maxwidth) + { + x = 0; + OSD_Printf("\n"); + } + } + if (x) OSD_Printf("\n"); + OSD_Printf(OSDTEXT_RED "Found %d maps\n",numfiles); + } + + return OSDCMD_SHOWHELP; + } #if 0 if (numplayers > 1) @@ -1366,7 +1417,7 @@ int registerosdcommands(void) else { OSD_RegisterFunction("changelevel","changelevel : warps to the given level", osdcmd_changelevel); - OSD_RegisterFunction("map","map : loads the given user map", osdcmd_map); + OSD_RegisterFunction("map","map : loads a map", osdcmd_map); } OSD_RegisterFunction("addpath","addpath : adds path to game filesystem", osdcmd_addpath); diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c index 8d3585621..76e4daa4b 100644 --- a/polymer/eduke32/source/startwin.game.c +++ b/polymer/eduke32/source/startwin.game.c @@ -49,14 +49,14 @@ static int done = -1, mode = TAB_CONFIG; static CACHE1D_FIND_REC *finddirs=NULL; static int numdirs=0; -void clearfilenames(void) +static void clearfilenames(void) { klistfree(finddirs); finddirs = NULL; numdirs = 0; } -int getfilenames(char *path) +static int getfilenames(char *path) { CACHE1D_FIND_REC *r;