mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 18:39:40 +00:00
Sort class list in select class dialog
This commit is contained in:
parent
768c4a5757
commit
9a1bde684f
1 changed files with 20 additions and 8 deletions
|
@ -9,6 +9,16 @@
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
bool sortClasses(const std::pair<std::string, std::string>& left, const std::pair<std::string, std::string>& right)
|
||||||
|
{
|
||||||
|
return left.second.compare(right.second) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -129,8 +139,6 @@ namespace MWGui
|
||||||
if (Misc::StringUtils::ciEqual(*mClassList->getItemDataAt<std::string>(i), classId))
|
if (Misc::StringUtils::ciEqual(*mClassList->getItemDataAt<std::string>(i), classId))
|
||||||
{
|
{
|
||||||
mClassList->setIndexSelected(i);
|
mClassList->setIndexSelected(i);
|
||||||
MyGUI::Button* okButton;
|
|
||||||
getWidget(okButton, "OKButton");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,9 +173,6 @@ namespace MWGui
|
||||||
if (_index == MyGUI::ITEM_NONE)
|
if (_index == MyGUI::ITEM_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MyGUI::Button* okButton;
|
|
||||||
getWidget(okButton, "OKButton");
|
|
||||||
|
|
||||||
const std::string *classId = mClassList->getItemDataAt<std::string>(_index);
|
const std::string *classId = mClassList->getItemDataAt<std::string>(_index);
|
||||||
if (Misc::StringUtils::ciEqual(mCurrentClassId, *classId))
|
if (Misc::StringUtils::ciEqual(mCurrentClassId, *classId))
|
||||||
return;
|
return;
|
||||||
|
@ -184,7 +189,7 @@ namespace MWGui
|
||||||
|
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
int index = 0;
|
std::vector<std::pair<std::string, std::string> > items; // class id, class name
|
||||||
MWWorld::Store<ESM::Class>::iterator it = store.get<ESM::Class>().begin();
|
MWWorld::Store<ESM::Class>::iterator it = store.get<ESM::Class>().begin();
|
||||||
for (; it != store.get<ESM::Class>().end(); ++it)
|
for (; it != store.get<ESM::Class>().end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -192,8 +197,15 @@ namespace MWGui
|
||||||
if (!playable) // Only display playable classes
|
if (!playable) // Only display playable classes
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string &id = it->mId;
|
items.push_back(std::make_pair(it->mId, it->mName));
|
||||||
mClassList->addItem(it->mName, id);
|
}
|
||||||
|
std::sort(items.begin(), items.end(), sortClasses);
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for (std::vector<std::pair<std::string, std::string> >::const_iterator it = items.begin(); it != items.end(); ++it)
|
||||||
|
{
|
||||||
|
const std::string &id = it->first;
|
||||||
|
mClassList->addItem(it->second, id);
|
||||||
if (mCurrentClassId.empty())
|
if (mCurrentClassId.empty())
|
||||||
{
|
{
|
||||||
mCurrentClassId = id;
|
mCurrentClassId = id;
|
||||||
|
|
Loading…
Reference in a new issue