mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-08-31 00:39:50 +08:00
Update ticket use status after CDN installation.
This commit is contained in:
parent
c004695469
commit
4bada77420
@ -527,14 +527,14 @@ Result util_close_archive(FS_Archive archive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* util_get_display_eta(u32 seconds) {
|
const char* util_get_display_eta(u32 seconds) {
|
||||||
static char disp[9];
|
static char disp[12];
|
||||||
|
|
||||||
u8 hours = seconds / 3600;
|
u8 hours = seconds / 3600;
|
||||||
seconds -= hours * 3600;
|
seconds -= hours * 3600;
|
||||||
u8 minutes = seconds / 60;
|
u8 minutes = seconds / 60;
|
||||||
seconds -= minutes* 60;
|
seconds -= minutes* 60;
|
||||||
|
|
||||||
snprintf(disp, 9, "%02u:%02u:%02u", hours, minutes, (u8) seconds);
|
snprintf(disp, 12, "%02u:%02u:%02u", hours, minutes, (u8) seconds);
|
||||||
return disp;
|
return disp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define CONTENTS_MAX 256
|
#define CONTENTS_MAX 256
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
list_item* item;
|
||||||
ticket_info* ticket;
|
ticket_info* ticket;
|
||||||
volatile bool* done;
|
volatile bool* done;
|
||||||
bool finishedPrompt;
|
bool finishedPrompt;
|
||||||
@ -220,6 +221,10 @@ static void action_install_cdn_update(ui_view* view, void* data, float* progress
|
|||||||
|
|
||||||
if(R_SUCCEEDED(installData->installInfo.result) && R_SUCCEEDED(res)) {
|
if(R_SUCCEEDED(installData->installInfo.result) && R_SUCCEEDED(res)) {
|
||||||
if(installData->finishedPrompt) {
|
if(installData->finishedPrompt) {
|
||||||
|
if(installData->item != NULL) {
|
||||||
|
task_populate_tickets_update_use(installData->item);
|
||||||
|
}
|
||||||
|
|
||||||
prompt_display_notify("Success", "Install finished.", COLOR_TEXT, installData->ticket, ui_draw_ticket_info, NULL);
|
prompt_display_notify("Success", "Install finished.", COLOR_TEXT, installData->ticket, ui_draw_ticket_info, NULL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -291,7 +296,7 @@ static void action_install_cdn_version_onresponse(ui_view* view, void* data, Swk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void action_install_cdn_noprompt(volatile bool* done, ticket_info* info, bool finishedPrompt, bool promptVersion) {
|
void action_install_cdn_noprompt_internal(volatile bool* done, ticket_info* info, bool finishedPrompt, bool promptVersion, list_item* item) {
|
||||||
install_cdn_data* data = (install_cdn_data*) calloc(1, sizeof(install_cdn_data));
|
install_cdn_data* data = (install_cdn_data*) calloc(1, sizeof(install_cdn_data));
|
||||||
if(data == NULL) {
|
if(data == NULL) {
|
||||||
error_display(NULL, NULL, "Failed to allocate install CDN data.");
|
error_display(NULL, NULL, "Failed to allocate install CDN data.");
|
||||||
@ -299,6 +304,7 @@ void action_install_cdn_noprompt(volatile bool* done, ticket_info* info, bool fi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data->item = item;
|
||||||
data->ticket = info;
|
data->ticket = info;
|
||||||
data->done = done;
|
data->done = done;
|
||||||
data->finishedPrompt = finishedPrompt;
|
data->finishedPrompt = finishedPrompt;
|
||||||
@ -349,18 +355,24 @@ void action_install_cdn_noprompt(volatile bool* done, ticket_info* info, bool fi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void action_install_cdn_noprompt(volatile bool* done, ticket_info* info, bool finishedPrompt, bool promptVersion) {
|
||||||
|
action_install_cdn_noprompt_internal(done, info, finishedPrompt, promptVersion, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
#define CDN_PROMPT_DEFAULT_VERSION 0
|
#define CDN_PROMPT_DEFAULT_VERSION 0
|
||||||
#define CDN_PROMPT_SELECT_VERSION 1
|
#define CDN_PROMPT_SELECT_VERSION 1
|
||||||
#define CDN_PROMPT_NO 2
|
#define CDN_PROMPT_NO 2
|
||||||
|
|
||||||
static void action_install_cdn_onresponse(ui_view* view, void* data, u32 response) {
|
static void action_install_cdn_onresponse(ui_view* view, void* data, u32 response) {
|
||||||
if(response != CDN_PROMPT_NO) {
|
if(response != CDN_PROMPT_NO) {
|
||||||
action_install_cdn_noprompt(NULL, (ticket_info*) data, true, response == CDN_PROMPT_SELECT_VERSION);
|
list_item* item = (list_item*) data;
|
||||||
|
|
||||||
|
action_install_cdn_noprompt_internal(NULL, (ticket_info*) item->data, true, response == CDN_PROMPT_SELECT_VERSION, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void action_install_cdn(linked_list* items, list_item* selected) {
|
void action_install_cdn(linked_list* items, list_item* selected) {
|
||||||
static const char* options[3] = {"Default\nVersion", "Select\nVersion", "No"};
|
static const char* options[3] = {"Default\nVersion", "Select\nVersion", "No"};
|
||||||
static u32 optionButtons[3] = {KEY_A, KEY_X, KEY_B};
|
static u32 optionButtons[3] = {KEY_A, KEY_X, KEY_B};
|
||||||
prompt_display_multi_choice("Confirmation", "Install the selected title from the CDN?", COLOR_TEXT, options, optionButtons, 3, selected->data, ui_draw_ticket_info, action_install_cdn_onresponse);
|
prompt_display_multi_choice("Confirmation", "Install the selected title from the CDN?", COLOR_TEXT, options, optionButtons, 3, selected, ui_draw_ticket_info, action_install_cdn_onresponse);
|
||||||
}
|
}
|
@ -18,6 +18,26 @@ static int task_populate_tickets_compare_ids(const void* e1, const void* e2) {
|
|||||||
return id1 > id2 ? 1 : id1 < id2 ? -1 : 0;
|
return id1 > id2 ? 1 : id1 < id2 ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void task_populate_tickets_update_use(list_item* item) {
|
||||||
|
if(item == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ticket_info* info = (ticket_info*) item->data;
|
||||||
|
|
||||||
|
info->inUse = false;
|
||||||
|
|
||||||
|
AM_TitleEntry entry;
|
||||||
|
for(FS_MediaType mediaType = MEDIATYPE_NAND; mediaType != MEDIATYPE_GAME_CARD; mediaType++) {
|
||||||
|
if(R_SUCCEEDED(AM_GetTitleInfo(mediaType, 1, &info->titleId, &entry))) {
|
||||||
|
info->inUse = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
item->color = info->inUse ? COLOR_TICKET_IN_USE : COLOR_TICKET_NOT_IN_USE;
|
||||||
|
}
|
||||||
|
|
||||||
static void task_populate_tickets_thread(void* arg) {
|
static void task_populate_tickets_thread(void* arg) {
|
||||||
populate_tickets_data* data = (populate_tickets_data*) arg;
|
populate_tickets_data* data = (populate_tickets_data*) arg;
|
||||||
|
|
||||||
@ -41,20 +61,12 @@ static void task_populate_tickets_thread(void* arg) {
|
|||||||
ticket_info* ticketInfo = (ticket_info*) calloc(1, sizeof(ticket_info));
|
ticket_info* ticketInfo = (ticket_info*) calloc(1, sizeof(ticket_info));
|
||||||
if(ticketInfo != NULL) {
|
if(ticketInfo != NULL) {
|
||||||
ticketInfo->titleId = ticketIds[i];
|
ticketInfo->titleId = ticketIds[i];
|
||||||
ticketInfo->inUse = false;
|
|
||||||
|
|
||||||
AM_TitleEntry entry;
|
|
||||||
for(FS_MediaType mediaType = MEDIATYPE_NAND; mediaType != MEDIATYPE_GAME_CARD; mediaType++) {
|
|
||||||
if(R_SUCCEEDED(AM_GetTitleInfo(mediaType, 1, &ticketInfo->titleId, &entry))) {
|
|
||||||
ticketInfo->inUse = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(item->name, LIST_ITEM_NAME_MAX, "%016llX", ticketIds[i]);
|
snprintf(item->name, LIST_ITEM_NAME_MAX, "%016llX", ticketIds[i]);
|
||||||
item->color = ticketInfo->inUse ? COLOR_TICKET_IN_USE : COLOR_TICKET_NOT_IN_USE;
|
|
||||||
item->data = ticketInfo;
|
item->data = ticketInfo;
|
||||||
|
|
||||||
|
task_populate_tickets_update_use(item);
|
||||||
|
|
||||||
linked_list_add(data->items, item);
|
linked_list_add(data->items, item);
|
||||||
} else {
|
} else {
|
||||||
free(item);
|
free(item);
|
||||||
|
@ -250,6 +250,7 @@ void task_free_system_save_data(list_item* item);
|
|||||||
void task_clear_system_save_data(linked_list* items);
|
void task_clear_system_save_data(linked_list* items);
|
||||||
Result task_populate_system_save_data(populate_system_save_data_data* data);
|
Result task_populate_system_save_data(populate_system_save_data_data* data);
|
||||||
|
|
||||||
|
void task_populate_tickets_update_use(list_item* item);
|
||||||
void task_free_ticket(list_item* item);
|
void task_free_ticket(list_item* item);
|
||||||
void task_clear_tickets(linked_list* items);
|
void task_clear_tickets(linked_list* items);
|
||||||
Result task_populate_tickets(populate_tickets_data* data);
|
Result task_populate_tickets(populate_tickets_data* data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user