From cf240632261d5ead70df89626ea380fb3c29047e Mon Sep 17 00:00:00 2001 From: Andrew Lanzone Date: Tue, 15 Jul 2025 01:33:52 -0700 Subject: [PATCH] Replace more C-style casts with C++ style --- apps/openmw/mwgui/countdialog.cpp | 4 ++-- apps/openmw/mwgui/itemview.cpp | 6 +++--- apps/openmw/mwgui/windowmanagerimp.cpp | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/countdialog.cpp b/apps/openmw/mwgui/countdialog.cpp index 063bf061c9..db34b082e0 100644 --- a/apps/openmw/mwgui/countdialog.cpp +++ b/apps/openmw/mwgui/countdialog.cpp @@ -59,7 +59,7 @@ namespace MWGui void CountDialog::setCount(int count) { - count = std::clamp(count, 1, (int)mSlider->getScrollRange()); + count = std::clamp(count, 1, static_cast(mSlider->getScrollRange())); mSlider->setScrollPosition(count - 1); mItemEdit->setValue(count); } @@ -105,7 +105,7 @@ namespace MWGui else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) setCount(1); else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) - setCount((int)mSlider->getScrollRange()); + setCount(static_cast(mSlider->getScrollRange())); else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT) MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false); else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) diff --git a/apps/openmw/mwgui/itemview.cpp b/apps/openmw/mwgui/itemview.cpp index 0afb3d3d76..a01eaad2e8 100644 --- a/apps/openmw/mwgui/itemview.cpp +++ b/apps/openmw/mwgui/itemview.cpp @@ -55,7 +55,7 @@ namespace MWGui mRows = std::max(maxHeight / 42, 1); mItemCount = dragArea->getChildCount(); - bool showScrollbar = int(std::ceil(mItemCount / float(mRows))) > mScrollView->getWidth() / 42; + bool showScrollbar = static_cast(std::ceil(mItemCount / float(mRows))) > mScrollView->getWidth() / 42; if (showScrollbar) { maxHeight -= 18; @@ -264,14 +264,14 @@ namespace MWGui if (prevFocus >= 0 && prevFocus < mItemCount) { - ItemWidget* prev = (ItemWidget*)dragArea->getChildAt(prevFocus); + ItemWidget* prev = static_cast(dragArea->getChildAt(prevFocus)); if (prev) prev->setControllerFocus(false); } if (mControllerActiveWindow && newFocus >= 0 && newFocus < mItemCount) { - ItemWidget* focused = (ItemWidget*)dragArea->getChildAt(newFocus); + ItemWidget* focused = static_cast(dragArea->getChildAt(newFocus)); if (focused) { focused->setControllerFocus(true); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index ee9df120c8..78ea13af35 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -899,7 +899,8 @@ namespace MWGui if (state.mWindows.size() == 0) return nullptr; - int activeIndex = std::clamp(mActiveControllerWindows[mode], 0, (int)state.mWindows.size() - 1); + int activeIndex + = std::clamp(mActiveControllerWindows[mode], 0, static_cast(state.mWindows.size()) - 1); // If the active window is no longer visible, find the next visible window. if (!state.mWindows[activeIndex]->isVisible())