From 235ecfbed71986f0be2ecf469a10e1105dcb3c96 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 9 Apr 2015 17:44:53 +0200 Subject: Return GetNames languages, to avoid hardcoded language lists in callers This makes the code cleaner and also leads to some user-visible changes: The wx game properties will no longer let the user select WAD languages that don't have any names. The Qt game list will now display names using the languages set in the configuration instead of always using English for PAL GC games and Japanese for WADs. If a WAD doesn't have a name in the user's preferred language, English is now selected as a fallback before Japanese. --- Source/Core/DolphinWX/MainAndroid.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Source/Core/DolphinWX/MainAndroid.cpp') diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index 1ab7be8c57..9ac5f7735b 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -114,8 +115,8 @@ static bool MsgAlert(const char* caption, const char* text, bool /*yes_no*/, int #define DVD_BANNER_WIDTH 96 #define DVD_BANNER_HEIGHT 32 -std::vector m_volume_names; -std::vector m_names; +std::map m_volume_names; +std::map m_names; static inline u32 Average32(u32 a, u32 b) { return ((a >> 1) & 0x7f7f7f7f) + ((b >> 1) & 0x7f7f7f7f); -- cgit v1.2.3 From ee694e327ada8c42949a3907d6fa222f73f276b0 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 10 Apr 2015 22:10:49 +0200 Subject: Get rid of banner loaders and move their functionality to volumes Having some data available in banner loaders and some other data data available in volumes gets messy, especially with GetNames(), which is available in both but returns different results depending on which one is used. This change drops support for reading names and descriptions from Wii save data. --- Source/Core/DolphinWX/MainAndroid.cpp | 97 ++++++++++++++++------------------- 1 file changed, 45 insertions(+), 52 deletions(-) (limited to 'Source/Core/DolphinWX/MainAndroid.cpp') diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index 9ac5f7735b..0d5f71dc99 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -38,9 +37,6 @@ #include "Core/HW/Wiimote.h" #include "Core/PowerPC/PowerPC.h" -// Banner loading -#include "DiscIO/BannerLoader.h" -#include "DiscIO/Filesystem.h" #include "DiscIO/VolumeCreator.h" #include "UICommon/UICommon.h" @@ -115,8 +111,8 @@ static bool MsgAlert(const char* caption, const char* text, bool /*yes_no*/, int #define DVD_BANNER_WIDTH 96 #define DVD_BANNER_HEIGHT 32 -std::map m_volume_names; std::map m_names; +bool m_is_wii_title; static inline u32 Average32(u32 a, u32 b) { return ((a >> 1) & 0x7f7f7f7f) + ((b >> 1) & 0x7f7f7f7f); @@ -131,54 +127,39 @@ static inline u32 GetPixel(u32 *buffer, unsigned int x, unsigned int y) { static bool LoadBanner(std::string filename, u32 *Banner) { - DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename); + std::unique_ptr pVolume(DiscIO::CreateVolumeFromFilename(filename)); if (pVolume != nullptr) { - bool bIsWad = false; - if (DiscIO::IsVolumeWadFile(pVolume)) - bIsWad = true; - - m_volume_names = pVolume->GetNames(); - - // check if we can get some info from the banner file too - DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume); - - if (pFileSystem != nullptr || bIsWad) + m_names = pVolume->GetNames(); + m_is_wii_title = pVolume->IsWiiDisc() || pVolume->IsWadFile(); + + int Width, Height; + std::vector BannerVec = pVolume->GetBanner(&Width, &Height); + // This code (along with above inlines) is moved from + // elsewhere. Someone who knows anything about Android + // please get rid of it and use proper high-resolution + // images. + if (Height == 64 && Width == 192) { - DiscIO::IBannerLoader* pBannerLoader = DiscIO::CreateBannerLoader(*pFileSystem, pVolume); - - if (pBannerLoader != nullptr) - if (pBannerLoader->IsValid()) + u32* Buffer = &BannerVec[0]; + for (int y = 0; y < 32; y++) + { + for (int x = 0; x < 96; x++) { - m_names = pBannerLoader->GetNames(); - int Width, Height; - std::vector BannerVec = pBannerLoader->GetBanner(&Width, &Height); - // This code (along with above inlines) is moved from - // elsewhere. Someone who knows anything about Android - // please get rid of it and use proper high-resolution - // images. - if (Height == 64) - { - u32* Buffer = &BannerVec[0]; - for (int y = 0; y < 32; y++) - { - for (int x = 0; x < 96; x++) - { - // simplified plus-shaped "gaussian" - u32 surround = Average32( - Average32(GetPixel(Buffer, x*2 - 1, y*2), GetPixel(Buffer, x*2 + 1, y*2)), - Average32(GetPixel(Buffer, x*2, y*2 - 1), GetPixel(Buffer, x*2, y*2 + 1))); - Banner[y * 96 + x] = Average32(GetPixel(Buffer, x*2, y*2), surround); - } - } - } - else - { - memcpy(Banner, &BannerVec[0], 96 * 32 * 4); - } - return true; + // simplified plus-shaped "gaussian" + u32 surround = Average32( + Average32(GetPixel(Buffer, x*2 - 1, y*2), GetPixel(Buffer, x*2 + 1, y*2)), + Average32(GetPixel(Buffer, x*2, y*2 - 1), GetPixel(Buffer, x*2, y*2 + 1))); + Banner[y * 96 + x] = Average32(GetPixel(Buffer, x*2, y*2), surround); } + } + return true; + } + else if (Height == 32 && Width == 96) + { + memcpy(Banner, &BannerVec[0], 96 * 32 * 4); + return true; } } @@ -187,15 +168,28 @@ static bool LoadBanner(std::string filename, u32 *Banner) static std::string GetName(std::string filename) { + DiscIO::IVolume::ELanguage language = SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(m_is_wii_title); + + auto end = m_names.end(); + auto it = m_names.find(language); + if (it != end) + return it->second; + + // English tends to be a good fallback when the requested language isn't available + if (language != IVolume::ELanguage::LANGUAGE_ENGLISH) + { + it = m_names.find(IVolume::ELanguage::LANGUAGE_ENGLISH); + if (it != end) + return it->second; + } + + // If English isn't available either, just pick something if (!m_names.empty()) - return m_names[0]; + return m_names.cbegin()->second; - if (!m_volume_names.empty()) - return m_volume_names[0]; // No usable name, return filename (better than nothing) std::string name; SplitPath(filename, nullptr, &name, nullptr); - return name; } @@ -277,7 +271,6 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetTitle( std::string file = GetJString(env, jFile); std::string name = GetName(file); m_names.clear(); - m_volume_names.clear(); return env->NewStringUTF(name.c_str()); } -- cgit v1.2.3