|
OpenTTD Source
1.10.0-RC1
|
Functions related to the gfx engine. More...
Go to the source code of this file.
Macros | |
| #define | FONT_HEIGHT_SMALL (GetCharacterHeight(FS_SMALL)) |
| Height of characters in the small (FS_SMALL) font. More... | |
| #define | FONT_HEIGHT_NORMAL (GetCharacterHeight(FS_NORMAL)) |
| Height of characters in the normal (FS_NORMAL) font. More... | |
| #define | FONT_HEIGHT_LARGE (GetCharacterHeight(FS_LARGE)) |
| Height of characters in the large (FS_LARGE) font. More... | |
| #define | FONT_HEIGHT_MONO (GetCharacterHeight(FS_MONO)) |
| Height of characters in the large (FS_MONO) font. More... | |
| #define | GREY_SCALE(level) (level) |
| Return the colour for a particular greyscale level. More... | |
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 } |
| How to align the to-be drawn text. More... | |
Functions | |
| void | GameLoop () |
| void | CreateConsole () |
| void | HandleKeypress (uint keycode, WChar key) |
| Handle keyboard input. More... | |
| void | HandleTextInput (const char *str, bool marked=false, const char *caret=nullptr, const char *insert_location=nullptr, const char *replacement_end=nullptr) |
| Handle text input. More... | |
| void | HandleCtrlChanged () |
| State of CONTROL key has changed. | |
| void | HandleMouseEvents () |
| Handle a mouse event from the video driver. | |
| 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. More... | |
| 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=nullptr, ZoomLevel zoom=ZOOM_LVL_GUI) |
| Get the size of a sprite. More... | |
| void | DrawSpriteViewport (SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub=nullptr) |
| Draw a sprite in a viewport. More... | |
| void | DrawSprite (SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub=nullptr, ZoomLevel zoom=ZOOM_LVL_GUI) |
| Draw a sprite, not in a viewport. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| void | DrawCharCentered (uint32 c, int x, int y, TextColour colour) |
| Draw single character horizontally centered around (x,y) More... | |
| 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. More... | |
| void | GfxFillPolygon (const std::vector< Point > &shape, int colour, FillRectMode mode=FILLRECT_OPAQUE) |
| Fill a polygon with colour. More... | |
| void | GfxDrawLine (int left, int top, int right, int bottom, int colour, int width=1, int dash=0) |
| 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... | |
| Dimension | GetStringBoundingBox (const char *str, FontSize start_fontsize=FS_NORMAL) |
| Return the string dimension in pixels. More... | |
| Dimension | GetStringBoundingBox (StringID strid) |
| Get bounding box of a string. More... | |
| int | GetStringHeight (const char *str, int maxw, FontSize fontsize=FS_NORMAL) |
| 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... | |
| void | LoadStringWidthTable (bool monospace=false) |
| Initialize _stringwidth_table cache. More... | |
| Point | GetCharPosInString (const char *str, const char *ch, FontSize start_fontsize=FS_NORMAL) |
| 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=FS_NORMAL) |
| Get the character from a string that is drawn at a specific position. More... | |
| void | DrawDirtyBlocks () |
| Repaints the rectangle blocks which are marked as 'dirty'. More... | |
| 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. More... | |
| void | MarkWholeScreenDirty () |
| This function mark the whole screen as dirty. More... | |
| void | GfxInitPalettes () |
| void | CheckBlitter () |
| Check whether we still use the right blitter, or use another (better) one. 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... | |
| static int | CenterBounds (int min, int max, int size) |
| Determine where to draw a centred object inside a widget. More... | |
| void | DrawOverlappedWindowForAll (int left, int top, int right, int bottom) |
| From a rectangle that needs redrawing, find the windows that intersect with the rectangle. More... | |
| void | SetMouseCursorBusy (bool busy) |
| Set or unset the ZZZ cursor. More... | |
| void | SetMouseCursor (CursorID cursor, PaletteID pal) |
| Assign a single non-animated sprite to the cursor. More... | |
| void | SetAnimatedMouseCursor (const AnimCursor *table) |
| Assign an animation to the cursor. More... | |
| void | CursorTick () |
| void | UpdateCursorSize () |
| Update cursor dimension. More... | |
| bool | ChangeResInGame (int w, int h) |
| void | SortResolutions () |
| bool | ToggleFullScreen (bool fs) |
| byte | GetCharacterWidth (FontSize size, uint32 key) |
| Return width of character glyph. More... | |
| byte | GetDigitWidth (FontSize size=FS_NORMAL) |
| Return the maximum width of single digit. More... | |
| void | GetBroadestDigit (uint *front, uint *next, FontSize size=FS_NORMAL) |
| Determine the broadest digits for guessing the maximum width of a n-digit number. More... | |
| int | GetCharacterHeight (FontSize size) |
| Get height of a character for a given font size. More... | |
| TextColour | GetContrastColour (uint8 background, uint8 threshold=128) |
| Determine a contrasty text colour for a coloured background. More... | |
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? | |
| 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) | |
| std::vector< Dimension > | _resolutions |
| 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. More... | |
| 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. More... | |
| 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_VERY_DARK_BLUE = 0x9A |
| Almost-black blue palette colour. | |
| static const uint8 | PC_DARK_BLUE = 0x9D |
| Dark blue palette colour. | |
| static const uint8 | PC_LIGHT_BLUE = 0x98 |
| Light blue palette colour. | |
| static const uint8 | PC_ROUGH_LAND = 0x52 |
| Dark green palette colour for rough land. | |
| static const uint8 | PC_GRASS_LAND = 0x54 |
| Dark green palette colour for grass land. | |
| static const uint8 | PC_BARE_LAND = 0x37 |
| Brown palette colour for bare land. | |
| static const uint8 | PC_FIELDS = 0x25 |
| Light brown palette colour for fields. | |
| static const uint8 | PC_TREES = 0x57 |
| Green palette colour for trees. | |
| static const uint8 | PC_WATER = 0xC9 |
| Dark blue palette colour for water. | |
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 180 of file gfx_func.h.
Referenced by DrawString().
| #define FONT_HEIGHT_MONO (GetCharacterHeight(FS_MONO)) |
Height of characters in the large (FS_MONO) font.
Definition at line 183 of file gfx_func.h.
Referenced by DrawString(), and TextfileWindow::SetupScrollbars().
| #define FONT_HEIGHT_NORMAL (GetCharacterHeight(FS_NORMAL)) |
Height of characters in the normal (FS_NORMAL) font.
Definition at line 177 of file gfx_func.h.
Referenced by CheckClickOnViewportSign(), CargoesField::Draw(), DrawButtonDropdown(), NetworkContentListWindow::DrawDetails(), DrawFrame(), NetworkContentListWindow::DrawMatrix(), DrawString(), CompanyLeagueWindow::DrawWidget(), NetworkClientListPopupWindow::DrawWidget(), NetworkClientListWindow::DrawWidget(), SavePresetWindow::DrawWidget(), ScenarioEditorToolbarWindow::DrawWidget(), StoryBookWindow::GetContentHeight(), TownViewWindow::GetDesiredInfoHeight(), GetEngineListHeight(), StoryBookWindow::GetHeadHeight(), TownAuthorityWindow::GetNthSetBit(), VehicleDetailsWindow::GetRoadVehDetailsHeight(), LocalGetWindowPlacement(), MakeAsdfgKeys(), MakeNumberKeys(), MakeQwertyKeys(), MakeSpacebarKeys(), MakeTopKeys(), MakeZxcvbKeys(), ViewportSign::MarkDirty(), NetworkReInitChatBoxSize(), CompanyStationsWindow::OnClick(), IndustryViewWindow::OnClick(), StationViewWindow::OnClick(), IndustryCargoesWindow::OnInit(), NetworkGameWindow::OnPaint(), ReplaceVehicleWindow::ReplaceClick_StartReplace(), SelectGameWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), AIListWindow::UpdateWidgetSize(), BuildObjectWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), BuildAirportWindow::UpdateWidgetSize(), AISettingsWindow::UpdateWidgetSize(), CompanyStationsWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), AboutWindow::UpdateWidgetSize(), StoryBookWindow::UpdateWidgetSize(), SaveLoadWindow::UpdateWidgetSize(), NetworkContentListWindow::UpdateWidgetSize(), RefitWindow::UpdateWidgetSize(), AIConfigWindow::UpdateWidgetSize(), OrdersWindow::UpdateWidgetSize(), SpriteAlignerWindow::UpdateWidgetSize(), BuildRailStationWindow::UpdateWidgetSize(), AIDebugWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), NetworkLobbyWindow::UpdateWidgetSize(), StationViewWindow::UpdateWidgetSize(), GameSettingsWindow::UpdateWidgetSize(), VehicleDetailsWindow::UpdateWidgetSize(), NetworkJoinStatusWindow::UpdateWidgetSize(), SavePresetWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), and ViewportAddString().
| #define FONT_HEIGHT_SMALL (GetCharacterHeight(FS_SMALL)) |
Height of characters in the small (FS_SMALL) font.
Definition at line 174 of file gfx_func.h.
Referenced by CheckClickOnViewportSign(), DrawString(), SmallMapWindow::GetLegendHeight(), SmallMapWindow::GetPositionOnLegend(), GetVehicleListHeight(), and CompanyStationsWindow::UpdateWidgetSize().
| #define GREY_SCALE | ( | level | ) | (level) |
Return the colour for a particular greyscale level.
| level | Intensity, 0 = black, 15 = white |
Definition at line 202 of file gfx_func.h.
| enum StringAlignment |
How to align the to-be drawn text.
Definition at line 93 of file gfx_func.h.
|
inlinestatic |
Determine where to draw a centred object inside a widget.
| min | The top or left coordinate. |
| max | The bottom or right coordinate. |
| size | The height or width of the object to draw. |
Definition at line 149 of file gfx_func.h.
References DrawOverlappedWindowForAll(), SetAnimatedMouseCursor(), SetMouseCursor(), and SetMouseCursorBusy().
| void CheckBlitter | ( | ) |
Check whether we still use the right blitter, or use another (better) one.
Definition at line 328 of file gfxinit.cpp.
References SwitchNewGRFBlitter().
| 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 414 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)
| c | Character (glyph) to draw |
| x | X position to draw character |
| y | Y position to draw character |
| 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 895 of file gfx.cpp.
Referenced by OskWindow::DrawWidget().
| void DrawDirtyBlocks | ( | ) |
Repaints the rectangle blocks which are marked as 'dirty'.
| 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 959 of file window.cpp.
Referenced by CenterBounds().
| 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 973 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 636 of file gfx.cpp.
References FONT_HEIGHT_LARGE, FONT_HEIGHT_MONO, FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL, and max().
Referenced by CargoesField::Draw(), DrawCaption(), NetworkContentListWindow::DrawDetails(), SelectCompanyManagerFaceWindow::DrawFaceStringLabel(), DrawFrame(), DrawInset(), DrawPrice(), DrawText(), StatusBarWindow::DrawWidget(), CompanyFinancesWindow::DrawWidget(), ReplaceVehicleWindow::DrawWidget(), NetworkChatWindow::DrawWidget(), GenerateLandscapeWindow::DrawWidget(), NetworkContentListWindow::DrawWidget(), MusicWindow::DrawWidget(), AIConfigWindow::DrawWidget(), NetworkStartServerWindow::DrawWidget(), SelectCompanyManagerFaceWindow::DrawWidget(), GameSettingsWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), ScenarioEditorToolbarWindow::DrawWidget(), and NetworkGameWindow::OnPaint().
| 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 672 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 759 of file gfx.cpp.
References Layouter::GetBounds().
Referenced by StationViewWindow::DrawAcceptedCargo(), SelectGameWindow::DrawWidget(), BootstrapAskForDownloadWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), ErrmsgWindow::DrawWidget(), GameOptionsWindow::DrawWidget(), GoalQuestionWindow::DrawWidget(), TooltipsWindow::DrawWidget(), QueryStringWindow::DrawWidget(), QueryWindow::DrawWidget(), NetworkCompanyPasswordWindow::DrawWidget(), CompanyWindow::DrawWidget(), BuyCompanyWindow::DrawWidget(), and HighScoreWindow::OnPaint().
| 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 821 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 1619 of file gfx.cpp.
Referenced by NWidgetMatrix::Draw(), NWidgetLeaf::Draw(), SmallMapWindow::DrawWidget(), and BuildRailStationWindow::DrawWidget().
| void GameSizeChanged | ( | ) |
Size of the application screen changed.
Adapt the game screen-size, re-allocate the open windows, and repaint everything
Definition at line 594 of file main_gui.cpp.
References _cur_resolution.
| 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 1318 of file gfx.cpp.
Referenced by SetDParamMaxDigits().
| int GetCharacterHeight | ( | FontSize | size | ) |
Get height of a character for a given font size.
| size | Font size to get height of |
Definition at line 62 of file fontcache.cpp.
References FontCache::Get(), and FontCache::GetHeight().
Referenced by NWidgetResizeBase::SetMinimalTextLines().
Return width of character glyph.
| size | Font of the character |
| key | Character code glyph |
Definition at line 1290 of file gfx.cpp.
References _stringwidth_table, and GetGlyphWidth().
| 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 866 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 1257 of file gfx.cpp.
References Palette::palette.
| byte GetDigitWidth | ( | FontSize | size | ) |
Return the maximum width of single digit.
| size | Font of the digit |
Definition at line 1303 of file gfx.cpp.
Referenced by BuildSignalWindow::UpdateWidgetSize().
Get the size of a sprite.
| sprid | Sprite to examine. | |
| [out] | offset | Optionally returns the sprite position offset. |
Definition at line 908 of file gfx.cpp.
Referenced by VehicleGroupWindow::ComputeGroupInfoSize(), StoryBookWindow::DrawActionElement(), BuildSignalWindow::DrawSignalSprite(), BaseVehicleListWindow::DrawVehicleListItems(), TimetableWindow::DrawWidget(), OrdersWindow::DrawWidget(), BuildTreesWindow::GetMaxTreeSpriteSize(), StoryBookWindow::GetPageElementHeight(), GetRailTypeDropDownList(), MakeNWidgetCompanyLines(), NetworkContentListWindow::NetworkContentListWindow(), SelectCompanyManagerFaceWindow::OnInit(), NetworkLobbyWindow::OnPaint(), BuildBridgeWindow::UpdateWidgetSize(), ErrmsgWindow::UpdateWidgetSize(), SignListWindow::UpdateWidgetSize(), NewsWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), NetworkGameWindow::UpdateWidgetSize(), NewGRFWindow::UpdateWidgetSize(), SelectCompanyManagerFaceWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), VehicleViewWindow::UpdateWidgetSize(), and BuyCompanyWindow::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 838 of file gfx.cpp.
Referenced by DrawCaption(), DrawText(), TimetableWindow::DrawWidget(), OrdersWindow::DrawWidget(), BaseVehicleListWindow::GetActionDropdownSize(), BaseGraphWindow::GetYLabelWidth(), SelectCompanyManagerFaceWindow::OnInit(), IndustryCargoesWindow::OnInit(), GoalListWindow::OnPaint(), TextfileWindow::SetupScrollbars(), SelectGameWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), SetDateWindow::UpdateWidgetSize(), StatusBarWindow::UpdateWidgetSize(), BuildObjectWindow::UpdateWidgetSize(), SubsidyListWindow::UpdateWidgetSize(), BootstrapAskForDownloadWindow::UpdateWidgetSize(), BuildBridgeWindow::UpdateWidgetSize(), GoalListWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), ReplaceVehicleWindow::UpdateWidgetSize(), BuildAirportWindow::UpdateWidgetSize(), CompanyFinancesWindow::UpdateWidgetSize(), NewsWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), CompanyStationsWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), GenerateLandscapeWindow::UpdateWidgetSize(), NetworkChatWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), NetworkGameWindow::UpdateWidgetSize(), StoryBookWindow::UpdateWidgetSize(), SaveLoadWindow::UpdateWidgetSize(), NetworkContentListWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), MusicWindow::UpdateWidgetSize(), TooltipsWindow::UpdateWidgetSize(), AIConfigWindow::UpdateWidgetSize(), OrdersWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), PaymentRatesGraphWindow::UpdateWidgetSize(), CreateScenarioWindow::UpdateWidgetSize(), BuildRailStationWindow::UpdateWidgetSize(), NetworkStartServerWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), CompanyLeagueWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), StationViewWindow::UpdateWidgetSize(), BuildVehicleWindow::UpdateWidgetSize(), IndustryDirectoryWindow::UpdateWidgetSize(), NetworkClientListPopupWindow::UpdateWidgetSize(), GameSettingsWindow::UpdateWidgetSize(), CompanyInfrastructureWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), SavePresetWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), and Textbuf::UpdateWidth().
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 850 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 685 of file gfx.cpp.
Referenced by TextfileWindow::GetContentHeight(), StoryBookWindow::GetHeadHeight(), SettingEntry::GetMaxHelpHeight(), StoryBookWindow::GetPageElementHeight(), SelectGameWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), BootstrapAskForDownloadWindow::UpdateWidgetSize(), ErrmsgWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), GoalQuestionWindow::UpdateWidgetSize(), and TooltipsWindow::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 697 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 710 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 725 of file gfx.cpp.
Referenced by QueryWindow::UpdateWidgetSize().
| 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 206 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 110 of file gfx.cpp.
References BlitterFactory::GetCurrentBlitter().
Referenced by NWidgetMatrix::Draw(), NWidgetViewport::Draw(), NWidgetToolbarContainer::Draw(), DrawCaption(), NetworkContentListWindow::DrawDetails(), DrawFrame(), BootstrapBackground::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), MusicWindow::DrawWidget(), TooltipsWindow::DrawWidget(), NewGRFWindow::DrawWidget(), NetworkClientListPopupWindow::DrawWidget(), BuildRailWaypointWindow::DrawWidget(), SavePresetWindow::DrawWidget(), and NetworkGameWindow::OnPaint().
| void HandleKeypress | ( | uint | keycode, |
| WChar | key | ||
| ) |
Handle keyboard input.
| keycode | Virtual keycode of the key. |
| key | Unicode character of the key. |
Definition at line 2673 of file window.cpp.
Referenced by HandleCharMsg().
| void HandleTextInput | ( | const char * | str, |
| bool | marked, | ||
| const char * | caret, | ||
| const char * | insert_location, | ||
| const char * | replacement_end | ||
| ) |
Handle text input.
| str | Text string to input. |
| marked | Is the input a marked composition string from an IME? |
| caret | Move the caret to this point in the insertion string. |
Definition at line 2761 of file window.cpp.
References EditBoxInGlobalFocus(), NWidgetCore::index, Window::InsertTextString(), Window::nested_focus, WC_CONSOLE, and Window::window_class.
Referenced by CancelIMEComposition(), and HandleIMEComposition().
| void LoadStringWidthTable | ( | bool | monospace | ) |
Initialize _stringwidth_table cache.
| monospace | Whether to load the monospace cache or the normal fonts. |
Definition at line 1271 of file gfx.cpp.
Referenced by ReloadNewGRFData().
| void SetAnimatedMouseCursor | ( | const AnimCursor * | table | ) |
Assign an animation to the cursor.
| table | Array of animation states. |
Definition at line 1769 of file gfx.cpp.
References CursorVars::animate_cur, CursorVars::animate_list, PalSpriteID::pal, and CursorVars::sprite_seq.
Referenced by CenterBounds().
| 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 bottom 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 1557 of file gfx.cpp.
Referenced by MarkViewportDirty(), MarkWholeScreenDirty(), NWidgetBase::SetDirty(), Window::SetDirty(), and NewsWindow::SetWindowTop().
Assign a single non-animated sprite to the cursor.
Definition at line 1756 of file gfx.cpp.
References CursorVars::animate_timeout, and SetCursorSprite().
Referenced by CenterBounds(), and SetMouseCursorBusy().
| void SetMouseCursorBusy | ( | bool | busy | ) |
Set or unset the ZZZ cursor.
| busy | Whether to show the ZZZ cursor. |
Definition at line 1741 of file gfx.cpp.
References SetMouseCursor(), SPR_CURSOR_MOUSE, PalSpriteID::sprite, and CursorVars::sprite_seq.
Referenced by CenterBounds(), CleanupGeneration(), and GenerateProgressWindow::OnClick().
| void UpdateCursorSize | ( | ) |
Update cursor dimension.
Called when changing cursor sprite resp. reloading grfs.
Definition at line 1669 of file gfx.cpp.
References GetMaxSpriteID().
Referenced by SetCursorSprite().
| bool _palette_remap_grf[] |
Whether the given NewGRFs must get a palette remap from windows to DOS or not.
Definition at line 30 of file gfxinit.cpp.
Referenced by LoadSpriteTables().
|
static |
Size of the buffer used for drawing strings.
Definition at line 83 of file gfx_func.h.
Referenced by StringFilter::AddLine(), CopyOutDParam(), DrawString(), DrawStringMultiLine(), GetLayouter(), GetStringBoundingBox(), GetStringHeight(), GetStringLineCount(), NetworkAddChatMessage(), and ViewportSign::UpdatePosition().