cleanup edithide
- replace by simple bitmask
- rewrite showedithide, setedithide and seteditshow in cubescript
- menu added for convenient use
setedithide and seteditshow no longer accept entity type numbers as
parameters - only entity type names
showedithide, setedithide and seteditshow are considered deprecated
edithideentmask
Integer variable containing a bitmask of hidden entity types.
DOCREF showedithide setedithide seteditshow edithideentmask
This commit is contained in:
@@ -668,8 +668,15 @@ menuitem "Select the next closest entity" nextclosestent
|
||||
menuitem "Copy the current closest entity" copyent
|
||||
menuitem "Paste a previously copied entity" pasteent
|
||||
menuitemslider "Select only these entities: " 0 15 "$_closestenttypestatus" 1 [All Light Playerstart Pistol Ammobox Grenades Health Armour Akimbo Mapmodel Ladder CTF-flag Sound Clip Helmet PlayerClip] [ _closestentslider $arg1 ]
|
||||
menuitem "Hide entity sparklies\i\3" [ showmenu [Hide entity sparklies] ]
|
||||
_closestentslider = [ closestenttype (at ["" light playerstart pistol ammobox grenades health armour akimbo mapmodel ladder ctf-flag sound clip helmet plclip] $arg1); _closestenttypestatus = $arg1 ]
|
||||
|
||||
//// Main > Editing > Map operations > Hide entity sparklies ////
|
||||
|
||||
newmenu [Hide entity sparklies]
|
||||
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 settings ////
|
||||
|
||||
|
||||
@@ -62,3 +62,42 @@ switch = [
|
||||
execute (getalias (format arg%1 (+ $arg1 2)))
|
||||
]
|
||||
]
|
||||
|
||||
const showedithide [
|
||||
if $edithideentmask [
|
||||
push n "Hidden entities:"
|
||||
push m 1
|
||||
looplist (listoptions ents) e [
|
||||
if (&b $edithideentmask $m) [
|
||||
n = (concat $n $e)
|
||||
]
|
||||
+= m $m
|
||||
]
|
||||
echo (pop n m)
|
||||
] [
|
||||
echo "all entities are visible"
|
||||
]
|
||||
]
|
||||
|
||||
const setedithide [
|
||||
edithideentmask 0
|
||||
looplist $arg1 e [
|
||||
push n (findlist (listoptions ents) $e)
|
||||
if (< $n 0) [
|
||||
echo "\f3" $e is not an entity type
|
||||
] [
|
||||
edithideentmask (|b $edithideentmask (powf 2 $n))
|
||||
]
|
||||
pop n
|
||||
]
|
||||
]
|
||||
|
||||
const seteditshow [
|
||||
push n (findlist (listoptions ents) $arg1)
|
||||
if (< $n 0) [
|
||||
echo "\f3" $arg1 is not an entity type
|
||||
] [
|
||||
edithideentmask (- (- (powf 2 (listlen (listoptions ents))) 1) (powf 2 $n))
|
||||
]
|
||||
pop n
|
||||
]
|
||||
|
||||
@@ -38,7 +38,6 @@ extern vector<bounceent *> bounceents;
|
||||
extern bool editmode;
|
||||
extern int unsavededits;
|
||||
extern vector<entity> ents; // map entities
|
||||
extern vector<int> eh_ents; // edithide entities
|
||||
extern vec worldpos, camup, camright, camdir; // current target of the crosshair in the world
|
||||
extern int lastmillis, totalmillis, skipmillis; // last time
|
||||
extern int curtime; // current frame time
|
||||
|
||||
+2
-60
@@ -6,9 +6,9 @@ VAR(showclips, 0, 1, 1);
|
||||
VARP(showmodelclipping, 0, 0, 1);
|
||||
VARP(showladderentities, 0, 0, 1);
|
||||
VARP(showplayerstarts, 0, 0, 1);
|
||||
VAR(edithideentmask, 0, 0, INT_MAX);
|
||||
|
||||
vector<entity> ents;
|
||||
vector<int> eh_ents; // edithide entities
|
||||
|
||||
const char *entmdlnames[] =
|
||||
{
|
||||
@@ -82,62 +82,6 @@ void rendermapmodels()
|
||||
}
|
||||
}
|
||||
|
||||
void showedithide()
|
||||
{
|
||||
if(eh_ents.length())
|
||||
{
|
||||
conoutf("Hidden entities:");
|
||||
loopv(eh_ents)
|
||||
{
|
||||
if(eh_ents[i]>0 && eh_ents[i]<MAXENTTYPES) { conoutf("#%02d: %d : %s", i, eh_ents[i], entnames[eh_ents[i]]); }
|
||||
else { conoutf("#%02d: %d : -n/a-", i, eh_ents[i]); }
|
||||
}
|
||||
}
|
||||
else conoutf("all entities are visible");
|
||||
}
|
||||
COMMAND(showedithide, "");
|
||||
|
||||
void setedithide(char *text) // FIXME: human indexing inside
|
||||
{
|
||||
eh_ents.setsize(0);
|
||||
if(text && text[0] != '\0')
|
||||
{
|
||||
char *b, *s = strtok_r(text, " ", &b);
|
||||
do
|
||||
{
|
||||
bool k = false;
|
||||
int sn = -1;
|
||||
int tn = atoi(s);
|
||||
loopi(MAXENTTYPES) if(!strcmp(entnames[i], s)) sn = i;
|
||||
if(sn!=-1) { loopv(eh_ents) { if(eh_ents[i]==sn) { k = true; } } }
|
||||
else sn = tn;
|
||||
if(!k) { if(sn>0 && sn<MAXENTTYPES) eh_ents.add(sn); }
|
||||
s = strtok_r(NULL, " ", &b);
|
||||
}
|
||||
while(s);
|
||||
}
|
||||
}
|
||||
COMMAND(setedithide, "c");
|
||||
|
||||
void seteditshow(char *just)
|
||||
{
|
||||
eh_ents.setsize(0);
|
||||
if(just && just[0] != '\0')
|
||||
{
|
||||
char *b, *s = strtok_r(just, " ", &b);
|
||||
int sn = -1;
|
||||
int tn = atoi(s);
|
||||
loopi(MAXENTTYPES) if(!strcmp(entnames[i], s)) sn = i;
|
||||
if(sn==-1) sn = tn;
|
||||
loopi(MAXENTTYPES-1)
|
||||
{
|
||||
int j = i+1;
|
||||
if(j!=sn) eh_ents.add(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
COMMAND(seteditshow, "s");
|
||||
|
||||
void renderentarrow(const entity &e, const vec &dir, float radius)
|
||||
{
|
||||
if(radius <= 0) return;
|
||||
@@ -183,9 +127,7 @@ void renderentities()
|
||||
{
|
||||
entity &e = ents[i];
|
||||
if(e.type==NOTUSED) continue;
|
||||
bool ice = false;
|
||||
loopk(eh_ents.length()) if(eh_ents[k]==e.type) ice = true;
|
||||
if(ice) continue;
|
||||
if(edithideentmask & (1 << (e.type - 1))) continue;
|
||||
vec v(e.x, e.y, e.z);
|
||||
if(vec(v).sub(camera1->o).dot(camdir) < 0) continue;
|
||||
//particle_splash(i == closest ? PART_ELIGHT : PART_ECLOSEST, 2, 40, v);
|
||||
|
||||
@@ -923,6 +923,7 @@ extern void checkweaponstate();
|
||||
extern int burstshotssettings[NUMGUNS];
|
||||
|
||||
// entities
|
||||
extern int edithideentmask;
|
||||
extern void pickupeffects(int n, playerent *d);
|
||||
extern void renderentities();
|
||||
extern void rendermapmodels();
|
||||
|
||||
@@ -175,9 +175,7 @@ int closestent() // used for delent and edit mode ent display
|
||||
entity &e = ents[i];
|
||||
if(e.type==NOTUSED) continue;
|
||||
if(clenttype != NOTUSED && e.type != clenttype) continue;
|
||||
bool ice = false;
|
||||
loopk(eh_ents.length()) if(eh_ents[k]==e.type) ice = true;
|
||||
if(ice) continue;
|
||||
if(edithideentmask & (1 << (e.type - 1))) continue;
|
||||
if(!intersectangular(camera1->o, worldpos, vec(e.x, e.y, e.z), maxangle, dist)) continue;
|
||||
if(j)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user