Fix clang format issues

This commit is contained in:
Andrew Lanzone 2025-06-07 22:51:29 -07:00
parent 0ca6bc012c
commit be32cbb413
23 changed files with 80 additions and 80 deletions

View File

@ -552,7 +552,8 @@ namespace MWGui
bool AlchemyWindow::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
bool isFilterListOpen = focus != nullptr && focus->getParent() != nullptr && focus->getParent()->getParent() == mFilterValue;
bool isFilterListOpen
= focus != nullptr && focus->getParent() != nullptr && focus->getParent()->getParent() == mFilterValue;
if (isFilterListOpen)
{

View File

@ -91,8 +91,8 @@ namespace MWGui
{
onBackClicked(mBackButton);
}
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && mOkButtonFocus) ||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mOkButtonFocus))
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && mOkButtonFocus)
|| (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mOkButtonFocus))
{
mOkButtonFocus = !mOkButtonFocus;
mOkButton->setStateSelected(mOkButtonFocus);

View File

@ -86,8 +86,8 @@ namespace MWGui
{
onCancelButtonClicked(mCancelButton);
}
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && !mOkButtonFocus) ||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && mOkButtonFocus))
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && !mOkButtonFocus)
|| (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && mOkButtonFocus))
{
mOkButtonFocus = !mOkButtonFocus;
mOkButton->setStateSelected(mOkButtonFocus);

View File

@ -127,8 +127,7 @@ namespace MWGui
if (!onTakeItem(item, count))
return;
MWGui::InventoryWindow* inventoryWindow
= MWBase::Environment::get().getWindowManager()->getInventoryWindow();
MWGui::InventoryWindow* inventoryWindow = MWBase::Environment::get().getWindowManager()->getInventoryWindow();
ItemModel* playerModel = inventoryWindow->getModel();
mModel->moveItem(item, count, playerModel);
@ -385,11 +384,9 @@ namespace MWGui
if (mDisposeCorpseButton->getVisible())
onDisposeCorpseButtonClicked(mDisposeCorpseButton);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK || arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP
|| arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN || arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT
|| arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
{
mItemView->onControllerButton(arg.button);
}

View File

@ -75,7 +75,8 @@ namespace MWGui
setVisible(buttonCount > 0);
}
int ControllerButtonsOverlay::updateButton(MyGUI::TextBox* text, MyGUI::ImageBox* image, const std::string& buttonStr)
int ControllerButtonsOverlay::updateButton(
MyGUI::TextBox* text, MyGUI::ImageBox* image, const std::string& buttonStr)
{
if (buttonStr.length() > 0)
{

View File

@ -603,10 +603,10 @@ namespace MWGui
void DialogueWindow::updateTopicsPane()
{
const std::string focusedTopic =
Settings::gui().mControllerMenus && mControllerFocus < mTopicsList->getItemCount()
? mTopicsList->getItemNameAt(mControllerFocus)
: "";
const std::string focusedTopic
= Settings::gui().mControllerMenus && mControllerFocus < mTopicsList->getItemCount()
? mTopicsList->getItemNameAt(mControllerFocus)
: "";
mTopicsList->clear();
for (auto& linkPair : mTopicLinks)
@ -931,7 +931,8 @@ namespace MWGui
{
mGoodbyeButton->setStateSelected(focused);
}
else {
else
{
std::string keyword = mTopicsList->getItemNameAt(mControllerFocus);
if (keyword.length() == 0)
return;

View File

@ -941,15 +941,19 @@ namespace MWGui
else if (mGuiMode == MWGui::GM_Companion && mDragAndDrop->mIsOnDragAndDrop)
{
// Drag and drop the item on the companion's window.
MWGui::CompanionWindow* companionWindow =
(MWGui::CompanionWindow *)MWBase::Environment::get().getWindowManager()->getGuiModeWindows(mGuiMode).at(0);
MWGui::CompanionWindow* companionWindow = (MWGui::CompanionWindow*)MWBase::Environment::get()
.getWindowManager()
->getGuiModeWindows(mGuiMode)
.at(0);
mDragAndDrop->drop(companionWindow->getModel(), companionWindow->getItemView());
}
else if (mGuiMode == MWGui::GM_Container && mDragAndDrop->mIsOnDragAndDrop)
{
// Drag and drop the item on the container window.
MWGui::ContainerWindow* containerWindow =
(MWGui::ContainerWindow *)MWBase::Environment::get().getWindowManager()->getGuiModeWindows(mGuiMode).at(0);
MWGui::ContainerWindow* containerWindow = (MWGui::ContainerWindow*)MWBase::Environment::get()
.getWindowManager()
->getGuiModeWindows(mGuiMode)
.at(0);
mDragAndDrop->drop(containerWindow->getModel(), containerWindow->getItemView());
}
// GM_Barter is handled by onControllerButtonEvent. No other steps are necessary.
@ -967,16 +971,20 @@ namespace MWGui
{
// Take all. Pass the button press to the container window and let it do the
// logic of taking all.
MWGui::ContainerWindow* containerWindow =
(MWGui::ContainerWindow *)MWBase::Environment::get().getWindowManager()->getGuiModeWindows(mGuiMode).at(0);
MWGui::ContainerWindow* containerWindow = (MWGui::ContainerWindow*)MWBase::Environment::get()
.getWindowManager()
->getGuiModeWindows(mGuiMode)
.at(0);
containerWindow->onControllerButtonEvent(arg);
}
else if (mGuiMode == MWGui::GM_Barter)
{
// Offer. Pass the button press to the barter window and let it do the logic
// of making an offer.
MWGui::TradeWindow* tradeWindow =
(MWGui::TradeWindow*)MWBase::Environment::get().getWindowManager()->getGuiModeWindows(mGuiMode).at(1);
MWGui::TradeWindow* tradeWindow = (MWGui::TradeWindow*)MWBase::Environment::get()
.getWindowManager()
->getGuiModeWindows(mGuiMode)
.at(1);
tradeWindow->onControllerButtonEvent(arg);
}
}

View File

@ -268,14 +268,14 @@ namespace MWGui
if (prevFocus >= 0 && prevFocus < mItemCount)
{
ItemWidget* prev = (ItemWidget *)dragArea->getChildAt(prevFocus);
ItemWidget* prev = (ItemWidget*)dragArea->getChildAt(prevFocus);
if (prev)
prev->setControllerFocus(false);
}
if (mControllerActiveWindow && newFocus >= 0 && newFocus < mItemCount)
{
ItemWidget* focused = (ItemWidget *)dragArea->getChildAt(newFocus);
ItemWidget* focused = (ItemWidget*)dragArea->getChildAt(newFocus);
if (focused)
{
focused->setControllerFocus(true);

View File

@ -496,7 +496,8 @@ namespace
MyGUI::Button* listItem = _list->getItemWidget(_list->getItemNameAt(i));
if (listItem)
{
listItem->setTextColour(mButtons.size() == _selectedIndex ? MWGui::journalHeaderColour : MyGUI::Colour::Black);
listItem->setTextColour(
mButtons.size() == _selectedIndex ? MWGui::journalHeaderColour : MyGUI::Colour::Black);
mButtons.push_back(listItem);
}
}
@ -737,8 +738,10 @@ namespace
// Choose an index. Cyrillic capital A is a 0xd090 in UTF-8.
// Words can not be started with characters 26 or 28.
int russianOffset = 0xd090;
if (mSelectedIndex >= 26) russianOffset++;
if (mSelectedIndex >= 27) russianOffset++; // 27, not 28, because of skipping char 26
if (mSelectedIndex >= 26)
russianOffset++;
if (mSelectedIndex >= 27)
russianOffset++; // 27, not 28, because of skipping char 26
notifyIndexLinkClicked(isRussian ? mSelectedIndex + russianOffset : mSelectedIndex + 'A');
}
return true;
@ -776,7 +779,8 @@ namespace
notifyCancel(getWidget<MyGUI::Widget>(CancelBTN));
mQuestMode = false;
}
else {
else
{
// Show the quest overlay if viewing a journal entry or the topics
if (!mOptionsMode)
notifyOptions(getWidget<MyGUI::Widget>(OptionsBTN));
@ -793,7 +797,8 @@ namespace
notifyCancel(getWidget<MyGUI::Widget>(CancelBTN));
mQuestMode = false;
}
else {
else
{
// Show the topics overlay if viewing a journal entry or the quest list
if (!mOptionsMode)
notifyOptions(getWidget<MyGUI::Widget>(OptionsBTN));

View File

@ -387,7 +387,7 @@ namespace MWGui
if (arg.button == SDL_CONTROLLER_BUTTON_A)
{
if (mControllerFocus >= 0 && mControllerFocus < mAttributeButtons.size())
onAttributeClicked(mAttributeButtons[mControllerFocus]);
onAttributeClicked(mAttributeButtons[mControllerFocus]);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Item Gold Up"));
}
else if (arg.button == SDL_CONTROLLER_BUTTON_X)

View File

@ -1440,14 +1440,12 @@ namespace MWGui
{
mNeedDoorMarkersUpdate = true;
mLocalMap->setViewOffset(
MyGUI::IntPoint(
mLocalMap->getViewOffset().left + dx, mLocalMap->getViewOffset().top + dy));
MyGUI::IntPoint(mLocalMap->getViewOffset().left + dx, mLocalMap->getViewOffset().top + dy));
}
else
{
mGlobalMap->setViewOffset(
MyGUI::IntPoint(
mGlobalMap->getViewOffset().left + dx, mGlobalMap->getViewOffset().top + dy));
MyGUI::IntPoint(mGlobalMap->getViewOffset().left + dx, mGlobalMap->getViewOffset().top + dy));
}
}

View File

@ -469,8 +469,7 @@ namespace MWGui
onQuickKeyButtonClicked(mKey[mControllerFocus].button);
if (arg.button == SDL_CONTROLLER_BUTTON_B)
onOkButtonClicked(mOkButton);
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP || arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
mControllerFocus = (mControllerFocus + 5) % 10;
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
{

View File

@ -142,8 +142,7 @@ namespace MWGui
bool Recharge::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{
if ((arg.button == SDL_CONTROLLER_BUTTON_A && !mGemBox->getVisible())
|| arg.button == SDL_CONTROLLER_BUTTON_Y)
if ((arg.button == SDL_CONTROLLER_BUTTON_A && !mGemBox->getVisible()) || arg.button == SDL_CONTROLLER_BUTTON_Y)
{
onSelectItem(mGemIcon);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));

View File

@ -156,8 +156,7 @@ namespace MWGui
bool Repair::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{
if ((arg.button == SDL_CONTROLLER_BUTTON_A && !mToolBox->getVisible())
|| arg.button == SDL_CONTROLLER_BUTTON_Y)
if ((arg.button == SDL_CONTROLLER_BUTTON_A && !mToolBox->getVisible()) || arg.button == SDL_CONTROLLER_BUTTON_Y)
{
onSelectItem(mToolIcon);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));

View File

@ -542,7 +542,7 @@ namespace MWGui
{
if (arg.button == SDL_CONTROLLER_BUTTON_A)
{
switch(mControllerFocus)
switch (mControllerFocus)
{
case 0:
onNameClicked(mButtons[0]);
@ -573,15 +573,13 @@ namespace MWGui
{
onOkClicked(mButtons[5]);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP || arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
{
setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus - 1, mButtons.size());
setControllerFocus(mButtons, mControllerFocus, true);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN || arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
{
setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus + 1, mButtons.size());

View File

@ -163,10 +163,11 @@ namespace MWGui
hour = 12;
ESM::EpochTimeStamp currentDate = timeManager.getEpochTimeStamp();
std::string daysPassed = Misc::StringUtils::format("#{Calendar:day} %i", timeManager.getTimeStamp().getDay());
std::string daysPassed
= Misc::StringUtils::format("#{Calendar:day} %i", timeManager.getTimeStamp().getDay());
std::string_view formattedHour(pm ? "#{Calendar:pm}" : "#{Calendar:am}");
std::string autoFilename
= Misc::StringUtils::format("%s - %i %s %i %s", daysPassed, currentDate.mDay, month, hour, formattedHour);
std::string autoFilename = Misc::StringUtils::format(
"%s - %i %s %i %s", daysPassed, currentDate.mDay, month, hour, formattedHour);
mSaveNameEdit->setCaptionWithReplacing(autoFilename);
}
@ -561,8 +562,8 @@ namespace MWGui
winMgr->setKeyFocusWidget(mSaveList);
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
}
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && !mOkButtonFocus) ||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && mOkButtonFocus))
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && !mOkButtonFocus)
|| (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && mOkButtonFocus))
{
mOkButtonFocus = !mOkButtonFocus;
mOkButton->setStateSelected(mOkButtonFocus);

View File

@ -13,8 +13,8 @@
#include <components/esm3/loadgmst.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/inputmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/class.hpp"
@ -550,10 +550,8 @@ namespace MWGui
if (prevFocus >= 0 && prevFocus < mButtons.size())
{
MyGUI::TextBox* button = mButtons[prevFocus];
if (button == mMagnitudeMinValue ||
button == mMagnitudeMaxValue ||
button == mDurationValue ||
button == mAreaValue)
if (button == mMagnitudeMinValue || button == mMagnitudeMaxValue || button == mDurationValue
|| button == mAreaValue)
{
button->setTextColour(textColours.normal);
}
@ -566,10 +564,8 @@ namespace MWGui
if (newFocus >= 0 && newFocus < mButtons.size())
{
MyGUI::TextBox* button = mButtons[newFocus];
if (button == mMagnitudeMinValue ||
button == mMagnitudeMaxValue ||
button == mDurationValue ||
button == mAreaValue)
if (button == mMagnitudeMinValue || button == mMagnitudeMaxValue || button == mDurationValue
|| button == mAreaValue)
{
button->setTextColour(textColours.link);
}
@ -744,7 +740,6 @@ namespace MWGui
mSuccessChance->setCaption(MyGUI::utility::toString(intChance));
}
bool SpellCreationDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{
if (arg.button == SDL_CONTROLLER_BUTTON_B)
@ -761,7 +756,6 @@ namespace MWGui
return EffectEditorBase::onControllerButtonEvent(arg);
}
// ------------------------------------------------------------------------------------------------
EffectEditorBase::EffectEditorBase(Type type)
@ -856,7 +850,7 @@ namespace MWGui
mEffectFocus = 0;
mRightColumn = false;
if (mAvailableButtons.size() > 0)
mAvailableButtons[0]->setStateSelected(true);
mAvailableButtons[0]->setStateSelected(true);
}
}

View File

@ -1,8 +1,8 @@
#ifndef MWGUI_SPELLCREATION_H
#define MWGUI_SPELLCREATION_H
#include <memory>
#include <SDL.h>
#include <memory>
#include <components/esm3/loadmgef.hpp>
#include <components/esm3/loadspel.hpp>

View File

@ -393,7 +393,7 @@ namespace MWGui
void SpellView::updateControllerFocus(int prevFocus, int newFocus)
{
if (mButtons.empty())
return;
return;
if (prevFocus >= 0 && prevFocus < mButtons.size())
{

View File

@ -95,7 +95,7 @@ namespace MWGui
void adjustSpellWidget(const Spell& spell, SpellModel::ModelIndex index, MyGUI::Widget* widget);
/// Keep a list of buttons for controller navigation and their index in the full list.
std::vector<std::pair<Gui::SharedStateButton *, int>> mButtons;
std::vector<std::pair<Gui::SharedStateButton*, int>> mButtons;
/// Keep a list of group offsets for controller navigation
std::vector<int> mGroupIndices;

View File

@ -733,11 +733,9 @@ namespace MWGui
onFilterChanged(mFilterAll);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
}
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT ||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK || arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP
|| arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN || arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT
|| arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
{
mItemView->onControllerButton(arg.button);
}

View File

@ -898,7 +898,8 @@ 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;
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())
@ -1903,7 +1904,8 @@ namespace MWGui
{
// If using controller menus, don't persist changes to size of the stats or magic
// windows.
if (Settings::gui().mControllerMenus && (window == (MyGUI::Window*)mStatsWindow || window == (MyGUI::Window*)mSpellWindow))
if (Settings::gui().mControllerMenus
&& (window == (MyGUI::Window*)mStatsWindow || window == (MyGUI::Window*)mSpellWindow))
return;
const auto it = mTrackedWindows.find(window);
@ -2616,7 +2618,8 @@ namespace MWGui
// setButtons will handle setting visibility based on if any buttons are defined.
mControllerButtonsOverlay->setButtons(topWin->getControllerButtons());
if (getMode() == GM_Inventory) {
if (getMode() == GM_Inventory)
{
mInventoryTabsOverlay->setVisible(true);
mInventoryTabsOverlay->setTab(mActiveControllerWindows[GM_Inventory]);
}

View File

@ -255,9 +255,7 @@ namespace MWInput
{
// When the inventory tooltip is visible, we don't actually want the A button to
// act like a mouse button; it should act normally.
if (treatAsMouse
&& arg.button == SDL_CONTROLLER_BUTTON_A
&& winMgr->getControllerTooltip())
if (treatAsMouse && arg.button == SDL_CONTROLLER_BUTTON_A && winMgr->getControllerTooltip())
treatAsMouse = false;
mGamepadGuiCursorEnabled = topWin->isGamepadCursorAllowed();