mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-26 19:36:38 +08:00
Improve DS banner title parsing.
This commit is contained in:
parent
61724235a2
commit
ddc3d9d002
@ -74,21 +74,38 @@ static Result task_populate_titles_from(populate_titles_data* data, FS_MediaType
|
|||||||
char title[0x100] = {'\0'};
|
char title[0x100] = {'\0'};
|
||||||
utf16_to_utf8((uint8_t*) title, bnr->titles[systemLanguage], 0x100);
|
utf16_to_utf8((uint8_t*) title, bnr->titles[systemLanguage], 0x100);
|
||||||
|
|
||||||
char* nameEnd = strchr(title, '\n');
|
if(strchr(title, '\n') == NULL) {
|
||||||
if(nameEnd != NULL) {
|
size_t len = strlen(title);
|
||||||
char* curr = NULL;
|
strncpy(item->name, title, len);
|
||||||
while((curr = strchr(nameEnd + 1, '\n')) != NULL) {
|
strncpy(titleInfo->smdhInfo.shortDescription, title, len);
|
||||||
*nameEnd = ' ';
|
|
||||||
nameEnd = curr;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
nameEnd = title + strlen(title);
|
char* destinations[] = {titleInfo->smdhInfo.shortDescription, titleInfo->smdhInfo.longDescription, titleInfo->smdhInfo.publisher};
|
||||||
|
int currDest = 0;
|
||||||
|
|
||||||
|
char* last = title;
|
||||||
|
char* curr = NULL;
|
||||||
|
|
||||||
|
while(currDest < 3 && (curr = strchr(last, '\n')) != NULL) {
|
||||||
|
if(currDest == 0) {
|
||||||
|
strncpy(item->name, last, curr - last);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(item->name, title, nameEnd - title);
|
strncpy(destinations[currDest++], last, curr - last);
|
||||||
|
last = curr + 1;
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(titleInfo->smdhInfo.shortDescription, title, nameEnd - title);
|
if(currDest < 3) {
|
||||||
strncpy(titleInfo->smdhInfo.longDescription, nameEnd + 1, strlen(title) - (nameEnd - title) - 1);
|
strncpy(destinations[currDest], last, strlen(title) - (last - title));
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(item->name, title, last - title);
|
||||||
|
int len = strlen(item->name);
|
||||||
|
for(int pos = 0; pos < len; pos++) {
|
||||||
|
if(item->name[pos] == '\n') {
|
||||||
|
item->name[pos] = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u8 icon[32 * 32 * 2];
|
u8 icon[32 * 32 * 2];
|
||||||
for(u32 x = 0; x < 32; x++) {
|
for(u32 x = 0; x < 32; x++) {
|
||||||
@ -213,21 +230,31 @@ static Result task_populate_titles_from(populate_titles_data* data, FS_MediaType
|
|||||||
char title[0x100] = {'\0'};
|
char title[0x100] = {'\0'};
|
||||||
utf16_to_utf8((uint8_t*) title, bnr->titles[systemLanguage], 0x100);
|
utf16_to_utf8((uint8_t*) title, bnr->titles[systemLanguage], 0x100);
|
||||||
|
|
||||||
char* nameEnd = strchr(title, '\n');
|
if(strchr(title, '\n') == NULL) {
|
||||||
if(nameEnd != NULL) {
|
size_t len = strlen(title);
|
||||||
char* curr = NULL;
|
strncpy(item->name, title, len);
|
||||||
while((curr = strchr(nameEnd + 1, '\n')) != NULL) {
|
strncpy(titleInfo->smdhInfo.shortDescription, title, len);
|
||||||
*nameEnd = ' ';
|
|
||||||
nameEnd = curr;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
nameEnd = title + strlen(title);
|
char* destinations[] = {titleInfo->smdhInfo.shortDescription, titleInfo->smdhInfo.longDescription, titleInfo->smdhInfo.publisher};
|
||||||
|
int currDest = 0;
|
||||||
|
|
||||||
|
char* last = title;
|
||||||
|
char* curr = NULL;
|
||||||
|
|
||||||
|
while(currDest < 3 && (curr = strchr(last, '\n')) != NULL) {
|
||||||
|
if(currDest == 0) {
|
||||||
|
strncpy(item->name, last, curr - last);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(item->name, title, nameEnd - title);
|
strncpy(destinations[currDest++], last, curr - last);
|
||||||
|
last = curr + 1;
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(titleInfo->smdhInfo.shortDescription, title, nameEnd - title);
|
strncpy(item->name, title, last - title);
|
||||||
strncpy(titleInfo->smdhInfo.longDescription, nameEnd + 1, strlen(title) - (nameEnd - title) - 1);
|
if(currDest < 3) {
|
||||||
|
strncpy(destinations[currDest], last, strlen(title) - (last - title));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u8 icon[32 * 32 * 2];
|
u8 icon[32 * 32 * 2];
|
||||||
for(u32 x = 0; x < 32; x++) {
|
for(u32 x = 0; x < 32; x++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user