diff --git a/source/src/console.cpp b/source/src/console.cpp index 8c7beed2..b886ec50 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -77,7 +77,7 @@ void rendercommand(int x, int y) { s_sprintfd(s)("> %s", cmdline.buf); int offset = text_width(s, cmdline.pos>=0 ? cmdline.pos+2 : -1); - blendbox(x+offset, y, x+offset+char_width(cmdline.pos>=0 ? cmdline.buf[cmdline.pos] : '_'), y+FONTH, true); + rendercursor(x+offset, y, char_width(cmdline.pos>=0 ? cmdline.buf[cmdline.pos] : '_')); draw_text(s, x, y); } diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 973e4097..1589c5f6 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -243,7 +243,7 @@ struct mitemtextinput : mitemtext if(selection) blendbox(x+tw, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false); draw_text(text, x, y); int offset = text_width(input.buf, input.pos>=0 ? input.pos : -1); - if(selection) blendbox(x+tw+offset, y, x+tw+offset+char_width(input.pos>=0 ? input.buf[input.pos] : '_'), y+FONTH, true); + if(selection) rendercursor(x+tw+offset, y, char_width(input.pos>=0 ? input.buf[input.pos] : '_')); draw_text(input.buf, x+tw, y); } @@ -310,12 +310,14 @@ struct mitemslider : mitem virtual void render(int x, int y, int w) { - static color white1(0.2f, 0.2f, 0.2f), white2(1.0f, 1.0f, 1.0f); + bool sel = isselection(); + static color white1(0.2f, 0.2f, 0.2f); + color white2(1.0f, 1.0f, 1.0f, sel ? (sinf(lastmillis/200.0f)+1.0f)/2.0f : 1.0f); int range = max_-min_; int cval = value-min_; int tw = text_width(text); - if(isselection()) blendbox(x+tw, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false); + if(sel) blendbox(x+tw, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false); draw_text(text, x, y); string v; @@ -536,7 +538,7 @@ bool menukey(int code, bool isdown, int unicode) { if(!curmenu->allowinput) return false; mitem &m = *curmenu->items[menusel]; - m.key(code, isdown, unicode); + m.key(code, isdown, unicode); return true; } } diff --git a/source/src/protos.h b/source/src/protos.h index 7bb1700a..da13d6f8 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -145,6 +145,7 @@ extern void quad(GLuint tex, float x, float y, float s, float tx, float ty, floa extern void circle(GLuint tex, float x, float y, float r, float tx, float ty, float tr, int subdiv = 32); extern void gl_drawframe(int w, int h, float changelod, float curfps); extern void clearminimap(); +extern void rendercursor(int x, int y, int w); // texture struct Texture diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 85acc777..95bc76ac 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -239,6 +239,12 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex, color *c) glDepthMask(GL_TRUE); } +void rendercursor(int x, int y, int w) +{ + color c(1, 1, 1, (sinf(lastmillis/200.0f)+1.0f)/2.0f); + blendbox(x, y, x+w, y+FONTH, true, -1, &c); +} + VARP(fov, 90, 100, 120); VAR(fog, 64, 180, 1024); VAR(fogcolour, 0, 0x8099B3, 0xFFFFFF);