gfx.cpp File Reference

Handling of drawing text and other gfx related stuff. More...

#include "stdafx.h"
#include "openttd.h"
#include "gfx_func.h"
#include "variables.h"
#include "spritecache.h"
#include "fontcache.h"
#include "genworld.h"
#include "zoom_func.h"
#include "blitter/factory.hpp"
#include "video/video_driver.hpp"
#include "strings_func.h"
#include "settings_type.h"
#include "core/alloc_func.hpp"
#include "core/sort_func.hpp"
#include "landscape_type.h"
#include "network/network_func.h"
#include "table/palettes.h"
#include "table/sprites.h"
#include "table/control_codes.h"

Go to the source code of this file.

Defines

#define EXTR(p, q)   (((uint16)(_palette_animation_counter * (p)) * (q)) >> 16)
#define EXTR2(p, q)   (((uint16)(~_palette_animation_counter * (p)) * (q)) >> 16)

Enumerations

enum  { DIRTY_BLOCK_HEIGHT = 8, DIRTY_BLOCK_WIDTH = 64 }

Functions

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, TextColour colour, bool parse_string_also_when_clipped)
 Draw a string at the given coordinates with the given colour.
void GfxScroll (int left, int top, int width, int height, int xo, int yo)
void GfxFillRect (int left, int top, int right, int bottom, int colour, FillRectMode mode)
 Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
void GfxDrawLine (int x, int y, int x2, int y2, int colour)
void GfxDrawLineUnscaled (int x, int y, int x2, int y2, int colour)
void DrawBox (int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3)
 Draws the projection of a parallelepiped.
static void SetColourRemap (TextColour colour)
 Set the colour remap to be for the given colour.
static void HandleBiDiAndArabicShapes (char *text, const char *lastof)
static int TruncateString (char *str, int maxw)
 Truncate a given string to a maximum width if neccessary.
static int TruncateStringID (StringID src, char *dest, int maxw, const char *last)
 Write string to output buffer, truncating it to specified maximal width in pixels if it is too long.
int DrawString (int x, int y, StringID str, TextColour colour)
 Draw string starting at position (x,y).
int DrawStringTruncated (int x, int y, StringID str, TextColour colour, uint maxw)
 Draw string, possibly truncated to make it fit in its allocated space.
int DrawStringRightAligned (int x, int y, StringID str, TextColour colour)
 Draw string right-aligned.
void DrawStringRightAlignedTruncated (int x, int y, StringID str, TextColour colour, uint maxw)
 Draw string right-aligned, possibly truncated to make it fit in its allocated space.
void DrawStringRightAlignedUnderline (int x, int y, StringID str, TextColour colour)
 Draw string right-aligned with a line underneath it.
int DrawStringCentered (int x, int y, StringID str, TextColour colour)
 Draw string centered.
int DrawStringCenteredTruncated (int xl, int xr, int y, StringID str, TextColour colour)
 Draw string centered, possibly truncated to fit in the assigned space.
int DoDrawStringCentered (int x, int y, const char *str, TextColour colour)
 Draw string centered.
void DrawStringCenterUnderline (int x, int y, StringID str, TextColour colour)
 Draw string centered, with additional line underneath it.
void DrawStringCenterUnderlineTruncated (int xl, int xr, int y, StringID str, TextColour colour)
 Draw string centered possibly truncated, with additional line underneath it.
uint32 FormatStringLinebreaks (char *str, int maxw)
 'Correct' a string to a maximum length.
static int GetMultilineStringHeight (const char *src, int num)
 Calculates height of string (in pixels).
int GetStringHeight (StringID str, int maxw)
 Calculates height of string (in pixels).
void DrawStringMultiCenter (int x, int y, StringID str, int maxw)
 Draw a given string with the centre around the given (x,y) coordinates.
uint DrawStringMultiLine (int x, int y, StringID str, int maxw, int maxh)
Dimension GetStringBoundingBox (const char *str)
 Return the string dimension in pixels.
void DrawCharCentered (WChar c, int x, int y, TextColour colour)
 Draw single character horizontally centered around (x,y).
int DoDrawString (const char *string, int x, int y, TextColour colour, bool parse_string_also_when_clipped)
 Draw a string at the given coordinates with the given colour.
