mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-25 03:11:58 +01:00
-sorting plugins by display names now so they are displayed ordered
in the plugin menu -using the newly created sort function for covers too now so we dont need to use two separate ones (covers should be sorted same way still)
This commit is contained in:
parent
3e62aeb278
commit
b2aef2cdaa
@ -1823,21 +1823,9 @@ bool CCoverFlow::_sortByGameID(CItem item1, CItem item2)
|
||||
|
||||
bool CCoverFlow::_sortByAlpha(CItem item1, CItem item2)
|
||||
{
|
||||
u32 s = min(wcslen(item1.hdr->title), wcslen(item2.hdr->title));
|
||||
wstringEx title1 = item1.hdr->title;
|
||||
wstringEx title2 = item2.hdr->title;
|
||||
|
||||
for (u32 j = 0, k = 0; j < s && k < s; ++j && ++k)
|
||||
{
|
||||
while (!iswalnum(title1[j]) && j < s) j++;
|
||||
while (!iswalnum(title2[k]) && k < s) k++;
|
||||
|
||||
if (upperCaseWChar(title1[j]) < upperCaseWChar(title2[k]))
|
||||
return true;
|
||||
else if(upperCaseWChar(title1[j]) > upperCaseWChar(title2[k]))
|
||||
return false;
|
||||
}
|
||||
return title1.length() < title2.length();
|
||||
const wchar_t *first = item1.hdr->title;
|
||||
const wchar_t *second = item2.hdr->title;
|
||||
return wchar_cmp(first, second, wcslen(first), wcslen(second));
|
||||
}
|
||||
|
||||
bool CCoverFlow::_sortByPlayers(CItem item1, CItem item2)
|
||||
|
@ -443,3 +443,17 @@ string rtrim(string s)
|
||||
s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end());
|
||||
return s;
|
||||
}
|
||||
|
||||
bool wchar_cmp(const wchar_t *first, const wchar_t *second, u32 first_len, u32 second_len)
|
||||
{
|
||||
u32 i = 0;
|
||||
while((i < first_len) && (i < second_len))
|
||||
{
|
||||
if(tolower(first[i]) < tolower(second[i]))
|
||||
return true;
|
||||
else if(tolower(first[i]) > tolower(second[i]))
|
||||
return false;
|
||||
++i;
|
||||
}
|
||||
return first_len < second_len;
|
||||
}
|
||||
|
@ -68,5 +68,6 @@ std::string upperCase(std::string text);
|
||||
std::string lowerCase(std::string text);
|
||||
std::string ltrim(std::string s);
|
||||
std::string rtrim(std::string s);
|
||||
bool wchar_cmp(const wchar_t *first, const wchar_t *second, u32 first_len, u32 second_len);
|
||||
|
||||
#endif // !defined(__TEXT_HPP)
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include "plugin.hpp"
|
||||
#include "gui/text.hpp"
|
||||
#include "gecko/gecko.hpp"
|
||||
@ -37,8 +37,16 @@ void Plugin::init(const string& m_pluginsDir)
|
||||
adding = true;
|
||||
}
|
||||
|
||||
static bool PluginOptions_cmp(PluginOptions lhs, PluginOptions rhs)
|
||||
{
|
||||
const wchar_t *first = lhs.DisplayName.c_str();
|
||||
const wchar_t *second = rhs.DisplayName.c_str();
|
||||
return wchar_cmp(first, second, wcslen(first), wcslen(second));
|
||||
}
|
||||
|
||||
void Plugin::EndAdd()
|
||||
{
|
||||
std::sort(Plugins.begin(), Plugins.end(), PluginOptions_cmp);
|
||||
adding = false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user