better selection handling for arch and slope placement
enlargearchslopeselections If the variable is set to 1, after placing an arch or a slope, the selection is enlarged, so that the arch or slope can be changed by vdelta increments (for example, to raise an arch in 1/4 cube increments). This is also the classic behaviour. If the variable is set to 0 (which is now default), the selection remains unchanged. This way, for example, the arch can be raised or lowered by regular cube increments. The arch menu allows changing the setting and also contains a script to enlarge the selections once. pushselections New script to store the positions of all current selections. Can be used repeatedly. To restore the selections, type "popselections". enlargevdeltaselections Enlarges all selections by one cube in x- and y- direction, to change a selection from the "cube area" to the "vdelta area". If an argument is given, it is used as increment value, so, for example "enlargevdeltaselections -1" undoes a previous enlargement. DOCREF enlargearchslopeselections pushselections enlargevdeltaselections
This commit is contained in:
@@ -104,10 +104,12 @@ menuitem "Edit arches..." [ showmenu "Edit arches" ]
|
||||
menuitem "" -1
|
||||
menuitemslider "Slope axis: " 0 1 "$__slopeaxis" 1 ["West to East (X)" "North to South (Y)"] [ __slopeaxis = $arg1 ]
|
||||
menuitemslider "Slope increment: " 0 5 "$__slopeinc" 1 ["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 ]" [ __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 ]
|
||||
menuitemcheckbox "Automatically enlarge selections after placing arches and slopes" "$enlargearchslopeselections" [ enlargearchslopeselections $arg1 ]
|
||||
menuitem "Enlarge selections now" enlargevdeltaselections
|
||||
menuitem "" -1
|
||||
menuitemslider "Stairs axis: " 0 1 "$__stairaxis" 1 ["West to East (X)" "North to South (Y)"] [ __stairaxis = $arg1 ]
|
||||
menuitemslider "Step width: " 0 5 "$__stairwidth" 1 ["downwards 3" "downwards 2" "downwards 1" "upwards 1" "upwards 2" "upwards 3"] [ __stairwidth = $arg1 ]
|
||||
|
||||
@@ -349,6 +349,32 @@ const selectall [
|
||||
select 2 2 (- (powf 2 (mapsize)) 4) (- (powf 2 (mapsize)) 4)
|
||||
]
|
||||
|
||||
// push and pop selection sets
|
||||
const pushselections [
|
||||
if (listlen (selx)) [
|
||||
push selsets ""
|
||||
selectionwalk [ ] [ selsets = (concat $selsets "; addselection" $sw_cursel) ]
|
||||
push popselections (concat "resetselections" (pop selsets) "; pop popselections")
|
||||
][
|
||||
echo no selction
|
||||
]
|
||||
]
|
||||
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)) [
|
||||
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
|
||||
]
|
||||
]
|
||||
|
||||
// /expandselection 1 // makes the current selection bigger by 1 cube on all sides
|
||||
const expandselection [
|
||||
if $numargs [
|
||||
|
||||
@@ -944,6 +944,8 @@ void setvdelta(int *delta)
|
||||
}
|
||||
COMMANDN(vdelta, setvdelta, "i");
|
||||
|
||||
VARP(enlargearchslopeselections, 0, 0, 1); // "1" is classic behaviour
|
||||
|
||||
const int MAXARCHVERT = 50;
|
||||
int archverts[MAXARCHVERT][MAXARCHVERT];
|
||||
bool archvinit = false;
|
||||
@@ -982,7 +984,8 @@ void arch(int *sidedelta)
|
||||
if(sel.ys>MAXARCHVERT) sel.ys = MAXARCHVERT;
|
||||
int *averts = sel.xs > sel.ys ? &archverts[sel.xs-1][0] : &archverts[sel.ys-1][0];
|
||||
addmsg(SV_EDITARCH, "ri5v", sel.x, sel.y, sel.xs, sel.ys, *sidedelta, MAXARCHVERT, averts);
|
||||
archxy(*sidedelta, averts, sel); // (changes xs and ys)
|
||||
archxy(*sidedelta, averts, sel);
|
||||
if(!enlargearchslopeselections) { sel.xs--; sel.ys--; }
|
||||
}
|
||||
}
|
||||
COMMAND(arch, "i");
|
||||
@@ -1006,6 +1009,7 @@ void slope(int *xd, int *yd)
|
||||
block &sel = sels[i];
|
||||
addmsg(SV_EDITXY, "ri7", EDITXY_SLOPE, sel.x, sel.y, sel.xs, sel.ys, *xd, *yd);
|
||||
slopexy(*xd, *yd, sel); // (changes xs and ys)
|
||||
if(!enlargearchslopeselections) { sel.xs--; sel.ys--; }
|
||||
}
|
||||
}
|
||||
COMMAND(slope, "ii");
|
||||
@@ -1044,6 +1048,7 @@ void perlin(int *scale, int *seed, int *psize)
|
||||
sel.xs++;
|
||||
sel.ys++;
|
||||
remipmore(sel);
|
||||
if(!enlargearchslopeselections) { sel.xs--; sel.ys--; }
|
||||
}
|
||||
}
|
||||
COMMAND(perlin, "iii");
|
||||
|
||||
Reference in New Issue
Block a user