1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-11-30 14:04:30 +00:00

Resolve various conversion warnings in mwgui

This commit is contained in:
Evil Eye 2025-09-21 15:58:38 +02:00
parent 39f17f5651
commit fc700c61fd
50 changed files with 294 additions and 311 deletions

View file

@ -391,7 +391,7 @@ namespace MWBase
virtual int getControllerMenuHeight() = 0;
/// Cycle to the next window to receive controller events
virtual void cycleActiveControllerWindow(bool next) = 0;
virtual void setActiveControllerWindow(MWGui::GuiMode mode, int activeIndex) = 0;
virtual void setActiveControllerWindow(MWGui::GuiMode mode, size_t activeIndex) = 0;
virtual bool getControllerTooltipVisible() const = 0;
virtual void setControllerTooltipVisible(bool visible) = 0;
virtual bool getControllerTooltipEnabled() const = 0;

View file

@ -135,7 +135,7 @@ namespace MWGui
mSections[section].mLines[line].mRuns[run].mStyle->mNormalColour = colour;
}
virtual ~TypesetBookImpl() {}
virtual ~TypesetBookImpl() = default;
Range addContent(const BookTypesetter::Utf8Span& text)
{
@ -285,7 +285,7 @@ namespace MWGui
Book::Content const* mCurrentContent;
Alignment mCurrentAlignment;
Typesetter(size_t width, size_t height)
Typesetter(int width, int height)
: mPageWidth(width)
, mPageHeight(height)
, mSection(nullptr)
@ -297,7 +297,7 @@ namespace MWGui
mBook = std::make_shared<Book>();
}
virtual ~Typesetter() {}
virtual ~Typesetter() = default;
Style* createStyle(const std::string& fontName, const Colour& fontColour, bool useBookFont) override
{

View file

@ -62,8 +62,8 @@ namespace MWGui
{
// english button has a 7 pixel wide strip of garbage on its right edge
mNextPageButton->setSize(64 - 7, mNextPageButton->getSize().height);
mNextPageButton->setImageCoord(
MyGUI::IntCoord(0, 0, (64 - 7) * scale, mNextPageButton->getSize().height * scale));
mNextPageButton->setImageCoord(MyGUI::IntCoord(
0, 0, static_cast<int>((64 - 7) * scale), static_cast<int>(mNextPageButton->getSize().height * scale)));
}
mControllerButtons.mL1 = "#{Interface:Prev}";

View file

@ -28,7 +28,7 @@ namespace MWGui
MWWorld::Ptr CompanionItemModel::addItem(const ItemStack& item, size_t count, bool allowAutoEquip)
{
if (hasProfit(mActor))
modifyProfit(mActor, item.mBase.getClass().getValue(item.mBase) * count);
modifyProfit(mActor, static_cast<int>(item.mBase.getClass().getValue(item.mBase) * count));
return InventoryItemModel::addItem(item, count, allowAutoEquip);
}
@ -36,7 +36,7 @@ namespace MWGui
MWWorld::Ptr CompanionItemModel::copyItem(const ItemStack& item, size_t count, bool allowAutoEquip)
{
if (hasProfit(mActor))
modifyProfit(mActor, item.mBase.getClass().getValue(item.mBase) * count);
modifyProfit(mActor, static_cast<int>(item.mBase.getClass().getValue(item.mBase) * count));
return InventoryItemModel::copyItem(item, count, allowAutoEquip);
}
@ -44,7 +44,7 @@ namespace MWGui
void CompanionItemModel::removeItem(const ItemStack& item, size_t count)
{
if (hasProfit(mActor))
modifyProfit(mActor, -item.mBase.getClass().getValue(item.mBase) * count);
modifyProfit(mActor, -static_cast<int>(item.mBase.getClass().getValue(item.mBase) * count));
InventoryItemModel::removeItem(item, count);
}

View file

@ -90,7 +90,7 @@ namespace MWGui
ItemModel::ModelIndex ContainerItemModel::getIndex(const ItemStack& item)
{
size_t i = 0;
ModelIndex i = 0;
for (ItemStack& itemStack : mItems)
{
if (itemStack == item)
@ -106,7 +106,7 @@ namespace MWGui
MWWorld::ContainerStore& store = source.first.getClass().getContainerStore(source.first);
if (item.mBase.getContainerStore() == &store)
throw std::runtime_error("Item to add needs to be from a different container!");
return *store.add(item.mBase, count, allowAutoEquip);
return *store.add(item.mBase, static_cast<int>(count), allowAutoEquip);
}
MWWorld::Ptr ContainerItemModel::copyItem(const ItemStack& item, size_t count, bool allowAutoEquip)
@ -115,8 +115,8 @@ namespace MWGui
MWWorld::ContainerStore& store = source.first.getClass().getContainerStore(source.first);
if (item.mBase.getContainerStore() == &store)
throw std::runtime_error("Item to copy needs to be from a different container!");
MWWorld::ManualRef newRef(*MWBase::Environment::get().getESMStore(), item.mBase, count);
return *store.add(newRef.getPtr(), count, allowAutoEquip);
MWWorld::ManualRef newRef(*MWBase::Environment::get().getESMStore(), item.mBase, static_cast<int>(count));
return *store.add(newRef.getPtr(), static_cast<int>(count), allowAutoEquip);
}
void ContainerItemModel::removeItem(const ItemStack& item, size_t count)

View file

@ -186,13 +186,13 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
{
setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus - 1, mButtons.size());
mControllerFocus = wrap(mControllerFocus, mButtons.size(), -1);
setControllerFocus(mButtons, mControllerFocus, true);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
{
setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus + 1, mButtons.size());
mControllerFocus = wrap(mControllerFocus, mButtons.size(), 1);
setControllerFocus(mButtons, mControllerFocus, true);
}
@ -428,8 +428,8 @@ namespace MWGui
{
if (!mScrollBar->getVisible())
return;
mScrollBar->setScrollPosition(
std::clamp<int>(mScrollBar->getScrollPosition() - rel * 0.3, 0, mScrollBar->getScrollRange() - 1));
mScrollBar->setScrollPosition(std::clamp<size_t>(
static_cast<size_t>(mScrollBar->getScrollPosition() - rel * 0.3), 0, mScrollBar->getScrollRange() - 1));
onScrollbarMoved(mScrollBar, mScrollBar->getScrollPosition());
}
@ -441,7 +441,7 @@ namespace MWGui
}
}
void DialogueWindow::onSelectListItem(const std::string& topic, int id)
void DialogueWindow::onSelectListItem(const std::string& topic, int /*id*/)
{
MWBase::DialogueManager* dialogueManager = MWBase::Environment::get().getDialogueManager();
@ -607,7 +607,7 @@ namespace MWGui
void DialogueWindow::updateTopicsPane()
{
std::string focusedTopic;
if (Settings::gui().mControllerMenus && mControllerFocus < static_cast<int>(mTopicsList->getItemCount()))
if (Settings::gui().mControllerMenus && mControllerFocus < mTopicsList->getItemCount())
focusedTopic = mTopicsList->getItemNameAt(mControllerFocus);
mTopicsList->clear();
@ -970,10 +970,10 @@ namespace MWGui
else if (mControllerChoice >= 0 && mControllerChoice < static_cast<int>(mChoices.size()))
onChoiceActivated(mChoices[mControllerChoice].second);
}
else if (mControllerFocus == static_cast<int>(mTopicsList->getItemCount()))
else if (mControllerFocus == mTopicsList->getItemCount())
onGoodbyeActivated();
else
onSelectListItem(mTopicsList->getItemNameAt(mControllerFocus), mControllerFocus);
onSelectListItem(mTopicsList->getItemNameAt(mControllerFocus), static_cast<int>(mControllerFocus));
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
}
else if (arg.button == SDL_CONTROLLER_BUTTON_B && mChoices.empty())
@ -1013,9 +1013,9 @@ namespace MWGui
{
// Number of items is mTopicsList.length+1 because of "Goodbye" button.
setControllerFocus(mControllerFocus, false);
if (mControllerFocus >= static_cast<int>(mTopicsList->getItemCount()))
if (mControllerFocus >= mTopicsList->getItemCount())
mControllerFocus = 0;
else if (mControllerFocus == static_cast<int>(mTopicsList->getItemCount()) - 1)
else if (mControllerFocus == mTopicsList->getItemCount() - 1)
mControllerFocus = mTopicsList->getItemCount(); // "Goodbye" button
else if (mTopicsList->getItemNameAt(mControllerFocus + 1).empty())
mControllerFocus += 2; // Skip separator
@ -1027,13 +1027,13 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER && mChoices.size() == 0)
{
setControllerFocus(mControllerFocus, false);
mControllerFocus = std::max(mControllerFocus - 5, 0);
mControllerFocus = mControllerFocus > 5 ? mControllerFocus - 5 : 0;
setControllerFocus(mControllerFocus, true);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER && mChoices.size() == 0)
{
setControllerFocus(mControllerFocus, false);
mControllerFocus = std::min(mControllerFocus + 5, static_cast<int>(mTopicsList->getItemCount()));
mControllerFocus = std::min(mControllerFocus + 5, mTopicsList->getItemCount());
setControllerFocus(mControllerFocus, true);
}

