mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-02 22:28:45 +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;
|
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) {
|
static bool CompareStringsAscending(GameInfo a, GameInfo b, int columnIndex) {
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 1:
|
case 1:
|
||||||
return a.name < b.name;
|
return a.name < b.name;
|
||||||
case 2:
|
case 2:
|
||||||
return a.serial < b.serial;
|
return a.serial.substr(4) < b.serial.substr(4);
|
||||||
case 3:
|
case 3:
|
||||||
return a.region < b.region;
|
return a.region < b.region;
|
||||||
case 4:
|
case 4:
|
||||||
return a.fw < b.fw;
|
return parseAsFloat(a.fw, 0) < parseAsFloat(b.fw, 0);
|
||||||
case 5:
|
case 5:
|
||||||
return a.size < b.size;
|
return parseSizeMB(b.size) < parseSizeMB(a.size);
|
||||||
case 6:
|
case 6:
|
||||||
return a.version < b.version;
|
return a.version < b.version;
|
||||||
case 7:
|
case 7:
|
||||||
|
@ -70,13 +81,13 @@ public:
|
||||||
case 1:
|
case 1:
|
||||||
return a.name > b.name;
|
return a.name > b.name;
|
||||||
case 2:
|
case 2:
|
||||||
return a.serial > b.serial;
|
return a.serial.substr(4) > b.serial.substr(4);
|
||||||
case 3:
|
case 3:
|
||||||
return a.region > b.region;
|
return a.region > b.region;
|
||||||
case 4:
|
case 4:
|
||||||
return a.fw > b.fw;
|
return parseAsFloat(a.fw, 0) > parseAsFloat(b.fw, 0);
|
||||||
case 5:
|
case 5:
|
||||||
return a.size > b.size;
|
return parseSizeMB(b.size) > parseSizeMB(a.size);
|
||||||
case 6:
|
case 6:
|
||||||
return a.version > b.version;
|
return a.version > b.version;
|
||||||
case 7:
|
case 7:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue