Skip to content
Permalink
Browse files

pin selection of closest entity in map editor

Pressing the middle mouse button toggles a pin on the "closest entity"
selector. The HUD will indicate the lock by showing "pinned" instead of
"closest" entity. All actions, that would otherwise affect the closest
entity, will affect the pinned entity instead. Deleting the locked entity
will unlock it.

toggleclosestentpin
  Toggles the pin on the "closest ent" selector. Bound to MOUSE3
  by default.

DOCREF togglelockclosestent
  • Loading branch information...
ac-stef committed Jun 1, 2015
1 parent d74296a commit 107a563e99aea668e2c02b4ea0357ac462fb0596
Showing with 13 additions and 1 deletion.
  1. +1 −0 config/resetbinds.cfg
  2. +1 −0 source/src/clientgame.cpp
  3. +1 −1 source/src/editing.cpp
  4. +1 −0 source/src/protos.h
  5. +9 −0 source/src/world.cpp
@@ -27,6 +27,7 @@ bind MOUSE1 attack
bind MOUSE2 altaction
editbind MOUSE2 [ showmenu editing ]
bind MOUSE3 weapon
editbind MOUSE3 toggleclosestentpin
bind MOUSE4 key_universaldelta_plus
bind MOUSE5 key_universaldelta_minus
bind BACKSPACE dropflag
@@ -1085,6 +1085,7 @@ void resetmap(bool mrproper)
pruneundos();
changedents.setsize(0);
deleted_ents.setsize(0);
pinnedclosestent = false;
particlereset();
if(mrproper)
{
@@ -106,7 +106,7 @@ char *editinfo()
{
entity &c = ents[e];
int t = c.type < MAXENTTYPES ? c.type : 0;
formatstring(info)("closest entity: %s (%s)", entnames[t], formatentityattributes(c, true));
formatstring(info)("%s entity: %s (%s)", pinnedclosestent ? "\fs\f3pinned\fr" : "closest", entnames[t], formatentityattributes(c, true));
const char *slotinfo = "unassigned slot";
if(t == MAPMODEL)
{
@@ -485,6 +485,7 @@ extern void calcmapdims();
extern bool empty_world(int factor, bool force);
extern void remip(const block &b, int level = 0);
extern void remipmore(const block &b, int level = 0);
extern bool pinnedclosestent;
extern int closestent();
extern void deletesoundentity(entity &e);
extern int findtype(const char *what);
@@ -128,9 +128,18 @@ void closestenttype(char *what)
COMMAND(nextclosestent, "");
COMMAND(closestenttype, "s");

bool pinnedclosestent = false;
static int pinnedent = -1;
COMMANDF(toggleclosestentpin, "", () { pinnedclosestent = ents.inrange((pinnedent = pinnedclosestent ? -1 : closestent())); });

int closestent() // used for delent and edit mode ent display
{
if(noteditmode("closestent")) return -1;
if(pinnedclosestent)
{
if(ents.inrange(pinnedent) && ents[pinnedent].type != NOTUSED) return pinnedent;
pinnedclosestent = false; // release lock when ent is deleted
}
int best = -1, bcnt = 0;
float bdist = 99999;
loopj(3)

0 comments on commit 107a563

Please sign in to comment.
You can’t perform that action at this time.