From 6d240872bbdd042596576ed62e0fccf952e1f4a6 Mon Sep 17 00:00:00 2001 From: wiidev Date: Sun, 1 Aug 2021 18:00:20 +0100 Subject: [PATCH] Display banners correctly on Korean consoles This is a workaround. Ideally a lightweight Korean banner font should be loaded. --- source/banner/Layout.cpp | 12 ++ source/banner/Layout.h | 1 + source/banner/OpeningBNR.cpp | 239 ++++++++++++++++---------------- source/banner/OpeningBNR.hpp | 98 +++++++------ source/banner/Pane.cpp | 19 +++ source/banner/Pane.h | 3 +- source/prompts/BannerWindow.cpp | 89 +++++++++++- source/prompts/BannerWindow.hpp | 5 + 8 files changed, 301 insertions(+), 165 deletions(-) diff --git a/source/banner/Layout.cpp b/source/banner/Layout.cpp index 4cf4b916..2f842512 100644 --- a/source/banner/Layout.cpp +++ b/source/banner/Layout.cpp @@ -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) diff --git a/source/banner/Layout.h b/source/banner/Layout.h index a1cac479..bf217819 100644 --- a/source/banner/Layout.h +++ b/source/banner/Layout.h @@ -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); diff --git a/source/banner/OpeningBNR.cpp b/source/banner/OpeningBNR.cpp index e7c9918c..d3dc2649 100644 --- a/source/banner/OpeningBNR.cpp +++ b/source/banner/OpeningBNR.cpp @@ -42,7 +42,7 @@ distribution. #include "wstring.hpp" #include "OpeningBNR.hpp" -BNRInstance * BNRInstance::instance = NULL; +BNRInstance *BNRInstance::instance = NULL; OpeningBNR::OpeningBNR() : imetHdr(0), filesize(0) @@ -52,7 +52,7 @@ OpeningBNR::OpeningBNR() OpeningBNR::~OpeningBNR() { - if(imetHdr) + if (imetHdr) free(imetHdr); } @@ -60,19 +60,19 @@ bool OpeningBNR::LoadCachedBNR(const char *id) { char path[255]; snprintf(path, sizeof(path), "%s%.6s.bnr", Settings.BNRCachePath, id); - if((filesize = FileSize(path)) == 0) + if ((filesize = FileSize(path)) == 0) { snprintf(path, sizeof(path), "%s%.3s.bnr", Settings.BNRCachePath, id); - if((filesize = FileSize(path)) == 0) + if ((filesize = FileSize(path)) == 0) return false; } FILE *f = fopen(path, "rb"); - if(!f) + if (!f) return false; - imetHdr = (IMETHeader *) malloc(filesize); - if(!imetHdr) + imetHdr = (IMETHeader *)malloc(filesize); + if (!imetHdr) { fclose(f); return false; @@ -85,7 +85,7 @@ bool OpeningBNR::LoadCachedBNR(const char *id) { //! check if it's a channel .app file IMETHeader *channelImet = (IMETHeader *)(((u8 *)imetHdr) + 0x40); - if(channelImet->fcc != 'IMET') + if (channelImet->fcc != 'IMET') { free(imetHdr); imetHdr = NULL; @@ -108,28 +108,28 @@ void OpeningBNR::WriteCachedBNR(const char *id, const u8 *buffer, u32 size) CreateSubfolder(Settings.BNRCachePath); FILE *f = fopen(path, "wb"); - if(!f) + if (!f) return; fwrite(buffer, 1, size, f); fclose(f); } -bool OpeningBNR::Load(const discHdr * header) +bool OpeningBNR::Load(const discHdr *header) { - if(!header) + if (!header) return false; - if(memcmp(gameID, header->id, 6) == 0) + if (memcmp(gameID, header->id, 6) == 0) return true; memcpy(gameID, header->id, 6); - if(imetHdr) + if (imetHdr) free(imetHdr); imetHdr = NULL; - switch(header->type) + switch (header->type) { case TYPE_GAME_WII_IMG: case TYPE_GAME_WII_DISC: @@ -140,7 +140,7 @@ bool OpeningBNR::Load(const discHdr * header) case TYPE_GAME_GC_IMG: case TYPE_GAME_GC_DISC: case TYPE_GAME_GC_EXTRACTED: - if(!Settings.CacheBNRFiles) + if (!Settings.CacheBNRFiles) return false; return LoadCachedBNR((char *)header->id); default: @@ -150,23 +150,21 @@ bool OpeningBNR::Load(const discHdr * header) return false; } -bool OpeningBNR::LoadWiiBanner(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)) + if (Settings.CacheBNRFiles && LoadCachedBNR((const char *)header->id)) return true; - if(header->type == TYPE_GAME_WII_DISC) + if (header->type == TYPE_GAME_WII_DISC) { wiidisc_t *wdisc = wd_open_disc(__ReadDVD, 0); if (!wdisc) return false; - imetHdr = (IMETHeader*) wd_extract_file(wdisc, ALL_PARTITIONS, (char *) "opening.bnr"); + imetHdr = (IMETHeader *)wd_extract_file(wdisc, ALL_PARTITIONS, (char *)"opening.bnr"); filesize = wdisc->extracted_size; @@ -174,18 +172,18 @@ bool OpeningBNR::LoadWiiBanner(const discHdr * header) } else { - wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) gameID); + wbfs_disc_t *disc = WBFS_OpenDisc((u8 *)gameID); if (!disc) return false; - wiidisc_t *wdisc = wd_open_disc((s32(*)(void *, u32, u32, void *)) wbfs_disc_read, disc); + wiidisc_t *wdisc = wd_open_disc((s32(*)(void *, u32, u32, void *))wbfs_disc_read, disc); if (!wdisc) { WBFS_CloseDisc(disc); return false; } - imetHdr = (IMETHeader*) wd_extract_file(wdisc, ALL_PARTITIONS, (char *) "opening.bnr"); + imetHdr = (IMETHeader *)wd_extract_file(wdisc, ALL_PARTITIONS, (char *)"opening.bnr"); filesize = wdisc->extracted_size; @@ -193,7 +191,7 @@ bool OpeningBNR::LoadWiiBanner(const discHdr * header) WBFS_CloseDisc(disc); } - if(!imetHdr) + if (!imetHdr) return false; if (imetHdr->fcc != 'IMET') @@ -203,26 +201,25 @@ bool OpeningBNR::LoadWiiBanner(const discHdr * header) return false; } - if(Settings.CacheBNRFiles) - WriteCachedBNR((const char *) header->id, (u8 *) imetHdr, filesize); + if (Settings.CacheBNRFiles) + WriteCachedBNR((const char *)header->id, (u8 *)imetHdr, filesize); return true; } 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)) + if (Settings.CacheBNRFiles && LoadCachedBNR((char *)header->id)) return true; const u64 &tid = header->tid; const char *pathPrefix = (header->type == TYPE_GAME_EMUNANDCHAN) ? Settings.NandEmuChanPath : ""; - imetHdr = (IMETHeader*) Channels::GetOpeningBnr(tid, &filesize, pathPrefix); - if(!imetHdr) + imetHdr = (IMETHeader *)Channels::GetOpeningBnr(tid, &filesize, pathPrefix); + if (!imetHdr) return false; if (imetHdr->fcc != 'IMET') @@ -232,29 +229,29 @@ bool OpeningBNR::LoadChannelBanner(const discHdr *header) return false; } - if(Settings.CacheBNRFiles) - WriteCachedBNR((char *) header->id, (u8 *) imetHdr, filesize); + if (Settings.CacheBNRFiles) + WriteCachedBNR((char *)header->id, (u8 *)imetHdr, filesize); return true; } -const u16 * OpeningBNR::GetIMETTitle(int lang) +const u16 *OpeningBNR::GetIMETTitle(int lang) { - if(!imetHdr || lang < 0 || lang >= 10) + if (!imetHdr || lang < 0 || lang >= 10) return NULL; if (imetHdr->fcc != 'IMET') return NULL; - if(imetHdr->names[lang][0] == 0) + if (imetHdr->names[lang][0] == 0) lang = CONF_LANG_ENGLISH; return imetHdr->names[lang]; // possible unaligned pointer value } -static s32 GC_Disc_Read(void *fp, u32 offset, u32 count, void*iobuf) +static s32 GC_Disc_Read(void *fp, u32 offset, u32 count, void *iobuf) { - if(fp) + if (fp) { fseek((FILE *)fp, offset, SEEK_SET); return fread(iobuf, 1, count, (FILE *)fp); @@ -263,72 +260,74 @@ static s32 GC_Disc_Read(void *fp, u32 offset, u32 count, void*iobuf) return __ReadDVDPlain(iobuf, count, offset); } -u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len) +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); - if(!path) + const char *path = GCGames::Instance()->GetPath((char *)header->id); + if (!path) return NULL; FILE *file = NULL; GC_OpeningBnr *openingBnr = NULL; // read from file - if((header->type == TYPE_GAME_GC_IMG) || (header->type == TYPE_GAME_GC_DISC)) + if ((header->type == TYPE_GAME_GC_IMG) || (header->type == TYPE_GAME_GC_DISC)) { //! open iso file if it's iso - if(header->type == TYPE_GAME_GC_IMG) + if (header->type == TYPE_GAME_GC_IMG) { file = fopen(path, "rb"); - if(!file) + if (!file) return NULL; } 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) + if (!loaded) loaded = gc_extract_file(disc, "opening.bnr"); - if(!loaded) + if (!loaded) loaded = gc_extract_file(disc, "openingUS.bnr"); - if(!loaded) + 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) + if (!loaded) loaded = gc_extract_file(disc, "opening.bnr"); - if(!loaded) + if (!loaded) loaded = gc_extract_file(disc, "openingEU.bnr"); - if(!loaded) + if (!loaded) loaded = gc_extract_file(disc, "openingJA.bnr"); } - else { + else + { bool loaded = gc_extract_file(disc, "openingEU.bnr"); - if(!loaded) + if (!loaded) loaded = gc_extract_file(disc, "opening.bnr"); - if(!loaded) + if (!loaded) loaded = gc_extract_file(disc, "openingUS.bnr"); - if(!loaded) + if (!loaded) loaded = gc_extract_file(disc, "openingJA.bnr"); } - openingBnr = (GC_OpeningBnr *) disc->extracted_buffer; - if(len) + openingBnr = (GC_OpeningBnr *)disc->extracted_buffer; + if (len) *len = disc->extracted_size; gc_close_disc(disc); } - else if(header->type == TYPE_GAME_GC_EXTRACTED) + else if (header->type == TYPE_GAME_GC_EXTRACTED) { std::string gamePath = path; gamePath += "root/"; @@ -336,69 +335,73 @@ 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(!file) + if (!strcmp(Settings.db_language, "JA")) + { + if (!file) file = fopen((gamePath + "openingJA.bnr").c_str(), "rb"); - if(!file) + if (!file) file = fopen((gamePath + "openingUS.bnr").c_str(), "rb"); - if(!file) + if (!file) file = fopen((gamePath + "openingEU.bnr").c_str(), "rb"); } - else if(!strcmp(Settings.db_language, "EN")) { - if(!file) + else if (!strcmp(Settings.db_language, "EN")) + { + if (!file) file = fopen((gamePath + "openingUS.bnr").c_str(), "rb"); - if(!file) + if (!file) file = fopen((gamePath + "openingEU.bnr").c_str(), "rb"); - if(!file) + if (!file) file = fopen((gamePath + "openingJA.bnr").c_str(), "rb"); } - else { - if(!file) + else + { + if (!file) file = fopen((gamePath + "openingEU.bnr").c_str(), "rb"); - if(!file) + if (!file) file = fopen((gamePath + "openingUS.bnr").c_str(), "rb"); - if(!file) + if (!file) file = fopen((gamePath + "openingJA.bnr").c_str(), "rb"); } // file not found - if(!file) + if (!file) return NULL; fseek(file, 0, SEEK_END); int size = ftell(file); rewind(file); - openingBnr = (GC_OpeningBnr *) malloc(size); - if(openingBnr) + openingBnr = (GC_OpeningBnr *)malloc(size); + if (openingBnr) { - if(len) + if (len) *len = size; fread(openingBnr, 1, size, file); } - } - if(file) + if (file) fclose(file); - if(!openingBnr) + if (!openingBnr) 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; } - return (u8 *) openingBnr; + return (u8 *)openingBnr; } -CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header) +CustomBanner *OpeningBNR::CreateGCBanner(const discHdr *header) { int language = 0; u32 openingBnrSize; - GC_OpeningBnr *openingBnr = (GC_OpeningBnr *) LoadGCBNR(header, &openingBnrSize); + wString developer; + GC_OpeningBnr *openingBnr = (GC_OpeningBnr *)LoadGCBNR(header, &openingBnrSize); CustomBanner *banner = new CustomBanner; banner->LoadBanner(Resources::GetFile("custom_banner.bnr"), Resources::GetFileSize("custom_banner.bnr")); @@ -406,56 +409,52 @@ CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header) banner->SetBannerText("T_PF", tr("GameCube")); - if(openingBnr) + if (openingBnr) { banner->SetBannerTexture("HBPic.tpl", openingBnr->tpl_data, 96, 32, GX_TF_RGB5A3); // European opening bnr file - if(openingBnr->magic == 'BNR2') + 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') + if (header->id[3] == 'J' || header->id[3] == 'W') { - std::string description((char *) openingBnr->description[language].long_description); + std::string description((char *)openingBnr->description[language].long_description); banner->SetBannerText("T_short_descript", sj2utf8(description).c_str()); } 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,7 +468,13 @@ CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header) banner->SetBannerText("T_short_descript", " "); } - banner->SetBannerText("T_name", GameTitles.GetTitle(header)); + 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); banner->SetBannerPaneVisible("T_Released", false); @@ -481,14 +486,14 @@ CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header) return banner; } -CustomBanner *OpeningBNR::CreateGCIcon(const discHdr * header) +CustomBanner *OpeningBNR::CreateGCIcon(const discHdr *header) { - GC_OpeningBnr *openingBnr = (GC_OpeningBnr *) LoadGCBNR(header); + GC_OpeningBnr *openingBnr = (GC_OpeningBnr *)LoadGCBNR(header); CustomBanner *newBanner = new CustomBanner; newBanner->LoadIcon(Resources::GetFile("custom_banner.bnr"), Resources::GetFileSize("custom_banner.bnr")); - if(openingBnr) + if (openingBnr) newBanner->SetIconTexture("Iconpng.tpl", openingBnr->tpl_data, 96, 32, GX_TF_RGB5A3); else newBanner->SetIconPngImage("Iconpng.tpl", Resources::GetFile("gc_icon_bg.png"), Resources::GetFileSize("gc_icon_bg.png")); @@ -496,7 +501,7 @@ CustomBanner *OpeningBNR::CreateGCIcon(const discHdr * header) newBanner->SetIconPngImage("HBLogo.tpl", Resources::GetFile("gc_icon_bg.png"), Resources::GetFileSize("gc_icon_bg.png")); // free buffer - if(openingBnr) + if (openingBnr) free(openingBnr); return newBanner; diff --git a/source/banner/OpeningBNR.hpp b/source/banner/OpeningBNR.hpp index 3c25a8b1..f18e46bd 100644 --- a/source/banner/OpeningBNR.hpp +++ b/source/banner/OpeningBNR.hpp @@ -29,17 +29,17 @@ distribution. typedef struct _GC_OpeningBnr { - u32 magic; // BNR1 or BNR2 + u32 magic; // BNR1 or BNR2 u8 pad[0x1C]; - u8 tpl_data[0x1800]; // 96x32 pixel format GX_TF_RGB5A3 + u8 tpl_data[0x1800]; // 96x32 pixel format GX_TF_RGB5A3 struct { - u8 disc_title[0x20]; // Gamename - u8 developer_short[0x20]; // Company/Developer - u8 full_title[0x40]; // Full Game Title - u8 developer[0x40]; // Company/Developer Full name, or description - u8 long_description[0x80]; // Game Description - } description[6]; // 6 only on BNR2 => English, German, French, Spanish, Italian, Dutch ?? + u8 disc_title[0x20]; // Gamename + u8 developer_short[0x20]; // Company/Developer + u8 full_title[0x40]; // Full Game Title + u8 developer[0x40]; // Company/Developer Full name, or description + u8 long_description[0x80]; // Game Description + } description[6]; // 6 only on BNR2 => English, German, French, Spanish, Italian, Dutch ?? } GC_OpeningBnr; typedef struct _IMETHeader @@ -51,8 +51,8 @@ typedef struct _IMETHeader u32 bannerSize; u32 soundSize; u32 flag1; - u16 names[10][42]; // 10 languages (thanks dkosmari for the info) - u16 zeroes_2[7*42]; // padding for 7 more languages (thanks dkosmari for the info) + u16 names[10][42]; // 10 languages (thanks dkosmari for the info) + u16 zeroes_2[7 * 42]; // padding for 7 more languages (thanks dkosmari for the info) u8 crypto[16]; } __attribute__((packed)) IMETHeader; @@ -77,8 +77,8 @@ typedef struct _U8Entry { struct { - u32 fileType :8; - u32 nameOffset :24; + u32 fileType : 8; + u32 nameOffset : 24; }; u32 fileOffset; union @@ -86,49 +86,63 @@ typedef struct _U8Entry u32 fileLength; u32 numEntries; }; -} __attribute__( ( packed ) ) U8Entry; +} __attribute__((packed)) U8Entry; - -static inline const char * u8Filename(const U8Entry *fst, int i) +static inline const char *u8Filename(const U8Entry *fst, int i) { - return (char *) (fst + fst[0].numEntries) + fst[i].nameOffset; + return (char *)(fst + fst[0].numEntries) + fst[i].nameOffset; } class OpeningBNR { - public: - OpeningBNR(); - ~OpeningBNR(); - bool Load(const discHdr * header); - bool LoadWiiBanner(const discHdr * header); - bool LoadChannelBanner(const discHdr *header); - CustomBanner *CreateGCBanner(const discHdr * header); - CustomBanner *CreateGCIcon(const discHdr * header); +public: + OpeningBNR(); + ~OpeningBNR(); + bool Load(const discHdr *header); + bool LoadWiiBanner(const discHdr *header); + bool LoadChannelBanner(const discHdr *header); + CustomBanner *CreateGCBanner(const discHdr *header); + CustomBanner *CreateGCIcon(const discHdr *header); - const u8 * Get() const { return (const u8*) imetHdr; } - u32 GetSize() const { return filesize; } + const u8 *Get() const { return (const u8 *)imetHdr; } + u32 GetSize() const { return filesize; } - bool LoadCachedBNR(const char *id); - void WriteCachedBNR(const char *id, const u8 *buffer, u32 size); + bool LoadCachedBNR(const char *id); + 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); } - private: - u8 *LoadGCBNR(const discHdr * header, u32 *len = 0); - IMETHeader *imetHdr; - u32 filesize; - char gameID[7]; + const u16 *GetIMETTitle(int 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; + u32 filesize; + char gameID[7]; }; class BNRInstance : public OpeningBNR { - public: - static BNRInstance * Instance() { if(!instance) instance = new BNRInstance; return instance; } - static void DestroyInstance() { delete instance; instance = NULL; } - private: - BNRInstance() { } - ~BNRInstance() { } - static BNRInstance * instance; +public: + static BNRInstance *Instance() + { + if (!instance) + instance = new BNRInstance; + return instance; + } + static void DestroyInstance() + { + delete instance; + instance = NULL; + } + +private: + BNRInstance() {} + ~BNRInstance() {} + static BNRInstance *instance; }; #endif diff --git a/source/banner/Pane.cpp b/source/banner/Pane.cpp index 84139607..8f170fbd 100644 --- a/source/banner/Pane.cpp +++ b/source/banner/Pane.cpp @@ -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 diff --git a/source/banner/Pane.h b/source/banner/Pane.h index b0374bfe..3ab4c4f3 100644 --- a/source/banner/Pane.h +++ b/source/banner/Pane.h @@ -108,7 +108,8 @@ public: bool GetWidescren() const { return ((header->flags & (1 << FLAG_WIDESCREEN)) != 0); } - Pane* FindPane(const std::string& name); // recursive + Pane* FindPane(const std::string& name); // recursive + Pane* FindPanePartial(const std::string& name, int len); // recursive PaneList panes; diff --git a/source/prompts/BannerWindow.cpp b/source/prompts/BannerWindow.cpp index 702b8004..e1d934a2 100644 --- a/source/prompts/BannerWindow.cpp +++ b/source/prompts/BannerWindow.cpp @@ -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,12 +272,19 @@ BannerWindow::BannerWindow(GameBrowseMenu *m, struct discHdr *header) Append(btnRight); } - bannerFrame.SetButtonBText(tr("Start")); + 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)) { - bannerFrame.SetButtonAText(tr("Settings")); + if (strcmp(Settings.db_language, "KO") != 0) + bannerFrame.SetButtonAText(tr("Settings")); Append(settingsBtn); if(Settings.bannerFavIcon != BANNER_FAVICON_OFF) for(int i = 0; i < FAVORITE_STARS; ++i) @@ -267,12 +292,26 @@ BannerWindow::BannerWindow(GameBrowseMenu *m, struct discHdr *header) } else { - bannerFrame.SetButtonAText(tr("Back")); - backBtn->SetPosition(-120, 175); + 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(); diff --git a/source/prompts/BannerWindow.hpp b/source/prompts/BannerWindow.hpp index ba77bd33..d8e0ae9d 100644 --- a/source/prompts/BannerWindow.hpp +++ b/source/prompts/BannerWindow.hpp @@ -90,6 +90,11 @@ class BannerWindow : public GuiWindow GuiText * playcntTxt; + GuiText * startBtnTxt; + GuiText * backBtnTxt; + GuiText * settingsBtnTxt; + GuiText * titleName; + GuiButton * startBtn; GuiButton * backBtn; GuiButton * settingsBtn;