int DoDrawStringTruncated (const char *str, int x, int y, TextColour colour, uint maxw)
 Draw the string of the character buffer, starting at position (x,y) with a given maximal width.
void DrawSprite (SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub)
 Draw a sprite.
void DoPaletteAnimations ()
void GfxInitPalettes ()
void LoadStringWidthTable ()
 Initialize _stringwidth_table cache.
byte GetCharacterWidth (FontSize size, WChar key)
 Return width of character glyph.
void ScreenSizeChanged ()
void UndrawMouseCursor ()
void DrawMouseCursor ()
void RedrawScreenRect (int left, int top, int right, int bottom)
void DrawDirtyBlocks ()
 Let the dirty blocks repainting by the video driver.
void SetDirtyBlocks (int left, int top, int right, int bottom)
 Set a new dirty block.
void MarkWholeScreenDirty ()
 Marks the whole screen as dirty.
bool FillDrawPixelInfo (DrawPixelInfo *n, int left, int top, int width, int height)
 Set up a clipping area for only drawing into a certain area.
static void SetCursorSprite (SpriteID cursor, SpriteID pal)
static void SwitchAnimatedCursor ()
void CursorTick ()
void SetMouseCursor (SpriteID sprite, SpriteID pal)
void SetAnimatedMouseCursor (const AnimCursor *table)
bool ChangeResInGame (int width, int height)
bool ToggleFullScreen (bool fs)
static int CDECL compare_res (const Dimension *pa, const Dimension *pb)
void SortResolutions (int count)

Variables

byte _dirkeys
 1 = left, 2 = up, 4 = right, 8 = down
bool _fullscreen
CursorVars _cursor
bool _ctrl_pressed
 Is Ctrl pressed?
bool _shift_pressed
 Is Shift pressed?
byte _fast_forward
bool _left_button_down
 Is left mouse button pressed?
bool _left_button_clicked
 Is left mouse button clicked?
bool _right_button_down
 Is right mouse button pressed?
bool _right_button_clicked
 Is right mouse button clicked?
DrawPixelInfo _screen
bool _screen_disable_anim = false
 Disable palette animation (important for 32bpp-anim blitter during giant screenshot).
bool _exit_game
GameMode _game_mode
SwitchMode _switch_mode
 The next mainloop command.
int8 _pause_game
int _pal_first_dirty
int _pal_count_dirty
Colour _cur_palette [256]
 Current palette. Entry 0 has to be always fully transparent!
byte _stringwidth_table [FS_END][224]
 Cache containing width of often used characters.
DrawPixelInfo * _cur_dpi
byte _colour_gradient [COLOUR_END][8]
 All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7).
FontSize _cur_fontsize
static FontSize _last_fontsize
static ReusableBuffer< uint8 > _cursor_backup
static Rect _invalid_rect
 The rect for repaint.
static const byte * _colour_remap_ptr
static byte _string_colourremap [3]
static uint _dirty_bytes_per_line = 0
static byte * _dirty_blocks = NULL


Detailed Description

Handling of drawing text and other gfx related stuff.

Definition in file gfx.cpp.


Function Documentation

int DoDrawString ( const char *  string,
int  x,
int  y,
TextColour  colour,
bool  parse_string_also_when_clipped 
)

Draw a string at the given coordinates with the given colour.

While drawing the string, parse it in case some formatting is specified, like new colour, new size or even positionning.

Parameters:
string The string to draw. This is not yet bidi reordered.
x Offset from left side of the screen
y Offset from top side of the screen
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
parse_string_also_when_clipped By default, always test the available space where to draw the string. When in multipline drawing, it would already be done, so no need to re-perform the same kind (more or less) of verifications. It's not only an optimisation, it's also a way to ensures the string will be parsed (as there are certain side effects on global variables, which are important for the next line)
Returns:
the x-coordinates where the drawing has finished. If nothing is drawn, the originally passed x-coordinate is returned

Definition at line 879 of file gfx.cpp.

References lastof, ReallyDoDrawString(), and strecpy().

Referenced by DoDrawStringTruncated(), Window::DrawSortButtonState(), Window::DrawWidgets(), and StationViewWindow::OnPaint().

int DoDrawStringCentered ( int  x,
int  y,
const char *  str,
TextColour  colour 
)

Draw string centered.

Parameters:
x X position of center of the string
y Y position of center of the string
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details
Returns:
Width of the drawn string in pixels

Definition at line 542 of file gfx.cpp.

References GetStringBoundingBox(), lastof, ReallyDoDrawString(), strecpy(), and Dimension::width.

int DoDrawStringTruncated ( const char *  str,
int  x,
int  y,
TextColour  colour,
uint  maxw 
)

Draw the string of the character buffer, starting at position (x,y) with a given maximal width.

String is truncated if it is too long.

Parameters:
str Character buffer containing the string
x Left-most x coordinate to start drawing
y Y coordinate to draw the string
colour Colour to use, see DoDrawString() for details.
maxw Maximal width in pixels that may be used for drawing
Returns:
Right-most x position after drawing the (possibly truncated) string

Definition at line 985 of file gfx.cpp.

References DoDrawString(), lastof, strecpy(), and TruncateString().

Referenced by DrawNewsString(), NewGRFWindow::OnPaint(), NewGRFAddWindow::OnPaint(), AISettingsWindow::OnPaint(), and AIListWindow::OnPaint().

void DrawBox ( int  x,
int  y,
int  dx1,
int  dy1,
int  dx2,
int  dy2,
int  dx3,
int  dy3 
)

Draws the projection of a parallelepiped.

This can be used to draw boxes in world coordinates.

Parameters:
x Screen X-coordinate of top front corner.
y Screen Y-coordinate of top front corner.
dx1 Screen X-length of first edge.
dy1 Screen Y-length of first edge.
dx2 Screen X-length of second edge.
dy2 Screen Y-length of second edge.
dx3 Screen X-length of third edge.
dy3 Screen Y-length of third edge.

Definition at line 207 of file gfx.cpp.

Referenced by ViewportDrawBoundingBoxes().

void DrawCharCentered ( WChar  c,
int  x,
int  y,
TextColour  colour 
)

Draw single character horizontally centered around (x,y).

Parameters:
c Character (glyph) to draw
x X position to draw character
y Y position to draw character
colour Colour to use, see DoDrawString() for details

Definition at line 856 of file gfx.cpp.

References GetCharacterWidth(), GetGlyph(), and SetColourRemap().

void DrawSprite ( SpriteID  img,
SpriteID  pal,
int  x,
int  y,
const SubSprite sub 
)

Draw a sprite.

Parameters:
img Image number to draw
pal Palette to use.
x Left coordinate of image
y Top coordinate of image
sub If available, draw only specified part of the sprite

Definition at line 1001 of file gfx.cpp.

References GB(), HasBit(), PALETTE_MODIFIER_TRANSPARENT, PALETTE_WIDTH, SPRITE_WIDTH, ST_NORMAL, and ST_RECOLOUR.

Referenced by SettingEntry::Draw(), DrawCargoIcons(), DrawCompanyManagerFace(), DrawStationTile(), DrawVehicleProfitButton(), Window::DrawWidgets(), NewGRFWindow::OnPaint(), and CompanyWindow::OnPaint().

int DrawString ( int  x,
int  y,
StringID  str,
TextColour  colour 
)

Draw string starting at position (x,y).

Parameters:
x X position to start drawing
y Y position to start drawing
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details
Returns:
Horizontal coordinate after drawing the string

Definition at line 403 of file gfx.cpp.

References lastof, and ReallyDoDrawString().

Referenced by DrawAircraftDetails(), DrawCompanyOwnerText(), DrawCompanyVehiclesAmount(), DrawShipDetails(), DrawVehiclePurchaseInfo(), DrawVehicleRefitWindow(), Window::DrawWidgets(), VehicleListWindow::OnPaint(), StationViewWindow::OnPaint(), CompanyStationsWindow::OnPaint(), CompanyWindow::OnPaint(), AIConfigWindow::OnPaint(), AIListWindow::OnPaint(), and StationsWndShowStationRating().

int DrawStringCentered ( int  x,
int  y,
StringID  str,
TextColour  colour 
)

Draw string centered.

Parameters:
x X position of center of the string
y Y position of center of the string
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details
Returns:
Width of the drawn string in pixels

Definition at line 497 of file gfx.cpp.

References GetStringBoundingBox(), lastof, ReallyDoDrawString(), and Dimension::width.

Referenced by DrawArrowButtons(), DrawStringCenterUnderline(), Window::DrawWidgets(), and CompanyStationsWindow::OnPaint().

