1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-25 03:32:10 +00:00

LayeredErrorFrame: use focus stack references

Other changes include:

* Codebase: remove `_i18n` operators from strings used in brls::i18n::getStr() calls.

* GameCardStatusTask: rename first_notification -> skip_notification.
* GameCardStatusTask: fire event before displaying a notification.

* libs: update borealis fork.

* TitlesTab: store application metadata pointer array and size into local variables.
This commit is contained in:
Pablo Curiel 2024-05-10 12:18:57 +02:00
parent d9c8d93180
commit b0ce6fc618
11 changed files with 42 additions and 41 deletions

View file

@ -42,7 +42,7 @@ namespace nxdt::tasks
GameCardStatusEvent gc_status_event;
GameCardStatus cur_gc_status = GameCardStatus_NotInserted;
GameCardStatus prev_gc_status = GameCardStatus_NotInserted;
bool first_notification = true;
bool skip_notification = true;
protected:
void run(retro_time_t current_time) override;

@ -1 +1 @@
Subproject commit 1a69955c64f72a48342abce317a75998ffac3f9d
Subproject commit a4eaaf45824f1407b2a85e02d3ab8e47a83378e3

View file

@ -70,7 +70,7 @@ int main(int argc, char *argv[])
} catch (...) {
std::exception_ptr p = std::current_exception();
LOG_MSG_ERROR("Exception caught! (%s).", p ? p.__cxa_exception_type()->name() : "unknown");
brls::Application::crash(i18n::getStr("generic/exception_caught"_i18n, p ? p.__cxa_exception_type()->name() : "generic/unknown_exception"_i18n));
brls::Application::crash(i18n::getStr("generic/exception_caught", p ? p.__cxa_exception_type()->name() : "generic/unknown_exception"_i18n));
while(brls::Application::mainLoop());
}

View file

@ -29,9 +29,9 @@ namespace nxdt::tasks
{
brls::RepeatingTask::start();
this->first_notification = (gamecardGetStatus() != GameCardStatus_NotInserted);
this->skip_notification = (gamecardGetStatus() != GameCardStatus_NotInserted);
LOG_MSG_DEBUG("Gamecard task started with first_notification = %u.", this->first_notification);
LOG_MSG_DEBUG("Gamecard task started with skip_notification = %u.", this->skip_notification);
}
GameCardStatusTask::~GameCardStatusTask()
@ -48,7 +48,10 @@ namespace nxdt::tasks
{
LOG_MSG_DEBUG("Gamecard status change triggered: %u.", this->cur_gc_status);
if (!this->first_notification)
/* Fire task event. */
this->gc_status_event.fire(this->cur_gc_status);
if (!this->skip_notification)
{
if (this->prev_gc_status == GameCardStatus_NotInserted && this->cur_gc_status == GameCardStatus_Processing)
{
@ -63,14 +66,11 @@ namespace nxdt::tasks
brls::Application::notify("tasks/notifications/gamecard_ejected"_i18n);
}
} else {
this->first_notification = false;
this->skip_notification = false;
}
/* Update previous gamecard status. */
this->prev_gc_status = this->cur_gc_status;
/* Fire task event. */
this->gc_status_event.fire(this->cur_gc_status);
}
}
}

View file

@ -123,7 +123,7 @@ extern "C" {
LOG_MSG_ERROR("*** libnx aborted with error code: 0x%X ***", res);
/* Abort program execution. */
std::string crash_str = (g_borealisInitialized ? i18n::getStr("utils/exception_handler/libnx_abort"_i18n, res) : fmt::format("Fatal error triggered in libnx!\nError code: 0x{:08X}.", res));
std::string crash_str = (g_borealisInitialized ? i18n::getStr("utils/exception_handler/libnx_abort", res) : fmt::format("Fatal error triggered in libnx!\nError code: 0x{:08X}.", res));
nxdt::utils::AbortProgramExecution(crash_str);
}
@ -223,7 +223,7 @@ extern "C" {
#endif /* LOG_LEVEL < LOG_LEVEL_NONE */
/* Abort program execution. */
crash_str = (g_borealisInitialized ? i18n::getStr("utils/exception_handler/exception_triggered"_i18n, error_desc_str, ctx->error_desc) : \
crash_str = (g_borealisInitialized ? i18n::getStr("utils/exception_handler/exception_triggered", error_desc_str, ctx->error_desc) : \
fmt::format("Fatal exception triggered!\nReason: {} (0x{:X}).", error_desc_str, ctx->error_desc));
crash_str += (fmt::format("\nPC: 0x{:X}", ctx->pc.x) + (IS_HB_ADDR(ctx->pc.x) ? fmt::format(" (BASE + 0x{:X}).", ctx->pc.x - info.addr) : "."));
nxdt::utils::AbortProgramExecution(crash_str);

View file

@ -47,17 +47,17 @@ namespace nxdt::views
this->addView(new AboutTabLabel(brls::LabelStyle::CRASH, "about_tab/description"_i18n, true));
/* Copyright. */
brls::Label *copyright = new brls::Label(brls::LabelStyle::DESCRIPTION, i18n::getStr("about_tab/copyright"_i18n, APP_AUTHOR, GITHUB_REPOSITORY_URL), true);
brls::Label *copyright = new brls::Label(brls::LabelStyle::DESCRIPTION, i18n::getStr("about_tab/copyright", APP_AUTHOR, GITHUB_REPOSITORY_URL), true);
copyright->setHorizontalAlign(NVG_ALIGN_CENTER);
this->addView(copyright);
/* Dependencies. */
this->addView(new brls::Header("about_tab/dependencies/header"_i18n));
this->addView(new brls::Label(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_00"_i18n, APP_TITLE, BOREALIS_URL), true));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_01"_i18n, LIBUSBHSFS_URL)));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_02"_i18n, FATFS_URL)));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_03"_i18n, LZ4_URL)));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_04"_i18n, JSON_C_URL)));
this->addView(new brls::Label(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_00", APP_TITLE, BOREALIS_URL), true));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_01", LIBUSBHSFS_URL)));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_02", FATFS_URL)));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_03", LZ4_URL)));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/dependencies/line_04", JSON_C_URL)));
/* Acknowledgments. */
this->addView(new brls::Header("about_tab/acknowledgments/header"_i18n));
@ -66,7 +66,7 @@ namespace nxdt::views
/* Additional links and resources. */
this->addView(new brls::Header("about_tab/links/header"_i18n));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/links/line_00"_i18n, DISCORD_SERVER_URL)));
this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/links/line_00", DISCORD_SERVER_URL)));
}
AboutTab::~AboutTab()

View file

@ -83,7 +83,7 @@ namespace nxdt::views
this->error_frame->SetMessage("gamecard_tab/error_frame/lafw_update_required"_i18n);
break;
case GameCardStatus_InsertedAndInfoNotLoaded:
this->error_frame->SetMessage(i18n::getStr("gamecard_tab/error_frame/info_not_loaded"_i18n, GITHUB_NEW_ISSUE_URL));
this->error_frame->SetMessage(i18n::getStr("gamecard_tab/error_frame/info_not_loaded", GITHUB_NEW_ISSUE_URL));
break;
case GameCardStatus_InsertedAndInfoLoaded:
/* Update list and switch to it. */
@ -176,7 +176,7 @@ namespace nxdt::views
this->list->addView(new brls::Header("gamecard_tab/list/user_titles/header"_i18n));
/* Add information about how to work with individual user titles. */
brls::Label *user_titles_info = new brls::Label(brls::LabelStyle::DESCRIPTION, i18n::getStr("gamecard_tab/list/user_titles/info"_i18n, \
brls::Label *user_titles_info = new brls::Label(brls::LabelStyle::DESCRIPTION, i18n::getStr("gamecard_tab/list/user_titles/info", \
"root_view/tabs/user_titles"_i18n), true);
user_titles_info->setHorizontalAlign(NVG_ALIGN_CENTER);
this->list->addView(user_titles_info);

View file

@ -59,17 +59,17 @@ namespace nxdt::views
int LayeredErrorFrame::GetFocusStackViewIndex(void)
{
size_t cur_list_count = this->list->getViewsCount();
std::vector<brls::View*> *focus_stack = brls::Application::getFocusStack();
std::vector<brls::View*>& focus_stack = brls::Application::getFocusStack();
if (cur_list_count && focus_stack)
if (cur_list_count)
{
size_t focus_stack_size = focus_stack->size();
size_t focus_stack_size = focus_stack.size();
for(size_t i = 0; i < focus_stack_size; i++)
{
for(size_t j = 0; j < cur_list_count; j++)
{
if (this->list->getChild(j) == focus_stack->at(i)) return static_cast<int>(i);
if (this->list->getChild(j) == focus_stack.at(i)) return static_cast<int>(i);
}
}
}
@ -79,13 +79,12 @@ namespace nxdt::views
bool LayeredErrorFrame::UpdateFocusStackViewAtIndex(int index, brls::View *view)
{
std::vector<brls::View*> *focus_stack = brls::Application::getFocusStack();
if (!focus_stack || index < 0 || !view) return false;
std::vector<brls::View*>& focus_stack = brls::Application::getFocusStack();
size_t focus_stack_size = focus_stack.size();
size_t focus_stack_size = focus_stack->size();
if (index >= static_cast<int>(focus_stack_size)) return false;
if (index < 0 || index >= static_cast<int>(focus_stack_size) || !view) return false;
focus_stack->at(index) = view;
focus_stack.at(index) = view;
LOG_MSG_DEBUG("Focus stack updated.");
return true;

View file

@ -144,7 +144,7 @@ namespace nxdt::views
this->changelog_list->addView(version_lbl);
/* Display release date and commit hash. */
brls::Label *release_details_lbl = new brls::Label(brls::LabelStyle::DESCRIPTION, i18n::getStr("options_tab/update_app/frame/release_details"_i18n, \
brls::Label *release_details_lbl = new brls::Label(brls::LabelStyle::DESCRIPTION, i18n::getStr("options_tab/update_app/frame/release_details", \
this->json_data.commit_hash, RootView::GetFormattedDateString(this->json_data.date)), true);
release_details_lbl->setHorizontalAlign(NVG_ALIGN_CENTER);
this->changelog_list->addView(release_details_lbl);
@ -286,7 +286,7 @@ namespace nxdt::views
/* 2. Generate the string vector required by the dropdown. */
/* 3. Initialize the dropdown and pass a custom callback that will take care of unmounting the selected device. */
brls::SelectListItem *unmount_ums_device = new brls::SelectListItem("options_tab/unmount_ums_device/label"_i18n, { "dummy" }, 0,
i18n::getStr("options_tab/unmount_ums_device/description"_i18n, APP_TITLE), false);
i18n::getStr("options_tab/unmount_ums_device/description", APP_TITLE), false);
unmount_ums_device->getClickEvent()->unsubscribeAll();

View file

@ -84,7 +84,7 @@ namespace nxdt::views
this->usb_icon->setVerticalAlign(NVG_ALIGN_TOP);
this->usb_icon->setParent(this);
this->ums_counter_lbl = new brls::Label(brls::LabelStyle::SMALL, i18n::getStr("root_view/ums_counter"_i18n, usbHsFsGetPhysicalDeviceCount()));
this->ums_counter_lbl = new brls::Label(brls::LabelStyle::SMALL, i18n::getStr("root_view/ums_counter", usbHsFsGetPhysicalDeviceCount()));
this->ums_counter_lbl->setHorizontalAlign(NVG_ALIGN_RIGHT);
this->ums_counter_lbl->setVerticalAlign(NVG_ALIGN_TOP);
this->ums_counter_lbl->setParent(this);
@ -161,7 +161,7 @@ namespace nxdt::views
/* Subscribe to UMS event. */
this->ums_task_sub = this->ums_task->RegisterListener([this](const nxdt::tasks::UmsDeviceVector& ums_devices) {
/* Update UMS counter label. */
this->ums_counter_lbl->setText(i18n::getStr("root_view/ums_counter"_i18n, usbHsFsGetPhysicalDeviceCount()));
this->ums_counter_lbl->setText(i18n::getStr("root_view/ums_counter", usbHsFsGetPhysicalDeviceCount()));
/* Update cached output storage value, if needed. */
if (this->output_storage > ConfigOutputStorage_UsbHost) this->output_storage = ConfigOutputStorage_SdCard;
@ -170,7 +170,7 @@ namespace nxdt::views
/* Subscribe to USB host event. */
this->usb_host_task_sub = this->usb_host_task->RegisterListener([this](UsbHostSpeed usb_host_speed) {
/* Update USB host speed label. */
this->usb_host_speed_lbl->setText(usb_host_speed ? i18n::getStr("root_view/usb_host_speed"_i18n, usb_host_speed) : "root_view/usb_host_not_connected"_i18n);
this->usb_host_speed_lbl->setText(usb_host_speed ? i18n::getStr("root_view/usb_host_speed", usb_host_speed) : "root_view/usb_host_not_connected"_i18n);
});
}
@ -224,7 +224,7 @@ namespace nxdt::views
}
}
return i18n::getStr("generic/date"_i18n, ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec, is_am ? "AM" : "PM");
return i18n::getStr("generic/date", ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec, is_am ? "AM" : "PM");
}
void RootView::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx)

View file

@ -106,29 +106,31 @@ namespace nxdt::views
brls::Application::blockInputs();
/* Populate variables. */
TitleApplicationMetadata **app_metadata = app_metadata_info.app_metadata;
const u32 app_metadata_count = app_metadata_info.app_metadata_count;
bool update_focused_view = this->IsListItemFocused();
int focus_stack_index = this->GetFocusStackViewIndex();
/* If needed, switch to the error frame *before* cleaning up our list. */
if (!app_metadata_info.app_metadata_count) this->SwitchLayerView(true);
if (!app_metadata_count) this->SwitchLayerView(true);
/* Clear list. */
this->list->clear();
this->list->invalidate(true);
/* Return immediately if we have no application metadata. */
if (!app_metadata_info.app_metadata_count)
if (!app_metadata_count)
{
brls::Application::unblockInputs();
return;
}
/* Populate list. */
for(u32 i = 0; i < app_metadata_info.app_metadata_count; i++)
for(u32 i = 0; i < app_metadata_count; i++)
{
/* Create list item. */
const TitleApplicationMetadata *cur_app_metadata = app_metadata_info.app_metadata[i];
TitlesTabItem *item = new TitlesTabItem(cur_app_metadata, this->is_system);
TitlesTabItem *item = new TitlesTabItem(app_metadata[i], this->is_system);
/* Register click event. */
item->getClickEvent()->subscribe([](brls::View *view) {