mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-26 15:39:51 +00:00
Merge branch 'sortalphabetcalinrechargeandrepairmenu' into 'master'
Sort repair and recharge menu list alphabetically See merge request OpenMW/openmw!3524
This commit is contained in:
commit
6e069161a4
@ -85,6 +85,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);
|
||||
|
||||
currentY += lineHeight;
|
||||
|
||||
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);
|
||||
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
|
||||
? "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…
x
Reference in New Issue
Block a user