int DrawStringCenteredTruncated ( int  xl,
int  xr,
int  y,
StringID  str,
TextColour  colour 
)

Draw string centered, possibly truncated to fit in the assigned space.

Parameters:
xl Left-most x position
xr Right-most x position
y Y position of the string
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details
Returns:
Right-most coordinate of the (possibly truncated) drawn string

Definition at line 522 of file gfx.cpp.

References GetStringBoundingBox(), lastof, ReallyDoDrawString(), TruncateStringID(), and Dimension::width.

Referenced by DrawStringCenterUnderlineTruncated(), and Window::DrawWidgets().

void DrawStringCenterUnderline ( int  x,
int  y,
StringID  str,
TextColour  colour 
)

Draw string centered, with additional line underneath it.

Parameters:
x X position of center of the string
y Y position of center of the string
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details

Definition at line 561 of file gfx.cpp.

References DrawStringCentered(), and GfxFillRect().

void DrawStringCenterUnderlineTruncated ( int  xl,
int  xr,
int  y,
StringID  str,
TextColour  colour 
)

Draw string centered possibly truncated, with additional line underneath it.

Parameters:
xl Left x position of the string
xr Right x position of the string
y Y position of center of the string
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details

Definition at line 576 of file gfx.cpp.

References DrawStringCenteredTruncated(), and GfxFillRect().

void DrawStringMultiCenter ( int  x,
int  y,
StringID  str,
int  maxw 
)

Draw a given string with the centre around the given (x,y) coordinates.

Parameters:
x Centre the string around this pixel width
y Centre the string around this pixel height
str String to draw
maxw Maximum width the string can have before it is wrapped

Definition at line 708 of file gfx.cpp.

References FormatStringLinebreaks(), GB(), GetCharacterHeight(), GetStringBoundingBox(), lastof, ReallyDoDrawString(), strecpy(), and Dimension::width.

Referenced by QueryWindow::OnPaint(), EndGameWindow::OnPaint(), and CompanyWindow::OnPaint().

int DrawStringRightAligned ( int  x,
int  y,
StringID  str,
TextColour  colour 
)

Draw string right-aligned.

Parameters:
x Right-most x position of the string
y Y position of the string
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details
Returns:
Width of drawn string in pixels

Definition at line 441 of file gfx.cpp.

References GetStringBoundingBox(), lastof, ReallyDoDrawString(), and Dimension::width.

Referenced by DrawEngineList(), DrawStringRightAlignedUnderline(), and StationViewWindow::OnPaint().

void DrawStringRightAlignedTruncated ( int  x,
int  y,
StringID  str,
TextColour  colour,
uint  maxw 
)

Draw string right-aligned, possibly truncated to make it fit in its allocated space.

Parameters:
x Right-most x position to start drawing
y Y position to start drawing
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details
maxw Maximal width of the string

Definition at line 464 of file gfx.cpp.

References GetStringBoundingBox(), lastof, ReallyDoDrawString(), and TruncateStringID().

Referenced by StationViewWindow::OnPaint().

void DrawStringRightAlignedUnderline ( int  x,
int  y,
StringID  str,
TextColour  colour 
)

Draw string right-aligned with a line underneath it.

Parameters:
x Right-most x position of the string
y Y position of the string
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details

Definition at line 481 of file gfx.cpp.

References DrawStringRightAligned(), and GfxFillRect().

int DrawStringTruncated ( int  x,
int  y,
StringID  str,
TextColour  colour,
uint  maxw 
)

Draw string, possibly truncated to make it fit in its allocated space.

Parameters:
x X position to start drawing
y Y position to start drawing
str String to draw
colour Colour used for drawing the string, see DoDrawString() for details
maxw Maximal width of the string
Returns:
Horizontal coordinate after drawing the (possibly truncated) string

Definition at line 423 of file gfx.cpp.

References lastof, ReallyDoDrawString(), and TruncateStringID().

Referenced by SettingEntry::Draw(), DrawEngineList(), SettingEntry::DrawSetting(), Window::DrawWidgets(), IndustryDirectoryWindow::OnPaint(), ReplaceVehicleWindow::OnPaint(), AIConfigWindow::OnPaint(), AISettingsWindow::OnPaint(), and AIListWindow::OnPaint().

bool FillDrawPixelInfo ( DrawPixelInfo *  n,
int  left,
int  top,
int  width,
int  height 
)

Set up a clipping area for only drawing into a certain area.

To do this, Fill a DrawPixelInfo object with the supplied relative rectangle, backup the original (calling) _cur_dpi and assign the just returned DrawPixelInfo _cur_dpi. When you are done, give restore _cur_dpi's original value

Parameters:
*n the DrawPixelInfo that will be the clipping rectangle box allowed for drawing
left,top,width,height the relative coordinates of the clipping rectangle relative to the current _cur_dpi. This will most likely be the offset from the calling window coordinates
Returns:
return false if the requested rectangle is not possible with the current dpi pointer. Only continue of the return value is true, or you'll get some nasty results

Definition at line 1539 of file gfx.cpp.

References BlitterFactoryBase::GetCurrentBlitter(), and Blitter::MoveTo().

uint32 FormatStringLinebreaks ( char *  str,
int  maxw 
)

'Correct' a string to a maximum length.

Longer strings will be cut into additional lines at whitespace characters if possible. The string parameter is modified with terminating characters mid-string which are the placeholders for the newlines. The string WILL be truncated if there was no whitespace for the current line's maximum width.

Note:
To know if the terminating '' is the string end or just a newline, the returned 'num' value should be consulted. The num'th '', starting with index 0 is the real string end.
Parameters:
str string to check and correct for length restrictions
maxw the maximum width the string can have on one line
Returns:
return a 32bit wide number consisting of 2 packed values: 0 - 15 the number of lines ADDED to the string 16 - 31 the fontsize in which the length calculation was done at

Definition at line 600 of file gfx.cpp.

References GetCharacterWidth(), IsWhitespace(), SCC_BIGFONT, SCC_TINYFONT, and Utf8PrevChar().

Referenced by DrawStringMultiCenter(), and GetStringHeight().

byte GetCharacterWidth ( FontSize  size,
WChar  key 
)

Return width of character glyph.

Parameters:
size Font of the character
key Character code glyph
Returns:
Width of the character glyph

Definition at line 1264 of file gfx.cpp.

References _stringwidth_table, and GetGlyphWidth().

Referenced by DrawCharCentered(), FormatStringLinebreaks(), GetStringBoundingBox(), InsertTextBufferChar(), InsertTextBufferClipboard(), MoveTextBufferPos(), ReallyDoDrawString(), TruncateString(), and UpdateTextBufferSize().

static int GetMultilineStringHeight ( const char *  src,
int  num 
) [static]

Calculates height of string (in pixels).

Accepts multiline string with '' as separators.

Parameters:
src string to check
num number of extra lines (output of FormatStringLinebreaks())
Note:
assumes text won't be truncated. FormatStringLinebreaks() is a good way to ensure that.
Returns:
height of pixels of string when it is drawn

Definition at line 664 of file gfx.cpp.

References fh, GetCharacterHeight(), SCC_BIGFONT, and SCC_TINYFONT.

Referenced by GetStringHeight().

Dimension GetStringBoundingBox ( const char *  str  ) 

Return the string dimension in pixels.

The height and width are returned in a single Dimension value. TINYFONT, BIGFONT modifiers are only supported as the first character of the string. The returned dimensions are therefore a rough estimation correct for all the current strings but not every possible combination

Parameters:
str string to calculate pixel-width
Returns:
string width and height in pixels

Definition at line 813 of file gfx.cpp.

References GetCharacterHeight(), GetCharacterWidth(), Dimension::height, max(), SCC_BIGFONT, SCC_TINYFONT, and Dimension::width.

Referenced by DoDrawStringCentered(), DrawStringCentered(), DrawStringCenteredTruncated(), DrawStringMultiCenter(), DrawStringRightAligned(), DrawStringRightAlignedTruncated(), and GuiShowTooltips().

int GetStringHeight ( StringID  str,
int  maxw 
)

Calculates height of string (in pixels).

The string is changed to a multiline string if needed.

Parameters:
str string to check
maxw maximum string width
Returns:
height of pixels of string when it is drawn

Definition at line 691 of file gfx.cpp.

References FormatStringLinebreaks(), GB(), GetMultilineStringHeight(), and lastof.

void GfxFillRect ( int  left,
int  top,
int  right,
int  bottom,
int  colour,
FillRectMode  mode 
)

Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.

