mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-22 04:24:44 +00:00
fix list sorting for serial, firmware version, and game size
This commit is contained in:
parent
a5968b630d
commit
e04b4d1f9d
1 changed files with 17 additions and 6 deletions
|
@ -44,18 +44,29 @@ public:
|
|||
|
||||
int icon_size;
|
||||
|
||||
static float parseAsFloat(const std::string& str, const int& offset) {
|
||||
float num;
|
||||
std::from_chars(str.data(), str.data() + str.size() - offset, num);
|
||||
return num;
|
||||
}
|
||||
|
||||
static float parseSizeMB(const std::string& size) {
|
||||
float num = parseAsFloat(size, 3);
|
||||
return (size[size.size() - 2] == 'G') ? num * 1024 : num;
|
||||
}
|
||||
|
||||
static bool CompareStringsAscending(GameInfo a, GameInfo b, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 1:
|
||||
return a.name < b.name;
|
||||
case 2:
|
||||
return a.serial < b.serial;
|
||||
return a.serial.substr(4) < b.serial.substr(4);
|
||||
case 3:
|
||||
return a.region < b.region;
|
||||
case 4:
|
||||
return a.fw < b.fw;
|
||||
return parseAsFloat(a.fw, 0) < parseAsFloat(b.fw, 0);
|
||||
case 5:
|
||||
return a.size < b.size;
|
||||
return parseSizeMB(b.size) < parseSizeMB(a.size);
|
||||
case 6:
|
||||
return a.version < b.version;
|
||||
case 7:
|
||||
|
@ -70,13 +81,13 @@ public:
|
|||
case 1:
|
||||
return a.name > b.name;
|
||||
case 2:
|
||||
return a.serial > b.serial;
|
||||
return a.serial.substr(4) > b.serial.substr(4);
|
||||
case 3:
|
||||
return a.region > b.region;
|
||||
case 4:
|
||||
return a.fw > b.fw;
|
||||
return parseAsFloat(a.fw, 0) > parseAsFloat(b.fw, 0);
|
||||
case 5:
|
||||
return a.size > b.size;
|
||||
return parseSizeMB(b.size) > parseSizeMB(a.size);
|
||||
case 6:
|
||||
return a.version > b.version;
|
||||
case 7:
|
||||
|
|
Loading…
Add table
Reference in a new issue