From 50abbbe3cec7d906a181331c68b779741394e0f7 Mon Sep 17 00:00:00 2001 From: driAn Date: Sat, 10 May 2008 20:28:49 +0000 Subject: [PATCH] text-input width git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1919 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 2 +- source/src/menus.cpp | 2 +- source/src/renderhud.cpp | 22 +++++++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 72e78c80..66ebcec2 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -885,7 +885,7 @@ void spectate(int mode) // set new spect mode void togglespect() // cycle through all spectating modes { int mode; - if(player1->spectatemode<=SM_DEATHCAM) mode = SM_FOLLOW1ST; // start with 1st person spect + if(player1->spectatemode==SM_NONE) mode = SM_FOLLOW1ST; // start with 1st person spect else mode = SM_FOLLOW1ST + (((player1->spectatemode-1) % (SM_NUM-SM_FOLLOW1ST))); spectate(mode); } diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 2ac6f43f..93347e94 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -162,7 +162,7 @@ struct mitemtextinput : mitemtext virtual void render(int x, int y, int w) { bool selection = isselection(); - int tw = max(text_width(text), VIRTW/4); + int tw = VIRTW/4; if(selection) renderbg(x+w-tw, y-FONTH/6, tw, NULL); draw_text(text, x, y); int offset = text_width(input.buf, input.pos>=0 ? input.pos : -1); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index a4cdf728..4f2c7822 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -376,6 +376,7 @@ void drawteamicons(int w, int h) void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater) { playerent *p = camera1->type==ENT_PLAYER ? (playerent *)camera1 : player1; + bool spectating = p->isspectating(); glDisable(GL_DEPTH_TEST); @@ -426,7 +427,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat char *infostr = editinfo(); if(command) rendercommand(20, 1570); else if(infostr) draw_text(infostr, 20, 1570); - else if(targetplayer) draw_text(colorname(targetplayer), 20, 1570); + else if(targetplayer && !spectating) draw_text(colorname(targetplayer), 20, 1570); glLoadIdentity(); glOrtho(0, VIRTW*2, VIRTH*2, 0, -1, 1); @@ -474,22 +475,29 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat if(!hidehudmsgs) hudmsgs.render(); - /* - if(!hidespecthud && p->state==CS_DEAD && p->spectatemode==SM_NONE) + + if(!hidespecthud && p->state==CS_DEAD && p->spectatemode<=SM_DEATHCAM) { glLoadIdentity(); glOrtho(0, VIRTW*3/2, VIRTH*3/2, 0, -1, 1); const int left = (VIRTW*3/2)*6/8, top = (VIRTH*3/2)*3/4; - draw_textf("F7 spectate", left, top); - draw_textf("F8 follow player", left, top+80); + draw_textf("SPACE to change view", left, top); + draw_textf("SCROLL to change player", left, top+80); } - */ - if(!hidespecthud && (p->state==CS_SPECTATE || (p->state==CS_DEAD && p->spectatemode!=SM_NONE))) + if(!hidespecthud && spectating) { glLoadIdentity(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); draw_text("SPECTATING", VIRTW/40, VIRTH/10*7); + if(player1->spectatemode==SM_FOLLOW1ST || player1->spectatemode==SM_FOLLOW3RD || player1->spectatemode==SM_FOLLOW3RD_TRANSPARENT) + { + if(players.inrange(player1->followplayercn) && players[player1->followplayercn]) + { + s_sprintfd(name)("Player %s", players[player1->followplayercn]->name); + draw_text(name, VIRTW/40, VIRTH/10*8); + } + } } if(p->state==CS_ALIVE)