mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r15425) -Codechange: some color->colour changes and type safety.
This commit is contained in:
parent
861e9cefb3
commit
8dae160d0f
|
@ -674,7 +674,7 @@ struct AIDebugWindow : public Window {
|
||||||
uint pos = (log->count + log->pos - i) % log->count;
|
uint pos = (log->count + log->pos - i) % log->count;
|
||||||
if (log->lines[pos] == NULL) break;
|
if (log->lines[pos] == NULL) break;
|
||||||
|
|
||||||
uint colour;
|
TextColour colour;
|
||||||
switch (log->type[pos]) {
|
switch (log->type[pos]) {
|
||||||
case AILog::LOG_SQ_INFO: colour = TC_BLACK; break;
|
case AILog::LOG_SQ_INFO: colour = TC_BLACK; break;
|
||||||
case AILog::LOG_SQ_ERROR: colour = TC_RED; break;
|
case AILog::LOG_SQ_ERROR: colour = TC_RED; break;
|
||||||
|
|
|
@ -228,7 +228,7 @@ public:
|
||||||
if (_settings_game.economy.station_noise_level) {
|
if (_settings_game.economy.station_noise_level) {
|
||||||
/* show the noise of the selected airport */
|
/* show the noise of the selected airport */
|
||||||
SetDParam(0, airport->noise_level);
|
SetDParam(0, airport->noise_level);
|
||||||
DrawString(2, 206, STR_STATION_NOISE, 0);
|
DrawString(2, 206, STR_STATION_NOISE, TC_FROMSTRING);
|
||||||
y_noise_offset = 10;
|
y_noise_offset = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,16 @@ struct IConsoleLine {
|
||||||
static int size; ///< The amount of items in the backlog
|
static int size; ///< The amount of items in the backlog
|
||||||
|
|
||||||
IConsoleLine *previous; ///< The previous console message.
|
IConsoleLine *previous; ///< The previous console message.
|
||||||
char *buffer; ///< The data to store.
|
char *buffer; ///< The data to store.
|
||||||
uint16 colour; ///< The colour of the line.
|
TextColour colour; ///< The colour of the line.
|
||||||
uint16 time; ///< The amount of time the line is in the backlog.
|
uint16 time; ///< The amount of time the line is in the backlog.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the console line.
|
* Initialize the console line.
|
||||||
* @param buffer the data to print.
|
* @param buffer the data to print.
|
||||||
* @param colour the colour of the line.
|
* @param colour the colour of the line.
|
||||||
*/
|
*/
|
||||||
IConsoleLine(char *buffer, uint16 colour) :
|
IConsoleLine(char *buffer, TextColour colour) :
|
||||||
previous(IConsoleLine::front),
|
previous(IConsoleLine::front),
|
||||||
buffer(buffer),
|
buffer(buffer),
|
||||||
colour(colour),
|
colour(colour),
|
||||||
|
@ -172,11 +172,11 @@ struct IConsoleWindow : Window
|
||||||
/* If the text is longer than the window, don't show the starting ']' */
|
/* If the text is longer than the window, don't show the starting ']' */
|
||||||
int delta = this->width - 10 - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH;
|
int delta = this->width - 10 - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH;
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
DoDrawString("]", 5, this->height - ICON_LINE_HEIGHT, CC_COMMAND);
|
DoDrawString("]", 5, this->height - ICON_LINE_HEIGHT, (TextColour)CC_COMMAND);
|
||||||
delta = 0;
|
delta = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoDrawString(_iconsole_cmdline.buf, 10 + delta, this->height - ICON_LINE_HEIGHT, CC_COMMAND);
|
DoDrawString(_iconsole_cmdline.buf, 10 + delta, this->height - ICON_LINE_HEIGHT, (TextColour)CC_COMMAND);
|
||||||
|
|
||||||
if (_focused_window == this && _iconsole_cmdline.caret) {
|
if (_focused_window == this && _iconsole_cmdline.caret) {
|
||||||
DoDrawString("_", 10 + delta + _iconsole_cmdline.caretxoffs, this->height - ICON_LINE_HEIGHT, TC_WHITE);
|
DoDrawString("_", 10 + delta + _iconsole_cmdline.caretxoffs, this->height - ICON_LINE_HEIGHT, TC_WHITE);
|
||||||
|
@ -442,6 +442,6 @@ static void IConsoleHistoryNavigate(int direction)
|
||||||
*/
|
*/
|
||||||
void IConsoleGUIPrint(ConsoleColour color_code, char *str)
|
void IConsoleGUIPrint(ConsoleColour color_code, char *str)
|
||||||
{
|
{
|
||||||
new IConsoleLine(str, color_code);
|
new IConsoleLine(str, (TextColour)color_code);
|
||||||
SetWindowDirty(FindWindowById(WC_CONSOLE, 0));
|
SetWindowDirty(FindWindowById(WC_CONSOLE, 0));
|
||||||
}
|
}
|
||||||
|
|
170
src/gfx.cpp
170
src/gfx.cpp
|
@ -47,7 +47,7 @@ DrawPixelInfo *_cur_dpi;
|
||||||
byte _colour_gradient[COLOUR_END][8];
|
byte _colour_gradient[COLOUR_END][8];
|
||||||
|
|
||||||
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = NULL);
|
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = NULL);
|
||||||
static int ReallyDoDrawString(const char *string, int x, int y, uint16 real_colour, bool parse_string_also_when_clipped = false);
|
static int ReallyDoDrawString(const char *string, int x, int y, TextColour colour, bool parse_string_also_when_clipped = false);
|
||||||
|
|
||||||
FontSize _cur_fontsize;
|
FontSize _cur_fontsize;
|
||||||
static FontSize _last_fontsize;
|
static FontSize _last_fontsize;
|
||||||
|
@ -61,8 +61,8 @@ static uint8 _cursor_backup[64 * 64 * 4];
|
||||||
* @ingroup dirty
|
* @ingroup dirty
|
||||||
*/
|
*/
|
||||||
static Rect _invalid_rect;
|
static Rect _invalid_rect;
|
||||||
static const byte *_color_remap_ptr;
|
static const byte *_colour_remap_ptr;
|
||||||
static byte _string_colorremap[3];
|
static byte _string_colourremap[3];
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
DIRTY_BLOCK_HEIGHT = 8,
|
DIRTY_BLOCK_HEIGHT = 8,
|
||||||
|
@ -97,13 +97,13 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo)
|
||||||
* @param top Minimum Y (inclusive)
|
* @param top Minimum Y (inclusive)
|
||||||
* @param right Maximum X (inclusive)
|
* @param right Maximum X (inclusive)
|
||||||
* @param bottom Maximum Y (inclusive)
|
* @param bottom Maximum Y (inclusive)
|
||||||
* @param color A 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolor spritenumber (FILLRECT_RECOLOR)
|
* @param colour A 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolour spritenumber (FILLRECT_RECOLOR)
|
||||||
* @param mode
|
* @param mode
|
||||||
* FILLRECT_OPAQUE: Fill the rectangle with the specified color
|
* FILLRECT_OPAQUE: Fill the rectangle with the specified colour
|
||||||
* FILLRECT_CHECKER: Like FILLRECT_OPAQUE, but only draw every second pixel (used to grey out things)
|
* FILLRECT_CHECKER: Like FILLRECT_OPAQUE, but only draw every second pixel (used to grey out things)
|
||||||
* FILLRECT_RECOLOR: Apply a recolor sprite to every pixel in the rectangle currently on screen
|
* FILLRECT_RECOLOR: Apply a recolour sprite to every pixel in the rectangle currently on screen
|
||||||
*/
|
*/
|
||||||
void GfxFillRect(int left, int top, int right, int bottom, int color, FillRectMode mode)
|
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
|
||||||
{
|
{
|
||||||
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
||||||
const DrawPixelInfo *dpi = _cur_dpi;
|
const DrawPixelInfo *dpi = _cur_dpi;
|
||||||
|
@ -132,17 +132,17 @@ void GfxFillRect(int left, int top, int right, int bottom, int color, FillRectMo
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
default: // FILLRECT_OPAQUE
|
default: // FILLRECT_OPAQUE
|
||||||
blitter->DrawRect(dst, right, bottom, (uint8)color);
|
blitter->DrawRect(dst, right, bottom, (uint8)colour);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILLRECT_RECOLOR:
|
case FILLRECT_RECOLOR:
|
||||||
blitter->DrawColorMappingRect(dst, right, bottom, GB(color, 0, PALETTE_WIDTH));
|
blitter->DrawColorMappingRect(dst, right, bottom, GB(colour, 0, PALETTE_WIDTH));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILLRECT_CHECKER: {
|
case FILLRECT_CHECKER: {
|
||||||
byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
|
byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
|
||||||
do {
|
do {
|
||||||
for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)color);
|
for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)colour);
|
||||||
dst = blitter->MoveTo(dst, 0, 1);
|
dst = blitter->MoveTo(dst, 0, 1);
|
||||||
} while (--bottom > 0);
|
} while (--bottom > 0);
|
||||||
break;
|
break;
|
||||||
|
@ -150,7 +150,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int color, FillRectMo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxDrawLine(int x, int y, int x2, int y2, int color)
|
void GfxDrawLine(int x, int y, int x2, int y2, int colour)
|
||||||
{
|
{
|
||||||
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
||||||
DrawPixelInfo *dpi = _cur_dpi;
|
DrawPixelInfo *dpi = _cur_dpi;
|
||||||
|
@ -166,10 +166,10 @@ void GfxDrawLine(int x, int y, int x2, int y2, int color)
|
||||||
if (x > dpi->width && x2 > dpi->width) return;
|
if (x > dpi->width && x2 > dpi->width) return;
|
||||||
if (y > dpi->height && y2 > dpi->height) return;
|
if (y > dpi->height && y2 > dpi->height) return;
|
||||||
|
|
||||||
blitter->DrawLine(dpi->dst_ptr, x, y, x2, y2, dpi->width, dpi->height, color);
|
blitter->DrawLine(dpi->dst_ptr, x, y, x2, y2, dpi->width, dpi->height, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxDrawLineUnscaled(int x, int y, int x2, int y2, int color)
|
void GfxDrawLineUnscaled(int x, int y, int x2, int y2, int colour)
|
||||||
{
|
{
|
||||||
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
||||||
DrawPixelInfo *dpi = _cur_dpi;
|
DrawPixelInfo *dpi = _cur_dpi;
|
||||||
|
@ -187,7 +187,7 @@ void GfxDrawLineUnscaled(int x, int y, int x2, int y2, int color)
|
||||||
|
|
||||||
blitter->DrawLine(dpi->dst_ptr, UnScaleByZoom(x, dpi->zoom), UnScaleByZoom(y, dpi->zoom),
|
blitter->DrawLine(dpi->dst_ptr, UnScaleByZoom(x, dpi->zoom), UnScaleByZoom(y, dpi->zoom),
|
||||||
UnScaleByZoom(x2, dpi->zoom), UnScaleByZoom(y2, dpi->zoom),
|
UnScaleByZoom(x2, dpi->zoom), UnScaleByZoom(y2, dpi->zoom),
|
||||||
UnScaleByZoom(dpi->width, dpi->zoom), UnScaleByZoom(dpi->height, dpi->zoom), color);
|
UnScaleByZoom(dpi->width, dpi->zoom), UnScaleByZoom(dpi->height, dpi->zoom), colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,18 +220,18 @@ void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3)
|
||||||
* ....V.
|
* ....V.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const byte color = 255;
|
static const byte colour = 255;
|
||||||
|
|
||||||
GfxDrawLineUnscaled(x, y, x + dx1, y + dy1, color);
|
GfxDrawLineUnscaled(x, y, x + dx1, y + dy1, colour);
|
||||||
GfxDrawLineUnscaled(x, y, x + dx2, y + dy2, color);
|
GfxDrawLineUnscaled(x, y, x + dx2, y + dy2, colour);
|
||||||
GfxDrawLineUnscaled(x, y, x + dx3, y + dy3, color);
|
GfxDrawLineUnscaled(x, y, x + dx3, y + dy3, colour);
|
||||||
|
|
||||||
GfxDrawLineUnscaled(x + dx1, y + dy1, x + dx1 + dx2, y + dy1 + dy2, color);
|
GfxDrawLineUnscaled(x + dx1, y + dy1, x + dx1 + dx2, y + dy1 + dy2, colour);
|
||||||
GfxDrawLineUnscaled(x + dx1, y + dy1, x + dx1 + dx3, y + dy1 + dy3, color);
|
GfxDrawLineUnscaled(x + dx1, y + dy1, x + dx1 + dx3, y + dy1 + dy3, colour);
|
||||||
GfxDrawLineUnscaled(x + dx2, y + dy2, x + dx2 + dx1, y + dy2 + dy1, color);
|
GfxDrawLineUnscaled(x + dx2, y + dy2, x + dx2 + dx1, y + dy2 + dy1, colour);
|
||||||
GfxDrawLineUnscaled(x + dx2, y + dy2, x + dx2 + dx3, y + dy2 + dy3, color);
|
GfxDrawLineUnscaled(x + dx2, y + dy2, x + dx2 + dx3, y + dy2 + dy3, colour);
|
||||||
GfxDrawLineUnscaled(x + dx3, y + dy3, x + dx3 + dx1, y + dy3 + dy1, color);
|
GfxDrawLineUnscaled(x + dx3, y + dy3, x + dx3 + dx1, y + dy3 + dy1, colour);
|
||||||
GfxDrawLineUnscaled(x + dx3, y + dy3, x + dx3 + dx2, y + dy3 + dy2, color);
|
GfxDrawLineUnscaled(x + dx3, y + dy3, x + dx3 + dx2, y + dy3 + dy2, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -378,17 +378,17 @@ static inline int TruncateStringID(StringID src, char *dest, int maxw, const cha
|
||||||
* @param x X position to start drawing
|
* @param x X position to start drawing
|
||||||
* @param y Y position to start drawing
|
* @param y Y position to start drawing
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
*
|
*
|
||||||
* @return Horizontal coordinate after drawing the string
|
* @return Horizontal coordinate after drawing the string
|
||||||
*/
|
*/
|
||||||
int DrawString(int x, int y, StringID str, uint16 color)
|
int DrawString(int x, int y, StringID str, TextColour colour)
|
||||||
{
|
{
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
|
|
||||||
GetString(buffer, str, lastof(buffer));
|
GetString(buffer, str, lastof(buffer));
|
||||||
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
||||||
return ReallyDoDrawString(buffer, x, y, color);
|
return ReallyDoDrawString(buffer, x, y, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -397,17 +397,17 @@ int DrawString(int x, int y, StringID str, uint16 color)
|
||||||
* @param x X position to start drawing
|
* @param x X position to start drawing
|
||||||
* @param y Y position to start drawing
|
* @param y Y position to start drawing
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
* @param maxw Maximal width of the string
|
* @param maxw Maximal width of the string
|
||||||
*
|
*
|
||||||
* @return Horizontal coordinate after drawing the (possibly truncated) string
|
* @return Horizontal coordinate after drawing the (possibly truncated) string
|
||||||
*/
|
*/
|
||||||
int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw)
|
int DrawStringTruncated(int x, int y, StringID str, TextColour colour, uint maxw)
|
||||||
{
|
{
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
TruncateStringID(str, buffer, maxw, lastof(buffer));
|
TruncateStringID(str, buffer, maxw, lastof(buffer));
|
||||||
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
||||||
return ReallyDoDrawString(buffer, x, y, color);
|
return ReallyDoDrawString(buffer, x, y, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -416,11 +416,11 @@ int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw)
|
||||||
* @param x Right-most x position of the string
|
* @param x Right-most x position of the string
|
||||||
* @param y Y position of the string
|
* @param y Y position of the string
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
*
|
*
|
||||||
* @return Width of drawn string in pixels
|
* @return Width of drawn string in pixels
|
||||||
*/
|
*/
|
||||||
int DrawStringRightAligned(int x, int y, StringID str, uint16 color)
|
int DrawStringRightAligned(int x, int y, StringID str, TextColour colour)
|
||||||
{
|
{
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
int w;
|
int w;
|
||||||
|
@ -429,7 +429,7 @@ int DrawStringRightAligned(int x, int y, StringID str, uint16 color)
|
||||||
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
||||||
|
|
||||||
w = GetStringBoundingBox(buffer).width;
|
w = GetStringBoundingBox(buffer).width;
|
||||||
ReallyDoDrawString(buffer, x - w, y, color);
|
ReallyDoDrawString(buffer, x - w, y, colour);
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
@ -440,16 +440,16 @@ int DrawStringRightAligned(int x, int y, StringID str, uint16 color)
|
||||||
* @param x Right-most x position to start drawing
|
* @param x Right-most x position to start drawing
|
||||||
* @param y Y position to start drawing
|
* @param y Y position to start drawing
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
* @param maxw Maximal width of the string
|
* @param maxw Maximal width of the string
|
||||||
*/
|
*/
|
||||||
void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw)
|
void DrawStringRightAlignedTruncated(int x, int y, StringID str, TextColour colour, uint maxw)
|
||||||
{
|
{
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
|
|
||||||
TruncateStringID(str, buffer, maxw, lastof(buffer));
|
TruncateStringID(str, buffer, maxw, lastof(buffer));
|
||||||
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
||||||
ReallyDoDrawString(buffer, x - GetStringBoundingBox(buffer).width, y, color);
|
ReallyDoDrawString(buffer, x - GetStringBoundingBox(buffer).width, y, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,12 +458,12 @@ void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, u
|
||||||
* @param x Right-most x position of the string
|
* @param x Right-most x position of the string
|
||||||
* @param y Y position of the string
|
* @param y Y position of the string
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
*/
|
*/
|
||||||
void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color)
|
void DrawStringRightAlignedUnderline(int x, int y, StringID str, TextColour colour)
|
||||||
{
|
{
|
||||||
int w = DrawStringRightAligned(x, y, str, color);
|
int w = DrawStringRightAligned(x, y, str, colour);
|
||||||
GfxFillRect(x - w, y + 10, x, y + 10, _string_colorremap[1]);
|
GfxFillRect(x - w, y + 10, x, y + 10, _string_colourremap[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,11 +472,11 @@ void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color)
|
||||||
* @param x X position of center of the string
|
* @param x X position of center of the string
|
||||||
* @param y Y position of center of the string
|
* @param y Y position of center of the string
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
*
|
*
|
||||||
* @return Width of the drawn string in pixels
|
* @return Width of the drawn string in pixels
|
||||||
*/
|
*/
|
||||||
int DrawStringCentered(int x, int y, StringID str, uint16 color)
|
int DrawStringCentered(int x, int y, StringID str, TextColour colour)
|
||||||
{
|
{
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
int w;
|
int w;
|
||||||
|
@ -485,7 +485,7 @@ int DrawStringCentered(int x, int y, StringID str, uint16 color)
|
||||||
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
||||||
|
|
||||||
w = GetStringBoundingBox(buffer).width;
|
w = GetStringBoundingBox(buffer).width;
|
||||||
ReallyDoDrawString(buffer, x - w / 2, y, color);
|
ReallyDoDrawString(buffer, x - w / 2, y, colour);
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
@ -497,18 +497,18 @@ int DrawStringCentered(int x, int y, StringID str, uint16 color)
|
||||||
* @param xr Right-most x position
|
* @param xr Right-most x position
|
||||||
* @param y Y position of the string
|
* @param y Y position of the string
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
*
|
*
|
||||||
* @return Right-most coordinate of the (possibly truncated) drawn string
|
* @return Right-most coordinate of the (possibly truncated) drawn string
|
||||||
*/
|
*/
|
||||||
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color)
|
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, TextColour colour)
|
||||||
{
|
{
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
TruncateStringID(str, buffer, xr - xl, lastof(buffer));
|
TruncateStringID(str, buffer, xr - xl, lastof(buffer));
|
||||||
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
||||||
|
|
||||||
int w = GetStringBoundingBox(buffer).width;
|
int w = GetStringBoundingBox(buffer).width;
|
||||||
return ReallyDoDrawString(buffer, (xl + xr - w) / 2, y, color);
|
return ReallyDoDrawString(buffer, (xl + xr - w) / 2, y, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -517,18 +517,18 @@ int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 colo
|
||||||
* @param x X position of center of the string
|
* @param x X position of center of the string
|
||||||
* @param y Y position of center of the string
|
* @param y Y position of center of the string
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
*
|
*
|
||||||
* @return Width of the drawn string in pixels
|
* @return Width of the drawn string in pixels
|
||||||
*/
|
*/
|
||||||
int DoDrawStringCentered(int x, int y, const char *str, uint16 color)
|
int DoDrawStringCentered(int x, int y, const char *str, TextColour colour)
|
||||||
{
|
{
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
strecpy(buffer, str, lastof(buffer));
|
strecpy(buffer, str, lastof(buffer));
|
||||||
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
||||||
|
|
||||||
int w = GetStringBoundingBox(buffer).width;
|
int w = GetStringBoundingBox(buffer).width;
|
||||||
ReallyDoDrawString(buffer, x - w / 2, y, color);
|
ReallyDoDrawString(buffer, x - w / 2, y, colour);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,12 +538,12 @@ int DoDrawStringCentered(int x, int y, const char *str, uint16 color)
|
||||||
* @param x X position of center of the string
|
* @param x X position of center of the string
|
||||||
* @param y Y position of center of the string
|
* @param y Y position of center of the string
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
*/
|
*/
|
||||||
void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color)
|
void DrawStringCenterUnderline(int x, int y, StringID str, TextColour colour)
|
||||||
{
|
{
|
||||||
int w = DrawStringCentered(x, y, str, color);
|
int w = DrawStringCentered(x, y, str, colour);
|
||||||
GfxFillRect(x - (w >> 1), y + 10, x - (w >> 1) + w, y + 10, _string_colorremap[1]);
|
GfxFillRect(x - (w >> 1), y + 10, x - (w >> 1) + w, y + 10, _string_colourremap[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -553,12 +553,12 @@ void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color)
|
||||||
* @param xr Right x position of the string
|
* @param xr Right x position of the string
|
||||||
* @param y Y position of center of the string
|
* @param y Y position of center of the string
|
||||||
* @param str String to draw
|
* @param str String to draw
|
||||||
* @param color Color used for drawing the string, see DoDrawString() for details
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
||||||
*/
|
*/
|
||||||
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color)
|
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, TextColour colour)
|
||||||
{
|
{
|
||||||
int w = DrawStringCenteredTruncated(xl, xr, y, str, color);
|
int w = DrawStringCenteredTruncated(xl, xr, y, str, colour);
|
||||||
GfxFillRect((xl + xr - w) / 2, y + 10, (xl + xr + w) / 2, y + 10, _string_colorremap[1]);
|
GfxFillRect((xl + xr - w) / 2, y + 10, (xl + xr + w) / 2, y + 10, _string_colourremap[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -711,7 +711,7 @@ void DrawStringMultiCenter(int x, int y, StringID str, int maxw)
|
||||||
strecpy(buf2, src, lastof(buf2));
|
strecpy(buf2, src, lastof(buf2));
|
||||||
HandleBiDiAndArabicShapes(buf2, lastof(buf2));
|
HandleBiDiAndArabicShapes(buf2, lastof(buf2));
|
||||||
int w = GetStringBoundingBox(buf2).width;
|
int w = GetStringBoundingBox(buf2).width;
|
||||||
ReallyDoDrawString(buf2, x - (w >> 1), y, 0xFE, true);
|
ReallyDoDrawString(buf2, x - (w >> 1), y, TC_FROMSTRING, true);
|
||||||
_cur_fontsize = _last_fontsize;
|
_cur_fontsize = _last_fontsize;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -764,7 +764,7 @@ uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh)
|
||||||
char buf2[DRAW_STRING_BUFFER];
|
char buf2[DRAW_STRING_BUFFER];
|
||||||
strecpy(buf2, src, lastof(buf2));
|
strecpy(buf2, src, lastof(buf2));
|
||||||
HandleBiDiAndArabicShapes(buf2, lastof(buf2));
|
HandleBiDiAndArabicShapes(buf2, lastof(buf2));
|
||||||
ReallyDoDrawString(buf2, x, y, 0xFE, true);
|
ReallyDoDrawString(buf2, x, y, TC_FROMSTRING, true);
|
||||||
_cur_fontsize = _last_fontsize;
|
_cur_fontsize = _last_fontsize;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -833,17 +833,18 @@ Dimension GetStringBoundingBox(const char *str)
|
||||||
* @param c Character (glyph) to draw
|
* @param c Character (glyph) to draw
|
||||||
* @param x X position to draw character
|
* @param x X position to draw character
|
||||||
* @param y Y position to draw character
|
* @param y Y position to draw character
|
||||||
* @param real_color Colour to use, see DoDrawString() for details
|
* @param real_colour Colour to use, see DoDrawString() for details
|
||||||
*/
|
*/
|
||||||
void DrawCharCentered(WChar c, int x, int y, uint16 real_color)
|
void DrawCharCentered(WChar c, int x, int y, TextColour colour)
|
||||||
{
|
{
|
||||||
FontSize size = FS_NORMAL;
|
FontSize size = FS_NORMAL;
|
||||||
byte color = real_color & 0xFF;
|
assert(colour & IS_PALETTE_COLOR);
|
||||||
|
colour &= ~IS_PALETTE_COLOR;
|
||||||
int w = GetCharacterWidth(size, c);
|
int w = GetCharacterWidth(size, c);
|
||||||
|
|
||||||
_string_colorremap[1] = _string_colormap[_use_palette][color].text;
|
_string_colourremap[1] = _string_colourmap[_use_palette][colour].text;
|
||||||
_string_colorremap[2] = _string_colormap[_use_palette][color].shadow;
|
_string_colourremap[2] = _string_colourmap[_use_palette][colour].shadow;
|
||||||
_color_remap_ptr = _string_colorremap;
|
_colour_remap_ptr = _string_colourremap;
|
||||||
|
|
||||||
GfxMainBlitter(GetGlyph(size, c), x - w / 2, y, BM_COLOUR_REMAP);
|
GfxMainBlitter(GetGlyph(size, c), x - w / 2, y, BM_COLOUR_REMAP);
|
||||||
}
|
}
|
||||||
|
@ -854,7 +855,7 @@ void DrawCharCentered(WChar c, int x, int y, uint16 real_color)
|
||||||
* @param string The string to draw. This is not yet bidi reordered.
|
* @param string The string to draw. This is not yet bidi reordered.
|
||||||
* @param x Offset from left side of the screen
|
* @param x Offset from left side of the screen
|
||||||
* @param y Offset from top side of the screen
|
* @param y Offset from top side of the screen
|
||||||
* @param real_colour Colour of the string, see _string_colormap in
|
* @param colour Colour of the string, see _string_colourmap in
|
||||||
* table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
|
* table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
|
||||||
* @param parse_string_also_when_clipped
|
* @param parse_string_also_when_clipped
|
||||||
* By default, always test the available space where to draw the string.
|
* By default, always test the available space where to draw the string.
|
||||||
|
@ -865,13 +866,13 @@ void DrawCharCentered(WChar c, int x, int y, uint16 real_color)
|
||||||
* @return the x-coordinates where the drawing has finished.
|
* @return the x-coordinates where the drawing has finished.
|
||||||
* If nothing is drawn, the originally passed x-coordinate is returned
|
* If nothing is drawn, the originally passed x-coordinate is returned
|
||||||
*/
|
*/
|
||||||
int DoDrawString(const char *string, int x, int y, uint16 real_colour, bool parse_string_also_when_clipped)
|
int DoDrawString(const char *string, int x, int y, TextColour colour, bool parse_string_also_when_clipped)
|
||||||
{
|
{
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
strecpy(buffer, string, lastof(buffer));
|
strecpy(buffer, string, lastof(buffer));
|
||||||
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
HandleBiDiAndArabicShapes(buffer, lastof(buffer));
|
||||||
|
|
||||||
return ReallyDoDrawString(buffer, x, y, real_colour, parse_string_also_when_clipped);
|
return ReallyDoDrawString(buffer, x, y, colour, parse_string_also_when_clipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Draw a string at the given coordinates with the given colour.
|
/** Draw a string at the given coordinates with the given colour.
|
||||||
|
@ -880,7 +881,7 @@ int DoDrawString(const char *string, int x, int y, uint16 real_colour, bool pars
|
||||||
* @param string The string to draw. This is already bidi reordered.
|
* @param string The string to draw. This is already bidi reordered.
|
||||||
* @param x Offset from left side of the screen
|
* @param x Offset from left side of the screen
|
||||||
* @param y Offset from top side of the screen
|
* @param y Offset from top side of the screen
|
||||||
* @param real_colour Colour of the string, see _string_colormap in
|
* @param colour Colour of the string, see _string_colourmap in
|
||||||
* table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
|
* table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
|
||||||
* @param parse_string_also_when_clipped
|
* @param parse_string_also_when_clipped
|
||||||
* By default, always test the available space where to draw the string.
|
* By default, always test the available space where to draw the string.
|
||||||
|
@ -891,15 +892,14 @@ int DoDrawString(const char *string, int x, int y, uint16 real_colour, bool pars
|
||||||
* @return the x-coordinates where the drawing has finished.
|
* @return the x-coordinates where the drawing has finished.
|
||||||
* If nothing is drawn, the originally passed x-coordinate is returned
|
* If nothing is drawn, the originally passed x-coordinate is returned
|
||||||
*/
|
*/
|
||||||
static int ReallyDoDrawString(const char *string, int x, int y, uint16 real_colour, bool parse_string_also_when_clipped)
|
static int ReallyDoDrawString(const char *string, int x, int y, TextColour colour, bool parse_string_also_when_clipped)
|
||||||
{
|
{
|
||||||
DrawPixelInfo *dpi = _cur_dpi;
|
DrawPixelInfo *dpi = _cur_dpi;
|
||||||
FontSize size = _cur_fontsize;
|
FontSize size = _cur_fontsize;
|
||||||
WChar c;
|
WChar c;
|
||||||
int xo = x, yo = y;
|
int xo = x, yo = y;
|
||||||
|
|
||||||
byte colour = real_colour & 0xFF; // extract the 8 bits colour index that is required for the mapping
|
TextColour previous_colour = colour;
|
||||||
byte previous_colour = colour;
|
|
||||||
|
|
||||||
if (!parse_string_also_when_clipped) {
|
if (!parse_string_also_when_clipped) {
|
||||||
/* in "mode multiline", the available space have been verified. Not in regular one.
|
/* in "mode multiline", the available space have been verified. Not in regular one.
|
||||||
|
@ -908,14 +908,14 @@ static int ReallyDoDrawString(const char *string, int x, int y, uint16 real_colo
|
||||||
|
|
||||||
if (colour != TC_INVALID) { // the invalid colour flag test should not really occur. But better be safe
|
if (colour != TC_INVALID) { // the invalid colour flag test should not really occur. But better be safe
|
||||||
switch_colour:;
|
switch_colour:;
|
||||||
if (real_colour & IS_PALETTE_COLOR) {
|
if (colour & IS_PALETTE_COLOR) {
|
||||||
_string_colorremap[1] = colour;
|
_string_colourremap[1] = colour & ~IS_PALETTE_COLOR;
|
||||||
_string_colorremap[2] = (_use_palette == PAL_DOS) ? 1 : 215;
|
_string_colourremap[2] = (_use_palette == PAL_DOS) ? 1 : 215;
|
||||||
} else {
|
} else {
|
||||||
_string_colorremap[1] = _string_colormap[_use_palette][colour].text;
|
_string_colourremap[1] = _string_colourmap[_use_palette][colour].text;
|
||||||
_string_colorremap[2] = _string_colormap[_use_palette][colour].shadow;
|
_string_colourremap[2] = _string_colourmap[_use_palette][colour].shadow;
|
||||||
}
|
}
|
||||||
_color_remap_ptr = _string_colorremap;
|
_colour_remap_ptr = _string_colourremap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,7 +947,7 @@ skip_cont:;
|
||||||
goto check_bounds;
|
goto check_bounds;
|
||||||
} else if (c >= SCC_BLUE && c <= SCC_BLACK) { // change colour?
|
} else if (c >= SCC_BLUE && c <= SCC_BLACK) { // change colour?
|
||||||
previous_colour = colour;
|
previous_colour = colour;
|
||||||
colour = (byte)(c - SCC_BLUE);
|
colour = (TextColour)(c - SCC_BLUE);
|
||||||
goto switch_colour;
|
goto switch_colour;
|
||||||
} else if (c == SCC_PREVIOUS_COLOUR) { // revert to the previous colour
|
} else if (c == SCC_PREVIOUS_COLOUR) { // revert to the previous colour
|
||||||
Swap(colour, previous_colour);
|
Swap(colour, previous_colour);
|
||||||
|
@ -974,17 +974,17 @@ skip_cont:;
|
||||||
* @param str Character buffer containing the string
|
* @param str Character buffer containing the string
|
||||||
* @param x Left-most x coordinate to start drawing
|
* @param x Left-most x coordinate to start drawing
|
||||||
* @param y Y coordinate to draw the string
|
* @param y Y coordinate to draw the string
|
||||||
* @param color Colour to use, see DoDrawString() for details.
|
* @param colour Colour to use, see DoDrawString() for details.
|
||||||
* @param maxw Maximal width in pixels that may be used for drawing
|
* @param maxw Maximal width in pixels that may be used for drawing
|
||||||
*
|
*
|
||||||
* @return Right-most x position after drawing the (possibly truncated) string
|
* @return Right-most x position after drawing the (possibly truncated) string
|
||||||
*/
|
*/
|
||||||
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw)
|
int DoDrawStringTruncated(const char *str, int x, int y, TextColour colour, uint maxw)
|
||||||
{
|
{
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
strecpy(buffer, str, lastof(buffer));
|
strecpy(buffer, str, lastof(buffer));
|
||||||
TruncateString(buffer, maxw);
|
TruncateString(buffer, maxw);
|
||||||
return DoDrawString(buffer, x, y, color);
|
return DoDrawString(buffer, x, y, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -998,10 +998,10 @@ int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw
|
||||||
void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub)
|
void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub)
|
||||||
{
|
{
|
||||||
if (HasBit(img, PALETTE_MODIFIER_TRANSPARENT)) {
|
if (HasBit(img, PALETTE_MODIFIER_TRANSPARENT)) {
|
||||||
_color_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
|
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
|
||||||
GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH), ST_NORMAL), x, y, BM_TRANSPARENT, sub);
|
GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH), ST_NORMAL), x, y, BM_TRANSPARENT, sub);
|
||||||
} else if (pal != PAL_NONE) {
|
} else if (pal != PAL_NONE) {
|
||||||
_color_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
|
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
|
||||||
GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH), ST_NORMAL), x, y, BM_COLOUR_REMAP, sub);
|
GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH), ST_NORMAL), x, y, BM_COLOUR_REMAP, sub);
|
||||||
} else {
|
} else {
|
||||||
GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH), ST_NORMAL), x, y, BM_NORMAL, sub);
|
GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH), ST_NORMAL), x, y, BM_NORMAL, sub);
|
||||||
|
@ -1042,7 +1042,7 @@ static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode,
|
||||||
|
|
||||||
bp.dst = dpi->dst_ptr;
|
bp.dst = dpi->dst_ptr;
|
||||||
bp.pitch = dpi->pitch;
|
bp.pitch = dpi->pitch;
|
||||||
bp.remap = _color_remap_ptr;
|
bp.remap = _colour_remap_ptr;
|
||||||
|
|
||||||
assert(sprite->width > 0);
|
assert(sprite->width > 0);
|
||||||
assert(sprite->height > 0);
|
assert(sprite->height > 0);
|
||||||
|
|
|
@ -85,27 +85,27 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo);
|
||||||
|
|
||||||
void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL);
|
void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL);
|
||||||
|
|
||||||
int DrawStringCentered(int x, int y, StringID str, uint16 color);
|
int DrawStringCentered(int x, int y, StringID str, TextColour colour);
|
||||||
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color);
|
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, TextColour colour);
|
||||||
int DoDrawStringCentered(int x, int y, const char *str, uint16 color);
|
int DoDrawStringCentered(int x, int y, const char *str, TextColour colour);
|
||||||
|
|
||||||
int DrawString(int x, int y, StringID str, uint16 color);
|
int DrawString(int x, int y, StringID str, TextColour colour);
|
||||||
int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw);
|
int DrawStringTruncated(int x, int y, StringID str, TextColour colour, uint maxw);
|
||||||
|
|
||||||
int DoDrawString(const char *string, int x, int y, uint16 real_colour, bool parse_string_also_when_clipped = false);
|
int DoDrawString(const char *string, int x, int y, TextColour colour, bool parse_string_also_when_clipped = false);
|
||||||
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw);
|
int DoDrawStringTruncated(const char *str, int x, int y, TextColour colour, uint maxw);
|
||||||
|
|
||||||
void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color);
|
void DrawStringCenterUnderline(int x, int y, StringID str, TextColour colour);
|
||||||
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color);
|
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, TextColour colour);
|
||||||
|
|
||||||
int DrawStringRightAligned(int x, int y, StringID str, uint16 color);
|
int DrawStringRightAligned(int x, int y, StringID str, TextColour colour);
|
||||||
void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw);
|
void DrawStringRightAlignedTruncated(int x, int y, StringID str, TextColour colour, uint maxw);
|
||||||
void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color);
|
void DrawStringRightAlignedUnderline(int x, int y, StringID str, TextColour colour);
|
||||||
|
|
||||||
void DrawCharCentered(uint32 c, int x, int y, uint16 color);
|
void DrawCharCentered(uint32 c, int x, int y, TextColour colour);
|
||||||
|
|
||||||
void GfxFillRect(int left, int top, int right, int bottom, int color, FillRectMode mode = FILLRECT_OPAQUE);
|
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE);
|
||||||
void GfxDrawLine(int left, int top, int right, int bottom, int color);
|
void GfxDrawLine(int left, int top, int right, int bottom, int colour);
|
||||||
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
|
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
|
||||||
|
|
||||||
Dimension GetStringBoundingBox(const char *str);
|
Dimension GetStringBoundingBox(const char *str);
|
||||||
|
|
|
@ -206,7 +206,10 @@ enum TextColour {
|
||||||
TC_DARK_BLUE = 0x0F,
|
TC_DARK_BLUE = 0x0F,
|
||||||
TC_BLACK = 0x10,
|
TC_BLACK = 0x10,
|
||||||
TC_INVALID = 0xFF,
|
TC_INVALID = 0xFF,
|
||||||
|
|
||||||
|
IS_PALETTE_COLOR = 0x100, ///< colour value is already a real palette colour index, not an index of a StringColour
|
||||||
};
|
};
|
||||||
|
DECLARE_ENUM_AS_BIT_SET(TextColour);
|
||||||
|
|
||||||
/** Defines a few values that are related to animations using palette changes */
|
/** Defines a few values that are related to animations using palette changes */
|
||||||
enum PaletteAnimationSizes {
|
enum PaletteAnimationSizes {
|
||||||
|
@ -215,10 +218,6 @@ enum PaletteAnimationSizes {
|
||||||
PALETTE_ANIM_SIZE_START = 217, ///< Index in the _palettes array from which all animations are taking places (table/palettes.h)
|
PALETTE_ANIM_SIZE_START = 217, ///< Index in the _palettes array from which all animations are taking places (table/palettes.h)
|
||||||
};
|
};
|
||||||
|
|
||||||
enum StringColorFlags {
|
|
||||||
IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Define the operation GfxFillRect performs */
|
/** Define the operation GfxFillRect performs */
|
||||||
enum FillRectMode {
|
enum FillRectMode {
|
||||||
FILLRECT_OPAQUE, ///< Fill rectangle with a single color
|
FILLRECT_OPAQUE, ///< Fill rectangle with a single color
|
||||||
|
|
|
@ -189,7 +189,7 @@ bool NetworkCompanyIsPassworded(CompanyID company_id)
|
||||||
// This puts a text-message to the console, or in the future, the chat-box,
|
// This puts a text-message to the console, or in the future, the chat-box,
|
||||||
// (to keep it all a bit more general)
|
// (to keep it all a bit more general)
|
||||||
// If 'self_send' is true, this is the client who is sending the message
|
// If 'self_send' is true, this is the client who is sending the message
|
||||||
void NetworkTextMessage(NetworkAction action, ConsoleColour color, bool self_send, const char *name, const char *str, int64 data)
|
void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_send, const char *name, const char *str, int64 data)
|
||||||
{
|
{
|
||||||
const int duration = 10; // Game days the messages stay visible
|
const int duration = 10; // Game days the messages stay visible
|
||||||
|
|
||||||
|
@ -200,19 +200,19 @@ void NetworkTextMessage(NetworkAction action, ConsoleColour color, bool self_sen
|
||||||
if (data >= NETWORK_SERVER_MESSAGE_END) return;
|
if (data >= NETWORK_SERVER_MESSAGE_END) return;
|
||||||
|
|
||||||
strid = STR_NETWORK_SERVER_MESSAGE;
|
strid = STR_NETWORK_SERVER_MESSAGE;
|
||||||
color = CC_DEFAULT;
|
colour = CC_DEFAULT;
|
||||||
data = STR_NETWORK_SERVER_MESSAGE_GAME_PAUSED_PLAYERS + data;
|
data = STR_NETWORK_SERVER_MESSAGE_GAME_PAUSED_PLAYERS + data;
|
||||||
break;
|
break;
|
||||||
case NETWORK_ACTION_COMPANY_SPECTATOR:
|
case NETWORK_ACTION_COMPANY_SPECTATOR:
|
||||||
color = CC_DEFAULT;
|
colour = CC_DEFAULT;
|
||||||
strid = STR_NETWORK_CLIENT_COMPANY_SPECTATE;
|
strid = STR_NETWORK_CLIENT_COMPANY_SPECTATE;
|
||||||
break;
|
break;
|
||||||
case NETWORK_ACTION_COMPANY_JOIN:
|
case NETWORK_ACTION_COMPANY_JOIN:
|
||||||
color = CC_DEFAULT;
|
colour = CC_DEFAULT;
|
||||||
strid = STR_NETWORK_CLIENT_COMPANY_JOIN;
|
strid = STR_NETWORK_CLIENT_COMPANY_JOIN;
|
||||||
break;
|
break;
|
||||||
case NETWORK_ACTION_COMPANY_NEW:
|
case NETWORK_ACTION_COMPANY_NEW:
|
||||||
color = CC_DEFAULT;
|
colour = CC_DEFAULT;
|
||||||
strid = STR_NETWORK_CLIENT_COMPANY_NEW;
|
strid = STR_NETWORK_CLIENT_COMPANY_NEW;
|
||||||
break;
|
break;
|
||||||
case NETWORK_ACTION_JOIN: strid = STR_NETWORK_CLIENT_JOINED; break;
|
case NETWORK_ACTION_JOIN: strid = STR_NETWORK_CLIENT_JOINED; break;
|
||||||
|
@ -231,8 +231,8 @@ void NetworkTextMessage(NetworkAction action, ConsoleColour color, bool self_sen
|
||||||
GetString(message, strid, lastof(message));
|
GetString(message, strid, lastof(message));
|
||||||
|
|
||||||
DEBUG(desync, 1, "msg: %d; %d; %s\n", _date, _date_fract, message);
|
DEBUG(desync, 1, "msg: %d; %d; %s\n", _date, _date_fract, message);
|
||||||
IConsolePrintF(color, "%s", message);
|
IConsolePrintF(colour, "%s", message);
|
||||||
NetworkAddChatMessage(color, duration, "%s", message);
|
NetworkAddChatMessage((TextColour)colour, duration, "%s", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the frame-lag of a client
|
// Calculate the frame-lag of a client
|
||||||
|
|
|
@ -32,7 +32,7 @@ enum {
|
||||||
|
|
||||||
struct ChatMessage {
|
struct ChatMessage {
|
||||||
char message[DRAW_STRING_BUFFER];
|
char message[DRAW_STRING_BUFFER];
|
||||||
uint16 color;
|
TextColour colour;
|
||||||
Date end_date;
|
Date end_date;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ static inline uint GetChatMessageCount()
|
||||||
* @param duration The duration of the chat message in game-days
|
* @param duration The duration of the chat message in game-days
|
||||||
* @param message message itself in printf() style
|
* @param message message itself in printf() style
|
||||||
*/
|
*/
|
||||||
void CDECL NetworkAddChatMessage(uint16 color, uint8 duration, const char *message, ...)
|
void CDECL NetworkAddChatMessage(TextColour colour, uint8 duration, const char *message, ...)
|
||||||
{
|
{
|
||||||
char buf[DRAW_STRING_BUFFER];
|
char buf[DRAW_STRING_BUFFER];
|
||||||
const char *bufp;
|
const char *bufp;
|
||||||
|
@ -96,7 +96,7 @@ void CDECL NetworkAddChatMessage(uint16 color, uint8 duration, const char *messa
|
||||||
|
|
||||||
/* The default colour for a message is company colour. Replace this with
|
/* The default colour for a message is company colour. Replace this with
|
||||||
* white for any additional lines */
|
* white for any additional lines */
|
||||||
cmsg->color = (bufp == buf && color & IS_PALETTE_COLOR) ? color : (0x1D - 15) | IS_PALETTE_COLOR;
|
cmsg->colour = (bufp == buf && colour & IS_PALETTE_COLOR) ? colour : (TextColour)(0x1D - 15) | IS_PALETTE_COLOR;
|
||||||
cmsg->end_date = _date + duration;
|
cmsg->end_date = _date + duration;
|
||||||
|
|
||||||
bufp += strlen(bufp) + 1; // jump to 'next line' in the formatted string
|
bufp += strlen(bufp) + 1; // jump to 'next line' in the formatted string
|
||||||
|
@ -237,7 +237,7 @@ void NetworkDrawChatMessage()
|
||||||
|
|
||||||
/* Paint the chat messages starting with the lowest at the bottom */
|
/* Paint the chat messages starting with the lowest at the bottom */
|
||||||
for (uint y = NETWORK_CHAT_LINE_HEIGHT; count-- != 0; y += NETWORK_CHAT_LINE_HEIGHT) {
|
for (uint y = NETWORK_CHAT_LINE_HEIGHT; count-- != 0; y += NETWORK_CHAT_LINE_HEIGHT) {
|
||||||
DoDrawString(_chatmsg_list[count].message, _chatmsg_box.x + 3, _screen.height - _chatmsg_box.y - y + 1, _chatmsg_list[count].color);
|
DoDrawString(_chatmsg_list[count].message, _chatmsg_box.x + 3, _screen.height - _chatmsg_box.y - y + 1, _chatmsg_list[count].colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the data is updated next flush */
|
/* Make sure the data is updated next flush */
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "core/address.h"
|
#include "core/address.h"
|
||||||
#include "network_type.h"
|
#include "network_type.h"
|
||||||
#include "../console_type.h"
|
#include "../console_type.h"
|
||||||
|
#include "../gfx_type.h"
|
||||||
|
|
||||||
extern NetworkServerGameInfo _network_game_info;
|
extern NetworkServerGameInfo _network_game_info;
|
||||||
extern NetworkCompanyState *_network_company_states;
|
extern NetworkCompanyState *_network_company_states;
|
||||||
|
@ -69,7 +70,7 @@ void NetworkServerSendError(ClientID client_id, NetworkErrorCode error);
|
||||||
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0);
|
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0);
|
||||||
|
|
||||||
void NetworkInitChatMessage();
|
void NetworkInitChatMessage();
|
||||||
void CDECL NetworkAddChatMessage(uint16 color, uint8 duration, const char *message, ...);
|
void CDECL NetworkAddChatMessage(TextColour colour, uint8 duration, const char *message, ...);
|
||||||
void NetworkUndrawChatMessage();
|
void NetworkUndrawChatMessage();
|
||||||
void NetworkChatMessageDailyLoop();
|
void NetworkChatMessageDailyLoop();
|
||||||
|
|
||||||
|
|
|
@ -662,11 +662,11 @@ void ShowLastNewsMessage()
|
||||||
* Draw an unformatted news message truncated to a maximum length. If
|
* Draw an unformatted news message truncated to a maximum length. If
|
||||||
* length exceeds maximum length it will be postfixed by '...'
|
* length exceeds maximum length it will be postfixed by '...'
|
||||||
* @param x,y position of the string
|
* @param x,y position of the string
|
||||||
* @param color the color the string will be shown in
|
* @param colour the colour the string will be shown in
|
||||||
* @param *ni NewsItem being printed
|
* @param *ni NewsItem being printed
|
||||||
* @param maxw maximum width of string in pixels
|
* @param maxw maximum width of string in pixels
|
||||||
*/
|
*/
|
||||||
static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint maxw)
|
static void DrawNewsString(int x, int y, TextColour colour, const NewsItem *ni, uint maxw)
|
||||||
{
|
{
|
||||||
char buffer[512], buffer2[512];
|
char buffer[512], buffer2[512];
|
||||||
StringID str;
|
StringID str;
|
||||||
|
@ -698,7 +698,7 @@ static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint
|
||||||
|
|
||||||
*dest = '\0';
|
*dest = '\0';
|
||||||
/* Truncate and show string; postfixed by '...' if neccessary */
|
/* Truncate and show string; postfixed by '...' if neccessary */
|
||||||
DoDrawStringTruncated(buffer2, x, y, color, maxw);
|
DoDrawStringTruncated(buffer2, x, y, colour, maxw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ struct StringColor {
|
||||||
byte shadow;
|
byte shadow;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const StringColor _string_colormap[][17] = {
|
static const StringColor _string_colourmap[][17] = {
|
||||||
{ /* DOS palette. */
|
{ /* DOS palette. */
|
||||||
{ 150, 1 }, // TC_BLUE
|
{ 150, 1 }, // TC_BLUE
|
||||||
{ 12, 1 }, // TC_SILVER
|
{ 12, 1 }, // TC_SILVER
|
||||||
|
|
|
@ -171,7 +171,7 @@ public:
|
||||||
|
|
||||||
SetDParam(0, company);
|
SetDParam(0, company);
|
||||||
SetDParam(1, company);
|
SetDParam(1, company);
|
||||||
int col;
|
TextColour col;
|
||||||
if (this->greyed) {
|
if (this->greyed) {
|
||||||
col = TC_GREY;
|
col = TC_GREY;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -286,7 +286,7 @@ public:
|
||||||
if (_settings_game.economy.station_noise_level) {
|
if (_settings_game.economy.station_noise_level) {
|
||||||
SetDParam(0, this->town->noise_reached);
|
SetDParam(0, this->town->noise_reached);
|
||||||
SetDParam(1, this->town->MaxTownNoise());
|
SetDParam(1, this->town->MaxTownNoise());
|
||||||
DrawString(2, 137, STR_NOISE_IN_TOWN, 0);
|
DrawString(2, 137, STR_NOISE_IN_TOWN, TC_FROMSTRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1418,7 +1418,7 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDrawVect
|
||||||
|
|
||||||
const StringSpriteToDraw *ssend = sstdv->End();
|
const StringSpriteToDraw *ssend = sstdv->End();
|
||||||
for (const StringSpriteToDraw *ss = sstdv->Begin(); ss != ssend; ++ss) {
|
for (const StringSpriteToDraw *ss = sstdv->Begin(); ss != ssend; ++ss) {
|
||||||
uint16 colour;
|
TextColour colour;
|
||||||
|
|
||||||
if (ss->width != 0) {
|
if (ss->width != 0) {
|
||||||
/* Do not draw signs nor station names if they are set invisible */
|
/* Do not draw signs nor station names if they are set invisible */
|
||||||
|
@ -1453,7 +1453,7 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDrawVect
|
||||||
if (IsTransparencySet(TO_SIGNS) && ss->string != STR_2806 && ss->width != 0) {
|
if (IsTransparencySet(TO_SIGNS) && ss->string != STR_2806 && ss->width != 0) {
|
||||||
/* Real colors need the IS_PALETTE_COLOR flag
|
/* Real colors need the IS_PALETTE_COLOR flag
|
||||||
* otherwise colors from _string_colormap are assumed. */
|
* otherwise colors from _string_colormap are assumed. */
|
||||||
colour = _colour_gradient[ss->color][6] | IS_PALETTE_COLOR;
|
colour = (TextColour)_colour_gradient[ss->color][6] | IS_PALETTE_COLOR;
|
||||||
} else {
|
} else {
|
||||||
colour = TC_BLACK;
|
colour = TC_BLACK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ void Window::DrawWidgets() const
|
||||||
case WWT_TEXT: {
|
case WWT_TEXT: {
|
||||||
const StringID str = wi->data;
|
const StringID str = wi->data;
|
||||||
|
|
||||||
if (str != STR_NULL) DrawStringTruncated(r.left, r.top, str, wi->colour, r.right - r.left);
|
if (str != STR_NULL) DrawStringTruncated(r.left, r.top, str, (TextColour)wi->colour, r.right - r.left);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue