From d107aa3cd6bf644e1b2258d21cd5c52631bfd938 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sat, 13 Feb 2016 18:52:18 +0100 Subject: [PATCH] added mapmodel menus sorted by author and distribution all generated automatically from mapmodel attributes also: * fixed typo in model config * concatuniq now works fine with spaces --- config/menus_edit.cfg | 51 ++++++++++++++++++- config/scripts.cfg | 2 +- .../hanging_ladder/ladder_low/md3.cfg | 2 +- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/config/menus_edit.cfg b/config/menus_edit.cfg index 89d9b855..ab1846ad 100644 --- a/config/menus_edit.cfg +++ b/config/menus_edit.cfg @@ -551,8 +551,8 @@ tempalias __mapmodelcategories [ looplist $__mapmodelcategories [key menu] [tempalias (concatword __mm_key_ $key) $menu] -tempalias __mm_unassigned [echo (yellow) sry: mapmodel (addpunct $arg1) has no slot assigned. Please edit your map config file.] tempalias __mm_showmodel [concat alias __lastwatchedmapmodel $arg2 ";" chmenumdl (escape $arg1) (concatword mapmodels/ $arg2) all 40 3] +tempalias __mm_tempmenus "" tempalias __rebuildmapmodelmenus [ if $mapmodelchanged [ @@ -588,11 +588,58 @@ tempalias __rebuildmapmodelmenus [ menuitem (concatword "\f4" $desc) (concat newent mapmodel "(mapmodel" $dflts $path ")") (__mm_showmodel $$keyword $path) $usage // mapmodel has no slot assigned: assign one ] ] + // add menus sorted by author and distribution + push amenu "" + push distmenus "" + looplist $__mm_tempmenus menu [delmenu $menu] + __mm_tempmenus = "" + looplist (listallmapmodelattributes sortby: author desc usage defaults distribution) [path author desc usage dflts dist] [ + mpath = (concatword "mapmodels/" $path) + dflts = (concat $dflts "0 0 0 0") + dflts = (concat (at $dflts 0) (at $dflts 1) (at $dflts 2) (at $dflts 3)) // fix missing/incomplete default slot parameters + if (strlen $author) [] [author = "*unknown*"] + idxs = (mapmodelslotbyname $mpath) + amenu = (concat "Map models by" $author) + newmenu $amenu // menu sorted by author + concatuniq __mm_tempmenus $amenu + menurenderoffset -40 0 + if (listlen $idxs) [ + if (> (listlen $idxs) 1) [ + looplist $idxs i [menuitem (concat $path (concatword "#" $i)) (concat newent mapmodel $i) (__mm_showmodel $amenu $path) $desc] // several slots for the same mapmodel + ][ + menuitem $path (concat newent mapmodel $idxs) (__mm_showmodel $amenu $path) $desc // usual case: one slot per model + ] + ][ + menuitem (concatword "\f4" $path) (concat newent mapmodel "(mapmodel" $dflts $path ")") (__mm_showmodel $amenu $path) $desc // mapmodel has no slot assigned: assign one + ] + if (strlen $dist) [] [dist = "*unknown*"] + amenu = (concat "Map models of origin:" $dist) + newmenu $amenu // menu sorted by distribution + concatuniq distmenus $amenu + menurenderoffset -40 0 + if (listlen $idxs) [ + if (> (listlen $idxs) 1) [ + looplist $idxs i [menuitem (concat $path (concatword "#" $i)) (concat newent mapmodel $i) (__mm_showmodel $amenu $path) $desc] // several slots for the same mapmodel + ][ + menuitem $path (concat newent mapmodel $idxs) (__mm_showmodel $amenu $path) $desc // usual case: one slot per model + ] + ][ + menuitem (concatword "\f4" $path) (concat newent mapmodel "(mapmodel" $dflts $path ")") (__mm_showmodel $amenu $path) $desc // mapmodel has no slot assigned: assign one + ] + ] + amenu = "Browse all map models" + delmenu $amenu + newmenu $amenu + looplist $__mm_tempmenus m [menuitem $m (concat showmenu (escape $m))] + menuitem "" -1 + looplist $distmenus m [menuitem $m (concat showmenu (escape $m))] + __mm_tempmenus = (concat $__mm_tempmenus $distmenus) delmenu Mapmodels newmenu Mapmodels push __mm_sorted "" looplist $__mapmodelcategories [key menu] [if (>= (findlist $__mm_menus $menu) 0) [concatuniq __mm_sorted $menu]] // create list of non-empty menus in order of list above looplist $__mm_sorted m [menuitem $m (concat showmenu $m)] // only create non-empty menus + if (strlen $__mm_tempmenus) [menuitem "" -1 ; menuitem $amenu (concat showmenu (escape $amenu))] delmenu [Delete unused mapmodel slot] delmenu [Edit mapmodel slots] if $editing [ @@ -619,7 +666,7 @@ tempalias __rebuildmapmodelmenus [ newmenu [Edit mapmodel slots] menuitem "menu only available in edit mode" -1 ] - pop menu __mm_menus __mm_sorted __mm_done __mm_unsorted idxs mpath + pop menu __mm_menus __mm_sorted __mm_done __mm_unsorted idxs mpath amenu distmenus ] ] diff --git a/config/scripts.cfg b/config/scripts.cfg index f800a9db..e6b81d20 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -161,7 +161,7 @@ const aliasinit [ loop ail (listlen $arg1) [ checkinit (at $arg1 $ail) $ar const add2list [ if (strcmp [] (getalias $arg1)) [ $arg1 = $arg2 ] [ $arg1 = (concat (getalias $arg1) $arg2) ] ] // works exactly like concat, use as a shortcut to: alias = (concat $alias "some string") const add2bind [ if (! (strstr (keybind $arg1) $arg2)) [ bind $arg1 (format [%1; %2] (keybind $arg1) $arg2) ] ] // works exactly like add2alias except for used with keybinds -const concatuniq [ if (< (findlist $$arg1 $arg2) 0) [$arg1 = (concat $$arg1 $arg2) ; result 1] [result 0] ] // add item to list, if it's not already been in the list +const concatuniq [ if (< (findlist $$arg1 $arg2) 0) [$arg1 = (concat $$arg1 (escape $arg2)) ; result 1] [result 0] ] // add item to list, if it's not already been in the list // Weapon switching/action utilities. const hasprimary [ result (= (curweapon) (currentprimary)) ] diff --git a/packages/models/mapmodels/misterfloppy/hanging_ladder/ladder_low/md3.cfg b/packages/models/mapmodels/misterfloppy/hanging_ladder/ladder_low/md3.cfg index 74a211a7..705df2de 100644 --- a/packages/models/mapmodels/misterfloppy/hanging_ladder/ladder_low/md3.cfg +++ b/packages/models/mapmodels/misterfloppy/hanging_ladder/ladder_low/md3.cfg @@ -1,5 +1,5 @@ mdlattribute keywords "ladders" mdlattribute desc "Hangable Ladder (Bottom)" -mdlattribute author misterfloppyw +mdlattribute author misterfloppy mdlattribute distribution official