View file

@ -69,7 +69,7 @@ namespace MWGui
Gui::AutoSizedTextBox* mGoldLabel;
std::vector<MyGUI::Button*> mButtons;
int mControllerFocus = 0;
size_t mControllerFocus = 0;
void adjustAction(MyGUI::Widget* action, int& totalHeight);
@ -230,7 +230,7 @@ namespace MWGui
std::unique_ptr<ResponseCallback> mGreetingCallback;
void setControllerFocus(size_t index, bool focused);
int mControllerFocus = 0;
size_t mControllerFocus = 0;
int mControllerChoice = -1;
void updateTopicFormat();

View file

@ -349,7 +349,7 @@ namespace MWGui
if (mIsDrowning)
{
mDrowningFlashTheta += dt * osg::PI * 2;
mDrowningFlashTheta += dt * osg::PIf * 2;
float intensity = (cos(mDrowningFlashTheta) + 2.0f) / 3.0f;

View file

@ -37,7 +37,7 @@ namespace MWGui
ItemModel::ModelIndex InventoryItemModel::getIndex(const ItemStack& item)
{
size_t i = 0;
ModelIndex i = 0;
for (ItemStack& itemStack : mItems)
{
if (itemStack == item)
@ -51,7 +51,7 @@ namespace MWGui
{
if (item.mBase.getContainerStore() == &mActor.getClass().getContainerStore(mActor))
throw std::runtime_error("Item to add needs to be from a different container!");
return *mActor.getClass().getContainerStore(mActor).add(item.mBase, count, allowAutoEquip);
return *mActor.getClass().getContainerStore(mActor).add(item.mBase, static_cast<int>(count), allowAutoEquip);
}
MWWorld::Ptr InventoryItemModel::copyItem(const ItemStack& item, size_t count, bool allowAutoEquip)
@ -59,8 +59,9 @@ namespace MWGui
if (item.mBase.getContainerStore() == &mActor.getClass().getContainerStore(mActor))
throw std::runtime_error("Item to copy needs to be from a different container!");
MWWorld::ManualRef newRef(*MWBase::Environment::get().getESMStore(), item.mBase, count);
return *mActor.getClass().getContainerStore(mActor).add(newRef.getPtr(), count, allowAutoEquip);
MWWorld::ManualRef newRef(*MWBase::Environment::get().getESMStore(), item.mBase, static_cast<int>(count));
return *mActor.getClass().getContainerStore(mActor).add(
newRef.getPtr(), static_cast<int>(count), allowAutoEquip);
}
void InventoryItemModel::removeItem(const ItemStack& item, size_t count)
@ -70,12 +71,12 @@ namespace MWGui
if (mActor.getClass().hasInventoryStore(mActor))
{
MWWorld::InventoryStore& store = mActor.getClass().getInventoryStore(mActor);
removed = store.remove(item.mBase, count, true);
removed = store.remove(item.mBase, static_cast<int>(count), true);
}
else
{
MWWorld::ContainerStore& store = mActor.getClass().getContainerStore(mActor);
removed = store.remove(item.mBase, count);
removed = store.remove(item.mBase, static_cast<int>(count));
}
std::stringstream error;

View file

@ -161,7 +161,7 @@ namespace MWGui
mScrollView->setVisibleVScroll(true);
if (Settings::gui().mControllerMenus)
updateControllerFocus(-1, mControllerFocus);
updateControllerFocus(mLines.size(), mControllerFocus);
}
void ItemChargeView::resetScrollbars()
@ -242,37 +242,37 @@ namespace MWGui
if (mLines.empty())
return;
int prevFocus = mControllerFocus;
size_t prevFocus = mControllerFocus;
if (button == SDL_CONTROLLER_BUTTON_A)
{
// Select the focused item, if any.
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mLines.size()))
if (mControllerFocus < mLines.size())
onIconClicked(mLines[mControllerFocus].mIcon);
}
else if (button == SDL_CONTROLLER_BUTTON_DPAD_UP)
mControllerFocus = wrap(mControllerFocus - 1, mLines.size());
mControllerFocus = wrap(mControllerFocus, mLines.size(), -1);
else if (button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
mControllerFocus = wrap(mControllerFocus + 1, mLines.size());
mControllerFocus = wrap(mControllerFocus, mLines.size(), 1);
if (prevFocus != mControllerFocus)
updateControllerFocus(prevFocus, mControllerFocus);
}
void ItemChargeView::updateControllerFocus(int prevFocus, int newFocus)
void ItemChargeView::updateControllerFocus(size_t prevFocus, size_t newFocus)
{
if (mLines.empty())
return;
const TextColours& textColours{ MWBase::Environment::get().getWindowManager()->getTextColours() };
if (prevFocus >= 0 && prevFocus < static_cast<int>(mLines.size()))
if (prevFocus < mLines.size())
{
mLines[prevFocus].mText->setTextColour(textColours.normal);
mLines[prevFocus].mIcon->setControllerFocus(false);
}
if (newFocus >= 0 && newFocus < static_cast<int>(mLines.size()))
if (newFocus >= 0 && newFocus < mLines.size())
{
mLines[newFocus].mText->setTextColour(textColours.link);
mLines[newFocus].mIcon->setControllerFocus(true);
@ -281,7 +281,7 @@ namespace MWGui
if (newFocus <= 3)
mScrollView->setViewOffset(MyGUI::IntPoint(0, 0));
else
mScrollView->setViewOffset(MyGUI::IntPoint(0, -55 * (newFocus - 3)));
mScrollView->setViewOffset(MyGUI::IntPoint(0, -55 * static_cast<int>(newFocus - 3)));
}
}
}

View file

@ -75,8 +75,8 @@ namespace MWGui
MyGUI::ScrollView* mScrollView;
DisplayMode mDisplayMode;
int mControllerFocus = 0;
void updateControllerFocus(int prevFocus, int newFocus);
size_t mControllerFocus = 0;
void updateControllerFocus(size_t prevFocus, size_t newFocus);
};
}

View file

@ -109,9 +109,9 @@ namespace MWGui
const ItemStack& itemToSearch = getItem(index);
for (size_t i = 0; i < mSourceModel->getItemCount(); ++i)
{
const ItemStack& item = mSourceModel->getItem(i);
const ItemStack& item = mSourceModel->getItem(static_cast<ModelIndex>(i));
if (item.mBase == itemToSearch.mBase)
return i;
return static_cast<ModelIndex>(i);
}
return -1;
}
@ -121,9 +121,9 @@ namespace MWGui
const ItemStack& itemToSearch = mSourceModel->getItem(index);
for (size_t i = 0; i < getItemCount(); ++i)
{
const ItemStack& item = getItem(i);
const ItemStack& item = getItem(static_cast<ModelIndex>(i));
if (item.mBase == itemToSearch.mBase)
return i;
return static_cast<ModelIndex>(i);
}
return -1;
}

View file

@ -55,7 +55,7 @@ namespace MWGui
WorldItemModel worldItemModel(0.5f, 0.5f);
ItemModel* const targetModel = targetView == nullptr ? &worldItemModel : targetView->getModel();
if (!targetModel->onDropItem(item.mBase, count))
if (!targetModel->onDropItem(item.mBase, static_cast<int>(count)))
return;
sourceView.getModel()->moveItem(item, count, targetModel);

View file

