mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-06 03:58:02 +08:00
Display appropriate size units.
This commit is contained in:
parent
ca6913d2ef
commit
22ddf40394
@ -470,3 +470,36 @@ Result util_close_archive(FS_Archive archive) {
|
||||
|
||||
return FSUSER_CloseArchive(archive);
|
||||
}
|
||||
|
||||
double util_get_display_size(u64 size) {
|
||||
double s = size;
|
||||
if(s > 1024) {
|
||||
s /= 1024;
|
||||
}
|
||||
|
||||
if(s > 1024) {
|
||||
s /= 1024;
|
||||
}
|
||||
|
||||
if(s > 1024) {
|
||||
s /= 1024;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
const char* util_get_display_size_units(u64 size) {
|
||||
if(size > 1024 * 1024 * 1024) {
|
||||
return "GiB";
|
||||
}
|
||||
|
||||
if(size > 1024 * 1024) {
|
||||
return "MiB";
|
||||
}
|
||||
|
||||
if(size > 1024) {
|
||||
return "KiB";
|
||||
}
|
||||
|
||||
return "B";
|
||||
}
|
@ -69,4 +69,7 @@ void util_set_3dsx_path(const char* path);
|
||||
|
||||
Result util_open_archive(FS_Archive* archive, FS_ArchiveID id, FS_Path path);
|
||||
Result util_ref_archive(FS_Archive archive);
|
||||
Result util_close_archive(FS_Archive archive);
|
||||
Result util_close_archive(FS_Archive archive);
|
||||
|
||||
double util_get_display_size(u64 size);
|
||||
const char* util_get_display_size_units(u64 size);
|
@ -141,7 +141,7 @@ static void action_export_twl_save_update(ui_view* view, void* data, float* prog
|
||||
}
|
||||
|
||||
*progress = exportData->exportInfo.currTotal != 0 ? (float) ((double) exportData->exportInfo.currProcessed / (double) exportData->exportInfo.currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%.2f MiB / %.2f MiB", exportData->exportInfo.currProcessed / 1024.0f / 1024.0f, exportData->exportInfo.currTotal / 1024.0f / 1024.0f);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%.2f %s / %.2f %s", util_get_display_size(exportData->exportInfo.currProcessed), util_get_display_size_units(exportData->exportInfo.currProcessed), util_get_display_size(exportData->exportInfo.currTotal), util_get_display_size_units(exportData->exportInfo.currTotal));
|
||||
}
|
||||
|
||||
static void action_export_twl_save_onresponse(ui_view* view, void* data, bool response) {
|
||||
|
@ -127,7 +127,7 @@ static void action_import_twl_save_update(ui_view* view, void* data, float* prog
|
||||
}
|
||||
|
||||
*progress = importData->importInfo.currTotal != 0 ? (float) ((double) importData->importInfo.currProcessed / (double) importData->importInfo.currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%.2f MiB / %.2f MiB", importData->importInfo.currProcessed / 1024.0f / 1024.0f, importData->importInfo.currTotal / 1024.0f / 1024.0f);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%.2f %s / %.2f %s", util_get_display_size(importData->importInfo.currProcessed), util_get_display_size_units(importData->importInfo.currProcessed), util_get_display_size(importData->importInfo.currTotal), util_get_display_size_units(importData->importInfo.currTotal));
|
||||
}
|
||||
|
||||
static void action_import_twl_save_onresponse(ui_view* view, void* data, bool response) {
|
||||
|
@ -246,7 +246,7 @@ static void action_install_cdn_update(ui_view* view, void* data, float* progress
|
||||
}
|
||||
|
||||
*progress = installData->installInfo.currTotal != 0 ? (float) ((double) installData->installInfo.currProcessed / (double) installData->installInfo.currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f MiB / %.2f MiB", installData->installInfo.processed, installData->installInfo.total, installData->installInfo.currProcessed / 1024.0 / 1024.0, installData->installInfo.currTotal / 1024.0 / 1024.0);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f %s / %.2f %s", installData->installInfo.processed, installData->installInfo.total, util_get_display_size(installData->installInfo.currProcessed), util_get_display_size_units(installData->installInfo.currProcessed), util_get_display_size(installData->installInfo.currTotal), util_get_display_size_units(installData->installInfo.currTotal));
|
||||
}
|
||||
|
||||
void action_install_cdn_noprompt(volatile bool* done, ticket_info* info, bool finishedPrompt) {
|
||||
|
@ -229,7 +229,7 @@ static void action_install_cias_update(ui_view* view, void* data, float* progres
|
||||
}
|
||||
|
||||
*progress = installData->installInfo.currTotal != 0 ? (float) ((double) installData->installInfo.currProcessed / (double) installData->installInfo.currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f MiB / %.2f MiB", installData->installInfo.processed, installData->installInfo.total, installData->installInfo.currProcessed / 1024.0 / 1024.0, installData->installInfo.currTotal / 1024.0 / 1024.0);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f %s / %.2f %s", installData->installInfo.processed, installData->installInfo.total, util_get_display_size(installData->installInfo.currProcessed), util_get_display_size_units(installData->installInfo.currProcessed), util_get_display_size(installData->installInfo.currTotal), util_get_display_size_units(installData->installInfo.currTotal));
|
||||
}
|
||||
|
||||
static void action_install_cias_onresponse(ui_view* view, void* data, bool response) {
|
||||
|
@ -202,7 +202,7 @@ static void action_install_tickets_update(ui_view* view, void* data, float* prog
|
||||
}
|
||||
|
||||
*progress = installData->installInfo.currTotal != 0 ? (float) ((double) installData->installInfo.currProcessed / (double) installData->installInfo.currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f MiB / %.2f MiB", installData->installInfo.processed, installData->installInfo.total, installData->installInfo.currProcessed / 1024.0 / 1024.0, installData->installInfo.currTotal / 1024.0 / 1024.0);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f %s / %.2f %s", installData->installInfo.processed, installData->installInfo.total, util_get_display_size(installData->installInfo.currProcessed), util_get_display_size_units(installData->installInfo.currProcessed), util_get_display_size(installData->installInfo.currTotal), util_get_display_size_units(installData->installInfo.currTotal));
|
||||
}
|
||||
|
||||
static void action_install_tickets_cdn_check_onresponse(ui_view* view, void* data, bool response) {
|
||||
|
@ -250,7 +250,7 @@ static void action_paste_files_update(ui_view* view, void* data, float* progress
|
||||
}
|
||||
|
||||
*progress = pasteData->pasteInfo.currTotal != 0 ? (float) ((double) pasteData->pasteInfo.currProcessed / (double) pasteData->pasteInfo.currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f MiB / %.2f MiB", pasteData->pasteInfo.processed, pasteData->pasteInfo.total, pasteData->pasteInfo.currProcessed / 1024.0 / 1024.0, pasteData->pasteInfo.currTotal / 1024.0 / 1024.0);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f %s / %.2f %s", pasteData->pasteInfo.processed, pasteData->pasteInfo.total, util_get_display_size(pasteData->pasteInfo.currProcessed), util_get_display_size_units(pasteData->pasteInfo.currProcessed), util_get_display_size(pasteData->pasteInfo.currTotal), util_get_display_size_units(pasteData->pasteInfo.currTotal));
|
||||
}
|
||||
|
||||
static void action_paste_files_onresponse(ui_view* view, void* data, bool response) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "../prompt.h"
|
||||
#include "../ui.h"
|
||||
#include "../../core/screen.h"
|
||||
#include "../../core/util.h"
|
||||
|
||||
static Result dumpnand_is_src_directory(void* data, u32 index, bool* isDirectory) {
|
||||
*isDirectory = false;
|
||||
@ -95,7 +96,7 @@ static void dumpnand_update(ui_view* view, void* data, float* progress, char* te
|
||||
}
|
||||
|
||||
*progress = dumpData->currTotal != 0 ? (float) ((double) dumpData->currProcessed / (double) dumpData->currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%.2f MiB / %.2f MiB", dumpData->currProcessed / 1024.0f / 1024.0f, dumpData->currTotal / 1024.0f / 1024.0f);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%.2f %s / %.2f %s", util_get_display_size(dumpData->currProcessed), util_get_display_size_units(dumpData->currProcessed), util_get_display_size(dumpData->currTotal), util_get_display_size_units(dumpData->currTotal));
|
||||
}
|
||||
|
||||
static void dumpnand_onresponse(ui_view* view, void* data, bool response) {
|
||||
|
@ -259,7 +259,7 @@ static void networkinstall_install_update(ui_view* view, void* data, float* prog
|
||||
}
|
||||
|
||||
*progress = networkInstallData->installInfo.currTotal != 0 ? (float) ((double) networkInstallData->installInfo.currProcessed / (double) networkInstallData->installInfo.currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f MiB / %.2f MiB", networkInstallData->installInfo.processed, networkInstallData->installInfo.total, networkInstallData->installInfo.currProcessed / 1024.0 / 1024.0, networkInstallData->installInfo.currTotal / 1024.0 / 1024.0);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f %s / %.2f %s", networkInstallData->installInfo.processed, networkInstallData->installInfo.total, util_get_display_size(networkInstallData->installInfo.currProcessed), util_get_display_size_units(networkInstallData->installInfo.currProcessed), util_get_display_size(networkInstallData->installInfo.currTotal), util_get_display_size_units(networkInstallData->installInfo.currTotal));
|
||||
}
|
||||
|
||||
static void networkinstall_cdn_check_onresponse(ui_view* view, void* data, bool response) {
|
||||
|
@ -259,7 +259,7 @@ static void qrinstall_install_update(ui_view* view, void* data, float* progress,
|
||||
}
|
||||
|
||||
*progress = qrInstallData->installInfo.currTotal != 0 ? (float) ((double) qrInstallData->installInfo.currProcessed / (double) qrInstallData->installInfo.currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f MiB / %.2f MiB", qrInstallData->installInfo.processed, qrInstallData->installInfo.total, qrInstallData->installInfo.currProcessed / 1024.0 / 1024.0, qrInstallData->installInfo.currTotal / 1024.0 / 1024.0);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f %s / %.2f %s", qrInstallData->installInfo.processed, qrInstallData->installInfo.total, util_get_display_size(qrInstallData->installInfo.currProcessed), util_get_display_size_units(qrInstallData->installInfo.currProcessed), util_get_display_size(qrInstallData->installInfo.currTotal), util_get_display_size_units(qrInstallData->installInfo.currTotal));
|
||||
}
|
||||
|
||||
static void qrinstall_cdn_check_onresponse(ui_view* view, void* data, bool response) {
|
||||
|
@ -171,7 +171,7 @@ static void update_install_update(ui_view* view, void* data, float* progress, ch
|
||||
}
|
||||
|
||||
*progress = updateData->installInfo.currTotal != 0 ? (float) ((double) updateData->installInfo.currProcessed / (double) updateData->installInfo.currTotal) : 0;
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%.2f MiB / %.2f MiB", updateData->installInfo.currProcessed / 1024.0f / 1024.0f, updateData->installInfo.currTotal / 1024.0f / 1024.0f);
|
||||
snprintf(text, PROGRESS_TEXT_MAX, "%.2f %s / %.2f %s", util_get_display_size(updateData->installInfo.currProcessed), util_get_display_size_units(updateData->installInfo.currProcessed), util_get_display_size(updateData->installInfo.currTotal), util_get_display_size_units(updateData->installInfo.currTotal));
|
||||
}
|
||||
|
||||
static void update_check_update(ui_view* view, void* data, float* progress, char* text) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "ui.h"
|
||||
#include "section/task/task.h"
|
||||
#include "../core/screen.h"
|
||||
#include "../core/util.h"
|
||||
|
||||
#define MAX_UI_VIEWS 16
|
||||
|
||||
@ -168,7 +169,8 @@ static void ui_draw_top(ui_view* ui) {
|
||||
currBuffer += strlen(currBuffer);
|
||||
}
|
||||
|
||||
snprintf(currBuffer, sizeof(buffer) - (currBuffer - buffer), "SD: %.1f MiB", ((u64) resource.freeClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0);
|
||||
u64 size = (u64) resource.freeClusters * (u64) resource.clusterSize;
|
||||
snprintf(currBuffer, sizeof(buffer) - (currBuffer - buffer), "SD: %.1f %s", util_get_display_size(size), util_get_display_size_units(size));
|
||||
currBuffer += strlen(currBuffer);
|
||||
}
|
||||
|
||||
@ -178,7 +180,8 @@ static void ui_draw_top(ui_view* ui) {
|
||||
currBuffer += strlen(currBuffer);
|
||||
}
|
||||
|
||||
snprintf(currBuffer, sizeof(buffer) - (currBuffer - buffer), "CTR NAND: %.1f MiB", ((u64) resource.freeClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0);
|
||||
u64 size = (u64) resource.freeClusters * (u64) resource.clusterSize;
|
||||
snprintf(currBuffer, sizeof(buffer) - (currBuffer - buffer), "CTR NAND: %.1f %s", util_get_display_size(size), util_get_display_size_units(size));
|
||||
currBuffer += strlen(currBuffer);
|
||||
}
|
||||
|
||||
@ -188,7 +191,8 @@ static void ui_draw_top(ui_view* ui) {
|
||||
currBuffer += strlen(currBuffer);
|
||||
}
|
||||
|
||||
snprintf(currBuffer, sizeof(buffer) - (currBuffer - buffer), "TWL NAND: %.1f MiB", ((u64) resource.freeClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0);
|
||||
u64 size = (u64) resource.freeClusters * (u64) resource.clusterSize;
|
||||
snprintf(currBuffer, sizeof(buffer) - (currBuffer - buffer), "TWL NAND: %.1f %s", util_get_display_size(size), util_get_display_size_units(size));
|
||||
currBuffer += strlen(currBuffer);
|
||||
}
|
||||
|
||||
@ -198,7 +202,8 @@ static void ui_draw_top(ui_view* ui) {
|
||||
currBuffer += strlen(currBuffer);
|
||||
}
|
||||
|
||||
snprintf(currBuffer, sizeof(buffer) - (currBuffer - buffer), "TWL Photo: %.1f MiB", ((u64) resource.freeClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0);
|
||||
u64 size = (u64) resource.freeClusters * (u64) resource.clusterSize;
|
||||
snprintf(currBuffer, sizeof(buffer) - (currBuffer - buffer), "TWL Photo: %.1f %s", util_get_display_size(size), util_get_display_size_units(size));
|
||||
currBuffer += strlen(currBuffer);
|
||||
}
|
||||
|
||||
@ -366,7 +371,7 @@ void ui_draw_file_info(ui_view* view, void* data, float x1, float y1, float x2,
|
||||
}
|
||||
|
||||
if(!info->isDirectory) {
|
||||
infoTextPos += snprintf(infoText + infoTextPos, sizeof(infoText) - infoTextPos, "Size: %.2f MiB\n", info->size / 1024.0 / 1024.0);
|
||||
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) {
|
||||
if(info->ciaInfo.hasMeta) {
|
||||
@ -418,10 +423,10 @@ void ui_draw_file_info(ui_view* view, void* data, float x1, float y1, float x2,
|
||||
infoTextPos += snprintf(infoText + infoTextPos, sizeof(infoText) - infoTextPos,
|
||||
"Title ID: %016llX\n"
|
||||
"Version: %hu\n"
|
||||
"Installed Size: %.2f MiB",
|
||||
"Installed Size: %.2f %s",
|
||||
info->ciaInfo.titleId,
|
||||
info->ciaInfo.version,
|
||||
info->ciaInfo.installedSize / 1024.0 / 1024.0);
|
||||
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);
|
||||
}
|
||||
@ -544,12 +549,12 @@ 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"
|
||||
"Installed Size: %.2f MiB",
|
||||
"Installed Size: %.2f %s",
|
||||
info->titleId,
|
||||
info->mediaType == MEDIATYPE_NAND ? "NAND" : info->mediaType == MEDIATYPE_SD ? "SD" : "Game Card",
|
||||
info->version,
|
||||
info->productCode,
|
||||
info->installedSize / 1024.0 / 1024.0);
|
||||
util_get_display_size(info->installedSize), util_get_display_size_units(info->installedSize));
|
||||
|
||||
float infoWidth;
|
||||
screen_get_string_size(&infoWidth, NULL, infoText, 0.5f, 0.5f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user