2021-06-13 07:18:14 +01:00
|
|
|
/*
|
|
|
|
* gamecard_tab.cpp
|
|
|
|
*
|
2024-04-12 10:47:36 +01:00
|
|
|
* Copyright (c) 2020-2024, DarkMatterCore <pabloacurielz@gmail.com>.
|
2021-06-13 07:18:14 +01:00
|
|
|
*
|
|
|
|
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
|
|
|
|
*
|
|
|
|
* nxdumptool is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* nxdumptool is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
#include <core/nxdt_utils.h>
|
|
|
|
#include <views/gamecard_tab.hpp>
|
|
|
|
#include <views/titles_tab.hpp>
|
|
|
|
#include <views/gamecard_image_dump_options_frame.hpp>
|
|
|
|
#include <utils/scope_guard.hpp>
|
|
|
|
|
|
|
|
#define GAMECARD_TAB_TABLE_PROPERTY(name) brls::TableRow *name = properties_table->addRow(brls::TableRowType::BODY, i18n::getStr("gamecard_tab/list/properties_table/" #name))
|
|
|
|
|
|
|
|
#define GAMECARD_TAB_LISTITEM_ELEMENT(name, ...) \
|
|
|
|
brls::ListItem *name = new brls::ListItem(i18n::getStr("gamecard_tab/list/" #name "/label"), i18n::getStr("gamecard_tab/list/" #name "/description", ##__VA_ARGS__)); \
|
|
|
|
this->list->addView(name)
|
2021-06-13 07:18:14 +01:00
|
|
|
|
2021-06-13 20:32:37 +01:00
|
|
|
namespace i18n = brls::i18n; /* For getStr(). */
|
|
|
|
using namespace i18n::literals; /* For _i18n. */
|
2021-06-13 07:18:14 +01:00
|
|
|
|
|
|
|
namespace nxdt::views
|
|
|
|
{
|
2021-08-11 08:17:57 +01:00
|
|
|
GameCardTab::GameCardTab(RootView *root_view) : LayeredErrorFrame("gamecard_tab/error_frame/not_inserted"_i18n), root_view(root_view)
|
2021-06-13 07:18:14 +01:00
|
|
|
{
|
2021-06-21 03:43:40 +01:00
|
|
|
/* Set custom spacing. */
|
|
|
|
this->list->setSpacing(this->list->getSpacing() / 2);
|
|
|
|
this->list->setMarginBottom(20);
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2022-09-12 19:19:10 +01:00
|
|
|
/* Subscribe to the gamecard status event. */
|
2024-05-05 20:42:32 +01:00
|
|
|
this->gc_status_task_sub = this->root_view->RegisterGameCardStatusTaskListener([this](const GameCardStatus& gc_status) {
|
2022-07-27 23:53:52 +01:00
|
|
|
/* Process gamecard status. */
|
|
|
|
this->ProcessGameCardStatus(gc_status);
|
2021-06-13 07:18:14 +01:00
|
|
|
});
|
2022-07-27 23:53:52 +01:00
|
|
|
|
|
|
|
/* Process gamecard status. */
|
|
|
|
this->ProcessGameCardStatus(GameCardStatus_NotInserted);
|
2021-06-13 07:18:14 +01:00
|
|
|
}
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2024-04-19 11:08:44 +01:00
|
|
|
GameCardTab::~GameCardTab()
|
2021-06-20 21:37:31 +01:00
|
|
|
{
|
|
|
|
/* Unregister task listener. */
|
2024-04-30 22:01:42 +01:00
|
|
|
this->root_view->UnregisterGameCardStatusTaskListener(this->gc_status_task_sub);
|
2021-06-20 21:37:31 +01:00
|
|
|
}
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2024-05-05 20:42:32 +01:00
|
|
|
void GameCardTab::ProcessGameCardStatus(const GameCardStatus& gc_status)
|
2022-07-27 23:53:52 +01:00
|
|
|
{
|
2024-05-05 20:42:32 +01:00
|
|
|
LOG_MSG_DEBUG("Processing gamecard status: %u.", gc_status);
|
|
|
|
|
|
|
|
/* Block user inputs. */
|
|
|
|
brls::Application::blockInputs();
|
|
|
|
|
2022-07-27 23:53:52 +01:00
|
|
|
/* Switch to the error layer if gamecard info hasn't been loaded. */
|
|
|
|
if (gc_status < GameCardStatus_InsertedAndInfoLoaded) this->SwitchLayerView(true);
|
|
|
|
|
|
|
|
switch(gc_status)
|
|
|
|
{
|
|
|
|
case GameCardStatus_NotInserted:
|
|
|
|
this->error_frame->SetMessage("gamecard_tab/error_frame/not_inserted"_i18n);
|
|
|
|
break;
|
|
|
|
case GameCardStatus_Processing:
|
|
|
|
this->error_frame->SetMessage("gamecard_tab/error_frame/processing"_i18n);
|
|
|
|
break;
|
|
|
|
case GameCardStatus_NoGameCardPatchEnabled:
|
|
|
|
this->error_frame->SetMessage("gamecard_tab/error_frame/nogc_enabled"_i18n);
|
|
|
|
break;
|
|
|
|
case GameCardStatus_LotusAsicFirmwareUpdateRequired:
|
|
|
|
this->error_frame->SetMessage("gamecard_tab/error_frame/lafw_update_required"_i18n);
|
|
|
|
break;
|
|
|
|
case GameCardStatus_InsertedAndInfoNotLoaded:
|
2024-05-10 11:18:57 +01:00
|
|
|
this->error_frame->SetMessage(i18n::getStr("gamecard_tab/error_frame/info_not_loaded", GITHUB_NEW_ISSUE_URL));
|
2022-07-27 23:53:52 +01:00
|
|
|
break;
|
|
|
|
case GameCardStatus_InsertedAndInfoLoaded:
|
|
|
|
/* Update list and switch to it. */
|
|
|
|
this->PopulateList();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update internal gamecard status. */
|
|
|
|
this->gc_status = gc_status;
|
2024-05-05 20:42:32 +01:00
|
|
|
|
|
|
|
/* Unlock user inputs. */
|
|
|
|
brls::Application::unblockInputs();
|
2022-07-27 23:53:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GameCardTab::PopulateList(void)
|
|
|
|
{
|
|
|
|
bool update_focused_view = this->IsListItemFocused();
|
|
|
|
int focus_stack_index = this->GetFocusStackViewIndex();
|
|
|
|
|
|
|
|
/* Clear list. */
|
|
|
|
this->list->clear();
|
|
|
|
this->list->invalidate(true);
|
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
/* Generate and store raw filenames. */
|
|
|
|
this->GenerateRawFilenames();
|
|
|
|
|
2022-07-27 23:53:52 +01:00
|
|
|
/* Information about how to handle HOS launch errors. */
|
2023-05-24 20:05:34 +01:00
|
|
|
/* TODO: remove this if we ever find a way to fix this issue. */
|
2024-04-12 12:40:50 +01:00
|
|
|
FocusableLabel *launch_error_info = new FocusableLabel(true, false, brls::LabelStyle::DESCRIPTION, "gamecard_tab/list/launch_error_info"_i18n, true);
|
2022-07-27 23:53:52 +01:00
|
|
|
launch_error_info->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
|
|
this->list->addView(launch_error_info);
|
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
/* Add gamecard application metadata information. */
|
|
|
|
this->AddApplicationMetadataItems();
|
|
|
|
|
|
|
|
/* Add gamecard properties table. */
|
|
|
|
this->AddPropertiesTable();
|
|
|
|
|
|
|
|
/* Add ListItem elements. */
|
|
|
|
this->list->addView(new brls::Header("gamecard_tab/list/dump_options"_i18n));
|
|
|
|
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_card_image);
|
|
|
|
|
|
|
|
this->list->addView(new brls::ListItemGroupSpacing(true));
|
|
|
|
|
|
|
|
brls::Label *advanced_disclaimer = new brls::Label(brls::LabelStyle::DESCRIPTION, "gamecard_tab/list/advanced_disclaimer"_i18n, true);
|
|
|
|
advanced_disclaimer->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
|
|
this->list->addView(advanced_disclaimer);
|
|
|
|
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_initial_data);
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_certificate, GAMECARD_CERT_OFFSET / GAMECARD_PAGE_SIZE);
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_card_id_set);
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_card_uid);
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_header, 0);
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_plaintext_cardinfo);
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_specific_data);
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_hfs_partitions);
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(browse_hfs_partitions);
|
|
|
|
GAMECARD_TAB_LISTITEM_ELEMENT(dump_lafw);
|
|
|
|
|
|
|
|
/* Set ListItem callbacks. */
|
|
|
|
dump_card_image->getClickEvent()->subscribe([this](brls::View *view) {
|
|
|
|
/* Display gamecard image dump options. */
|
|
|
|
std::string& raw_filename = (configGetInteger("naming_convention") == TitleNamingConvention_Full ? raw_filename_full : raw_filename_id_only);
|
|
|
|
brls::Application::pushView(new GameCardImageDumpOptionsFrame(this->root_view, raw_filename), brls::ViewAnimation::SLIDE_LEFT);
|
|
|
|
});
|
|
|
|
|
|
|
|
/* Update focus stack, if needed. */
|
|
|
|
if (focus_stack_index > -1) this->UpdateFocusStackViewAtIndex(focus_stack_index, this->GetListFirstFocusableChild());
|
|
|
|
|
|
|
|
/* Switch to the list view. */
|
|
|
|
this->list->invalidate(true);
|
|
|
|
this->SwitchLayerView(false, update_focused_view, focus_stack_index < 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameCardTab::AddApplicationMetadataItems(void)
|
|
|
|
{
|
2024-05-05 20:42:32 +01:00
|
|
|
TitleGameCardApplicationMetadata *gc_app_metadata = nullptr;
|
2024-04-30 22:01:42 +01:00
|
|
|
u32 gc_app_metadata_count = 0;
|
|
|
|
|
2022-07-27 23:53:52 +01:00
|
|
|
/* Retrieve gamecard application metadata. */
|
Add DataTransferTaskFrame and GameCardImageDumpTaskFrame classes
DataTransferTaskFrame is a template class that's derived from brls::AppletFrame, which automatically starts a background task using an internal object belonging to a class derived from DataTransferTask. A DataTransferProgressDisplay view is used to show progress updates. If the background task hits an error, the class takes care of switching to an ErrorFrame view with the corresponding error message.
GameCardImageDumpTaskFrame is a derived class of DataTransferTaskFrame that uses a GameCardImageDumpTask object as its background task. In layman's terms, this provides a way to fully dump gamecard images using the new UI.
DataTransferTaskFrame depends on the newly added is_base_template helper from goneskiing to check if the class for the provided task is derived from DataTransferTask.
Other changes include:
* DataTransferProgressDisplay: rename setProgress() method to SetProgress().
* DataTransferTask: move post-task-execution code into its own new private method, PostExecutionCallback(), and update both OnCancelled() and OnPostExecute() callbacks to invoke it.
* DataTransferTask: update OnProgressUpdate() to allow sending a last progress update to all event subscribers even if the background task was cancelled.
* DataTransferTask: update OnProgressUpdate() to allow sending a first progress update if no data has been transferred but the total transfer size is already known.
* DataTransferTask: update OnProgressUpdate() to avoid calculating the ETA if the speed isn't greater than 0.
* DumpOptionsFrame: remove UpdateOutputStorages() method.
* DumpOptionsFrame: update class to use the cached output storage value from our RootView.
* DumpOptionsFrame: add GenerateOutputStoragesVector() method, which is used to avoid setting dummy options while initializing the output storages SelectListItem.
* DumpOptionsFrame: update UMS task callback to add the rest of the leftover logic from UpdateOutputStorages().
* DumpOptionsFrame: update RegisterButtonListener() to use a wrapper callback around the user-provided callback to check if the USB host was selected as the output storage but no USB host connection is available.
* ErrorFrame: use const references for all input string arguments.
* FileWriter: fix a localization stirng name typo.
* FileWriter: fix an exception that was previously being thrown by a fmt::format() call because of a wrong format specifier.
* FocusableItem: add a static assert to check if the provided ViewType is derived from brls::View.
* gamecard: redefine global gamecard status variable as an atomic unsigned 8-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call gamecardGetStatus().
* GameCardImageDumpOptionsFrame: define GAMECARD_TOGGLE_ITEM macro, which is used to initialize all ToggleListItem elements from the view.
* GameCardImageDumpOptionsFrame: update button callback to push a GameCardImageDumpTaskFrame view onto the borealis stack.
* GameCardImageDumpTask: move class into its own header and module files.
* GameCardImageDumpTask: update class to also take in the checksum lookup method (not yet implemented).
* GameCardImageDumpTask: update class to send its first progress update as soon as the gamecard image size is known.
* GameCardImageDumpTask: update class to avoid returning a string if the task was cancelled -- DataTransferTaskFrame offers logic to display the appropiate cancel message on its own.
* GameCardTab: update PopulateList() method to display the new version information available in TitleGameCardApplicationMetadataEntry elements as part of the generated TitlesTabItem objects.
* i18n: add new localization strings.
* OptionsTab: update background task callback logic to handle task cancellation, reflecting the changes made to DataTransferTask.
* OptionsTab: reflect changes made to DataTransferProgressDisplay.
* RootView: cache the currently selected output storage value at all times, which is propagated throughout different parts of the UI. Getter and setter helpers have been added to operate with this value.
* RootView: add GetUsbHostSpeed() helper, which can be used by child views to retrieve the USB host speed on demand.
* RootView: update UMS task callback to automatically reset the cached output storage value back to the SD card if a UMS device was previously selected.
* title: define TitleGameCardApplicationMetadataEntry struct, which also holds version-specific information retrieved from the gamecard titles.
* title: refactor titleGetGameCardApplicationMetadataEntries() to return a dynamically allocated array of TitleGameCardApplicationMetadataEntry elements.
* usb: redefine global endpoint max packet size variable as an atomic unsigned 16-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call usbIsReady().
* UsbHostTask: add GetUsbHostSpeed() method.
2024-04-29 14:26:12 +01:00
|
|
|
gc_app_metadata = titleGetGameCardApplicationMetadataEntries(&gc_app_metadata_count);
|
2024-04-30 22:01:42 +01:00
|
|
|
if (!gc_app_metadata) return;
|
2022-07-27 23:53:52 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
ON_SCOPE_EXIT { free(gc_app_metadata); };
|
2023-11-03 01:22:47 +00:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
/* Display the applications that are part of the inserted gamecard. */
|
|
|
|
this->list->addView(new brls::Header("gamecard_tab/list/user_titles/header"_i18n));
|
|
|
|
|
|
|
|
/* Add information about how to work with individual user titles. */
|
2024-05-10 11:18:57 +01:00
|
|
|
brls::Label *user_titles_info = new brls::Label(brls::LabelStyle::DESCRIPTION, i18n::getStr("gamecard_tab/list/user_titles/info", \
|
2024-04-30 22:01:42 +01:00
|
|
|
"root_view/tabs/user_titles"_i18n), true);
|
|
|
|
user_titles_info->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
|
|
this->list->addView(user_titles_info);
|
|
|
|
|
|
|
|
/* Add gamecard application metadata items. */
|
|
|
|
for(u32 i = 0; i < gc_app_metadata_count; i++)
|
|
|
|
{
|
2024-05-05 20:42:32 +01:00
|
|
|
TitleGameCardApplicationMetadata *cur_gc_app_metadata = &(gc_app_metadata[i]);
|
Add DataTransferTaskFrame and GameCardImageDumpTaskFrame classes
DataTransferTaskFrame is a template class that's derived from brls::AppletFrame, which automatically starts a background task using an internal object belonging to a class derived from DataTransferTask. A DataTransferProgressDisplay view is used to show progress updates. If the background task hits an error, the class takes care of switching to an ErrorFrame view with the corresponding error message.
GameCardImageDumpTaskFrame is a derived class of DataTransferTaskFrame that uses a GameCardImageDumpTask object as its background task. In layman's terms, this provides a way to fully dump gamecard images using the new UI.
DataTransferTaskFrame depends on the newly added is_base_template helper from goneskiing to check if the class for the provided task is derived from DataTransferTask.
Other changes include:
* DataTransferProgressDisplay: rename setProgress() method to SetProgress().
* DataTransferTask: move post-task-execution code into its own new private method, PostExecutionCallback(), and update both OnCancelled() and OnPostExecute() callbacks to invoke it.
* DataTransferTask: update OnProgressUpdate() to allow sending a last progress update to all event subscribers even if the background task was cancelled.
* DataTransferTask: update OnProgressUpdate() to allow sending a first progress update if no data has been transferred but the total transfer size is already known.
* DataTransferTask: update OnProgressUpdate() to avoid calculating the ETA if the speed isn't greater than 0.
* DumpOptionsFrame: remove UpdateOutputStorages() method.
* DumpOptionsFrame: update class to use the cached output storage value from our RootView.
* DumpOptionsFrame: add GenerateOutputStoragesVector() method, which is used to avoid setting dummy options while initializing the output storages SelectListItem.
* DumpOptionsFrame: update UMS task callback to add the rest of the leftover logic from UpdateOutputStorages().
* DumpOptionsFrame: update RegisterButtonListener() to use a wrapper callback around the user-provided callback to check if the USB host was selected as the output storage but no USB host connection is available.
* ErrorFrame: use const references for all input string arguments.
* FileWriter: fix a localization stirng name typo.
* FileWriter: fix an exception that was previously being thrown by a fmt::format() call because of a wrong format specifier.
* FocusableItem: add a static assert to check if the provided ViewType is derived from brls::View.
* gamecard: redefine global gamecard status variable as an atomic unsigned 8-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call gamecardGetStatus().
* GameCardImageDumpOptionsFrame: define GAMECARD_TOGGLE_ITEM macro, which is used to initialize all ToggleListItem elements from the view.
* GameCardImageDumpOptionsFrame: update button callback to push a GameCardImageDumpTaskFrame view onto the borealis stack.
* GameCardImageDumpTask: move class into its own header and module files.
* GameCardImageDumpTask: update class to also take in the checksum lookup method (not yet implemented).
* GameCardImageDumpTask: update class to send its first progress update as soon as the gamecard image size is known.
* GameCardImageDumpTask: update class to avoid returning a string if the task was cancelled -- DataTransferTaskFrame offers logic to display the appropiate cancel message on its own.
* GameCardTab: update PopulateList() method to display the new version information available in TitleGameCardApplicationMetadataEntry elements as part of the generated TitlesTabItem objects.
* i18n: add new localization strings.
* OptionsTab: update background task callback logic to handle task cancellation, reflecting the changes made to DataTransferTask.
* OptionsTab: reflect changes made to DataTransferProgressDisplay.
* RootView: cache the currently selected output storage value at all times, which is propagated throughout different parts of the UI. Getter and setter helpers have been added to operate with this value.
* RootView: add GetUsbHostSpeed() helper, which can be used by child views to retrieve the USB host speed on demand.
* RootView: update UMS task callback to automatically reset the cached output storage value back to the SD card if a UMS device was previously selected.
* title: define TitleGameCardApplicationMetadataEntry struct, which also holds version-specific information retrieved from the gamecard titles.
* title: refactor titleGetGameCardApplicationMetadataEntries() to return a dynamically allocated array of TitleGameCardApplicationMetadataEntry elements.
* usb: redefine global endpoint max packet size variable as an atomic unsigned 16-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call usbIsReady().
* UsbHostTask: add GetUsbHostSpeed() method.
2024-04-29 14:26:12 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
/* Create item. */
|
|
|
|
TitlesTabItem *title = new TitlesTabItem(cur_gc_app_metadata->app_metadata, false, false);
|
Add DataTransferTaskFrame and GameCardImageDumpTaskFrame classes
DataTransferTaskFrame is a template class that's derived from brls::AppletFrame, which automatically starts a background task using an internal object belonging to a class derived from DataTransferTask. A DataTransferProgressDisplay view is used to show progress updates. If the background task hits an error, the class takes care of switching to an ErrorFrame view with the corresponding error message.
GameCardImageDumpTaskFrame is a derived class of DataTransferTaskFrame that uses a GameCardImageDumpTask object as its background task. In layman's terms, this provides a way to fully dump gamecard images using the new UI.
DataTransferTaskFrame depends on the newly added is_base_template helper from goneskiing to check if the class for the provided task is derived from DataTransferTask.
Other changes include:
* DataTransferProgressDisplay: rename setProgress() method to SetProgress().
* DataTransferTask: move post-task-execution code into its own new private method, PostExecutionCallback(), and update both OnCancelled() and OnPostExecute() callbacks to invoke it.
* DataTransferTask: update OnProgressUpdate() to allow sending a last progress update to all event subscribers even if the background task was cancelled.
* DataTransferTask: update OnProgressUpdate() to allow sending a first progress update if no data has been transferred but the total transfer size is already known.
* DataTransferTask: update OnProgressUpdate() to avoid calculating the ETA if the speed isn't greater than 0.
* DumpOptionsFrame: remove UpdateOutputStorages() method.
* DumpOptionsFrame: update class to use the cached output storage value from our RootView.
* DumpOptionsFrame: add GenerateOutputStoragesVector() method, which is used to avoid setting dummy options while initializing the output storages SelectListItem.
* DumpOptionsFrame: update UMS task callback to add the rest of the leftover logic from UpdateOutputStorages().
* DumpOptionsFrame: update RegisterButtonListener() to use a wrapper callback around the user-provided callback to check if the USB host was selected as the output storage but no USB host connection is available.
* ErrorFrame: use const references for all input string arguments.
* FileWriter: fix a localization stirng name typo.
* FileWriter: fix an exception that was previously being thrown by a fmt::format() call because of a wrong format specifier.
* FocusableItem: add a static assert to check if the provided ViewType is derived from brls::View.
* gamecard: redefine global gamecard status variable as an atomic unsigned 8-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call gamecardGetStatus().
* GameCardImageDumpOptionsFrame: define GAMECARD_TOGGLE_ITEM macro, which is used to initialize all ToggleListItem elements from the view.
* GameCardImageDumpOptionsFrame: update button callback to push a GameCardImageDumpTaskFrame view onto the borealis stack.
* GameCardImageDumpTask: move class into its own header and module files.
* GameCardImageDumpTask: update class to also take in the checksum lookup method (not yet implemented).
* GameCardImageDumpTask: update class to send its first progress update as soon as the gamecard image size is known.
* GameCardImageDumpTask: update class to avoid returning a string if the task was cancelled -- DataTransferTaskFrame offers logic to display the appropiate cancel message on its own.
* GameCardTab: update PopulateList() method to display the new version information available in TitleGameCardApplicationMetadataEntry elements as part of the generated TitlesTabItem objects.
* i18n: add new localization strings.
* OptionsTab: update background task callback logic to handle task cancellation, reflecting the changes made to DataTransferTask.
* OptionsTab: reflect changes made to DataTransferProgressDisplay.
* RootView: cache the currently selected output storage value at all times, which is propagated throughout different parts of the UI. Getter and setter helpers have been added to operate with this value.
* RootView: add GetUsbHostSpeed() helper, which can be used by child views to retrieve the USB host speed on demand.
* RootView: update UMS task callback to automatically reset the cached output storage value back to the SD card if a UMS device was previously selected.
* title: define TitleGameCardApplicationMetadataEntry struct, which also holds version-specific information retrieved from the gamecard titles.
* title: refactor titleGetGameCardApplicationMetadataEntries() to return a dynamically allocated array of TitleGameCardApplicationMetadataEntry elements.
* usb: redefine global endpoint max packet size variable as an atomic unsigned 16-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call usbIsReady().
* UsbHostTask: add GetUsbHostSpeed() method.
2024-04-29 14:26:12 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
/* Unregister A button action. */
|
|
|
|
title->unregisterAction(brls::Key::A);
|
Add DataTransferTaskFrame and GameCardImageDumpTaskFrame classes
DataTransferTaskFrame is a template class that's derived from brls::AppletFrame, which automatically starts a background task using an internal object belonging to a class derived from DataTransferTask. A DataTransferProgressDisplay view is used to show progress updates. If the background task hits an error, the class takes care of switching to an ErrorFrame view with the corresponding error message.
GameCardImageDumpTaskFrame is a derived class of DataTransferTaskFrame that uses a GameCardImageDumpTask object as its background task. In layman's terms, this provides a way to fully dump gamecard images using the new UI.
DataTransferTaskFrame depends on the newly added is_base_template helper from goneskiing to check if the class for the provided task is derived from DataTransferTask.
Other changes include:
* DataTransferProgressDisplay: rename setProgress() method to SetProgress().
* DataTransferTask: move post-task-execution code into its own new private method, PostExecutionCallback(), and update both OnCancelled() and OnPostExecute() callbacks to invoke it.
* DataTransferTask: update OnProgressUpdate() to allow sending a last progress update to all event subscribers even if the background task was cancelled.
* DataTransferTask: update OnProgressUpdate() to allow sending a first progress update if no data has been transferred but the total transfer size is already known.
* DataTransferTask: update OnProgressUpdate() to avoid calculating the ETA if the speed isn't greater than 0.
* DumpOptionsFrame: remove UpdateOutputStorages() method.
* DumpOptionsFrame: update class to use the cached output storage value from our RootView.
* DumpOptionsFrame: add GenerateOutputStoragesVector() method, which is used to avoid setting dummy options while initializing the output storages SelectListItem.
* DumpOptionsFrame: update UMS task callback to add the rest of the leftover logic from UpdateOutputStorages().
* DumpOptionsFrame: update RegisterButtonListener() to use a wrapper callback around the user-provided callback to check if the USB host was selected as the output storage but no USB host connection is available.
* ErrorFrame: use const references for all input string arguments.
* FileWriter: fix a localization stirng name typo.
* FileWriter: fix an exception that was previously being thrown by a fmt::format() call because of a wrong format specifier.
* FocusableItem: add a static assert to check if the provided ViewType is derived from brls::View.
* gamecard: redefine global gamecard status variable as an atomic unsigned 8-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call gamecardGetStatus().
* GameCardImageDumpOptionsFrame: define GAMECARD_TOGGLE_ITEM macro, which is used to initialize all ToggleListItem elements from the view.
* GameCardImageDumpOptionsFrame: update button callback to push a GameCardImageDumpTaskFrame view onto the borealis stack.
* GameCardImageDumpTask: move class into its own header and module files.
* GameCardImageDumpTask: update class to also take in the checksum lookup method (not yet implemented).
* GameCardImageDumpTask: update class to send its first progress update as soon as the gamecard image size is known.
* GameCardImageDumpTask: update class to avoid returning a string if the task was cancelled -- DataTransferTaskFrame offers logic to display the appropiate cancel message on its own.
* GameCardTab: update PopulateList() method to display the new version information available in TitleGameCardApplicationMetadataEntry elements as part of the generated TitlesTabItem objects.
* i18n: add new localization strings.
* OptionsTab: update background task callback logic to handle task cancellation, reflecting the changes made to DataTransferTask.
* OptionsTab: reflect changes made to DataTransferProgressDisplay.
* RootView: cache the currently selected output storage value at all times, which is propagated throughout different parts of the UI. Getter and setter helpers have been added to operate with this value.
* RootView: add GetUsbHostSpeed() helper, which can be used by child views to retrieve the USB host speed on demand.
* RootView: update UMS task callback to automatically reset the cached output storage value back to the SD card if a UMS device was previously selected.
* title: define TitleGameCardApplicationMetadataEntry struct, which also holds version-specific information retrieved from the gamecard titles.
* title: refactor titleGetGameCardApplicationMetadataEntries() to return a dynamically allocated array of TitleGameCardApplicationMetadataEntry elements.
* usb: redefine global endpoint max packet size variable as an atomic unsigned 16-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call usbIsReady().
* UsbHostTask: add GetUsbHostSpeed() method.
2024-04-29 14:26:12 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
/* Set version information as the item sublabel instead of the title author. */
|
|
|
|
std::string sublabel = fmt::format("v{}", cur_gc_app_metadata->version.value);
|
Add DataTransferTaskFrame and GameCardImageDumpTaskFrame classes
DataTransferTaskFrame is a template class that's derived from brls::AppletFrame, which automatically starts a background task using an internal object belonging to a class derived from DataTransferTask. A DataTransferProgressDisplay view is used to show progress updates. If the background task hits an error, the class takes care of switching to an ErrorFrame view with the corresponding error message.
GameCardImageDumpTaskFrame is a derived class of DataTransferTaskFrame that uses a GameCardImageDumpTask object as its background task. In layman's terms, this provides a way to fully dump gamecard images using the new UI.
DataTransferTaskFrame depends on the newly added is_base_template helper from goneskiing to check if the class for the provided task is derived from DataTransferTask.
Other changes include:
* DataTransferProgressDisplay: rename setProgress() method to SetProgress().
* DataTransferTask: move post-task-execution code into its own new private method, PostExecutionCallback(), and update both OnCancelled() and OnPostExecute() callbacks to invoke it.
* DataTransferTask: update OnProgressUpdate() to allow sending a last progress update to all event subscribers even if the background task was cancelled.
* DataTransferTask: update OnProgressUpdate() to allow sending a first progress update if no data has been transferred but the total transfer size is already known.
* DataTransferTask: update OnProgressUpdate() to avoid calculating the ETA if the speed isn't greater than 0.
* DumpOptionsFrame: remove UpdateOutputStorages() method.
* DumpOptionsFrame: update class to use the cached output storage value from our RootView.
* DumpOptionsFrame: add GenerateOutputStoragesVector() method, which is used to avoid setting dummy options while initializing the output storages SelectListItem.
* DumpOptionsFrame: update UMS task callback to add the rest of the leftover logic from UpdateOutputStorages().
* DumpOptionsFrame: update RegisterButtonListener() to use a wrapper callback around the user-provided callback to check if the USB host was selected as the output storage but no USB host connection is available.
* ErrorFrame: use const references for all input string arguments.
* FileWriter: fix a localization stirng name typo.
* FileWriter: fix an exception that was previously being thrown by a fmt::format() call because of a wrong format specifier.
* FocusableItem: add a static assert to check if the provided ViewType is derived from brls::View.
* gamecard: redefine global gamecard status variable as an atomic unsigned 8-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call gamecardGetStatus().
* GameCardImageDumpOptionsFrame: define GAMECARD_TOGGLE_ITEM macro, which is used to initialize all ToggleListItem elements from the view.
* GameCardImageDumpOptionsFrame: update button callback to push a GameCardImageDumpTaskFrame view onto the borealis stack.
* GameCardImageDumpTask: move class into its own header and module files.
* GameCardImageDumpTask: update class to also take in the checksum lookup method (not yet implemented).
* GameCardImageDumpTask: update class to send its first progress update as soon as the gamecard image size is known.
* GameCardImageDumpTask: update class to avoid returning a string if the task was cancelled -- DataTransferTaskFrame offers logic to display the appropiate cancel message on its own.
* GameCardTab: update PopulateList() method to display the new version information available in TitleGameCardApplicationMetadataEntry elements as part of the generated TitlesTabItem objects.
* i18n: add new localization strings.
* OptionsTab: update background task callback logic to handle task cancellation, reflecting the changes made to DataTransferTask.
* OptionsTab: reflect changes made to DataTransferProgressDisplay.
* RootView: cache the currently selected output storage value at all times, which is propagated throughout different parts of the UI. Getter and setter helpers have been added to operate with this value.
* RootView: add GetUsbHostSpeed() helper, which can be used by child views to retrieve the USB host speed on demand.
* RootView: update UMS task callback to automatically reset the cached output storage value back to the SD card if a UMS device was previously selected.
* title: define TitleGameCardApplicationMetadataEntry struct, which also holds version-specific information retrieved from the gamecard titles.
* title: refactor titleGetGameCardApplicationMetadataEntries() to return a dynamically allocated array of TitleGameCardApplicationMetadataEntry elements.
* usb: redefine global endpoint max packet size variable as an atomic unsigned 16-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call usbIsReady().
* UsbHostTask: add GetUsbHostSpeed() method.
2024-04-29 14:26:12 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
if (cur_gc_app_metadata->display_version[0]) sublabel += fmt::format(" ({})", cur_gc_app_metadata->display_version);
|
Add DataTransferTaskFrame and GameCardImageDumpTaskFrame classes
DataTransferTaskFrame is a template class that's derived from brls::AppletFrame, which automatically starts a background task using an internal object belonging to a class derived from DataTransferTask. A DataTransferProgressDisplay view is used to show progress updates. If the background task hits an error, the class takes care of switching to an ErrorFrame view with the corresponding error message.
GameCardImageDumpTaskFrame is a derived class of DataTransferTaskFrame that uses a GameCardImageDumpTask object as its background task. In layman's terms, this provides a way to fully dump gamecard images using the new UI.
DataTransferTaskFrame depends on the newly added is_base_template helper from goneskiing to check if the class for the provided task is derived from DataTransferTask.
Other changes include:
* DataTransferProgressDisplay: rename setProgress() method to SetProgress().
* DataTransferTask: move post-task-execution code into its own new private method, PostExecutionCallback(), and update both OnCancelled() and OnPostExecute() callbacks to invoke it.
* DataTransferTask: update OnProgressUpdate() to allow sending a last progress update to all event subscribers even if the background task was cancelled.
* DataTransferTask: update OnProgressUpdate() to allow sending a first progress update if no data has been transferred but the total transfer size is already known.
* DataTransferTask: update OnProgressUpdate() to avoid calculating the ETA if the speed isn't greater than 0.
* DumpOptionsFrame: remove UpdateOutputStorages() method.
* DumpOptionsFrame: update class to use the cached output storage value from our RootView.
* DumpOptionsFrame: add GenerateOutputStoragesVector() method, which is used to avoid setting dummy options while initializing the output storages SelectListItem.
* DumpOptionsFrame: update UMS task callback to add the rest of the leftover logic from UpdateOutputStorages().
* DumpOptionsFrame: update RegisterButtonListener() to use a wrapper callback around the user-provided callback to check if the USB host was selected as the output storage but no USB host connection is available.
* ErrorFrame: use const references for all input string arguments.
* FileWriter: fix a localization stirng name typo.
* FileWriter: fix an exception that was previously being thrown by a fmt::format() call because of a wrong format specifier.
* FocusableItem: add a static assert to check if the provided ViewType is derived from brls::View.
* gamecard: redefine global gamecard status variable as an atomic unsigned 8-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call gamecardGetStatus().
* GameCardImageDumpOptionsFrame: define GAMECARD_TOGGLE_ITEM macro, which is used to initialize all ToggleListItem elements from the view.
* GameCardImageDumpOptionsFrame: update button callback to push a GameCardImageDumpTaskFrame view onto the borealis stack.
* GameCardImageDumpTask: move class into its own header and module files.
* GameCardImageDumpTask: update class to also take in the checksum lookup method (not yet implemented).
* GameCardImageDumpTask: update class to send its first progress update as soon as the gamecard image size is known.
* GameCardImageDumpTask: update class to avoid returning a string if the task was cancelled -- DataTransferTaskFrame offers logic to display the appropiate cancel message on its own.
* GameCardTab: update PopulateList() method to display the new version information available in TitleGameCardApplicationMetadataEntry elements as part of the generated TitlesTabItem objects.
* i18n: add new localization strings.
* OptionsTab: update background task callback logic to handle task cancellation, reflecting the changes made to DataTransferTask.
* OptionsTab: reflect changes made to DataTransferProgressDisplay.
* RootView: cache the currently selected output storage value at all times, which is propagated throughout different parts of the UI. Getter and setter helpers have been added to operate with this value.
* RootView: add GetUsbHostSpeed() helper, which can be used by child views to retrieve the USB host speed on demand.
* RootView: update UMS task callback to automatically reset the cached output storage value back to the SD card if a UMS device was previously selected.
* title: define TitleGameCardApplicationMetadataEntry struct, which also holds version-specific information retrieved from the gamecard titles.
* title: refactor titleGetGameCardApplicationMetadataEntries() to return a dynamically allocated array of TitleGameCardApplicationMetadataEntry elements.
* usb: redefine global endpoint max packet size variable as an atomic unsigned 16-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call usbIsReady().
* UsbHostTask: add GetUsbHostSpeed() method.
2024-04-29 14:26:12 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
if (cur_gc_app_metadata->dlc_count > 1)
|
|
|
|
{
|
|
|
|
sublabel += fmt::format(" (+{} DLCs)", cur_gc_app_metadata->dlc_count);
|
|
|
|
} else
|
|
|
|
if (cur_gc_app_metadata->dlc_count == 1)
|
|
|
|
{
|
|
|
|
sublabel += " (+1 DLC)";
|
2022-07-27 23:53:52 +01:00
|
|
|
}
|
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
title->setSubLabel(sublabel);
|
|
|
|
|
|
|
|
/* Add view to item list. */
|
|
|
|
this->list->addView(title);
|
2022-07-27 23:53:52 +01:00
|
|
|
}
|
2024-04-30 22:01:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GameCardTab::AddPropertiesTable(void)
|
|
|
|
{
|
|
|
|
GameCardHeader card_header{};
|
|
|
|
GameCardInfo card_info{};
|
|
|
|
FsGameCardIdSet card_id_set_data{};
|
|
|
|
|
|
|
|
/* Get gamecard data. */
|
|
|
|
gamecardGetHeader(&card_header);
|
|
|
|
gamecardGetPlaintextCardInfoArea(&card_info);
|
|
|
|
gamecardGetCardIdSet(&card_id_set_data);
|
2022-07-27 23:53:52 +01:00
|
|
|
|
|
|
|
/* Populate gamecard properties table. */
|
|
|
|
this->list->addView(new brls::Header("gamecard_tab/list/properties_table/header"_i18n));
|
|
|
|
|
2024-04-12 12:40:50 +01:00
|
|
|
FocusableTable *properties_table = new FocusableTable(true, false);
|
2024-04-30 22:01:42 +01:00
|
|
|
GAMECARD_TAB_TABLE_PROPERTY(capacity);
|
|
|
|
GAMECARD_TAB_TABLE_PROPERTY(total_size);
|
|
|
|
GAMECARD_TAB_TABLE_PROPERTY(trimmed_size);
|
|
|
|
GAMECARD_TAB_TABLE_PROPERTY(update_version);
|
|
|
|
GAMECARD_TAB_TABLE_PROPERTY(lafw_version);
|
|
|
|
GAMECARD_TAB_TABLE_PROPERTY(sdk_version);
|
|
|
|
GAMECARD_TAB_TABLE_PROPERTY(compatibility_type);
|
|
|
|
GAMECARD_TAB_TABLE_PROPERTY(package_id);
|
|
|
|
GAMECARD_TAB_TABLE_PROPERTY(card_id_set);
|
|
|
|
|
|
|
|
/* Set table row values. */
|
2022-07-27 23:53:52 +01:00
|
|
|
capacity->setValue(this->GetFormattedSizeString(&gamecardGetRomCapacity));
|
|
|
|
total_size->setValue(this->GetFormattedSizeString(&gamecardGetTotalSize));
|
|
|
|
trimmed_size->setValue(this->GetFormattedSizeString(&gamecardGetTrimmedSize));
|
|
|
|
|
2023-05-24 20:05:34 +01:00
|
|
|
const SystemVersion upp_version = card_info.upp_version.system_version;
|
|
|
|
|
2023-05-26 10:01:34 +01:00
|
|
|
if (upp_version.major == 0 && upp_version.minor == 0)
|
2023-05-24 20:05:34 +01:00
|
|
|
{
|
2024-04-30 22:01:42 +01:00
|
|
|
/* Nintendo didn't start matching SystemVersion fields to the system version displayed in the Settings menu until HOS 3.0.0. */
|
|
|
|
/* So we need to manually handle those exceptions. */
|
|
|
|
std::string upp_version_display{};
|
2023-05-24 20:05:34 +01:00
|
|
|
|
2023-05-26 10:01:34 +01:00
|
|
|
switch(upp_version.micro)
|
2023-05-24 20:05:34 +01:00
|
|
|
{
|
|
|
|
case 0: /* v450 / 0.0.0-450 */
|
|
|
|
upp_version_display = "1.0.0";
|
|
|
|
break;
|
|
|
|
case 1: /* v65796 / 0.0.1-260 */
|
|
|
|
upp_version_display = "2.0.0";
|
|
|
|
break;
|
|
|
|
case 2: /* v131162 / 0.0.2-90 */
|
|
|
|
upp_version_display = "2.1.0";
|
|
|
|
break;
|
|
|
|
case 3: /* v196628 / 0.0.3-20 */
|
|
|
|
upp_version_display = "2.2.0";
|
|
|
|
break;
|
|
|
|
case 4: /* v262164 / 0.0.4-20 */
|
|
|
|
upp_version_display = "2.3.0";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (upp_version_display != "")
|
|
|
|
{
|
2024-04-30 22:01:42 +01:00
|
|
|
update_version->setValue(fmt::format("{} ({}.{}.{}-{}) (v{})", upp_version_display, upp_version.major, upp_version.minor, upp_version.micro,
|
2023-05-26 10:01:34 +01:00
|
|
|
upp_version.relstep, upp_version.value));
|
2023-05-24 20:05:34 +01:00
|
|
|
} else {
|
2024-04-30 22:01:42 +01:00
|
|
|
update_version->setValue(fmt::format("{}.{}.{}-{} (v{})", upp_version.major, upp_version.minor, upp_version.micro,
|
2023-05-26 10:01:34 +01:00
|
|
|
upp_version.relstep, upp_version.value));
|
2023-05-24 20:05:34 +01:00
|
|
|
}
|
|
|
|
} else {
|
2024-04-30 22:01:42 +01:00
|
|
|
update_version->setValue(fmt::format("{}.{}.{}-{}.{} (v{})", upp_version.major, upp_version.minor, upp_version.micro,
|
2023-05-24 20:05:34 +01:00
|
|
|
upp_version.major_relstep, upp_version.minor_relstep, upp_version.value));
|
|
|
|
}
|
2022-07-27 23:53:52 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
const u64 fw_version = card_info.fw_version;
|
2022-07-27 23:53:52 +01:00
|
|
|
lafw_version->setValue(fmt::format("{} ({})", fw_version, fw_version >= GameCardFwVersion_Count ? "generic/unknown"_i18n : gamecardGetRequiredHosVersionString(fw_version)));
|
|
|
|
|
2023-05-24 20:05:34 +01:00
|
|
|
const SdkAddOnVersion fw_mode = card_info.fw_mode.sdk_addon_version;
|
|
|
|
sdk_version->setValue(fmt::format("{}.{}.{}-{} (v{})", fw_mode.major, fw_mode.minor, fw_mode.micro, fw_mode.relstep, fw_mode.value));
|
2022-07-27 23:53:52 +01:00
|
|
|
|
|
|
|
u8 compat_type = card_info.compatibility_type;
|
2024-04-30 22:01:42 +01:00
|
|
|
compatibility_type->setValue(fmt::format("{} ({})",
|
|
|
|
compat_type >= GameCardCompatibilityType_Count ? "generic/unknown"_i18n : gamecardGetCompatibilityTypeString(compat_type), compat_type));
|
2022-07-27 23:53:52 +01:00
|
|
|
|
2023-11-03 01:22:47 +00:00
|
|
|
char package_id_str[0x11] = {0};
|
|
|
|
utilsGenerateHexString(package_id_str, sizeof(package_id_str), card_header.package_id, sizeof(card_header.package_id), true);
|
|
|
|
package_id->setValue(std::string(package_id_str));
|
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
card_id_set->setValue(this->GetCardIdSetString(card_id_set_data));
|
2023-05-24 20:05:34 +01:00
|
|
|
|
2022-07-27 23:53:52 +01:00
|
|
|
this->list->addView(properties_table);
|
2024-04-30 22:01:42 +01:00
|
|
|
}
|
2022-07-27 23:53:52 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
void GameCardTab::GenerateRawFilenames(void)
|
|
|
|
{
|
|
|
|
char *raw_filename = nullptr;
|
2022-07-27 23:53:52 +01:00
|
|
|
|
2024-04-15 12:47:50 +01:00
|
|
|
raw_filename = titleGenerateGameCardFileName(TitleNamingConvention_Full, TitleFileNameIllegalCharReplaceType_None);
|
|
|
|
this->raw_filename_full = std::string(raw_filename);
|
|
|
|
if (raw_filename) free(raw_filename);
|
|
|
|
|
|
|
|
raw_filename = titleGenerateGameCardFileName(TitleNamingConvention_IdAndVersionOnly, TitleFileNameIllegalCharReplaceType_None);
|
|
|
|
this->raw_filename_id_only = std::string(raw_filename);
|
|
|
|
if (raw_filename) free(raw_filename);
|
|
|
|
|
|
|
|
raw_filename = nullptr;
|
2024-04-30 22:01:42 +01:00
|
|
|
}
|
2024-04-15 12:47:50 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
std::string GameCardTab::GetFormattedSizeString(GameCardSizeFunc func)
|
|
|
|
{
|
|
|
|
u64 size = 0;
|
|
|
|
char strbuf[0x40] = {0};
|
2024-04-12 12:40:50 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
func(&size);
|
|
|
|
utilsGenerateFormattedSizeString(static_cast<double>(size), strbuf, sizeof(strbuf));
|
2024-04-12 12:40:50 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
return std::string(strbuf);
|
|
|
|
}
|
2024-04-12 12:40:50 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
std::string GameCardTab::GetCardIdSetString(const FsGameCardIdSet& card_id_set)
|
|
|
|
{
|
|
|
|
char card_id_set_str[0x20] = {0};
|
2022-07-27 23:53:52 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
utilsGenerateHexString(card_id_set_str, sizeof(card_id_set_str), &(card_id_set.id1), sizeof(card_id_set.id1), true);
|
2024-04-12 12:40:50 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
card_id_set_str[8] = ' ';
|
|
|
|
utilsGenerateHexString(card_id_set_str + 9, sizeof(card_id_set_str) - 9, &(card_id_set.id2), sizeof(card_id_set.id2), true);
|
2024-04-12 12:40:50 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
card_id_set_str[17] = ' ';
|
|
|
|
utilsGenerateHexString(card_id_set_str + 18, sizeof(card_id_set_str) - 18, &(card_id_set.id3), sizeof(card_id_set.id3), true);
|
2022-07-27 23:53:52 +01:00
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
return std::string(card_id_set_str);
|
2022-07-27 23:53:52 +01:00
|
|
|
}
|
2021-06-13 07:18:14 +01:00
|
|
|
}
|