1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-28 17:24:47 +01:00

Use named casts on openrct2-ui/windows (#11136)

This commit is contained in:
Tulio Leao
2020-04-18 08:32:48 -03:00
committed by GitHub
parent b71062ce1b
commit 935cfe90fc
44 changed files with 326 additions and 298 deletions

View File

@@ -32,7 +32,7 @@ enum
};
static rct_widget window_dropdown_widgets[] = {
{ WWT_IMGBTN, 0, 0, 0, 0, 0, (uint32_t)SPR_NONE, STR_NONE },
{ WWT_IMGBTN, 0, 0, 0, 0, 0, static_cast<uint32_t>(SPR_NONE), STR_NONE },
{ WIDGETS_END },
};
@@ -54,7 +54,7 @@ int32_t gDropdownDefaultIndex;
bool dropdown_is_checked(int32_t index)
{
if (index < 0 || index >= (int32_t)std::size(_dropdownItemsDisabled))
if (index < 0 || index >= static_cast<int32_t>(std::size(_dropdownItemsDisabled)))
{
return false;
}
@@ -63,7 +63,7 @@ bool dropdown_is_checked(int32_t index)
bool dropdown_is_disabled(int32_t index)
{
if (index < 0 || index >= (int32_t)std::size(_dropdownItemsDisabled))
if (index < 0 || index >= static_cast<int32_t>(std::size(_dropdownItemsDisabled)))
{
return true;
}
@@ -72,7 +72,7 @@ bool dropdown_is_disabled(int32_t index)
void dropdown_set_checked(int32_t index, bool value)
{
if (index < 0 || index >= (int32_t)std::size(_dropdownItemsDisabled))
if (index < 0 || index >= static_cast<int32_t>(std::size(_dropdownItemsDisabled)))
{
return;
}
@@ -81,7 +81,7 @@ void dropdown_set_checked(int32_t index, bool value)
void dropdown_set_disabled(int32_t index, bool value)
{
if (index < 0 || index >= (int32_t)std::size(_dropdownItemsDisabled))
if (index < 0 || index >= static_cast<int32_t>(std::size(_dropdownItemsDisabled)))
{
return;
}
@@ -143,7 +143,7 @@ void window_dropdown_show_text(int32_t x, int32_t y, int32_t extray, uint8_t col
max_string_width = 0;
for (size_t i = 0; i < num_items; i++)
{
format_string(buffer, 256, gDropdownItemsFormat[i], (void*)(&gDropdownItemsArgs[i]));
format_string(buffer, 256, gDropdownItemsFormat[i], static_cast<void*>(&gDropdownItemsArgs[i]));
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
string_width = gfx_get_string_width(buffer);
max_string_width = std::max(string_width, max_string_width);
@@ -178,7 +178,7 @@ void window_dropdown_show_text_custom_width(
// Set and calculate num items, rows and columns
_dropdown_item_width = width;
_dropdown_item_height = (flags & DROPDOWN_FLAG_CUSTOM_HEIGHT) ? custom_height : DROPDOWN_ITEM_HEIGHT;
gDropdownNumItems = (int32_t)num_items;
gDropdownNumItems = static_cast<int32_t>(num_items);
// There must always be at least one column to prevent dividing by zero
if (gDropdownNumItems == 0)
{
@@ -365,7 +365,7 @@ static void window_dropdown_paint(rct_window* w, rct_drawpixelinfo* dpi)
if (item == DROPDOWN_FORMAT_LAND_PICKER || item == DROPDOWN_FORMAT_COLOUR_PICKER)
{
// Image item
image = (uint32_t)gDropdownItemsArgs[i];
image = static_cast<uint32_t>(gDropdownItemsArgs[i]);
if (item == DROPDOWN_FORMAT_COLOUR_PICKER && highlightedIndex == i)
image++;
@@ -394,8 +394,9 @@ static void window_dropdown_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Draw item string
gfx_draw_string_left_clipped(
dpi, item, (void*)(&gDropdownItemsArgs[i]), colour, w->windowPos.x + 2 + (cell_x * _dropdown_item_width),
w->windowPos.y + 2 + (cell_y * _dropdown_item_height), w->width - 5);
dpi, item, static_cast<void*>(&gDropdownItemsArgs[i]), colour,
w->windowPos.x + 2 + (cell_x * _dropdown_item_width), w->windowPos.y + 2 + (cell_y * _dropdown_item_height),
w->width - 5);
}
}
}