Precondition:
dpi->zoom == ZOOM_LVL_NORMAL, right >= left, bottom >= top
Parameters:
left Minimum X (inclusive)
top Minimum Y (inclusive)
right Maximum X (inclusive)
bottom Maximum Y (inclusive)
colour A 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolour spritenumber (FILLRECT_RECOLOUR)
mode 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_RECOLOUR: Apply a recolour sprite to every pixel in the rectangle currently on screen

Definition at line 107 of file gfx.cpp.

References Blitter::DrawColourMappingRect(), Blitter::DrawRect(), FILLRECT_CHECKER, FILLRECT_RECOLOUR, GB(), BlitterFactoryBase::GetCurrentBlitter(), Blitter::MoveTo(), PALETTE_WIDTH, and Blitter::SetPixel().

Referenced by DrawArrowButtons(), DrawFrameRect(), DrawStringCenterUnderline(), DrawStringCenterUnderlineTruncated(), DrawStringRightAlignedUnderline(), Window::DrawWidgets(), CompanyStationsWindow::OnPaint(), NewGRFAddWindow::OnPaint(), and StationsWndShowStationRating().

static int ReallyDoDrawString ( const char *  string,
int  x,
int  y,
TextColour  colour,
bool  parse_string_also_when_clipped 
) [static]

Draw a string at the given coordinates with the given colour.

While drawing the string, parse it in case some formatting is specified, like new colour, new size or even positionning.

Parameters:
string The string to draw. This is already bidi reordered.
x Offset from left side of the screen
y Offset from top side of the screen
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
parse_string_also_when_clipped By default, always test the available space where to draw the string. When in multipline drawing, it would already be done, so no need to re-perform the same kind (more or less) of verifications. It's not only an optimisation, it's also a way to ensures the string will be parsed (as there are certain side effects on global variables, which are important for the next line)
Returns:
the x-coordinates where the drawing has finished. If nothing is drawn, the originally passed x-coordinate is returned

Definition at line 905 of file gfx.cpp.

References GetCharacterHeight(), GetCharacterWidth(), GetGlyph(), SCC_BIGFONT, SCC_TINYFONT, SetColourRemap(), and Swap().

Referenced by DoDrawString(), DoDrawStringCentered(), DrawString(), DrawStringCentered(), DrawStringCenteredTruncated(), DrawStringMultiCenter(), DrawStringRightAligned(), DrawStringRightAlignedTruncated(), and DrawStringTruncated().

static void SetColourRemap ( TextColour  colour  )  [static]

Set the colour remap to be for the given colour.

Parameters:
colour the new colour of the remap.

Definition at line 242 of file gfx.cpp.

References _use_palette, IS_PALETTE_COLOUR, and PAL_DOS.

Referenced by DrawCharCentered(), and ReallyDoDrawString().

static int TruncateString ( char *  str,
int  maxw 
) [static]

Truncate a given string to a maximum width if neccessary.

If the string is truncated, add three dots ('...') to show this.

Parameters:
*str string that is checked and possibly truncated
maxw maximum width in pixels of the string
Returns:
new width of (truncated) string

Definition at line 329 of file gfx.cpp.

References GetCharacterWidth(), SCC_BIGFONT, and SCC_TINYFONT.

Referenced by DoDrawStringTruncated(), and TruncateStringID().

static int TruncateStringID ( StringID  src,
char *  dest,
int  maxw,
const char *  last 
) [inline, static]

Write string to output buffer, truncating it to specified maximal width in pixels if it is too long.

Parameters:
src String to truncate
dest Start of character output buffer where truncated string is stored
maxw Maximal allowed length of the string in pixels
last Address of last character in output buffer
Returns:
Actual width of the (possibly) truncated string in pixels

Definition at line 387 of file gfx.cpp.

References TruncateString().

Referenced by DrawStringCenteredTruncated(), DrawStringRightAlignedTruncated(), and DrawStringTruncated().


Variable Documentation

byte _stringwidth_table[FS_END][224]

Cache containing width of often used characters.

See also:
GetCharacterWidth()

Definition at line 46 of file gfx.cpp.

Referenced by GetCharacterWidth(), and LoadStringWidthTable().


Generated on Mon Mar 9 23:33:55 2009 for openttd by  doxygen 1.5.6