OpenTTD Source 20260421-master-gc2fbc6fdeb
gfx_type.h File Reference

Types related to the graphics and/or input devices. More...

#include "core/enum_type.hpp"
#include "core/geometry_type.hpp"
#include "zoom_type.h"

Go to the source code of this file.

Data Structures

struct  PalSpriteID
 Combination of a palette sprite and a 'real' sprite. More...
struct  AnimCursor
 A single sprite of a list of animated cursors. More...
struct  CursorSprite
struct  CursorVars
 Collection of variables for cursor-display and -animation. More...
struct  DrawPixelInfo
 Data about how and where to blit pixels. More...
union  ColourRGBA
 Packed colour union to access the alpha, red, green, and blue channels from a 32 bit number for Emscripten build. More...
union  ColourARGB
 Packed colour union to access the alpha, red, green, and blue channels from a 32 bit number for big-endian systems. More...
union  ColourBGRA
 Packed colour union to access the alpha, red, green, and blue channels from a 32 bit number for little-endian systems. More...
struct  SubSprite
 Used to only draw a part of the sprite. More...
struct  Palette
 Information about the currently used palette. More...
struct  PixelColour
 Colour for pixel/line drawing. More...

Typedefs

typedef uint32_t SpriteID
 The number of a sprite, without mapping bits and colourtables.
typedef uint32_t PaletteID
 The number of the palette.
typedef uint32_t CursorID
 The number of the cursor (sprite).
using Colour = std::conditional_t<std::endian::native == std::endian::little, ColourBGRA, ColourARGB>
using FontSizes = EnumBitSet<FontSize, uint8_t>

Enumerations

enum  WindowKeyCodes : uint16_t {
  WKC_SHIFT = 0x8000 , WKC_CTRL = 0x4000 , WKC_ALT = 0x2000 , WKC_META = 0x1000 ,
  WKC_GLOBAL_HOTKEY = 0x0800 , WKC_SPECIAL_KEYS = WKC_SHIFT | WKC_CTRL | WKC_ALT | WKC_META | WKC_GLOBAL_HOTKEY , WKC_NONE = 0 , WKC_ESC = 1 ,
  WKC_BACKSPACE = 2 , WKC_INSERT = 3 , WKC_DELETE = 4 , WKC_PAGEUP = 5 ,
  WKC_PAGEDOWN = 6 , WKC_END = 7 , WKC_HOME = 8 , WKC_LEFT = 9 ,
  WKC_UP = 10 , WKC_RIGHT = 11 , WKC_DOWN = 12 , WKC_RETURN = 13 ,
  WKC_TAB = 14 , WKC_SPACE = 32 , WKC_F1 = 33 , WKC_F2 = 34 ,
  WKC_F3 = 35 , WKC_F4 = 36 , WKC_F5 = 37 , WKC_F6 = 38 ,
  WKC_F7 = 39 , WKC_F8 = 40 , WKC_F9 = 41 , WKC_F10 = 42 ,
  WKC_F11 = 43 , WKC_F12 = 44 , WKC_BACKQUOTE = 45 , WKC_PAUSE = 46 ,
  WKC_NUM_DIV = 138 , WKC_NUM_MUL = 139 , WKC_NUM_MINUS = 140 , WKC_NUM_PLUS = 141 ,
  WKC_NUM_ENTER = 142 , WKC_NUM_DECIMAL = 143 , WKC_SLASH = 144 , WKC_SEMICOLON = 145 ,
  WKC_EQUALS = 146 , WKC_L_BRACKET = 147 , WKC_BACKSLASH = 148 , WKC_R_BRACKET = 149 ,
  WKC_SINGLEQUOTE = 150 , WKC_COMMA = 151 , WKC_PERIOD = 152 , WKC_MINUS = 153
}
enum class  FontSize : uint8_t {
  Normal , Small , Large , Monospace ,
  End , Begin = FontSize::Normal
}
 Available font sizes. More...
enum class  Colours : uint8_t {
  Begin , DarkBlue = Colours::Begin , PaleGreen , Pink ,
  Yellow , Red , LightBlue , Green ,
  DarkGreen , Blue , Cream , Mauve ,
  Purple , Orange , Brown , Grey ,
  White , End , Invalid = 0xFF
}
 One of 16 base colours used for companies and windows/widgets. More...
