Functions related to the gfx engine. More...
#include "gfx_type.h"
#include "strings_type.h"
Go to the source code of this file.
Defines | |
#define | FONT_HEIGHT_SMALL (GetCharacterHeight(FS_SMALL)) |
Height of characters in the small (FS_SMALL) font. | |
#define | FONT_HEIGHT_NORMAL (GetCharacterHeight(FS_NORMAL)) |
Height of characters in the normal (FS_NORMAL) font. | |
#define | FONT_HEIGHT_LARGE (GetCharacterHeight(FS_LARGE)) |
Height of characters in the large (FS_LARGE) font. | |
#define | FONT_HEIGHT_MONO (GetCharacterHeight(FS_MONO)) |
Height of characters in the large (FS_MONO) font. | |
#define | GREY_SCALE(level) (level) |
Return the colour for a particular greyscale level. | |
Enumerations | |
enum | StringAlignment { SA_LEFT = 0 << 0, SA_HOR_CENTER = 1 << 0, SA_RIGHT = 2 << 0, SA_HOR_MASK = 3 << 0, SA_TOP = 0 << 2, SA_VERT_CENTER = 1 << 2, SA_BOTTOM = 2 << 2, SA_VERT_MASK = 3 << 2, SA_CENTER = SA_HOR_CENTER | SA_VERT_CENTER, SA_FORCE = 1 << 4, SA_STRIP = 1 << 5 } |
How to align the to-be drawn text. More... | |
Functions | |
void | GameLoop () |
void | CreateConsole () |
void | HandleKeypress (uint32 key) |
Handle keyboard input. | |
void | HandleCtrlChanged () |
State of CONTROL key has changed. | |
void | HandleMouseEvents () |
Handle a mouse event from the video driver. | |
void | CSleep (int milliseconds) |
void | UpdateWindows () |
Update the continuously changing contents of the windows, such as the viewports. | |
void | DrawMouseCursor () |
void | ScreenSizeChanged () |
void | GameSizeChanged () |
Size of the application screen changed. | |
void | UndrawMouseCursor () |
void | RedrawScreenRect (int left, int top, int right, int bottom) |
void | GfxScroll (int left, int top, int width, int height, int xo, int yo) |
Dimension | GetSpriteSize (SpriteID sprid, Point *offset=NULL, ZoomLevel zoom=ZOOM_LVL_GUI) |
Get the size of a sprite. | |
void | DrawSpriteViewport (SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub=NULL) |
Draw a sprite in a viewport. | |
void | DrawSprite (SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub=NULL, ZoomLevel zoom=ZOOM_LVL_GUI) |
Draw a sprite, not in a viewport. | |
int | DrawString (int left, int right, int top, const char *str, TextColour colour=TC_FROMSTRING, StringAlignment align=SA_LEFT, bool underline=false, FontSize fontsize=FS_NORMAL) |
Draw string, possibly truncated to make it fit in its allocated space. | |
int | DrawString (int left, int right, int top, StringID str, TextColour colour=TC_FROMSTRING, StringAlignment align=SA_LEFT, bool underline=false, FontSize fontsize=FS_NORMAL) |
Draw string, possibly truncated to make it fit in its allocated space. | |
int | DrawStringMultiLine (int left, int right, int top, int bottom, const char *str, TextColour colour=TC_FROMSTRING, StringAlignment align=(SA_TOP|SA_LEFT), bool underline=false, FontSize fontsize=FS_NORMAL) |
Draw string, possibly over multiple lines. | |
int | DrawStringMultiLine (int left, int right, int top, int bottom, StringID str, TextColour colour=TC_FROMSTRING, StringAlignment align=(SA_TOP|SA_LEFT), bool underline=false, FontSize fontsize=FS_NORMAL) |
Draw string, possibly over multiple lines. | |
void | DrawCharCentered (uint32 c, int x, int y, TextColour colour) |
void | GfxFillRect (int left, int top, int right, int bottom, int colour, FillRectMode mode=FILLRECT_OPAQUE) |
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen. | |
void | GfxDrawLine (int left, int top, int right, int bottom, int colour, int width=1) |
void | DrawBox (int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3) |
Draws the projection of a parallelepiped. | |
Dimension | GetStringBoundingBox (const char *str, FontSize start_fontsize=FS_NORMAL) |
Return the string dimension in pixels. | |
Dimension | GetStringBoundingBox (StringID strid) |
Get bounding box of a string. | |
uint32 | FormatStringLinebreaks (char *str, const char *last, int maxw, FontSize start_fontsize=FS_NORMAL) |
'Correct' a string to a maximum length. | |
int | GetStringHeight (StringID str, int maxw) |
Calculates height of string (in pixels). | |
Dimension | GetStringMultiLineBoundingBox (StringID str, const Dimension &suggestion) |
Calculate string bounding box for multi-line strings. | |
Dimension | GetStringMultiLineBoundingBox (const char *str, const Dimension &suggestion) |
Calculate string bounding box for multi-line strings. | |
void | LoadStringWidthTable (bool monospace=false) |
Initialize _stringwidth_table cache. | |
void | DrawDirtyBlocks () |
Repaints the rectangle blocks which are marked as 'dirty'. | |
void | SetDirtyBlocks (int left, int top, int right, int bottom) |
This function extends the internal _invalid_rect rectangle as it now contains the rectangle defined by the given parameters. | |
void | MarkWholeScreenDirty () |
This function mark the whole screen as dirty. | |
void | GfxInitPalettes () |
bool | FillDrawPixelInfo (DrawPixelInfo *n, int left, int top, int width, int height) |
Set up a clipping area for only drawing into a certain area. | |
void | DrawOverlappedWindowForAll (int left, int top, int right, int bottom) |
From a rectangle that needs redrawing, find the windows that intersect with the rectangle. | |
void | SetMouseCursor (CursorID cursor, PaletteID pal) |
Assign a single non-animated sprite to the cursor. | |
void | SetAnimatedMouseCursor (const AnimCursor *table) |
Assign an animation to the cursor. | |
void | CursorTick () |
void | UpdateCursorSize () |
Update cursor dimension. | |
bool | ChangeResInGame (int w, int h) |
void | SortResolutions (int count) |
bool | ToggleFullScreen (bool fs) |
byte | GetCharacterWidth (FontSize size, uint32 key) |
byte | GetDigitWidth (FontSize size=FS_NORMAL) |
Return the maximum width of single digit. | |
static byte | GetCharacterHeight (FontSize size) |
Get height of a character for a given font size. | |
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 |
Disable palette animation (important for 32bpp-anim blitter during giant screenshot). | |
int | _num_resolutions |
The number of resolutions. | |
Dimension | _resolutions [32] |
List of resolutions. | |
Dimension | _cur_resolution |
The current resolution. | |
Palette | _cur_palette |
Current palette. | |
static const int | DRAW_STRING_BUFFER = 2048 |
Size of the buffer used for drawing strings. | |
DrawPixelInfo * | _cur_dpi |
byte | _colour_gradient [COLOUR_END][8] |
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7). | |
bool | _palette_remap_grf [] |
Whether the given NewGRFs must get a palette remap from windows to DOS or not. | |
static const uint8 | PC_BLACK = GREY_SCALE(1) |
Black palette colour. | |
static const uint8 | PC_DARK_GREY = GREY_SCALE(6) |
Dark grey palette colour. | |
static const uint8 | PC_GREY = GREY_SCALE(10) |
Grey palette colour. | |
static const uint8 | PC_WHITE = GREY_SCALE(15) |
White palette colour. | |
static const uint8 | PC_VERY_DARK_RED = 0xB2 |
Almost-black red palette colour. | |
static const uint8 | PC_DARK_RED = 0xB4 |
Dark red palette colour. | |
static const uint8 | PC_RED = 0xB8 |
Red palette colour. | |
static const uint8 | PC_VERY_DARK_BROWN = 0x56 |
Almost-black brown palette colour. | |
static const uint8 | PC_ORANGE = 0xC2 |
Orange palette colour. | |
static const uint8 | PC_YELLOW = 0xBF |
Yellow palette colour. | |
static const uint8 | PC_LIGHT_YELLOW = 0x44 |
Light yellow palette colour. | |
static const uint8 | PC_VERY_LIGHT_YELLOW = 0x45 |
Almost-white yellow palette colour. | |
static const uint8 | PC_GREEN = 0xD0 |
Green palette colour. | |
static const uint8 | PC_DARK_BLUE = 0x9D |
Dark blue palette colour. | |
static const uint8 | PC_LIGHT_BLUE = 0x98 |
Light blue palette colour. |
Functions related to the gfx engine.
Definition in file gfx_func.h.
#define FONT_HEIGHT_LARGE (GetCharacterHeight(FS_LARGE)) |
Height of characters in the large (FS_LARGE) font.
Definition at line 173 of file gfx_func.h.
Referenced by HighScoreWindow::OnPaint().
#define FONT_HEIGHT_MONO (GetCharacterHeight(FS_MONO)) |
Height of characters in the large (FS_MONO) font.
Definition at line 176 of file gfx_func.h.
#define FONT_HEIGHT_NORMAL (GetCharacterHeight(FS_NORMAL)) |
Height of characters in the normal (FS_NORMAL) font.
Definition at line 170 of file gfx_func.h.
Referenced by CargoesField::CargoClickedAt(), CargoesField::CargoLabelClickedAt(), CheckClickOnViewportSign(), CargoesField::Draw(), StationViewWindow::DrawAcceptedCargo(), DrawAircraftDetails(), DrawButtonDropdown(), StationViewWindow::DrawCargoRatings(), DrawCategories(), NetworkContentListWindow::DrawDetails(), DrawFrame(), CargoesField::DrawHorConnection(), NetworkContentListWindow::DrawMatrix(), DrawOrderString(), TownAuthorityWindow::DrawRatings(), DrawRoadVehDetails(), NetworkGameWindow::DrawServerLine(), DrawShipDetails(), DrawString(), DrawTrainDetails(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), VehicleDetailsWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), TownViewWindow::DrawWidget(), ScenarioEditorToolbarWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), StatusBarWindow::DrawWidget(), GameSettingsWindow::DrawWidget(), ScanProgressWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), NetworkClientListWindow::DrawWidget(), NetworkClientListPopupWindow::DrawWidget(), LandInfoWindow::DrawWidget(), CompanyLeagueWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), GoalListWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), CheatWindow::DrawWidget(), AIListWindow::DrawWidget(), DrawYearColumn(), TownViewWindow::GetDesiredInfoHeight(), GetEngineListHeight(), VehicleDetailsWindow::GetRoadVehDetailsHeight(), MakeAsdfgKeys(), MakeNumberKeys(), MakeQwertyKeys(), MakeSpacebarKeys(), MakeTopKeys(), MakeZxcvbKeys(), ViewportSign::MarkDirty(), NetworkDrawChatMessage(), NetworkReInitChatBoxSize(), TownAuthorityWindow::OnClick(), StationViewWindow::OnClick(), CompanyStationsWindow::OnClick(), IndustryViewWindow::OnClick(), CheatWindow::OnClick(), IndustryCargoesWindow::OnInit(), NetworkClientListPopupWindow::OnMouseLoop(), NetworkClientListWindow::OnMouseOver(), BuildAirportWindow::OnPaint(), NWidgetBackground::SetupSmallestSize(), VehicleDetailsWindow::UpdateWidgetSize(), RefitWindow::UpdateWidgetSize(), TownAuthorityWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), StationViewWindow::UpdateWidgetSize(), GameSettingsWindow::UpdateWidgetSize(), BuildRailStationWindow::UpdateWidgetSize(), BuildObjectWindow::UpdateWidgetSize(), MessageOptionsWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), SpriteAlignerWindow::UpdateWidgetSize(), NewGRFInspectWindow::UpdateWidgetSize(), NetworkLobbyWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), SelectGameWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), EnginePreviewWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), CompanyInfrastructureWindow::UpdateWidgetSize(), CheatWindow::UpdateWidgetSize(), BuildAirportWindow::UpdateWidgetSize(), AIConfigWindow::UpdateWidgetSize(), AISettingsWindow::UpdateWidgetSize(), AIListWindow::UpdateWidgetSize(), and ViewportAddString().
#define FONT_HEIGHT_SMALL (GetCharacterHeight(FS_SMALL)) |
Height of characters in the small (FS_SMALL) font.
Definition at line 167 of file gfx_func.h.
Referenced by CheckClickOnViewportSign(), DrawEngineList(), SmallMapWindow::DrawTowns(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), GetVehicleListHeight(), SmallMapWindow::OnClick(), MusicTrackSelectionWindow::OnClick(), and BaseGraphWindow::UpdateWidgetSize().
#define GREY_SCALE | ( | level | ) | (level) |
Return the colour for a particular greyscale level.
level | Intensity, 0 = black, 15 = white |
Definition at line 193 of file gfx_func.h.
enum StringAlignment |
How to align the to-be drawn text.
Definition at line 94 of file gfx_func.h.
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 249 of file gfx.cpp.
References PC_WHITE.
Referenced by ViewportDrawBoundingBoxes().
void DrawDirtyBlocks | ( | ) |
Repaints the rectangle blocks which are marked as 'dirty'.
Definition at line 1722 of file gfx.cpp.
References _modal_progress_paint_mutex, _modal_progress_work_mutex, _realtime_tick, _switch_mode, Align(), ThreadMutex::BeginCritical(), ThreadMutex::EndCritical(), HasModalProgress(), IsFirstModalProgressLoop(), and MODAL_PROGRESS_REDRAW_TIMEOUT.
Referenced by MakeScreenshot(), and UpdateWindows().
void DrawOverlappedWindowForAll | ( | int | left, | |
int | top, | |||
int | right, | |||
int | bottom | |||
) |
From a rectangle that needs redrawing, find the windows that intersect with the rectangle.
These windows should be re-painted.
left | Left edge of the rectangle that should be repainted | |
top | Top edge of the rectangle that should be repainted | |
right | Right edge of the rectangle that should be repainted | |
bottom | Bottom edge of the rectangle that should be repainted |
Definition at line 673 of file window.cpp.
References DrawOverlappedWindow(), Window::height, Window::left, MayBeShown(), Window::top, and Window::width.
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 1210 of file gfx.cpp.
References BM_COLOUR_REMAP, BM_NORMAL, BM_TRANSPARENT, GB(), HasBit(), PALETTE_MODIFIER_TRANSPARENT, PALETTE_WIDTH, SPRITE_WIDTH, ST_NORMAL, and ST_RECOLOUR.
Referenced by SettingEntry::Draw(), DrawAircraftImage(), DrawArrowButtons(), DrawCargoIcons(), DrawCommonTileSeqInGUI(), DrawCompanyIcon(), DrawCompanyManagerFace(), DrawDebugBox(), DrawEngineList(), VehicleGroupWindow::DrawGroupInfo(), DrawHorizontalScrollbar(), DrawImageButtons(), NetworkContentListWindow::DrawMatrix(), DrawNewObjectTileInGUI(), DrawOrderString(), TownAuthorityWindow::DrawRatings(), DrawResizeBox(), DrawRoadDepotSprite(), DrawRoadVehEngine(), DrawRoadVehImage(), NetworkGameWindow::DrawServerLine(), DrawShadeBox(), DrawShipImage(), BuildSignalWindow::DrawSignalSprite(), DrawStationTile(), DrawStickyBox(), DrawTrainDetails(), DrawTrainImage(), DepotWindow::DrawVehicleInDepot(), DrawVehicleProfitButton(), VehicleViewWindow::DrawWidget(), BuildTreesWindow::DrawWidget(), TransparenciesWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), ScenarioEditorLandscapeGenerationWindow::DrawWidget(), StatusBarWindow::DrawWidget(), SpriteAlignerWindow::DrawWidget(), CompanyWindow::DrawWidget(), SelectCompanyLiveryWindow::DrawWidget(), CheatWindow::DrawWidget(), BuildBridgeWindow::DrawWidget(), BuildAirportWindow::DrawWidget(), and MainWindow::OnPaint().
Draw a sprite in a viewport.
img | Image number to draw | |
pal | Palette to use. | |
x | Left coordinate of image in viewport, scaled by zoom | |
y | Top coordinate of image in viewport, scaled by zoom | |
sub | If available, draw only specified part of the sprite |
Definition at line 1187 of file gfx.cpp.
References BM_COLOUR_REMAP, BM_NORMAL, BM_TRANSPARENT, GB(), HasBit(), PALETTE_MODIFIER_TRANSPARENT, PALETTE_WIDTH, SPRITE_WIDTH, ST_NORMAL, and ST_RECOLOUR.
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, see DoDrawString() for details | |
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 628 of file gfx.cpp.
References DRAW_STRING_BUFFER, DrawString(), lastof, and strecpy().
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, see DoDrawString() for details | |
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 650 of file gfx.cpp.
References DRAW_STRING_BUFFER, DrawString(), and lastof.
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, see DoDrawString() for details | |
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 972 of file gfx.cpp.
References DRAW_STRING_BUFFER, DrawStringMultiLine(), lastof, and strecpy().
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, see DoDrawString() for details | |
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 994 of file gfx.cpp.
References DRAW_STRING_BUFFER, DrawStringMultiLine(), and lastof.
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 1895 of file gfx.cpp.
References BlitterFactoryBase::GetCurrentBlitter(), and Blitter::MoveTo().
Referenced by NWidgetMatrix::Draw(), DrawRoadVehImage(), DrawTrainImage(), SmallMapWindow::DrawWidget(), BuildRailStationWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), and IndustryCargoesWindow::DrawWidget().
uint32 FormatStringLinebreaks | ( | char * | str, | |
const char * | last, | |||
int | maxw, | |||
FontSize | size | |||
) |
'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.
str | string to check and correct for length restrictions | |
last | the last valid location (for '') in the buffer of str | |
maxw | the maximum width the string can have on one line | |
size | Fontsize to start the text with |
Definition at line 678 of file gfx.cpp.
References GetCharacterWidth(), IsTextDirectionChar(), IsWhitespace(), SCC_BIGFONT, SCC_TINYFONT, and Utf8PrevChar().
Referenced by DrawStringMultiLine(), GetStringHeight(), and NetworkAddChatMessage().
void GameSizeChanged | ( | ) |
Size of the application screen changed.
Adapt the game screen-size, re-allocate the open windows, and repaint everything
Definition at line 583 of file main_gui.cpp.
References _cur_resolution, MarkWholeScreenDirty(), and RelocateAllWindows().
Referenced by VideoDriver_Win32::MakeWindow().
static byte GetCharacterHeight | ( | FontSize | size | ) | [inline, static] |
Get height of a character for a given font size.
size | Font size to get height of |
Definition at line 159 of file gfx_func.h.
References _font_height.
Referenced by BaseGraphWindow::DrawGraph(), DrawStringMultiLine(), GetMultilineStringHeight(), GetStringBoundingBox(), LoadStringWidthTable(), ReallyDoDrawString(), NWidgetResizeBase::SetMinimalTextLines(), and StationsWndShowStationRating().
byte GetDigitWidth | ( | FontSize | size | ) |
Return the maximum width of single digit.
size | Font of the digit |
Definition at line 1598 of file gfx.cpp.
References GetCharacterWidth(), and max().
Referenced by BaseVehicleListWindow::DrawVehicleListItems(), and DepotWindow::UpdateWidgetSize().
Get the size of a sprite.
sprid | Sprite to examine. | |
[out] | offset | Optionally returns the sprite position offset. |
Definition at line 1164 of file gfx.cpp.
References Sprite::height, ST_NORMAL, UnScaleByZoom(), Sprite::width, Sprite::x_offs, and Sprite::y_offs.
Referenced by VehicleGroupWindow::ComputeGroupInfoSize(), DrawEngineList(), DrawOrderString(), TownAuthorityWindow::DrawRatings(), BaseVehicleListWindow::DrawVehicleListItems(), TownDirectoryWindow::DrawWidget(), TimetableWindow::DrawWidget(), StatusBarWindow::DrawWidget(), OrdersWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), CompanyWindow::DrawWidget(), BuildBridgeWindow::DrawWidget(), BuildAirportWindow::DrawWidget(), BuildTreesWindow::GetMaxTreeSpriteSize(), MakeCompanyButtonRows(), MakeNWidgetCompanyLines(), SelectCompanyManagerFaceWindow::OnInit(), MainWindow::OnPaint(), NWidgetLeaf::SetupSmallestSize(), TownDirectoryWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), CompanyLeagueWindow::UpdateWidgetSize(), BuyCompanyWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), BuildBridgeWindow::UpdateWidgetSize(), and BuildAirportWindow::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 1011 of file gfx.cpp.
References GetCharacterHeight(), GetCharacterWidth(), IsTextDirectionChar(), max(), SCC_BIGFONT, and SCC_TINYFONT.
Referenced by VehicleGroupWindow::ComputeGroupInfoSize(), DrawCaption(), DrawEngineList(), DrawLabel(), DrawString(), DrawText(), TimetableWindow::DrawWidget(), OrdersWindow::DrawWidget(), CheatWindow::DrawWidget(), BaseVehicleListWindow::GetActionDropdownSize(), ExpensesList::GetCategoriesWidth(), GetStringBoundingBox(), BaseGraphWindow::GetYLabelWidth(), TextfileWindow::LoadTextfile(), SmallMapWindow::OnInit(), MessageOptionsWindow::OnInit(), IndustryCargoesWindow::OnInit(), SelectCompanyManagerFaceWindow::OnInit(), RefitWindow::OnInvalidateData(), NWidgetLeaf::SetupSmallestSize(), NWidgetBackground::SetupSmallestSize(), ViewportSign::UpdatePosition(), VehicleDetailsWindow::UpdateWidgetSize(), VehicleListWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), TownAuthorityWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), SubsidyListWindow::UpdateWidgetSize(), StatusBarWindow::UpdateWidgetSize(), SelectStationWindow< T >::UpdateWidgetSize(), StationViewWindow::UpdateWidgetSize(), CompanyStationsWindow::UpdateWidgetSize(), CustomCurrencyWindow::UpdateWidgetSize(), GameSettingsWindow::UpdateWidgetSize(), GameDifficultyWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), BuildRailStationWindow::UpdateWidgetSize(), OrdersWindow::UpdateWidgetSize(), BuildObjectWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), NetworkJoinStatusWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), NetworkClientListPopupWindow::UpdateWidgetSize(), MusicWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), TooltipsWindow::UpdateWidgetSize(), AboutWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), SelectGameWindow::UpdateWidgetSize(), IndustryDirectoryWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), CompanyLeagueWindow::UpdateWidgetSize(), PaymentRatesGraphWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), GoalListWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), CreateScenarioWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), CompanyInfrastructureWindow::UpdateWidgetSize(), SelectCompanyManagerFaceWindow::UpdateWidgetSize(), SelectCompanyLiveryWindow::UpdateWidgetSize(), CompanyFinancesWindow::UpdateWidgetSize(), CheatWindow::UpdateWidgetSize(), BuildVehicleWindow::UpdateWidgetSize(), BuildBridgeWindow::UpdateWidgetSize(), ReplaceVehicleWindow::UpdateWidgetSize(), and BuildAirportWindow::UpdateWidgetSize().
Get bounding box of a string.
Uses parameters set by DParam if needed. Has the same restrictions as GetStringBoundingBox(const char *str).
strid | String to examine. |
Definition at line 1053 of file gfx.cpp.
References DRAW_STRING_BUFFER, GetStringBoundingBox(), and lastof.
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 803 of file gfx.cpp.
References DRAW_STRING_BUFFER, FormatStringLinebreaks(), FS_NORMAL, GB(), GetMultilineStringHeight(), and lastof.
Referenced by EnginePreviewWindow::DrawWidget(), TownViewWindow::GetDesiredInfoHeight(), SettingEntry::GetMaxHelpHeight(), GetStringMultiLineBoundingBox(), GameOptionsWindow::UpdateWidgetSize(), TooltipsWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), SelectGameWindow::UpdateWidgetSize(), GoalQuestionWindow::UpdateWidgetSize(), EnginePreviewWindow::UpdateWidgetSize(), BuyCompanyWindow::UpdateWidgetSize(), and CheatWindow::UpdateWidgetSize().
Calculate string bounding box for multi-line strings.
str | String to check. | |
suggestion | Suggested bounding box. |
Definition at line 820 of file gfx.cpp.
References GetStringHeight().
Referenced by TownAuthorityWindow::UpdateWidgetSize(), NewsWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), QueryWindow::UpdateWidgetSize(), and BuildAirportWindow::UpdateWidgetSize().
Calculate string bounding box for multi-line strings.
str | String to check. | |
suggestion | Suggested bounding box. |
Definition at line 850 of file gfx.cpp.
References GetStringHeight().
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 147 of file gfx.cpp.
References Blitter::DrawColourMappingRect(), Blitter::DrawRect(), FILLRECT_CHECKER, FILLRECT_RECOLOUR, GB(), BlitterFactoryBase::GetCurrentBlitter(), Blitter::MoveTo(), PALETTE_WIDTH, Blitter::SetPixel(), and ZOOM_LVL_NORMAL.
Referenced by NWidgetLeaf::Draw(), NWidgetViewport::Draw(), NWidgetBackground::Draw(), NWidgetMatrix::Draw(), NWidgetToolbarContainer::Draw(), CargoesField::Draw(), DrawArrowButtons(), DrawCaption(), NetworkContentListWindow::DrawDetails(), DrawDropDownButton(), DrawFrame(), DrawFrameRect(), BaseGraphWindow::DrawGraph(), VehicleGroupWindow::DrawGroupInfo(), CargoesField::DrawHorConnection(), SmallMapWindow::DrawHorizMapIndicator(), DrawHorizontalScrollbar(), DrawMatrix(), NetworkContentListWindow::DrawMatrix(), NetworkGameWindow::DrawServerLine(), SmallMapWindow::DrawSmallMap(), DrawString(), DrawTrainDetails(), LinkGraphOverlay::DrawVertex(), DrawVerticalScrollbar(), SmallMapWindow::DrawVertMapIndicator(), DropdownWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), SmallMapWindow::DrawWidget(), BuildRailWaypointWindow::DrawWidget(), BuildRailStationWindow::DrawWidget(), OrdersWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), NewsWindow::DrawWidget(), NetworkClientListWindow::DrawWidget(), NetworkClientListPopupWindow::DrawWidget(), MusicWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), TooltipsWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), PaymentRatesGraphWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), CompanyFinancesWindow::DrawWidget(), BootstrapBackground::DrawWidget(), BuildAirportWindow::DrawWidget(), Window::DrawWidgets(), DrawYearColumn(), HighlightDragPosition(), NetworkDrawChatMessage(), IConsoleWindow::OnPaint(), and StationsWndShowStationRating().
void HandleKeypress | ( | uint32 | raw_key | ) |
Handle keyboard input.
raw_key | Lower 8 bits contain the ASCII character, the higher 16 bits the keycode |
Definition at line 2223 of file window.cpp.
References EditBoxInGlobalFocus(), FindWindowById(), GB(), HasModalProgress(), IsLocalCompany(), Window::OnKeyPress(), WC_MAIN_TOOLBAR, and Window::window_class.
void LoadStringWidthTable | ( | bool | monospace | ) |
Initialize _stringwidth_table cache.
monospace | Whether to load the monospace cache or the normal fonts. |
Definition at line 1554 of file gfx.cpp.
References _max_char_height, _max_char_width, _stringwidth_table, FS_BEGIN, FS_MONO, GetCharacterHeight(), and ReInitAllWindows().
Referenced by AfterLoadGame(), CheckForMissingGlyphs(), GenerateWorld(), and ReloadNewGRFData().
void SetAnimatedMouseCursor | ( | const AnimCursor * | table | ) |
Assign an animation to the cursor.
table | Array of animation states. |
Definition at line 2013 of file gfx.cpp.
References CursorVars::animate_cur, and CursorVars::animate_list.
void SetDirtyBlocks | ( | int | left, | |
int | top, | |||
int | right, | |||
int | bottom | |||
) |
This function extends the internal _invalid_rect rectangle as it now contains the rectangle defined by the given parameters.
Note the point (0,0) is top left.
left | The left edge of the rectangle | |
top | The top edge of the rectangle | |
right | The right edge of the rectangle | |
bottom | The bottm edge of the rectangle |
AddDirtyBlock
as it neither set a dirty rect nor add several dirty rects although the function name is in plural. (Progman) Definition at line 1833 of file gfx.cpp.
Referenced by MarkViewportDirty(), MarkWholeScreenDirty(), PositionWindow(), Window::SetDirty(), NWidgetBase::SetDirty(), and NewsWindow::SetWindowTop().
Assign a single non-animated sprite to the cursor.
Definition at line 2000 of file gfx.cpp.
References CursorVars::animate_timeout, and SetCursorSprite().
Referenced by CleanupGeneration(), GenerateProgressWindow::OnClick(), SaveFileDone(), and SaveFileStart().
void UpdateCursorSize | ( | ) |
Update cursor dimension.
Called when changing cursor sprite resp. reloading grfs.
Definition at line 1945 of file gfx.cpp.
References CursorVars::dirty, GB(), Sprite::height, CursorVars::sprite, SPRITE_WIDTH, ST_NORMAL, UnScaleByZoom(), Sprite::width, Sprite::x_offs, Sprite::y_offs, and ZOOM_LVL_GUI.
Referenced by GfxLoadSprites(), and SetCursorSprite().
bool _palette_remap_grf[] |
Whether the given NewGRFs must get a palette remap from windows to DOS or not.
Definition at line 28 of file gfxinit.cpp.
Referenced by DecodeSingleSprite(), LoadNewGRFFile(), LoadSpriteTables(), and ReadRecolourSprite().
const int DRAW_STRING_BUFFER = 2048 [static] |
Size of the buffer used for drawing strings.
Definition at line 84 of file gfx_func.h.
Referenced by CopyOutDParam(), NetworkContentListWindow::DrawDetails(), DrawString(), DrawStringMultiLine(), GetStringBoundingBox(), GetStringHeight(), HandleBiDiAndArabicShapes(), NetworkAddChatMessage(), NetworkHandlePauseChange(), ShowErrorMessage(), strnatcmp(), and ViewportSign::UpdatePosition().