Qt: Display language flags instead of region

This commit is contained in:
Stenzek 2024-10-12 16:48:38 +10:00
parent ba0708a4ff
commit 6e26ba3e9e
No known key found for this signature in database
19 changed files with 978 additions and 34 deletions

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="600" viewBox="0 0 5 3">
<desc>Flag of Germany</desc>
<rect id="black_stripe" width="5" height="3" y="0" x="0" fill="#000"/>
<rect id="red_stripe" width="5" height="2" y="1" x="0" fill="#D00"/>
<rect id="gold_stripe" width="5" height="1" y="2" x="0" fill="#FFCE00"/>
</svg>

After

Width:  |  Height:  |  Size: 491 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600">
<desc>Japanese flag</desc>
<rect fill="#fff" height="600" width="900"/>
<circle fill="#bc002d" cx="450" cy="300" r="180"/>
</svg>

After

Width:  |  Height:  |  Size: 234 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600">
<desc>Japanese flag</desc>
<rect fill="#fff" height="600" width="900"/>
<circle fill="#bc002d" cx="450" cy="300" r="180"/>
</svg>

After

Width:  |  Height:  |  Size: 234 B

View File

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="900px" height="600px" viewBox="0 0 5850 3900" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
<desc>Vertically split United States and Canada flag, made for identification of the NTSU-U/C region.</desc>
<defs>
<rect width="5850" height="3900" id="artboard_1" />
<clipPath id="clip_1">
<use xlink:href="#artboard_1" clip-rule="evenodd" />
</clipPath>
</defs>
<g id="Flag-3:2" clip-path="url(#clip_1)">
<use xlink:href="#artboard_1" stroke="none" fill="#FFFFFF" />
<g id="flag-us-Copy" transform="translate(0.484375 -3.0517578E-05)">
<path d="M0 0L5850 0L5850 3900L0 3900L0 0Z" id="Rectangle" fill="#B22234" stroke="none" />
<path d="M5850 1800L0 1800M0 2400L5850 2400M5850 3000L0 3000M0 0L5850 0M0 1200L5850 1200M5850 600L0 600" transform="translate(0 450)" id="Shape" fill="#000000" stroke="#FFFFFF" stroke-width="300" />
<path d="M0 0L2925 0L2925 2100L0 2100L0 0Z" id="Rectangle" fill="#3C3B6E" stroke="none" />
<g id="Group" transform="translate(113 83)">
<g id="s18">
<g id="s9">
<g id="s5">
<g id="s4">
<g id="Group">
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 420)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 840)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1260)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1680)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(247 210)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(247 630)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(247 1050)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(247 1470)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(494 0)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(494 420)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(494 840)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(494 1260)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(494 1680)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(741 210)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(741 630)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(741 1050)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(741 1470)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(988 0)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(988 420)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(988 840)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(988 1260)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(988 1680)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(1235 210)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(1235 630)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(1235 1050)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(1235 1470)" id="s" fill="#FFFFFF" stroke="none" />
<g id="s5" transform="translate(1482 0)">
<g id="s4">
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 420)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 840)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1260)" id="s" fill="#FFFFFF" stroke="none" />
</g>
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1680)" id="s" fill="#FFFFFF" stroke="none" />
</g>
<g id="s4" transform="translate(1729.0007 210)">
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 420)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 840)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1260)" id="s" fill="#FFFFFF" stroke="none" />
</g>
<g id="s9" transform="translate(1976.001 0)">
<g id="s5">
<g id="s4">
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 420)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 840)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1260)" id="s" fill="#FFFFFF" stroke="none" />
</g>
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1680)" id="s" fill="#FFFFFF" stroke="none" />
</g>
<g id="s4" transform="translate(247.00006 210)">
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 420)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 840)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1260)" id="s" fill="#FFFFFF" stroke="none" />
</g>
</g>
<g id="s5" transform="translate(2470 0)">
<g id="s4">
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 420)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 840)" id="s" fill="#FFFFFF" stroke="none" />
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1260)" id="s" fill="#FFFFFF" stroke="none" />
</g>
<path d="M114.127 0L184.661 217.082L0 82.9179L228.254 82.9179L43.5926 217.082L114.127 0Z" transform="translate(0 1680)" id="s" fill="#FFFFFF" stroke="none" />
</g>
</g>
</g>
</g>
<g id="s4" transform="translate(266.74683 216.91797)" />
</g>
<g id="s9" transform="translate(513.7468 6.9179688)">
<g id="s5">
<g id="s4" />
</g>
<g id="s4" transform="translate(247 210)" />
</g>
</g>
<g id="s18" transform="translate(1007.7468 6.9179688)">
<g id="s9">
<g id="s5">
<g id="s4" />
</g>
<g id="s4" transform="translate(247 210)" />
</g>
<g id="s9" transform="translate(494 0)" />
</g>
</g>
</g>
<g id="Group-Copy" transform="translate(2925.4844 -3.0517578E-05)">
<path d="M0 0L2925 0L2925 3900L0 3900L0 0Z" transform="translate(0.25 0)" id="Rectangle" fill="#D52B1E" stroke="none" />
<path d="M2925 0L0 0L0 3900L2925 3900L2925 0ZM1483.77 2507.42L1505.55 2925L1418.45 2925L1440.23 2507.42C1440.87 2493.51 1435.17 2480.06 1424.73 2470.84C1414.29 2461.63 1400.24 2457.64 1386.52 2460L970.871 2533.06L1027 2378.23C1031.67 2365.59 1027.78 2351.39 1017.32 2342.9L562 1974.19L664.581 1926.29C678.915 1919.52 685.967 1903.13 681.032 1888.06L591.032 1611.29L853.29 1666.94C867.939 1669.99 882.712 1662.3 888.613 1648.55L939.42 1529.03L1144.1 1748.71C1153.71 1758.85 1168.86 1761.43 1181.29 1755.05C1193.72 1748.67 1200.45 1734.85 1197.81 1721.13L1099.1 1212.1L1257.32 1303.55C1264.83 1307.95 1273.83 1309.04 1282.17 1306.57C1290.52 1304.09 1297.46 1298.27 1301.36 1290.48L1462 975L1622.65 1290.48C1626.54 1298.27 1633.48 1304.09 1641.83 1306.57C1650.17 1309.04 1659.17 1307.95 1666.68 1303.55L1824.9 1212.1L1726.19 1721.13C1723.55 1734.85 1730.28 1748.67 1742.71 1755.05C1755.14 1761.43 1770.29 1758.85 1779.9 1748.71L1984.58 1529.03L2035.39 1648.55C2041.29 1662.3 2056.06 1669.99 2070.71 1666.94L2332.97 1611.29L2242.97 1888.06C2238.03 1903.13 2245.09 1919.52 2259.42 1926.29L2362 1974.19L1906.68 2342.9C1896.22 2351.39 1892.33 2365.59 1897 2378.23L1953.13 2533.06L1537.48 2460C1523.76 2457.64 1509.71 2461.63 1499.27 2470.84C1488.83 2480.06 1483.13 2493.51 1483.77 2507.42Z" id="Shape" fill="#FFFFFF" fill-rule="evenodd" stroke="none" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Creator: CorelDRAW -->
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="400">
<rect fill="#969594" width="600" height="400"/>
<rect fill="#c2c1c1" width="400" height="400"/>
<rect fill="#72706f" width="200" height="400"/>
</svg>

After

Width:  |  Height:  |  Size: 286 B

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Creator: CorelDRAW -->
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="400">
<rect fill="#969594" width="600" height="400"/>
<rect fill="#c2c1c1" width="400" height="400"/>
<rect fill="#72706f" width="200" height="400"/>
<path fill="#fff" stroke="#000" stroke-width="0.1524" d="M348.367 270.386h-93.7054v-9.3454c0-15.9122 1.768-28.8778 5.3882-38.8124 3.6202-10.0188 9.0086-19.0274 16.1648-27.2782 7.1564-8.2508 23.237-22.7318 48.242-43.443 13.3024-10.8608 19.9534-20.7954 19.9534-29.8038 0-9.0928-2.694-16.0808-7.9982-21.1322-5.3882-4.9674-13.4706-7.4932-24.3314-7.4932-11.7026 0-21.3006 3.873-28.962 11.6186-7.6614 7.6614-12.5446 21.2164-14.6494 40.412l-95.7262-11.871c3.2836-35.1922 16.0808-63.4806 38.3074-84.9496 22.3108-21.469 56.4928-32.1612 102.546-32.1612 35.8658 0 64.7436 7.493 86.8018 22.395 29.8882 20.2902 44.8744 47.2316 44.8744 80.9084 0 13.9758-3.8728 27.5306-11.6186 40.4962-7.6614 12.9656-23.4894 28.8778-47.3158 47.5684-16.5858 13.2182-27.1098 23.7422-31.4878 31.7404-4.2938 7.914-6.4828 18.3538-6.4828 31.151zm-96.989 24.9208h100.441v88.5698H251.378v-88.5698z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,31 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="900" height="600" viewBox="0 0 810 540">
<desc>European Union flag</desc>
<defs>
<g id="s">
<g id="c">
<path id="t" d="M0,0v1h0.5z" transform="translate(0,-1)rotate(18)"/>
<use xlink:href="#t" transform="scale(-1,1)"/>
</g>
<g id="a">
<use xlink:href="#c" transform="rotate(72)"/>
<use xlink:href="#c" transform="rotate(144)"/>
</g>
<use xlink:href="#a" transform="scale(-1,1)"/>
</g>
</defs>
<rect fill="#039" width="810" height="540"/>
<g fill="#fc0" transform="scale(30)translate(13.5,9)">
<use xlink:href="#s" y="-6"/>
<use xlink:href="#s" y="6"/>
<g id="l">
<use xlink:href="#s" x="-6"/>
<use xlink:href="#s" transform="rotate(150)translate(0,6)rotate(66)"/>
<use xlink:href="#s" transform="rotate(120)translate(0,6)rotate(24)"/>
<use xlink:href="#s" transform="rotate(60)translate(0,6)rotate(12)"/>
<use xlink:href="#s" transform="rotate(30)translate(0,6)rotate(42)"/>
</g>
<use xlink:href="#l" transform="scale(-1,1)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 152 KiB

View File

@ -0,0 +1,2 @@
Spanish.svg: https://commons.wikimedia.org/wiki/File:Flag_of_Spain.svg
Other.svg: https://en.wikipedia.org/wiki/File:Flag_with_question_mark.svg

View File

@ -864,6 +864,14 @@ void SmallStringBase::resize(u32 new_size, char fill, bool shrink_if_smaller)
}
}
void SmallStringBase::set_size(u32 new_size, bool shrink_if_smaller /*= false*/)
{
DebugAssert(new_size <= m_buffer_size);
m_length = new_size;
if (shrink_if_smaller)
shrink_to_fit();
}
void SmallStringBase::update_size()
{
m_length = static_cast<u32>(std::strlen(m_buffer));

View File

@ -158,6 +158,9 @@ public:
// Cuts characters off the string to reduce it to len bytes long.
void resize(u32 new_size, char fill = ' ', bool shrink_if_smaller = false);
// sets the size externally, use with data()
void set_size(u32 new_size, bool shrink_if_smaller = false);
// updates the internal length counter when the string is externally modified
void update_size();

View File

@ -6434,13 +6434,20 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
// region
{
const TinyString flag_texture =
TinyString::from_format("fullscreenui/{}.png", Settings::GetDiscRegionName(selected_entry->region));
ImGui::TextUnformatted(FSUI_CSTR("Region: "));
const bool display_as_language = (selected_entry->dbentry && selected_entry->dbentry->HasAnyLanguage());
ImGui::TextUnformatted(display_as_language ? FSUI_CSTR("Language: ") : FSUI_CSTR("Region: "));
ImGui::SameLine();
ImGui::Image(GetCachedTextureAsync(flag_texture.c_str()), LayoutScale(23.0f, 16.0f));
ImGui::Image(GetCachedTexture(selected_entry->GetLanguageIconFileName(), 23, 16), LayoutScale(23.0f, 16.0f));
ImGui::SameLine();
ImGui::Text(" (%s)", Settings::GetDiscRegionDisplayName(selected_entry->region));
if (display_as_language)
{
ImGui::TextWrapped(" (%s, %s)", selected_entry->dbentry->GetLanguagesString().c_str(),
Settings::GetDiscRegionName(selected_entry->region));
}
else
{
ImGui::TextWrapped(" (%s)", Settings::GetDiscRegionName(selected_entry->region));
}
}
// genre
@ -6448,9 +6455,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
ImGui::Text(FSUI_CSTR("Genre: %s"), selected_entry->dbentry->genre.c_str());
// release date
char release_date_str[64];
selected_entry->GetReleaseDateString(release_date_str, sizeof(release_date_str));
ImGui::Text(FSUI_CSTR("Release Date: %s"), release_date_str);
ImGui::Text(FSUI_CSTR("Release Date: %s"), selected_entry->GetReleaseDateString().c_str());
// compatibility
ImGui::TextUnformatted(FSUI_CSTR("Compatibility: "));

View File

@ -28,8 +28,8 @@
#include "fmt/format.h"
#include <algorithm>
#include <bit>
#include <array>
#include <bit>
#include <ctime>
#include <string_view>
#include <type_traits>
@ -990,21 +990,34 @@ std::string_view GameList::Entry::GetLanguageIcon() const
return ret;
}
size_t GameList::Entry::GetReleaseDateString(char* buffer, size_t buffer_size) const
TinyString GameList::Entry::GetLanguageIconFileName() const
{
if (!dbentry || dbentry->release_date == 0)
return StringUtil::Strlcpy(buffer, "Unknown", buffer_size);
return TinyString::from_format("images/flags/{}.svg", GetLanguageIcon());
}
std::time_t date_as_time = static_cast<std::time_t>(dbentry->release_date);
TinyString GameList::Entry::GetReleaseDateString() const
{
TinyString ret;
if (!dbentry || dbentry->release_date == 0)
{
ret.append(TRANSLATE_SV("GameList", "Unknown"));
}
else
{
std::time_t date_as_time = static_cast<std::time_t>(dbentry->release_date);
#ifdef _WIN32
tm date_tm = {};
gmtime_s(&date_tm, &date_as_time);
tm date_tm = {};
gmtime_s(&date_tm, &date_as_time);
#else
tm date_tm = {};
gmtime_r(&date_as_time, &date_tm);
tm date_tm = {};
gmtime_r(&date_as_time, &date_tm);
#endif
return std::strftime(buffer, buffer_size, "%d %B %Y", &date_tm);
ret.set_size(static_cast<u32>(std::strftime(ret.data(), ret.buffer_size(), "%d %B %Y", &date_tm)));
}
return ret;
}
std::string GameList::GetPlayedTimeFile()

View File

@ -58,7 +58,9 @@ struct Entry
std::string_view GetLanguageIcon() const;
size_t GetReleaseDateString(char* buffer, size_t buffer_size) const;
TinyString GetLanguageIconFileName() const;
TinyString GetReleaseDateString() const;
ALWAYS_INLINE bool IsDisc() const { return (type == EntryType::Disc); }
ALWAYS_INLINE bool IsDiscSet() const { return (type == EntryType::DiscSet); }

View File

@ -284,6 +284,21 @@ const QPixmap& GameListModel::getIconPixmapForEntry(const GameList::Entry* ge) c
return m_type_pixmaps[static_cast<u32>(ge->type)];
}
const QPixmap& GameListModel::getFlagPixmapForEntry(const GameList::Entry* ge) const
{
static constexpr u32 FLAG_PIXMAP_WIDTH = 42;
static constexpr u32 FLAG_PIXMAP_HEIGHT = 30;
const std::string_view name = ge->GetLanguageIcon();
auto it = m_flag_pixmap_cache.find(name);
if (it != m_flag_pixmap_cache.end())
return it->second;
const QIcon icon(QString::fromStdString(QtHost::GetResourcePath(ge->GetLanguageIconFileName(), true)));
it = m_flag_pixmap_cache.emplace(name, icon.pixmap(FLAG_PIXMAP_WIDTH, FLAG_PIXMAP_HEIGHT)).first;
return it->second;
}
QIcon GameListModel::getIconForGame(const QString& path)
{
QIcon ret;
@ -544,7 +559,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role, const GameList:
case Column_Region:
{
return m_region_pixmaps[static_cast<u32>(ge->region)];
return getFlagPixmapForEntry(ge);
}
case Column_Compatibility:
@ -788,9 +803,6 @@ void GameListModel::loadThemeSpecificImages()
{
for (u32 i = 0; i < static_cast<u32>(GameList::EntryType::Count); i++)
m_type_pixmaps[i] = QtUtils::GetIconForEntryType(static_cast<GameList::EntryType>(i)).pixmap(QSize(24, 24));
for (u32 i = 0; i < static_cast<u32>(DiscRegion::Count); i++)
m_region_pixmaps[i] = QtUtils::GetIconForRegion(static_cast<DiscRegion>(i)).pixmap(42, 30);
}
void GameListModel::loadCommonImages()

View File

@ -111,6 +111,7 @@ private:
void invalidateCoverForPath(const std::string& path);
const QPixmap& getIconPixmapForEntry(const GameList::Entry* ge) const;
const QPixmap& getFlagPixmapForEntry(const GameList::Entry* ge) const;
static void fixIconPixmapSize(QPixmap& pm);
static QString formatTimespan(time_t timespan);
@ -123,12 +124,13 @@ private:
std::array<QString, Column_Count> m_column_display_names;
std::array<QPixmap, static_cast<int>(GameList::EntryType::Count)> m_type_pixmaps;
std::array<QPixmap, static_cast<int>(DiscRegion::Count)> m_region_pixmaps;
std::array<QPixmap, static_cast<int>(GameDatabase::CompatibilityRating::Count)> m_compatibility_pixmaps;
QPixmap m_placeholder_pixmap;
QPixmap m_loading_pixmap;
mutable PreferUnorderedStringMap<QPixmap> m_flag_pixmap_cache;
mutable LRUCache<std::string, QPixmap> m_cover_pixmap_cache;
mutable LRUCache<std::string, QPixmap> m_memcard_pixmap_cache;

View File

@ -103,7 +103,6 @@ static void SetDefaultSettings(SettingsInterface& si, bool system, bool controll
static void MigrateSettings();
static void SaveSettings();
static bool RunSetupWizard();
static std::string GetResourcePath(std::string_view name, bool allow_override);
static std::optional<bool> DownloadFile(QWidget* parent, const QString& title, std::string url, std::vector<u8>* data);
static void InitializeEarlyConsole();
static void HookSignals();
@ -1948,7 +1947,7 @@ void Host::OnInputDeviceDisconnected(InputBindingKey key, std::string_view ident
}
}
ALWAYS_INLINE std::string QtHost::GetResourcePath(std::string_view filename, bool allow_override)
std::string QtHost::GetResourcePath(std::string_view filename, bool allow_override)
{
return allow_override ? EmuFolders::GetOverridableResourcePath(filename) :
Path::Combine(EmuFolders::Resources, filename);

View File

@ -294,6 +294,9 @@ const QIcon& GetAppIcon();
/// Returns the base path for resources. This may be : prefixed, if we're using embedded resources.
QString GetResourcesBasePath();
/// Returns the path to the specified resource.
std::string GetResourcePath(std::string_view name, bool allow_override);
/// Returns the base settings interface. Should lock before manipulating.
INISettingsInterface* GetBaseSettingsInterface();

View File

@ -251,11 +251,14 @@ QIcon QtUtils::GetIconForRegion(ConsoleRegion region)
switch (region)
{
case ConsoleRegion::NTSC_J:
return QIcon(QStringLiteral(":/icons/flag-jp.svg"));
case ConsoleRegion::PAL:
return QIcon(QStringLiteral(":/icons/flag-eu.svg"));
return QIcon(QString::fromStdString(QtHost::GetResourcePath("images/flags/NTSC-J.svg", true)));
case ConsoleRegion::NTSC_U:
return QIcon(QStringLiteral(":/icons/flag-uc.svg"));
return QIcon(QString::fromStdString(QtHost::GetResourcePath("images/flags/NTSC-U.svg", true)));
case ConsoleRegion::PAL:
return QIcon(QString::fromStdString(QtHost::GetResourcePath("images/flags/PAL.svg", true)));
default:
return QIcon::fromTheme(QStringLiteral("file-unknow-line"));
}
@ -266,11 +269,14 @@ QIcon QtUtils::GetIconForRegion(DiscRegion region)
switch (region)
{
case DiscRegion::NTSC_J:
return QIcon(QStringLiteral(":/icons/flag-jp.svg"));
case DiscRegion::PAL:
return QIcon(QStringLiteral(":/icons/flag-eu.svg"));
return QIcon(QString::fromStdString(QtHost::GetResourcePath("images/flags/NTSC-J.svg", true)));
case DiscRegion::NTSC_U:
return QIcon(QStringLiteral(":/icons/flag-uc.svg"));
return QIcon(QString::fromStdString(QtHost::GetResourcePath("images/flags/NTSC-U.svg", true)));
case DiscRegion::PAL:
return QIcon(QString::fromStdString(QtHost::GetResourcePath("images/flags/PAL.svg", true)));
case DiscRegion::Other:
case DiscRegion::NonPS1:
default: