From 4a5c8ca5c53fb5ff31e3999bdbc8e22d72303d62 Mon Sep 17 00:00:00 2001 From: drian Date: Thu, 15 Apr 2021 10:19:58 +0200 Subject: [PATCH] #61 Cleanedit Mode --- source/src/editing.cpp | 4 ++++ source/src/entities.cpp | 7 ++++--- source/src/protos.h | 1 + source/src/renderhud.cpp | 16 +++++++++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 079bede3..2e2472ab 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -30,6 +30,9 @@ VAR(unsavededits, 1, 0, 0); VAR(editmetakeydown, 1, 0, 0); COMMANDF(editmeta, "d", (bool on) { editmetakeydown = on ? 1 : 0; } ); +VAR(cleanedit, 0, 0, 1); // hides everything in edit mode you can't see in regular mode +COMMANDF(togglecleanedit, "", () { cleanedit = !cleanedit; }); + void toggleedit(bool force) { if(player1->state==CS_DEAD) return; // do not allow dead players to edit to avoid state confusion @@ -213,6 +216,7 @@ inline void forceinsideborders(int &xy) void cursorupdate() // called every frame from hud { ASSERT(editmode); + if(cleanedit) return; flrceil = camera1->pitch >= 0 ? 2 : 0; editaxis = fabs(camera1->pitch) > 60 ? "\161\15\15"[flrceil] : "\160\13\14\157"[(int(camera1->yaw + 45) / 90) & 3]; diff --git a/source/src/entities.cpp b/source/src/entities.cpp index eca07f7f..64d56d37 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -24,6 +24,7 @@ void renderent(entity &e) void renderclip(int type, int x, int y, float xs, float ys, float h, float elev, float tilt, int shape) { + if(cleanedit) return; if(xs < 0.05f) xs = 0.05f; if(ys < 0.05f) ys = 0.05f; if(h < 0.1f) h = 0.1f; @@ -84,7 +85,7 @@ void rendermapmodels() void renderentarrow(const entity &e, const vec &dir, float radius) { - if(radius <= 0) return; + if(cleanedit || radius <= 0) return; float arrowsize = min(radius/8, 0.5f); vec epos(e.x, e.y, e.z); vec target = vec(dir).mul(radius).add(epos), arrowbase = vec(dir).mul(radius - arrowsize).add(epos), spoke; @@ -115,7 +116,7 @@ void renderentarrow(const entity &e, const vec &dir, float radius) void rendereditentities() { - if(!editmode) return; + if(!editmode || cleanedit) return; int closest = closestent(); static int lastsparkle = 0; @@ -215,7 +216,7 @@ void rendereditentities() void renderentities() { - if(editmode) return; + if(editmode && !cleanedit) return; loopv(ents) { entity &e = ents[i]; diff --git a/source/src/protos.h b/source/src/protos.h index 4d225011..65d54b94 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -758,6 +758,7 @@ extern void storeposition(short p[]); extern void restoreposition(short p[]); extern void restoreeditundo(ucharbuf &q); extern int backupeditundo(vector &buf, int undolimit, int redolimit); +extern int cleanedit; // renderhud #define HUDPOS_X_BOTTOMLEFT 20 diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 7b0a4636..72621910 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -211,6 +211,7 @@ COMMAND(loadcrosshair, "ss"); void drawcrosshair(playerent *p, int n, color *c, float size) { + if (cleanedit && editmode) return; Texture *crosshair = crosshairs[n]; if(!crosshair) { @@ -822,7 +823,20 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat char *infostr = editinfo(); int commandh = HUDPOS_Y_BOTTOMLEFT + FONTH; if(command) commandh -= rendercommand(-1, HUDPOS_Y_BOTTOMLEFT, VIRTW - FONTH); // dryrun to get height - else if(infostr) draw_text(infostr, HUDPOS_X_BOTTOMLEFT, HUDPOS_Y_BOTTOMLEFT); + else if(infostr) + { + if(cleanedit) // smaller text + { + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, VIRTW * 2, VIRTH * 2, 0, -1, 1); + glScalef(1.0, 1.0, 1.0); //set scale + draw_text(infostr, 48, VIRTH * 2 - 3 * FONTH); + glPopMatrix(); + } + else + draw_text(infostr, HUDPOS_X_BOTTOMLEFT, HUDPOS_Y_BOTTOMLEFT); + } else if(targetplayer && showtargetname) draw_text(colorname(targetplayer), HUDPOS_X_BOTTOMLEFT, HUDPOS_Y_BOTTOMLEFT); glLoadIdentity(); glOrtho(0, VIRTW*2, VIRTH*2, 0, -1, 1);