With cordite in the air, splintered steel, shell casings and powder burns, there’s only one explanation...
Discuss & improve the game engine.

Moderators: sparcdr, torhu, Tequila

A little extension for text color scheme [patched]

Postby Lucky Bro » Thu Aug 13, 2009 6:42 pm

Good day,

Again a short modification. This time it is mLy's friendly request.

The request:
To extend text color scheme at least to 16 colors.

How the color scheme in Q3 works & our suggestions.
We have ASCII char table (this one).
Find the '0' character. The difference between '0' and typed color character is divided by colors count. The residue of division is the color number.
Before patch we have 8 colors.
Now when you know the logic you may decide for how much colors we should extend the scheme.
I think the maximum is 31-32.. I'm not sure since it still requires checking.
Also you may suggest new colors here as well.
In patch I just made them transparent. I don't have any clue what colors we need. I'm fine with current ones.

Current implementation for 1.1:
I did all the colors from Wolfenstein wiki as it was suggested by Torhu.
Seems non-alphabetic characters could be used too, ioQuake won't let you. That is restriction of ioQuake. I don't want to modify it. But if you really need it - say it and maybe I'll take a closer look to ioQuake source. But before doing it - just try to use other colors from that scheme - maybe they will fit your needs as well.

The patch text for 1.1 version for discussion (1.0 patch is not supported from now on):
Code: Select all
Index: code/client/cl_console.c
===================================================================
--- code/client/cl_console.c   (revision 263)
+++ code/client/cl_console.c   (working copy)
@@ -545,8 +545,8 @@
          if ( ( text[x] & 0xff ) == ' ' ) {
             continue;
          }
-         if ( ( (text[x]>>8)&7 ) != currentColor ) {
-            currentColor = (text[x]>>8)&7;
+         if ( ( (text[x]>>8)&Q_COLORS_COUNT ) != currentColor ) {
+            currentColor = (text[x]>>8)&Q_COLORS_COUNT;
             re.SetColor( g_color_table[currentColor] );
          }
          SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH, v, text[x] & 0xff );
@@ -681,8 +681,8 @@
             continue;
          }
 
-         if ( ( (text[x]>>8)&7 ) != currentColor ) {
-            currentColor = (text[x]>>8)&7;
+         if ( ( (text[x]>>8)&Q_COLORS_COUNT ) != currentColor ) {
+            currentColor = (text[x]>>8)&Q_COLORS_COUNT;
             re.SetColor( g_color_table[currentColor] );
          }
          SCR_DrawSmallChar(  con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff );
Index: code/qcommon/q_math.c
===================================================================
--- code/qcommon/q_math.c   (revision 263)
+++ code/qcommon/q_math.c   (working copy)
@@ -49,7 +49,7 @@
 vec4_t      colorMdGrey   = {0.5, 0.5, 0.5, 1};
 vec4_t      colorDkGrey   = {0.25, 0.25, 0.25, 1};
 
-vec4_t   g_color_table[8] =
+vec4_t   g_color_table[Q_COLORS_COUNT+1] =
    {
    {0.0, 0.0, 0.0, 1.0},
    {1.0, 0.0, 0.0, 1.0},
@@ -59,6 +59,33 @@
    {0.0, 1.0, 1.0, 1.0},
    {1.0, 0.0, 1.0, 1.0},
    {1.0, 1.0, 1.0, 1.0},
+
+   {1.0, 0.5, 0.0, 1.0},
+   {0.5, 0.5, 0.5, 1.0},
+   {0.75, 0.75, 0.75, 1.0},
+   {0.75, 0.75, 0.75, 1.0},
+   {0.0, 0.5, 0.0, 1.0},
+   {0.5, 0.5, 0.0, 1.0},
+   {0.0, 0.0, 0.5, 1.0},
+   {0.5, 0.0, 0.0, 1.0},
+
+   {0.5, 0.25, 0.0, 1.0},
+   {1.0, 0.6, 0.1, 1.0},
+   {0.0, 0.5, 0.5, 1.0},
+   {0.5, 0.0, 0.5, 1.0},
+   {0.0, 0.5, 1.0, 1.0},
+   {0.5, 0.0, 1.0, 1.0},
+   {0.2, 0.6, 0.8, 1.0},
+   {0.8, 1.0, 0.8, 1.0},
+
+   {0.0, 0.4, 0.2, 1.0},
+   {1.0, 0.0, 0.2, 1.0},
+   {0.7, 0.1, 0.1, 1.0},
+   {0.6, 0.2, 0.0, 1.0},
+   {0.8, 0.6, 0.2, 1.0},
+   {0.6, 0.6, 0.2, 1.0},
+   {1.0, 1.0, 0.75, 1.0},
+   {1.0, 1.0, 0.5, 1.0},
    };
 
 
Index: code/qcommon/q_shared.h
===================================================================
--- code/qcommon/q_shared.h   (revision 263)
+++ code/qcommon/q_shared.h   (working copy)
@@ -419,6 +419,8 @@
 #define Q_COLOR_ESCAPE   '^'
 #define Q_IsColorString(p)   ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && isalnum(*((p)+1)) ) // ^[0-9a-zA-Z]
 
+#define Q_COLORS_COUNT 31
+
 #define COLOR_BLACK      '0'
 #define COLOR_RED      '1'
 #define COLOR_GREEN      '2'
@@ -427,7 +429,7 @@
 #define COLOR_CYAN      '5'
 #define COLOR_MAGENTA   '6'
 #define COLOR_WHITE      '7'
-#define ColorIndex(c)   ( ( (c) - '0' ) & 7 )
+#define ColorIndex(c)   ( ( (c) - '0' ) & Q_COLORS_COUNT )
 
 #define S_COLOR_BLACK   "^0"
 #define S_COLOR_RED      "^1"
@@ -438,7 +440,7 @@
 #define S_COLOR_MAGENTA   "^6"
 #define S_COLOR_WHITE   "^7"
 
-extern vec4_t   g_color_table[8];
+extern vec4_t   g_color_table[Q_COLORS_COUNT+1];
 
 #define   MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b
 #define   MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a


Can we use it now in 1.0 as we did with demo stuff?
Unfortanutely the answer is no.
Yeah, for the first look it seems that we have to replace only binary things, but no - cgame&ui QVMs are affected as well - with scoreboard and player nick name.
So we need to replace default pak0.pk3 file on each server we want to use new color scheme (or make servers unpure but that will cause cheaters wave).
Yeah, I'm disappointed about this too.
That is the reason why I haven't released new patch for 1.0.

The patch files:
ExtendColors.1.0.patch
ExtendColors1.1.patch

One more note - I understand that everyone has its own colors he wants to see, but please don't do a simple posts like "dark purple is must have!". Maybe you can just put your request in one big spoiled post with pictures or color lists..
That way we sooner came to final conclusion how many colors we should add and which those colors are.
Current solution is to use the scheme suggested by Torhu. I feel fine with it.

Yeah, there should be other more complicated way to do the thing.. But I don't want to do it. As I said I'm not using colors very often and I'm fine with current ones.

Thanks for attention!
Have a good day!
Last edited by Lucky Bro on Fri Sep 18, 2009 9:09 am, edited 2 times in total.
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Postby Conq » Thu Aug 13, 2009 6:58 pm

Good job LuckyBro ! :-)

