1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-01 20:34:32 +00:00

Minor fixes based on code review feedback.

This commit is contained in:
Andrew Lanzone 2025-07-10 08:46:01 -07:00
parent e04f0a8bd6
commit b075428513
8 changed files with 27 additions and 30 deletions

View file

@ -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;
}
}
}

View file

@ -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<int>(mTopicsList->getItemCount())
? mTopicsList->getItemNameAt(mControllerFocus)
: "";
std::string focusedTopic;
if (Settings::gui().mControllerMenus && mControllerFocus < static_cast<int>(mTopicsList->getItemCount()))
focusedTopic = mTopicsList->getItemNameAt(mControllerFocus);
mTopicsList->clear();
for (auto& linkPair : mTopicLinks)

View file

@ -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<ResponseCallback> mCallback;
std::unique_ptr<ResponseCallback> mGreetingCallback;

View file

@ -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;

View file

@ -25,7 +25,7 @@ int MWGui::wrap(int index, int max)
return index;
}
void MWGui::setControllerFocus(std::vector<MyGUI::Button*> buttons, int index, bool focused)
void MWGui::setControllerFocus(const std::vector<MyGUI::Button*>& buttons, int index, bool focused)
{
if (index >= 0 && index < static_cast<int>(buttons.size()))
buttons[index]->setStateSelected(focused);

View file

@ -15,7 +15,7 @@ namespace MWGui
class DragAndDrop;
int wrap(int index, int max);
void setControllerFocus(std::vector<MyGUI::Button*> buttons, int index, bool selected);
void setControllerFocus(const std::vector<MyGUI::Button*>& buttons, int index, bool selected);
struct ControllerButtonStr
{

View file

@ -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);

View file

@ -538,7 +538,7 @@ namespace MWInput
return "textures/omw_steam_button_y.dds";
case SDL_CONTROLLER_BUTTON_GUIDE:
default:
return "";
return {};
}
}