enum  TextColour : uint16_t {
  TC_BEGIN = 0x00 , TC_FROMSTRING = 0x00 , TC_BLUE = 0x00 , TC_SILVER = 0x01 ,
  TC_GOLD = 0x02 , TC_RED = 0x03 , TC_PURPLE = 0x04 , TC_LIGHT_BROWN = 0x05 ,
  TC_ORANGE = 0x06 , TC_GREEN = 0x07 , TC_YELLOW = 0x08 , TC_DARK_GREEN = 0x09 ,
  TC_CREAM = 0x0A , TC_BROWN = 0x0B , TC_WHITE = 0x0C , TC_LIGHT_BLUE = 0x0D ,
  TC_GREY = 0x0E , TC_DARK_BLUE = 0x0F , TC_BLACK = 0x10 , TC_END ,
  TC_INVALID = 0xFF , TC_IS_PALETTE_COLOUR = 0x100 , TC_NO_SHADE = 0x200 , TC_FORCED = 0x400 ,
  TC_COLOUR_MASK = 0xFF , TC_FLAGS_MASK = 0x700
}
 Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palette.png. More...
enum  FillRectMode : uint8_t { FILLRECT_OPAQUE , FILLRECT_CHECKER , FILLRECT_RECOLOUR }
 Define the operation GfxFillRect performs. More...
enum  PaletteType : uint8_t { DOS , Windows }
 Palettes OpenTTD supports. More...
enum class  SpriteType : uint8_t {
  Normal = 0 , MapGen = 1 , Font = 2 , Recolour = 3 ,
  Invalid = 4
}
 Types of sprites that might be loaded. More...
enum  Support8bpp : uint8_t { S8BPP_NONE = 0 , S8BPP_SYSTEM , S8BPP_HARDWARE }
 Modes for 8bpp support. More...