@ -49,7 +49,7 @@ namespace
{
struct DisplayState
{
unsigned int mPage;
size_t mPage;
Book mBook;
};
@ -159,8 +159,8 @@ namespace
{
// english button has a 7 pixel wide strip of garbage on its right edge
nextButton->setSize(64 - 7, nextButton->getSize().height);
nextButton->setImageCoord(
MyGUI::IntCoord(0, 0, (64 - 7) * nextButtonScale, nextButton->getSize().height * nextButtonScale));
nextButton->setImageCoord(MyGUI::IntCoord(0, 0, static_cast<int>((64 - 7) * nextButtonScale),
static_cast<int>(nextButton->getSize().height * nextButtonScale)));
}
if (!questList)
@ -246,12 +246,12 @@ namespace
else
journalBook = createJournalBook();
pushBook(journalBook, 0);
pushBook(journalBook);
// fast forward to the last page
if (!mStates.empty())
{
unsigned int& page = mStates.top().mPage;
size_t& page = mStates.top().mPage;
page = mStates.top().mBook->pageCount() - 1;
if (page % 2)
--page;
@ -326,21 +326,21 @@ namespace
MWBase::Environment::get().getWindowManager()->updateControllerButtonsOverlay();
}
void pushBook(Book& book, unsigned int page)
void pushBook(Book& book)
{
DisplayState bs;
bs.mPage = page;
bs.mPage = 0;
bs.mBook = book;
mStates.push(bs);
updateShowingPages();
updateCloseJournalButton();
}
void replaceBook(Book& book, unsigned int page)
void replaceBook(Book& book)
{
assert(!mStates.empty());
mStates.top().mBook = book;
mStates.top().mPage = page;
mStates.top().mPage = 0;
updateShowingPages();
}
@ -361,8 +361,8 @@ namespace
void updateShowingPages()
{
Book book;
unsigned int page;
unsigned int relPages;
size_t page;
size_t relPages;
if (!mStates.empty())
{
@ -415,9 +415,9 @@ namespace
Book topicBook = createTopicBook(linkId);
if (mStates.size() > 1)
replaceBook(topicBook, 0);
replaceBook(topicBook);
else
pushBook(topicBook, 0);
pushBook(topicBook);
setVisible(OptionsOverlay, false);
setVisible(OptionsBTN, true);
@ -447,9 +447,9 @@ namespace
Book book = createQuestBook(name);
if (mStates.size() > 1)
replaceBook(book, 0);
replaceBook(book);
else
pushBook(book, 0);
pushBook(book);
setVisible(OptionsOverlay, false);
setVisible(OptionsBTN, true);
@ -604,7 +604,7 @@ namespace
if (Settings::gui().mControllerMenus)
{
addControllerButtons(list, mSelectedQuest);
setControllerFocusedQuest(MWGui::wrap(mSelectedQuest, mButtons.size()));
setControllerFocusedQuest(std::min(mSelectedQuest, mButtons.size()));
}
if (mAllQuests)
@ -663,7 +663,7 @@ namespace
return;
if (!mStates.empty())
{
unsigned int& page = mStates.top().mPage;
size_t& page = mStates.top().mPage;
Book book = mStates.top().mBook;
if (page + 2 < book->pageCount())
@ -682,7 +682,7 @@ namespace
return;
if (!mStates.empty())
{
unsigned int& page = mStates.top().mPage;
size_t& page = mStates.top().mPage;
if (page >= 2)
{
@ -718,8 +718,8 @@ namespace
void setIndexControllerFocus(bool focused)
{
int col = mSelectedIndex / mIndexRowCount;
int row = mSelectedIndex % mIndexRowCount;
size_t col = mSelectedIndex / mIndexRowCount;
size_t row = mSelectedIndex % mIndexRowCount;
mTopicIndexBook->setColour(col, row, 0, focused ? MWGui::journalHeaderColour : MyGUI::Colour::Black);
}
@ -728,7 +728,7 @@ namespace
setIndexControllerFocus(false);
int numChars = mEncoding == ToUTF8::WINDOWS_1251 ? 30 : 26;
int col = mSelectedIndex / mIndexRowCount;
size_t col = mSelectedIndex / mIndexRowCount;
if (offset == -1) // Up
{
@ -836,7 +836,7 @@ namespace
return true;
// Scroll through the list of quests or topics
setControllerFocusedQuest(MWGui::wrap(mSelectedQuest - 1, mButtons.size()));
setControllerFocusedQuest(MWGui::wrap(mSelectedQuest, mButtons.size(), -1));
}
else
moveSelectedIndex(-1);
@ -849,19 +849,19 @@ namespace
return true;
// Scroll through the list of quests or topics
setControllerFocusedQuest(MWGui::wrap(mSelectedQuest + 1, mButtons.size()));
setControllerFocusedQuest(MWGui::wrap(mSelectedQuest, mButtons.size(), 1));
}
else
moveSelectedIndex(1);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && !mQuestMode && !mTopicsMode)
moveSelectedIndex(-mIndexRowCount);
moveSelectedIndex(-static_cast<int>(mIndexRowCount));
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mQuestMode && !mTopicsMode)
moveSelectedIndex(mIndexRowCount);
moveSelectedIndex(static_cast<int>(mIndexRowCount));
else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER && (mQuestMode || mTopicsMode))
{
// Scroll up 5 items in the list of quests or topics
setControllerFocusedQuest(std::max(static_cast<int>(mSelectedQuest) - 5, 0));
setControllerFocusedQuest(mSelectedQuest >= 5 ? mSelectedQuest - 5 : 0);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER && (mQuestMode || mTopicsMode))
{

View file

@ -36,10 +36,6 @@ namespace MWGui
size_t mIndexRowCount = 1;
size_t mSelectedQuest = 0;
size_t mSelectedIndex = 0;
void moveSelectedIndex(int offset);
void setIndexControllerFocus(bool focused);
void setControllerFocusedQuest(size_t index);
bool optionsModeButtonHandler(const SDL_ControllerButtonEvent& arg);
};
}

View file

@ -111,7 +111,7 @@ namespace MWGui
for (const ESM::Attribute& attribute : MWBase::Environment::get().getESMStore()->get<ESM::Attribute>())
{
int val = creatureStats.getAttribute(attribute.mId).getBase();
int val = static_cast<int>(creatureStats.getAttribute(attribute.mId).getBase());
if (std::find(mSpentAttributes.begin(), mSpentAttributes.end(), attribute.mId) != mSpentAttributes.end())
{
val += pcStats.getLevelupAttributeMultiplier(attribute.mId);
@ -202,8 +202,8 @@ namespace MWGui
widgets.mValue->setEnabled(true);
availableAttributes++;
float mult = pcStats.getLevelupAttributeMultiplier(attribute.mId);
mult = std::min(mult, 100 - pcStats.getAttribute(attribute.mId).getBase());
int mult = pcStats.getLevelupAttributeMultiplier(attribute.mId);
mult = std::min(mult, static_cast<int>(100 - pcStats.getAttribute(attribute.mId).getBase()));
if (mult <= 1)
widgets.mMultiplier->setCaption({});
else
@ -231,7 +231,7 @@ namespace MWGui
{
mControllerFocus = 0;
for (size_t i = 0; i < mAttributeButtons.size(); i++)
setControllerFocus(mAttributeButtons, i, i == 0);
mAttributeButtons[i]->setStateSelected(i == 0);
}
// Play LevelUp Music

View file

@ -120,8 +120,9 @@ namespace MWGui
void operator()(osg::RenderInfo& renderInfo) const override
{
int w = renderInfo.getCurrentCamera()->getViewport()->width();
int h = renderInfo.getCurrentCamera()->getViewport()->height();
const osg::Viewport* viewPort = renderInfo.getCurrentCamera()->getViewport();
int w = static_cast<int>(viewPort->width());
int h = static_cast<int>(viewPort->height());
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, w, h);
mOneshot = false;
@ -208,7 +209,8 @@ namespace MWGui
{
if (!mSplashScreens.empty())
{
std::string const& randomSplash = mSplashScreens.at(Misc::Rng::rollDice(mSplashScreens.size()));
std::string const& randomSplash
= mSplashScreens.at(Misc::Rng::rollDice(static_cast<int>(mSplashScreens.size())));
// TODO: add option (filename pattern?) to use image aspect ratio instead of 4:3
// we can't do this by default, because the Morrowind splash screens are 1024x1024, but should be displayed
@ -259,10 +261,10 @@ namespace MWGui
return false;
// the minimal delay before a loading screen shows
const float initialDelay = 0.05;
constexpr float initialDelay = 0.05f;
bool alreadyShown = (mLastRenderTime > mLoadingOnTime);
float diff = (mTimer.time_m() - mLoadingOnTime);
double diff = (mTimer.time_m() - mLoadingOnTime);
if (!alreadyShown)
{

View file

@ -71,7 +71,7 @@ namespace MWGui
size_t mProgress;
bool mShowWallpaper;
float mOldIcoMin = 0.f;
double mOldIcoMin = 0.0;
unsigned int mOldIcoMax = 0;
MyGUI::Widget* mLoadingBox;

View file

@ -364,10 +364,10 @@ namespace MWGui
// Trim off some of the excessive padding
// TODO: perhaps do this within ImageButton?
int height = requested.height;
button->setImageTile(MyGUI::IntSize(requested.width, requested.height - 16 * scale));
button->setCoord(
(maxwidth - requested.width / scale) / 2, curH, requested.width / scale, height / scale - 16);
curH += height / scale - 16;
button->setImageTile(MyGUI::IntSize(requested.width, static_cast<int>(requested.height - 16 * scale)));
button->setCoord(static_cast<int>((maxwidth - requested.width / scale) / 2), curH,
static_cast<int>(requested.width / scale), static_cast<int>(height / scale - 16));
curH += static_cast<int>(height / scale - 16);
}
if (state == MWBase::StateManager::State_NoGame)

View file

@ -92,7 +92,8 @@ namespace
return Constants::CellGridRadius;
if (!Settings::terrain().mDistantTerrain)
return Constants::CellGridRadius;
const int viewingDistanceInCells = Settings::camera().mViewingDistance / Constants::CellSizeInUnits;
const int viewingDistanceInCells
= static_cast<int>(Settings::camera().mViewingDistance / Constants::CellSizeInUnits);
return std::clamp(
viewingDistanceInCells, Constants::CellGridRadius, Settings::map().mMaxLocalViewingDistance.get());
}
@ -255,8 +256,8 @@ namespace MWGui
{
// normalized cell coordinates
auto mapWidgetSize = getWidgetSize();
return MyGUI::IntPoint(std::round((nX + cellX - mGrid.left) * mapWidgetSize),
std::round((nY - cellY + mGrid.bottom) * mapWidgetSize));
return MyGUI::IntPoint(static_cast<int>(std::round((nX + cellX - mGrid.left) * mapWidgetSize)),
static_cast<int>(std::round((nY - cellY + mGrid.bottom) * mapWidgetSize)));
}
MyGUI::IntPoint LocalMapBase::getMarkerPosition(float worldX, float worldY, MarkerUserData& markerPos) const
@ -286,7 +287,7 @@ namespace MWGui
}
MyGUI::IntCoord LocalMapBase::getMarkerCoordinates(
float worldX, float worldY, MarkerUserData& markerPos, size_t markerSize) const
float worldX, float worldY, MarkerUserData& markerPos, unsigned short markerSize) const
{
int halfMarkerSize = markerSize / 2;
auto position = getMarkerPosition(worldX, worldY, markerPos);
@ -320,7 +321,7 @@ namespace MWGui
mLocalMap->setViewOffset(viewOffset);
}
MyGUI::IntCoord LocalMapBase::getMarkerCoordinates(MyGUI::Widget* widget, size_t markerSize) const
MyGUI::IntCoord LocalMapBase::getMarkerCoordinates(MyGUI::Widget* widget, unsigned short markerSize) const
{
MarkerUserData& markerPos(*widget->getUserData<MarkerUserData>());
auto position = getPosition(markerPos.cellX, markerPos.cellY, markerPos.nX, markerPos.nY);
@ -453,7 +454,7 @@ namespace MWGui
}
if (oldSize != MyGUI::IntSize{ mGrid.width(), mGrid.height() })
setCanvasSize(mLocalMap, mGrid, getWidgetSize());
setCanvasSize(mLocalMap, mGrid, static_cast<int>(getWidgetSize()));
// Delay the door markers update until scripts have been given a chance to run.
// If we don't do this, door markers that should be disabled will still appear on the map.
@ -665,8 +666,7 @@ namespace MWGui
{
std::vector<std::string> destNotes;
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(marker.dest);
for (CustomMarkerCollection::ContainerType::const_iterator iter = markers.first; iter != markers.second;
++iter)
for (auto iter = markers.first; iter != markers.second; ++iter)
destNotes.push_back(iter->second.mNote);
MyGUI::Widget* markerWidget = nullptr;
@ -733,9 +733,10 @@ namespace MWGui
void LocalMapBase::updateLocalMap()
{
auto mapWidgetSize = getWidgetSize();
setCanvasSize(mLocalMap, mGrid, getWidgetSize());
setCanvasSize(mLocalMap, mGrid, static_cast<int>(getWidgetSize()));
const auto size = MyGUI::IntSize(std::ceil(mapWidgetSize), std::ceil(mapWidgetSize));
const auto size
= MyGUI::IntSize(static_cast<int>(std::ceil(mapWidgetSize)), static_cast<int>(std::ceil(mapWidgetSize)));
for (auto& entry : mMaps)
{
const auto position = getPosition(entry.mCellX, entry.mCellY, 0, 0);
@ -1570,7 +1571,7 @@ namespace MWGui
{
if (getDeleteButtonShown())
{
mControllerFocus = wrap(mControllerFocus - 1, 3);
mControllerFocus = wrap(mControllerFocus, 3, -1);
mDeleteButton->setStateSelected(mControllerFocus == 0);
mOkButton->setStateSelected(mControllerFocus == 1);
mCancelButton->setStateSelected(mControllerFocus == 2);
@ -1586,7 +1587,7 @@ namespace MWGui
{
if (getDeleteButtonShown())
{
mControllerFocus = wrap(mControllerFocus + 1, 3);
mControllerFocus = wrap(mControllerFocus, 3, 1);
mDeleteButton->setStateSelected(mControllerFocus == 0);
mOkButton->setStateSelected(mControllerFocus == 1);
mCancelButton->setStateSelected(mControllerFocus == 2);

View file

@ -163,9 +163,9 @@ namespace MWGui
MyGUI::IntPoint getPosition(int cellX, int cellY, float nx, float ny) const;
MyGUI::IntPoint getMarkerPosition(float worldX, float worldY, MarkerUserData& markerPos) const;
MyGUI::IntCoord getMarkerCoordinates(
float worldX, float worldY, MarkerUserData& markerPos, size_t markerSize) const;
float worldX, float worldY, MarkerUserData& markerPos, unsigned short markerSize) const;
MyGUI::Widget* createDoorMarker(const std::string& name, float x, float y) const;
MyGUI::IntCoord getMarkerCoordinates(MyGUI::Widget* widget, size_t markerSize) const;
MyGUI::IntCoord getMarkerCoordinates(MyGUI::Widget* widget, unsigned short markerSize) const;
virtual void notifyPlayerUpdate() {}
virtual void centerView();
@ -225,7 +225,7 @@ namespace MWGui
MyGUI::Button* mDeleteButton;
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
int mControllerFocus = 0;
size_t mControllerFocus = 0;
};
class MapWindow : public MWGui::WindowPinnableBase, public LocalMapBase, public NoDrop

View file

@ -191,7 +191,7 @@ namespace MWGui
return true;
mButtons[mControllerFocus].first->setStateSelected(false);
mControllerFocus = wrap(mControllerFocus - 1, mButtons.size());
mControllerFocus = wrap(mControllerFocus, mButtons.size(), -1);
mButtons[mControllerFocus].first->setStateSelected(true);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
@ -200,7 +200,7 @@ namespace MWGui
return true;
mButtons[mControllerFocus].first->setStateSelected(false);
mControllerFocus = wrap(mControllerFocus + 1, mButtons.size());
mControllerFocus = wrap(mControllerFocus, mButtons.size(), 1);
mButtons[mControllerFocus].first->setStateSelected(true);
}
@ -213,7 +213,7 @@ namespace MWGui
else
{
const int lineHeight = Settings::gui().mFontSize + 2;
mList->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5)));
mList->setViewOffset(MyGUI::IntPoint(0, -lineHeight * static_cast<int>(line - 5)));
}
}

View file

@ -473,7 +473,7 @@ namespace MWGui
return true;
setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus - 1, mButtons.size());
mControllerFocus = wrap(mControllerFocus, mButtons.size(), -1);
setControllerFocus(mButtons, mControllerFocus, true);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN || arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
@ -484,7 +484,7 @@ namespace MWGui
return true;
setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus + 1, mButtons.size());
mControllerFocus = wrap(mControllerFocus, mButtons.size(), 1);
setControllerFocus(mButtons, mControllerFocus, true);
}

View file

@ -290,8 +290,8 @@ namespace MWGui
if (texture)
scale = texture->getHeight() / 64.f;
mSelected->button->setFrame(
"textures\\menu_icon_select_magic_magic.dds", MyGUI::IntCoord(0, 0, 44 * scale, 44 * scale));
mSelected->button->setFrame("textures\\menu_icon_select_magic_magic.dds",
MyGUI::IntCoord(0, 0, static_cast<int>(44 * scale), static_cast<int>(44 * scale)));
mSelected->button->setIcon(item);
mSelected->button->setUserString("ToolTipType", "ItemPtr");
@ -562,9 +562,9 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
mParent->onCancelButtonClicked(mCancelButton);
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
mControllerFocus = wrap(mControllerFocus - 1, 4);
mControllerFocus = wrap(mControllerFocus, 4, -1);
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
mControllerFocus = wrap(mControllerFocus + 1, 4);
mControllerFocus = wrap(mControllerFocus, 4, 1);
mItemButton->setStateSelected(mControllerFocus == 0);
mMagicButton->setStateSelected(mControllerFocus == 1);

View file

@ -96,7 +96,7 @@ namespace MWGui
QuickKeysMenu* mParent;
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
int mControllerFocus = 0;
size_t mControllerFocus = 0;
};
class MagicSelectionDialog : public WindowModal
@ -117,7 +117,7 @@ namespace MWGui
void onModelIndexSelected(SpellModel::ModelIndex index);
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
int mControllerFocus = 0;
size_t mControllerFocus = 0;
};
}

View file

@ -256,7 +256,7 @@ namespace MWGui
void RaceDialog::onSelectPreviousGender(MyGUI::Widget*)
{
mGenderIndex = wrap(mGenderIndex - 1, 2);
mGenderIndex = wrap(mGenderIndex, 2, -1);
recountParts();
updatePreview();
@ -264,7 +264,7 @@ namespace MWGui
void RaceDialog::onSelectNextGender(MyGUI::Widget*)
{
mGenderIndex = wrap(mGenderIndex + 1, 2);
mGenderIndex = wrap(mGenderIndex, 2, 1);
recountParts();
updatePreview();
@ -272,25 +272,25 @@ namespace MWGui
void RaceDialog::onSelectPreviousFace(MyGUI::Widget*)
{
mFaceIndex = wrap(mFaceIndex - 1, mAvailableHeads.size());
mFaceIndex = wrap(mFaceIndex, mAvailableHeads.size(), -1);
updatePreview();
}
void RaceDialog::onSelectNextFace(MyGUI::Widget*)
{
mFaceIndex = wrap(mFaceIndex + 1, mAvailableHeads.size());
mFaceIndex = wrap(mFaceIndex, mAvailableHeads.size(), 1);
updatePreview();
}
void RaceDialog::onSelectPreviousHair(MyGUI::Widget*)
{
mHairIndex = wrap(mHairIndex - 1, mAvailableHairs.size());
mHairIndex = wrap(mHairIndex, mAvailableHairs.size(), -1);
updatePreview();
}
void RaceDialog::onSelectNextHair(MyGUI::Widget*)
{
mHairIndex = wrap(mHairIndex + 1, mAvailableHairs.size());
mHairIndex = wrap(mHairIndex, mAvailableHairs.size(), 1);
updatePreview();
}
@ -359,10 +359,10 @@ namespace MWGui
record.mRace = mCurrentRaceId;
record.setIsMale(mGenderIndex == 0);
if (mFaceIndex >= 0 && mFaceIndex < int(mAvailableHeads.size()))
if (mFaceIndex >= 0 && mFaceIndex < mAvailableHeads.size())
record.mHead = mAvailableHeads[mFaceIndex];
if (mHairIndex >= 0 && mHairIndex < int(mAvailableHairs.size()))
if (mHairIndex >= 0 && mHairIndex < mAvailableHairs.size())
record.mHair = mAvailableHairs[mHairIndex];
try

View file

@ -110,7 +110,7 @@ namespace MWGui
MyGUI::Widget* mSpellPowerList;
std::vector<MyGUI::Widget*> mSpellPowerItems;
int mGenderIndex, mFaceIndex, mHairIndex;
size_t mGenderIndex, mFaceIndex, mHairIndex;
ESM::RefId mCurrentRaceId;

View file

@ -381,8 +381,8 @@ namespace MWGui
}
const MWMechanics::SkillValue& stat = skillValue->second;
int base = stat.getBase();
int modified = stat.getModified();
float base = stat.getBase();
float modified = stat.getModified();
std::string state = "normal";
if (modified > base)
@ -577,13 +577,13 @@ namespace MWGui
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());
mControllerFocus = wrap(mControllerFocus, mButtons.size(), -1);
setControllerFocus(mButtons, mControllerFocus, true);
}
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());
mControllerFocus = wrap(mControllerFocus, mButtons.size(), 1);
setControllerFocus(mButtons, mControllerFocus, true);
}

View file

@ -104,7 +104,7 @@ namespace MWGui
// 0 = Name, 1 = Race, 2 = Class, 3 = BirthSign, 4 = Back, 5 = OK
std::vector<MyGUI::Button*> mButtons;
int mControllerFocus = 0;
size_t mControllerFocus = 0;
};
}
#endif

View file

@ -549,7 +549,7 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_Y)
{
size_t index = mCharacterSelection->getIndexSelected();
index = wrap(index + 1, mCharacterSelection->getItemCount());
index = wrap(index, mCharacterSelection->getItemCount(), 1);
mCharacterSelection->setIndexSelected(index);
onCharacterSelected(mCharacterSelection, index);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));

View file

@ -1144,7 +1144,7 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER)
{
size_t index = mSettingsTab->getIndexSelected();
index = wrap(index - 1, mSettingsTab->getItemCount());
index = wrap(index, mSettingsTab->getItemCount(), -1);
mSettingsTab->setIndexSelected(index);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
return true;
@ -1152,7 +1152,7 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
{
size_t index = mSettingsTab->getIndexSelected();
index = wrap(index + 1, mSettingsTab->getItemCount());
index = wrap(index, mSettingsTab->getItemCount(), 1);
mSettingsTab->setIndexSelected(index);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
return true;

View file

@ -79,8 +79,6 @@ namespace
if (mSortByType && left.mType != right.mType)
return left.mType < right.mType;
float result = 0;
// compare items by type
auto leftType = left.mBase.getType();
auto rightType = right.mBase.getType();
@ -92,9 +90,11 @@ namespace
std::string leftName = Utf8Stream::lowerCaseUtf8(left.mBase.getClass().getName(left.mBase));
std::string rightName = Utf8Stream::lowerCaseUtf8(right.mBase.getClass().getName(right.mBase));
result = leftName.compare(rightName);
if (result != 0)
return result < 0;
{
int result = leftName.compare(rightName);
if (result != 0)
return result < 0;
}
// compare items by enchantment:
// 1. enchanted items showed before non-enchanted
@ -133,32 +133,38 @@ namespace
}
}
result = leftChargePercent - rightChargePercent;
if (result != 0)
return result > 0;
{
int result = leftChargePercent - rightChargePercent;
if (result != 0)
return result > 0;
}
// compare items by condition
if (left.mBase.getClass().hasItemHealth(left.mBase) && right.mBase.getClass().hasItemHealth(right.mBase))
{
result = left.mBase.getClass().getItemHealth(left.mBase)
int result = left.mBase.getClass().getItemHealth(left.mBase)
- right.mBase.getClass().getItemHealth(right.mBase);
if (result != 0)
return result > 0;
}
// compare items by remaining usage time
result = left.mBase.getClass().getRemainingUsageTime(left.mBase)
- right.mBase.getClass().getRemainingUsageTime(right.mBase);
if (result != 0)
return result > 0;
{
float result = left.mBase.getClass().getRemainingUsageTime(left.mBase)
- right.mBase.getClass().getRemainingUsageTime(right.mBase);
if (result != 0)
return result > 0;
}
// compare items by value
result = left.mBase.getClass().getValue(left.mBase) - right.mBase.getClass().getValue(right.mBase);
if (result != 0)
return result > 0;
{
int result = left.mBase.getClass().getValue(left.mBase) - right.mBase.getClass().getValue(right.mBase);
if (result != 0)
return result > 0;
}
// compare items by weight
result = left.mBase.getClass().getWeight(left.mBase) - right.mBase.getClass().getWeight(right.mBase);
float result = left.mBase.getClass().getWeight(left.mBase) - right.mBase.getClass().getWeight(right.mBase);
if (result != 0)
return result > 0;
@ -377,16 +383,15 @@ namespace MWGui
mItems.clear();
for (size_t i = 0; i < count; ++i)
{
ItemStack item = mSourceModel->getItem(i);
ItemStack item = mSourceModel->getItem(static_cast<ModelIndex>(i));
for (std::vector<std::pair<MWWorld::Ptr, size_t>>::iterator it = mDragItems.begin(); it != mDragItems.end();
++it)
for (const std::pair<MWWorld::Ptr, size_t>& drag : mDragItems)
{
if (item.mBase == it->first)
if (item.mBase == drag.first)
{
if (item.mCount < it->second)
if (item.mCount < drag.second)
throw std::runtime_error("Dragging more than present in the model");
item.mCount -= it->second;
item.mCount -= drag.second;
}
}

View file

@ -254,7 +254,7 @@ namespace MWGui
return true;
mSpellButtons[mControllerFocus].first->setStateSelected(false);
mControllerFocus = wrap(mControllerFocus - 1, mSpellButtons.size());
mControllerFocus = wrap(mControllerFocus, mSpellButtons.size(), -1);
mSpellButtons[mControllerFocus].first->setStateSelected(true);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
@ -265,7 +265,7 @@ namespace MWGui
return true;
mSpellButtons[mControllerFocus].first->setStateSelected(false);
mControllerFocus = wrap(mControllerFocus + 1, mSpellButtons.size());
mControllerFocus = wrap(mControllerFocus, mSpellButtons.size(), 1);
mSpellButtons[mControllerFocus].first->setStateSelected(true);
}
else
@ -280,7 +280,7 @@ namespace MWGui
else
{
const int lineHeight = Settings::gui().mFontSize + 2;
mSpellsView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5)));
mSpellsView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * static_cast<int>(line - 5)));
}
// Warp the mouse to the selected spell to show the tooltip

View file

