mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Fix: Sorted the item list in the debug overlay
This commit is contained in:
parent
f870ef2a10
commit
96dcd30e26
|
|
@ -39,17 +39,37 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa
|
|||
m_buttonSetNight.init(L"Set Night", eControl_SetNight);
|
||||
|
||||
m_buttonListItems.init(eControl_Items);
|
||||
|
||||
// Sort items alphabetically
|
||||
std::vector<std::pair<std::wstring, unsigned int>> sortedItems;
|
||||
for (unsigned int i = 0; i < Item::items.length; ++i)
|
||||
{
|
||||
if (Item::items[i] != NULL)
|
||||
{
|
||||
sortedItems.push_back(std::make_pair(std::wstring(app.GetString(Item::items[i]->getDescriptionId())), i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < (int)sortedItems.size(); ++i)
|
||||
{
|
||||
auto key = sortedItems[i];
|
||||
int j = i - 1;
|
||||
while (j >= 0 && sortedItems[j].first > key.first)
|
||||
{
|
||||
sortedItems[j + 1] = sortedItems[j];
|
||||
--j;
|
||||
}
|
||||
sortedItems[j + 1] = key;
|
||||
}
|
||||
|
||||
// Populate the list in sorted order
|
||||
int listId = 0;
|
||||
for(unsigned int i = 0; i < Item::items.length; ++i)
|
||||
{
|
||||
if(Item::items[i] != NULL)
|
||||
{
|
||||
m_itemIds.push_back(i);
|
||||
m_buttonListItems.addItem(app.GetString(Item::items[i]->getDescriptionId()), listId);
|
||||
++listId;
|
||||
}
|
||||
}
|
||||
for (const auto& entry : sortedItems)
|
||||
{
|
||||
m_itemIds.push_back(entry.second);
|
||||
m_buttonListItems.addItem(entry.first.c_str(), listId);
|
||||
++listId;
|
||||
}
|
||||
|
||||
m_buttonListEnchantments.init(eControl_Enchantments);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<LastConfigDeployed>Debug</LastConfigDeployed>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory>
|
||||
|
|
|
|||
Loading…
Reference in a new issue