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
|
|
@ -40,16 +40,36 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa
|
||||||
|
|
||||||
m_buttonListItems.init(eControl_Items);
|
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;
|
int listId = 0;
|
||||||
for(unsigned int i = 0; i < Item::items.length; ++i)
|
for (const auto& entry : sortedItems)
|
||||||
{
|
{
|
||||||
if(Item::items[i] != NULL)
|
m_itemIds.push_back(entry.second);
|
||||||
{
|
m_buttonListItems.addItem(entry.first.c_str(), listId);
|
||||||
m_itemIds.push_back(i);
|
++listId;
|
||||||
m_buttonListItems.addItem(app.GetString(Item::items[i]->getDescriptionId()), listId);
|
}
|
||||||
++listId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_buttonListEnchantments.init(eControl_Enchantments);
|
m_buttonListEnchantments.init(eControl_Enchantments);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<LastConfigDeployed>Debug</LastConfigDeployed>
|
<LastConfigDeployed>Debug</LastConfigDeployed>
|
||||||
|
<ShowAllFiles>true</ShowAllFiles>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory>
|
<LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue