merge old and new entity copy/paste

- copyent and pasteent now also work with the menu list of copied ents
- pressing editmeta while using pasteent opens the menu
- new switch command (not unlike the old one)
- make expandselection and shrinkselection work with multiple selections

DOCREF switch copyent pasteent
This commit is contained in:
ac-stef
2017-06-15 14:00:54 +02:00
parent 43aea343ad
commit 8235300d77
4 changed files with 34 additions and 81 deletions
+3 -5
View File
@@ -234,10 +234,10 @@ menuinit [
menuitem "Place clip entity\i\3" [ showmenu Clips ]
menuitem "" -1
push n (format2 "%1 %5 %6 %7 %8 %9 %010 %011" (editentity (getclosestent)))
push d (findlist "mapmodel sound" (at $n 0)); d = (if (! $d) [mapmodelslotname (at $n 2)] [if (= $d 1) [at (editmapsoundslot (at $n 1)) 0]])
menuitem "Copy closest entity" (format "newmenu [Paste entity]; menuitem \"paste: %1 %2\" \"newent7 %1\"; echo entity copied: %1 %2" $n $d) [] (format "\f4current closest entity:\n%1\n%2" $n $d)
push d (switch (findlist "mapmodel sound" (at $n 0)) [mapmodelslotname (at $n 2)] [at (editmapsoundslot (at $n 1)) 0])
menuitem "Copy closest entity" copyent [] (format "\fs\f4current closest entity:\n\fr%1\f4\n%2" (pop n) (pop d))
menuitem "Paste entity\i\3" [ showmenu [Paste entity] ]
pop n d
menuitem "Paste last copied entity" pasteent
menuitem "" -1
menuitem "Show list of TODO entities\i\3" [ showmenu "TODO entities" ]
menuitem "Show list of deleted entities\i\3" [ showmenu "Deleted entities" ]
@@ -684,8 +684,6 @@ menuitem "Newmap (128x128 cubes - recommended)" [ newmap 7 ]
menuitem "Newmap (256x256 cubes)" [ newmap 8 ]
menuitem "Increase mapsize (2x)" [ mapenlarge; echo The map size has been increased by 2. However, the new space is solid. To utilize it, you will need to turn it into non-solid space, by selecting it and pressing G. ]
menuitem "Print entity stats" entstats
menuitem "Copy the current closest entity" copyent
menuitem "Paste a previously copied entity" pasteent
menuitem "Cycle through multiple closest entities" nextclosestent
menuitemslider "Select only entities of this type: " 0 -1 "(closestenttype -)" (concat all (listoptions ents)) [ if $arg1 [ closestenttype $arg1 ] [ closestenttype ] ] 1
menuitem "Hide entity sparklies\i\3" [ showmenu [Hide entity sparklies] ]
-9
View File
@@ -55,15 +55,6 @@ loop k 10 [ const (at [green blue yellow red gray white dbrown dred purple orang
]
]
// switch - Takes an integer argument to determine which block of code to execute.
// NOTE: This command can only handle up to 23 "cases" (24 arguments).
const MAX_ARGS 24
switch = [
if (&& (<= $numargs $MAX_ARGS) (checkrange $arg1 0 (- $MAX_ARGS 2))) [
execute (getalias (format arg%1 (+ $arg1 2)))
]
]
const showedithide [
if $edithideentmask [
push n "Hidden entities:"
+4 -7
View File
@@ -259,13 +259,10 @@ echo "\fs\f2selectmiddle\fr\tfind middle cube in selection"
tempalias selectmiddle [
if $editing [
push res resetselections
loop i (listlen (selx)) [
push x (at (selx) $i)
push y (at (sely) $i)
push xs (at (selxs) $i)
push ys (at (selys) $i)
res = (concat $res ";" addselection (+ $x (div $xs 2)) (+ $y (div $ys 2)) 1 1)
pop x y xs ys
selectionwalk [] [
looplist $sw_cursel [x y xs ys] [
res = (concat $res ";" addselection (+ $x (div $xs 2)) (+ $y (div $ys 2)) 1 1)
]
]
echo reduced (listlen (selx)) selections to the middle cube
res
+27 -60
View File
@@ -66,6 +66,7 @@ const closecurmenu [ closemenu (curmenu) ]
const resetcurmenu [ delmenu (curmenu) ; newmenu (curmenu) ]
const refreshcurmenu [ push __curmenu (curmenu); closecurmenu; showmenu (pop __curmenu) ]
const refreshcurmenudelayed [ push __curmenu (curmenu); closecurmenu; sleep 0 [ showmenu (pop __curmenu) ] ]
const switch [ if (&& (< $arg1 $numargs) (>= $arg1 0)) [ arg@(+ $arg1 2) ]]
// Auto-completions
const mapcomplete [complete $arg1 "packages/maps/official packages/maps" cgz]
@@ -134,7 +135,6 @@ const NUM_WEAPONS (listlen (listoptions weapons))
const NUM_MODES (listlen $MODES)
const MAX_CLIENTS 16
const MAX_BOT_MATCH_LENGTH 60
const ENT_NUM_ATTRS 4
const getgunindex [ findlist (listoptions weapons) $arg1 ]
loop r $NUM_MODES [ const (at $MODES $r) (format [votemap %1 %2 %3] $r "$arg1" "$arg2") ]
@@ -179,7 +179,7 @@ const gndtoggle [ ptoggle grenades ]
const altaction [ (concatword altaction_ (curweapon)) ]
const checkmag [ result (|| (magcontent $arg1) (magreserve $arg1)) ]
const checkrange [ result (&& (>=f $arg1 $arg2) (<=f $arg1 $arg3)) ]
const checkrange [ && (>=f $arg1 $arg2) (<=f $arg1 $arg3) ] // checkrange x min max
loop i $NUM_WEAPONS [ (concatword altaction_ $i) = quicknadethrow ] // Quick nade throw is default
// Use format to define altaction_N aliases from now on, makes for less edits in the future if weapon IDs change. - Bukz
@@ -217,7 +217,7 @@ const universaldelta [
if $editing [ s = edit ] [
if (player1 alive) [ s = game ] [ s = spect ]
]
(concatword delta _ (pop s) _ $modifier) (* $arg1 (at "1 3" $editmetakeydown)) (* $arg1 (at "1 10" $editmetakeydown))
[delta_@(pop s)_@modifier] (* $arg1 (at "1 3" $editmetakeydown)) (* $arg1 (at "1 10" $editmetakeydown))
]
// To utilize the below, you will need to bind "domodifier X"
// (replace X with the number of the delta_edit) to a key. To
@@ -231,7 +231,7 @@ delta_edit_3 = [ edittex (+ $flrceil 1) $arg1 ] // Change wall/upper-wall textur
delta_edit_4 = [ equalize $flrceil ] // Equalize floor/ceiling...
delta_edit_6 = [ entproperty $editaxis $arg1 ] // Move map entity...
delta_edit_10 = [ if (checkrange (+f $flyspeed (divf $arg1 4)) 1 5) [ flyspeed (+f $flyspeed (divf $arg1 4)); echo $flyspeed ] ] // Tweak flyspeed
delta_edit_11 = [ if (> $arg1 0) [ expandselection 1 ] [ shrinkselection 1 ] ] // Expand/shrink the current selection
delta_edit_11 = [ expandselection $arg1 ] // Expand/shrink the current selection
delta_edit_attr1 = [ entproperty 0 $arg2 $editmeta2down ] // Changes the first value on entities...
delta_edit_attr2 = [ entproperty 1 $arg2 $editmeta2down ] // Changes the second value on entities...
delta_edit_attr3 = [ entproperty 2 $arg2 $editmeta2down ] // Changes the third value on entities...
@@ -292,26 +292,17 @@ const rrnd [ + (rnd (- $arg2 $arg1)) $arg1 ]
const listaverage [ push sum "" ; looplist $arg1 n [ +=f sum $n ] ; if (strlen $sum) [ div=f sum (listlen $arg1) ] ; result (pop sum) ]
forceinit [cp_entbuf cp_entstr] NULL
const get_ent_attrs [ cp_entbuf = (getenttype); loop gea $ENT_NUM_ATTRS [ add2list cp_entbuf (getentattr $gea) ] ]
tempalias pasteent [if $editing [echo no entity copied, yet]]
const copyent [
if $editing [
get_ent_attrs
cp_entstr = (concatword "\f9(" (at $cp_entbuf 0) [ ] (at $cp_entbuf 1) [ ] (at $cp_entbuf 2) [ ] (at $cp_entbuf 3) [ ] (at $cp_entbuf 4) ")\f5") // Output (a string): (enttype param1 param2 param3 param4)
echo "\f1Note: \f5The current closest entity:" $cp_entstr - has been copied.
]
]
const pasteent [
if $editing [
if (strcmp (at $cp_entbuf 0) mapmodel) [
newent (at $cp_entbuf 0) (at $cp_entbuf 2) (at $cp_entbuf 3) (at $cp_entbuf 4)
] [
newent (at $cp_entbuf 0) (at $cp_entbuf 1) (at $cp_entbuf 2) (at $cp_entbuf 3) (at $cp_entbuf 4)
if $editing [
push n (format2 "%1 %5 %6 %7 %8 %9 %010 %011" (editentity (getclosestent)))
push d (switch (findlist "mapmodel sound" (at $n 0)) [mapmodelslotname (at $n 2)] [at (editmapsoundslot (at $n 1)) 0])
pasteent = [if $editing [if $editmetakeydown [showmenu [Paste entity]] [newent7 @@@n ; echo @@@n @@@d pasted.]]]
newmenu [Paste entity]
menuitem [paste: @n @d] [newent7 @n ; echo @n @d pasted.]
echo $n $d copied.
pop n d
]
echo "\f1Note: \f5The previously copied entity:" $cp_entstr - has been pasted.
]
]
const newent7 [ // like newent, but setting all seven attributes directly
@@ -389,53 +380,29 @@ const pushselections [
]
tempalias popselections [ echo no selections stored ]
// enlarge selections after slope or arch placement to change all vdelta values (when enlargearchslopeselections is 0)
const enlargevdeltaselections [
if (listlen (selx)) [
const __changeselectionsize [
if (&& $editing (= $numargs 4)) [
push selsets ""
push i (if $numargs $arg1 1)
selectionwalk [] [ selsets = (concat $selsets $sw_cursel) ]
resetselections
looplist (pop selsets) [x y xs ys] [ addselection $x $y (+ $xs $i) (+ $ys $i) ]
pop i
][
echo no selction
looplist (pop selsets) [x y xs ys] [
if (&& (> (+ $xs $arg3) 0) (> (+ $ys $arg4) 0)) [
addselection (- $x $arg1) (- $y $arg2) (+ $xs $arg3) (+ $ys $arg4)
] [
addselection $x $y $xs $ys
]
]
]
]
// enlarge selections after slope or arch placement to change all vdelta values (when enlargearchslopeselections is 0)
const enlargevdeltaselections [ __changeselectionsize 0 0 (if $numargs $arg1 1) (if $numargs $arg1 1) ]
// /expandselection 1 // makes the current selection bigger by 1 cube on all sides
const expandselection [
if $numargs [
et1 = $arg1
if (> $et1 0) [
ep1 = (selx)
ep2 = (sely)
eps1 = (selxs)
eps2 = (selys)
select (- $ep1 $et1) (- $ep2 $et1) (+ $eps1 (* $et1 2)) (+ $eps2 (* $et1 2))
result 1
] [ result 0 ]
] [ result 0 ]
]
const expandselection [ if $numargs [ __changeselectionsize $arg1 $arg1 (* 2 $arg1) (* 2 $arg1) ] ]
// /shrinkselection 1 // makes the current selection smaller by 1 cube on all sides
const shrinkselection [
if $numargs [
st1 = $arg1
if (> $st1 0) [
sp1 = (selx)
sp2 = (sely)
sps1 = (selxs)
sps2 = (selys)
sps1 = (- $sps1 (* $st1 2))
sps2 = (- $sps2 (* $st1 2))
if (&& (> $sps1 0) (> $sps2 0)) [
select (+ $sp1 $st1) (+ $sp2 $st1) $sps1 $sps2
result 1
] [ result 0 ]
] [ result 0 ]
] [ result 0 ]
]
const shrinkselection [ if $numargs [ *= arg1 -1 ; __changeselectionsize $arg1 $arg1 (* 2 $arg1) (* 2 $arg1) ] ]
alias updateeditinfopanel explainclosestentity // default hook