mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Changed: Sort tribe fame list
--HG-- branch : develop
This commit is contained in:
parent
d6faf81c81
commit
9390f9cca5
2 changed files with 63 additions and 0 deletions
|
@ -1431,6 +1431,8 @@ function game:onInGameDbInitialized()
|
||||||
end
|
end
|
||||||
|
|
||||||
game:setInfoPlayerCharacterRace()
|
game:setInfoPlayerCharacterRace()
|
||||||
|
|
||||||
|
runAH(nil, "sort_tribefame", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
function game:onWebIgReady()
|
function game:onWebIgReady()
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "stdpch.h"
|
#include "stdpch.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <locale>
|
||||||
|
|
||||||
// Interface includes
|
// Interface includes
|
||||||
#include "interface_manager.h"
|
#include "interface_manager.h"
|
||||||
|
@ -4511,3 +4512,63 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_ACTION_HANDLER( CHandlerEmote, "emote");
|
REGISTER_ACTION_HANDLER( CHandlerEmote, "emote");
|
||||||
|
|
||||||
|
//=================================================================================================================
|
||||||
|
class CHandlerSortTribeFame : public IActionHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
|
||||||
|
{
|
||||||
|
CGroupList * list = dynamic_cast<CGroupList*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:fame:content:tribes:list"));
|
||||||
|
if (list && list->getNumChildren() > 1)
|
||||||
|
{
|
||||||
|
uint nbChilds = list->getNumChildren();
|
||||||
|
|
||||||
|
// std::collate does not work with ucchar
|
||||||
|
std::vector<string> names;
|
||||||
|
|
||||||
|
for (uint i = 0; i < nbChilds; ++i)
|
||||||
|
{
|
||||||
|
CInterfaceGroup *pIG = dynamic_cast<CInterfaceGroup*>(list->getChild(i));
|
||||||
|
if (!pIG) break;
|
||||||
|
|
||||||
|
CViewText *pVT = dynamic_cast<CViewText *>(pIG->getView("t"));
|
||||||
|
if (!pVT) break;
|
||||||
|
|
||||||
|
names.push_back(toUpper(pVT->getText().toUtf8()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (names.size() != nbChilds)
|
||||||
|
{
|
||||||
|
nlwarning("Failed to sort tribe fame list");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::locale loc("");
|
||||||
|
const std::collate<char>& coll = std::use_facet<std::collate<char> >(loc);
|
||||||
|
|
||||||
|
for(uint i = 0; i < nbChilds - 1; ++i)
|
||||||
|
{
|
||||||
|
uint imin = i;
|
||||||
|
for(uint j = i; j < nbChilds; j++)
|
||||||
|
{
|
||||||
|
// simple comparison fails with accented letters
|
||||||
|
if (coll.compare(names[j].c_str(), names[j].c_str() + names[j].size(),
|
||||||
|
names[imin].c_str(), names[imin].c_str() + names[imin].size()) < 0)
|
||||||
|
{
|
||||||
|
imin = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (imin != i)
|
||||||
|
{
|
||||||
|
list->swapChildren(i, imin);
|
||||||
|
std::swap(names[i], names[imin]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list->invalidateCoords();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
REGISTER_ACTION_HANDLER( CHandlerSortTribeFame, "sort_tribefame");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue