diff --git a/config/menus_edit.cfg b/config/menus_edit.cfg index 5a35e37a..d6d89552 100644 --- a/config/menus_edit.cfg +++ b/config/menus_edit.cfg @@ -195,7 +195,7 @@ menuinit [ menuitem "Map area checks..." [ showmenu [Map area checks] ] menuitem "Entity statistics" [ showmenu [Entity statistics] ] menuitem "Check mapmodels with unconfigured custom textures" [ showmenu [Walk mapmodel entities with unconfigured custom textures] ] - + menuitem "Show most visible textures" [ showmenu [Most visible textures] ] ] [ menuitem "menu only available in edit mode" -1 ] @@ -277,6 +277,8 @@ menuinit [ ] ] +tempalias __defaultskymapdummy kurt/klite1.jpg + // Edit texture slot newmenu [Edit texture slot] menuinit [ @@ -295,6 +297,9 @@ menuinit [ if (&& (strlen $__lastwatchedtexture) (! (strcmp $__lastwatchedtexture (at $info 1)))) [ menuitem (concat " change to" (escape $__lastwatchedtexture)) [edittextureslot $__texslot "" $__lastwatchedtexture] ] + if (&& (! $__texslot) (! (strcmp $__defaultskymapdummy (at $info 1)))) [ + menuitem (concat " change to skymap default" (escape $__defaultskymapdummy)) [edittextureslot $__texslot 0 $__defaultskymapdummy] + ] menuitem "" -1 menuitem "use as next (upper-)wall texture" [edittexturestack wall $__texslot] menuitem "use as next floor texture" [edittexturestack floor $__texslot] @@ -317,6 +322,19 @@ menuinit [ menuitem "" -1 menuitem "\f3Delete unused slot" (concat deletetextureslot $__texslot) ] + if (! (strcmp $__lastwatchedtexture (at $info 1))) [ + menuitem "" -1 + menuitem (concat "Pick texture name" (at $info 1)) (concat __lastwatchedtexture = (escape (at $info 1))) + ] + if (! $__texslot) [ + menuitem "" -1 + menuitem (concat "Slot #0 is hardcoded as skymap, please use" $__defaultskymapdummy) -1 + ] [ + if (< $__texslot 5) [ + menuitem "" -1 + menuitem (concatword "Slot #" $__texslot " is the default " (at ["" "cube 1 water" "wall" "floor" "ceiling"] $__texslot) " texture") -1 + ] + ] pop info ][ menuitem "no slot selected" -1 @@ -974,6 +992,26 @@ newmenu [Walk mapmodel entities with unconfigured custom textures] menuinit (concat $__a "looplist (enumentities mapmodel) i [if (! (strlen (edittextureslot (at (editentity $i) 7)))) [menuitem (concatword # $i [ ] (editentity $i)) (concat gotoentity $i) (concat gotoentity $i)]]") pop __a __b +newmenu [Most visible textures] +menuinit [ + resetcurmenu + menurenderoffset -20 0 + if $editing [ + push ec (escape (curmenu)) + push mvis (textureslotusagelist onlymostvisible) + push info "" + looplist $mvis [d i] [ + info = (edittextureslot $i) + menuitem (concatword "most visible " $d " texture: " (if $i (escape $info) [result ]) " (slot #" $i ")") (concat __texslot = $i "; showmenu [Edit texture slot]") (concat chmenutexture $ec (at $info 1)) + ] + menuitem "" -1 (concat chmenutexture $ec []) + menuitem "Sort the most visible textures to the default slot positions" (concat sorttextureslots nomerge nosort 1 (at $mvis 1) (at $mvis 3) (at $mvis 5) (at $mvis 7)) (concat chmenutexture $ec []) + pop mvis ec info + ] [ + menuitem "menu only available in edit mode" -1 + ] +] + newmenu [Entity statistics] menuinit [ resetcurmenu diff --git a/source/src/texture.cpp b/source/src/texture.cpp index 308414cc..e75b7d73 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -1245,13 +1245,17 @@ int tempslotunsort(temptexslot *a, temptexslot *b) void sorttextureslots(char **args, int numargs) { bool nomerge = false, mergeused = false, nosort = false, unknownarg = false; + vector presort; + presort.add(0); // skymap needs to stay on #0 loopi(numargs) if(args[i][0]) { if(!strcasecmp(args[i], "nomerge")) nomerge = true; else if(!strcasecmp(args[i], "nosort")) nosort = true; else if(!strcasecmp(args[i], "mergeused")) mergeused = true; + else if(isdigit(args[i][0])) presort.add(ATOI(args[i])); else { conoutf("sorttextureslots: unknown argument \"%s\"", args[i]); unknownarg = true; } } + while(presort.length() < 5) presort.add(presort.length()); if(noteditmode("sorttextureslots") || multiplayer(true) || unknownarg || slots.length() < 5) return; @@ -1272,7 +1276,7 @@ void sorttextureslots(char **args, int numargs) if(!nomerge) loopvrev(tempslots) if(i > 0) { temptexslot &s1 = tempslots[i], &s0 = tempslots[i - 1]; - if(s1.oldslot[0] > 4 && !strcmp(s0.s.name, s1.s.name) && s0.s.scale == s1.s.scale && (mergeused || !s0.used || !s1.used)) + if(s1.oldslot[0] > 4 && s0.oldslot[0] > 0 && !strcmp(s0.s.name, s1.s.name) && s0.s.scale == s1.s.scale && (mergeused || !s0.used || !s1.used)) { if(s1.used) s0.used = true; loopvj(s1.oldslot) s0.oldslot.add(s1.oldslot[j]); @@ -1282,11 +1286,14 @@ void sorttextureslots(char **args, int numargs) // sort special textures (like skymap) back front - also, revert sorting, if it's unwanted if(nosort) tempslots.sort(tempslotunsort); - loopk(5) + loopv(presort) for(int n = i + 1; n < presort.length(); n++) if(presort[i] == presort[n]) presort.remove(n); // first occurrence is kept + loopvk(presort) { loopv(tempslots) { - if(tempslots[i].oldslot[0] == k && i > k) + bool yep = false; + loopvj(tempslots[i].oldslot) if(tempslots[i].oldslot[j] == presort[k]) yep = true; + if(yep && i > k) { temptexslot t = tempslots.remove(i); tempslots.insert(k, t);