xmap menus

getxmaplist <what>

    Returns a list of all regular xmaps in memory, or, if <what> is "bak"
    the details of a stored backup xmap. Each xmap is listed with nickname
    and description.

DOCREF getxmaplist
This commit is contained in:
ac-stef
2017-05-31 19:59:17 +02:00
parent 0bd18421f1
commit e5b99e6da4
2 changed files with 78 additions and 2 deletions
+70 -2
View File
@@ -180,7 +180,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 amenu distmenus
pop __mm_menus __mm_sorted __mm_done idxs mpath amenu distmenus
]
]
@@ -255,6 +255,7 @@ menuinit [
menuitem "" -1
menuitem (concat "Pick clip size from closest entity:" (at $x 4) (at $x 5) (at $x 6) (at $x 7) (at $x 9) (at $x 10)) [ loop i 7 [ (concatword _clip0 (+ $i 1)) = (at $x (+ $i 4)) ] ; refreshcurmenudelayed ]
]
pop x
]
]
@@ -318,6 +319,7 @@ tempalias __rebuildtexturemenus [
menuitem $fullname (concat _texmenu_exec (escape $fullname)) (concat _texmenu_hover (escape $fullname) (escape (curmenu)))
menurenderoffset -20 0
]
pop fullname
]
]
@@ -511,6 +513,7 @@ tempalias __rebuildmapsoundmenus [
] [
menuitem (concatword (at $__mapsoundtitles (+ $idx 1)) " (" $sname ")") (concat _sndmenu_exec $sname)
]
pop idx
menurenderoffset -20 0
]
]
@@ -668,6 +671,7 @@ menuitem "Paste a previously copied entity" pasteent
menuitem "Cycle through multiple closest entities" nextclosestent
menuitemslider "Select only entities of this type: " 0 (listlen (listoptions ents)) "(closestenttype -)" 1 (concat all (listoptions ents)) [ if $arg1 [ closestenttype $arg1 ] [ closestenttype ] ]
menuitem "Hide entity sparklies\i\3" [ showmenu [Hide entity sparklies] ]
menuitem "Multiple map buffers (xmaps)\i\3" [ showmenu xmaps ]
//// Main > Editing > Map operations > Hide entity sparklies ////
@@ -676,6 +680,70 @@ looplisti (listoptions ents) e [
menuitemcheckbox (concat Hide $e sparklies:) (concat "(&b $edithideentmask" (+ 0 (powf 2 $i)) ")") (concat "edithideentmask (^b $edithideentmask" (+ 0 (powf 2 $i)) ")")
]
//// Main > Editing > Map operations > xmaps ////
newmenu xmaps
tempalias __curxmap ""
menuinit [
resetcurmenu
if $editing [
push la (getxmaplist)
push lb (getxmaplist bak)
if (strlen $la) [
menuitem "\f2Currently available xmaps:" -1
looplist $la [n d] [
menuitem $d (concat "__curxmap =" $n "; showmenu xmap")
]
menuitem "" -1
]
if (strlen $lb) [
menuitem "\f2Currently stored backup xmap:" -1
menuitem (at $lb 1) -1
menuitem "Transfer backup xmap to new regular xmap" (concat inputcommand (at $lb 0) "[xmap_keep_backup $cmdbuf]" "\"\fs\f0[xmap_keep_backup]\f2 enter new nickname for backup xmap:\fr\"" 1)
menuitem "Delete backup xmap" [ saycommand "/xmap_delete_backup" ]
if $unsavededits [
menuitem (concat "Restore backup xmap \f3(and lose" $unsavededits "currently unsaved edits)") xmap_restore
] [
menuitem "Restore backup xmap" xmap_restore
]
menuitem "" -1
]
menuitem "Store current map and edit state as xmap" [ inputcommand "" [xmap_store $cmdbuf] "\"\fs\f0[xmap_store]\f2 enter nickname for new xmap:\fr\"" ]
menuitem "List all xmaps in console" [ saycommand "/xmap_list" ]
pop la lb
] [
menuitem "menu only available in edit mode" -1
]
]
//// Main > Editing > Map operations > xmaps > xmap ////
newmenu xmap
menuinit [
resetcurmenu
if $editing [
push desc ""
looplist (getxmaplist) [n d] [ if (strcmp $n $__curxmap) [ desc = $d ] ]
if (strlen $desc) [
menuitem (concatword "\f2xmap " $__curxmap ":") -1
menuitem $desc -1
menuitem "" -1
if (strlen (getxmaplist bak)) [
menuitem (concatword "Restore xmap \fs\f1" $__curxmap "\fr (store current state as new backup xmap \fs\f3and lose backup xmap \f1" (at (getxmaplist bak) 0) "\fr)") (concat xmap_restore $__curxmap)
] [
menuitem (concat "Restore xmap\fs\f1" $__curxmap "\fr(store current state as new backup xmap)") (concat xmap_restore $__curxmap)
]
menuitem "" -1
menuitem "Rename xmap" (concat inputcommand $__curxmap "[xmap_rename" $__curxmap "$cmdbuf]" "\"\fs\f0[xmap_rename]\f2 enter new nickname for xmap" $__curxmap ":\fr\"" 1)
menuitem "Delete xmap" (concat saycommand "/xmap_delete" $__curxmap)
]
menuselection (curmenu) 3
pop desc
] [
menuitem "menu only available in edit mode" -1
]
]
//// Main > Editing > Map settings ////
newmenu [Map settings]
@@ -916,7 +984,6 @@ menuinit [
menuitem "" -1
menuitem "Merge multiple slots using same texture" [showmenu "Texture slot merge"]
]
pop slots
] [
menuitem "" -1
menuitem "\f3Delete unused slot" (concat deletetextureslot $__texslot)
@@ -1199,6 +1266,7 @@ menuitemcheckbox "Show all playerstarts (spawn points): " "$showplayerstarts" [
menuitemslider "Show closest ent slot info: " 0 2 "$hideeditslotinfo" 1 [ always "if unassigned" never ][ hideeditslotinfo $arg1 ]
menuitemcheckbox "Show edit info panel: " "(! $hideeditinfopanel)" [ hideeditinfopanel (! $arg1) ]
menuitemslider "Fly speeds multiplier: " 1 5 "$flyspeed" 1 [] [ flyspeed $arg1 ]
menuitemcheckbox "Write xmaps to disk on quit: " "$persistentxmaps" [ persistentxmaps $arg1 ]
// opt/autosave.cfg may add some entries
+8
View File
@@ -1303,6 +1303,14 @@ COMMANDF(xmap_list, "", () // list xmaps (and status)
if(bak) conoutf("backup stored before %s", xmapdescstring(bak));
} );
COMMANDF(getxmaplist, "s", (char *what) // return list of xmap nicks and descriptions
{
vector<char> res;
if(strcasecmp(what, "bak")) loopv(xmaps) cvecprintf(res, "%s %s\n", escapestring(xmaps[i]->nick), escapestring(xmapdescstring(xmaps[i])));
else if(bak) cvecprintf(res, "%s %s", escapestring(bak->nick), escapestring(xmapdescstring(bak)));
resultcharvector(res, -1);
} );
COMMANDF(xmap_store, "s", (const char *nick) // store current map in an xmap buffer
{
if(noteditmode("xmap_store")) return; // (may also be used in coopedit)