@ -224,7 +224,7 @@ namespace MWGui
mEffectName->setCaptionWithReplacing("#{" + ESM::MagicEffect::indexToGmstString(effect->mIndex) + "}");
mEffect.mEffectID = effect->mIndex;
mEffect.mEffectID = static_cast<int16_t>(effect->mIndex);
mMagicEffect = effect;
@ -333,13 +333,13 @@ namespace MWGui
void EditEffectDialog::setSkill(ESM::RefId skill)
{
mEffect.mSkill = ESM::Skill::refIdToIndex(skill);
mEffect.mSkill = static_cast<signed char>(ESM::Skill::refIdToIndex(skill));
eventEffectModified(mEffect);
}
void EditEffectDialog::setAttribute(ESM::RefId attribute)
{
mEffect.mAttribute = ESM::Attribute::refIdToIndex(attribute);
mEffect.mAttribute = static_cast<signed char>(ESM::Attribute::refIdToIndex(attribute));
eventEffectModified(mEffect);
}
@ -772,7 +772,7 @@ namespace MWGui
mAddEffectDialog.setVisible(false);
}
EffectEditorBase::~EffectEditorBase() {}
EffectEditorBase::~EffectEditorBase() = default;
void EffectEditorBase::startEditing()
{
@ -1044,12 +1044,12 @@ namespace MWGui
if (arg.button == SDL_CONTROLLER_BUTTON_A)
{
if (!mRightColumn && mAvailableFocus >= 0 && mAvailableFocus < static_cast<int>(mAvailableButtons.size()))
if (!mRightColumn && mAvailableFocus < mAvailableButtons.size())
{
onAvailableEffectClicked(mAvailableButtons[mAvailableFocus]);
winMgr->playSound(ESM::RefId::stringRefId("Menu Click"));
}
else if (mRightColumn && mEffectFocus >= 0 && mEffectFocus < static_cast<int>(mEffectButtons.size()))
else if (mRightColumn && mEffectFocus < mEffectButtons.size())
{
onEditEffect(mEffectButtons[mEffectFocus].second);
winMgr->playSound(ESM::RefId::stringRefId("Menu Click"));
@ -1062,44 +1062,44 @@ namespace MWGui
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
{
if (mRightColumn && mEffectButtons.size() > 0)
if (mRightColumn && !mEffectButtons.empty())
{
if (mEffectFocus >= 0 && mEffectFocus < static_cast<int>(mEffectButtons.size()))
if (mEffectFocus < mEffectButtons.size())
mEffectButtons[mEffectFocus].first->setStateSelected(false);
mEffectFocus = wrap(mEffectFocus - 1, mEffectButtons.size());
mEffectFocus = wrap(mEffectFocus, mEffectButtons.size(), -1);
mEffectButtons[mEffectFocus].first->setStateSelected(true);
}
else if (!mRightColumn && mAvailableButtons.size() > 0)
else if (!mRightColumn && !mAvailableButtons.empty())
{
if (mAvailableFocus >= 0 && mAvailableFocus < static_cast<int>(mAvailableButtons.size()))
if (mAvailableFocus < mAvailableButtons.size())
mAvailableButtons[mAvailableFocus]->setStateSelected(false);
mAvailableFocus = wrap(mAvailableFocus - 1, mAvailableButtons.size());
mAvailableFocus = wrap(mAvailableFocus, mAvailableButtons.size(), -1);
mAvailableButtons[mAvailableFocus]->setStateSelected(true);
}
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
{
if (mRightColumn && mEffectButtons.size() > 0)
if (mRightColumn && !mEffectButtons.empty())
{
if (mEffectFocus >= 0 && mEffectFocus < static_cast<int>(mEffectButtons.size()))
if (mEffectFocus < mEffectButtons.size())
mEffectButtons[mEffectFocus].first->setStateSelected(false);
mEffectFocus = wrap(mEffectFocus + 1, mEffectButtons.size());
mEffectFocus = wrap(mEffectFocus, mEffectButtons.size(), 1);
mEffectButtons[mEffectFocus].first->setStateSelected(true);
}
else if (!mRightColumn && mAvailableButtons.size() > 0)
else if (!mRightColumn && !mAvailableButtons.empty())
{
if (mAvailableFocus >= 0 && mAvailableFocus < static_cast<int>(mAvailableButtons.size()))
if (mAvailableFocus < mAvailableButtons.size())
mAvailableButtons[mAvailableFocus]->setStateSelected(false);
mAvailableFocus = wrap(mAvailableFocus + 1, mAvailableButtons.size());
mAvailableFocus = wrap(mAvailableFocus, mAvailableButtons.size(), 1);
mAvailableButtons[mAvailableFocus]->setStateSelected(true);
}
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && mRightColumn)
{
mRightColumn = false;
if (mEffectFocus >= 0 && mEffectFocus < static_cast<int>(mEffectButtons.size()))
if (mEffectFocus < mEffectButtons.size())
mEffectButtons[mEffectFocus].first->setStateSelected(false);
if (mAvailableFocus >= 0 && mAvailableFocus < static_cast<int>(mAvailableButtons.size()))
if (mAvailableFocus < mAvailableButtons.size())
mAvailableButtons[mAvailableFocus]->setStateSelected(true);
winMgr->setControllerTooltipVisible(Settings::gui().mControllerTooltips);
@ -1107,9 +1107,9 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mRightColumn && mEffectButtons.size() > 0)
{
mRightColumn = true;
if (mAvailableFocus >= 0 && mAvailableFocus < static_cast<int>(mAvailableButtons.size()))
if (mAvailableFocus < mAvailableButtons.size())
mAvailableButtons[mAvailableFocus]->setStateSelected(false);
if (mEffectFocus >= 0 && mEffectFocus < static_cast<int>(mEffectButtons.size()))
if (mEffectFocus < mEffectButtons.size())
mEffectButtons[mEffectFocus].first->setStateSelected(true);
winMgr->setControllerTooltipVisible(false);
@ -1123,10 +1123,10 @@ namespace MWGui
else
{
const int lineHeight = Settings::gui().mFontSize + 3;
mAvailableEffectsList->setViewOffset(-lineHeight * (mAvailableFocus - 5));
mAvailableEffectsList->setViewOffset(-lineHeight * static_cast<int>(mAvailableFocus - 5));
}
if (!mRightColumn && mAvailableFocus >= 0 && mAvailableFocus < static_cast<int>(mAvailableButtons.size()))
if (!mRightColumn && mAvailableFocus < mAvailableButtons.size())
{
// Warp the mouse to the selected spell to show the tooltip
if (winMgr->getControllerTooltipVisible())

View file

@ -153,9 +153,9 @@ namespace MWGui
private:
Type mType;
int mAvailableFocus;
int mEffectFocus;
bool mRightColumn;
size_t mAvailableFocus = 0;
size_t mEffectFocus = 0;
bool mRightColumn = false;
std::vector<MyGUI::Button*> mAvailableButtons;
std::vector<std::pair<Widgets::MWSpellEffectPtr, MyGUI::Button*>> mEffectButtons;
};

View file

@ -19,8 +19,6 @@
namespace MWGui
{
const char* SpellView::sSpellModelIndex = "SpellModelIndex";
SpellView::LineInfo::LineInfo(
MyGUI::Widget* leftWidget, MyGUI::Widget* rightWidget, SpellModel::ModelIndex spellIndex)
: mLeftWidget(leftWidget)
@ -29,15 +27,6 @@ namespace MWGui
{
}
SpellView::SpellView()
: mScrollView(nullptr)
, mShowCostColumn(true)
, mHighlightSelected(true)
, mControllerActiveWindow(false)
, mControllerFocus(0)
{
}
void SpellView::initialiseOverride()
{
Base::initialiseOverride();
@ -126,7 +115,7 @@ namespace MWGui
t->setCaption(spell.mName + captionSuffix);
t->setTextAlign(MyGUI::Align::Left);
adjustSpellWidget(spell, i, t);
mButtons.emplace_back(std::make_pair(t, i));
mButtons.emplace_back(t, i);
if (!spell.mCostColumn.empty() && mShowCostColumn)
{
@ -235,8 +224,8 @@ namespace MWGui
if (Settings::gui().mControllerMenus)
{
mControllerFocus = wrap(mControllerFocus, mButtons.size());
updateControllerFocus(-1, mControllerFocus);
mControllerFocus = std::min(mControllerFocus, mButtons.size());
updateControllerFocus(mButtons.size(), mControllerFocus);
}
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the
@ -307,7 +296,7 @@ namespace MWGui
widget->setUserString("Spell", spell.mId.serialize());
}
widget->setUserString(sSpellModelIndex, MyGUI::utility::toString(index));
widget->setUserString("SpellModelIndex", MyGUI::utility::toString(index));
widget->eventMouseWheel += MyGUI::newDelegate(this, &SpellView::onMouseWheelMoved);
widget->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellView::onSpellSelected);
@ -315,7 +304,7 @@ namespace MWGui
SpellModel::ModelIndex SpellView::getSpellModelIndex(MyGUI::Widget* widget)
{
return MyGUI::utility::parseInt(widget->getUserString(sSpellModelIndex));
return MyGUI::utility::parseInt(widget->getUserString("SpellModelIndex"));
}
void SpellView::onSpellSelected(MyGUI::Widget* sender)
@ -349,14 +338,14 @@ namespace MWGui
if (mButtons.empty())
return;
int prevFocus = mControllerFocus;
size_t prevFocus = mControllerFocus;
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
int delta = 0;
switch (button)
{
case SDL_CONTROLLER_BUTTON_A:
// Select the focused item, if any.
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mButtons.size()))
if (mControllerFocus < mButtons.size())
{
onSpellSelected(mButtons[mControllerFocus].first);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
@ -368,25 +357,25 @@ namespace MWGui
break;
case SDL_CONTROLLER_BUTTON_DPAD_UP:
winMgr->restoreControllerTooltips();
mControllerFocus--;
delta = -1;
break;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
winMgr->restoreControllerTooltips();
mControllerFocus++;
delta = 1;
break;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
winMgr->restoreControllerTooltips();
mControllerFocus = std::max(0, mControllerFocus - 10);
delta = -10;
break;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
winMgr->restoreControllerTooltips();
mControllerFocus = std::min(mControllerFocus + 10, static_cast<int>(mButtons.size()) - 1);
delta = 10;
break;
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
{
// Jump to first item in previous group
int prevGroupIndex = 0;
for (int groupIndex : mGroupIndices)
size_t prevGroupIndex = 0;
for (size_t groupIndex : mGroupIndices)
{
if (groupIndex >= mControllerFocus)
break;
@ -399,8 +388,8 @@ namespace MWGui
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
{
// Jump to first item in next group
int newFocus = mControllerFocus;
for (int groupIndex : mGroupIndices)
size_t newFocus = mControllerFocus;
for (size_t groupIndex : mGroupIndices)
{
if (groupIndex > mControllerFocus)
{
@ -418,27 +407,27 @@ namespace MWGui
return;
}
mControllerFocus = wrap(mControllerFocus, mButtons.size());
mControllerFocus = wrap(mControllerFocus, mButtons.size(), delta);
if (prevFocus != mControllerFocus)
updateControllerFocus(prevFocus, mControllerFocus);
else
updateControllerFocus(-1, mControllerFocus);
updateControllerFocus(mButtons.size(), mControllerFocus);
}
void SpellView::updateControllerFocus(int prevFocus, int newFocus)
void SpellView::updateControllerFocus(size_t prevFocus, size_t newFocus)
{
if (mButtons.empty())
return;
if (prevFocus >= 0 && prevFocus < static_cast<int>(mButtons.size()))
if (prevFocus < mButtons.size())
{
Gui::SharedStateButton* prev = mButtons[prevFocus].first;
if (prev)
prev->onMouseLostFocus(nullptr);
}
if (mControllerActiveWindow && newFocus >= 0 && newFocus < static_cast<int>(mButtons.size()))
if (mControllerActiveWindow && newFocus < mButtons.size())
{
Gui::SharedStateButton* focused = mButtons[newFocus].first;
if (focused)

View file

@ -28,7 +28,7 @@ namespace MWGui
{
MYGUI_RTTI_DERIVED(SpellView)
public:
SpellView();
SpellView() {};
/// Register needed components with MyGUI's factory manager
static void registerComponents();
@ -63,8 +63,6 @@ namespace MWGui
void onControllerButton(const unsigned char button);
private:
MyGUI::ScrollView* mScrollView;
std::unique_ptr<SpellModel> mModel;
/// tracks a row in the spell view
@ -90,28 +88,27 @@ namespace MWGui
std::vector<LineInfo> mLines;
bool mShowCostColumn;
bool mHighlightSelected;
/// Keep a list of buttons for controller navigation and their index in the full list.
std::vector<std::pair<Gui::SharedStateButton*, int>> mButtons;
/// Keep a list of group offsets for controller navigation
std::vector<size_t> mGroupIndices;
MyGUI::ScrollView* mScrollView = nullptr;
size_t mControllerFocus = 0;
bool mShowCostColumn = true;
bool mHighlightSelected = true;
bool mControllerActiveWindow = false;
void layoutWidgets();
void addGroup(const std::string& label1, const std::string& label2);
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;
/// Keep a list of group offsets for controller navigation
std::vector<int> mGroupIndices;
bool mControllerActiveWindow;
int mControllerFocus;
void updateControllerFocus(int prevFocus, int newFocus);
void updateControllerFocus(size_t prevFocus, size_t newFocus);
void onSpellSelected(MyGUI::Widget* sender);
void onMouseWheelMoved(MyGUI::Widget* sender, int rel);
SpellModel::ModelIndex getSpellModelIndex(MyGUI::Widget* sender);
static const char* sSpellModelIndex;
};
}

View file

@ -255,7 +255,7 @@ namespace MWGui
return;
mSpellView->setModel(new SpellModel(MWMechanics::getPlayer()));
int itemCount = mSpellView->getModel()->getItemCount();
int itemCount = static_cast<int>(mSpellView->getModel()->getItemCount());
if (itemCount == 0)
return;

View file

@ -258,8 +258,8 @@ namespace MWGui
MyGUI::TextBox* nameWidget = widgets.first;
if (valueWidget && nameWidget)
{
int modified = value.getModified(), base = value.getBase();
std::string text = MyGUI::utility::toString(modified);
float modified = value.getModified(), base = value.getBase();
std::string text = MyGUI::utility::toString(static_cast<int>(modified));
std::string state = "normal";
if (modified > base)
state = "increased";
@ -341,8 +341,8 @@ namespace MWGui
bool first = true;
for (const auto& attribute : store->get<ESM::Attribute>())
{
float mult = playerStats.getLevelupAttributeMultiplier(attribute.mId);
mult = std::min(mult, 100 - playerStats.getAttribute(attribute.mId).getBase());
int mult = playerStats.getLevelupAttributeMultiplier(attribute.mId);
mult = std::min(mult, static_cast<int>(100 - playerStats.getAttribute(attribute.mId).getBase()));
if (mult > 1)
{
if (!first)

View file

@ -298,7 +298,7 @@ namespace MWGui
const ItemStack& item = mSortModel->getItem(index);
MWWorld::Ptr object = item.mBase;
int count = item.mCount;
size_t count = item.mCount;
bool shift = MyGUI::InputManager::getInstance().isShiftPressed();
if (MyGUI::InputManager::getInstance().isControlPressed())
count = 1;
@ -309,7 +309,7 @@ namespace MWGui
std::string message = "#{sQuanityMenuMessage02}";
std::string name{ object.getClass().getName(object) };
name += MWGui::ToolTips::getSoulString(object.getCellRef());
dialog->openCountDialog(name, message, count);
dialog->openCountDialog(name, message, static_cast<int>(count));
dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &TradeWindow::sellItem);
mItemToSell = mSortModel->mapToSource(index);
@ -335,14 +335,14 @@ namespace MWGui
// this was an item borrowed to us by the player
mTradeModel->returnItemBorrowedToUs(mItemToSell, count);
playerTradeModel->returnItemBorrowedFromUs(mItemToSell, mTradeModel, count);
buyFromNpc(item.mBase, count, true);
updateOffer();
}
else
{
// borrow item to player
playerTradeModel->borrowItemToUs(mItemToSell, mTradeModel, count);
mTradeModel->borrowItemFromUs(mItemToSell, count);
buyFromNpc(item.mBase, count, false);
updateOffer();
}
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->updateItemView();
@ -355,17 +355,16 @@ namespace MWGui
= MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
mTradeModel->borrowItemToUs(index, playerTradeModel, count);
mItemView->update();
sellToNpc(playerTradeModel->getItem(index).mBase, count, false);
updateOffer();
}
void TradeWindow::returnItem(int index, size_t count)
{
TradeItemModel* playerTradeModel
= MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
const ItemStack& item = playerTradeModel->getItem(index);
mTradeModel->returnItemBorrowedFromUs(index, playerTradeModel, count);
mItemView->update();
sellToNpc(item.mBase, count, true);
updateOffer();
}
void TradeWindow::addOrRemoveGold(int amount, const MWWorld::Ptr& actor)
@ -648,16 +647,6 @@ namespace MWGui
updateLabels();
}
void TradeWindow::sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem)
{
updateOffer();
}
void TradeWindow::buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem)
{
updateOffer();
}
void TradeWindow::onReferenceUnavailable()
{
// remove both Trade and Dialogue (since you always trade with the NPC/creature that you have previously talked

View file

@ -90,11 +90,6 @@ namespace MWGui
bool mUpdateNextFrame;
void sellToNpc(
const MWWorld::Ptr& item, int count, bool boughtItem); ///< only used for adjusting the gold balance
void buyFromNpc(
const MWWorld::Ptr& item, int count, bool soldItem); ///< only used for adjusting the gold balance
void updateOffer();
void onItemSelected(int index);

View file

@ -123,7 +123,7 @@ namespace MWGui
MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>(price <= playerGold
? "SandTextButton"
: "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
MyGUI::IntCoord(4, 3 + i * lineHeight, mTrainingOptions->getWidth() - 10, lineHeight),
MyGUI::IntCoord(4, static_cast<int>(3 + i * lineHeight), mTrainingOptions->getWidth() - 10, lineHeight),
MyGUI::Align::Default);
button->setUserData(skills[i].first);
@ -169,8 +169,8 @@ namespace MWGui
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
int price = pcStats.getSkill(skill->mId).getBase()
* store.get<ESM::GameSetting>().find("iTrainingMod")->mValue.getInteger();
int price = static_cast<int>(pcStats.getSkill(skill->mId).getBase()
* store.get<ESM::GameSetting>().find("iTrainingMod")->mValue.getInteger());
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, price, true);
if (price > player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId))
@ -263,7 +263,7 @@ namespace MWGui
return true;
setControllerFocus(mTrainingButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus - 1, mTrainingButtons.size());
mControllerFocus = wrap(mControllerFocus, mTrainingButtons.size(), -1);
setControllerFocus(mTrainingButtons, mControllerFocus, true);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
@ -272,7 +272,7 @@ namespace MWGui
return true;
setControllerFocus(mTrainingButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus + 1, mTrainingButtons.size());
mControllerFocus = wrap(mControllerFocus, mTrainingButtons.size(), 1);
setControllerFocus(mTrainingButtons, mControllerFocus, true);
}

View file

@ -63,8 +63,8 @@ namespace MWGui
else
{
const ESM::Position playerPos = player.getRefData().getPosition();
float d = sqrt(pow(pos.pos[0] - playerPos.pos[0], 2) + pow(pos.pos[1] - playerPos.pos[1], 2)
+ pow(pos.pos[2] - playerPos.pos[2], 2));
double d = std::sqrt(std::pow(pos.pos[0] - playerPos.pos[0], 2) + std::pow(pos.pos[1] - playerPos.pos[1], 2)
+ std::pow(pos.pos[2] - playerPos.pos[2], 2));
float fTravelMult = gmst.find("fTravelMult")->mValue.getFloat();
if (fTravelMult != 0)
price = static_cast<int>(d / fTravelMult);
@ -207,10 +207,10 @@ namespace MWGui
= (osg::Vec3f(pos.pos[0], pos.pos[1], 0) - osg::Vec3f(playerPos.pos[0], playerPos.pos[1], 0)).length();
int hours = static_cast<int>(d
/ MWBase::Environment::get()
.getESMStore()
->get<ESM::GameSetting>()
.find("fTravelTimeMult")
->mValue.getFloat());
.getESMStore()
->get<ESM::GameSetting>()
.find("fTravelTimeMult")
->mValue.getFloat());
MWBase::Environment::get().getMechanicsManager()->rest(hours, true);
MWBase::Environment::get().getWorld()->advanceTime(hours);
}
@ -279,7 +279,7 @@ namespace MWGui
return true;
setControllerFocus(mDestinationButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus - 1, mDestinationButtons.size());
mControllerFocus = wrap(mControllerFocus, mDestinationButtons.size(), -1);
setControllerFocus(mDestinationButtons, mControllerFocus, true);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
@ -288,7 +288,7 @@ namespace MWGui
return true;
setControllerFocus(mDestinationButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus + 1, mDestinationButtons.size());
mControllerFocus = wrap(mControllerFocus, mDestinationButtons.size(), 1);
setControllerFocus(mDestinationButtons, mControllerFocus, true);
}
@ -298,7 +298,7 @@ namespace MWGui
else
{
const int lineHeight = Settings::gui().mFontSize + 2;
mDestinationsView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (mControllerFocus - 5)));
mDestinationsView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * static_cast<int>(mControllerFocus - 5)));
}
return true;

View file

@ -239,7 +239,7 @@ namespace MWGui
void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position)
{
mHourText->setCaptionWithReplacing(MyGUI::utility::toString(position + 1) + " #{sRestMenu2}");
mManualHours = position + 1;
mManualHours = static_cast<int>(position + 1);
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mWaitButton);
}

View file

@ -15,19 +15,28 @@
using namespace MWGui;
int MWGui::wrap(int index, int max)
size_t MWGui::wrap(size_t index, size_t max, int delta)
{
if (index < 0)
return max - 1;
else if (index >= max)
if (delta >= 0)
{
unsigned absDelta = static_cast<unsigned>(delta);
if (absDelta >= max)
return 0;
else if (index >= max - absDelta)
return 0;
return index + absDelta;
}
unsigned absDelta = static_cast<unsigned>(-delta);
if (index >= absDelta)
return index - absDelta;
else if (max == 0)
return 0;
else
return index;
return max - 1;
}
void MWGui::setControllerFocus(const std::vector<MyGUI::Button*>& buttons, int index, bool focused)
void MWGui::setControllerFocus(const std::vector<MyGUI::Button*>& buttons, size_t index, bool focused)
{
if (index >= 0 && index < static_cast<int>(buttons.size()))
if (index < buttons.size())
buttons[index]->setStateSelected(focused);
}
@ -199,16 +208,14 @@ float BookWindowBase::adjustButton(std::string_view name)
WindowBase::getWidget(button, name);
MyGUI::IntSize requested = button->getRequestedSize();
float scale = float(requested.height) / button->getSize().height;
MyGUI::IntSize newSize = requested;
newSize.width /= scale;
newSize.height /= scale;
MyGUI::IntSize newSize(static_cast<int>(requested.width / scale), static_cast<int>(requested.height / scale));
button->setSize(newSize);
if (button->getAlign().isRight())
{
MyGUI::IntSize diff = (button->getSize() - requested);
diff.width /= scale;
diff.height /= scale;
diff.width = static_cast<int>(diff.width / scale);
diff.height = static_cast<int>(diff.height / scale);
button->setPosition(button->getPosition() + MyGUI::IntPoint(diff.width, 0));
}

