mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
Use named casts on openrct2-ui root folder (#11137)
This commit is contained in:
@@ -92,7 +92,7 @@ SDL_Cursor* CursorRepository::Create(const CursorData* cursorInfo, uint8_t scale
|
||||
{
|
||||
SDL_Cursor* cursor;
|
||||
|
||||
auto integer_scale = (int)round(scale);
|
||||
auto integer_scale = static_cast<int>(round(scale));
|
||||
|
||||
auto data = scaleDataArray(cursorInfo->Data, CURSOR_BIT_WIDTH, CURSOR_HEIGHT, static_cast<size_t>(integer_scale));
|
||||
auto mask = scaleDataArray(cursorInfo->Mask, CURSOR_BIT_WIDTH, CURSOR_HEIGHT, static_cast<size_t>(integer_scale));
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace OpenRCT2::Ui
|
||||
void* processHandle = dlopen(nullptr, RTLD_NOW);
|
||||
if (processHandle != nullptr)
|
||||
{
|
||||
dummy* p = ((dummy*)processHandle)->ptr;
|
||||
lmap* pl = (lmap*)p->ptr;
|
||||
dummy* p = (static_cast<dummy*>(processHandle))->ptr;
|
||||
lmap* pl = reinterpret_cast<lmap*>(p->ptr);
|
||||
while (pl != nullptr)
|
||||
{
|
||||
if (strstr(pl->path, "gameoverlayrenderer.so") != nullptr)
|
||||
@@ -357,7 +357,7 @@ namespace OpenRCT2::Ui
|
||||
}
|
||||
else if (isalpha(c))
|
||||
{
|
||||
filtersb << '[' << (char)tolower(c) << (char)toupper(c) << ']';
|
||||
filtersb << '[' << static_cast<char>(tolower(c)) << static_cast<char>(toupper(c)) << ']';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace OpenRCT2::Ui
|
||||
HWND hwnd = GetHWND(window);
|
||||
if (hwnd != nullptr)
|
||||
{
|
||||
SendMessageA(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon);
|
||||
SendMessageA(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icon));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ namespace OpenRCT2::Ui
|
||||
openFileName.lpstrInitialDir = wcInitialDirectory.c_str();
|
||||
openFileName.lpstrFilter = wcFilters.c_str();
|
||||
openFileName.lpstrFile = &wcFilename[0];
|
||||
openFileName.nMaxFile = (DWORD)wcFilename.size();
|
||||
openFileName.nMaxFile = static_cast<DWORD>(wcFilename.size());
|
||||
|
||||
// Open dialog
|
||||
BOOL dialogResult = FALSE;
|
||||
@@ -141,7 +141,7 @@ namespace OpenRCT2::Ui
|
||||
int32_t filterIndex = openFileName.nFilterIndex - 1;
|
||||
|
||||
assert(filterIndex >= 0);
|
||||
assert(filterIndex < (int32_t)desc.Filters.size());
|
||||
assert(filterIndex < static_cast<int32_t>(desc.Filters.size()));
|
||||
|
||||
std::string pattern = desc.Filters[filterIndex].Pattern;
|
||||
std::string patternExtension = Path::GetExtension(pattern);
|
||||
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
void SetFullscreenMode(FULLSCREEN_MODE mode) override
|
||||
{
|
||||
static constexpr const int32_t SDLFSFlags[] = { 0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP };
|
||||
uint32_t windowFlags = SDLFSFlags[(int32_t)mode];
|
||||
uint32_t windowFlags = SDLFSFlags[static_cast<int32_t>(mode)];
|
||||
|
||||
// HACK Changing window size when in fullscreen usually has no effect
|
||||
if (mode == FULLSCREEN_MODE::FULLSCREEN)
|
||||
@@ -499,7 +499,7 @@ public:
|
||||
|
||||
// Zoom gesture
|
||||
constexpr int32_t tolerance = 128;
|
||||
int32_t gesturePixels = (int32_t)(_gestureRadius * _width);
|
||||
int32_t gesturePixels = static_cast<int32_t>(_gestureRadius * _width);
|
||||
if (abs(gesturePixels) > tolerance)
|
||||
{
|
||||
_gestureRadius = 0;
|
||||
@@ -661,7 +661,7 @@ private:
|
||||
OnResize(width, height);
|
||||
|
||||
UpdateFullscreenResolutions();
|
||||
SetFullscreenMode((FULLSCREEN_MODE)gConfigGeneral.fullscreen_mode);
|
||||
SetFullscreenMode(static_cast<FULLSCREEN_MODE>(gConfigGeneral.fullscreen_mode));
|
||||
|
||||
TriggerResize();
|
||||
}
|
||||
@@ -669,8 +669,8 @@ private:
|
||||
void OnResize(int32_t width, int32_t height)
|
||||
{
|
||||
// Scale the native window size to the game's canvas size
|
||||
_width = (int32_t)(width / gConfigGeneral.window_scale);
|
||||
_height = (int32_t)(height / gConfigGeneral.window_scale);
|
||||
_width = static_cast<int32_t>(width / gConfigGeneral.window_scale);
|
||||
_height = static_cast<int32_t>(height / gConfigGeneral.window_scale);
|
||||
|
||||
drawing_engine_resize();
|
||||
|
||||
@@ -713,13 +713,13 @@ private:
|
||||
|
||||
// Get resolutions
|
||||
auto resolutions = std::vector<Resolution>();
|
||||
float desktopAspectRatio = (float)mode.w / mode.h;
|
||||
float desktopAspectRatio = static_cast<float>(mode.w) / mode.h;
|
||||
for (int32_t i = 0; i < numDisplayModes; i++)
|
||||
{
|
||||
SDL_GetDisplayMode(displayIndex, i, &mode);
|
||||
if (mode.w > 0 && mode.h > 0)
|
||||
{
|
||||
float aspectRatio = (float)mode.w / mode.h;
|
||||
float aspectRatio = static_cast<float>(mode.w) / mode.h;
|
||||
if (std::fabs(desktopAspectRatio - aspectRatio) < 0.1f)
|
||||
{
|
||||
resolutions.push_back({ mode.w, mode.h });
|
||||
|
||||
@@ -212,9 +212,9 @@ public:
|
||||
switch (intent->GetWindowClass())
|
||||
{
|
||||
case WC_PEEP:
|
||||
return window_guest_open((Peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP));
|
||||
return window_guest_open(static_cast<Peep*>(intent->GetPointerExtra(INTENT_EXTRA_PEEP)));
|
||||
case WC_FIRE_PROMPT:
|
||||
return window_staff_fire_prompt_open((Peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP));
|
||||
return window_staff_fire_prompt_open(static_cast<Peep*>(intent->GetPointerExtra(INTENT_EXTRA_PEEP)));
|
||||
case WC_INSTALL_TRACK:
|
||||
return window_install_track_open(intent->GetStringExtra(INTENT_EXTRA_PATH).c_str());
|
||||
case WC_GUEST_LIST:
|
||||
@@ -224,14 +224,16 @@ public:
|
||||
{
|
||||
uint32_t type = intent->GetUIntExtra(INTENT_EXTRA_LOADSAVE_TYPE);
|
||||
std::string defaultName = intent->GetStringExtra(INTENT_EXTRA_PATH);
|
||||
loadsave_callback callback = (loadsave_callback)intent->GetPointerExtra(INTENT_EXTRA_CALLBACK);
|
||||
loadsave_callback callback = reinterpret_cast<loadsave_callback>(
|
||||
intent->GetPointerExtra(INTENT_EXTRA_CALLBACK));
|
||||
TrackDesign* trackDesign = static_cast<TrackDesign*>(intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN));
|
||||
rct_window* w = window_loadsave_open(type, defaultName.c_str(), callback, trackDesign);
|
||||
|
||||
return w;
|
||||
}
|
||||
case WC_MANAGE_TRACK_DESIGN:
|
||||
return window_track_manage_open((track_design_file_ref*)intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN));
|
||||
return window_track_manage_open(
|
||||
static_cast<track_design_file_ref*>(intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN)));
|
||||
case WC_NETWORK_STATUS:
|
||||
{
|
||||
std::string message = intent->GetStringExtra(INTENT_EXTRA_MESSAGE);
|
||||
@@ -241,7 +243,7 @@ public:
|
||||
case WC_OBJECT_LOAD_ERROR:
|
||||
{
|
||||
std::string path = intent->GetStringExtra(INTENT_EXTRA_PATH);
|
||||
const rct_object_entry* objects = (rct_object_entry*)intent->GetPointerExtra(INTENT_EXTRA_LIST);
|
||||
const rct_object_entry* objects = static_cast<rct_object_entry*>(intent->GetPointerExtra(INTENT_EXTRA_LIST));
|
||||
size_t count = intent->GetUIntExtra(INTENT_EXTRA_LIST_COUNT);
|
||||
window_object_load_error_open(const_cast<utf8*>(path.c_str()), count, objects);
|
||||
|
||||
@@ -253,7 +255,8 @@ public:
|
||||
return ride == nullptr ? nullptr : window_ride_main_open(ride);
|
||||
}
|
||||
case WC_TRACK_DESIGN_PLACE:
|
||||
return window_track_place_open((track_design_file_ref*)intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN));
|
||||
return window_track_place_open(
|
||||
static_cast<track_design_file_ref*>(intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN)));
|
||||
case WC_TRACK_DESIGN_LIST:
|
||||
{
|
||||
ride_list_item rideItem;
|
||||
@@ -263,11 +266,11 @@ public:
|
||||
}
|
||||
case WC_SCENARIO_SELECT:
|
||||
return window_scenarioselect_open(
|
||||
(scenarioselect_callback)intent->GetPointerExtra(INTENT_EXTRA_CALLBACK), false);
|
||||
reinterpret_cast<scenarioselect_callback>(intent->GetPointerExtra(INTENT_EXTRA_CALLBACK)), false);
|
||||
case WD_VEHICLE:
|
||||
return window_ride_open_vehicle((Vehicle*)intent->GetPointerExtra(INTENT_EXTRA_VEHICLE));
|
||||
return window_ride_open_vehicle(static_cast<Vehicle*>(intent->GetPointerExtra(INTENT_EXTRA_VEHICLE)));
|
||||
case WD_TRACK:
|
||||
return window_ride_open_track((TileElement*)intent->GetPointerExtra(INTENT_EXTRA_TILE_ELEMENT));
|
||||
return window_ride_open_track(static_cast<TileElement*>(intent->GetPointerExtra(INTENT_EXTRA_TILE_ELEMENT)));
|
||||
case INTENT_ACTION_NEW_RIDE_OF_TYPE:
|
||||
{
|
||||
// Open ride list window
|
||||
|
||||
Reference in New Issue
Block a user