View Issue Details

IDProjectCategoryView StatusLast Update
0002224FSSCPgraphicspublic2011-10-10 11:52
ReporterThe_E Assigned ToZacam  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version3.6.12 RC2 
Summary0002224: Chat messages may end up unreadable due to unfortunate color choice
DescriptionDuring a multi game, the engine will automatically assign a colour to each player for use in the various chat windows. If this colour is black, it will render anything that player says unreadable, as the default interface art with its dark greens and blacks hides the written text quite well.
TagsNo tags attached.

Activities

chief1983

2010-06-14 14:54

administrator   ~0012069

Never seen black personally, that's interesting. Although, some mods use different interface art, so eliminating black text would only help FS2. We may need a table solution that allows mods to restrict what color text is allowed, and eliminate black from retail by default.

taylor

2010-06-15 15:18

administrator   ~0012073

This is just a standard multi ui issue, not FS2NetD related.

The problem is in alphacolors.cpp, Color_netplayer[]. That is a bit problematic in the first place, but the black color could be easily removed from the array. I do agree that a tbl for specifying the colors is probably the best option in the long term though. The tbl could set the default colors overall and then it would apply to text everywhere, not just in the chatbox. It should be pretty trivial to add parsing colors.tbl to alpha_colors_init(), after the colors have otherwise been initialized.

So who wants to do it. :)

chief1983

2010-06-15 15:21

administrator   ~0012074

Aspiring coder task?

taylor

2010-06-15 15:35

administrator   ~0012075

And a pretty good one I think. Only one (very small) file to change, with only a little bit of tbl handling code required, and the tbl itself should be pretty simple as well.

Something like:

#Start Colors

$White: 255 255 255

#End

With the rgb values for $White set with gr_init_alphacolor(&Color_white, r, g, b, 255). This would be done for each of the 22 pre-defined color sets listed in alphacolors.h/cpp. And each of the colors would be optional of course.

It would take one of the experienced coders no more than 5-10 minutes to code in, so it should make for a good noob project. :)

The_E

2010-06-18 18:31

administrator   ~0012090

Stopgap measure (with black replaced by pink) committed in revision 6223.

CommanderDJ

2011-09-26 02:49

developer   ~0012859

Last edited: 2011-09-26 05:51

Patch and colors.tbl uploaded. Needs critique and evaluation.

Edit: New patch and tbl uploaded taking into account suggestions by IssMneur.

Edit 2: Please note the patch here is not the same as the one committed by Zacam. Updates have been made since then.

2011-09-26 03:49

 

colors.tbl (1,570 bytes)

2011-09-26 03:50

 

mantis_2224.patch (6,465 bytes)   
Index: code/freespace2/freespace.cpp
===================================================================
--- code/freespace2/freespace.cpp	(revision 7808)
+++ code/freespace2/freespace.cpp	(working copy)
@@ -2024,7 +2024,9 @@
 	load_animating_pointer(NOX("cursor"), 0, 0);	
 
 	// initialize alpha colors
