mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-05-31 20:29:16 +08:00
Revert TitleDB 3DSX support (does not work; SMDH ID does not equal 3DSX ID)
This commit is contained in:
parent
3a6d9f3277
commit
6bf2ce54ce
@ -8,7 +8,6 @@
|
||||
#include "../../list.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/util.h"
|
||||
|
||||
static void action_install_titledb_draw_top(ui_view* view, void* data, float x1, float y1, float x2, float y2, u32 index) {
|
||||
ui_draw_titledb_info(view, ((list_item*) data)->data, x1, y1, x2, y2);
|
||||
@ -22,13 +21,7 @@ void action_install_titledb(linked_list* items, list_item* selected) {
|
||||
titledb_info* info = (titledb_info*) selected->data;
|
||||
|
||||
char url[64];
|
||||
snprintf(url, INSTALL_URL_MAX, "https://3ds.titledb.com/v1/%s/%lu/download", info->type == TITLEDB_TYPE_CIA ? "cia" : "tdsx", info->id);
|
||||
snprintf(url, INSTALL_URL_MAX, "https://3ds.titledb.com/v1/cia/%lu/download", info->id);
|
||||
|
||||
char name[FILE_NAME_MAX];
|
||||
util_escape_file_name(name, info->meta.shortDescription, sizeof(name));
|
||||
|
||||
char path3dsx[FILE_PATH_MAX];
|
||||
snprintf(path3dsx, sizeof(path3dsx), "/3ds/%s/%s.3dsx", name, name);
|
||||
|
||||
action_install_url("Install the selected title from TitleDB?", url, path3dsx, selected, action_update_titledb_finished, action_install_titledb_draw_top);
|
||||
action_install_url("Install the selected title from TitleDB?", url, NULL, selected, action_update_titledb_finished, action_install_titledb_draw_top);
|
||||
}
|
@ -17,32 +17,9 @@
|
||||
void task_populate_titledb_update_status(list_item* item) {
|
||||
titledb_info* info = (titledb_info*) item->data;
|
||||
|
||||
if(info->type == TITLEDB_TYPE_CIA) {
|
||||
AM_TitleEntry entry;
|
||||
info->installed = R_SUCCEEDED(AM_GetTitleInfo(util_get_title_destination(info->titleId), 1, &info->titleId, &entry));
|
||||
info->installedVersion = info->installed ? entry.version : (u16) 0;
|
||||
} else if(info->type == TITLEDB_TYPE_3DSX) {
|
||||
info->installed = false;
|
||||
info->installedVersion = 0;
|
||||
|
||||
char name[FILE_NAME_MAX];
|
||||
util_escape_file_name(name, info->meta.shortDescription, sizeof(name));
|
||||
|
||||
char path3dsx[FILE_PATH_MAX];
|
||||
snprintf(path3dsx, sizeof(path3dsx), "/3ds/%s/%s.3dsx", name, name);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(path3dsx);
|
||||
if(fsPath != NULL) {
|
||||
Handle handle = 0;
|
||||
if(R_SUCCEEDED(FSUSER_OpenFileDirectly(&handle, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), *fsPath, FS_OPEN_READ, 0))) {
|
||||
info->installed = true;
|
||||
|
||||
FSFILE_Close(handle);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
}
|
||||
}
|
||||
AM_TitleEntry entry;
|
||||
info->installed = R_SUCCEEDED(AM_GetTitleInfo(util_get_title_destination(info->titleId), 1, &info->titleId, &entry));
|
||||
info->installedVersion = info->installed ? entry.version : (u16) 0;
|
||||
|
||||
if(info->installed) {
|
||||
item->color = COLOR_TITLEDB_INSTALLED;
|
||||
@ -82,11 +59,8 @@ static void task_populate_titledb_thread(void* arg) {
|
||||
u32 maxTextSize = 256 * 1024;
|
||||
char* text = (char*) calloc(sizeof(char), maxTextSize);
|
||||
if(text != NULL) {
|
||||
char url[256];
|
||||
snprintf(url, sizeof(url), "https://api.titledb.com/v1/%sonly=id&only=size&only=updated_at&only=version&only=name_s&only=name_l&only=publisher", data->type == TITLEDB_TYPE_CIA ? "cia?only=titleid&" : "smdh?");
|
||||
|
||||
u32 textSize = 0;
|
||||
if(R_SUCCEEDED(res = task_populate_titledb_download(&textSize, text, maxTextSize, url))) {
|
||||
if(R_SUCCEEDED(res = task_populate_titledb_download(&textSize, text, maxTextSize, "https://api.titledb.com/v1/cia?only=id&only=size&only=updated_at&only=titleid&only=name_s&only=name_l&only=publisher"))) {
|
||||
json_value* json = json_parse(text, textSize);
|
||||
if(json != NULL) {
|
||||
if(json->type == json_array) {
|
||||
@ -105,8 +79,6 @@ static void task_populate_titledb_thread(void* arg) {
|
||||
if(item != NULL) {
|
||||
titledb_info* titledbInfo = (titledb_info*) calloc(1, sizeof(titledb_info));
|
||||
if(titledbInfo != NULL) {
|
||||
titledbInfo->type = data->type;
|
||||
|
||||
for(u32 j = 0; j < val->u.object.length; j++) {
|
||||
char* name = val->u.object.values[j].name;
|
||||
u32 nameLen = val->u.object.values[j].name_length;
|
||||
@ -223,7 +195,7 @@ static void task_populate_titledb_thread(void* arg) {
|
||||
titledb_info* titledbInfo = (titledb_info*) item->data;
|
||||
|
||||
char url[128];
|
||||
snprintf(url, sizeof(url), "https://3ds.titledb.com/v1/%s/%lu/icon_l.bin", data->type == TITLEDB_TYPE_CIA ? "cia" : "smdh", titledbInfo->id);
|
||||
snprintf(url, sizeof(url), "https://3ds.titledb.com/v1/cia/%lu/icon_l.bin", titledbInfo->id);
|
||||
|
||||
u8 icon[0x1200];
|
||||
u32 iconSize = 0;
|
||||
|
@ -71,13 +71,7 @@ typedef struct file_info_s {
|
||||
ticket_info ticketInfo;
|
||||
} file_info;
|
||||
|
||||
typedef enum titledb_type_e {
|
||||
TITLEDB_TYPE_CIA,
|
||||
TITLEDB_TYPE_3DSX
|
||||
} titledb_type;
|
||||
|
||||
typedef struct titledb_info_s {
|
||||
titledb_type type;
|
||||
u32 id;
|
||||
u64 titleId;
|
||||
u16 installedVersion;
|
||||
@ -231,7 +225,6 @@ typedef struct populate_titles_data_s {
|
||||
|
||||
typedef struct populate_titledb_data_s {
|
||||
linked_list* items;
|
||||
titledb_type type;
|
||||
|
||||
volatile bool itemsListed;
|
||||
volatile bool finished;
|
||||
|
@ -12,18 +12,13 @@
|
||||
#include "../../core/linkedlist.h"
|
||||
#include "../../core/screen.h"
|
||||
|
||||
static titledb_type section_cia_type = TITLEDB_TYPE_CIA;
|
||||
static list_item section_cia = {"CIA", COLOR_TEXT, §ion_cia_type};
|
||||
static titledb_type section_3dsx_type = TITLEDB_TYPE_3DSX;
|
||||
static list_item section_3dsx = {"3DSX", COLOR_TEXT, §ion_3dsx_type};
|
||||
|
||||
static list_item action_install = {"Install", COLOR_TEXT, action_install_titledb};
|
||||
static list_item install = {"Install", COLOR_TEXT, action_install_titledb};
|
||||
|
||||
typedef struct {
|
||||
populate_titledb_data populateData;
|
||||
|
||||
bool populated;
|
||||
} titledb_section_data;
|
||||
} titledb_data;
|
||||
|
||||
typedef struct {
|
||||
linked_list* items;
|
||||
@ -60,7 +55,7 @@ static void titledb_action_update(ui_view* view, void* data, linked_list* items,
|
||||
}
|
||||
|
||||
if(linked_list_size(items) == 0) {
|
||||
linked_list_add(items, &action_install);
|
||||
linked_list_add(items, &install);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,8 +73,8 @@ static void titledb_action_open(linked_list* items, list_item* selected) {
|
||||
list_display("TitleDB Action", "A: Select, B: Return", data, titledb_action_update, titledb_action_draw_top);
|
||||
}
|
||||
|
||||
static void titledb_section_draw_top(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected) {
|
||||
titledb_section_data* listData = (titledb_section_data*) data;
|
||||
static void titledb_draw_top(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected) {
|
||||
titledb_data* listData = (titledb_data*) data;
|
||||
|
||||
if(!listData->populateData.itemsListed) {
|
||||
static const char* text = "Loading title list, please wait...\nNOTE: Cancelling may take up to 15 seconds.";
|
||||
@ -93,8 +88,8 @@ static void titledb_section_draw_top(ui_view* view, void* data, float x1, float
|
||||
}
|
||||
}
|
||||
|
||||
static void titledb_section_update(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched) {
|
||||
titledb_section_data* listData = (titledb_section_data*) data;
|
||||
static void titledb_update(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched) {
|
||||
titledb_data* listData = (titledb_data*) data;
|
||||
|
||||
if(hidKeysDown() & KEY_B) {
|
||||
if(!listData->populateData.finished) {
|
||||
@ -142,40 +137,15 @@ static void titledb_section_update(ui_view* view, void* data, linked_list* items
|
||||
}
|
||||
}
|
||||
|
||||
void titledb_section_open(titledb_type type) {
|
||||
titledb_section_data* data = (titledb_section_data*) calloc(1, sizeof(titledb_section_data));
|
||||
void titledb_open() {
|
||||
titledb_data* data = (titledb_data*) calloc(1, sizeof(titledb_data));
|
||||
if(data == NULL) {
|
||||
error_display(NULL, NULL, "Failed to allocate TitleDB section data.");
|
||||
error_display(NULL, NULL, "Failed to allocate TitleDB data.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data->populateData.type = type;
|
||||
|
||||
data->populateData.finished = true;
|
||||
|
||||
list_display("TitleDB.com", "A: Select, B: Return, X: Refresh", data, titledb_section_update, titledb_section_draw_top);
|
||||
}
|
||||
|
||||
static void titledb_update(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched) {
|
||||
if(hidKeysDown() & KEY_B) {
|
||||
ui_pop();
|
||||
list_destroy(view);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(selected != NULL && selected->data != NULL && (selectedTouched || (hidKeysDown() & KEY_A))) {
|
||||
titledb_section_open(*(titledb_type*) selected->data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(linked_list_size(items) == 0) {
|
||||
linked_list_add(items, §ion_cia);
|
||||
linked_list_add(items, §ion_3dsx);
|
||||
}
|
||||
}
|
||||
|
||||
void titledb_open() {
|
||||
list_display("TitleDB.com", "A: Select, B: Return", NULL, titledb_update, NULL);
|
||||
list_display("TitleDB.com", "A: Select, B: Return, X: Refresh", data, titledb_update, titledb_draw_top);
|
||||
}
|
@ -618,23 +618,15 @@ void ui_draw_titledb_info(ui_view* view, void* data, float x1, float y1, float x
|
||||
|
||||
char infoText[512];
|
||||
|
||||
if(info->type == TITLEDB_TYPE_CIA) {
|
||||
snprintf(infoText, sizeof(infoText),
|
||||
"Title ID: %016llX\n"
|
||||
"Installed Version: %hu (%d.%d.%d)\n"
|
||||
"Size: %.2f %s\n"
|
||||
"Updated At: %s %s",
|
||||
info->titleId,
|
||||
info->installedVersion, (info->installedVersion >> 10) & 0x3F, (info->installedVersion >> 4) & 0x3F, info->installedVersion & 0xF,
|
||||
util_get_display_size(info->size), util_get_display_size_units(info->size),
|
||||
updatedDate, updatedTime);
|
||||
} else {
|
||||
snprintf(infoText, sizeof(infoText),
|
||||
"Size: %.2f %s\n"
|
||||
"Updated At: %s %s",
|
||||
util_get_display_size(info->size), util_get_display_size_units(info->size),
|
||||
updatedDate, updatedTime);
|
||||
}
|
||||
snprintf(infoText, sizeof(infoText),
|
||||
"Title ID: %016llX\n"
|
||||
"Installed Version: %hu (%d.%d.%d)\n"
|
||||
"Size: %.2f %s\n"
|
||||
"Updated At: %s %s",
|
||||
info->titleId,
|
||||
info->installedVersion, (info->installedVersion >> 10) & 0x3F, (info->installedVersion >> 4) & 0x3F, info->installedVersion & 0xF,
|
||||
util_get_display_size(info->size), util_get_display_size_units(info->size),
|
||||
updatedDate, updatedTime);
|
||||
|
||||
float infoWidth;
|
||||
screen_get_string_size(&infoWidth, NULL, infoText, 0.5f, 0.5f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user