Display banners correctly on Korean consoles

This is a workaround. Ideally a lightweight Korean banner font should be loaded.
This commit is contained in:
wiidev 2021-08-01 18:00:20 +01:00
parent 6b0a425bb0
commit 6d240872bb
8 changed files with 301 additions and 165 deletions

View File

@ -368,6 +368,18 @@ Pane* Layout::FindPane(const std::string& find_name)
return NULL;
}
Pane* Layout::FindPanePartial(const std::string& find_name)
{
for(u32 i = 0; i < panes.size(); ++i)
{
Pane* found = panes[i]->FindPanePartial(find_name, find_name.length());
if(found)
return found;
}
return NULL;
}
Material* Layout::FindMaterial(const std::string& find_name)
{
for(u32 i = 0; i < resources.materials.size(); ++i)

View File

@ -88,6 +88,7 @@ public:
void SetLanguage(const std::string& language);
Pane* FindPane(const std::string& name);
Pane* FindPanePartial(const std::string& name);
Material* FindMaterial(const std::string& name);
Texture *FindTexture(const std::string &name);

View File

@ -152,11 +152,9 @@ bool OpeningBNR::Load(const discHdr * header)
bool OpeningBNR::LoadWiiBanner(const discHdr *header)
{
if(!header || ( (header->type != TYPE_GAME_WII_IMG)
&& (header->type != TYPE_GAME_WII_DISC)))
if (!header || ((header->type != TYPE_GAME_WII_IMG) && (header->type != TYPE_GAME_WII_DISC)))
return false;
if (Settings.CacheBNRFiles && LoadCachedBNR((const char *)header->id))
return true;
@ -211,8 +209,7 @@ bool OpeningBNR::LoadWiiBanner(const discHdr * header)
bool OpeningBNR::LoadChannelBanner(const discHdr *header)
{
if(!header || (header->tid == 0) || ( (header->type != TYPE_GAME_NANDCHAN)
&& (header->type != TYPE_GAME_EMUNANDCHAN)))
if (!header || (header->tid == 0) || ((header->type != TYPE_GAME_NANDCHAN) && (header->type != TYPE_GAME_EMUNANDCHAN)))
return false;
if (Settings.CacheBNRFiles && LoadCachedBNR((char *)header->id))
@ -265,9 +262,7 @@ static s32 GC_Disc_Read(void *fp, u32 offset, u32 count, void*iobuf)
u8 *OpeningBNR::LoadGCBNR(const discHdr *header, u32 *len)
{
if(!header || ( (header->type != TYPE_GAME_GC_IMG)
&& (header->type != TYPE_GAME_GC_DISC)
&& (header->type != TYPE_GAME_GC_EXTRACTED)))
if (!header || ((header->type != TYPE_GAME_GC_IMG) && (header->type != TYPE_GAME_GC_DISC) && (header->type != TYPE_GAME_GC_EXTRACTED)))
return NULL;
const char *path = GCGames::Instance()->GetPath((char *)header->id);
@ -289,12 +284,14 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len)
}
gcdisc_t *disc = gc_open_disc(GC_Disc_Read, file);
if(!disc) {
if (!disc)
{
fclose(file);
return NULL;
}
if(!strcmp(Settings.db_language, "JA")) {
if (!strcmp(Settings.db_language, "JA"))
{
bool loaded = gc_extract_file(disc, "openingJA.bnr");
if (!loaded)
loaded = gc_extract_file(disc, "opening.bnr");
@ -303,7 +300,8 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len)
if (!loaded)
loaded = gc_extract_file(disc, "openingEU.bnr");
}
else if(!strcmp(Settings.db_language, "EN")) {
else if (!strcmp(Settings.db_language, "EN"))
{
bool loaded = gc_extract_file(disc, "openingUS.bnr");
if (!loaded)
loaded = gc_extract_file(disc, "opening.bnr");
@ -312,7 +310,8 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len)
if (!loaded)
loaded = gc_extract_file(disc, "openingJA.bnr");
}
else {
else
{
bool loaded = gc_extract_file(disc, "openingEU.bnr");
if (!loaded)
loaded = gc_extract_file(disc, "opening.bnr");
@ -336,7 +335,8 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len)
file = fopen((gamePath + "opening.bnr").c_str(), "rb");
// if not found try the region specific ones
if(!strcmp(Settings.db_language, "JA")) {
if (!strcmp(Settings.db_language, "JA"))
{
if (!file)
file = fopen((gamePath + "openingJA.bnr").c_str(), "rb");
if (!file)
@ -344,7 +344,8 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len)
if (!file)
file = fopen((gamePath + "openingEU.bnr").c_str(), "rb");
}
else if(!strcmp(Settings.db_language, "EN")) {
else if (!strcmp(Settings.db_language, "EN"))
{
if (!file)
file = fopen((gamePath + "openingUS.bnr").c_str(), "rb");
if (!file)
@ -352,7 +353,8 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len)
if (!file)
file = fopen((gamePath + "openingJA.bnr").c_str(), "rb");
}
else {
else
{
if (!file)
file = fopen((gamePath + "openingEU.bnr").c_str(), "rb");
if (!file)
@ -376,7 +378,6 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len)
*len = size;
fread(openingBnr, 1, size, file);
}
}
if (file)
@ -386,7 +387,8 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len)
return NULL;
// check magic of the opening bnr
if(openingBnr->magic != 'BNR1' && openingBnr->magic != 'BNR2') {
if (openingBnr->magic != 'BNR1' && openingBnr->magic != 'BNR2')
{
free(openingBnr);
return NULL;
}
@ -398,6 +400,7 @@ CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header)
{
int language = 0;
u32 openingBnrSize;
wString developer;
GC_OpeningBnr *openingBnr = (GC_OpeningBnr *)LoadGCBNR(header, &openingBnrSize);
CustomBanner *banner = new CustomBanner;
@ -413,35 +416,30 @@ CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header)
// European opening bnr file
if (openingBnr->magic == 'BNR2')
{
if(!strcmp(Settings.db_language, "DE")) {
if (!strcmp(Settings.db_language, "DE"))
language = 1;
}
else if(!strcmp(Settings.db_language, "FR")) {
else if (!strcmp(Settings.db_language, "FR"))
language = 2;
}
else if(!strcmp(Settings.db_language, "ES")) {
else if (!strcmp(Settings.db_language, "ES"))
language = 3;
}
else if(!strcmp(Settings.db_language, "IT")) {
else if (!strcmp(Settings.db_language, "IT"))
language = 4;
}
else if(!strcmp(Settings.db_language, "NL")) {
else if (!strcmp(Settings.db_language, "NL"))
language = 5;
}
if((0x1820 + sizeof(openingBnr->description[0]) * language) > openingBnrSize) {
if ((0x1820 + sizeof(openingBnr->description[0]) * language) > openingBnrSize)
{
language = 0;
}
}
// sets the developer
wString str;
str.resize(strlen((char *) openingBnr->description[language].developer));
for(u32 i = 0; i < str.size(); i++)
str[i] = *(openingBnr->description[language].developer + i);
developer.resize(strlen((char *)openingBnr->description[language].developer));
for (u32 i = 0; i < developer.size(); i++)
developer[i] = *(openingBnr->description[language].developer + i);
banner->SetBannerText("T_Coded_by", tr("Developer:"));
banner->SetBannerText("T_coder", str.toUTF8().c_str());
banner->SetBannerText("T_coder", developer.toUTF8().c_str());
// sets the description and converts encodings (Japan and Taiwan)
if (header->id[3] == 'J' || header->id[3] == 'W')
@ -451,11 +449,12 @@ CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header)
}
else
{
str.resize(strlen((char *) openingBnr->description[language].long_description));
for(u32 i = 0; i < str.size(); i++)
str[i] = *(openingBnr->description[language].long_description + i);
wString description;
description.resize(strlen((char *)openingBnr->description[language].long_description));
for (u32 i = 0; i < description.size(); i++)
description[i] = *(openingBnr->description[language].long_description + i);
banner->SetBannerText("T_short_descript", str.toUTF8().c_str());
banner->SetBannerText("T_short_descript", description.toUTF8().c_str());
}
// free buffer
@ -469,6 +468,12 @@ CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header)
banner->SetBannerText("T_short_descript", " ");
}
if (strcmp(Settings.db_language, "KO") == 0)
{
banner->SetBannerText("T_Coded_by", developer.toUTF8().c_str());
banner->SetBannerPaneVisible("T_coder", false);
}
else
banner->SetBannerText("T_name", GameTitles.GetTitle(header));
banner->SetBannerPaneVisible("Line1", false);
banner->SetBannerPaneVisible("Line2", false);

View File

@ -88,7 +88,6 @@ typedef struct _U8Entry
};
} __attribute__((packed)) U8Entry;
static inline const char *u8Filename(const U8Entry *fst, int i)
{
return (char *)(fst + fst[0].numEntries) + fst[i].nameOffset;
@ -112,7 +111,12 @@ class OpeningBNR
void WriteCachedBNR(const char *id, const u8 *buffer, u32 size);
const u16 *GetIMETTitle(int lang);
const u16 * GetIMETTitle(const discHdr * header, int lang) { Load(header); return GetIMETTitle(lang); }
const u16 *GetIMETTitle(const discHdr *header, int lang)
{
Load(header);
return GetIMETTitle(lang);
}
private:
u8 *LoadGCBNR(const discHdr *header, u32 *len = 0);
IMETHeader *imetHdr;
@ -123,8 +127,18 @@ class OpeningBNR
class BNRInstance : public OpeningBNR
{
public:
static BNRInstance * Instance() { if(!instance) instance = new BNRInstance; return instance; }
static void DestroyInstance() { delete instance; instance = NULL; }
static BNRInstance *Instance()
{
if (!instance)
instance = new BNRInstance;
return instance;
}
static void DestroyInstance()
{
delete instance;
instance = NULL;
}
private:
BNRInstance() {}
~BNRInstance() {}

View File

@ -130,6 +130,25 @@ Pane* Pane::FindPane(const std::string& find_name)
return NULL;
}
Pane* Pane::FindPanePartial(const std::string& find_name, int len)
{
if(!header)
return NULL;
std::string str(getName());
if (str.compare(0, len, find_name) == 0)
return this;
for(u32 i = 0; i < panes.size(); ++i)
{
Pane *found = panes[i]->FindPanePartial(find_name, len);
if (found)
return found;
}
return NULL;
}
void Pane::ProcessHermiteKey(const KeyType& type, float value)
{
if (type.type == ANIMATION_TYPE_VERTEX_COLOR) // vertex color

View File

@ -109,6 +109,7 @@ public:
bool GetWidescren() const { return ((header->flags & (1 << FLAG_WIDESCREEN)) != 0); }
Pane* FindPane(const std::string& name); // recursive
Pane* FindPanePartial(const std::string& name, int len); // recursive
PaneList panes;

View File

@ -22,6 +22,7 @@
#include "banner/OpeningBNR.hpp"
#include "settings/CSettings.h"
#include "settings/CGameStatistics.h"
#include "settings/GameTitles.h"
#include "settings/menus/GameSettingsMenu.hpp"
#include "SystemMenu/SystemMenuResources.h"
#include "prompts/GameWindow.hpp"
@ -116,6 +117,12 @@ BannerWindow::BannerWindow(GameBrowseMenu *m, struct discHdr *header)
settingsBtn->SetSoundClick(btnSoundClick2);
settingsBtn->SetPosition(-120, 175);
settingsBtn->SetTrigger(trigA);
if (strcmp(Settings.db_language, "KO") == 0)
{
settingsBtnTxt = new GuiText(tr("Settings"), 35, thColor("r=0 g=0 b=0 a=255 - game window size text color"));
settingsBtn->SetPosition(Settings.widescreen ? -113 : -131, 161);
settingsBtn->SetLabel(settingsBtnTxt);
}
startBtn = new GuiButton(215, 75);
startBtn->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
@ -123,6 +130,12 @@ BannerWindow::BannerWindow(GameBrowseMenu *m, struct discHdr *header)
startBtn->SetSoundClick(btnSoundClick2);
startBtn->SetPosition(110, 175);
startBtn->SetTrigger(trigA);
if (strcmp(Settings.db_language, "KO") == 0)
{
startBtnTxt = new GuiText(tr("Start"), 35, thColor("r=0 g=0 b=0 a=255 - game window size text color"));
startBtn->SetPosition(Settings.widescreen ? 114 : 132, 161);
startBtn->SetLabel(startBtnTxt);
}
backBtn = new GuiButton(215, 75);
backBtn->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
@ -131,6 +144,11 @@ BannerWindow::BannerWindow(GameBrowseMenu *m, struct discHdr *header)
backBtn->SetPosition(-screenwidth, -screenheight); // set out of screen
backBtn->SetTrigger(0, trigA);
backBtn->SetTrigger(1, trigB);
if (strcmp(Settings.db_language, "KO") == 0)
{
backBtnTxt = new GuiText(tr("Back"), 35, thColor("r=0 g=0 b=0 a=255 - game window size text color"));
backBtn->SetLabel(backBtnTxt);
}
// Set favorite button position
int xPos = -198-(3*27)-14;
@ -254,11 +272,18 @@ BannerWindow::BannerWindow(GameBrowseMenu *m, struct discHdr *header)
Append(btnRight);
}
if (strcmp(Settings.db_language, "KO") == 0)
{
bannerFrame.SetButtonAText(" ");
bannerFrame.SetButtonBText(" ");
}
else
bannerFrame.SetButtonBText(tr("Start"));
//check if unlocked
if (Settings.godmode || !(Settings.ParentalBlocks & BLOCK_GAME_SETTINGS))
{
if (strcmp(Settings.db_language, "KO") != 0)
bannerFrame.SetButtonAText(tr("Settings"));
Append(settingsBtn);
if(Settings.bannerFavIcon != BANNER_FAVICON_OFF)
@ -266,13 +291,27 @@ BannerWindow::BannerWindow(GameBrowseMenu *m, struct discHdr *header)
Append(FavoriteBtn[i]);
}
else
{
if (strcmp(Settings.db_language, "KO") == 0)
{
backBtn->SetPosition(Settings.widescreen ? -113 : -131, 161);
}
else
{
bannerFrame.SetButtonAText(tr("Back"));
backBtn->SetPosition(-120, 175);
}
}
Append(startBtn); //! Appending the disc on top of all
if (strcmp(Settings.db_language, "KO") == 0)
{
titleName = new GuiText((char *) NULL, 29, (GXColor) {255, 255, 255, 255});
titleName->SetFontSize(29);
titleName->SetScale(0.8f);
}
ChangeGame(false);
}
@ -300,6 +339,14 @@ BannerWindow::~BannerWindow()
delete playcntTxt;
if (strcmp(Settings.db_language, "KO") == 0)
{
delete startBtnTxt;
delete backBtnTxt;
delete settingsBtnTxt;
delete titleName;
}
delete startBtn;
delete backBtn;
delete settingsBtn;
@ -331,6 +378,11 @@ void BannerWindow::ChangeGame(bool playsound)
BannerAsync::HaltThread();
Banner *newBanner = NULL;
if (strcmp(Settings.db_language, "KO") == 0)
{
Remove(titleName);
titleName->SetText(GameTitles.GetTitle(header));
}
// continue playing sound during loading process
if((header->type == TYPE_GAME_GC_IMG) || (header->type == TYPE_GAME_GC_DISC) || (header->type == TYPE_GAME_GC_EXTRACTED))
{
@ -338,9 +390,18 @@ void BannerWindow::ChangeGame(bool playsound)
if(BNRInstance::Instance()->Load(header) && BNRInstance::Instance()->Get() != NULL)
newBanner = new Banner;
else
{
newBanner = BNRInstance::Instance()->CreateGCBanner(header);
if (strcmp(Settings.db_language, "KO") == 0)
{
titleName->SetAlignment(ALIGN_CENTER, ALIGN_BOTTOM);
titleName->SetPosition(0, -170);
Append(titleName);
}
else {
}
}
else
{
BNRInstance::Instance()->Load(header);
newBanner = new Banner;
}
@ -393,6 +454,24 @@ void BannerWindow::ChangeGame(bool playsound)
for(int i = 0; i < FAVORITE_STARS; ++i)
FavoriteBtnImg[i]->SetImage(favoritevar >= i+1 ? imgFavorite : imgNotFavorite);
if (strcmp(Settings.db_language, "KO") == 0)
{
Pane *yearPane = gameBanner->getBanner()->FindPanePartial("YearLine");
if (yearPane)
yearPane->SetVisible(false);
Pane *playersPane = gameBanner->getBanner()->FindPanePartial("PlayLine");
if (playersPane)
playersPane->SetVisible(false);
Pane *titlePane = gameBanner->getBanner()->FindPanePartial("T_VCTitle");
if (titlePane)
{
titlePane->SetVisible(false);
titleName->SetAlignment(ALIGN_CENTER, ALIGN_BOTTOM);
titleName->SetPosition(0, -170);
Append(titleName);
}
}
//! Resume all threads
BannerAsync::ResumeThread();
ResumeGui();

View File

@ -90,6 +90,11 @@ class BannerWindow : public GuiWindow
GuiText * playcntTxt;
GuiText * startBtnTxt;
GuiText * backBtnTxt;
GuiText * settingsBtnTxt;
GuiText * titleName;
GuiButton * startBtn;
GuiButton * backBtn;
GuiButton * settingsBtn;