mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-06 03:58:02 +08:00
Display title regions.
This commit is contained in:
parent
81cb06aad7
commit
943418459b
@ -567,4 +567,41 @@ void util_escape_file_name(char* out, const char* in, size_t size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define SMDH_NUM_REGIONS 7
|
||||
#define SMDH_ALL_REGIONS 0x7F
|
||||
|
||||
static const char* regionStrings[SMDH_NUM_REGIONS] = {
|
||||
"Japan",
|
||||
"North America",
|
||||
"Europe",
|
||||
"Australia",
|
||||
"China",
|
||||
"Korea",
|
||||
"Taiwan"
|
||||
};
|
||||
|
||||
void util_smdh_region_to_string(char* out, u32 region, size_t size) {
|
||||
if(out == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(region == 0) {
|
||||
snprintf(out, size, "Unknown");
|
||||
} else if((region & SMDH_ALL_REGIONS) == SMDH_ALL_REGIONS) {
|
||||
snprintf(out, size, "Region Free");
|
||||
} else {
|
||||
size_t pos = 0;
|
||||
|
||||
for(u32 i = 0; i < SMDH_NUM_REGIONS; i++) {
|
||||
if(region & (1 << i)) {
|
||||
if(pos > 0) {
|
||||
pos += snprintf(out + pos, size - pos, ", ");
|
||||
}
|
||||
|
||||
pos += snprintf(out + pos, size - pos, regionStrings[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -76,4 +76,6 @@ Result util_close_archive(FS_Archive archive);
|
||||
double util_get_display_size(u64 size);
|
||||
const char* util_get_display_size_units(u64 size);
|
||||
|
||||
void util_escape_file_name(char* out, const char* in, size_t size);
|
||||
void util_escape_file_name(char* out, const char* in, size_t size);
|
||||
|
||||
void util_smdh_region_to_string(char* out, u32 region, size_t size);
|
@ -61,6 +61,7 @@ static Result task_populate_ext_save_data_from(populate_ext_save_data_data* data
|
||||
utf16_to_utf8((uint8_t*) extSaveDataInfo->meta.shortDescription, smdh->titles[systemLanguage].shortDescription, sizeof(extSaveDataInfo->meta.shortDescription) - 1);
|
||||
utf16_to_utf8((uint8_t*) extSaveDataInfo->meta.longDescription, smdh->titles[systemLanguage].longDescription, sizeof(extSaveDataInfo->meta.longDescription) - 1);
|
||||
utf16_to_utf8((uint8_t*) extSaveDataInfo->meta.publisher, smdh->titles[systemLanguage].publisher, sizeof(extSaveDataInfo->meta.publisher) - 1);
|
||||
extSaveDataInfo->meta.region = smdh->region;
|
||||
extSaveDataInfo->meta.texture = screen_load_texture_tiled_auto(smdh->largeIcon, sizeof(smdh->largeIcon), 48, 48, GPU_RGB565, false);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ Result task_create_file_item(list_item** out, FS_Archive archive, const char* pa
|
||||
utf16_to_utf8((uint8_t*) fileInfo->ciaInfo.meta.shortDescription, smdh->titles[systemLanguage].shortDescription, sizeof(fileInfo->ciaInfo.meta.shortDescription) - 1);
|
||||
utf16_to_utf8((uint8_t*) fileInfo->ciaInfo.meta.longDescription, smdh->titles[systemLanguage].longDescription, sizeof(fileInfo->ciaInfo.meta.longDescription) - 1);
|
||||
utf16_to_utf8((uint8_t*) fileInfo->ciaInfo.meta.publisher, smdh->titles[systemLanguage].publisher, sizeof(fileInfo->ciaInfo.meta.publisher) - 1);
|
||||
fileInfo->ciaInfo.meta.region = smdh->region;
|
||||
fileInfo->ciaInfo.meta.texture = screen_load_texture_tiled_auto(smdh->largeIcon, sizeof(smdh->largeIcon), 48, 48, GPU_RGB565, false);
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ static Result task_populate_titles_add_ctr(populate_titles_data* data, FS_MediaT
|
||||
utf16_to_utf8((uint8_t*) titleInfo->meta.shortDescription, smdh->titles[systemLanguage].shortDescription, sizeof(titleInfo->meta.shortDescription) - 1);
|
||||
utf16_to_utf8((uint8_t*) titleInfo->meta.longDescription, smdh->titles[systemLanguage].longDescription, sizeof(titleInfo->meta.longDescription) - 1);
|
||||
utf16_to_utf8((uint8_t*) titleInfo->meta.publisher, smdh->titles[systemLanguage].publisher, sizeof(titleInfo->meta.publisher) - 1);
|
||||
titleInfo->meta.region = smdh->region;
|
||||
titleInfo->meta.texture = screen_load_texture_tiled_auto(smdh->largeIcon, sizeof(smdh->largeIcon), 48, 48, GPU_RGB565, false);
|
||||
}
|
||||
}
|
||||
@ -111,28 +112,28 @@ static Result task_populate_titles_add_twl(populate_titles_data* data, FS_MediaT
|
||||
u16 version = 0;
|
||||
u64 installedSize = 0;
|
||||
|
||||
u8 header[0x3B4] = {0};
|
||||
Result headerRes = FSUSER_GetLegacyRomHeader(mediaType, titleId, header);
|
||||
|
||||
AM_TitleEntry entry;
|
||||
if(R_SUCCEEDED(res = AM_GetTitleInfo(mediaType, 1, &titleId, &entry))) {
|
||||
realTitleId = titleId;
|
||||
AM_GetTitleProductCode(mediaType, titleId, productCode);
|
||||
version = entry.version;
|
||||
installedSize = entry.size;
|
||||
} else {
|
||||
u8 header[0x3B4] = {0};
|
||||
if(R_SUCCEEDED(res = FSUSER_GetLegacyRomHeader(mediaType, titleId, header))) {
|
||||
memcpy(&realTitleId, &header[0x230], sizeof(u64));
|
||||
memcpy(productCode, header, 0x00C);
|
||||
version = header[0x01E];
|
||||
} else if(R_SUCCEEDED(res = headerRes)) {
|
||||
memcpy(&realTitleId, &header[0x230], sizeof(realTitleId));
|
||||
memcpy(productCode, header, sizeof(productCode));
|
||||
version = header[0x01E];
|
||||
|
||||
u32 size = 0;
|
||||
if((header[0x012] & 0x2) != 0) {
|
||||
memcpy(&size, &header[0x210], sizeof(u32));
|
||||
} else {
|
||||
memcpy(&size, &header[0x080], sizeof(u32));
|
||||
}
|
||||
|
||||
installedSize = size;
|
||||
u32 size = 0;
|
||||
if((header[0x012] & 0x2) != 0) {
|
||||
memcpy(&size, &header[0x210], sizeof(size));
|
||||
} else {
|
||||
memcpy(&size, &header[0x080], sizeof(size));
|
||||
}
|
||||
|
||||
installedSize = size;
|
||||
}
|
||||
|
||||
if(R_SUCCEEDED(res)) {
|
||||
@ -201,6 +202,12 @@ static Result task_populate_titles_add_twl(populate_titles_data* data, FS_MediaT
|
||||
}
|
||||
}
|
||||
|
||||
if(R_SUCCEEDED(headerRes)) {
|
||||
memcpy(&titleInfo->meta.region, &header[0x1B0], sizeof(titleInfo->meta.region));
|
||||
} else {
|
||||
titleInfo->meta.region = 0;
|
||||
}
|
||||
|
||||
titleInfo->meta.texture = screen_load_texture_auto(icon, sizeof(icon), 32, 32, GPU_RGBA5551, false);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ typedef struct meta_info_s {
|
||||
char shortDescription[0x100];
|
||||
char longDescription[0x200];
|
||||
char publisher[0x100];
|
||||
u32 region;
|
||||
u32 texture;
|
||||
} meta_info;
|
||||
|
||||
|
@ -454,16 +454,24 @@ void ui_draw_file_info(ui_view* view, void* data, float x1, float y1, float x2,
|
||||
infoTextPos += snprintf(infoText + infoTextPos, sizeof(infoText) - infoTextPos, "Size: %.2f %s\n", util_get_display_size(info->size), util_get_display_size_units(info->size));
|
||||
|
||||
if(info->isCia) {
|
||||
char regionString[64];
|
||||
|
||||
if(info->ciaInfo.hasMeta) {
|
||||
ui_draw_meta_info(view, &info->ciaInfo.meta, x1, y1, x2, y2);
|
||||
|
||||
util_smdh_region_to_string(regionString, info->ciaInfo.meta.region, sizeof(regionString));
|
||||
} else {
|
||||
snprintf(regionString, sizeof(regionString), "Unknown");
|
||||
}
|
||||
|
||||
infoTextPos += snprintf(infoText + infoTextPos, sizeof(infoText) - infoTextPos,
|
||||
"Title ID: %016llX\n"
|
||||
"Version: %hu (%d.%d.%d)\n"
|
||||
"Region: %s\n"
|
||||
"Installed Size: %.2f %s",
|
||||
info->ciaInfo.titleId,
|
||||
info->ciaInfo.version, (info->ciaInfo.version >> 10) & 0x3F, (info->ciaInfo.version >> 4) & 0x3F, info->ciaInfo.version & 0xF,
|
||||
regionString,
|
||||
util_get_display_size(info->ciaInfo.installedSize), util_get_display_size_units(info->ciaInfo.installedSize));
|
||||
} else if(info->isTicket) {
|
||||
infoTextPos += snprintf(infoText + infoTextPos, sizeof(infoText) - infoTextPos, "Ticket ID: %016llX", info->ticketInfo.titleId);
|
||||
@ -532,8 +540,14 @@ void ui_draw_ticket_info(ui_view* view, void* data, float x1, float y1, float x2
|
||||
void ui_draw_title_info(ui_view* view, void* data, float x1, float y1, float x2, float y2) {
|
||||
title_info* info = (title_info*) data;
|
||||
|
||||
char regionString[64];
|
||||
|
||||
if(info->hasMeta) {
|
||||
ui_draw_meta_info(view, &info->meta, x1, y1, x2, y2);
|
||||
|
||||
util_smdh_region_to_string(regionString, info->meta.region, sizeof(regionString));
|
||||
} else {
|
||||
snprintf(regionString, sizeof(regionString), "Unknown");
|
||||
}
|
||||
|
||||
char infoText[512];
|
||||
@ -543,11 +557,13 @@ void ui_draw_title_info(ui_view* view, void* data, float x1, float y1, float x2,
|
||||
"Media Type: %s\n"
|
||||
"Version: %hu\n"
|
||||
"Product Code: %s\n"
|
||||
"Region: %s\n"
|
||||
"Size: %.2f %s",
|
||||
info->titleId,
|
||||
info->mediaType == MEDIATYPE_NAND ? "NAND" : info->mediaType == MEDIATYPE_SD ? "SD" : "Game Card",
|
||||
info->version,
|
||||
info->productCode,
|
||||
regionString,
|
||||
util_get_display_size(info->installedSize), util_get_display_size_units(info->installedSize));
|
||||
|
||||
float infoWidth;
|
||||
|
Loading…
x
Reference in New Issue
Block a user