I have an idea to extend a little more color codes. It consists to replace "^color" by "$color$" and extend a little more name's size.
For example, "^" is limited by ascii table, but with "$80$", you'll tell to color parser that you want to use color #79.
Conq
Drifter
 
Posts: 13
Joined: Sun May 31, 2009 9:37 am



Postby /dev/random » Thu Aug 13, 2009 7:11 pm

Why would one need 79 colors?
This patch is pure cosmetic. Simply include all base colors, like this (maybe add a light and a dark version, that's still less than 79 colors ;) ).

User avatar
/dev/random
Smokin' Amigo!
 
Posts: 410
Joined: Thu Jan 22, 2009 1:58 pm



Postby Lucky Bro » Fri Aug 14, 2009 9:37 am

/dev/random,
Thank you for picture! Really helpful one. I agree about these colors. To me seems enough.
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Postby mLy! » Fri Aug 14, 2009 10:39 am

Lucky Bro wrote:/dev/random,
Thank you for picture! Really helpful one. I agree about these colors. To me seems enough.



yes those seem good (+black :p )
My Latest fragmovies:
Winning BB cup
User avatar
mLy!
Gunslinger
 
Posts: 218
Joined: Wed Feb 11, 2009 8:46 pm



Postby torhu » Fri Aug 14, 2009 2:40 pm

Enemy Territory has extended the q3 color codes to support 32 colors:
http://wolfwiki.anime.net/index.php/Color_Codes

It's simple and backwards compatible.
In game: =SG=monSter
Monster Browser
User avatar
torhu
SG Team
 
Posts: 1125
Joined: Thu Jan 06, 2005 8:12 pm
Location: Norway



Looks nice!

Postby Lucky Bro » Fri Aug 14, 2009 4:05 pm

Thank you Torhu,
We could use the same if it is allowed to take someone's color table. And we already have some ET gamers, so that would be easy for them to have the same nicks as they have there.
But in the table there are 10th and 11th the same colors. Shall we do it in the same way?

EDIT: Done. See the first post for details
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Postby torhu » Fri Sep 18, 2009 12:30 am

Color support a la Enemy Territory is checked in. Thanks for the patch, Lucky Bro! I forgot to credit you in the commit message, really sorry about that. :oops:
In game: =SG=monSter
Monster Browser
User avatar
torhu
SG Team
 
Posts: 1125
Joined: Thu Jan 06, 2005 8:12 pm
Location: Norway



Postby Lucky Bro » Fri Sep 18, 2009 11:32 am

Torhu, your commit isn't my patch actually. My patch you may see in first post. I thought it was clear and readable even by ones who don't know the code.
And concerning q3ToAnsi @ Sys_AnsiColorPrint(), yes, I forgot about com_ansiColor console variable. I had to extend this array as well (including its initial definition).

The topic is closed!
Thanks everyone for participating!

Have a good day.
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Postby torhu » Fri Sep 18, 2009 5:40 pm

I did use your patch, I just fixed the Q_IsColorString macro, and the ANSI codes. And I gave the color count macro a name I thought was better, since the count of color codes is 32, and not 31. That's mostly it.
In game: =SG=monSter
Monster Browser
User avatar
torhu
SG Team
 
Posts: 1125
Joined: Thu Jan 06, 2005 8:12 pm
Location: Norway



Postby Lucky Bro » Fri Sep 18, 2009 6:39 pm

And have replaced isalnum() with !='^' check as well.
Seems that is all changes.
I won't discuss them. Your commit should work (except the initial definition of array q3ToAnsi).
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm




Return to Code

Show Sidebar
Show Sidebar

User Control Panel

cron