View file

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

View file

@ -903,11 +903,11 @@ namespace MWGui
{
GuiMode mode = mGuiModes.back();
GuiModeState& state = mGuiModeStates[mode];
if (state.mWindows.size() == 0)
if (state.mWindows.empty())
return nullptr;
int activeIndex
= std::clamp(mActiveControllerWindows[mode], 0, static_cast<int>(state.mWindows.size()) - 1);
size_t activeIndex
= std::clamp<size_t>(mActiveControllerWindows[mode], 0, state.mWindows.size() - 1);
// If the active window is no longer visible, find the next visible window.
if (!state.mWindows[activeIndex]->isVisible())
@ -925,18 +925,18 @@ namespace MWGui
return;
GuiMode mode = mGuiModes.back();
int winCount = mGuiModeStates[mode].mWindows.size();
size_t winCount = mGuiModeStates[mode].mWindows.size();
int activeIndex = 0;
size_t activeIndex = 0;
if (winCount > 1)
{
// Find next/previous visible window
activeIndex = mActiveControllerWindows[mode];
int delta = next ? 1 : -1;
for (int i = 0; i < winCount; i++)
for (size_t i = 0; i < winCount; ++i)
{
activeIndex = wrap(activeIndex + delta, winCount);
activeIndex = wrap(activeIndex, winCount, delta);
if (mGuiModeStates[mode].mWindows[activeIndex]->isVisible())
break;
}
@ -952,9 +952,9 @@ namespace MWGui
return;
const GuiMode mode = mGuiModes.back();
int winCount = mGuiModeStates[mode].mWindows.size();
size_t winCount = mGuiModeStates[mode].mWindows.size();
for (int i = 0; i < winCount; i++)
for (size_t i = 0; i < winCount; i++)
{
// Set active window last so inactive windows don't stomp on changes it makes, e.g. to tooltips.
if (i != mActiveControllerWindows[mode])
@ -964,16 +964,16 @@ namespace MWGui
mGuiModeStates[mode].mWindows[mActiveControllerWindows[mode]]->setActiveControllerWindow(true);
}
void WindowManager::setActiveControllerWindow(GuiMode mode, int activeIndex)
void WindowManager::setActiveControllerWindow(GuiMode mode, size_t activeIndex)
{
if (!Settings::gui().mControllerMenus)
return;
int winCount = mGuiModeStates[mode].mWindows.size();
size_t winCount = mGuiModeStates[mode].mWindows.size();
if (winCount == 0)
return;
activeIndex = std::clamp(activeIndex, 0, winCount - 1);
activeIndex = std::clamp<size_t>(activeIndex, 0, winCount - 1);
mActiveControllerWindows[mode] = activeIndex;
reapplyActiveControllerWindow();
@ -1437,7 +1437,8 @@ namespace MWGui
if (mode == GM_Container)
mActiveControllerWindows[mode] = 0; // Ensure controller focus is on container
// Activate first visible window. This needs to be called after updateVisible.
mActiveControllerWindows[mode] = std::max(mActiveControllerWindows[mode] - 1, -1);
if (mActiveControllerWindows[mode] != 0)
mActiveControllerWindows[mode] = mActiveControllerWindows[mode] - 1;
cycleActiveControllerWindow(true);
}
}

View file

@ -394,7 +394,7 @@ namespace MWGui
WindowBase* getActiveControllerWindow() override;
int getControllerMenuHeight() override;
void cycleActiveControllerWindow(bool next) override;
void setActiveControllerWindow(GuiMode mode, int activeIndex) override;
void setActiveControllerWindow(GuiMode mode, size_t activeIndex) override;
bool getControllerTooltipVisible() const override { return mControllerTooltipVisible; }
void setControllerTooltipVisible(bool visible) override;
bool getControllerTooltipEnabled() const override { return mControllerTooltipEnabled; }
@ -513,7 +513,7 @@ namespace MWGui
// The currently active stack of GUI modes (top mode is the one we are in).
std::vector<GuiMode> mGuiModes;
// The active window for controller mode for each GUI mode.
std::map<GuiMode, int> mActiveControllerWindows;
std::map<GuiMode, size_t> mActiveControllerWindows;
// Current tooltip visibility state (can be disabled by mouse movement)
bool mControllerTooltipVisible = false;
// User preference for tooltips (persists across mouse/controller switches)

View file

@ -604,7 +604,7 @@ std::string MWMechanics::Alchemy::suggestPotionName()
return effects.begin()->toString();
}
std::vector<std::string> MWMechanics::Alchemy::effectsDescription(const MWWorld::ConstPtr& ptr, const int alchemySkill)
std::vector<std::string> MWMechanics::Alchemy::effectsDescription(const MWWorld::ConstPtr& ptr, const float alchemySkill)
{
std::vector<std::string> effects;

View file

@ -135,7 +135,7 @@ namespace MWMechanics
/// adjust the skills of the alchemist accordingly.
/// \param name must not be an empty string, or Result_NoName is returned
static std::vector<std::string> effectsDescription(const MWWorld::ConstPtr& ptr, const int alchemySKill);
static std::vector<std::string> effectsDescription(const MWWorld::ConstPtr& ptr, const float alchemySKill);
};
}