mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-19 07:28:43 +00:00
Merge with develop
--HG-- branch : compatibility-develop
This commit is contained in:
commit
37d6dc50f0
2 changed files with 63 additions and 0 deletions
|
@ -1431,6 +1431,8 @@ function game:onInGameDbInitialized()
|
|||
end
|
||||
|
||||
game:setInfoPlayerCharacterRace()
|
||||
|
||||
runAH(nil, "sort_tribefame", "")
|
||||
end
|
||||
|
||||
function game:onWebIgReady()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "stdpch.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <locale>
|
||||
|
||||
// Interface includes
|
||||
#include "interface_manager.h"
|
||||
|
@ -4511,3 +4512,63 @@ public:
|
|||
}
|
||||
};
|
||||
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