diff --git a/source/src/clientextras.cpp b/source/src/clientextras.cpp index b6674fbe..31ae2aff 100644 --- a/source/src/clientextras.cpp +++ b/source/src/clientextras.cpp @@ -87,8 +87,8 @@ void renderscore(void *menu, playerent *d, int cn) { s_sprintfd(lag)("%d", d->plag); s_sprintfd(name) ("(%s)", d->name); - if(m_ctf) s_sprintf(scorelines.add().s)("%d\t%d\t%s\t%d\t%s\t%s%s (%d)", d->flagscore, d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, d->team, d->ismaster ? "\f0" : "", d->state==CS_DEAD ? name : d->name, cn); - else s_sprintf(scorelines.add().s)("%d\t%s\t%d\t%s\t%s%s (%d)", d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, m_teammode ? d->team : "", d->ismaster ? "\f0" : "", d->state==CS_DEAD ? name : d->name, cn); + if(m_ctf) s_sprintf(scorelines.add().s)("%d\t%d\t%s\t%d\t%s\t%s%s\t%d", d->flagscore, d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, d->team, d->ismaster ? "\f0" : "", d->state==CS_DEAD ? name : d->name, cn); + else s_sprintf(scorelines.add().s)("%d\t%s\t%d\t%s\t%s%s\t%d", d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, m_teammode ? d->team : "", d->ismaster ? "\f0" : "", d->state==CS_DEAD ? name : d->name, cn); menumanual(menu, scorelines.length()-1, scorelines.last().s); }; diff --git a/source/src/main.cpp b/source/src/main.cpp index 2e378aad..4914ef02 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -299,9 +299,9 @@ int main(int argc, char **argv) log("cfg"); extern void *scoremenu, *servmenu, *ctfmenu, *kickmenu, *banmenu; - scoremenu = addmenu("frags\tpj\tping\tteam\tname", false, false, renderscores); + scoremenu = addmenu("frags\tpj\tping\tteam\tname\tcn", false, false, renderscores); servmenu = addmenu("ping\tplr\tserver", true, false, refreshservers); - ctfmenu = addmenu("flags\tfrags\tpj\tping\tteam\tname", false, false, renderscores); + ctfmenu = addmenu("flags\tfrags\tpj\tping\tteam\tname\tcn", false, false, renderscores); kickmenu = addmenu("kick player", true, false); banmenu = addmenu("ban player", true, false); diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 21e8e547..2fa776f4 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -63,6 +63,7 @@ bool rendermenu() s_sprintfd(title)(m.hastitle ? "[ %s menu ]" : "%s", m.name); // EDIT: AH int mdisp = m.items.length(); int w = 0; + text_startcolumns(); loopi(mdisp) { int x = text_width(m.items[i].text); @@ -89,6 +90,7 @@ bool rendermenu() draw_text(m.items[j].text, x, y); y += step; }; + text_endcolumns(); return true; }; diff --git a/source/src/protos.h b/source/src/protos.h index d25c1c6b..3224ceec 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -163,6 +163,8 @@ extern int char_width(int c, int x = 0); extern int text_width(const char *str, int limit = -1); extern int text_visible(const char *str, int max); extern void draw_envbox(int fogdist); +extern void text_startcolumns(); +extern void text_endcolumns(); // editing extern void cursorupdate(); diff --git a/source/src/rendertext.cpp b/source/src/rendertext.cpp index cbdc2bd4..51a20d64 100644 --- a/source/src/rendertext.cpp +++ b/source/src/rendertext.cpp @@ -113,10 +113,45 @@ int char_width(int c, int x) return x; }; +static vector *columns = NULL; + +void text_startcolumns() +{ + if(!columns) columns = new vector; +}; + +void text_endcolumns() +{ + DELETEP(columns); +}; + int text_width(const char *str, int limit) { - int x = 0; - for(int i = 0; str[i] && (limit<0 || i=columns->length()) columns->add(0); + x = max(x, (*columns)[col]); + (*columns)[col] = x; + col++; + }; + break; + + default: + x = char_width(str[i], x); + break; + }; + }; return x; } @@ -125,6 +160,11 @@ int text_visible(const char *str, int max) int i = 0, x = 0; while(str[i]) { + if(str[i]=='\f') + { + i += 2; + continue; + }; x = char_width(str[i], x); if(x > max) return i; ++i; @@ -147,26 +187,36 @@ void draw_text(const char *str, int left, int top) glBindTexture(GL_TEXTURE_2D, charstex->id); glColor3ub(255,255,255); - int x = left; - int y = top; - - int i; + int x = left, y = top, col = 0; + float in_left, in_top, in_right, in_bottom; int in_width, in_height; - for (i = 0; str[i] != 0; i++) + for (int i = 0; str[i]; i++) { int c = str[i]; - if(c=='\t') { x = (x-left+PIXELTAB)/PIXELTAB*PIXELTAB+left; continue; }; - if(c=='\f') switch(str[i+1]) - { - case '0': glColor3ub(64,255,128); i++; continue; // green: player talk - case '1': glColor3ub(96,160,255); i++; continue; // blue: "echo" command - case '2': glColor3ub(255,192,64); i++; continue; // yellow: gameplay action messages, only actions done by players - case '3': glColor3ub(255,64,64); i++; continue; // red: important errors - default: continue; // white: everything else - }; - if(c==' ') { x += FONTH/2; continue; }; + switch(c) + { + case '\t': + if(columns) x = left + (*columns)[col++]; + else x = (x-left+PIXELTAB)/PIXELTAB*PIXELTAB+left; + continue; + + case '\f': + switch(str[i+1]) + { + case '0': glColor3ub(64,255,128); i++; continue; // green: player talk + case '1': glColor3ub(96,160,255); i++; continue; // blue: "echo" command + case '2': glColor3ub(255,192,64); i++; continue; // yellow: gameplay action messages, only actions done by players + case '3': glColor3ub(255,64,64); i++; continue; // red: important errors + default: continue; // white: everything else + }; + + case ' ': + x += FONTH/2; + continue; + }; + c -= 33; if(c<0 || c>=95) continue; @@ -187,8 +237,8 @@ void draw_text(const char *str, int left, int top) xtraverts += 4; x += in_width + 1; - } -} + }; +}; // also Don's code, so goes in here too :)