diff --git a/config/scripts.cfg b/config/scripts.cfg index 419623ef..fa196b67 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -101,6 +101,7 @@ looplist [ team teamnames addpunct punctuations // the command addpunct actually wants the punctuation name as second argument, but we can't do that. sry. loadcrosshair crosshairnames + edittexturestack texturestacktypes ] [ cmd options ] [ listcomplete $cmd (listoptions $options) ] diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp index f4bbbd28..fda90f64 100644 --- a/source/src/audiomanager.cpp +++ b/source/src/audiomanager.cpp @@ -905,3 +905,53 @@ void editmapsoundslot(int *n, char *name, char *maxuses) // edit slot parameters } COMMAND(editmapsoundslot, "isssss"); +void getmapsoundorigin(char *fname) +{ + defformatstring(s)("packages/audio/ambience/%s", fname); + findfile(path(s), "r"); + const char *res = s; + switch(findfilelocation) + { + case FFL_WORKDIR: res = fileexists(s, "r") ? "official" : ""; break; + case FFL_HOME: res = "custom"; break; + default: formatstring(s)("package dir #%d", findfilelocation); break; + } + result(res); +} +COMMAND(getmapsoundorigin, "s"); + +void mapsoundslotbyname(char *name) // returns the slot(s) that a certain mapsound file is used in +{ + string res = ""; + loopv(mapconfigdata.mapsoundlines) if(!strcmp(name, mapconfigdata.mapsoundlines[i].name)) concatformatstring(res, "%s%d", *res ? " " : "", i); + result(res); +} +COMMAND(mapsoundslotbyname, "s"); + +void getmapsoundlist() // create a list of mapsound filenames +{ + vector files; + listfilesrecursive("packages/audio/ambience", files); + files.sort(stringsort); + loopvrev(files) if(files.inrange(i + 1) && !strcmp(files[i], files[i + 1])) delstring(files.remove(i + 1)); // remove doubles + int pn = strlen("packages/audio/ambience/"); + vector res; + loopv(files) + { + if(!strncmp(files[i], "packages/audio/ambience/", pn)) + { + const char *s = files[i] + pn; + int sn = strlen(s); + if(sn > 4) + { + const char *e = s + sn - 4; + if(!strcmp(e, ".ogg") || !strcmp(e, ".wav")) cvecprintf(res, "\"%s\"\n", s); + } + } + } + if(res.length()) res.last() = '\0'; + else res.add('\0'); + files.deletearrays(); + result(res.getbuf()); +} +COMMAND(getmapsoundlist, ""); diff --git a/source/src/command.cpp b/source/src/command.cpp index f3857170..fe8fe9db 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -1754,9 +1754,9 @@ COMMAND(getscrext, ""); void listoptions(char *s) { - extern const char *menufilesortorders[]; - const char *optionnames[] = { "entities", "ents", "weapons", "teamnames", "teamnames-abbrv", "punctuations", "crosshairnames", "menufilesortorders", "" }; - const char **optionlists[] = { optionnames, entnames + 1, entnames + 1, gunnames, teamnames, teamnames_s, punctnames, crosshairnames, menufilesortorders }; + extern const char *menufilesortorders[], *texturestacktypes[]; + const char *optionnames[] = { "entities", "ents", "weapons", "teamnames", "teamnames-abbrv", "punctuations", "crosshairnames", "menufilesortorders", "texturestacktypes", "" }; + const char **optionlists[] = { optionnames, entnames + 1, entnames + 1, gunnames, teamnames, teamnames_s, punctnames, crosshairnames, menufilesortorders, texturestacktypes }; const char **listp = optionlists[getlistindex(s, optionnames, true, -1) + 1]; commandret = conc(listp, -1, true); } diff --git a/source/src/editing.cpp b/source/src/editing.cpp index eed7afcf..db5ed648 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -622,6 +622,20 @@ void tofronttex() // maintain most recentl } } +const char *texturestacktypes[] = { "floor", "wall", "ceiling", "" }; + +void edittexturestack(char *what, int *slot) // manually manipulate the "last-used" texture lists to put certain textures up front +{ + tofronttex(); // keep laste edited texture + int n = getlistindex(what, texturestacktypes, true, -1); + if(n >= 0) + { + loopi(256) if(hdr.texlists[n][i] == *slot) curedittex[n] = i; // find stack index of wanted texture slot + } + tofronttex(); +} +COMMAND(edittexturestack, "si"); + void editdrag(bool isdown) { if((dragging = isdown)) diff --git a/source/src/texture.cpp b/source/src/texture.cpp index b15b78c6..2801bcfc 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -949,6 +949,36 @@ void gettexturelist(char *_filter, char *_exclude, char *_exts) // create a list } COMMAND(gettexturelist, "sss"); +void textureslotusagelist(char *what) +{ + int used[256] = { 0 }; + if(strcmp(what, "onlygeometry")) + { // if not only geometry, cound map model usage + loopv(ents) if(ents[i].type == MAPMODEL) used[ents[i].attr4]++; + used[0] = 0; + } + if(strcmp(what, "onlymodels")) + { // if not only models, count map geometry + sqr *s = world; + loopirev(cubicsize) + { + used[s->wtex]++; + if(s->type != SOLID) + { + used[s->ctex]++; + used[s->ftex]++; + used[s->utex]++; + } + s++; + } + } + vector res; + loopi(256) cvecprintf(res, "%d ", used[i]); + res.last() = '\0'; + result(res.getbuf()); +} +COMMAND(textureslotusagelist, "s"); + bool testworldtexusage(int n) { sqr *s = world; @@ -1036,6 +1066,30 @@ void edittextureslot(int *n, char *scale, char *name) // edit slot parameters != } COMMAND(edittextureslot, "iss"); +void gettextureorigin(char *fname) +{ + defformatstring(s)("packages/textures/%s", fname); + findfile(path(s), "r"); + const char *res = s; + switch(findfilelocation) + { + case FFL_WORKDIR: res = fileexists(s, "r") ? "official" : ""; break; + case FFL_HOME: res = "custom"; break; + default: formatstring(s)("package dir #%d", findfilelocation); break; + } + result(res); +} +COMMAND(gettextureorigin, "s"); + +void textureslotbyname(char *name) // returns the slot(s) that a certain texture file is configured in +{ + string res = ""; + loopv(slots) if(!strcmp(name, slots[i].name)) concatformatstring(res, "%s%d", *res ? " " : "", i); + result(res); +} +COMMAND(textureslotbyname, "s"); + + // helper functions to allow copy&paste between different maps while keeping the proper textures assigned // (pasting will add any missing texture slots) diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 47789f53..7158ce3d 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -404,6 +404,8 @@ void automapconfig() } COMMAND(automapconfig, ""); +COMMANDF(getautomapconfig, "", () { intret((hdr.flags & MHF_AUTOMAPCONFIG) != 0); }); + void flagmapconfigchange() { // if changes are tracked, because automapcfg is enabled and the change is not read from a config file -> set unsaved edits flag if(execcontext != IEXC_MAPCFG && hdr.flags & MHF_AUTOMAPCONFIG) unsavededits++;