Update to 14.0-beta1
This commit is contained in:
130
src/gfx_func.h
130
src/gfx_func.h
@@ -54,7 +54,7 @@ extern byte _support8bpp;
|
||||
extern CursorVars _cursor;
|
||||
extern bool _ctrl_pressed; ///< Is Ctrl pressed?
|
||||
extern bool _shift_pressed; ///< Is Shift pressed?
|
||||
extern uint16 _game_speed;
|
||||
extern uint16_t _game_speed;
|
||||
|
||||
extern bool _left_button_down;
|
||||
extern bool _left_button_clicked;
|
||||
@@ -69,7 +69,7 @@ extern Dimension _cur_resolution;
|
||||
extern Palette _cur_palette; ///< Current palette
|
||||
|
||||
void HandleToolbarHotkey(int hotkey);
|
||||
void HandleKeypress(uint keycode, WChar key);
|
||||
void HandleKeypress(uint keycode, char32_t key);
|
||||
void HandleTextInput(const char *str, bool marked = false, const char *caret = nullptr, const char *insert_location = nullptr, const char *replacement_end = nullptr);
|
||||
void HandleCtrlChanged();
|
||||
void HandleMouseEvents();
|
||||
@@ -82,9 +82,6 @@ void GameSizeChanged();
|
||||
bool AdjustGUIZoom(bool automatic);
|
||||
void UndrawMouseCursor();
|
||||
|
||||
/** Size of the buffer used for drawing strings. */
|
||||
static const int DRAW_STRING_BUFFER = 2048;
|
||||
|
||||
void RedrawScreenRect(int left, int top, int right, int bottom);
|
||||
void GfxScroll(int left, int top, int width, int height, int xo, int yo);
|
||||
|
||||
@@ -92,82 +89,73 @@ Dimension GetSpriteSize(SpriteID sprid, Point *offset = nullptr, ZoomLevel zoom
|
||||
Dimension GetScaledSpriteSize(SpriteID sprid); /* widget.cpp */
|
||||
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr);
|
||||
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||
void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, bool clicked, StringAlignment align); /* widget.cpp */
|
||||
std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||
void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, StringAlignment align); /* widget.cpp */
|
||||
std::unique_ptr<uint32_t[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||
|
||||
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);
|
||||
int DrawString(int left, int right, int top, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
|
||||
int DrawString(int left, int right, int top, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
|
||||
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);
|
||||
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);
|
||||
int DrawStringMultiLine(int left, int right, int top, int bottom, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
|
||||
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
|
||||
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);
|
||||
|
||||
void DrawCharCentered(WChar c, const Rect &r, TextColour colour);
|
||||
void DrawCharCentered(char32_t c, const Rect &r, TextColour colour);
|
||||
|
||||
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE);
|
||||
void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode = FILLRECT_OPAQUE);
|
||||
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);
|
||||
void DrawRectOutline(const Rect &r, int colour, int width = 1, int dash = 0);
|
||||
|
||||
/* Versions of DrawString/DrawStringMultiLine that accept a Rect instead of separate left, right, top and bottom parameters. */
|
||||
static inline int DrawString(const Rect &r, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
inline int DrawString(const Rect &r, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
{
|
||||
return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
|
||||
}
|
||||
|
||||
static inline int DrawString(const Rect &r, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
inline int DrawString(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
{
|
||||
return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
|
||||
}
|
||||
|
||||
static inline int DrawString(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
{
|
||||
return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
|
||||
}
|
||||
|
||||
static inline int DrawStringMultiLine(const Rect &r, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
inline int DrawStringMultiLine(const Rect &r, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
{
|
||||
return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
|
||||
}
|
||||
|
||||
static inline int DrawStringMultiLine(const Rect &r, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
inline int DrawStringMultiLine(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
{
|
||||
return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
|
||||
}
|
||||
|
||||
static inline int DrawStringMultiLine(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
|
||||
{
|
||||
return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
|
||||
}
|
||||
|
||||
static inline void GfxFillRect(const Rect &r, int colour, FillRectMode mode = FILLRECT_OPAQUE)
|
||||
inline void GfxFillRect(const Rect &r, int colour, FillRectMode mode = FILLRECT_OPAQUE)
|
||||
{
|
||||
GfxFillRect(r.left, r.top, r.right, r.bottom, colour, mode);
|
||||
}
|
||||
|
||||
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize = FS_NORMAL);
|
||||
Dimension GetStringBoundingBox(const std::string &str, FontSize start_fontsize = FS_NORMAL);
|
||||
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize = FS_NORMAL);
|
||||
Dimension GetStringBoundingBox(StringID strid, FontSize start_fontsize = FS_NORMAL);
|
||||
uint GetStringListWidth(const StringID *list, FontSize fontsize = FS_NORMAL);
|
||||
int GetStringHeight(const char *str, int maxw, FontSize fontsize = FS_NORMAL);
|
||||
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize = FS_NORMAL);
|
||||
int GetStringHeight(StringID str, int maxw);
|
||||
int GetStringLineCount(StringID str, int maxw);
|
||||
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion);
|
||||
Dimension GetStringMultiLineBoundingBox(const char *str, const Dimension &suggestion);
|
||||
Dimension GetStringMultiLineBoundingBox(std::string_view str, const Dimension &suggestion);
|
||||
void LoadStringWidthTable(bool monospace = false);
|
||||
Point GetCharPosInString(const char *str, const char *ch, FontSize start_fontsize = FS_NORMAL);
|
||||
const char *GetCharAtPosition(const char *str, int x, FontSize start_fontsize = FS_NORMAL);
|
||||
Point GetCharPosInString(std::string_view str, const char *ch, FontSize start_fontsize = FS_NORMAL);
|
||||
ptrdiff_t GetCharAtPosition(std::string_view str, int x, FontSize start_fontsize = FS_NORMAL);
|
||||
|
||||
void DrawDirtyBlocks();
|
||||
void AddDirtyBlock(int left, int top, int right, int bottom);
|
||||
void MarkWholeScreenDirty();
|
||||
|
||||
bool CopyPalette(Palette &local_palette, bool force_copy = false);
|
||||
void GfxInitPalettes();
|
||||
void CheckBlitter();
|
||||
|
||||
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height);
|
||||
|
||||
inline bool FillDrawPixelInfo(DrawPixelInfo *n, const Rect &r)
|
||||
{
|
||||
return FillDrawPixelInfo(n, r.left, r.top, r.Width(), r.Height());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine where to draw a centred object inside a widget.
|
||||
* @param min The top or left coordinate.
|
||||
@@ -175,7 +163,7 @@ bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int heigh
|
||||
* @param size The height or width of the object to draw.
|
||||
* @return Offset of where to start drawing the object.
|
||||
*/
|
||||
static inline int CenterBounds(int min, int max, int size)
|
||||
inline int CenterBounds(int min, int max, int size)
|
||||
{
|
||||
return (min + max - size + 1) / 2;
|
||||
}
|
||||
@@ -193,80 +181,12 @@ void SortResolutions();
|
||||
bool ToggleFullScreen(bool fs);
|
||||
|
||||
/* gfx.cpp */
|
||||
byte GetCharacterWidth(FontSize size, WChar key);
|
||||
byte GetCharacterWidth(FontSize size, char32_t key);
|
||||
byte GetDigitWidth(FontSize size = FS_NORMAL);
|
||||
void GetBroadestDigit(uint *front, uint *next, FontSize size = FS_NORMAL);
|
||||
|
||||
int GetCharacterHeight(FontSize size);
|
||||
|
||||
/** Height of characters in the small (#FS_SMALL) font. @note Some characters may be oversized. */
|
||||
#define FONT_HEIGHT_SMALL (GetCharacterHeight(FS_SMALL))
|
||||
|
||||
/** Height of characters in the normal (#FS_NORMAL) font. @note Some characters may be oversized. */
|
||||
#define FONT_HEIGHT_NORMAL (GetCharacterHeight(FS_NORMAL))
|
||||
|
||||
/** Height of characters in the large (#FS_LARGE) font. @note Some characters may be oversized. */
|
||||
#define FONT_HEIGHT_LARGE (GetCharacterHeight(FS_LARGE))
|
||||
|
||||
/** Height of characters in the large (#FS_MONO) font. @note Some characters may be oversized. */
|
||||
#define FONT_HEIGHT_MONO (GetCharacterHeight(FS_MONO))
|
||||
|
||||
extern DrawPixelInfo *_cur_dpi;
|
||||
|
||||
/**
|
||||
* Checks if a Colours value is valid.
|
||||
*
|
||||
* @param colours The value to check
|
||||
* @return true if the given value is a valid Colours.
|
||||
*/
|
||||
static inline bool IsValidColours(Colours colours)
|
||||
{
|
||||
return colours < COLOUR_END;
|
||||
}
|
||||
|
||||
TextColour GetContrastColour(uint8 background, uint8 threshold = 128);
|
||||
|
||||
/**
|
||||
* All 16 colour gradients
|
||||
* 8 colours per gradient from darkest (0) to lightest (7)
|
||||
*/
|
||||
extern byte _colour_gradient[COLOUR_END][8];
|
||||
|
||||
/**
|
||||
* Return the colour for a particular greyscale level.
|
||||
* @param level Intensity, 0 = black, 15 = white
|
||||
* @return colour
|
||||
*/
|
||||
#define GREY_SCALE(level) (level)
|
||||
|
||||
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_RAINFOREST = 0x5C; ///< Pale green palette colour for rainforest.
|
||||
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.
|
||||
#endif /* GFX_FUNC_H */
|
||||
|
||||
Reference in New Issue
Block a user