mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 23:09:46 +00:00
Sort repair and recharge menu list alphabetically (bug #7642)
This commit is contained in:
parent
d84caff94d
commit
733a6e01ad
4 changed files with 32 additions and 15 deletions
|
@ -84,6 +84,7 @@
|
||||||
Bug #7630: Charm can be cast on creatures
|
Bug #7630: Charm can be cast on creatures
|
||||||
Bug #7631: Cannot trade with/talk to Creeper or Mudcrab Merchant when they're fleeing
|
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 #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
|
Bug #7647: NPC walk cycle bugs after greeting player
|
||||||
Feature #3537: Shader-based water ripples
|
Feature #3537: Shader-based water ripples
|
||||||
Feature #5492: Let rain and snow collide with statics
|
Feature #5492: Let rain and snow collide with statics
|
||||||
|
|
|
@ -128,6 +128,11 @@ namespace MWGui
|
||||||
|
|
||||||
mLines.swap(lines);
|
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();
|
layoutWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace MWGui
|
||||||
|
|
||||||
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||||
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
|
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)
|
for (MWWorld::ContainerStoreIterator iter(store.begin(categories)); iter != store.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (iter->getClass().hasItemHealth(*iter))
|
if (iter->getClass().hasItemHealth(*iter))
|
||||||
|
@ -76,6 +78,15 @@ namespace MWGui
|
||||||
name += " - " + MyGUI::utility::toString(price)
|
name += " - " + MyGUI::utility::toString(price)
|
||||||
+ MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("sgp")->mValue.getString();
|
+ MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("sgp")->mValue.getString();
|
||||||
|
|
||||||
|
items.emplace_back(name, price, *iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)); });
|
||||||
|
|
||||||
|
for (const auto& [name, price, ptr] : items)
|
||||||
|
{
|
||||||
MyGUI::Button* button = mList->createWidget<MyGUI::Button>(price <= playerGold
|
MyGUI::Button* button = mList->createWidget<MyGUI::Button>(price <= playerGold
|
||||||
? "SandTextButton"
|
? "SandTextButton"
|
||||||
: "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
|
: "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
|
||||||
|
@ -84,14 +95,14 @@ namespace MWGui
|
||||||
currentY += lineHeight;
|
currentY += lineHeight;
|
||||||
|
|
||||||
button->setUserString("Price", MyGUI::utility::toString(price));
|
button->setUserString("Price", MyGUI::utility::toString(price));
|
||||||
button->setUserData(MWWorld::Ptr(*iter));
|
button->setUserData(MWWorld::Ptr(ptr));
|
||||||
button->setCaptionWithReplacing(name);
|
button->setCaptionWithReplacing(name);
|
||||||
button->setSize(mList->getWidth(), lineHeight);
|
button->setSize(mList->getWidth(), lineHeight);
|
||||||
button->eventMouseWheel += MyGUI::newDelegate(this, &MerchantRepair::onMouseWheel);
|
button->eventMouseWheel += MyGUI::newDelegate(this, &MerchantRepair::onMouseWheel);
|
||||||
button->setUserString("ToolTipType", "ItemPtr");
|
button->setUserString("ToolTipType", "ItemPtr");
|
||||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MerchantRepair::onRepairButtonClick);
|
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MerchantRepair::onRepairButtonClick);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the
|
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the
|
||||||
// scrollbar is hidden
|
// scrollbar is hidden
|
||||||
mList->setVisibleVScroll(false);
|
mList->setVisibleVScroll(false);
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace MWGui
|
||||||
= new SortFilterItemModel(std::make_unique<InventoryItemModel>(MWMechanics::getPlayer()));
|
= new SortFilterItemModel(std::make_unique<InventoryItemModel>(MWMechanics::getPlayer()));
|
||||||
model->setFilter(SortFilterItemModel::Filter_OnlyRepairable);
|
model->setFilter(SortFilterItemModel::Filter_OnlyRepairable);
|
||||||
mRepairBox->setModel(model);
|
mRepairBox->setModel(model);
|
||||||
|
mRepairBox->update();
|
||||||
// Reset scrollbars
|
// Reset scrollbars
|
||||||
mRepairBox->resetScrollbars();
|
mRepairBox->resetScrollbars();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue