Skip to content

Commit

Permalink
fix permissions for some edit commands
Browse files Browse the repository at this point in the history
- always allow read-only edittextureslot, editmapmodelslot and
  editmapsoundslot
- allow setvantagepoint when editing offline or spectating offline
- new var editing_sp: 1 during edit mode in singleplayer (offline)
- additional menus for read-only access to map config slots
- new bonus edit scripts: selectmiddle and unclipentclippedmodels

DOCREF edittextureslot editmapmodelslot editmapsoundslot setvantagepoint
DOCREF editing_sp
  • Loading branch information
ac-stef committed Jun 14, 2017
1 parent 9bb9cc2 commit d7277c1
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 65 deletions.
174 changes: 129 additions & 45 deletions config/menus_edit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ tempalias __mapmodelcategories [

looplist $__mapmodelcategories [key menu] [tempalias (concatword __mm_key_ $key) $menu]

tempalias __menuitem_offlineeditonly [ menuitem "menu only available in offline edit mode" -1 ]
tempalias __mm_showmodel [concat alias __lastwatchedmapmodel $arg2 ";" menumdl (escape $arg1) (concatword mapmodels/ $arg2) all 40 3]
tempalias __mm_showmodel2 [concat menumdl (escape $arg1) (concatword mapmodels/ $arg2) all 40 3]
tempalias __mm_tempmenus ""
Expand Down Expand Up @@ -144,7 +145,7 @@ tempalias __rebuildmapmodelmenus [
if (strlen $__mm_tempmenus) [menuitem "" -1 ; menuitem $amenu (concat showmenu (escape $amenu))]
delmenu [Delete unused mapmodel slot]
delmenu [Edit mapmodel slots]
if $editing [
if $editing_sp [
newmenu [Delete unused mapmodel slot]
loop i 256 [
mpath = (mapmodelslotname $i)
Expand Down Expand Up @@ -176,9 +177,9 @@ tempalias __rebuildmapmodelmenus [
mapmodelchanged 0
] [
newmenu [Delete unused mapmodel slot]
menuitem "menu only available in edit mode" -1
__menuitem_offlineeditonly // "menu only available in offline edit mode"
newmenu [Edit mapmodel slots]
menuitem "menu only available in edit mode" -1
__menuitem_offlineeditonly // "menu only available in offline edit mode"
]
pop __mm_menus __mm_sorted __mm_done idxs mpath amenu distmenus
]
Expand Down Expand Up @@ -572,12 +573,12 @@ tempalias __setundoarch [ __undoarch = (concat select (at (selx) 0) (at (sely) 0
newmenu Arches
menuinit [ chmenutexture (curmenu) map_editor/axes.png " " ]
menuitemslider "Arch sideways curve delta: " 0 5 "$__archside" 1 [ __archside = $arg1 ]
menuitem "\t[ Place arch ]" [ __setundoarch ; heightfield 2; arch $__archside ]
menuitem "\t[ Place arch ]" [ if $editing_sp __setundoarch ; heightfield 2; arch $__archside ]
menuitem "Edit arches\i\3" [ showmenu "Edit arches" ]
menuitem "" -1
menuitemradio "Slope axis: " 0 1 "$__slopeaxis" ["West to East (X)" "North to South (Y)"] [ __slopeaxis = $arg1 ]
menuitemslider "Slope increment: " 0 5 "$__slopeinc" ["downwards 3" "downwards 2" "downwards 1" "upwards 1" "upwards 2" "upwards 3"] [ __slopeinc = $arg1 ]
menuitem "\t[ Place slope ]" [ __setundoarch ; heightfield 0; push i (at "3 2 1 -1 -2 -3" $__slopeinc) ; slope (if $__slopeaxis 0 $i) (if $__slopeaxis $i 0) ; pop i ; 0]
menuitem "\t[ Place slope ]" [ if $editing_sp __setundoarch ; heightfield 0; push i (at "3 2 1 -1 -2 -3" $__slopeinc) ; slope (if $__slopeaxis 0 $i) (if $__slopeaxis $i 0) ; pop i ; 0]
menuitem "" -1
menuitem "Clear heightfielding" [ solid 0; slope 0 0 ]
menuitem "Undo last placed arch or slope" [ __undoarch ; -1 ]
Expand Down Expand Up @@ -701,10 +702,12 @@ menuinit [
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
if $editing_sp [
if $unsavededits [
menuitem (concat "Restore backup xmap \f3(and lose" $unsavededits "currently unsaved edits)") xmap_restore
] [
menuitem "Restore backup xmap" xmap_restore
]
]
menuitem "" -1
]
Expand All @@ -728,10 +731,12 @@ menuinit [
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)
if $editing_sp [
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)
Expand Down Expand Up @@ -825,10 +830,14 @@ menuinit [
if (strlen (getvantagepoint)) [
menuitem (format2 "Goto current map vantage point at x=%1, y=%2, z=%3, yaw=%4, pitch=%5" (getvantagepoint)) [ gotovantagepoint ]
menuitem "" -1
menuitem "\f3[ Delete vantage point ]" clearvantagepoint
menuitem "" -1
if $editing_sp [
menuitem "\f3[ Delete vantage point ]" clearvantagepoint
menuitem "" -1
]
]
if(! $connected) [
menuitem "\f0[ Set current position and viewing angle as map vantage point ]" setvantagepoint
]
menuitem "\f0[ Set current position and viewing angle as map vantage point ]" setvantagepoint
]

//// Main > Editing > Map settings > Select map license ////
Expand All @@ -840,23 +849,34 @@ menuinit [

newmenu [Map config operations]
tempalias __showorigin 0 ; tempalias __colororigin [ result (concatword " \fs\f" (if (strcmp $arg1 official) 4 2) "<" $arg1 ">\fr") ]
menuitem "Edit mapmodel slot\i\3" [ showmenu [Edit mapmodel slots] ]
menuitem "Delete unused mapmodel slot\i\3" [ showmenu [Delete unused mapmodel slot] ]
menuitem "" -1
menuitem "Edit texture slot\i\3" [ showmenu [Edit texture slots] ]
menuitem "" -1
menuitem "Edit mapsound slot\i\3" [ showmenu [Edit mapsound slots] ]
menuitem "" -1
menuitem "Delete ALL unused mapmodel slots" [loop ii 256 [ push i (- 255 $ii) ; if (&& (strlen (mapmodelslotname $i)) (strcmp "" (mapmodelslotusage $i))) [deletemapmodelslot $i] ; pop i]]
menuitem "Delete ALL unused texture slots" [loop ii 251 [ push i (- 255 $ii) ; if (&& (strlen (edittextureslot $i)) (strcmp "" (textureslotusage $i))) [deletetextureslot $i] ; pop i]]
menuitem "Delete ALL unused mapsound slots" [loop ii 256 [ push i (- 255 $ii) ; if (&& (strlen (editmapsoundslot $i)) (strcmp "" (mapsoundslotusage $i))) [deletemapsoundslot $i] ; pop i]]
menuitem "" -1
menuitem "Sort mapmodel slots\i\3" [ showmenu [Sort mapmodel slots] ]
menuitem "Sort texture slots\i\3" [ showmenu [Sort texture slots] ]
menuitem "Sort mapsound slots\i\3" [ showmenu [Sort mapsound slots] ]
menuitem "" -1
menuitem "Update mapmodel menus" "mapmodelchanged 1"
menuitemcheckbox "Show media file origin/distribution" "$__showorigin" [ __showorigin = $arg1 ; mapmodelchanged 1 ]
menuinit [
resetcurmenu
if $editing_sp [
menuitem "Edit mapmodel slot\i\3" [ showmenu [Edit mapmodel slots] ]
menuitem "Delete unused mapmodel slot\i\3" [ showmenu [Delete unused mapmodel slot] ]
menuitem "" -1
menuitem "Edit texture slot\i\3" [ showmenu [Edit texture slots] ]
menuitem "" -1
menuitem "Edit mapsound slot\i\3" [ showmenu [Edit mapsound slots] ]
menuitem "" -1
menuitem "Delete ALL unused mapmodel slots" [loop ii 256 [ push i (- 255 $ii) ; if (&& (strlen (mapmodelslotname $i)) (strcmp "" (mapmodelslotusage $i))) [deletemapmodelslot $i] ; pop i]]
menuitem "Delete ALL unused texture slots" [loop ii 251 [ push i (- 255 $ii) ; if (&& (strlen (edittextureslot $i)) (strcmp "" (textureslotusage $i))) [deletetextureslot $i] ; pop i]]
menuitem "Delete ALL unused mapsound slots" [loop ii 256 [ push i (- 255 $ii) ; if (&& (strlen (editmapsoundslot $i)) (strcmp "" (mapsoundslotusage $i))) [deletemapsoundslot $i] ; pop i]]
menuitem "" -1
menuitem "Sort mapmodel slots\i\3" [ showmenu [Sort mapmodel slots] ]
menuitem "Sort texture slots\i\3" [ showmenu [Sort texture slots] ]
menuitem "Sort mapsound slots\i\3" [ showmenu [Sort mapsound slots] ]
menuitem "" -1
menuitem "Update mapmodel menus" "mapmodelchanged 1"
][
menuitem "List mapmodel slots" [ showmenu [List mapmodel slots] ]
menuitem "List texture slots" [ showmenu [List texture slots] ]
menuitem "List mapsound slots" [ showmenu [List mapsound slots] ]
menuitem "\f4(offline edit mode required to make changes)" -1
menuitem "" -1
]
menuitemcheckbox "Show media file origin/distribution" "$__showorigin" [ __showorigin = $arg1 ; mapmodelchanged 1 ]
]

//// Main > Editing > Map config operations > Edit mapmodel slots ////

Expand Down Expand Up @@ -926,21 +946,21 @@ newmenu [Edit texture slots]
menuinit [
resetcurmenu
menurenderoffset -20 0
if $editing [
if $editing_sp [
push ecurmenu (escape (curmenu))
push info ""
push origin ""
looplisti (textureslotusagelist) [cnt used] [
info = (edittextureslot $i)
if $__showorigin [ origin = (__colororigin (gettextureorigin (at $info 1))) ]
if (|| $cnt (strlen $info)) [
if (! (strlen $info)) [ info = " \fs\f3<unassigned>\fr" ]
if (! (strlen $info)) [ info = " \fs\f3<unassigned>\fr" ; origin = "" ]
menuitem (concatword "edit texture slot #" $i ": " $info " (" $cnt " uses, " $used " visible)" $origin) (concat __texslot = $i "; showmenu [Edit texture slot]") (concat chmenutexture $ecurmenu (at $info 1))
]
]
pop info ecurmenu origin
] [
menuitem "menu only available in edit mode" -1
__menuitem_offlineeditonly // "menu only available in offline edit mode"
]
]

Expand Down Expand Up @@ -1046,7 +1066,7 @@ menuinit [
newmenu [Edit mapsound slots]
menuinit [
resetcurmenu
if $editing [
if $editing_sp [
push info ""
push origin ""
loop i 256 [
Expand All @@ -1062,7 +1082,7 @@ menuinit [
]
pop info origin
] [
menuitem "menu only available in edit mode" -1
__menuitem_offlineeditonly // "menu only available in offline edit mode"
]
]

Expand Down Expand Up @@ -1136,6 +1156,63 @@ menuitemslider "Merge " 0 2 "$__sndmerge" ["no slots" "unused identical slots" "
menuitem "" -1
menuitem "\t\t\f0[Start]" [sortmapsoundslots (at [nosort ""] $__sndsort) (at [nomerge "" mergeused] $__sndmerge)]

//// Main > Editing > Map config operations > List mapmodel slots ////

newmenu [List mapmodel slots]
menuinit [
resetcurmenu
menurenderoffset -40 0
push mpath ""
push origin ""
loop i 256 [
mpath = (mapmodelslotname $i)
if (strlen $mpath) [
if $__showorigin [
origin = (getmapmodelattributes $mpath distribution)
if (! (strlen $origin)) [ origin = "custom/unsorted" ]
origin = (__colororigin $origin)
]
menuitem [slot #@[i]: @(editmapmodelslot $i)@origin] -1 (__mm_showmodel2 [List mapmodel slots] $mpath)
]
]
pop origin mpath
]

//// Main > Editing > Map config operations > List texture slots ////

newmenu [List texture slots]
menuinit [
resetcurmenu
menurenderoffset -20 0
push info ""
push origin ""
looplisti (textureslotusagelist) [cnt used] [
info = (edittextureslot $i)
if $__showorigin [ origin = (__colororigin (gettextureorigin (at $info 1))) ]
if (strlen $info) [
menuitem [texture slot #@[i]: @info @"("@cnt uses, @used visible@")"@origin] -1 [chmenutexture [List texture slots] @(at $info 1)]
]
]
pop info origin
]

//// Main > Editing > Map config operations > List mapsound slots ////

newmenu [List mapsound slots]
menuinit [
resetcurmenu
push info ""
push origin ""
loop i 256 [
info = (editmapsoundslot $i)
if (strlen $info) [
if $__showorigin [ origin = (__colororigin (getmapsoundorigin (at $info 0))) ]
menuitem (concatword "mapsound slot #" $i ": " $info $origin) -1
]
]
pop info origin
]


//// Main > Editing > Map checks and statistics ////

Expand Down Expand Up @@ -1175,11 +1252,16 @@ tempalias __placeprobepointdummies [
//// Main > Editing > Map checks and statistics > Map area checks ////

newmenu [Map area checks]
menuitem "Heightfield slope stats" __showslopes
menuitem "Goto steepest heightfield position" [ push p (mapareacheck steepest) ; gotoposition (at $p 0) (at $p 1) (at (pop p) 2)]
menuitem "Place probe point dummies" __placeprobepointdummies
menuitem "Walk probe point dummies\i\3" [ showmenu [Walk probe point dummies] ]
menuitem "Clear probe point dummies" __clearprobepointdummies
menuinit [
resetcurmenu
menuitem "Heightfield slope stats" __showslopes
menuitem "Goto steepest heightfield position" [ push p (mapareacheck steepest) ; gotoposition (at $p 0) (at $p 1) (at (pop p) 2)]
if $editing_sp [
menuitem "Place probe point dummies" __placeprobepointdummies
menuitem "Walk probe point dummies\i\3" [ showmenu [Walk probe point dummies] ]
menuitem "Clear probe point dummies" __clearprobepointdummies
]
]

//// Main > Editing > Map checks and statistics > Map area checks > Walk probe point dummies ////

Expand Down Expand Up @@ -1243,8 +1325,10 @@ menuinit [
info = (edittextureslot $i)
menuitem (concatword "most visible " $d " texture: " (if $i (escape $info) [result <skymap>]) " (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 [])
if $editing_sp [
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
Expand Down
5 changes: 3 additions & 2 deletions config/opt/convmap.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// - stage MAPCONFIG is the only stage that will not embed the config file - all later stages embed (format 10 does not require an embedded config, but strongly encourages it)
// - can build a secondary list of licenses and mapmessages (also in saved.cfg) to allow bulk-editing of map licenses and messages outside AC

looplist "convmaplist m t" i [ tempalias $i ]

// pick up map names from the commandline ("run opt/convmap ac_2fort ac_abandoned ac_abyss ac_accomply")
if $execnumargs [
convmaplist = ""
Expand All @@ -21,8 +23,6 @@ if $execnumargs [
]
]

looplist "convmaplist m t" i [ tempalias $i ]

looplisti [ CMASTAGE CMAFIRSTERROR CMALASTERROR CMACOMMENT CMANUM ] n [ tempalias $n $i ]
tempalias cmstagenames [ NOP MAPCONFIG TRANSCLIP CLEANSLOTS FIXUNASSIGNEDS FIXBADENTS MANUALERRORS MANUALEDITING FIXPICKUPFHF FINDSTRAYENTS ]
if (checkalias uncliptagclippedmodels) [ cmstagenames = (concat $cmstagenames REDUCECLIPS) ]
Expand Down Expand Up @@ -417,6 +417,7 @@ if (! (checkalias cmcur)) [ // execute this only once
const cm_dostage_REDUCECLIPS [ // automatically un-clip mapmodels if possible
uncliptagclippedmodels
unclipentclippedmodels
duplicateclippedslots_cleanup
]
Expand Down
Loading

0 comments on commit d7277c1

Please sign in to comment.