enum  StringAlignment : uint8_t {
  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

std::string_view FontSizeToName (FontSize fs)

Variables

constexpr FontSizes FONTSIZES_ALL {FontSize::Normal, FontSize::Small, FontSize::Large, FontSize::Monospace}
 Mask of all possible font sizes.
constexpr FontSizes FONTSIZES_REQUIRED {FontSize::Normal, FontSize::Small, FontSize::Large}
 Mask of font sizes required to be present.
static constexpr uint8_t PALETTE_ANIM_SIZE = 28
 number of animated colours
static constexpr uint8_t PALETTE_ANIM_START = 227
 Index in the _palettes array from which all animations are taking places (table/palettes.h).
static const uint MILLISECONDS_PER_TICK = 27
 The number of milliseconds per game tick.

Detailed Description

Types related to the graphics and/or input devices.

Definition in file gfx_type.h.

Typedef Documentation

◆ Colour

using Colour = std::conditional_t<std::endian::native == std::endian::little, ColourBGRA, ColourARGB>

Definition at line 242 of file gfx_type.h.

◆ CursorID

typedef uint32_t CursorID

The number of the cursor (sprite).

Definition at line 19 of file gfx_type.h.

◆ FontSizes

using FontSizes = EnumBitSet<FontSize, uint8_t>

Definition at line 259 of file gfx_type.h.

◆ PaletteID

typedef uint32_t PaletteID

The number of the palette.

Definition at line 18 of file gfx_type.h.

◆ SpriteID

typedef uint32_t SpriteID

The number of a sprite, without mapping bits and colourtables.

Definition at line 17 of file gfx_type.h.

Enumeration Type Documentation

◆ Colours

enum class Colours : uint8_t
strong

One of 16 base colours used for companies and windows/widgets.

Enumerator
Begin 

Begin marker.

DarkBlue 

Dark blue.

PaleGreen 

Pale green.

Pink 

Pink.

Yellow 

Yellow.

Red 

Red.

LightBlue 

Light blue.

Green 

Green.

DarkGreen 

Dark green.

Blue 

Blue.

Cream 

Cream.

Mauve 

Mauve.

Purple 

Purple.

Orange 

Orange.

Brown 

Brown.

Grey 

Grey.

White 

White.

End 

End-of-array marker.

Invalid 

Invalid marker.

Definition at line 283 of file gfx_type.h.

◆ FillRectMode

enum FillRectMode : uint8_t

Define the operation GfxFillRect performs.

Enumerator
FILLRECT_OPAQUE 

Fill rectangle with a single colour.

FILLRECT_CHECKER 

Draw only every second pixel, used for greying-out.

FILLRECT_RECOLOUR 

Apply a recolour sprite to the screen content.

Definition at line 344 of file gfx_type.h.

◆ FontSize

enum class FontSize : uint8_t
strong

Available font sizes.

Enumerator
Normal 

Index of the normal font in the font tables.

Small 

Index of the small font in the font tables.

Large 

Index of the large font in the font tables.

Monospace 

Index of the monospaced font in the font tables.

End 

Marker for the end of the enumerations.

Begin 

Marker for the first font in the enumeration.

Definition at line 248 of file gfx_type.h.

◆ PaletteType

enum PaletteType : uint8_t

Palettes OpenTTD supports.

Enumerator
DOS 

Use the DOS palette.

Windows 

Use the Windows palette.

Definition at line 351 of file gfx_type.h.

◆ SpriteType

enum class SpriteType : uint8_t
strong

Types of sprites that might be loaded.

Enumerator
Normal 

The most basic (normal) sprite.

MapGen 

Special sprite for the map generator.

Font 

A sprite used for fonts.

Recolour 

Recolour sprite.

Invalid 

Pseudosprite or other unusable sprite, used only internally.

Definition at line 357 of file gfx_type.h.

◆ StringAlignment

enum StringAlignment : uint8_t

How to align the to-be drawn text.

Enumerator
SA_LEFT 

Left align the text.

SA_HOR_CENTER 

Horizontally center the text.

SA_RIGHT 

Right align the text (must be a single bit).

SA_HOR_MASK 

Mask for horizontal alignment.

SA_TOP 

Top align the text.

SA_VERT_CENTER 

Vertically center the text.

SA_BOTTOM 

Bottom align the text.

SA_VERT_MASK 

Mask for vertical alignment.

SA_CENTER 

Center both horizontally and vertically.

SA_FORCE 

Force the alignment, i.e. don't swap for RTL languages.

Definition at line 387 of file gfx_type.h.

◆ Support8bpp

enum Support8bpp : uint8_t

Modes for 8bpp support.

Enumerator
S8BPP_NONE 

No support for 8bpp by OS or hardware, force 32bpp blitters.

S8BPP_SYSTEM 

No 8bpp support by hardware, do not try to use 8bpp video modes or hardware palettes.

S8BPP_HARDWARE 

Full 8bpp support by OS and hardware.

Definition at line 380 of file gfx_type.h.

◆ TextColour

enum TextColour : uint16_t

Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palette.png.

Enumerator
TC_IS_PALETTE_COLOUR 

Colour value is already a real palette colour index, not an index of a StringColour.

TC_NO_SHADE 

Do not add shading to this text colour.

TC_FORCED 

Ignore colour changes from strings.

TC_COLOUR_MASK 

Mask to test if TextColour (without flags) is within limits.

TC_FLAGS_MASK 

Mask to test if TextColour (with flags) is within limits.

Definition at line 307 of file gfx_type.h.

◆ WindowKeyCodes

enum WindowKeyCodes : uint16_t
Enumerator
WKC_GLOBAL_HOTKEY 

Fake keycode bit to indicate global hotkeys.

WKC_SLASH 

/ Forward slash

WKC_SEMICOLON 

; Semicolon

WKC_EQUALS 

= Equals

WKC_L_BRACKET 

[ Left square bracket

WKC_BACKSLASH 

\ Backslash

WKC_R_BRACKET 

] Right square bracket

WKC_SINGLEQUOTE 

' Single quote

WKC_COMMA 

, Comma

WKC_PERIOD 

. Period

WKC_MINUS 
  • Minus

Definition at line 29 of file gfx_type.h.

Function Documentation

◆ FontSizeToName()

std::string_view FontSizeToName ( FontSize fs)
inline

Definition at line 266 of file gfx_type.h.

Variable Documentation

◆ FONTSIZES_ALL

FontSizes FONTSIZES_ALL {FontSize::Normal, FontSize::Small, FontSize::Large, FontSize::Monospace}
constexpr

Mask of all possible font sizes.

Definition at line 262 of file gfx_type.h.

Referenced by AdjustGUIZoom(), CheckBlitter(), GfxLoadSprites(), and GameOptionsWindow::OnClick().

◆ FONTSIZES_REQUIRED

FontSizes FONTSIZES_REQUIRED {FontSize::Normal, FontSize::Small, FontSize::Large}
constexpr

Mask of font sizes required to be present.

Definition at line 264 of file gfx_type.h.

Referenced by LanguagePackGlyphSearcher::LanguagePackGlyphSearcher(), and openttd_main().

◆ MILLISECONDS_PER_TICK

const uint MILLISECONDS_PER_TICK = 27
static

The number of milliseconds per game tick.

The value 27 together with a day length of 74 ticks makes one day 1998 milliseconds, almost exactly 2 seconds. With a 2 second day, one standard month is 1 minute, and one standard year is slightly over 12 minutes.

Definition at line 370 of file gfx_type.h.

Referenced by ClientNetworkGameSocketHandler::CloseConnection(), and NetworkServer_Tick().

◆ PALETTE_ANIM_SIZE

uint8_t PALETTE_ANIM_SIZE = 28
staticconstexpr

number of animated colours

Definition at line 340 of file gfx_type.h.

◆ PALETTE_ANIM_START

uint8_t PALETTE_ANIM_START = 227
staticconstexpr

Index in the _palettes array from which all animations are taking places (table/palettes.h).

Definition at line 341 of file gfx_type.h.

Referenced by Blitter_32bppAnim::CopyFromBuffer(), and Blitter_32bppAnim::PaletteAnimate().