mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 09:53:50 +00:00
bug #412: sort birth signs
This commit is contained in:
parent
5e9153e2b8
commit
fbe3538f32
1 changed files with 24 additions and 4 deletions
|
@ -14,6 +14,16 @@
|
|||
using namespace MWGui;
|
||||
using namespace Widgets;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool sortBirthSigns(const std::pair<std::string, const ESM::BirthSign*>& left, const std::pair<std::string, const ESM::BirthSign*>& right)
|
||||
{
|
||||
return left.second->mName.compare (right.second->mName) < 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager)
|
||||
: WindowBase("openmw_chargen_birth.layout", parWindowManager)
|
||||
{
|
||||
|
@ -115,11 +125,21 @@ void BirthDialog::updateBirths()
|
|||
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin();
|
||||
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end();
|
||||
int index = 0;
|
||||
for (; it != end; ++it)
|
||||
|
||||
// sort by name
|
||||
std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns;
|
||||
for (; it!=end; ++it)
|
||||
{
|
||||
const ESM::BirthSign &birth = it->second;
|
||||
mBirthList->addItem(birth.mName, it->first);
|
||||
if (boost::iequals(it->first, mCurrentBirthId))
|
||||
std::string id = it->first;
|
||||
const ESM::BirthSign* sign = &it->second;
|
||||
birthSigns.push_back(std::make_pair(id, sign));
|
||||
}
|
||||
std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns);
|
||||
|
||||
for (std::vector < std::pair<std::string, const ESM::BirthSign*> >::const_iterator it2 = birthSigns.begin(); it2 != birthSigns.end(); ++it2)
|
||||
{
|
||||
mBirthList->addItem(it2->second->mName, it2->first);
|
||||
if (boost::iequals(it2->first, mCurrentBirthId))
|
||||
mBirthList->setIndexSelected(index);
|
||||
++index;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue