Changeset - r17149:9460b4a23572
[Not reviewed]
master
0 2 0
rubidium - 14 years ago 2011-01-23 00:11:15
rubidium@openttd.org
(svn r21897) -Fix (21707): Kenobi visited IsValidConsoleColour shortly
2 files changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/console_gui.cpp
Show inline comments
 
@@ -488,30 +488,30 @@ static void IConsoleHistoryNavigate(int 
 
 * used as a history to print them onscreen
 
 * @param colour_code the colour of the command. Red in case of errors, etc.
 
 * @param str the message entered or output on the console (notice, error, etc.)
 
 */
 
void IConsoleGUIPrint(TextColour colour_code, char *str)
 
{
 
	new IConsoleLine(str, colour_code);
 
	SetWindowDirty(WC_CONSOLE, 0);
 
}
 

	
 

	
 
/**
 
 * Check whether the given TextColour is valid for console usage.
 
 * @param c The text colour to compare to.
 
 * @return true iff the TextColour is valid for console usage.
 
 */
 
bool IsValidConsoleColour(TextColour c)
 
{
 
	/* A normal text colour is used. */
 
	if (!(c & TC_IS_PALETTE_COLOUR)) return TC_BEGIN <= c && c < TC_END;
 

	
 
	/* A text colour from the palette is used; must be the company
 
	 * colour gradient, so it must be one of those. */
 
	c &= ~TC_IS_PALETTE_COLOUR;
 
	for (uint i = TC_BEGIN; i < TC_END; i++) {
 
	for (uint i = COLOUR_BEGIN; i < COLOUR_END; i++) {
 
		if (_colour_gradient[i][4] == c) return true;
 
	}
 

	
 
	return false;
 
}
src/gfx_type.h
Show inline comments
 
@@ -160,68 +160,69 @@ union Colour {
 
	};
 
};
 

	
 
/** Available font sizes */
 
enum FontSize {
 
	FS_NORMAL, ///< Index of the normal font in the font tables.
 
	FS_SMALL,  ///< Index of the small font in the font tables.
 
	FS_LARGE,  ///< Index of the large font in the font tables.
 
	FS_END,
 

	
 
	FS_BEGIN = FS_NORMAL, ///< First font.
 
};
 
DECLARE_POSTFIX_INCREMENT(FontSize)
 

	
 
/**
 
 * Used to only draw a part of the sprite.
 
 * Draw the subsprite in the rect (sprite_x_offset + left, sprite_y_offset + top) to (sprite_x_offset + right, sprite_y_offset + bottom).
 
 * Both corners are included in the drawing area.
 
 */
 
struct SubSprite {
 
	int left, top, right, bottom;
 
};
 

	
 
enum Colours {
 
	COLOUR_DARK_BLUE,
 
	COLOUR_BEGIN,
 
	COLOUR_DARK_BLUE = COLOUR_BEGIN,
 
	COLOUR_PALE_GREEN,
 
	COLOUR_PINK,
 
	COLOUR_YELLOW,
 
	COLOUR_RED,
 
	COLOUR_LIGHT_BLUE,
 
	COLOUR_GREEN,
 
	COLOUR_DARK_GREEN,
 
	COLOUR_BLUE,
 
	COLOUR_CREAM,
 
	COLOUR_MAUVE,
 
	COLOUR_PURPLE,
 
	COLOUR_ORANGE,
 
	COLOUR_BROWN,
 
	COLOUR_GREY,
 
	COLOUR_WHITE,
 
	COLOUR_END,
 
	INVALID_COLOUR = 0xFF,
 
};
 
template <> struct EnumPropsT<Colours> : MakeEnumPropsT<Colours, byte, COLOUR_DARK_BLUE, COLOUR_END, INVALID_COLOUR, 4> {};
 
template <> struct EnumPropsT<Colours> : MakeEnumPropsT<Colours, byte, COLOUR_BEGIN, COLOUR_END, INVALID_COLOUR, 4> {};
 

	
 
/** Colour of the strings, see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png */
 
enum TextColour {
 
	TC_BEGIN       = 0x00,
 
	TC_FROMSTRING  = 0x00,
 
	TC_BLUE        = 0x00,
 
	TC_SILVER      = 0x01,
 
	TC_GOLD        = 0x02,
 
	TC_RED         = 0x03,
 
	TC_PURPLE      = 0x04,
 
	TC_LIGHT_BROWN = 0x05,
 
	TC_ORANGE      = 0x06,
 
	TC_GREEN       = 0x07,
 
	TC_YELLOW      = 0x08,
 
	TC_DARK_GREEN  = 0x09,
 
	TC_CREAM       = 0x0A,
 
	TC_BROWN       = 0x0B,
 
	TC_WHITE       = 0x0C,
 
	TC_LIGHT_BLUE  = 0x0D,
 
	TC_GREY        = 0x0E,
 
	TC_DARK_BLUE   = 0x0F,
 
	TC_BLACK       = 0x10,
 
	TC_END,
 
	TC_INVALID     = 0xFF,
0 comments (0 inline, 0 general)