Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
This commit is contained in:
34
src/gfx.cpp
34
src/gfx.cpp
@@ -38,7 +38,7 @@ byte _support8bpp;
|
||||
CursorVars _cursor;
|
||||
bool _ctrl_pressed; ///< Is Ctrl pressed?
|
||||
bool _shift_pressed; ///< Is Shift pressed?
|
||||
uint16 _game_speed = 100; ///< Current game-speed; 100 is 1x, 0 is infinite.
|
||||
uint16_t _game_speed = 100; ///< Current game-speed; 100 is 1x, 0 is infinite.
|
||||
bool _left_button_down; ///< Is left mouse button pressed?
|
||||
bool _left_button_clicked; ///< Is left mouse button clicked?
|
||||
bool _right_button_down; ///< Is right mouse button pressed?
|
||||
@@ -61,7 +61,7 @@ static std::recursive_mutex _palette_mutex; ///< To coordinate access to _cur_pa
|
||||
static void GfxMainBlitterViewport(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE);
|
||||
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE, ZoomLevel zoom = ZOOM_LVL_NORMAL);
|
||||
|
||||
static ReusableBuffer<uint8> _cursor_backup;
|
||||
static ReusableBuffer<uint8_t> _cursor_backup;
|
||||
|
||||
ZoomLevel _gui_zoom = ZOOM_LVL_OUT_4X; ///< GUI Zoom level
|
||||
ZoomLevel _font_zoom = _gui_zoom; ///< Sprite font Zoom level (not clamped)
|
||||
@@ -145,7 +145,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectM
|
||||
|
||||
switch (mode) {
|
||||
default: // FILLRECT_OPAQUE
|
||||
blitter->DrawRect(dst, right, bottom, (uint8)colour);
|
||||
blitter->DrawRect(dst, right, bottom, (uint8_t)colour);
|
||||
break;
|
||||
|
||||
case FILLRECT_RECOLOUR:
|
||||
@@ -155,7 +155,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectM
|
||||
case FILLRECT_CHECKER: {
|
||||
byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
|
||||
do {
|
||||
for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)colour);
|
||||
for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8_t)colour);
|
||||
dst = blitter->MoveTo(dst, 0, 1);
|
||||
} while (--bottom > 0);
|
||||
break;
|
||||
@@ -281,7 +281,7 @@ void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mo
|
||||
void *dst = blitter->MoveTo(dpi->dst_ptr, x1, y);
|
||||
switch (mode) {
|
||||
default: // FILLRECT_OPAQUE
|
||||
blitter->DrawRect(dst, x2 - x1, 1, (uint8)colour);
|
||||
blitter->DrawRect(dst, x2 - x1, 1, (uint8_t)colour);
|
||||
break;
|
||||
case FILLRECT_RECOLOUR:
|
||||
blitter->DrawColourMappingRect(dst, x2 - x1, 1, GB(colour, 0, PALETTE_WIDTH));
|
||||
@@ -290,7 +290,7 @@ void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mo
|
||||
/* Fill every other pixel, offset such that the sum of filled pixels' X and Y coordinates is odd.
|
||||
* This creates a checkerboard effect. */
|
||||
for (int x = (x1 + y) & 1; x < x2 - x1; x += 2) {
|
||||
blitter->SetPixel(dst, x, 0, (uint8)colour);
|
||||
blitter->SetPixel(dst, x, 0, (uint8_t)colour);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mo
|
||||
* @param width Width of the line.
|
||||
* @param dash Length of dashes for dashed lines. 0 means solid line.
|
||||
*/
|
||||
static inline void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash = 0)
|
||||
static inline void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash = 0)
|
||||
{
|
||||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||
|
||||
@@ -909,7 +909,7 @@ ptrdiff_t GetCharAtPosition(std::string_view str, int x, FontSize start_fontsize
|
||||
* @param 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
|
||||
*/
|
||||
void DrawCharCentered(WChar c, const Rect &r, TextColour colour)
|
||||
void DrawCharCentered(char32_t c, const Rect &r, TextColour colour)
|
||||
{
|
||||
SetColourRemap(colour);
|
||||
GfxMainBlitter(GetGlyph(FS_NORMAL, c),
|
||||
@@ -1146,7 +1146,7 @@ static void GfxBlitter(const Sprite * const sprite, int x, int y, BlitterMode mo
|
||||
* @param zoom The zoom level at which to draw the sprites.
|
||||
* @return Pixel buffer, or nullptr if an 8bpp blitter is being used.
|
||||
*/
|
||||
std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom)
|
||||
std::unique_ptr<uint32_t[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom)
|
||||
{
|
||||
/* Invalid zoom level requested? */
|
||||
if (zoom < _settings_client.gui.zoom_min || zoom > _settings_client.gui.zoom_max) return nullptr;
|
||||
@@ -1159,7 +1159,7 @@ std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zo
|
||||
const Sprite *sprite = GetSprite(real_sprite, SpriteType::Normal);
|
||||
Dimension dim = GetSpriteSize(real_sprite, nullptr, zoom);
|
||||
size_t dim_size = static_cast<size_t>(dim.width) * dim.height;
|
||||
std::unique_ptr<uint32[]> result(new uint32[dim_size]);
|
||||
std::unique_ptr<uint32_t[]> result(new uint32_t[dim_size]);
|
||||
/* Set buffer to fully transparent. */
|
||||
MemSetT(result.get(), 0, dim_size);
|
||||
|
||||
@@ -1192,7 +1192,7 @@ std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zo
|
||||
|
||||
if (blitter->GetScreenDepth() == 8) {
|
||||
/* Resolve palette. */
|
||||
uint32 *dst = result.get();
|
||||
uint32_t *dst = result.get();
|
||||
const byte *src = pal_buffer.get();
|
||||
for (size_t i = 0; i < dim_size; ++i) {
|
||||
*dst++ = _cur_palette.palette[*src++].data;
|
||||
@@ -1247,8 +1247,8 @@ bool CopyPalette(Palette &local_palette, bool force_copy)
|
||||
return true;
|
||||
}
|
||||
|
||||
#define EXTR(p, q) (((uint16)(palette_animation_counter * (p)) * (q)) >> 16)
|
||||
#define EXTR2(p, q) (((uint16)(~palette_animation_counter * (p)) * (q)) >> 16)
|
||||
#define EXTR(p, q) (((uint16_t)(palette_animation_counter * (p)) * (q)) >> 16)
|
||||
#define EXTR2(p, q) (((uint16_t)(~palette_animation_counter * (p)) * (q)) >> 16)
|
||||
|
||||
void DoPaletteAnimations()
|
||||
{
|
||||
@@ -1367,7 +1367,7 @@ void DoPaletteAnimations()
|
||||
* @param threshold Background colour brightness threshold below which the background is considered dark and TC_WHITE is returned, range: 0 - 255, default 128.
|
||||
* @return TC_BLACK or TC_WHITE depending on what gives a better contrast.
|
||||
*/
|
||||
TextColour GetContrastColour(uint8 background, uint8 threshold)
|
||||
TextColour GetContrastColour(uint8_t background, uint8_t threshold)
|
||||
{
|
||||
Colour c = _cur_palette.palette[background];
|
||||
/* Compute brightness according to http://www.w3.org/TR/AERT#color-contrast.
|
||||
@@ -1400,7 +1400,7 @@ void LoadStringWidthTable(bool monospace)
|
||||
* @param key Character code glyph
|
||||
* @return Width of the character glyph
|
||||
*/
|
||||
byte GetCharacterWidth(FontSize size, WChar key)
|
||||
byte GetCharacterWidth(FontSize size, char32_t key)
|
||||
{
|
||||
/* Use _stringwidth_table cache if possible */
|
||||
if (key >= 32 && key < 256) return _stringwidth_table[size][key - 32];
|
||||
@@ -1517,7 +1517,7 @@ void DrawMouseCursor()
|
||||
_cursor.draw_size.x = width;
|
||||
_cursor.draw_size.y = height;
|
||||
|
||||
uint8 *buffer = _cursor_backup.Allocate(blitter->BufferSize(_cursor.draw_size.x, _cursor.draw_size.y));
|
||||
uint8_t *buffer = _cursor_backup.Allocate(blitter->BufferSize(_cursor.draw_size.x, _cursor.draw_size.y));
|
||||
|
||||
/* Make backup of stuff below cursor */
|
||||
blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, _cursor.draw_pos.x, _cursor.draw_pos.y), buffer, _cursor.draw_size.x, _cursor.draw_size.y);
|
||||
@@ -1946,7 +1946,7 @@ void UpdateGUIZoom()
|
||||
_gui_scale = Clamp(_gui_scale_cfg, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE);
|
||||
}
|
||||
|
||||
int8 new_zoom = ScaleGUITrad(1) <= 1 ? ZOOM_LVL_OUT_4X : ScaleGUITrad(1) >= 4 ? ZOOM_LVL_MIN : ZOOM_LVL_OUT_2X;
|
||||
int8_t new_zoom = ScaleGUITrad(1) <= 1 ? ZOOM_LVL_OUT_4X : ScaleGUITrad(1) >= 4 ? ZOOM_LVL_MIN : ZOOM_LVL_OUT_2X;
|
||||
/* Font glyphs should not be clamped to min/max zoom. */
|
||||
_font_zoom = static_cast<ZoomLevel>(new_zoom);
|
||||
/* Ensure the gui_zoom is clamped between min/max. */
|
||||
|
Reference in New Issue
Block a user