OpenTTD Source
12.0-beta2
|
#include "stdafx.h"
#include "gfx_layout.h"
#include "progress.h"
#include "zoom_func.h"
#include "blitter/factory.hpp"
#include "video/video_driver.hpp"
#include "strings_func.h"
#include "settings_type.h"
#include "network/network.h"
#include "network/network_func.h"
#include "window_func.h"
#include "newgrf_debug.h"
#include "thread.h"
#include "table/palettes.h"
#include "table/string_colours.h"
#include "table/sprites.h"
#include "table/control_codes.h"
#include "safeguards.h"
Go to the source code of this file.
Macros | |
#define | EXTR(p, q) (((uint16)(palette_animation_counter * (p)) * (q)) >> 16) |
#define | EXTR2(p, q) (((uint16)(~palette_animation_counter * (p)) * (q)) >> 16) |
Typedefs | |
typedef std::pair< Point, Point > | LineSegment |
Functions | |
static void | GfxMainBlitterViewport (const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub=nullptr, SpriteID sprite_id=SPR_CURSOR_MOUSE) |
static void | GfxMainBlitter (const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub=nullptr, SpriteID sprite_id=SPR_CURSOR_MOUSE, ZoomLevel zoom=ZOOM_LVL_NORMAL) |
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. More... | |
static std::vector< LineSegment > | MakePolygonSegments (const std::vector< Point > &shape, Point offset) |
Make line segments from a polygon defined by points, translated by an offset. More... | |
void | GfxFillPolygon (const std::vector< Point > &shape, int colour, FillRectMode mode) |
Fill a polygon with colour. More... | |
static void | GfxDoDrawLine (void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash=0) |
Check line clipping by using a linear equation and draw the visible part of the line given by x/y and x2/y2. More... | |
static bool | GfxPreprocessLine (DrawPixelInfo *dpi, int &x, int &y, int &x2, int &y2, int width) |
Align parameters of a line to the given DPI and check simple clipping. More... | |
void | GfxDrawLine (int x, int y, int x2, int y2, int colour, int width, int dash) |
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. More... | |
static void | SetColourRemap (TextColour colour) |
Set the colour remap to be for the given colour. More... | |
static int | DrawLayoutLine (const ParagraphLayouter::Line &line, int y, int left, int right, StringAlignment align, bool underline, bool truncation) |
Drawing routine for drawing a laid out line of text. More... | |
int | DrawString (int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize) |
Draw string, possibly truncated to make it fit in its allocated space. More... | |
int | DrawString (int left, int right, int top, const std::string &str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize) |
Draw string, possibly truncated to make it fit in its allocated space. More... | |
int | DrawString (int left, int right, int top, StringID str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize) |
Draw string, possibly truncated to make it fit in its allocated space. More... | |
int | GetStringHeight (const char *str, int maxw, FontSize fontsize) |
Calculates height of string (in pixels). More... | |
int | GetStringHeight (StringID str, int maxw) |
Calculates height of string (in pixels). More... | |
int | GetStringLineCount (StringID str, int maxw) |
Calculates number of lines of string. More... | |
Dimension | GetStringMultiLineBoundingBox (StringID str, const Dimension &suggestion) |
Calculate string bounding box for multi-line strings. More... | |
Dimension | GetStringMultiLineBoundingBox (const char *str, const Dimension &suggestion) |
Calculate string bounding box for multi-line strings. More... | |
int | DrawStringMultiLine (int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize) |
Draw string, possibly over multiple lines. More... | |
int | DrawStringMultiLine (int left, int right, int top, int bottom, const std::string &str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize) |
Draw string, possibly over multiple lines. More... | |
int | DrawStringMultiLine (int left, int right, int top, int bottom, StringID str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize) |
Draw string, possibly over multiple lines. More... | |
Dimension | GetStringBoundingBox (const char *str, FontSize start_fontsize) |
Return the string dimension in pixels. More... | |
Dimension | GetStringBoundingBox (const std::string &str, FontSize start_fontsize) |
Return the string dimension in pixels. More... | |
Dimension | GetStringBoundingBox (StringID strid) |
Get bounding box of a string. More... | |
Point | GetCharPosInString (const char *str, const char *ch, FontSize start_fontsize) |
Get the leading corner of a character in a single-line string relative to the start of the string. More... | |
const char * | GetCharAtPosition (const char *str, int x, FontSize start_fontsize) |
Get the character from a string that is drawn at a specific position. More... | |
void | DrawCharCentered (WChar c, const Rect &r, TextColour colour) |
Draw single character horizontally centered around (x,y) More... | |
Dimension | GetSpriteSize (SpriteID sprid, Point *offset, ZoomLevel zoom) |
Get the size of a sprite. More... | |
static BlitterMode | GetBlitterMode (PaletteID pal) |
Helper function to get the blitter mode for different types of palettes. More... | |
void | DrawSpriteViewport (SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub) |
Draw a sprite in a viewport. More... | |
void | DrawSprite (SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom) |
Draw a sprite, not in a viewport. More... | |
template<int ZOOM_BASE, bool SCALED_XY> | |
static void | GfxBlitter (const Sprite *const sprite, int x, int y, BlitterMode mode, const SubSprite *const sub, SpriteID sprite_id, ZoomLevel zoom) |
The code for setting up the blitter mode and sprite information before finally drawing the sprite. More... | |
void | DoPaletteAnimations () |
void | GfxInitPalettes () |
bool | CopyPalette (Palette &local_palette, bool force_copy) |
Copy the current palette if the palette was updated. More... | |
TextColour | GetContrastColour (uint8 background, uint8 threshold) |
Determine a contrasty text colour for a coloured background. More... | |
void | LoadStringWidthTable (bool monospace) |
Initialize _stringwidth_table cache. More... | |
byte | GetCharacterWidth (FontSize size, WChar key) |
Return width of character glyph. More... | |
byte | GetDigitWidth (FontSize size) |
Return the maximum width of single digit. More... | |
void | GetBroadestDigit (uint *front, uint *next, FontSize size) |
Determine the broadest digits for guessing the maximum width of a n-digit number. More... | |
void | ScreenSizeChanged () |
void | UndrawMouseCursor () |
void | DrawMouseCursor () |
void | RedrawScreenRect (int left, int top, int right, int bottom) |
Repaints a specific rectangle of the screen. More... | |
void | DrawDirtyBlocks () |
Repaints the rectangle blocks which are marked as 'dirty'. More... | |
void | AddDirtyBlock (int left, int top, int right, int bottom) |
Extend the internal _invalid_rect rectangle to contain the rectangle defined by the given parameters. More... | |
void | MarkWholeScreenDirty () |
This function mark the whole screen as dirty. More... | |
bool | FillDrawPixelInfo (DrawPixelInfo *n, int left, int top, int width, int height) |
Set up a clipping area for only drawing into a certain area. More... | |
void | UpdateCursorSize () |
Update cursor dimension. More... | |
static void | SetCursorSprite (CursorID cursor, PaletteID pal) |
Switch cursor to different sprite. More... | |
static void | SwitchAnimatedCursor () |
void | CursorTick () |
void | SetMouseCursorBusy (bool busy) |
Set or unset the ZZZ cursor. More... | |
void | SetMouseCursor (CursorID sprite, PaletteID pal) |
Assign a single non-animated sprite to the cursor. More... | |
void | SetAnimatedMouseCursor (const AnimCursor *table) |
Assign an animation to the cursor. More... | |
bool | ChangeResInGame (int width, int height) |
bool | ToggleFullScreen (bool fs) |
void | SortResolutions () |
void | UpdateGUIZoom () |
Resolve GUI zoom level, if auto-suggestion is requested. | |
void | ChangeGameSpeed (bool enable_fast_forward) |
Variables | |
byte | _dirkeys |
1 = left, 2 = up, 4 = right, 8 = down | |
bool | _fullscreen |
byte | _support8bpp |
CursorVars | _cursor |
bool | _ctrl_pressed |
Is Ctrl pressed? | |
bool | _shift_pressed |
Is Shift pressed? | |
uint16 | _game_speed = 100 |
Current game-speed; 100 is 1x, 0 is infinite. | |
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) | |
std::atomic< bool > | _exit_game |
GameMode | _game_mode |
SwitchMode | _switch_mode |
The next mainloop command. | |
PauseMode | _pause_mode |
The current pause mode. | |
Palette | _cur_palette |
Current palette. | |
static byte | _stringwidth_table [FS_END][224] |
Cache containing width of often used characters. More... | |
DrawPixelInfo * | _cur_dpi |
byte | _colour_gradient [COLOUR_END][8] |
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7) | |
static std::recursive_mutex | _palette_mutex |
To coordinate access to _cur_palette. | |
static ReusableBuffer< uint8 > | _cursor_backup |
ZoomLevel | _gui_zoom |
GUI Zoom level. | |
ZoomLevel | _font_zoom |
Font Zoom level. | |
int8 | _gui_zoom_cfg |
GUI zoom level in config. | |
int8 | _font_zoom_cfg |
Font zoom level in config. | |
static Rect | _invalid_rect |
The rect for repaint. More... | |
static const byte * | _colour_remap_ptr |
static byte | _string_colourremap [3] |
Recoloursprite for stringdrawing. The grf loader ensures that ST_FONT sprites only use colours 0 to 2. | |
static const uint | DIRTY_BLOCK_HEIGHT = 8 |
static const uint | DIRTY_BLOCK_WIDTH = 64 |
static uint | _dirty_bytes_per_line = 0 |
static byte * | _dirty_blocks = nullptr |
uint | _dirty_block_colour |
Handling of drawing text and other gfx related stuff.
Definition in file gfx.cpp.
bool CopyPalette | ( | Palette & | local_palette, |
bool | force_copy | ||
) |
Copy the current palette if the palette was updated.
Used by video-driver to get a current up-to-date version of the palette, to avoid two threads accessing the same piece of memory (with a good chance one is already updating the palette while the other is drawing based on it).
local_palette | The location to copy the palette to. |
force_copy | Whether to ignore if there is an update for the palette. |
Definition at line 1216 of file gfx.cpp.
References _cur_palette, _palette_mutex, Palette::count_dirty, Palette::first_dirty, and lock.
Referenced by VideoDriver_SDL::CheckPaletteAnim(), VideoDriver_Win32Base::CheckPaletteAnim(), VideoDriver_SDL_Base::CheckPaletteAnim(), and VideoDriver_SDL_Base::ClientSizeChanged().
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.
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 420 of file gfx.cpp.
Referenced by ViewportDrawBoundingBoxes().
void DrawCharCentered | ( | WChar | c, |
const Rect & | r, | ||
TextColour | colour | ||
) |
Draw single character horizontally centered around (x,y)
c | Character (glyph) to draw |
r | Rectangle to draw character within |
colour | Colour to use, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h |
Definition at line 959 of file gfx.cpp.
References SetColourRemap().
Referenced by OskWindow::DrawWidget().
|
static |
Drawing routine for drawing a laid out line of text.
line | String to draw. |
y | The top most position to draw on. |
left | The left most position to draw on. |
right | The right most position to draw on. |
align | The alignment of the string when drawing left-to-right. In the case a right-to-left language is chosen this is inverted so it will be drawn in the right direction. |
underline | Whether to underline what has been drawn or not. |
truncation | Whether to perform string truncation or not. |
void DrawSprite | ( | SpriteID | img, |
PaletteID | pal, | ||
int | x, | ||
int | y, | ||
const SubSprite * | sub, | ||
ZoomLevel | zoom | ||
) |
Draw a sprite, not in a viewport.
img | Image number to draw |
pal | Palette to use. |
x | Left coordinate of image in pixels |
y | Top coordinate of image in pixels |
sub | If available, draw only specified part of the sprite |
zoom | Zoom level of sprite |
Definition at line 1041 of file gfx.cpp.
Referenced by StoryBookWindow::DrawActionElement(), TransparenciesWindow::DrawWidget(), and BuildTreesWindow::DrawWidget().
int DrawString | ( | int | left, |
int | right, | ||
int | top, | ||
const char * | str, | ||
TextColour | colour, | ||
StringAlignment | align, | ||
bool | underline, | ||
FontSize | fontsize | ||
) |
Draw string, possibly truncated to make it fit in its allocated space.
left | The left most position to draw on. |
right | The right most position to draw on. |
top | The top most position to draw on. |
str | String to draw. |
colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h |
align | The alignment of the string when drawing left-to-right. In the case a right-to-left language is chosen this is inverted so it will be drawn in the right direction. |
underline | Whether to underline what has been drawn or not. |
fontsize | The size of the initial characters. |
Definition at line 642 of file gfx.cpp.
References FONT_HEIGHT_LARGE, FONT_HEIGHT_MONO, FONT_HEIGHT_NORMAL, and FONT_HEIGHT_SMALL.
Referenced by CargoesField::Draw(), DrawCaption(), NetworkContentListWindow::DrawDetails(), SelectCompanyManagerFaceWindow::DrawFaceStringLabel(), DrawFrame(), DrawInset(), DrawPrice(), DrawString(), DrawText(), StatusBarWindow::DrawWidget(), ReplaceVehicleWindow::DrawWidget(), NetworkContentListWindow::DrawWidget(), GenerateLandscapeWindow::DrawWidget(), MusicWindow::DrawWidget(), AIConfigWindow::DrawWidget(), NetworkStartServerWindow::DrawWidget(), GameSettingsWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), and ScenarioEditorToolbarWindow::DrawWidget().
int DrawString | ( | int | left, |
int | right, | ||
int | top, | ||
const std::string & | str, | ||
TextColour | colour, | ||
StringAlignment | align, | ||
bool | underline, | ||
FontSize | fontsize | ||
) |
Draw string, possibly truncated to make it fit in its allocated space.
left | The left most position to draw on. |
right | The right most position to draw on. |
top | The top most position to draw on. |
str | String to draw. |
colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h |
align | The alignment of the string when drawing left-to-right. In the case a right-to-left language is chosen this is inverted so it will be drawn in the right direction. |
underline | Whether to underline what has been drawn or not. |
fontsize | The size of the initial characters. |
Definition at line 678 of file gfx.cpp.
References DrawString().
int DrawString | ( | int | left, |
int | right, | ||
int | top, | ||
StringID | str, | ||
TextColour | colour, | ||
StringAlignment | align, | ||
bool | underline, | ||
FontSize | fontsize | ||
) |
Draw string, possibly truncated to make it fit in its allocated space.
left | The left most position to draw on. |
right | The right most position to draw on. |
top | The top most position to draw on. |
str | String to draw. |
colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h |
align | The alignment of the string when drawing left-to-right. In the case a right-to-left language is chosen this is inverted so it will be drawn in the right direction. |
underline | Whether to underline what has been drawn or not. |
fontsize | The size of the initial characters. |
Definition at line 700 of file gfx.cpp.
References DRAW_STRING_BUFFER.
int DrawStringMultiLine | ( | int | left, |
int | right, | ||
int | top, | ||
int | bottom, | ||
const char * | str, | ||
TextColour | colour, | ||
StringAlignment | align, | ||
bool | underline, | ||
FontSize | fontsize | ||
) |
Draw string, possibly over multiple lines.
left | The left most position to draw on. |
right | The right most position to draw on. |
top | The top most position to draw on. |
bottom | The bottom most position to draw on. |
str | String to draw. |
colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h |
align | The horizontal and vertical alignment of the string. |
underline | Whether to underline all strings |
fontsize | The size of the initial characters. |
Definition at line 787 of file gfx.cpp.
References Layouter::GetBounds().
Referenced by StationViewWindow::DrawAcceptedCargo(), DrawStringMultiLine(), SelectGameWindow::DrawWidget(), BootstrapErrorWindow::DrawWidget(), BootstrapAskForDownloadWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), ErrmsgWindow::DrawWidget(), GameOptionsWindow::DrawWidget(), GoalQuestionWindow::DrawWidget(), TooltipsWindow::DrawWidget(), QueryStringWindow::DrawWidget(), QueryWindow::DrawWidget(), NetworkCompanyPasswordWindow::DrawWidget(), CompanyWindow::DrawWidget(), NetworkAskRelayWindow::DrawWidget(), BuyCompanyWindow::DrawWidget(), HighScoreWindow::OnPaint(), and IConsoleWindow::OnPaint().
int DrawStringMultiLine | ( | int | left, |
int | right, | ||
int | top, | ||
int | bottom, | ||
const std::string & | str, | ||
TextColour | colour, | ||
StringAlignment | align, | ||
bool | underline, | ||
FontSize | fontsize | ||
) |
Draw string, possibly over multiple lines.
left | The left most position to draw on. |
right | The right most position to draw on. |
top | The top most position to draw on. |
bottom | The bottom most position to draw on. |
str | String to draw. |
colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h |
align | The horizontal and vertical alignment of the string. |
underline | Whether to underline all strings |
fontsize | The size of the initial characters. |
Definition at line 850 of file gfx.cpp.
References DrawStringMultiLine().
int DrawStringMultiLine | ( | int | left, |
int | right, | ||
int | top, | ||
int | bottom, | ||
StringID | str, | ||
TextColour | colour, | ||
StringAlignment | align, | ||
bool | underline, | ||
FontSize | fontsize | ||
) |
Draw string, possibly over multiple lines.
left | The left most position to draw on. |
right | The right most position to draw on. |
top | The top most position to draw on. |
bottom | The bottom most position to draw on. |
str | String to draw. |
colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h |
align | The horizontal and vertical alignment of the string. |
underline | Whether to underline all strings |
fontsize | The size of the initial characters. |
Definition at line 871 of file gfx.cpp.
References DRAW_STRING_BUFFER.
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
*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 |
Definition at line 1708 of file gfx.cpp.
References BlitterFactory::GetCurrentBlitter().
Referenced by NWidgetMatrix::Draw(), NWidgetLeaf::Draw(), SmallMapWindow::DrawWidget(), BuildRailStationWindow::DrawWidget(), and IndustryCargoesWindow::DrawWidget().
|
static |
void GetBroadestDigit | ( | uint * | front, |
uint * | next, | ||
FontSize | size | ||
) |
Determine the broadest digits for guessing the maximum width of a n-digit number.
[out] | front | Broadest digit, which is not 0. (Use this digit as first digit for numbers with more than one digit.) |
[out] | next | Broadest digit, including 0. (Use this digit for all digits, except the first one; or for numbers with only one digit.) |
size | Font of the digit |
Definition at line 1415 of file gfx.cpp.
References GetCharacterWidth().
Referenced by SetDParamMaxDigits().
Return width of character glyph.
size | Font of the character |
key | Character code glyph |
Definition at line 1387 of file gfx.cpp.
References _stringwidth_table, and GetGlyphWidth().
Referenced by GetBroadestDigit(), and GetDigitWidth().
const char* GetCharAtPosition | ( | const char * | str, |
int | x, | ||
FontSize | start_fontsize | ||
) |
Get the character from a string that is drawn at a specific position.
str | String to test. |
x | Position relative to the start of the string. |
start_fontsize | Font size to start the text with. |
Get the leading corner of a character in a single-line string relative to the start of the string.
str | String containing the character. |
ch | Pointer to the character in the string. |
start_fontsize | Font size to start the text with. |
Definition at line 931 of file gfx.cpp.
Referenced by Textbuf::UpdateCaretPosition(), and Textbuf::UpdateMarkedText().
TextColour GetContrastColour | ( | uint8 | background, |
uint8 | threshold | ||
) |
Determine a contrasty text colour for a coloured background.
background | Background colour. |
threshold | Background colour brightness threshold below which the background is considered dark and TC_WHITE is returned, range: 0 - 255, default 128. |
Definition at line 1354 of file gfx.cpp.
References _cur_palette, and Palette::palette.
byte GetDigitWidth | ( | FontSize | size | ) |
Return the maximum width of single digit.
size | Font of the digit |
Definition at line 1400 of file gfx.cpp.
References GetCharacterWidth().
Referenced by BuildSignalWindow::UpdateWidgetSize().
Get the size of a sprite.
sprid | Sprite to examine. | |
[out] | offset | Optionally returns the sprite position offset. |
zoom | The zoom level applicable to the sprite. |
Definition at line 976 of file gfx.cpp.
Referenced by VehicleGroupWindow::ComputeGroupInfoSize(), StoryBookWindow::DrawActionElement(), NetworkClientListWindow::DrawCompany(), BuildSignalWindow::DrawSignalSprite(), BaseVehicleListWindow::DrawVehicleListItems(), OrdersWindow::DrawWidget(), StoryBookWindow::GetPageElementHeight(), MakeCompanyButtonRows(), MakeNWidgetCompanyLines(), NetworkContentListWindow::NetworkContentListWindow(), SelectCompanyManagerFaceWindow::OnInit(), NetworkClientListWindow::OnTooltip(), NWidgetLeaf::SetupSmallestSize(), BuildBridgeWindow::UpdateWidgetSize(), ErrmsgWindow::UpdateWidgetSize(), SignListWindow::UpdateWidgetSize(), NewsWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), NetworkGameWindow::UpdateWidgetSize(), NewGRFWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), SelectCompanyManagerFaceWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), BuyCompanyWindow::UpdateWidgetSize(), and VehicleViewWindow::UpdateWidgetSize().
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
str | string to calculate pixel-width |
start_fontsize | Fontsize to start the text with |
Definition at line 888 of file gfx.cpp.
Referenced by DrawCaption(), DrawText(), OrdersWindow::DrawWidget(), BaseVehicleListWindow::GetActionDropdownSize(), ExpensesList::GetCategoriesWidth(), StoryBookWindow::GetPageElementFloatWidth(), StoryBookWindow::GetPageElementHeight(), GetStringBoundingBox(), BaseGraphWindow::GetYLabelWidth(), BaseVehicleListWindow::OnInit(), SelectCompanyManagerFaceWindow::OnInit(), IndustryCargoesWindow::OnInit(), GoalListWindow::OnPaint(), NWidgetBackground::SetupSmallestSize(), SelectGameWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), BootstrapErrorWindow::UpdateWidgetSize(), SetDateWindow::UpdateWidgetSize(), StatusBarWindow::UpdateWidgetSize(), SubsidyListWindow::UpdateWidgetSize(), BuildBridgeWindow::UpdateWidgetSize(), GoalListWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), BootstrapAskForDownloadWindow::UpdateWidgetSize(), BuildObjectWindow::UpdateWidgetSize(), ReplaceVehicleWindow::UpdateWidgetSize(), BuildAirportWindow::UpdateWidgetSize(), NewsWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), CompanyStationsWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), GenerateLandscapeWindow::UpdateWidgetSize(), SaveLoadWindow::UpdateWidgetSize(), NetworkContentListWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), MusicWindow::UpdateWidgetSize(), TooltipsWindow::UpdateWidgetSize(), StoryBookWindow::UpdateWidgetSize(), AIConfigWindow::UpdateWidgetSize(), OrdersWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), PaymentRatesGraphWindow::UpdateWidgetSize(), NetworkStartServerWindow::UpdateWidgetSize(), CreateScenarioWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), BuildRailStationWindow::UpdateWidgetSize(), CompanyLeagueWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), StationViewWindow::UpdateWidgetSize(), SelectCompanyManagerFaceWindow::UpdateWidgetSize(), BuildVehicleWindow::UpdateWidgetSize(), IndustryDirectoryWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), CompanyInfrastructureWindow::UpdateWidgetSize(), GameSettingsWindow::UpdateWidgetSize(), SavePresetWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), NetworkAskRelayWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), and Textbuf::UpdateWidth().
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
str | string to calculate pixel-width |
start_fontsize | Fontsize to start the text with |
Definition at line 904 of file gfx.cpp.
References GetStringBoundingBox().
Get bounding box of a string.
Uses parameters set by SetDParam if needed. Has the same restrictions as GetStringBoundingBox(const char *str, FontSize start_fontsize).
strid | String to examine. |
Definition at line 915 of file gfx.cpp.
References DRAW_STRING_BUFFER.
int GetStringHeight | ( | const char * | str, |
int | maxw, | ||
FontSize | fontsize | ||
) |
Calculates height of string (in pixels).
The string is changed to a multiline string if needed.
str | string to check |
maxw | maximum string width |
Definition at line 713 of file gfx.cpp.
Referenced by StoryBookWindow::GetHeadHeight(), SettingEntry::GetMaxHelpHeight(), StoryBookWindow::GetPageElementHeight(), TextfileWindow::ReflowContent(), SelectGameWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), BootstrapErrorWindow::UpdateWidgetSize(), ErrmsgWindow::UpdateWidgetSize(), BootstrapAskForDownloadWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), GoalQuestionWindow::UpdateWidgetSize(), TooltipsWindow::UpdateWidgetSize(), and NetworkAskRelayWindow::UpdateWidgetSize().
int GetStringHeight | ( | StringID | str, |
int | maxw | ||
) |
Calculates height of string (in pixels).
The string is changed to a multiline string if needed.
str | string to check |
maxw | maximum string width |
Definition at line 725 of file gfx.cpp.
References DRAW_STRING_BUFFER.
int GetStringLineCount | ( | StringID | str, |
int | maxw | ||
) |
Calculates number of lines of string.
The string is changed to a multiline string if needed.
str | string to check |
maxw | maximum string width |
Definition at line 738 of file gfx.cpp.
References DRAW_STRING_BUFFER.
Calculate string bounding box for multi-line strings.
str | String to check. |
suggestion | Suggested bounding box. |
Definition at line 753 of file gfx.cpp.
Referenced by QueryWindow::UpdateWidgetSize().
|
static |
The code for setting up the blitter mode and sprite information before finally drawing the sprite.
sprite | The sprite to draw. |
x | The X location to draw. |
y | The Y location to draw. |
mode | The settings for the blitter to pass. |
sub | Whether to only draw a sub set of the sprite. |
zoom | The zoom level at which to draw the sprites. |
ZOOM_BASE | The factor required to get the sub sprite information into the right size. |
SCALED_XY | Whether the X and Y are scaled or unscaled. |
|
inlinestatic |
Check line clipping by using a linear equation and draw the visible part of the line given by x/y and x2/y2.
video | Destination pointer to draw into. |
x | X coordinate of first point. |
y | Y coordinate of first point. |
x2 | X coordinate of second point. |
y2 | Y coordinate of second point. |
screen_width | With of the screen to check clipping against. |
screen_height | Height of the screen to check clipping against. |
colour | Colour of the line. |
width | Width of the line. |
dash | Length of dashes for dashed lines. 0 means solid line. |
void GfxFillPolygon | ( | const std::vector< Point > & | shape, |
int | colour, | ||
FillRectMode | mode | ||
) |
Fill a polygon with colour.
The odd-even winding rule is used, i.e. self-intersecting polygons will have holes in them. Left and top edges are inclusive, right and bottom edges are exclusive.
shape | List of points on the polygon. |
colour | An 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolour spritenumber (FILLRECT_RECOLOUR). |
mode | FILLRECT_OPAQUE: Fill the polygon with the specified colour. FILLRECT_CHECKER: Fill every other pixel with the specified colour, in a checkerboard pattern. FILLRECT_RECOLOUR: Apply a recolour sprite to every pixel in the polygon. |
Definition at line 212 of file gfx.cpp.
References BlitterFactory::GetCurrentBlitter().
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.
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 116 of file gfx.cpp.
References BlitterFactory::GetCurrentBlitter().
Referenced by NWidgetMatrix::Draw(), NWidgetViewport::Draw(), NWidgetToolbarContainer::Draw(), DrawCaption(), NetworkContentListWindow::DrawDetails(), DrawFrame(), BootstrapBackground::DrawWidget(), CompanyFinancesWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), MusicWindow::DrawWidget(), TooltipsWindow::DrawWidget(), NewGRFWindow::DrawWidget(), BuildRailWaypointWindow::DrawWidget(), NetworkClientListWindow::DrawWidget(), SavePresetWindow::DrawWidget(), HighlightDragPosition(), and IConsoleWindow::OnPaint().
|
inlinestatic |
Align parameters of a line to the given DPI and check simple clipping.
dpi | Screen parameters to align with. |
x | X coordinate of first point. |
y | Y coordinate of first point. |
x2 | X coordinate of second point. |
y2 | Y coordinate of second point. |
width | Width of the line. |
void LoadStringWidthTable | ( | bool | monospace | ) |
Initialize _stringwidth_table cache.
monospace | Whether to load the monospace cache or the normal fonts. |
Definition at line 1368 of file gfx.cpp.
Referenced by ReloadNewGRFData().
|
static |
Make line segments from a polygon defined by points, translated by an offset.
Entirely horizontal lines (start and end at same Y coordinate) are skipped, as they are irrelevant to scanline conversion algorithms. Generated line segments always have the lowest Y coordinate point first, i.e. original direction is lost.
shape | The polygon to convert. |
offset | Offset vector subtracted from all coordinates in the shape. |
void SetAnimatedMouseCursor | ( | const AnimCursor * | table | ) |
Assign an animation to the cursor.
table | Array of animation states. |
|
static |
Set the colour remap to be for the given colour.
colour | the new colour of the remap. |
Definition at line 455 of file gfx.cpp.
Referenced by DrawCharCentered().
Assign a single non-animated sprite to the cursor.
void SetMouseCursorBusy | ( | bool | busy | ) |
Set or unset the ZZZ cursor.
busy | Whether to show the ZZZ cursor. |
Definition at line 1830 of file gfx.cpp.
Referenced by CleanupGeneration(), GenerateProgressWindow::OnClick(), and SaveFileStart().
void UpdateCursorSize | ( | ) |
Update cursor dimension.
Called when changing cursor sprite resp. reloading grfs.
Definition at line 1758 of file gfx.cpp.
References GetMaxSpriteID(), and lengthof.
|
static |
Cache containing width of often used characters.
Definition at line 50 of file gfx.cpp.
Referenced by GetCharacterWidth().