Merge pull request #2286 from JosJuice/wii-opening-bnr

Read opening.bnr to get names from Wii discs
This commit is contained in:
comex
2015-05-05 16:20:04 -04:00
42 changed files with 728 additions and 1079 deletions

View File

@ -11,6 +11,7 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "DiscIO/Volume.h"
#include "DolphinWX/WxUtils.h"
#include "DolphinWX/Config/WiiConfigPane.h"
@ -125,7 +126,7 @@ void WiiConfigPane::OnConnectKeyboardCheckBoxChanged(wxCommandEvent& event)
void WiiConfigPane::OnSystemLanguageChoiceChanged(wxCommandEvent& event)
{
int wii_system_lang = m_system_language_choice->GetSelection();
IVolume::ELanguage wii_system_lang = (IVolume::ELanguage)m_system_language_choice->GetSelection();
SConfig::GetInstance().m_SYSCONF->SetData("IPL.LNG", wii_system_lang);
u8 country_code = GetSADRCountryCode(wii_system_lang);
@ -138,41 +139,33 @@ void WiiConfigPane::OnAspectRatioChoiceChanged(wxCommandEvent& event)
SConfig::GetInstance().m_SYSCONF->SetData("IPL.AR", m_aspect_ratio_choice->GetSelection());
}
// Change from IPL.LNG value to IPL.SADR country code
u8 WiiConfigPane::GetSADRCountryCode(int language)
// Change from IPL.LNG value to IPL.SADR country code.
// http://wiibrew.org/wiki/Country_Codes
u8 WiiConfigPane::GetSADRCountryCode(IVolume::ELanguage language)
{
//http://wiibrew.org/wiki/Country_Codes
u8 country_code = language;
switch (country_code)
switch (language)
{
case 0: //Japanese
country_code = 1; //Japan
break;
case 1: //English
country_code = 49; //USA
break;
case 2: //German
country_code = 78; //Germany
break;
case 3: //French
country_code = 77; //France
break;
case 4: //Spanish
country_code = 105; //Spain
break;
case 5: //Italian
country_code = 83; //Italy
break;
case 6: //Dutch
country_code = 94; //Netherlands
break;
case 7: //Simplified Chinese
case 8: //Traditional Chinese
country_code = 157; //China
break;
case 9: //Korean
country_code = 136; //Korea
break;
case IVolume::LANGUAGE_JAPANESE:
return 1; // Japan
case IVolume::LANGUAGE_ENGLISH:
return 49; // USA
case IVolume::LANGUAGE_GERMAN:
return 78; // Germany
case IVolume::LANGUAGE_FRENCH:
return 77; // France
case IVolume::LANGUAGE_SPANISH:
return 105; // Spain
case IVolume::LANGUAGE_ITALIAN:
return 83; // Italy
case IVolume::LANGUAGE_DUTCH:
return 94; // Netherlands
case IVolume::LANGUAGE_SIMPLIFIED_CHINESE:
case IVolume::LANGUAGE_TRADITIONAL_CHINESE:
return 157; // China
case IVolume::LANGUAGE_KOREAN:
return 136; // Korea
}
return country_code;
PanicAlert("Invalid language");
return 1;
}

View File

@ -7,6 +7,7 @@
#include <wx/arrstr.h>
#include <wx/panel.h>
#include "Common/CommonTypes.h"
#include "DiscIO/Volume.h"
class wxCheckBox;
class wxChoice;
@ -29,7 +30,7 @@ private:
void OnSystemLanguageChoiceChanged(wxCommandEvent&);
void OnAspectRatioChoiceChanged(wxCommandEvent&);
static u8 GetSADRCountryCode(int language);
static u8 GetSADRCountryCode(IVolume::ELanguage language);
wxArrayString m_system_language_strings;
wxArrayString m_aspect_ratio_strings;

View File

