Merge pull request #2199 from akortunov/guifixes

Use C++11-style loops in the GUI instead of iterators
pull/541/head
Bret Curtis 6 years ago committed by GitHub
commit f6127a30c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -238,15 +238,15 @@ namespace MWGui
std::set<MWMechanics::EffectKey> effectIds = mAlchemy->listEffects(); std::set<MWMechanics::EffectKey> effectIds = mAlchemy->listEffects();
Widgets::SpellEffectList list; Widgets::SpellEffectList list;
unsigned int effectIndex=0; unsigned int effectIndex=0;
for (std::set<MWMechanics::EffectKey>::iterator it2 = effectIds.begin(); it2 != effectIds.end(); ++it2) for (const MWMechanics::EffectKey& effectKey : effectIds)
{ {
Widgets::SpellEffectParams params; Widgets::SpellEffectParams params;
params.mEffectID = it2->mId; params.mEffectID = effectKey.mId;
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(it2->mId); const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectKey.mId);
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill) if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill)
params.mSkill = it2->mArg; params.mSkill = effectKey.mArg;
else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute) else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
params.mAttribute = it2->mArg; params.mAttribute = effectKey.mArg;
params.mIsConstant = true; params.mIsConstant = true;
params.mNoTarget = true; params.mNoTarget = true;

@ -145,35 +145,35 @@ namespace MWGui
// sort by name // sort by name
std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns; std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns;
MWWorld::Store<ESM::BirthSign>::iterator it = signs.begin(); for (const ESM::BirthSign& sign : signs)
for (; it != signs.end(); ++it)
{ {
birthSigns.push_back(std::make_pair(it->mId, &(*it))); birthSigns.push_back(std::make_pair(sign.mId, &sign));
} }
std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns); std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns);
int index = 0; int index = 0;
for (std::vector<std::pair<std::string, const ESM::BirthSign*> >::const_iterator it2 = birthSigns.begin(); for (auto& birthsignPair : birthSigns)
it2 != birthSigns.end(); ++it2, ++index)
{ {
mBirthList->addItem(it2->second->mName, it2->first); mBirthList->addItem(birthsignPair.second->mName, birthsignPair.first);
if (mCurrentBirthId.empty()) if (mCurrentBirthId.empty())
{ {
mBirthList->setIndexSelected(index); mBirthList->setIndexSelected(index);
mCurrentBirthId = it2->first; mCurrentBirthId = birthsignPair.first;
} }
else if (Misc::StringUtils::ciEqual(it2->first, mCurrentBirthId)) else if (Misc::StringUtils::ciEqual(birthsignPair.first, mCurrentBirthId))
{ {
mBirthList->setIndexSelected(index); mBirthList->setIndexSelected(index);
} }
index++;
} }
} }
void BirthDialog::updateSpells() void BirthDialog::updateSpells()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mSpellItems.begin(); it != mSpellItems.end(); ++it) for (MyGUI::Widget* widget : mSpellItems)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
} }
mSpellItems.clear(); mSpellItems.clear();

@ -257,19 +257,17 @@ namespace MWGui
{ {
std::map<int, MWMechanics::AttributeValue > attributes = MWBase::Environment::get().getWindowManager()->getPlayerAttributeValues(); std::map<int, MWMechanics::AttributeValue > attributes = MWBase::Environment::get().getWindowManager()->getPlayerAttributeValues();
for (std::map<int, MWMechanics::AttributeValue >::iterator it = attributes.begin(); for (auto& attributePair : attributes)
it != attributes.end(); ++it)
{ {
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (it->first), it->second); mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (attributePair.first), attributePair.second);
} }
} }
{ {
std::map<int, MWMechanics::SkillValue > skills = MWBase::Environment::get().getWindowManager()->getPlayerSkillValues(); std::map<int, MWMechanics::SkillValue > skills = MWBase::Environment::get().getWindowManager()->getPlayerSkillValues();
for (std::map<int, MWMechanics::SkillValue >::iterator it = skills.begin(); for (auto& skillPair : skills)
it != skills.end(); ++it)
{ {
mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (it->first), it->second); mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (skillPair.first), skillPair.second);
} }
mReviewDialog->configureSkills(MWBase::Environment::get().getWindowManager()->getPlayerMajorSkills(), MWBase::Environment::get().getWindowManager()->getPlayerMinorSkills()); mReviewDialog->configureSkills(MWBase::Environment::get().getWindowManager()->getPlayerMajorSkills(), MWBase::Environment::get().getWindowManager()->getPlayerMinorSkills());
} }

@ -208,24 +208,24 @@ namespace MWGui
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
std::vector<std::pair<std::string, std::string> > items; // class id, class name std::vector<std::pair<std::string, std::string> > items; // class id, class name
for (MWWorld::Store<ESM::Class>::iterator it = store.get<ESM::Class>().begin(); it != store.get<ESM::Class>().end(); ++it) for (const ESM::Class& classInfo : store.get<ESM::Class>())
{ {
bool playable = (it->mData.mIsPlayable != 0); bool playable = (classInfo.mData.mIsPlayable != 0);
if (!playable) // Only display playable classes if (!playable) // Only display playable classes
continue; continue;
if (store.get<ESM::Class>().isDynamic(it->mId)) if (store.get<ESM::Class>().isDynamic(classInfo.mId))
continue; // custom-made class not relevant for this dialog continue; // custom-made class not relevant for this dialog
items.push_back(std::make_pair(it->mId, it->mName)); items.push_back(std::make_pair(classInfo.mId, classInfo.mName));
} }
std::sort(items.begin(), items.end(), sortClasses); std::sort(items.begin(), items.end(), sortClasses);
int index = 0; int index = 0;
for (std::vector<std::pair<std::string, std::string> >::const_iterator it = items.begin(); it != items.end(); ++it) for (auto& itemPair : items)
{ {
const std::string &id = it->first; const std::string &id = itemPair.first;
mClassList->addItem(it->second, id); mClassList->addItem(itemPair.second, id);
if (mCurrentClassId.empty()) if (mCurrentClassId.empty())
{ {
mCurrentClassId = id; mCurrentClassId = id;
@ -332,19 +332,17 @@ namespace MWGui
void InfoBoxDialog::setButtons(ButtonList &buttons) void InfoBoxDialog::setButtons(ButtonList &buttons)
{ {
for (std::vector<MyGUI::Button*>::iterator it = this->mButtons.begin(); it != this->mButtons.end(); ++it) for (MyGUI::Button* button : this->mButtons)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(button);
} }
this->mButtons.clear(); this->mButtons.clear();
// TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget // TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget
MyGUI::Button* button; MyGUI::Button* button;
MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, mButtonBar->getWidth(), 10); MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, mButtonBar->getWidth(), 10);
ButtonList::const_iterator end = buttons.end(); for (const std::string &text : buttons)
for (ButtonList::const_iterator it = buttons.begin(); it != end; ++it)
{ {
const std::string &text = *it;
button = mButtonBar->createWidget<MyGUI::Button>("MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, ""); button = mButtonBar->createWidget<MyGUI::Button>("MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, "");
button->getSubWidgetText()->setWordWrap(true); button->getSubWidgetText()->setWordWrap(true);
button->setCaption(text); button->setCaption(text);
@ -368,11 +366,10 @@ namespace MWGui
void InfoBoxDialog::onButtonClicked(MyGUI::Widget* _sender) void InfoBoxDialog::onButtonClicked(MyGUI::Widget* _sender)
{ {
std::vector<MyGUI::Button*>::const_iterator end = mButtons.end();
int i = 0; int i = 0;
for (std::vector<MyGUI::Button*>::const_iterator it = mButtons.begin(); it != end; ++it) for (MyGUI::Button* button : mButtons)
{ {
if (*it == _sender) if (button == _sender)
{ {
eventButtonSelected(i); eventButtonSelected(i);
return; return;
@ -430,10 +427,9 @@ namespace MWGui
mSkills.push_back(mMinorSkill[i]); mSkills.push_back(mMinorSkill[i]);
} }
std::vector<Widgets::MWSkillPtr>::const_iterator end = mSkills.end(); for (Widgets::MWSkillPtr& skill : mSkills)
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = mSkills.begin(); it != end; ++it)
{ {
(*it)->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked); skill->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
} }
setText("LabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sName", "")); setText("LabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sName", ""));
@ -642,14 +638,13 @@ namespace MWGui
ESM::Skill::SkillEnum id = mSkillDialog->getSkillId(); ESM::Skill::SkillEnum id = mSkillDialog->getSkillId();
// Avoid duplicate skills by swapping any skill field that matches the selected one // Avoid duplicate skills by swapping any skill field that matches the selected one
std::vector<Widgets::MWSkillPtr>::const_iterator end = mSkills.end(); for (Widgets::MWSkillPtr& skill : mSkills)
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = mSkills.begin(); it != end; ++it)
{ {
if (*it == mAffectedSkill) if (skill == mAffectedSkill)
continue; continue;
if ((*it)->getSkillId() == id) if (skill->getSkillId() == id)
{ {
(*it)->setSkillId(mAffectedSkill->getSkillId()); skill->setSkillId(mAffectedSkill->getSkillId());
break; break;
} }
} }

@ -231,11 +231,13 @@ namespace MWGui
{ {
int i = 0; int i = 0;
printOK(""); printOK("");
for(std::vector<std::string>::iterator it=matches.begin(); it < matches.end(); ++it,++i ) for(std::string& match : matches)
{ {
printOK( *it ); if(i == 50)
if( i == 50 )
break; break;
printOK(match);
i++;
} }
} }
} }
@ -352,15 +354,16 @@ namespace MWGui
} }
/* Iterate through the vector. */ /* Iterate through the vector. */
for(std::vector<std::string>::iterator it=mNames.begin(); it < mNames.end();++it) { for(std::string& name : mNames)
{
bool string_different=false; bool string_different=false;
/* Is the string shorter than the input string? If yes skip it. */ /* Is the string shorter than the input string? If yes skip it. */
if( (*it).length() < tmp.length() ) if(name.length() < tmp.length())
continue; continue;
/* Is the beginning of the string different from the input string? If yes skip it. */ /* Is the beginning of the string different from the input string? If yes skip it. */
for( std::string::iterator iter=tmp.begin(), iter2=(*it).begin(); iter < tmp.end();++iter, ++iter2) { for( std::string::iterator iter=tmp.begin(), iter2=name.begin(); iter < tmp.end();++iter, ++iter2) {
if( Misc::StringUtils::toLower(*iter) != Misc::StringUtils::toLower(*iter2) ) { if( Misc::StringUtils::toLower(*iter) != Misc::StringUtils::toLower(*iter2) ) {
string_different=true; string_different=true;
break; break;
@ -371,7 +374,7 @@ namespace MWGui
continue; continue;
/* The beginning of the string matches the input string, save it for the next test. */ /* The beginning of the string matches the input string, save it for the next test. */
matches.push_back(*it); matches.push_back(name);
} }
/* There are no matches. Return the unchanged input. */ /* There are no matches. Return the unchanged input. */
@ -399,11 +402,14 @@ namespace MWGui
/* Check if all matching strings match further than input. If yes complete to this match. */ /* Check if all matching strings match further than input. If yes complete to this match. */
int i = tmp.length(); int i = tmp.length();
for(std::string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); ++iter, ++i) { for(std::string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); ++iter, ++i)
for(std::vector<std::string>::iterator it=matches.begin(); it < matches.end();++it) { {
if( Misc::StringUtils::toLower((*it)[i]) != Misc::StringUtils::toLower(*iter) ) { for(std::string& match : matches)
{
if(Misc::StringUtils::toLower(match[i]) != Misc::StringUtils::toLower(*iter))
{
/* Append the longest match to the end of the output string*/ /* Append the longest match to the end of the output string*/
output.append(matches.front().substr( 0, i)); output.append(matches.front().substr(0, i));
return output; return output;
} }
} }

@ -82,9 +82,9 @@ size_t ContainerItemModel::getItemCount()
ItemModel::ModelIndex ContainerItemModel::getIndex (ItemStack item) ItemModel::ModelIndex ContainerItemModel::getIndex (ItemStack item)
{ {
size_t i = 0; size_t i = 0;
for (std::vector<ItemStack>::iterator it = mItems.begin(); it != mItems.end(); ++it) for (ItemStack& itemStack : mItems)
{ {
if (*it == item) if (itemStack == item)
return i; return i;
++i; ++i;
} }
@ -103,29 +103,29 @@ void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
{ {
int toRemove = count; int toRemove = count;
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source) for (MWWorld::Ptr& source : mItemSources)
{ {
MWWorld::ContainerStore& store = source->getClass().getContainerStore(*source); MWWorld::ContainerStore& store = source.getClass().getContainerStore(source);
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
{ {
if (stacks(*it, item.mBase)) if (stacks(*it, item.mBase))
{ {
toRemove -= store.remove(*it, toRemove, *source); toRemove -= store.remove(*it, toRemove, source);
if (toRemove <= 0) if (toRemove <= 0)
return; return;
} }
} }
} }
for (std::vector<MWWorld::Ptr>::iterator source = mWorldItems.begin(); source != mWorldItems.end(); ++source) for (MWWorld::Ptr& source : mWorldItems)
{ {
if (stacks(*source, item.mBase)) if (stacks(source, item.mBase))
{ {
int refCount = source->getRefData().getCount(); int refCount = source.getRefData().getCount();
if (refCount - toRemove <= 0) if (refCount - toRemove <= 0)
MWBase::Environment::get().getWorld()->deleteObject(*source); MWBase::Environment::get().getWorld()->deleteObject(source);
else else
source->getRefData().setCount(std::max(0, refCount - toRemove)); source.getRefData().setCount(std::max(0, refCount - toRemove));
toRemove -= refCount; toRemove -= refCount;
if (toRemove <= 0) if (toRemove <= 0)
return; return;
@ -138,27 +138,28 @@ void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
void ContainerItemModel::update() void ContainerItemModel::update()
{ {
mItems.clear(); mItems.clear();
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source) for (MWWorld::Ptr& source : mItemSources)
{ {
MWWorld::ContainerStore& store = source->getClass().getContainerStore(*source); MWWorld::ContainerStore& store = source.getClass().getContainerStore(source);
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
{ {
if (!(*it).getClass().showsInInventory(*it)) if (!(*it).getClass().showsInInventory(*it))
continue; continue;
std::vector<ItemStack>::iterator itemStack = mItems.begin(); bool found = false;
for (; itemStack != mItems.end(); ++itemStack) for (ItemStack& itemStack : mItems)
{ {
if (stacks(*it, itemStack->mBase)) if (stacks(*it, itemStack.mBase))
{ {
// we already have an item stack of this kind, add to it // we already have an item stack of this kind, add to it
itemStack->mCount += it->getRefData().getCount(); itemStack.mCount += it->getRefData().getCount();
found = true;
break; break;
} }
} }
if (itemStack == mItems.end()) if (!found)
{ {
// no stack yet, create one // no stack yet, create one
ItemStack newItem (*it, this, it->getRefData().getCount()); ItemStack newItem (*it, this, it->getRefData().getCount());
@ -166,23 +167,24 @@ void ContainerItemModel::update()
} }
} }
} }
for (std::vector<MWWorld::Ptr>::iterator source = mWorldItems.begin(); source != mWorldItems.end(); ++source) for (MWWorld::Ptr& source : mWorldItems)
{ {
std::vector<ItemStack>::iterator itemStack = mItems.begin(); bool found = false;
for (; itemStack != mItems.end(); ++itemStack) for (ItemStack& itemStack : mItems)
{ {
if (stacks(*source, itemStack->mBase)) if (stacks(source, itemStack.mBase))
{ {
// we already have an item stack of this kind, add to it // we already have an item stack of this kind, add to it
itemStack->mCount += source->getRefData().getCount(); itemStack.mCount += source.getRefData().getCount();
found = true;
break; break;
} }
} }
if (itemStack == mItems.end()) if (!found)
{ {
// no stack yet, create one // no stack yet, create one
ItemStack newItem (*source, this, source->getRefData().getCount()); ItemStack newItem (source, this, source.getRefData().getCount());
mItems.push_back(newItem); mItems.push_back(newItem);
} }
} }

@ -184,16 +184,16 @@ namespace MWGui
BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal, false); BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal, false);
size_t formatted = 0; // points to the first character that is not laid out yet size_t formatted = 0; // points to the first character that is not laid out yet
for (std::map<Range, intptr_t>::iterator it = hyperLinks.begin(); it != hyperLinks.end(); ++it) for (auto& hyperLink : hyperLinks)
{ {
intptr_t topicId = it->second; intptr_t topicId = hyperLink.second;
BookTypesetter::Style* hotStyle = typesetter->createHotStyle (style, textColours.link, BookTypesetter::Style* hotStyle = typesetter->createHotStyle (style, textColours.link,
textColours.linkOver, textColours.linkPressed, textColours.linkOver, textColours.linkPressed,
topicId); topicId);
if (formatted < it->first.first) if (formatted < hyperLink.first.first)
typesetter->write(style, formatted, it->first.first); typesetter->write(style, formatted, hyperLink.first.first);
typesetter->write(hotStyle, it->first.first, it->first.second); typesetter->write(hotStyle, hyperLink.first.first, hyperLink.first.second);
formatted = it->first.second; formatted = hyperLink.first.second;
} }
if (formatted < text.size()) if (formatted < text.size())
typesetter->write(style, formatted, text.size()); typesetter->write(style, formatted, text.size());
@ -204,9 +204,8 @@ namespace MWGui
keywordSearch->highlightKeywords(text.begin(), text.end(), matches); keywordSearch->highlightKeywords(text.begin(), text.end(), matches);
std::string::const_iterator i = text.begin (); std::string::const_iterator i = text.begin ();
for (std::vector<KeywordSearchT::Match>::iterator it = matches.begin(); it != matches.end(); ++it) for (KeywordSearchT::Match& match : matches)
{ {
KeywordSearchT::Match match = *it;
if (i != match.mBeg) if (i != match.mBeg)
addTopicLink (typesetter, 0, i - text.begin (), match.mBeg - text.begin ()); addTopicLink (typesetter, 0, i - text.begin (), match.mBeg - text.begin ());
@ -419,13 +418,13 @@ namespace MWGui
bool sameActor = (mPtr == actor); bool sameActor = (mPtr == actor);
if (!sameActor) if (!sameActor)
{ {
for (std::vector<DialogueText*>::iterator it = mHistoryContents.begin(); it != mHistoryContents.end(); ++it) for (DialogueText* text : mHistoryContents)
delete (*it); delete text;
mHistoryContents.clear(); mHistoryContents.clear();
mKeywords.clear(); mKeywords.clear();
mTopicsList->clear(); mTopicsList->clear();
for (std::vector<Link*>::iterator it = mLinks.begin(); it != mLinks.end(); ++it) for (Link* link : mLinks)
mDeleteLater.push_back(*it); // Links are not deleted right away to prevent issues with event handlers mDeleteLater.push_back(link); // Links are not deleted right away to prevent issues with event handlers
mLinks.clear(); mLinks.clear();
} }
@ -489,8 +488,8 @@ namespace MWGui
void DialogueWindow::updateTopicsPane() void DialogueWindow::updateTopicsPane()
{ {
mTopicsList->clear(); mTopicsList->clear();
for (std::map<std::string, Link*>::iterator it = mTopicLinks.begin(); it != mTopicLinks.end(); ++it) for (auto& linkPair : mTopicLinks)
mDeleteLater.push_back(it->second); mDeleteLater.push_back(linkPair.second);
mTopicLinks.clear(); mTopicLinks.clear();
mKeywordSearch.clear(); mKeywordSearch.clear();
@ -533,15 +532,15 @@ namespace MWGui
mTopicsList->addSeparator(); mTopicsList->addSeparator();
for(std::list<std::string>::iterator it = mKeywords.begin(); it != mKeywords.end(); ++it) for(std::string& keyword : mKeywords)
{ {
mTopicsList->addItem(*it); mTopicsList->addItem(keyword);
Topic* t = new Topic(*it); Topic* t = new Topic(keyword);
t->eventTopicActivated += MyGUI::newDelegate(this, &DialogueWindow::onTopicActivated); t->eventTopicActivated += MyGUI::newDelegate(this, &DialogueWindow::onTopicActivated);
mTopicLinks[Misc::StringUtils::lowerCase(*it)] = t; mTopicLinks[Misc::StringUtils::lowerCase(keyword)] = t;
mKeywordSearch.seed(Misc::StringUtils::lowerCase(*it), intptr_t(t)); mKeywordSearch.seed(Misc::StringUtils::lowerCase(keyword), intptr_t(t));
} }
mTopicsList->adjustSize(); mTopicsList->adjustSize();
@ -563,9 +562,8 @@ namespace MWGui
BookTypesetter::Ptr typesetter = BookTypesetter::create (mHistory->getWidth(), std::numeric_limits<int>::max()); BookTypesetter::Ptr typesetter = BookTypesetter::create (mHistory->getWidth(), std::numeric_limits<int>::max());
for (std::vector<DialogueText*>::iterator it = mHistoryContents.begin(); it != mHistoryContents.end(); ++it) for (DialogueText* text : mHistoryContents)
(*it)->write(typesetter, &mKeywordSearch, mTopicLinks); text->write(typesetter, &mKeywordSearch, mTopicLinks);
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::White, false); BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::White, false);
@ -573,9 +571,9 @@ namespace MWGui
// choices // choices
const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
mChoices = MWBase::Environment::get().getDialogueManager()->getChoices(); mChoices = MWBase::Environment::get().getDialogueManager()->getChoices();
for (std::vector<std::pair<std::string, int> >::const_iterator it = mChoices.begin(); it != mChoices.end(); ++it) for (std::pair<std::string, int>& choice : mChoices)
{ {
Choice* link = new Choice(it->second); Choice* link = new Choice(choice.second);
link->eventChoiceActivated += MyGUI::newDelegate(this, &DialogueWindow::onChoiceActivated); link->eventChoiceActivated += MyGUI::newDelegate(this, &DialogueWindow::onChoiceActivated);
mLinks.push_back(link); mLinks.push_back(link);
@ -583,7 +581,7 @@ namespace MWGui
BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, textColours.answer, textColours.answerOver, BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, textColours.answer, textColours.answerOver,
textColours.answerPressed, textColours.answerPressed,
TypesetBook::InteractiveId(link)); TypesetBook::InteractiveId(link));
typesetter->write(questionStyle, to_utf8_span(it->first.c_str())); typesetter->write(questionStyle, to_utf8_span(choice.first.c_str()));
} }
mGoodbye = MWBase::Environment::get().getDialogueManager()->isGoodbye(); mGoodbye = MWBase::Environment::get().getDialogueManager()->isGoodbye();

@ -37,9 +37,9 @@ size_t InventoryItemModel::getItemCount()
ItemModel::ModelIndex InventoryItemModel::getIndex (ItemStack item) ItemModel::ModelIndex InventoryItemModel::getIndex (ItemStack item)
{ {
size_t i = 0; size_t i = 0;
for (std::vector<ItemStack>::iterator it = mItems.begin(); it != mItems.end(); ++it) for (ItemStack& itemStack : mItems)
{ {
if (*it == item) if (itemStack == item)
return i; return i;
++i; ++i;
} }

@ -130,13 +130,13 @@ namespace MWGui
{ {
int currentY = 0; int currentY = 0;
for (Lines::const_iterator iter = mLines.begin(); iter != mLines.end(); ++iter) for (Line& line : mLines)
{ {
iter->mText->setCoord(8, currentY, mScrollView->getWidth()-8, 18); line.mText->setCoord(8, currentY, mScrollView->getWidth()-8, 18);
currentY += 19; currentY += 19;
iter->mIcon->setCoord(16, currentY, 32, 32); line.mIcon->setCoord(16, currentY, 32, 32);
iter->mCharge->setCoord(72, currentY+2, std::max(199, mScrollView->getWidth()-72-38), 20); line.mCharge->setCoord(72, currentY+2, std::max(199, mScrollView->getWidth()-72-38), 20);
currentY += 32 + 4; currentY += 32 + 4;
} }

@ -105,12 +105,12 @@ namespace MWGui
Misc::StringUtils::replace(message, "%d", std::to_string(mDays).c_str(), 2); Misc::StringUtils::replace(message, "%d", std::to_string(mDays).c_str(), 2);
for (std::set<int>::iterator it = skills.begin(); it != skills.end(); ++it) for (const int& skill : skills)
{ {
std::string skillName = gmst.find(ESM::Skill::sSkillNameIds[*it])->mValue.getString(); std::string skillName = gmst.find(ESM::Skill::sSkillNameIds[skill])->mValue.getString();
int skillValue = player.getClass().getNpcStats(player).getSkill(*it).getBase(); int skillValue = player.getClass().getNpcStats(player).getSkill(skill).getBase();
std::string skillMsg = gmst.find("sNotifyMessage44")->mValue.getString(); std::string skillMsg = gmst.find("sNotifyMessage44")->mValue.getString();
if (*it == ESM::Skill::Sneak || *it == ESM::Skill::Security) if (skill == ESM::Skill::Sneak || skill == ESM::Skill::Security)
skillMsg = gmst.find("sNotifyMessage39")->mValue.getString(); skillMsg = gmst.find("sNotifyMessage39")->mValue.getString();
Misc::StringUtils::replace(skillMsg, "%s", skillName.c_str(), 2); Misc::StringUtils::replace(skillMsg, "%s", skillName.c_str(), 2);

@ -21,11 +21,11 @@ namespace MWGui
mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent); mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent);
const std::string main_name = mPrefix + MAIN_WINDOW; const std::string main_name = mPrefix + MAIN_WINDOW;
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin(); iter!=mListWindowRoot.end(); ++iter) for (MyGUI::Widget* widget : mListWindowRoot)
{ {
if ((*iter)->getName() == main_name) if (widget->getName() == main_name)
{ {
mMainWidget = (*iter); mMainWidget = widget;
break; break;
} }
} }
@ -66,10 +66,9 @@ namespace MWGui
MyGUI::Widget* Layout::getWidget(const std::string &_name) MyGUI::Widget* Layout::getWidget(const std::string &_name)
{ {
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin(); for (MyGUI::Widget* widget : mListWindowRoot)
iter!=mListWindowRoot.end(); ++iter)
{ {
MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name); MyGUI::Widget* find = widget->findWidget(mPrefix + _name);
if (nullptr != find) if (nullptr != find)
{ {
return find; return find;

@ -253,36 +253,36 @@ namespace MWGui
// Create new buttons if needed // Create new buttons if needed
std::vector<std::string> allButtons { "return", "newgame", "savegame", "loadgame", "options", "credits", "exitgame"}; std::vector<std::string> allButtons { "return", "newgame", "savegame", "loadgame", "options", "credits", "exitgame"};
for (std::vector<std::string>::iterator it = allButtons.begin(); it != allButtons.end(); ++it) for (std::string& buttonId : allButtons)
{ {
if (mButtons.find(*it) == mButtons.end()) if (mButtons.find(buttonId) == mButtons.end())
{ {
Gui::ImageButton* button = mButtonBox->createWidget<Gui::ImageButton> Gui::ImageButton* button = mButtonBox->createWidget<Gui::ImageButton>
("ImageBox", MyGUI::IntCoord(0, curH, 0, 0), MyGUI::Align::Default); ("ImageBox", MyGUI::IntCoord(0, curH, 0, 0), MyGUI::Align::Default);
button->setProperty("ImageHighlighted", "textures\\menu_" + *it + "_over.dds"); button->setProperty("ImageHighlighted", "textures\\menu_" + buttonId + "_over.dds");
button->setProperty("ImageNormal", "textures\\menu_" + *it + ".dds"); button->setProperty("ImageNormal", "textures\\menu_" + buttonId + ".dds");
button->setProperty("ImagePushed", "textures\\menu_" + *it + "_pressed.dds"); button->setProperty("ImagePushed", "textures\\menu_" + buttonId + "_pressed.dds");
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::onButtonClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::onButtonClicked);
button->setUserData(std::string(*it)); button->setUserData(std::string(buttonId));
mButtons[*it] = button; mButtons[buttonId] = button;
} }
} }
// Start by hiding all buttons // Start by hiding all buttons
int maxwidth = 0; int maxwidth = 0;
for (std::map<std::string, Gui::ImageButton*>::iterator it = mButtons.begin(); it != mButtons.end(); ++it) for (auto& buttonPair : mButtons)
{ {
it->second->setVisible(false); buttonPair.second->setVisible(false);
MyGUI::IntSize requested = it->second->getRequestedSize(); MyGUI::IntSize requested = buttonPair.second->getRequestedSize();
if (requested.width > maxwidth) if (requested.width > maxwidth)
maxwidth = requested.width; maxwidth = requested.width;
} }
// Now show and position the ones we want // Now show and position the ones we want
for (std::vector<std::string>::iterator it = buttons.begin(); it != buttons.end(); ++it) for (std::string& buttonId : buttons)
{ {
assert(mButtons.find(*it) != mButtons.end()); assert(mButtons.find(buttonId) != mButtons.end());
Gui::ImageButton* button = mButtons[*it]; Gui::ImageButton* button = mButtons[buttonId];
button->setVisible(true); button->setVisible(true);
MyGUI::IntSize requested = button->getRequestedSize(); MyGUI::IntSize requested = button->getRequestedSize();

@ -312,8 +312,8 @@ namespace MWGui
void LocalMapBase::updateCustomMarkers() void LocalMapBase::updateCustomMarkers()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mCustomMarkerWidgets.begin(); it != mCustomMarkerWidgets.end(); ++it) for (MyGUI::Widget* widget : mCustomMarkerWidgets)
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
mCustomMarkerWidgets.clear(); mCustomMarkerWidgets.clear();
for (int dX = -mCellDistance; dX <= mCellDistance; ++dX) for (int dX = -mCellDistance; dX <= mCellDistance; ++dX)
@ -487,9 +487,9 @@ namespace MWGui
} }
int counter = 0; int counter = 0;
for (std::vector<MWWorld::Ptr>::iterator it = markers.begin(); it != markers.end(); ++it) for (const MWWorld::Ptr& ptr : markers)
{ {
const ESM::Position& worldPos = it->getRefData().getPosition(); const ESM::Position& worldPos = ptr.getRefData().getPosition();
MarkerUserData markerPos (mLocalMapRender); MarkerUserData markerPos (mLocalMapRender);
MyGUI::IntPoint widgetPos = getMarkerPosition(worldPos.pos[0], worldPos.pos[1], markerPos); MyGUI::IntPoint widgetPos = getMarkerPosition(worldPos.pos[0], worldPos.pos[1], markerPos);
MyGUI::IntCoord widgetCoord(widgetPos.left - 4, MyGUI::IntCoord widgetCoord(widgetPos.left - 4,
@ -526,8 +526,8 @@ namespace MWGui
void LocalMapBase::updateDoorMarkers() void LocalMapBase::updateDoorMarkers()
{ {
// clear all previous door markers // clear all previous door markers
for (std::vector<MyGUI::Widget*>::iterator it = mDoorMarkerWidgets.begin(); it != mDoorMarkerWidgets.end(); ++it) for (MyGUI::Widget* widget : mDoorMarkerWidgets)
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
mDoorMarkerWidgets.clear(); mDoorMarkerWidgets.clear();
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
@ -553,10 +553,8 @@ namespace MWGui
// Create a widget for each marker // Create a widget for each marker
int counter = 0; int counter = 0;
for (std::vector<MWBase::World::DoorMarker>::iterator it = doors.begin(); it != doors.end(); ++it) for (MWBase::World::DoorMarker& marker : doors)
{ {
MWBase::World::DoorMarker marker = *it;
std::vector<std::string> destNotes; std::vector<std::string> destNotes;
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(marker.dest); CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(marker.dest);
for (CustomMarkerCollection::ContainerType::const_iterator iter = markers.first; iter != markers.second; ++iter) for (CustomMarkerCollection::ContainerType::const_iterator iter = markers.first; iter != markers.second; ++iter)
@ -589,8 +587,8 @@ namespace MWGui
void LocalMapBase::updateMagicMarkers() void LocalMapBase::updateMagicMarkers()
{ {
// clear all previous markers // clear all previous markers
for (std::vector<MyGUI::Widget*>::iterator it = mMagicMarkerWidgets.begin(); it != mMagicMarkerWidgets.end(); ++it) for (MyGUI::Widget* widget : mMagicMarkerWidgets)
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
mMagicMarkerWidgets.clear(); mMagicMarkerWidgets.clear();
addDetectionMarkers(MWBase::World::Detect_Creature); addDetectionMarkers(MWBase::World::Detect_Creature);
@ -848,9 +846,9 @@ namespace MWGui
mGlobalMapRender->cleanupCameras(); mGlobalMapRender->cleanupCameras();
for (std::vector<CellId>::iterator it = mQueuedToExplore.begin(); it != mQueuedToExplore.end(); ++it) for (CellId& cellId : mQueuedToExplore)
{ {
mGlobalMapRender->exploreCell(it->first, it->second, mLocalMapRender->getMapTexture(it->first, it->second)); mGlobalMapRender->exploreCell(cellId.first, cellId.second, mLocalMapRender->getMapTexture(cellId.first, cellId.second));
} }
mQueuedToExplore.clear(); mQueuedToExplore.clear();
@ -888,11 +886,11 @@ namespace MWGui
{ {
LocalMapBase::updateCustomMarkers(); LocalMapBase::updateCustomMarkers();
for (std::map<std::pair<int, int>, MyGUI::Widget*>::iterator widgetIt = mGlobalMapMarkers.begin(); widgetIt != mGlobalMapMarkers.end(); ++widgetIt) for (auto& widgetPair : mGlobalMapMarkers)
{ {
int x = widgetIt->first.first; int x = widgetPair.first.first;
int y = widgetIt->first.second; int y = widgetPair.first.second;
MyGUI::Widget* markerWidget = widgetIt->second; MyGUI::Widget* markerWidget = widgetPair.second;
setGlobalMapMarkerTooltip(markerWidget, x, y); setGlobalMapMarkerTooltip(markerWidget, x, y);
} }
} }
@ -1017,8 +1015,8 @@ namespace MWGui
mGlobalMapRender->clear(); mGlobalMapRender->clear();
mChanged = true; mChanged = true;
for (std::map<std::pair<int, int>, MyGUI::Widget*>::iterator it = mGlobalMapMarkers.begin(); it != mGlobalMapMarkers.end(); ++it) for (auto& widgetPair : mGlobalMapMarkers)
MyGUI::Gui::getInstance().destroyWidget(it->second); MyGUI::Gui::getInstance().destroyWidget(widgetPair.second);
mGlobalMapMarkers.clear(); mGlobalMapMarkers.clear();
} }
@ -1043,11 +1041,11 @@ namespace MWGui
mGlobalMapRender->read(map); mGlobalMapRender->read(map);
for (std::set<ESM::GlobalMap::CellId>::iterator it = map.mMarkers.begin(); it != map.mMarkers.end(); ++it) for (const ESM::GlobalMap::CellId& cellId : map.mMarkers)
{ {
const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search(it->first, it->second); const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search(cellId.first, cellId.second);
if (cell && !cell->mName.empty()) if (cell && !cell->mName.empty())
addVisitedLocation(cell->mName, it->first, it->second); addVisitedLocation(cell->mName, cellId.first, cellId.second);
} }
} }
} }
@ -1057,8 +1055,8 @@ namespace MWGui
NoDrop::setAlpha(alpha); NoDrop::setAlpha(alpha);
// can't allow showing map with partial transparency, as the fog of war will also go transparent // can't allow showing map with partial transparency, as the fog of war will also go transparent
// and reveal parts of the map you shouldn't be able to see // and reveal parts of the map you shouldn't be able to see
for (std::vector<MyGUI::ImageBox*>::iterator it = mMapWidgets.begin(); it != mMapWidgets.end(); ++it) for (MyGUI::ImageBox* widget : mMapWidgets)
(*it)->setVisible(alpha == 1); widget->setVisible(alpha == 1);
} }
void MapWindow::customMarkerCreated(MyGUI::Widget *marker) void MapWindow::customMarkerCreated(MyGUI::Widget *marker)

@ -28,10 +28,9 @@ namespace MWGui
MessageBoxManager::~MessageBoxManager () MessageBoxManager::~MessageBoxManager ()
{ {
std::vector<MessageBox*>::iterator it(mMessageBoxes.begin()); for (MessageBox* messageBox : mMessageBoxes)
for (; it != mMessageBoxes.end(); ++it)
{ {
delete *it; delete messageBox;
} }
} }
@ -50,12 +49,11 @@ namespace MWGui
mInterMessageBoxe = nullptr; mInterMessageBoxe = nullptr;
} }
std::vector<MessageBox*>::iterator it(mMessageBoxes.begin()); for (MessageBox* messageBox : mMessageBoxes)
for (; it != mMessageBoxes.end(); ++it)
{ {
if (*it == mStaticMessageBox) if (messageBox == mStaticMessageBox)
mStaticMessageBox = nullptr; mStaticMessageBox = nullptr;
delete *it; delete messageBox;
} }
mMessageBoxes.clear(); mMessageBoxes.clear();
@ -114,10 +112,10 @@ namespace MWGui
} }
int height = 0; int height = 0;
for(std::vector<MessageBox*>::iterator it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) for (MessageBox* messageBox : mMessageBoxes)
{ {
(*it)->update(height); messageBox->update(height);
height += (*it)->getHeight(); height += messageBox->getHeight();
} }
} }
@ -240,14 +238,14 @@ namespace MWGui
int buttonHeight = 0; int buttonHeight = 0;
MyGUI::IntCoord dummyCoord(0, 0, 0, 0); MyGUI::IntCoord dummyCoord(0, 0, 0, 0);
for(std::vector<std::string>::const_iterator it = buttons.begin(); it != buttons.end(); ++it) for(const std::string& buttonId : buttons)
{ {
MyGUI::Button* button = mButtonsWidget->createWidget<MyGUI::Button>( MyGUI::Button* button = mButtonsWidget->createWidget<MyGUI::Button>(
MyGUI::WidgetStyle::Child, MyGUI::WidgetStyle::Child,
std::string("MW_Button"), std::string("MW_Button"),
dummyCoord, dummyCoord,
MyGUI::Align::Default); MyGUI::Align::Default);
button->setCaptionWithReplacing(*it); button->setCaptionWithReplacing(buttonId);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); button->eventMouseButtonClick += MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed);
@ -300,16 +298,16 @@ namespace MWGui
MyGUI::IntSize buttonSize(0, buttonHeight); MyGUI::IntSize buttonSize(0, buttonHeight);
int left = (mainWidgetSize.width - buttonsWidth)/2; int left = (mainWidgetSize.width - buttonsWidth)/2;
for(std::vector<MyGUI::Button*>::const_iterator button = mButtons.begin(); button != mButtons.end(); ++button) for(MyGUI::Button* button : mButtons)
{ {
buttonCord.left = left; buttonCord.left = left;
buttonCord.top = messageWidgetCoord.top + textSize.height + textButtonPadding; buttonCord.top = messageWidgetCoord.top + textSize.height + textButtonPadding;
buttonSize.width = (*button)->getTextSize().width + 2*buttonLabelLeftPadding; buttonSize.width = button->getTextSize().width + 2*buttonLabelLeftPadding;
buttonSize.height = (*button)->getTextSize().height + 2*buttonLabelTopPadding; buttonSize.height = button->getTextSize().height + 2*buttonLabelTopPadding;
(*button)->setCoord(buttonCord); button->setCoord(buttonCord);
(*button)->setSize(buttonSize); button->setSize(buttonSize);
left += buttonSize.width + buttonLeftPadding; left += buttonSize.width + buttonLeftPadding;
} }
@ -329,16 +327,16 @@ namespace MWGui
int top = textPadding + textSize.height + textButtonPadding; int top = textPadding + textSize.height + textButtonPadding;
for(std::vector<MyGUI::Button*>::const_iterator button = mButtons.begin(); button != mButtons.end(); ++button) for(MyGUI::Button* button : mButtons)
{ {
buttonSize.width = (*button)->getTextSize().width + buttonLabelLeftPadding*2; buttonSize.width = button->getTextSize().width + buttonLabelLeftPadding*2;
buttonSize.height = (*button)->getTextSize().height + buttonLabelTopPadding*2; buttonSize.height = button->getTextSize().height + buttonLabelTopPadding*2;
buttonCord.top = top; buttonCord.top = top;
buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2; buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2;
(*button)->setCoord(buttonCord); button->setCoord(buttonCord);
(*button)->setSize(buttonSize); button->setSize(buttonSize);
top += buttonSize.height + buttonTopPadding; top += buttonSize.height + buttonTopPadding;
} }
@ -368,13 +366,13 @@ namespace MWGui
MyGUI::Widget* InteractiveMessageBox::getDefaultKeyFocus() MyGUI::Widget* InteractiveMessageBox::getDefaultKeyFocus()
{ {
std::vector<std::string> keywords { "sOk", "sYes" }; std::vector<std::string> keywords { "sOk", "sYes" };
for(std::vector<MyGUI::Button*>::const_iterator button = mButtons.begin(); button != mButtons.end(); ++button) for(MyGUI::Button* button : mButtons)
{ {
for (const std::string& keyword : keywords) for (const std::string& keyword : keywords)
{ {
if(Misc::StringUtils::ciEqual(MyGUI::LanguageManager::getInstance().replaceTags("#{" + keyword + "}"), (*button)->getCaption())) if(Misc::StringUtils::ciEqual(MyGUI::LanguageManager::getInstance().replaceTags("#{" + keyword + "}"), button->getCaption()))
{ {
return *button; return button;
} }
} }
} }
@ -390,10 +388,9 @@ namespace MWGui
{ {
mMarkedToDelete = true; mMarkedToDelete = true;
int index = 0; int index = 0;
std::vector<MyGUI::Button*>::const_iterator button; for(const MyGUI::Button* button : mButtons)
for(button = mButtons.begin(); button != mButtons.end(); ++button)
{ {
if(*button == pressed) if(button == pressed)
{ {
mButtonPressed = index; mButtonPressed = index;
mMessageBoxManager.onButtonPressed(mButtonPressed); mMessageBoxManager.onButtonPressed(mButtonPressed);

@ -540,32 +540,32 @@ namespace MWGui
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player); MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
int i=0; int i=0;
for (std::vector<ESM::QuickKeys::QuickKey>::const_iterator it = keys.mKeys.begin(); it != keys.mKeys.end(); ++it) for (ESM::QuickKeys::QuickKey& quickKey : keys.mKeys)
{ {
if (i >= 10) if (i >= 10)
return; return;
mSelected = &mKey[i]; mSelected = &mKey[i];
switch (it->mType) switch (quickKey.mType)
{ {
case Type_Magic: case Type_Magic:
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(it->mId)) if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(quickKey.mId))
onAssignMagic(it->mId); onAssignMagic(quickKey.mId);
break; break;
case Type_Item: case Type_Item:
case Type_MagicItem: case Type_MagicItem:
{ {
// Find the item by id // Find the item by id
MWWorld::Ptr item = store.findReplacement(it->mId); MWWorld::Ptr item = store.findReplacement(quickKey.mId);
if (item.isEmpty()) if (item.isEmpty())
unassign(mSelected); unassign(mSelected);
else else
{ {
if (it->mType == Type_Item) if (quickKey.mType == Type_Item)
onAssignItem(item); onAssignItem(item);
else // if (it->mType == Type_MagicItem) else // if (quickKey.mType == Type_MagicItem)
onAssignMagicItem(item); onAssignMagicItem(item);
} }

@ -290,9 +290,8 @@ namespace MWGui
const MWWorld::Store<ESM::BodyPart> &store = const MWWorld::Store<ESM::BodyPart> &store =
MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>();
for (MWWorld::Store<ESM::BodyPart>::iterator it = store.begin(); it != store.end(); ++it) for (const ESM::BodyPart& bodypart : store)
{ {
const ESM::BodyPart& bodypart = *it;
if (bodypart.mData.mFlags & ESM::BodyPart::BPF_NotPlayable) if (bodypart.mData.mFlags & ESM::BodyPart::BPF_NotPlayable)
continue; continue;
if (bodypart.mData.mType != ESM::BodyPart::MT_Skin) if (bodypart.mData.mType != ESM::BodyPart::MT_Skin)
@ -353,22 +352,21 @@ namespace MWGui
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>();
std::vector<std::pair<std::string, std::string> > items; // ID, name std::vector<std::pair<std::string, std::string> > items; // ID, name
MWWorld::Store<ESM::Race>::iterator it = races.begin(); for (const ESM::Race& race : races)
for (; it != races.end(); ++it)
{ {
bool playable = it->mData.mFlags & ESM::Race::Playable; bool playable = race.mData.mFlags & ESM::Race::Playable;
if (!playable) // Only display playable races if (!playable) // Only display playable races
continue; continue;
items.push_back(std::make_pair(it->mId, it->mName)); items.push_back(std::make_pair(race.mId, race.mName));
} }
std::sort(items.begin(), items.end(), sortRaces); std::sort(items.begin(), items.end(), sortRaces);
int index = 0; int index = 0;
for (std::vector<std::pair<std::string, std::string> >::const_iterator iter = items.begin(); iter != items.end(); ++iter) for (auto& item : items)
{ {
mRaceList->addItem(iter->second, iter->first); mRaceList->addItem(item.second, item.first);
if (Misc::StringUtils::ciEqual(iter->first, mCurrentRaceId)) if (Misc::StringUtils::ciEqual(item.first, mCurrentRaceId))
mRaceList->setIndexSelected(index); mRaceList->setIndexSelected(index);
++index; ++index;
} }
@ -376,9 +374,9 @@ namespace MWGui
void RaceDialog::updateSkills() void RaceDialog::updateSkills()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mSkillItems.begin(); it != mSkillItems.end(); ++it) for (MyGUI::Widget* widget : mSkillItems)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
} }
mSkillItems.clear(); mSkillItems.clear();
@ -413,9 +411,9 @@ namespace MWGui
void RaceDialog::updateSpellPowers() void RaceDialog::updateSpellPowers()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mSpellPowerItems.begin(); it != mSpellPowerItems.end(); ++it) for (MyGUI::Widget* widget : mSpellPowerItems)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
} }
mSpellPowerItems.clear(); mSpellPowerItems.clear();
@ -428,11 +426,9 @@ namespace MWGui
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.get<ESM::Race>().find(mCurrentRaceId); const ESM::Race *race = store.get<ESM::Race>().find(mCurrentRaceId);
std::vector<std::string>::const_iterator it = race->mPowers.mList.begin(); int i = 0;
std::vector<std::string>::const_iterator end = race->mPowers.mList.end(); for (const std::string& spellpower : race->mPowers.mList)
for (int i = 0; it != end; ++it)
{ {
const std::string &spellpower = *it;
Widgets::MWSpellPtr spellPowerWidget = mSpellPowerList->createWidget<Widgets::MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + MyGUI::utility::toString(i)); Widgets::MWSpellPtr spellPowerWidget = mSpellPowerList->createWidget<Widgets::MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + MyGUI::utility::toString(i));
spellPowerWidget->setSpellId(spellpower); spellPowerWidget->setSpellId(spellpower);
spellPowerWidget->setUserString("ToolTipType", "Spell"); spellPowerWidget->setUserString("ToolTipType", "Spell");

@ -353,9 +353,9 @@ namespace MWGui
void ReviewDialog::updateSkillArea() void ReviewDialog::updateSkillArea()
{ {
for (std::vector<MyGUI::Widget*>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it) for (MyGUI::Widget* skillWidget : mSkillWidgets)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(skillWidget);
} }
mSkillWidgets.clear(); mSkillWidgets.clear();
@ -388,19 +388,18 @@ namespace MWGui
attributes[i] = mAttributeWidgets[i]->getAttributeValue().getBase(); attributes[i] = mAttributeWidgets[i]->getAttributeValue().getBase();
std::vector<std::string> selectedSpells = MWMechanics::autoCalcPlayerSpells(skills, attributes, race); std::vector<std::string> selectedSpells = MWMechanics::autoCalcPlayerSpells(skills, attributes, race);
for (std::vector<std::string>::iterator iter = selectedSpells.begin(); iter != selectedSpells.end(); ++iter) for (std::string& spellId : selectedSpells)
{ {
std::string lower = Misc::StringUtils::lowerCase(*iter); std::string lower = Misc::StringUtils::lowerCase(spellId);
if (std::find(spells.begin(), spells.end(), lower) == spells.end()) if (std::find(spells.begin(), spells.end(), lower) == spells.end())
spells.push_back(lower); spells.push_back(lower);
} }
if (race) if (race)
{ {
for (std::vector<std::string>::const_iterator iter = race->mPowers.mList.begin(); for (const std::string& spellId : race->mPowers.mList)
iter != race->mPowers.mList.end(); ++iter)
{ {
std::string lower = Misc::StringUtils::lowerCase(*iter); std::string lower = Misc::StringUtils::lowerCase(spellId);
if (std::find(spells.begin(), spells.end(), lower) == spells.end()) if (std::find(spells.begin(), spells.end(), lower) == spells.end())
spells.push_back(lower); spells.push_back(lower);
} }
@ -409,10 +408,9 @@ namespace MWGui
if (!mBirthSignId.empty()) if (!mBirthSignId.empty())
{ {
const ESM::BirthSign* sign = MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find(mBirthSignId); const ESM::BirthSign* sign = MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find(mBirthSignId);
for (std::vector<std::string>::const_iterator iter = sign->mPowers.mList.begin(); for (const std::string& spellId : sign->mPowers.mList)
iter != sign->mPowers.mList.end(); ++iter)
{ {
std::string lower = Misc::StringUtils::lowerCase(*iter); std::string lower = Misc::StringUtils::lowerCase(spellId);
if (std::find(spells.begin(), spells.end(), lower) == spells.end()) if (std::find(spells.begin(), spells.end(), lower) == spells.end())
spells.push_back(lower); spells.push_back(lower);
} }
@ -421,27 +419,27 @@ namespace MWGui
if (!mSkillWidgets.empty()) if (!mSkillWidgets.empty())
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeAbility", "Abilities"), coord1, coord2); addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeAbility", "Abilities"), coord1, coord2);
for (std::vector<std::string>::const_iterator iter = spells.begin(); iter != spells.end(); ++iter) for (std::string& spellId : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*iter); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Ability) if (spell->mData.mType == ESM::Spell::ST_Ability)
addItem(spell, coord1, coord2); addItem(spell, coord1, coord2);
} }
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypePower", "Powers"), coord1, coord2); addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypePower", "Powers"), coord1, coord2);
for (std::vector<std::string>::const_iterator iter = spells.begin(); iter != spells.end(); ++iter) for (std::string& spellId : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*iter); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Power) if (spell->mData.mType == ESM::Spell::ST_Power)
addItem(spell, coord1, coord2); addItem(spell, coord1, coord2);
} }
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeSpell", "Spells"), coord1, coord2); addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeSpell", "Spells"), coord1, coord2);
for (std::vector<std::string>::const_iterator iter = spells.begin(); iter != spells.end(); ++iter) for (std::string& spellId : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*iter); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Spell) if (spell->mData.mType == ESM::Spell::ST_Spell)
addItem(spell, coord1, coord2); addItem(spell, coord1, coord2);
} }

@ -227,11 +227,10 @@ namespace MWGui
resolutions.push_back(std::make_pair(mode.w, mode.h)); resolutions.push_back(std::make_pair(mode.w, mode.h));
} }
std::sort(resolutions.begin(), resolutions.end(), sortResolutions); std::sort(resolutions.begin(), resolutions.end(), sortResolutions);
for (std::vector < std::pair<int, int> >::const_iterator it=resolutions.begin(); for (std::pair<int, int>& resolution : resolutions)
it!=resolutions.end(); ++it)
{ {
std::string str = MyGUI::utility::toString(it->first) + " x " + MyGUI::utility::toString(it->second) std::string str = MyGUI::utility::toString(resolution.first) + " x " + MyGUI::utility::toString(resolution.second)
+ " (" + getAspect(it->first,it->second) + ")"; + " (" + getAspect(resolution.first, resolution.second) + ")";
if (mResolutionList->findItemIndexWith(str) == MyGUI::ITEM_NONE) if (mResolutionList->findItemIndexWith(str) == MyGUI::ITEM_NONE)
mResolutionList->addItem(str); mResolutionList->addItem(str);
@ -476,17 +475,17 @@ namespace MWGui
else else
actions = MWBase::Environment::get().getInputManager()->getActionControllerSorting(); actions = MWBase::Environment::get().getInputManager()->getActionControllerSorting();
for (std::vector<int>::const_iterator it = actions.begin(); it != actions.end(); ++it) for (const int& action : actions)
{ {
std::string desc = MWBase::Environment::get().getInputManager()->getActionDescription (*it); std::string desc = MWBase::Environment::get().getInputManager()->getActionDescription (action);
if (desc == "") if (desc == "")
continue; continue;
std::string binding; std::string binding;
if(mKeyboardMode) if(mKeyboardMode)
binding = MWBase::Environment::get().getInputManager()->getActionKeyBindingName(*it); binding = MWBase::Environment::get().getInputManager()->getActionKeyBindingName(action);
else else
binding = MWBase::Environment::get().getInputManager()->getActionControllerBindingName(*it); binding = MWBase::Environment::get().getInputManager()->getActionControllerBindingName(action);
Gui::SharedStateButton* leftText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default); Gui::SharedStateButton* leftText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default);
leftText->setCaptionWithReplacing(desc); leftText->setCaptionWithReplacing(desc);
@ -494,7 +493,7 @@ namespace MWGui
Gui::SharedStateButton* rightText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default); Gui::SharedStateButton* rightText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default);
rightText->setCaptionWithReplacing(binding); rightText->setCaptionWithReplacing(binding);
rightText->setTextAlign (MyGUI::Align::Right); rightText->setTextAlign (MyGUI::Align::Right);
rightText->setUserData(*it); // save the action id for callbacks rightText->setUserData(action); // save the action id for callbacks
rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction); rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction);
rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel); rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel);

@ -122,9 +122,9 @@ namespace MWGui
std::stable_sort(spellsToSort.begin(), spellsToSort.end(), sortSpells); std::stable_sort(spellsToSort.begin(), spellsToSort.end(), sortSpells);
for (std::vector<const ESM::Spell*>::iterator it = spellsToSort.begin() ; it != spellsToSort.end(); ++it) for (const ESM::Spell* spell : spellsToSort)
{ {
addSpell(**it); addSpell(*spell);
} }
spellsToSort.clear(); spellsToSort.clear();

@ -455,10 +455,8 @@ namespace MWGui
const MWWorld::ESMStore &store = const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore(); MWBase::Environment::get().getWorld()->getStore();
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) for (const ESM::ENAMstruct& effect : mEffects)
{ {
const ESM::ENAMstruct& effect = *it;
y += std::max(1.f, MWMechanics::calcEffectCost(effect)); y += std::max(1.f, MWMechanics::calcEffectCost(effect));
if (effect.mRange == ESM::RT_Target) if (effect.mRange == ESM::RT_Target)
@ -530,18 +528,17 @@ namespace MWGui
if (spell->mData.mType != ESM::Spell::ST_Spell) if (spell->mData.mType != ESM::Spell::ST_Spell)
continue; continue;
const std::vector<ESM::ENAMstruct>& list = spell->mEffects.mList; for (const ESM::ENAMstruct& effectInfo : spell->mEffects.mList)
for (std::vector<ESM::ENAMstruct>::const_iterator it2 = list.begin(); it2 != list.end(); ++it2)
{ {
const ESM::MagicEffect * effect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(it2->mEffectID); const ESM::MagicEffect * effect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectInfo.mEffectID);
// skip effects that do not allow spellmaking/enchanting // skip effects that do not allow spellmaking/enchanting
int requiredFlags = (mType == Spellmaking) ? ESM::MagicEffect::AllowSpellmaking : ESM::MagicEffect::AllowEnchanting; int requiredFlags = (mType == Spellmaking) ? ESM::MagicEffect::AllowSpellmaking : ESM::MagicEffect::AllowEnchanting;
if (!(effect->mData.mFlags & requiredFlags)) if (!(effect->mData.mFlags & requiredFlags))
continue; continue;
if (std::find(knownEffects.begin(), knownEffects.end(), it2->mEffectID) == knownEffects.end()) if (std::find(knownEffects.begin(), knownEffects.end(), effectInfo.mEffectID) == knownEffects.end())
knownEffects.push_back(it2->mEffectID); knownEffects.push_back(effectInfo.mEffectID);
} }
} }
@ -550,23 +547,23 @@ namespace MWGui
mAvailableEffectsList->clear (); mAvailableEffectsList->clear ();
int i=0; int i=0;
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) for (const short effectId : knownEffects)
{ {
mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find( mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
ESM::MagicEffect::effectIdToString (*it))->mValue.getString()); ESM::MagicEffect::effectIdToString(effectId))->mValue.getString());
mButtonMapping[i] = *it; mButtonMapping[i] = effectId;
++i; ++i;
} }
mAvailableEffectsList->adjustSize (); mAvailableEffectsList->adjustSize ();
mAvailableEffectsList->scrollToTop(); mAvailableEffectsList->scrollToTop();
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) for (const short effectId : knownEffects)
{ {
std::string name = MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find( std::string name = MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
ESM::MagicEffect::effectIdToString (*it))->mValue.getString(); ESM::MagicEffect::effectIdToString(effectId))->mValue.getString();
MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name);
ToolTips::createMagicEffectToolTip (w, *it); ToolTips::createMagicEffectToolTip (w, effectId);
} }
mEffects.clear(); mEffects.clear();
@ -646,9 +643,9 @@ namespace MWGui
} }
else else
{ {
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) for (const ESM::ENAMstruct& effectInfo : mEffects)
{ {
if (it->mEffectID == mSelectedKnownEffectId) if (effectInfo.mEffectID == mSelectedKnownEffectId)
{ {
MWBase::Environment::get().getWindowManager()->messageBox ("#{sOnetypeEffectMessage}"); MWBase::Environment::get().getWindowManager()->messageBox ("#{sOnetypeEffectMessage}");
return; return;
@ -680,17 +677,17 @@ namespace MWGui
MyGUI::IntSize size(0,0); MyGUI::IntSize size(0,0);
int i = 0; int i = 0;
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) for (const ESM::ENAMstruct& effectInfo : mEffects)
{ {
Widgets::SpellEffectParams params; Widgets::SpellEffectParams params;
params.mEffectID = it->mEffectID; params.mEffectID = effectInfo.mEffectID;
params.mSkill = it->mSkill; params.mSkill = effectInfo.mSkill;
params.mAttribute = it->mAttribute; params.mAttribute = effectInfo.mAttribute;
params.mDuration = it->mDuration; params.mDuration = effectInfo.mDuration;
params.mMagnMin = it->mMagnMin; params.mMagnMin = effectInfo.mMagnMin;
params.mMagnMax = it->mMagnMax; params.mMagnMax = effectInfo.mMagnMax;
params.mRange = it->mRange; params.mRange = effectInfo.mRange;
params.mArea = it->mArea; params.mArea = effectInfo.mArea;
params.mIsConstant = mConstantEffect; params.mIsConstant = mConstantEffect;
MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default); MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default);

@ -65,10 +65,11 @@ namespace MWGui
int w=2; int w=2;
for (std::map <int, std::vector<MagicEffectInfo> >::const_iterator it = effects.begin(); it != effects.end(); ++it) for (auto& effectInfoPair : effects)
{ {
const int effectId = effectInfoPair.first;
const ESM::MagicEffect* effect = const ESM::MagicEffect* effect =
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(it->first); MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(effectId);
float remainingDuration = 0; float remainingDuration = 0;
float totalDuration = 0; float totalDuration = 0;
@ -77,46 +78,50 @@ namespace MWGui
static const float fadeTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMagicStartIconBlink")->mValue.getFloat(); static const float fadeTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMagicStartIconBlink")->mValue.getFloat();
for (std::vector<MagicEffectInfo>::const_iterator effectIt = it->second.begin(); std::vector<MagicEffectInfo>& effectInfos = effectInfoPair.second;
effectIt != it->second.end(); ++effectIt) bool addNewLine = true;
for (const MagicEffectInfo& effectInfo : effectInfos)
{
if (addNewLine)
{ {
if (effectIt != it->second.begin())
sourcesDescription += "\n"; sourcesDescription += "\n";
addNewLine = false;
}
// if at least one of the effect sources is permanent, the effect will never wear off // if at least one of the effect sources is permanent, the effect will never wear off
if (effectIt->mPermanent) if (effectInfo.mPermanent)
{ {
remainingDuration = fadeTime; remainingDuration = fadeTime;
totalDuration = fadeTime; totalDuration = fadeTime;
} }
else else
{ {
remainingDuration = std::max(remainingDuration, effectIt->mRemainingTime); remainingDuration = std::max(remainingDuration, effectInfo.mRemainingTime);
totalDuration = std::max(totalDuration, effectIt->mTotalTime); totalDuration = std::max(totalDuration, effectInfo.mTotalTime);
} }
sourcesDescription += effectIt->mSource; sourcesDescription += effectInfo.mSource;
if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill) if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill)
sourcesDescription += " (" + sourcesDescription += " (" +
MWBase::Environment::get().getWindowManager()->getGameSettingString( MWBase::Environment::get().getWindowManager()->getGameSettingString(
ESM::Skill::sSkillNameIds[effectIt->mKey.mArg], "") + ")"; ESM::Skill::sSkillNameIds[effectInfo.mKey.mArg], "") + ")";
if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute) if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
sourcesDescription += " (" + sourcesDescription += " (" +
MWBase::Environment::get().getWindowManager()->getGameSettingString( MWBase::Environment::get().getWindowManager()->getGameSettingString(
ESM::Attribute::sGmstAttributeIds[effectIt->mKey.mArg], "") + ")"; ESM::Attribute::sGmstAttributeIds[effectInfo.mKey.mArg], "") + ")";
ESM::MagicEffect::MagnitudeDisplayType displayType = effect->getMagnitudeDisplayType(); ESM::MagicEffect::MagnitudeDisplayType displayType = effect->getMagnitudeDisplayType();
if (displayType == ESM::MagicEffect::MDT_TimesInt) if (displayType == ESM::MagicEffect::MDT_TimesInt)
{ {
std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", ""); std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
std::stringstream formatter; std::stringstream formatter;
formatter << std::fixed << std::setprecision(1) << " " << (effectIt->mMagnitude / 10.0f) << timesInt; formatter << std::fixed << std::setprecision(1) << " " << (effectInfo.mMagnitude / 10.0f) << timesInt;
sourcesDescription += formatter.str(); sourcesDescription += formatter.str();
} }
else if ( displayType != ESM::MagicEffect::MDT_None ) else if ( displayType != ESM::MagicEffect::MDT_None )
{ {
sourcesDescription += ": " + MyGUI::utility::toString(effectIt->mMagnitude); sourcesDescription += ": " + MyGUI::utility::toString(effectInfo.mMagnitude);
if ( displayType == ESM::MagicEffect::MDT_Percentage ) if ( displayType == ESM::MagicEffect::MDT_Percentage )
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", ""); sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", "");
@ -124,32 +129,35 @@ namespace MWGui
sourcesDescription += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", ""); sourcesDescription += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", "");
else if ( displayType == ESM::MagicEffect::MDT_Level ) else if ( displayType == ESM::MagicEffect::MDT_Level )
{ {
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? sourcesDescription += " " + ((effectInfo.mMagnitude > 1) ?
MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", "") : MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", "") :
MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", "") ); MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", "") );
} }
else // ESM::MagicEffect::MDT_Points else // ESM::MagicEffect::MDT_Points
{ {
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? sourcesDescription += " " + ((effectInfo.mMagnitude > 1) ?
MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "") : MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "") :
MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "") ); MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "") );
} }
} }
if (effectIt->mRemainingTime > -1 && if (effectInfo.mRemainingTime > -1 &&
Settings::Manager::getBool("show effect duration","Game")) { Settings::Manager::getBool("show effect duration","Game")) {
sourcesDescription += " #{sDuration}: "; sourcesDescription += " #{sDuration}: ";
float duration = effectIt->mRemainingTime; float duration = effectInfo.mRemainingTime;
if (duration > 3600) { if (duration > 3600)
{
int hour = duration / 3600; int hour = duration / 3600;
duration -= hour*3600; duration -= hour*3600;
sourcesDescription += MWGui::ToolTips::toString(hour) + "h"; sourcesDescription += MWGui::ToolTips::toString(hour) + "h";
} }
if (duration > 60) { if (duration > 60)
{
int minute = duration / 60; int minute = duration / 60;
duration -= minute*60; duration -= minute*60;
sourcesDescription += MWGui::ToolTips::toString(minute) + "m"; sourcesDescription += MWGui::ToolTips::toString(minute) + "m";
} }
if (duration > 0.1) { if (duration > 0.1)
{
sourcesDescription += MWGui::ToolTips::toString(duration) + "s"; sourcesDescription += MWGui::ToolTips::toString(duration) + "s";
} }
} }
@ -158,15 +166,15 @@ namespace MWGui
if (remainingDuration > 0.f) if (remainingDuration > 0.f)
{ {
MyGUI::ImageBox* image; MyGUI::ImageBox* image;
if (mWidgetMap.find(it->first) == mWidgetMap.end()) if (mWidgetMap.find(effectId) == mWidgetMap.end())
{ {
image = parent->createWidget<MyGUI::ImageBox> image = parent->createWidget<MyGUI::ImageBox>
("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default); ("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default);
mWidgetMap[it->first] = image; mWidgetMap[effectId] = image;
image->setImageTexture(MWBase::Environment::get().getWindowManager()->correctIconPath(effect->mIcon)); image->setImageTexture(MWBase::Environment::get().getWindowManager()->correctIconPath(effect->mIcon));
std::string name = ESM::MagicEffect::effectIdToString (it->first); std::string name = ESM::MagicEffect::effectIdToString (effectId);
ToolTipInfo tooltipInfo; ToolTipInfo tooltipInfo;
tooltipInfo.caption = "#{" + name + "}"; tooltipInfo.caption = "#{" + name + "}";
@ -178,7 +186,7 @@ namespace MWGui
image->setUserString("ToolTipType", "ToolTipInfo"); image->setUserString("ToolTipType", "ToolTipInfo");
} }
else else
image = mWidgetMap[it->first]; image = mWidgetMap[effectId];
image->setPosition(w,2); image->setPosition(w,2);
image->setVisible(true); image->setVisible(true);
@ -191,9 +199,9 @@ namespace MWGui
if (totalDuration >= fadeTime && fadeTime > 0.f) if (totalDuration >= fadeTime && fadeTime > 0.f)
image->setAlpha(std::min(remainingDuration/fadeTime, 1.f)); image->setAlpha(std::min(remainingDuration/fadeTime, 1.f));
} }
else if (mWidgetMap.find(it->first) != mWidgetMap.end()) else if (mWidgetMap.find(effectId) != mWidgetMap.end())
{ {
mWidgetMap[it->first]->setVisible(false); mWidgetMap[effectId]->setVisible(false);
} }
} }
@ -208,10 +216,10 @@ namespace MWGui
} }
// hide inactive effects // hide inactive effects
for (std::map<int, MyGUI::ImageBox*>::iterator it = mWidgetMap.begin(); it != mWidgetMap.end(); ++it) for (auto& widgetPair : mWidgetMap)
{ {
if (effects.find(it->first) == effects.end()) if (effects.find(widgetPair.first) == effects.end())
it->second->setVisible(false); widgetPair.second->setVisible(false);
} }
} }

@ -149,13 +149,13 @@ namespace MWGui
mModel->update(); mModel->update();
bool fullUpdateRequired = false; bool fullUpdateRequired = false;
SpellModel::ModelIndex maxSpellIndexFound = -1; SpellModel::ModelIndex maxSpellIndexFound = -1;
for (std::vector< LineInfo >::iterator it = mLines.begin(); it != mLines.end(); ++it) for (LineInfo& line : mLines)
{ {
// only update the lines that are "updateable" // only update the lines that are "updateable"
SpellModel::ModelIndex spellIndex(it->mSpellIndex); SpellModel::ModelIndex spellIndex(line.mSpellIndex);
if (spellIndex != NoSpellIndex) if (spellIndex != NoSpellIndex)
{ {
Gui::SharedStateButton* nameButton = reinterpret_cast<Gui::SharedStateButton*>(it->mLeftWidget); Gui::SharedStateButton* nameButton = reinterpret_cast<Gui::SharedStateButton*>(line.mLeftWidget);
// match model against line // match model against line
// if don't match, then major change has happened, so do a full update // if don't match, then major change has happened, so do a full update
@ -176,7 +176,7 @@ namespace MWGui
else else
{ {
maxSpellIndexFound = spellIndex; maxSpellIndexFound = spellIndex;
Gui::SharedStateButton* costButton = reinterpret_cast<Gui::SharedStateButton*>(it->mRightWidget); Gui::SharedStateButton* costButton = reinterpret_cast<Gui::SharedStateButton*>(line.mRightWidget);
if ((costButton != nullptr) && (costButton->getCaption() != spell.mCostColumn)) if ((costButton != nullptr) && (costButton->getCaption() != spell.mCostColumn))
{ {
costButton->setCaption(spell.mCostColumn); costButton->setCaption(spell.mCostColumn);
@ -198,27 +198,25 @@ namespace MWGui
void SpellView::layoutWidgets() void SpellView::layoutWidgets()
{ {
int height = 0; int height = 0;
for (std::vector< LineInfo >::iterator it = mLines.begin(); for (LineInfo& line : mLines)
it != mLines.end(); ++it)
{ {
height += (it->mLeftWidget)->getHeight(); height += line.mLeftWidget->getHeight();
} }
bool scrollVisible = height > mScrollView->getHeight(); bool scrollVisible = height > mScrollView->getHeight();
int width = mScrollView->getWidth() - (scrollVisible ? 18 : 0); int width = mScrollView->getWidth() - (scrollVisible ? 18 : 0);
height = 0; height = 0;
for (std::vector< LineInfo >::iterator it = mLines.begin(); for (LineInfo& line : mLines)
it != mLines.end(); ++it)
{ {
int lineHeight = (it->mLeftWidget)->getHeight(); int lineHeight = line.mLeftWidget->getHeight();
(it->mLeftWidget)->setCoord(4, height, width - 8, lineHeight); line.mLeftWidget->setCoord(4, height, width - 8, lineHeight);
if (it->mRightWidget) if (line.mRightWidget)
{ {
(it->mRightWidget)->setCoord(4, height, width - 8, lineHeight); line.mRightWidget->setCoord(4, height, width - 8, lineHeight);
MyGUI::TextBox* second = (it->mRightWidget)->castType<MyGUI::TextBox>(false); MyGUI::TextBox* second = line.mRightWidget->castType<MyGUI::TextBox>(false);
if (second) if (second)
(it->mLeftWidget)->setSize(width - 8 - second->getTextSize().width, lineHeight); line.mLeftWidget->setSize(width - 8 - second->getTextSize().width, lineHeight);
} }
height += lineHeight; height += lineHeight;

@ -433,10 +433,8 @@ namespace MWGui
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2); addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2);
SkillList::const_iterator end = skills.end(); for (const int skillId : skills)
for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
{ {
int skillId = *it;
if (skillId < 0 || skillId >= ESM::Skill::Length) // Skip unknown skill indexes if (skillId < 0 || skillId >= ESM::Skill::Length) // Skip unknown skill indexes
continue; continue;
const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId]; const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId];
@ -499,9 +497,9 @@ namespace MWGui
{ {
mChanged = false; mChanged = false;
for (std::vector<MyGUI::Widget*>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it) for (MyGUI::Widget* widget : mSkillWidgets)
{ {
MyGUI::Gui::getInstance().destroyWidget(*it); MyGUI::Gui::getInstance().destroyWidget(widget);
} }
mSkillWidgets.clear(); mSkillWidgets.clear();
@ -550,11 +548,11 @@ namespace MWGui
const std::set<std::string> &expelled = PCstats.getExpelled(); const std::set<std::string> &expelled = PCstats.getExpelled();
bool firstFaction=true; bool firstFaction=true;
FactionList::const_iterator end = mFactions.end(); for (auto& factionPair : mFactions)
for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it)
{ {
const std::string& factionId = factionPair.first;
const ESM::Faction *faction = const ESM::Faction *faction =
store.get<ESM::Faction>().find(it->first); store.get<ESM::Faction>().find(factionId);
if (faction->mData.mIsHidden == 1) if (faction->mData.mIsHidden == 1)
continue; continue;
@ -575,11 +573,11 @@ namespace MWGui
text += std::string("#{fontcolourhtml=header}") + faction->mName; text += std::string("#{fontcolourhtml=header}") + faction->mName;
if (expelled.find(it->first) != expelled.end()) if (expelled.find(factionId) != expelled.end())
text += "\n#{fontcolourhtml=normal}#{sExpelled}"; text += "\n#{fontcolourhtml=normal}#{sExpelled}";
else else
{ {
int rank = it->second; int rank = factionPair.second;
rank = std::max(0, std::min(9, rank)); rank = std::max(0, std::min(9, rank));
text += std::string("\n#{fontcolourhtml=normal}") + faction->mRanks[rank]; text += std::string("\n#{fontcolourhtml=normal}") + faction->mRanks[rank];

@ -226,18 +226,17 @@ namespace MWGui
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(focus->getUserString("Spell")); MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(focus->getUserString("Spell"));
info.caption = spell->mName; info.caption = spell->mName;
Widgets::SpellEffectList effects; Widgets::SpellEffectList effects;
std::vector<ESM::ENAMstruct>::const_iterator end = spell->mEffects.mList.end(); for (const ESM::ENAMstruct& spellEffect : spell->mEffects.mList)
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->mEffects.mList.begin(); it != end; ++it)
{ {
Widgets::SpellEffectParams params; Widgets::SpellEffectParams params;
params.mEffectID = it->mEffectID; params.mEffectID = spellEffect.mEffectID;
params.mSkill = it->mSkill; params.mSkill = spellEffect.mSkill;
params.mAttribute = it->mAttribute; params.mAttribute = spellEffect.mAttribute;
params.mDuration = it->mDuration; params.mDuration = spellEffect.mDuration;
params.mMagnMin = it->mMagnMin; params.mMagnMin = spellEffect.mMagnMin;
params.mMagnMax = it->mMagnMax; params.mMagnMax = spellEffect.mMagnMax;
params.mRange = it->mRange; params.mRange = spellEffect.mRange;
params.mArea = it->mArea; params.mArea = spellEffect.mArea;
params.mIsConstant = (spell->mData.mType == ESM::Spell::ST_Ability); params.mIsConstant = (spell->mData.mType == ESM::Spell::ST_Ability);
params.mNoTarget = false; params.mNoTarget = false;
effects.push_back(params); effects.push_back(params);
@ -260,14 +259,13 @@ namespace MWGui
tooltip->setVisible(true); tooltip->setVisible(true);
std::map<std::string, std::string> userStrings = focus->getUserStrings(); std::map<std::string, std::string> userStrings = focus->getUserStrings();
for (std::map<std::string, std::string>::iterator it = userStrings.begin(); for (auto& userStringPair : userStrings)
it != userStrings.end(); ++it)
{ {
size_t underscorePos = it->first.find("_"); size_t underscorePos = userStringPair.first.find("_");
if (underscorePos == std::string::npos) if (underscorePos == std::string::npos)
continue; continue;
std::string key = it->first.substr(0, underscorePos); std::string key = userStringPair.first.substr(0, underscorePos);
std::string widgetName = it->first.substr(underscorePos+1, it->first.size()-(underscorePos+1)); std::string widgetName = userStringPair.first.substr(underscorePos+1, userStringPair.first.size()-(underscorePos+1));
type = "Property"; type = "Property";
size_t caretPos = key.find("^"); size_t caretPos = key.find("^");
@ -280,9 +278,9 @@ namespace MWGui
MyGUI::Widget* w; MyGUI::Widget* w;
getWidget(w, widgetName); getWidget(w, widgetName);
if (type == "Property") if (type == "Property")
w->setProperty(key, it->second); w->setProperty(key, userStringPair.second);
else if (type == "UserData") else if (type == "UserData")
w->setUserString(key, it->second); w->setUserString(key, userStringPair.second);
} }
tooltipSize = tooltip->getSize(); tooltipSize = tooltip->getSize();
@ -458,7 +456,7 @@ namespace MWGui
MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth), MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth),
((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
for (std::vector<std::string>::const_iterator it = info.notes.begin(); it != info.notes.end(); ++it) for (const std::string& note : info.notes)
{ {
MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("MarkerButton", MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("MarkerButton",
MyGUI::IntCoord(padding.left, totalSize.height+padding.top, 8, 8), MyGUI::Align::Default); MyGUI::IntCoord(padding.left, totalSize.height+padding.top, 8, 8), MyGUI::Align::Default);
@ -468,7 +466,7 @@ namespace MWGui
MyGUI::Align::Default); MyGUI::Align::Default);
edit->setEditMultiLine(true); edit->setEditMultiLine(true);
edit->setEditWordWrap(true); edit->setEditWordWrap(true);
edit->setCaption(*it); edit->setCaption(note);
edit->setSize(edit->getWidth(), edit->getTextSize().height); edit->setSize(edit->getWidth(), edit->getTextSize().height);
icon->setPosition(icon->getLeft(),(edit->getTop()+edit->getBottom())/2-icon->getHeight()/2); icon->setPosition(icon->getLeft(),(edit->getTop()+edit->getBottom())/2-icon->getHeight()/2);
totalSize.height += std::max(edit->getHeight(), icon->getHeight()); totalSize.height += std::max(edit->getHeight(), icon->getHeight());
@ -653,12 +651,12 @@ namespace MWGui
std::vector<std::pair<std::string, int> > itemOwners = std::vector<std::pair<std::string, int> > itemOwners =
MWBase::Environment::get().getMechanicsManager()->getStolenItemOwners(cellref.getRefId()); MWBase::Environment::get().getMechanicsManager()->getStolenItemOwners(cellref.getRefId());
for (std::vector<std::pair<std::string, int> >::const_iterator it = itemOwners.begin(); it != itemOwners.end(); ++it) for (std::pair<std::string, int>& owner : itemOwners)
{ {
if (it->second == std::numeric_limits<int>::max()) if (owner.second == std::numeric_limits<int>::max())
ret += std::string("\nStolen from ") + it->first; // for legacy (ESS) savegames ret += std::string("\nStolen from ") + owner.first; // for legacy (ESS) savegames
else else
ret += std::string("\nStolen ") + MyGUI::utility::toString(it->second) + " from " + it->first; ret += std::string("\nStolen ") + MyGUI::utility::toString(owner.second) + " from " + owner.first;
} }
ret += getMiscString(cellref.getGlobalVariable(), "Global"); ret += getMiscString(cellref.getGlobalVariable(), "Global");
@ -732,17 +730,16 @@ namespace MWGui
MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
bool isFirst = true; bool isFirst = true;
MWWorld::Store<ESM::Skill>::iterator it = skills.begin(); for (auto& skillPair : skills)
for (; it != skills.end(); ++it)
{ {
if (it->second.mData.mSpecialization == specId) if (skillPair.second.mData.mSpecialization == specId)
{ {
if (isFirst) if (isFirst)
isFirst = false; isFirst = false;
else else
specText += "\n"; specText += "\n";
specText += std::string("#{") + ESM::Skill::sSkillNameIds[it->first] + "}"; specText += std::string("#{") + ESM::Skill::sSkillNameIds[skillPair.first] + "}";
} }
} }
widget->setUserString("Caption_ColumnText", specText); widget->setUserString("Caption_ColumnText", specText);
@ -767,9 +764,8 @@ namespace MWGui
std::vector<std::string> abilities, powers, spells; std::vector<std::string> abilities, powers, spells;
for (std::vector<std::string>::const_iterator it = sign->mPowers.mList.begin(); it != sign->mPowers.mList.end(); ++it) for (const std::string& spellId : sign->mPowers.mList)
{ {
const std::string &spellId = *it;
const ESM::Spell *spell = store.get<ESM::Spell>().search(spellId); const ESM::Spell *spell = store.get<ESM::Spell>().search(spellId);
if (!spell) if (!spell)
continue; // Skip spells which cannot be found continue; // Skip spells which cannot be found
@ -797,15 +793,15 @@ namespace MWGui
for (int category = 0; category < 3; ++category) for (int category = 0; category < 3; ++category)
{ {
for (std::vector<std::string>::const_iterator it = categories[category].spells.begin(); it != categories[category].spells.end(); ++it) bool addHeader = true;
for (const std::string& spellId : categories[category].spells)
{ {
if (it == categories[category].spells.begin()) if (addHeader)
{ {
text += std::string("\n\n#{fontcolourhtml=header}") + std::string("#{") + categories[category].label + "}"; text += std::string("\n\n#{fontcolourhtml=header}") + std::string("#{") + categories[category].label + "}";
addHeader = false;
} }
const std::string &spellId = *it;
const ESM::Spell *spell = store.get<ESM::Spell>().find(spellId); const ESM::Spell *spell = store.get<ESM::Spell>().find(spellId);
text += "\n#{fontcolourhtml=normal}" + spell->mName; text += "\n#{fontcolourhtml=normal}" + spell->mName;
} }

@ -36,13 +36,12 @@ namespace MWGui
void TradeItemModel::borrowImpl(const ItemStack &item, std::vector<ItemStack> &out) void TradeItemModel::borrowImpl(const ItemStack &item, std::vector<ItemStack> &out)
{ {
std::vector<ItemStack>::iterator it = out.begin();
bool found = false; bool found = false;
for (; it != out.end(); ++it) for (ItemStack& itemStack : out)
{ {
if (it->mBase == item.mBase) if (itemStack.mBase == item.mBase)
{ {
it->mCount += item.mCount; itemStack.mCount += item.mCount;
found = true; found = true;
break; break;
} }
@ -100,15 +99,15 @@ namespace MWGui
void TradeItemModel::adjustEncumbrance(float &encumbrance) void TradeItemModel::adjustEncumbrance(float &encumbrance)
{ {
for (std::vector<ItemStack>::iterator it = mBorrowedToUs.begin(); it != mBorrowedToUs.end(); ++it) for (ItemStack& itemStack : mBorrowedToUs)
{ {
MWWorld::Ptr item = it->mBase; MWWorld::Ptr& item = itemStack.mBase;
encumbrance += item.getClass().getWeight(item) * it->mCount; encumbrance += item.getClass().getWeight(item) * itemStack.mCount;
} }
for (std::vector<ItemStack>::iterator it = mBorrowedFromUs.begin(); it != mBorrowedFromUs.end(); ++it) for (ItemStack& itemStack : mBorrowedFromUs)
{ {
MWWorld::Ptr item = it->mBase; MWWorld::Ptr& item = itemStack.mBase;
encumbrance -= item.getClass().getWeight(item) * it->mCount; encumbrance -= item.getClass().getWeight(item) * itemStack.mCount;
} }
encumbrance = std::max(0.f, encumbrance); encumbrance = std::max(0.f, encumbrance);
} }
@ -126,15 +125,14 @@ namespace MWGui
void TradeItemModel::transferItems() void TradeItemModel::transferItems()
{ {
std::vector<ItemStack>::iterator it = mBorrowedToUs.begin(); for (ItemStack& itemStack : mBorrowedToUs)
for (; it != mBorrowedToUs.end(); ++it)
{ {
// get index in the source model // get index in the source model
ItemModel* sourceModel = it->mCreator; ItemModel* sourceModel = itemStack.mCreator;
size_t i=0; size_t i=0;
for (; i<sourceModel->getItemCount(); ++i) for (; i<sourceModel->getItemCount(); ++i)
{ {
if (it->mBase == sourceModel->getItem(i).mBase) if (itemStack.mBase == sourceModel->getItem(i).mBase)
break; break;
} }
if (i == sourceModel->getItemCount()) if (i == sourceModel->getItemCount())
@ -142,9 +140,9 @@ namespace MWGui
const ItemStack& item = sourceModel->getItem(i); const ItemStack& item = sourceModel->getItem(i);
// copy the borrowed items to our model // copy the borrowed items to our model
copyItem(item, it->mCount); copyItem(item, itemStack.mCount);
// then remove them from the source model // then remove them from the source model
sourceModel->removeItem(item, it->mCount); sourceModel->removeItem(item, itemStack.mCount);
} }
mBorrowedToUs.clear(); mBorrowedToUs.clear();
mBorrowedFromUs.clear(); mBorrowedFromUs.clear();
@ -189,14 +187,13 @@ namespace MWGui
} }
// don't show items that we borrowed to someone else // don't show items that we borrowed to someone else
std::vector<ItemStack>::iterator it = mBorrowedFromUs.begin(); for (ItemStack& itemStack : mBorrowedFromUs)
for (; it != mBorrowedFromUs.end(); ++it)
{ {
if (it->mBase == item.mBase) if (itemStack.mBase == item.mBase)
{ {
if (item.mCount < it->mCount) if (item.mCount < itemStack.mCount)
throw std::runtime_error("Lent more items than present"); throw std::runtime_error("Lent more items than present");
item.mCount -= it->mCount; item.mCount -= itemStack.mCount;
} }
} }
@ -205,12 +202,10 @@ namespace MWGui
} }
// add items borrowed to us // add items borrowed to us
std::vector<ItemStack>::iterator it = mBorrowedToUs.begin(); for (ItemStack& itemStack : mBorrowedToUs)
for (; it != mBorrowedToUs.end(); ++it)
{ {
ItemStack item = *it; itemStack.mType = ItemStack::Type_Barter;
item.mType = ItemStack::Type_Barter; mItems.push_back(itemStack);
mItems.push_back(item);
} }
} }

@ -106,9 +106,9 @@ namespace MWGui
// Also restock any containers owned by this merchant, which are also available to buy in the trade window // Also restock any containers owned by this merchant, which are also available to buy in the trade window
std::vector<MWWorld::Ptr> itemSources; std::vector<MWWorld::Ptr> itemSources;
MWBase::Environment::get().getWorld()->getContainersOwnedBy(mPtr, itemSources); MWBase::Environment::get().getWorld()->getContainersOwnedBy(mPtr, itemSources);
for (std::vector<MWWorld::Ptr>::iterator it = itemSources.begin(); it != itemSources.end(); ++it) for (MWWorld::Ptr& source : itemSources)
{ {
it->getClass().restock(*it); source.getClass().restock(source);
} }
} }
@ -306,15 +306,15 @@ namespace MWGui
} }
// check if the player is attempting to sell back an item stolen from this actor // check if the player is attempting to sell back an item stolen from this actor
for (std::vector<ItemStack>::iterator it = merchantBought.begin(); it != merchantBought.end(); ++it) for (ItemStack& itemStack : merchantBought)
{ {
if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(it->mBase.getCellRef().getRefId(), mPtr)) if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(itemStack.mBase.getCellRef().getRefId(), mPtr))
{ {
std::string msg = gmst.find("sNotifyMessage49")->mValue.getString(); std::string msg = gmst.find("sNotifyMessage49")->mValue.getString();
Misc::StringUtils::replace(msg, "%s", it->mBase.getClass().getName(it->mBase).c_str(), 2); Misc::StringUtils::replace(msg, "%s", itemStack.mBase.getClass().getName(itemStack.mBase).c_str(), 2);
MWBase::Environment::get().getWindowManager()->messageBox(msg); MWBase::Environment::get().getWindowManager()->messageBox(msg);
MWBase::Environment::get().getMechanicsManager()->confiscateStolenItemToOwner(player, it->mBase, mPtr, it->mCount); MWBase::Environment::get().getMechanicsManager()->confiscateStolenItemToOwner(player, itemStack.mBase, mPtr, itemStack.mCount);
onCancelButtonClicked(mCancelButton); onCancelButtonClicked(mCancelButton);
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode(); MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
@ -469,15 +469,15 @@ namespace MWGui
int merchantOffer = 0; int merchantOffer = 0;
std::vector<ItemStack> playerBorrowed = playerTradeModel->getItemsBorrowedToUs(); std::vector<ItemStack> playerBorrowed = playerTradeModel->getItemsBorrowedToUs();
for (std::vector<ItemStack>::const_iterator it = playerBorrowed.begin(); it != playerBorrowed.end(); ++it) for (const ItemStack& itemStack : playerBorrowed)
{ {
merchantOffer -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(it->mBase, it->mCount), true); merchantOffer -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(itemStack.mBase, itemStack.mCount), true);
} }
std::vector<ItemStack> merchantBorrowed = mTradeModel->getItemsBorrowedToUs(); std::vector<ItemStack> merchantBorrowed = mTradeModel->getItemsBorrowedToUs();
for (std::vector<ItemStack>::const_iterator it = merchantBorrowed.begin(); it != merchantBorrowed.end(); ++it) for (const ItemStack& itemStack : merchantBorrowed)
{ {
merchantOffer += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(it->mBase, it->mCount), false); merchantOffer += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(itemStack.mBase, itemStack.mCount), false);
} }
int diff = merchantOffer - mCurrentMerchantOffer; int diff = merchantOffer - mCurrentMerchantOffer;

@ -222,18 +222,17 @@ namespace MWGui
const ESM::Spell *spell = store.get<ESM::Spell>().search(mId); const ESM::Spell *spell = store.get<ESM::Spell>().search(mId);
MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");
std::vector<ESM::ENAMstruct>::const_iterator end = spell->mEffects.mList.end(); for (const ESM::ENAMstruct& effectInfo : spell->mEffects.mList)
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->mEffects.mList.begin(); it != end; ++it)
{ {
MWSpellEffectPtr effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default); MWSpellEffectPtr effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
SpellEffectParams params; SpellEffectParams params;
params.mEffectID = it->mEffectID; params.mEffectID = effectInfo.mEffectID;
params.mSkill = it->mSkill; params.mSkill = effectInfo.mSkill;
params.mAttribute = it->mAttribute; params.mAttribute = effectInfo.mAttribute;
params.mDuration = it->mDuration; params.mDuration = effectInfo.mDuration;
params.mMagnMin = it->mMagnMin; params.mMagnMin = effectInfo.mMagnMin;
params.mMagnMax = it->mMagnMax; params.mMagnMax = effectInfo.mMagnMax;
params.mRange = it->mRange; params.mRange = effectInfo.mRange;
params.mIsConstant = (flags & MWEffectList::EF_Constant) != 0; params.mIsConstant = (flags & MWEffectList::EF_Constant) != 0;
params.mNoTarget = (flags & MWEffectList::EF_NoTarget); params.mNoTarget = (flags & MWEffectList::EF_NoTarget);
effect->setSpellEffect(params); effect->setSpellEffect(params);
@ -289,13 +288,12 @@ namespace MWGui
MWSpellEffectPtr effect = nullptr; MWSpellEffectPtr effect = nullptr;
int maxwidth = coord.width; int maxwidth = coord.width;
for (SpellEffectList::iterator it=mEffectList.begin(); for (auto& effectInfo : mEffectList)
it != mEffectList.end(); ++it)
{ {
effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default); effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
it->mIsConstant = (flags & EF_Constant) || it->mIsConstant; effectInfo.mIsConstant = (flags & EF_Constant) || effectInfo.mIsConstant;
it->mNoTarget = (flags & EF_NoTarget) || it->mNoTarget; effectInfo.mNoTarget = (flags & EF_NoTarget) || effectInfo.mNoTarget;
effect->setSpellEffect(*it); effect->setSpellEffect(effectInfo);
effects.push_back(effect); effects.push_back(effect);
if (effect->getRequestedWidth() > maxwidth) if (effect->getRequestedWidth() > maxwidth)
maxwidth = effect->getRequestedWidth(); maxwidth = effect->getRequestedWidth();
@ -304,9 +302,9 @@ namespace MWGui
} }
// ... then adjust the size for all widgets // ... then adjust the size for all widgets
for (std::vector<MyGUI::Widget*>::iterator it = effects.begin(); it != effects.end(); ++it) for (MyGUI::Widget* effectWidget : effects)
{ {
effect = (*it)->castType<MWSpellEffect>(); effect = effectWidget->castType<MWSpellEffect>();
bool needcenter = center && (maxwidth > effect->getRequestedWidth()); bool needcenter = center && (maxwidth > effect->getRequestedWidth());
int diff = maxwidth - effect->getRequestedWidth(); int diff = maxwidth - effect->getRequestedWidth();
if (needcenter) if (needcenter)
@ -339,18 +337,17 @@ namespace MWGui
SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects) SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects)
{ {
SpellEffectList result; SpellEffectList result;
std::vector<ESM::ENAMstruct>::const_iterator end = effects->mList.end(); for (const ESM::ENAMstruct& effectInfo : effects->mList)
for (std::vector<ESM::ENAMstruct>::const_iterator it = effects->mList.begin(); it != end; ++it)
{ {
SpellEffectParams params; SpellEffectParams params;
params.mEffectID = it->mEffectID; params.mEffectID = effectInfo.mEffectID;
params.mSkill = it->mSkill; params.mSkill = effectInfo.mSkill;
params.mAttribute = it->mAttribute; params.mAttribute = effectInfo.mAttribute;
params.mDuration = it->mDuration; params.mDuration = effectInfo.mDuration;
params.mMagnMin = it->mMagnMin; params.mMagnMin = effectInfo.mMagnMin;
params.mMagnMax = it->mMagnMax; params.mMagnMax = effectInfo.mMagnMax;
params.mRange = it->mRange; params.mRange = effectInfo.mRange;
params.mArea = it->mArea; params.mArea = effectInfo.mArea;
result.push_back(params); result.push_back(params);
} }
return result; return result;

@ -670,9 +670,9 @@ namespace MWGui
// Delete any dialogs which are no longer in use // Delete any dialogs which are no longer in use
if (!mGarbageDialogs.empty()) if (!mGarbageDialogs.empty())
{ {
for (std::vector<Layout*>::iterator it = mGarbageDialogs.begin(); it != mGarbageDialogs.end(); ++it) for (Layout* widget : mGarbageDialogs)
{ {
delete *it; delete widget;
} }
mGarbageDialogs.clear(); mGarbageDialogs.clear();
} }
@ -1211,14 +1211,13 @@ namespace MWGui
{ {
mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI")); mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI"));
for (Settings::CategorySettingVector::const_iterator it = changed.begin(); for (const auto& setting : changed)
it != changed.end(); ++it)
{ {
if (it->first == "HUD" && it->second == "crosshair") if (setting.first == "HUD" && setting.second == "crosshair")
mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD"); mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD");
else if (it->first == "GUI" && it->second == "subtitles") else if (setting.first == "GUI" && setting.second == "subtitles")
mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI"); mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI");
else if (it->first == "GUI" && it->second == "menu transparency") else if (setting.first == "GUI" && setting.second == "menu transparency")
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI")); setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
} }
} }

@ -16,10 +16,10 @@ namespace MWGui
MyGUI::Button* button = nullptr; MyGUI::Button* button = nullptr;
MyGUI::VectorWidgetPtr widgets = window->getSkinWidgetsByName("Action"); MyGUI::VectorWidgetPtr widgets = window->getSkinWidgetsByName("Action");
for (MyGUI::VectorWidgetPtr::iterator it = widgets.begin(); it != widgets.end(); ++it) for (MyGUI::Widget* widget : widgets)
{ {
if ((*it)->isUserString("HideWindowOnDoubleClick")) if (widget->isUserString("HideWindowOnDoubleClick"))
button = (*it)->castType<MyGUI::Button>(); button = widget->castType<MyGUI::Button>();
} }
if (button) if (button)

Loading…
Cancel
Save