Sort repair and recharge menu list alphabetically (bug #7642)

macos_ci_fix
Kindi 7 months ago committed by Alexei Kotov
parent d84caff94d
commit 733a6e01ad

@ -84,6 +84,7 @@
Bug #7630: Charm can be cast on creatures
Bug #7631: Cannot trade with/talk to Creeper or Mudcrab Merchant when they're fleeing
Bug #7639: NPCs don't use hand-to-hand if their other melee skills were damaged during combat
Bug #7642: Items in repair and recharge menus aren't sorted alphabetically
Bug #7647: NPC walk cycle bugs after greeting player
Feature #3537: Shader-based water ripples
Feature #5492: Let rain and snow collide with statics

@ -128,6 +128,11 @@ namespace MWGui
mLines.swap(lines);
std::stable_sort(mLines.begin(), mLines.end(),
[](const MWGui::ItemChargeView::Line& a, const MWGui::ItemChargeView::Line& b) {
return Misc::StringUtils::ciLess(a.mText->getCaption().asUTF8(), b.mText->getCaption().asUTF8());
});
layoutWidgets();
}

@ -47,6 +47,8 @@ namespace MWGui
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
std::vector<std::tuple<std::string, int, MWWorld::Ptr>> items;
for (MWWorld::ContainerStoreIterator iter(store.begin(categories)); iter != store.end(); ++iter)
{
if (iter->getClass().hasItemHealth(*iter))
@ -76,22 +78,31 @@ namespace MWGui
name += " - " + MyGUI::utility::toString(price)
+ MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("sgp")->mValue.getString();
MyGUI::Button* button = mList->createWidget<MyGUI::Button>(price <= playerGold
? "SandTextButton"
: "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
0, currentY, 0, lineHeight, MyGUI::Align::Default);
items.emplace_back(name, price, *iter);
}
}
currentY += lineHeight;
std::stable_sort(items.begin(), items.end(),
[](const auto& a, const auto& b) { return Misc::StringUtils::ciLess(std::get<0>(a), std::get<0>(b)); });
button->setUserString("Price", MyGUI::utility::toString(price));
button->setUserData(MWWorld::Ptr(*iter));
button->setCaptionWithReplacing(name);
button->setSize(mList->getWidth(), lineHeight);
button->eventMouseWheel += MyGUI::newDelegate(this, &MerchantRepair::onMouseWheel);
button->setUserString("ToolTipType", "ItemPtr");
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MerchantRepair::onRepairButtonClick);
}
for (const auto& [name, price, ptr] : items)
{
MyGUI::Button* button = mList->createWidget<MyGUI::Button>(price <= playerGold
? "SandTextButton"
: "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
0, currentY, 0, lineHeight, MyGUI::Align::Default);
currentY += lineHeight;
button->setUserString("Price", MyGUI::utility::toString(price));
button->setUserData(MWWorld::Ptr(ptr));
button->setCaptionWithReplacing(name);
button->setSize(mList->getWidth(), lineHeight);
button->eventMouseWheel += MyGUI::newDelegate(this, &MerchantRepair::onMouseWheel);
button->setUserString("ToolTipType", "ItemPtr");
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MerchantRepair::onRepairButtonClick);
}
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the
// scrollbar is hidden
mList->setVisibleVScroll(false);

@ -49,7 +49,7 @@ namespace MWGui
= new SortFilterItemModel(std::make_unique<InventoryItemModel>(MWMechanics::getPlayer()));
model->setFilter(SortFilterItemModel::Filter_OnlyRepairable);
mRepairBox->setModel(model);
mRepairBox->update();
// Reset scrollbars
mRepairBox->resetScrollbars();
}

Loading…
Cancel
Save