@ -364,8 +364,8 @@ wxMenuBar* CFrame::CreateMenu()
columnsMenu->Check(IDM_SHOW_SYSTEM, SConfig::GetInstance().m_showSystemColumn);
columnsMenu->AppendCheckItem(IDM_SHOW_BANNER, _("Banner"));
columnsMenu->Check(IDM_SHOW_BANNER, SConfig::GetInstance().m_showBannerColumn);
columnsMenu->AppendCheckItem(IDM_SHOW_NOTES, _("Notes"));
columnsMenu->Check(IDM_SHOW_NOTES, SConfig::GetInstance().m_showNotesColumn);
columnsMenu->AppendCheckItem(IDM_SHOW_MAKER, _("Maker"));
columnsMenu->Check(IDM_SHOW_MAKER, SConfig::GetInstance().m_showMakerColumn);
columnsMenu->AppendCheckItem(IDM_SHOW_ID, _("Game ID"));
columnsMenu->Check(IDM_SHOW_ID, SConfig::GetInstance().m_showIDColumn);
columnsMenu->AppendCheckItem(IDM_SHOW_REGION, _("Region"));
@ -2035,8 +2035,8 @@ void CFrame::OnChangeColumnsVisible(wxCommandEvent& event)
case IDM_SHOW_BANNER:
SConfig::GetInstance().m_showBannerColumn = !SConfig::GetInstance().m_showBannerColumn;
break;
case IDM_SHOW_NOTES:
SConfig::GetInstance().m_showNotesColumn = !SConfig::GetInstance().m_showNotesColumn;
case IDM_SHOW_MAKER:
SConfig::GetInstance().m_showMakerColumn = !SConfig::GetInstance().m_showMakerColumn;
break;
case IDM_SHOW_ID:
SConfig::GetInstance().m_showIDColumn = !SConfig::GetInstance().m_showIDColumn;

View File

@ -99,56 +99,27 @@ static int CompareGameListItems(const GameListItem* iso1, const GameListItem* is
sortData = -sortData;
}
int indexOne = 0;
int indexOther = 0;
// index only matters for WADS and PAL GC games, but invalid indicies for the others
// will return the (only) language in the list
if (iso1->GetPlatform() == GameListItem::WII_WAD)
{
indexOne = SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.LNG");
}
else // GC
{
indexOne = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
}
if (iso2->GetPlatform() == GameListItem::WII_WAD)
{
indexOther = SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.LNG");
}
else // GC
{
indexOther = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
}
IVolume::ELanguage languageOne = SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(iso1->GetPlatform() != GameListItem::GAMECUBE_DISC);
IVolume::ELanguage languageOther = SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(iso2->GetPlatform() != GameListItem::GAMECUBE_DISC);
switch (sortData)
{
case CGameListCtrl::COLUMN_TITLE:
if (!strcasecmp(iso1->GetName(indexOne).c_str(),iso2->GetName(indexOther).c_str()))
if (!strcasecmp(iso1->GetName(languageOne).c_str(), iso2->GetName(languageOther).c_str()))
{
if (iso1->GetUniqueID() != iso2->GetUniqueID())
return t * (iso1->GetUniqueID() > iso2->GetUniqueID() ? 1 : -1);
if (iso1->GetRevision() != iso2->GetRevision())
return t * (iso1->GetRevision() > iso2->GetRevision() ? 1 : -1);
return t * (iso1->GetRevision() > iso2->GetRevision() ? 1 : -1);
if (iso1->IsDiscTwo() != iso2->IsDiscTwo())
return t * (iso1->IsDiscTwo() ? 1 : -1);
}
return strcasecmp(iso1->GetName(indexOne).c_str(),
iso2->GetName(indexOther).c_str()) * t;
case CGameListCtrl::COLUMN_NOTES:
{
std::string cmp1 =
(iso1->GetPlatform() == GameListItem::GAMECUBE_DISC) ?
iso1->GetCompany() : iso1->GetDescription(indexOne);
std::string cmp2 =
(iso2->GetPlatform() == GameListItem::GAMECUBE_DISC) ?
iso2->GetCompany() : iso2->GetDescription(indexOther);
return strcasecmp(cmp1.c_str(), cmp2.c_str()) * t;
}
return strcasecmp(iso1->GetName(languageOne).c_str(),
iso2->GetName(languageOther).c_str()) * t;
case CGameListCtrl::COLUMN_MAKER:
return strcasecmp(iso1->GetCompany().c_str(), iso2->GetCompany().c_str()) * t;
case CGameListCtrl::COLUMN_ID:
return strcasecmp(iso1->GetUniqueID().c_str(), iso2->GetUniqueID().c_str()) * t;
return strcasecmp(iso1->GetUniqueID().c_str(), iso2->GetUniqueID().c_str()) * t;
case CGameListCtrl::COLUMN_COUNTRY:
if (iso1->GetCountry() > iso2->GetCountry())
return 1 * t;
@ -311,10 +282,7 @@ void CGameListCtrl::Update()
InsertColumn(COLUMN_BANNER, _("Banner"));
InsertColumn(COLUMN_TITLE, _("Title"));
// Instead of showing the notes + the company, which is unknown with
// Wii titles We show in the same column : company for GC games and
// description for Wii/wad games
InsertColumn(COLUMN_NOTES, _("Notes"));
InsertColumn(COLUMN_MAKER, _("Maker"));
InsertColumn(COLUMN_ID, _("ID"));
InsertColumn(COLUMN_COUNTRY, "");
InsertColumn(COLUMN_SIZE, _("Size"));
@ -331,7 +299,7 @@ void CGameListCtrl::Update()
SetColumnWidth(COLUMN_PLATFORM, SConfig::GetInstance().m_showSystemColumn ? 35 + platform_padding : 0);
SetColumnWidth(COLUMN_BANNER, SConfig::GetInstance().m_showBannerColumn ? 96 + platform_padding : 0);
SetColumnWidth(COLUMN_TITLE, 175 + platform_padding);
SetColumnWidth(COLUMN_NOTES, SConfig::GetInstance().m_showNotesColumn ? 150 + platform_padding : 0);
SetColumnWidth(COLUMN_MAKER, SConfig::GetInstance().m_showMakerColumn ? 150 + platform_padding : 0);
SetColumnWidth(COLUMN_ID, SConfig::GetInstance().m_showIDColumn ? 75 + platform_padding : 0);
SetColumnWidth(COLUMN_COUNTRY, SConfig::GetInstance().m_showRegionColumn ? 32 + platform_padding : 0);
SetColumnWidth(COLUMN_EMULATION_STATE, SConfig::GetInstance().m_showStateColumn ? 50 + platform_padding : 0);
@ -433,15 +401,7 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
// Set the game's banner in the second column
SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);
int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
// Is this sane?
if (rISOFile.GetPlatform() == GameListItem::WII_WAD)
{
SelectedLanguage = SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.LNG");
}
std::string name = rISOFile.GetName(SelectedLanguage);
std::string name = rISOFile.GetName();
std::ifstream titlestxt;
OpenFStream(titlestxt, File::GetUserPath(D_LOAD_IDX) + "titles.txt", std::ios::in);
@ -470,12 +430,7 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
name = title;
SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);
// We show the company string on GameCube only
// On Wii we show the description instead as the company string is empty
std::string const notes = (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) ?
rISOFile.GetCompany() : rISOFile.GetDescription(SelectedLanguage);
SetItem(_Index, COLUMN_NOTES, StrToWxStr(notes), -1);
SetItem(_Index, COLUMN_MAKER, StrToWxStr(rISOFile.GetCompany()), -1);
// Emulation state
SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]);
@ -699,7 +654,7 @@ void CGameListCtrl::ScanForISOs()
void CGameListCtrl::OnColBeginDrag(wxListEvent& event)
{
if (event.GetColumn() != COLUMN_TITLE && event.GetColumn() != COLUMN_NOTES)
if (event.GetColumn() != COLUMN_TITLE && event.GetColumn() != COLUMN_MAKER)
event.Veto();
}
@ -1348,13 +1303,13 @@ void CGameListCtrl::AutomaticColumnWidth()
+ GetColumnWidth(COLUMN_SIZE)
+ GetColumnWidth(COLUMN_EMULATION_STATE));
// We hide the Notes column if the window is too small
// We hide the Maker column if the window is too small
if (resizable > 400)
{
if (SConfig::GetInstance().m_showNotesColumn)
if (SConfig::GetInstance().m_showMakerColumn)
{
SetColumnWidth(COLUMN_TITLE, resizable / 2);
SetColumnWidth(COLUMN_NOTES, resizable / 2);
SetColumnWidth(COLUMN_MAKER, resizable / 2);
}
else
{
@ -1364,7 +1319,7 @@ void CGameListCtrl::AutomaticColumnWidth()
else
{
SetColumnWidth(COLUMN_TITLE, resizable);
SetColumnWidth(COLUMN_NOTES, 0);
SetColumnWidth(COLUMN_MAKER, 0);
}
}
}

View File

@ -52,7 +52,7 @@ public:
COLUMN_PLATFORM,
COLUMN_BANNER,
COLUMN_TITLE,
COLUMN_NOTES,
COLUMN_MAKER,
COLUMN_ID,
COLUMN_COUNTRY,
COLUMN_SIZE,

View File

@ -176,7 +176,7 @@ enum
// List Column Title Toggles
IDM_SHOW_SYSTEM,
IDM_SHOW_BANNER,
IDM_SHOW_NOTES,
IDM_SHOW_MAKER,
IDM_SHOW_ID,
IDM_SHOW_REGION,
IDM_SHOW_SIZE,

View File

@ -7,6 +7,7 @@
#include <cstring>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <wx/app.h>
#include <wx/bitmap.h>
@ -28,7 +29,6 @@
#include "Core/CoreParameter.h"
#include "Core/Boot/Boot.h"
#include "DiscIO/BannerLoader.h"
#include "DiscIO/CompressedBlob.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
@ -37,11 +37,33 @@
#include "DolphinWX/ISOFile.h"
#include "DolphinWX/WxUtils.h"
static const u32 CACHE_REVISION = 0x122;
static const u32 CACHE_REVISION = 0x123;
#define DVD_BANNER_WIDTH 96
#define DVD_BANNER_HEIGHT 32
static std::string GetLanguageString(IVolume::ELanguage language, std::map<IVolume::ELanguage, std::string> strings)
{
auto end = strings.end();
auto it = strings.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 = strings.find(IVolume::ELanguage::LANGUAGE_ENGLISH);
if (it != end)
return it->second;
}
// If English isn't available either, just pick something
if (!strings.empty())
return strings.cbegin()->second;
return "";
}
GameListItem::GameListItem(const std::string& _rFileName)
: m_FileName(_rFileName)
, m_emu_state(0)
@ -67,7 +89,9 @@ GameListItem::GameListItem(const std::string& _rFileName)
else
m_Platform = WII_WAD;
m_volume_names = pVolume->GetNames();
m_names = pVolume->GetNames();
m_descriptions = pVolume->GetDescriptions();
m_company = pVolume->GetCompany();
m_Country = pVolume->GetCountry();
m_FileSize = pVolume->GetRawSize();
@ -78,34 +102,15 @@ GameListItem::GameListItem(const std::string& _rFileName)
m_IsDiscTwo = pVolume->IsDiscTwo();
m_Revision = pVolume->GetRevision();
// check if we can get some info from the banner file too
DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume);
std::vector<u32> Buffer = pVolume->GetBanner(&m_ImageWidth, &m_ImageHeight);
u32* pData = Buffer.data();
m_pImage.resize(m_ImageWidth * m_ImageHeight * 3);
if (pFileSystem != nullptr || m_Platform == WII_WAD)
for (int i = 0; i < m_ImageWidth * m_ImageHeight; i++)
{
std::unique_ptr<DiscIO::IBannerLoader> pBannerLoader(DiscIO::CreateBannerLoader(*pFileSystem, pVolume));
if (pBannerLoader != nullptr && pBannerLoader->IsValid())
{
if (m_Platform != WII_WAD)
m_banner_names = pBannerLoader->GetNames();
m_company = pBannerLoader->GetCompany();
m_descriptions = pBannerLoader->GetDescriptions();
std::vector<u32> Buffer = pBannerLoader->GetBanner(&m_ImageWidth, &m_ImageHeight);
u32* pData = &Buffer[0];
// resize vector to image size
m_pImage.resize(m_ImageWidth * m_ImageHeight * 3);
for (int i = 0; i < m_ImageWidth * m_ImageHeight; i++)
{
m_pImage[i * 3 + 0] = (pData[i] & 0xFF0000) >> 16;
m_pImage[i * 3 + 1] = (pData[i] & 0x00FF00) >> 8;
m_pImage[i * 3 + 2] = (pData[i] & 0x0000FF) >> 0;
}
}
delete pFileSystem;
m_pImage[i * 3 + 0] = (pData[i] & 0xFF0000) >> 16;
m_pImage[i * 3 + 1] = (pData[i] & 0x00FF00) >> 8;
m_pImage[i * 3 + 2] = (pData[i] & 0x0000FF) >> 0;
}
delete pVolume;
@ -131,7 +136,7 @@ GameListItem::GameListItem(const std::string& _rFileName)
wxImage Image(m_ImageWidth, m_ImageHeight, &m_pImage[0], true);
double Scale = wxTheApp->GetTopWindow()->GetContentScaleFactor();
// Note: This uses nearest neighbor, which subjectively looks a lot
// better for GC banners than smooths caling.
// better for GC banners than smooth scaling.
Image.Rescale(DVD_BANNER_WIDTH * Scale, DVD_BANNER_HEIGHT * Scale);
#ifdef __APPLE__
m_Bitmap = wxBitmap(Image, -1, Scale);
@ -165,10 +170,9 @@ void GameListItem::SaveToCache()
void GameListItem::DoState(PointerWrap &p)
{
p.Do(m_volume_names);
p.Do(m_company);
p.Do(m_banner_names);
p.Do(m_names);
p.Do(m_descriptions);
p.Do(m_company);
p.Do(m_UniqueID);
p.Do(m_FileSize);
p.Do(m_VolumeSize);
@ -202,73 +206,43 @@ std::string GameListItem::CreateCacheFilename()
std::string GameListItem::GetCompany() const
{
if (m_company.empty())
return "N/A";
else
return m_company;
return m_company;
}
// (-1 = Japanese, 0 = English, etc)?
std::string GameListItem::GetDescription(int _index) const
std::string GameListItem::GetDescription(IVolume::ELanguage language) const
{
const u32 index = _index;
if (index < m_descriptions.size())
return m_descriptions[index];
if (!m_descriptions.empty())
return m_descriptions[0];
return "";
return GetLanguageString(language, m_descriptions);
}
// (-1 = Japanese, 0 = English, etc)?
std::string GameListItem::GetVolumeName(int _index) const
std::string GameListItem::GetDescription() const
{
u32 const index = _index;
if (index < m_volume_names.size() && !m_volume_names[index].empty())
return m_volume_names[index];
if (!m_volume_names.empty())
return m_volume_names[0];
return "";
return GetDescription(SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(m_Platform != GAMECUBE_DISC));
}
// (-1 = Japanese, 0 = English, etc)?
std::string GameListItem::GetBannerName(int _index) const
std::string GameListItem::GetName(IVolume::ELanguage language) const
{
u32 const index = _index;
if (index < m_banner_names.size() && !m_banner_names[index].empty())
return m_banner_names[index];
if (!m_banner_names.empty())
return m_banner_names[0];
return "";
return GetLanguageString(language, m_names);
}
// (-1 = Japanese, 0 = English, etc)?
std::string GameListItem::GetName(int _index) const
std::string GameListItem::GetName() const
{
// Prefer name from banner, fallback to name from volume, fallback to filename
std::string name = GetBannerName(_index);
if (name.empty())
name = GetVolumeName(_index);
std::string name = GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(m_Platform != GAMECUBE_DISC));
if (name.empty())
{
// No usable name, return filename (better than nothing)
SplitPath(GetFileName(), nullptr, &name, nullptr);
}
return name;
}
std::vector<IVolume::ELanguage> GameListItem::GetLanguages() const
{
std::vector<IVolume::ELanguage> languages;
for (std::pair<IVolume::ELanguage, std::string> name : m_names)
languages.push_back(name.first);
return languages;
}
const std::string GameListItem::GetWiiFSPath() const
{
DiscIO::IVolume *iso = DiscIO::CreateVolumeFromFilename(m_FileName);

View File

@ -5,6 +5,7 @@
#pragma once
#include <string>
#include <utility>
#include <vector>
#include "Common/Common.h"
@ -24,11 +25,12 @@ public:
bool IsValid() const {return m_Valid;}
const std::string& GetFileName() const {return m_FileName;}
std::string GetBannerName(int index) const;
std::string GetVolumeName(int index) const;
std::string GetName(int index) const;
std::string GetName(IVolume::ELanguage language) const;
std::string GetName() const;
std::string GetDescription(IVolume::ELanguage language) const;
std::string GetDescription() const;
std::vector<IVolume::ELanguage> GetLanguages() const;
std::string GetCompany() const;
std::string GetDescription(int index = 0) const;
int GetRevision() const { return m_Revision; }
const std::string& GetUniqueID() const {return m_UniqueID;}
const std::string GetWiiFSPath() const;
@ -57,13 +59,9 @@ public:
private:
std::string m_FileName;
// TODO: eliminate this and overwrite with names from banner when available?
std::vector<std::string> m_volume_names;
// Stuff from banner
std::map<IVolume::ELanguage, std::string> m_names;
std::map<IVolume::ELanguage, std::string> m_descriptions;
std::string m_company;
std::vector<std::string> m_banner_names;
std::vector<std::string> m_descriptions;
std::string m_UniqueID;

View File

@ -114,9 +114,8 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
{
// Load ISO data
OpenISO = DiscIO::CreateVolumeFromFilename(fileName);
bool IsWad = OpenISO->IsWadFile();
// TODO: Is it really necessary to use GetTitleID in case GetUniqueID fails?
// Is it really necessary to use GetTitleID if GetUniqueID fails?
game_id = OpenISO->GetUniqueID();
if (game_id.empty())
{
@ -137,7 +136,7 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
bRefreshList = false;
CreateGUIControls(IsWad);
CreateGUIControls();
LoadGameConfig();
@ -173,33 +172,15 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
break;
case DiscIO::IVolume::COUNTRY_USA:
m_Country->SetValue(_("USA"));
if (!IsWad) // For (non wad) NTSC Games, there's no multi lang
{
m_Lang->SetSelection(0);
m_Lang->Disable();
}
break;
case DiscIO::IVolume::COUNTRY_JAPAN:
m_Country->SetValue(_("Japan"));
if (!IsWad) // For (non wad) NTSC Games, there's no multi lang
{
m_Lang->Insert(_("Japanese"), 0);
m_Lang->SetSelection(0);
m_Lang->Disable();
}
break;
case DiscIO::IVolume::COUNTRY_KOREA:
m_Country->SetValue(_("Korea"));
break;
case DiscIO::IVolume::COUNTRY_TAIWAN:
m_Country->SetValue(_("Taiwan"));
if (!IsWad) // For (non wad) NTSC Games, there's no multi lang
{
m_Lang->Insert(_("Taiwan"), 0);
m_Lang->SetSelection(0);
m_Lang->Disable();
}
break;
case DiscIO::IVolume::COUNTRY_WORLD:
m_Country->SetValue(_("World"));
@ -210,27 +191,14 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
break;
}
if (OpenISO->IsWiiDisc()) // Only one language with Wii banners
{
m_Lang->SetSelection(0);
m_Lang->Disable();
}
wxString temp = "0x" + StrToWxStr(OpenISO->GetMakerID());
m_MakerID->SetValue(temp);
m_Revision->SetValue(wxString::Format("%u", OpenISO->GetRevision()));
m_Date->SetValue(StrToWxStr(OpenISO->GetApploaderDate()));
m_FST->SetValue(wxString::Format("%u", OpenISO->GetFSTSize()));
// Here we set all the info to be shown (be it SJIS or Ascii) + we set the window title
if (!IsWad)
{
ChangeBannerDetails(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage);
}
else
{
ChangeBannerDetails(SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.LNG"));
}
// Here we set all the info to be shown + we set the window title
ChangeBannerDetails(SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(OpenISO->IsWadFile() || OpenISO->IsWiiDisc()));
m_Banner->SetBitmap(OpenGameListItem->GetBitmap());
m_Banner->Bind(wxEVT_RIGHT_DOWN, &CISOProperties::RightClickOnBanner, this);
@ -351,7 +319,7 @@ long CISOProperties::GetElementStyle(const char* section, const char* key)
return wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER;
}
void CISOProperties::CreateGUIControls(bool IsWad)
void CISOProperties::CreateGUIControls()
{
wxButton* const EditConfig = new wxButton(this, ID_EDITCONFIG, _("Edit Config"));
EditConfig->SetToolTip(_("This will let you manually edit the INI config file."));
@ -534,24 +502,58 @@ void CISOProperties::CreateGUIControls(bool IsWad)
m_MD5SumCompute = new wxButton(m_Information, ID_MD5SUMCOMPUTE, _("Compute"));
wxStaticText* const m_LangText = new wxStaticText(m_Information, wxID_ANY, _("Show Language:"));
arrayStringFor_Lang.Add(_("English"));
arrayStringFor_Lang.Add(_("German"));
arrayStringFor_Lang.Add(_("French"));
arrayStringFor_Lang.Add(_("Spanish"));
arrayStringFor_Lang.Add(_("Italian"));
arrayStringFor_Lang.Add(_("Dutch"));
int language = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
if (IsWad)
{
arrayStringFor_Lang.Insert(_("Japanese"), 0);
arrayStringFor_Lang.Add(_("Simplified Chinese"));
arrayStringFor_Lang.Add(_("Traditional Chinese"));
arrayStringFor_Lang.Add(_("Korean"));
language = SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.LNG");
IVolume::ELanguage preferred_language = SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(OpenISO->IsWadFile() || OpenISO->IsWiiDisc());
std::vector<IVolume::ELanguage> languages = OpenGameListItem->GetLanguages();
int preferred_language_index = 0;
for (size_t i = 0; i < languages.size(); ++i)
{
if (languages[i] == preferred_language)
preferred_language_index = i;
switch (languages[i])
{
case IVolume::LANGUAGE_JAPANESE:
arrayStringFor_Lang.Add(_("Japanese"));
break;
case IVolume::LANGUAGE_ENGLISH:
arrayStringFor_Lang.Add(_("English"));
break;
case IVolume::LANGUAGE_GERMAN:
arrayStringFor_Lang.Add(_("German"));
break;
case IVolume::LANGUAGE_FRENCH:
arrayStringFor_Lang.Add(_("French"));
break;
case IVolume::LANGUAGE_SPANISH:
arrayStringFor_Lang.Add(_("Spanish"));
break;
case IVolume::LANGUAGE_ITALIAN:
arrayStringFor_Lang.Add(_("Italian"));
break;
case IVolume::LANGUAGE_DUTCH:
arrayStringFor_Lang.Add(_("Dutch"));
break;
case IVolume::LANGUAGE_SIMPLIFIED_CHINESE:
arrayStringFor_Lang.Add(_("Simplified Chinese"));
break;
case IVolume::LANGUAGE_TRADITIONAL_CHINESE:
arrayStringFor_Lang.Add(_("Traditional Chinese"));
break;
case IVolume::LANGUAGE_KOREAN:
arrayStringFor_Lang.Add(_("Korean"));
break;
case IVolume::LANGUAGE_UNKNOWN:
default:
arrayStringFor_Lang.Add(_("Unknown"));
break;
}
}
m_Lang = new wxChoice(m_Information, ID_LANG, wxDefaultPosition, wxDefaultSize, arrayStringFor_Lang);
m_Lang->SetSelection(language);
m_Lang->SetSelection(preferred_language_index);
if (arrayStringFor_Lang.size() <= 1)
m_Lang->Disable();
wxStaticText* const m_ShortText = new wxStaticText(m_Information, wxID_ANY, _("Short Name:"));
m_ShortName = new wxTextCtrl(m_Information, ID_SHORTNAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
@ -611,7 +613,7 @@ void CISOProperties::CreateGUIControls(bool IsWad)
sInfoPage->Add(sbBannerDetails, 0, wxEXPAND|wxALL, 5);
m_Information->SetSizer(sInfoPage);
if (!IsWad)
if (!OpenISO->IsWadFile())
{
wxPanel* const m_Filesystem = new wxPanel(m_Notebook, ID_FILESYSTEM);
m_Notebook->AddPage(m_Filesystem, _("Filesystem"));
@ -1490,13 +1492,13 @@ void CISOProperties::ActionReplayButtonClicked(wxCommandEvent& event)
void CISOProperties::OnChangeBannerLang(wxCommandEvent& event)
{
ChangeBannerDetails(event.GetSelection());
ChangeBannerDetails(OpenGameListItem->GetLanguages()[event.GetSelection()]);
}
void CISOProperties::ChangeBannerDetails(int lang)
void CISOProperties::ChangeBannerDetails(IVolume::ELanguage language)
{
wxString const shortName = StrToWxStr(OpenGameListItem->GetName(lang));
wxString const comment = StrToWxStr(OpenGameListItem->GetDescription(lang));
wxString const shortName = StrToWxStr(OpenGameListItem->GetName(language));
wxString const comment = StrToWxStr(OpenGameListItem->GetDescription(language));
wxString const maker = StrToWxStr(OpenGameListItem->GetCompany());
// Updates the information shown in the window

View File

@ -197,7 +197,7 @@ private:
void LaunchExternalEditor(const std::string& filename);
void CreateGUIControls(bool);
void CreateGUIControls();
void OnClose(wxCloseEvent& event);
void OnCloseClick(wxCommandEvent& event);
void OnEditConfig(wxCommandEvent& event);
@ -242,7 +242,7 @@ private:
void PatchList_Load();
void PatchList_Save();
void ActionReplayList_Save();
void ChangeBannerDetails(int lang);
void ChangeBannerDetails(IVolume::ELanguage language);
long GetElementStyle(const char* section, const char* key);
void SetCheckboxValueFromGameini(const char* section, const char* key, wxCheckBox* checkbox);

View File

@ -37,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"
@ -114,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::vector<std::string> m_volume_names;
std::vector<std::string> m_names;
std::map<DiscIO::IVolume::ELanguage, std::string> m_names;
bool m_is_wii_title;
static inline u32 Average32(u32 a, u32 b) {
return ((a >> 1) & 0x7f7f7f7f) + ((b >> 1) & 0x7f7f7f7f);
@ -130,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<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
if (pVolume != nullptr)
{
bool bIsWad = false;
if (DiscIO::IsVolumeWadFile(pVolume))
bIsWad = true;
m_names = pVolume->GetNames();
m_is_wii_title = pVolume->IsWiiDisc() || pVolume->IsWadFile();
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)
int Width, Height;
std::vector<u32> 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<u32> 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;
}
}
@ -186,15 +168,28 @@ static bool LoadBanner(std::string filename, u32 *Banner)
static std::string GetName(std::string filename)
{
if (!m_names.empty())
return m_names[0];
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.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;
}
@ -276,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());
}

View File

@ -69,7 +69,7 @@ static wxString FailureReasonStringForHostLabel(int reason)
static std::string BuildGameName(const GameListItem& game)
{
// Lang needs to be consistent
auto const lang = 0;
IVolume::ELanguage const lang = IVolume::LANGUAGE_ENGLISH;
std::string name(game.GetName(lang));