diff --git a/apps/openmw/mwgui/controllerbuttonsoverlay.cpp b/apps/openmw/mwgui/controllerbuttonsoverlay.cpp index 065fb46d77..aee2ae2631 100644 --- a/apps/openmw/mwgui/controllerbuttonsoverlay.cpp +++ b/apps/openmw/mwgui/controllerbuttonsoverlay.cpp @@ -99,14 +99,23 @@ namespace MWGui void ControllerButtonsOverlay::setIcon(MyGUI::ImageBox* image, const std::string& imagePath) { - if (imagePath.length() > 0) + if (!imagePath.empty()) image->setImageTexture(imagePath); } int ControllerButtonsOverlay::updateButton( MyGUI::TextBox* text, MyGUI::ImageBox* image, const std::string& buttonStr) { - if (buttonStr.length() > 0) + if (buttonStr.empty()) + { + image->setVisible(false); + image->setUserString("Hidden", "true"); + + text->setVisible(false); + text->setUserString("Hidden", "true"); + return 0; + } + else { image->setVisible(true); image->setUserString("Hidden", "false"); @@ -117,14 +126,5 @@ namespace MWGui text->setSize(text->getTextSize().width + 16, 48); return 1; } - else - { - image->setVisible(false); - image->setUserString("Hidden", "true"); - - text->setVisible(false); - text->setUserString("Hidden", "true"); - return 0; - } } } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 0d694a6c4d..20fd6c9e3c 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -347,6 +347,10 @@ namespace MWGui // -------------------------------------------------------------------------------------------------- + + // Morrowind uses 3 px invisible borders for padding topics + static constexpr int sVerticalPadding = 3; + DialogueWindow::DialogueWindow() : WindowBase("openmw_dialogue_window.layout") , mIsCompanion(false) @@ -603,10 +607,9 @@ namespace MWGui void DialogueWindow::updateTopicsPane() { - const std::string focusedTopic - = Settings::gui().mControllerMenus && mControllerFocus < static_cast(mTopicsList->getItemCount()) - ? mTopicsList->getItemNameAt(mControllerFocus) - : ""; + std::string focusedTopic; + if (Settings::gui().mControllerMenus && mControllerFocus < static_cast(mTopicsList->getItemCount())) + focusedTopic = mTopicsList->getItemNameAt(mControllerFocus); mTopicsList->clear(); for (auto& linkPair : mTopicLinks) diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 90f1c3eaaf..6f03076e92 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -226,9 +226,6 @@ namespace MWGui MyGUI::IntSize mCurrentWindowSize; - // Morrowind uses 3 px invisible borders for padding topics - static const int sVerticalPadding = 3; - std::unique_ptr mCallback; std::unique_ptr mGreetingCallback; diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 0e8c67f8bd..642cfed05d 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -977,22 +977,22 @@ namespace MWGui case MWGui::GM_Companion: mControllerButtons.a = "#{OMWEngine:InventorySelect}"; mControllerButtons.b = "#{sClose}"; - mControllerButtons.x = ""; - mControllerButtons.y = ""; + mControllerButtons.x.clear(); + mControllerButtons.y.clear(); mControllerButtons.r2 = "#{sCompanionShare}"; break; case MWGui::GM_Container: mControllerButtons.a = "#{OMWEngine:InventorySelect}"; mControllerButtons.b = "#{sClose}"; mControllerButtons.x = "#{sTakeAll}"; - mControllerButtons.y = ""; + mControllerButtons.y.clear(); mControllerButtons.r2 = "#{sContainer}"; break; case MWGui::GM_Barter: mControllerButtons.a = "#{sSell}"; mControllerButtons.b = "#{sCancel}"; mControllerButtons.x = "#{sOffer}"; - mControllerButtons.y = ""; + mControllerButtons.y.clear(); mControllerButtons.r2 = "#{sBarter}"; break; case MWGui::GM_Inventory: @@ -1001,7 +1001,7 @@ namespace MWGui mControllerButtons.b = "#{sBack}"; mControllerButtons.x = "#{sDrop}"; mControllerButtons.y = "#{sUnequip}"; - mControllerButtons.r2 = ""; + mControllerButtons.r2.clear(); break; } return &mControllerButtons; diff --git a/apps/openmw/mwgui/windowbase.cpp b/apps/openmw/mwgui/windowbase.cpp index b607ec50b2..d6a5cb9086 100644 --- a/apps/openmw/mwgui/windowbase.cpp +++ b/apps/openmw/mwgui/windowbase.cpp @@ -25,7 +25,7 @@ int MWGui::wrap(int index, int max) return index; } -void MWGui::setControllerFocus(std::vector buttons, int index, bool focused) +void MWGui::setControllerFocus(const std::vector& buttons, int index, bool focused) { if (index >= 0 && index < static_cast(buttons.size())) buttons[index]->setStateSelected(focused); diff --git a/apps/openmw/mwgui/windowbase.hpp b/apps/openmw/mwgui/windowbase.hpp index b4d17a1ba3..fb88af499a 100644 --- a/apps/openmw/mwgui/windowbase.hpp +++ b/apps/openmw/mwgui/windowbase.hpp @@ -15,7 +15,7 @@ namespace MWGui class DragAndDrop; int wrap(int index, int max); - void setControllerFocus(std::vector buttons, int index, bool selected); + void setControllerFocus(const std::vector& buttons, int index, bool selected); struct ControllerButtonStr { diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 145e07d2c7..866dd1580a 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -898,9 +898,6 @@ namespace MWGui int activeIndex = std::clamp(mActiveControllerWindows[mode], 0, (int)state.mWindows.size() - 1); - Log(Debug::Debug) << "Getting active controller window: mode=" << mode << ", " << state.mWindows.size() - << " window(s), activeIndex=" << activeIndex; - // If the active window is no longer visible, find the next visible window. if (!state.mWindows[activeIndex]->isVisible()) cycleActiveControllerWindow(true); @@ -2634,7 +2631,7 @@ namespace MWGui if (!Settings::gui().mControllerMenus || !mControllerButtonsOverlay) return; - WindowBase* topWin = this->getActiveControllerWindow(); + WindowBase* topWin = getActiveControllerWindow(); if (!topWin || !topWin->isVisible()) { mControllerButtonsOverlay->setVisible(false); diff --git a/apps/openmw/mwinput/controllermanager.cpp b/apps/openmw/mwinput/controllermanager.cpp index 68cd9a7dbd..61e12a3b1a 100644 --- a/apps/openmw/mwinput/controllermanager.cpp +++ b/apps/openmw/mwinput/controllermanager.cpp @@ -538,7 +538,7 @@ namespace MWInput return "textures/omw_steam_button_y.dds"; case SDL_CONTROLLER_BUTTON_GUIDE: default: - return ""; + return {}; } }