-	alpha_colors_init();	
+	//CommanderDJ: try with colors.tbl first, then use the old way if that doesn't work
+	if(!new_alpha_colors_init())
+		old_alpha_colors_init();
 
 	if (Cmdline_env) {
 		ENVMAP = Default_env_map = bm_load("cubemap");
Index: code/globalincs/alphacolors.cpp
===================================================================
--- code/globalincs/alphacolors.cpp	(revision 7808)
+++ code/globalincs/alphacolors.cpp	(working copy)
@@ -8,10 +8,10 @@
 */ 
 
 #include "graphics/2d.h"
+#include "parse/parselo.h"
+#include "globalincs/def_files.h"
 #include "globalincs/alphacolors.h"
 
-
-
 // -----------------------------------------------------------------------------------
 // ALPHA DEFINES/VARS
 //
@@ -24,7 +24,7 @@
 color Color_ui_light_pink, Color_ui_pink;
 
 // netplayer colors
-color *Color_netplayer[20] = {
+color *Color_netplayer[NETPLAYER_COLORS] = {
 
 	&Color_blue,
 	&Color_bright_blue,
@@ -53,8 +53,144 @@
 // ALPHA FUNCTIONS
 //
 
+//CommanderDJ: initialise alpha colors based on tbl
+//returns 1 if successful
+//0 if not
+int new_alpha_colors_init()
+{
+	int err_code;
+	if((err_code = setjmp(parse_abort)) != 0) 
+	{
+		mprintf(("Unable to parse 'colors.tbl'!  Error code = %d.\n", err_code));
+		return 0;
+	}
+
+	if(cf_exists_full("colors.tbl", CF_TYPE_TABLES))
+	{
+		read_file_text("colors.tbl", CF_TYPE_TABLES);
+		mprintf(("TABLES => Starting parse of 'colors.tbl'...\n"));
+	}
+	else
+	{
+		//colors.tbl doesn't exist
+		mprintf(("TABLES => Unable to find 'colors.tbl'. Initialising colors with default values.\n"));
+		return 0;
+	}
+
+	reset_parse();
+	
+	//we search for the colors based on their order of definition above
+	//if the color isn't found, we just use default values
+	if(required_string("#Start Colors"))
+	{
+		//vars for holding rgba values
+		int rgba[4] = {0,0,0,0};
+
+		color *colors[TOTAL_COLORS] = {
+			&Color_blue,
+			&Color_bright_blue,
+			&Color_green,
+			&Color_bright_green,
+			&Color_black,
+			&Color_grey,
+			&Color_silver,
+			&Color_white,
+			&Color_bright_white,
+			&Color_violet_gray,
+			&Color_violet,
+			&Color_dim_red,
+			&Color_red,
+			&Color_bright_red,
+			&Color_pink,
+			&Color_light_pink,
+			&Color_yellow,
+			&Color_bright_yellow,
+			&Color_ui_light_green,
+			&Color_ui_green,
+			&Color_ui_light_pink,
+			&Color_ui_pink,
+		};
+
+		char* color_names[TOTAL_COLORS];
+		color_names[0] = "$Blue:";
+		color_names[1] = "$Bright Blue:";
+		color_names[2] = "$Green:";
+		color_names[3] = "$Bright Green:";
+		color_names[4] = "$Black:";
+		color_names[5] = "$Grey:";
+		color_names[6] = "$Silver:";
+		color_names[7] = "$White:";
+		color_names[8] = "$Bright White:";
+		color_names[9] = "$Violet Gray:";
+		color_names[10] = "$Violet:";
+		color_names[11] = "$Dim Red:";
+		color_names[12] = "$Red:";
+		color_names[13] = "$Bright Red:";
+		color_names[14] = "$Pink:";
+		color_names[15] = "$Light Pink:";
+		color_names[16] = "$Yellow:";
+		color_names[17] = "$Bright Yellow:";
+		color_names[18] = "$UI Light Green:";
+		color_names[19] = "$UI Green:";
+		color_names[20] = "$UI Light Pink:";
+		color_names[21] = "$UI Pink:";
+		
+		int rgba_defaults[TOTAL_COLORS][4] = {
+			93, 93, 128, 255,
+			185, 185, 255, 255,
+			0, 120, 0, 255,
+			50, 190, 50, 255,
+			0, 0, 0, 255,
+			65, 65, 65, 255,
+			160, 160, 160, 255,
+			105, 105, 105, 255,
+			255, 255, 255 ,255,
+			160, 144, 160, 255,
+			192, 104, 192, 255,
+			80, 6, 6, 255,
+			126, 6, 6, 255,
+			200, 0, 0, 255,
+			185, 150, 150, 255,
+			230, 190, 190, 255,
+			255, 255, 122, 255,
+			255, 255, 0, 255,
+			161, 184, 161, 255,
+			190, 228, 190, 255,
+			184, 161, 161, 255,
+			228, 190, 190, 255
+		};
+
+		//now for each color, check if it's corresponding string is there
+		for(int i=0; i<TOTAL_COLORS; i++)
+		{
+			if(optional_string(color_names[i]))
+			{
+				//if so, get its rgba values and initialise it using them
+				mprintf(("'%s' has been redefined.\n", color_names[i]));
+				stuff_int_list(rgba, 4, RAW_INTEGER_TYPE);
+				for(int j=0; j<4; j++)
+				{
+					if(rgba[j] < 0)
+					rgba[j] = 0;
+					if(rgba[j] > 255)
+					rgba[j] = 255;
+				}
+				gr_init_alphacolor(colors[i], rgba[0], rgba[1], rgba[2], rgba[3]);
+			}
+			//otherwise use its defaults
+			else
+				gr_init_alphacolor(colors[i], rgba_defaults[i][0], rgba_defaults[i][1], rgba_defaults[i][2], rgba_defaults[i][3]);
+		}
+		required_string("#End");
+
+		return 1;
+	}
+	//if we get here, then something's wrong with the table
+	return 0;
+}
+
 // initialize all alpha colors (call at startup)
-void alpha_colors_init()
+void old_alpha_colors_init()
 {
 	// See the variable declarations above for color usage
 	gr_init_alphacolor( &Color_blue, 93, 93, 128, 255 );
Index: code/globalincs/alphacolors.h
===================================================================
--- code/globalincs/alphacolors.h	(revision 7808)
+++ code/globalincs/alphacolors.h	(working copy)
@@ -11,6 +11,8 @@
 #define _GLOBAL_ALPHACOLORS_HEADER_FILE
 
 #include "graphics/2d.h"
+#include "parse/parselo.h"
+#include "globalincs/def_files.h"
 
 // -----------------------------------------------------------------------------------
 // ALPHA DEFINES/VARS
@@ -39,6 +41,7 @@
 
 #define Color_bright Color_bright_blue
 #define Color_normal Color_white
+#define TOTAL_COLORS 22
 extern color Color_blue, Color_bright_blue, Color_green, Color_bright_green;
 extern color Color_black, Color_grey, Color_silver, Color_white, Color_bright_white;
 extern color Color_violet_gray, Color_violet, Color_pink, Color_light_pink;
@@ -48,14 +51,19 @@
 extern color Color_ui_light_pink, Color_ui_pink;
 
 // netplayer colors
-extern color *Color_netplayer[20];
+#define NETPLAYER_COLORS 20
+extern color *Color_netplayer[NETPLAYER_COLORS];
 
 // -----------------------------------------------------------------------------------
 // ALPHA FUNCTIONS
 //
 
-// initialize all alpha colors (call at startup)
-void alpha_colors_init();
+//initialize alpha colors based on colors.tbl
+int new_alpha_colors_init();
 
+//initialize alpha colors based on hardcoded values
+void old_alpha_colors_init();
 
+
+
 #endif
mantis_2224.patch (6,465 bytes)   

Zacam

2011-09-26 05:47

administrator   ~0012860

Fix committed to Trunk via Revision 7809.
Leaving in "Feedback" for testing purposes.
Will "resolve" in 14 days if no follow up.

Zacam

2011-10-10 11:52

administrator   ~0012889

Setting to resolved per last note.

Issue History

Date Modified Username Field Change
2010-06-13 22:34 The_E New Issue
2010-06-14 14:54 chief1983 Note Added: 0012069
2010-06-15 15:18 taylor Note Added: 0012073
2010-06-15 15:18 taylor Category FS2NetD => graphics
2010-06-15 15:21 chief1983 Note Added: 0012074
2010-06-15 15:35 taylor Note Added: 0012075
2010-06-18 18:31 The_E Note Added: 0012090
2011-09-26 02:48 CommanderDJ File Added: mantis_2224.patch
2011-09-26 02:48 CommanderDJ File Added: colors.tbl
2011-09-26 02:49 CommanderDJ Note Added: 0012859
2011-09-26 03:48 iss_mneur File Deleted: mantis_2224.patch
2011-09-26 03:48 iss_mneur File Deleted: colors.tbl
2011-09-26 03:49 CommanderDJ File Added: colors.tbl
2011-09-26 03:50 CommanderDJ File Added: mantis_2224.patch
2011-09-26 03:50 CommanderDJ Note Edited: 0012859
2011-09-26 05:47 Zacam Note Added: 0012860
2011-09-26 05:47 Zacam Assigned To => Zacam
2011-09-26 05:47 Zacam Status new => feedback
2011-09-26 05:51 CommanderDJ Note Edited: 0012859
2011-10-10 11:52 Zacam Note Added: 0012889
2011-10-10 11:52 Zacam Status feedback => resolved
2011-10-10 11:52 Zacam Resolution open => fixed