mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-22 10:16:39 +00:00
Repurposed UserTitlesTab class into TitlesTab.
Also implemented system titles tab view in the process.
This commit is contained in:
parent
7a15b4eab8
commit
9635670007
5 changed files with 53 additions and 40 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* user_titles_tab.hpp
|
||||
* titles_tab.hpp
|
||||
*
|
||||
* Copyright (c) 2020-2021, DarkMatterCore <pabloacurielz@gmail.com>.
|
||||
*
|
||||
|
@ -21,8 +21,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef __USER_TITLES_TAB_HPP__
|
||||
#define __USER_TITLES_TAB_HPP__
|
||||
#ifndef __TITLES_TAB_HPP__
|
||||
#define __TITLES_TAB_HPP__
|
||||
|
||||
#include "tasks.hpp"
|
||||
#include "layered_error_frame.hpp"
|
||||
|
@ -30,27 +30,30 @@
|
|||
namespace nxdt::views
|
||||
{
|
||||
/* Expanded ListItem class to hold a title ID. */
|
||||
class UserTitlesItem: public brls::ListItem
|
||||
class TitlesTabItem: public brls::ListItem
|
||||
{
|
||||
private:
|
||||
u64 title_id = 0;
|
||||
bool is_system = false;
|
||||
|
||||
public:
|
||||
UserTitlesItem(TitleApplicationMetadata *app_metadata);
|
||||
TitlesTabItem(TitleApplicationMetadata *app_metadata, bool is_system);
|
||||
};
|
||||
|
||||
class UserTitlesTab: public LayeredErrorFrame
|
||||
class TitlesTab: public LayeredErrorFrame
|
||||
{
|
||||
private:
|
||||
nxdt::tasks::TitleTask *title_task = nullptr;
|
||||
nxdt::tasks::TitleEvent::Subscription title_task_sub;
|
||||
|
||||
void PopulateList(const nxdt::tasks::TitleApplicationMetadataVector* user_app_metadata);
|
||||
bool is_system = false;
|
||||
|
||||
void PopulateList(const nxdt::tasks::TitleApplicationMetadataVector* app_metadata);
|
||||
|
||||
public:
|
||||
UserTitlesTab(nxdt::tasks::TitleTask *title_task);
|
||||
~UserTitlesTab(void);
|
||||
TitlesTab(nxdt::tasks::TitleTask *title_task, bool is_system);
|
||||
~TitlesTab(void);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __USER_TITLES_TAB_HPP__ */
|
||||
#endif /* __TITLES_TAB_HPP__ */
|
4
romfs/i18n/en-US/titles_tab.json
Normal file
4
romfs/i18n/en-US/titles_tab.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"no_titles_available": "No titles available.",
|
||||
"user_titles_notification": "User titles list updated!"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"no_titles_available": "No user titles available.",
|
||||
"notification": "User titles list updated!"
|
||||
}
|
|
@ -22,8 +22,7 @@
|
|||
#include <nxdt_utils.h>
|
||||
#include <root_view.hpp>
|
||||
#include <gamecard_tab.hpp>
|
||||
#include <user_titles_tab.hpp>
|
||||
//#include <system_titles_tab.hpp>
|
||||
#include <titles_tab.hpp>
|
||||
//#include <options_tab.hpp>
|
||||
#include <about_tab.hpp>
|
||||
|
||||
|
@ -74,8 +73,8 @@ namespace nxdt::views
|
|||
/* Add tabs. */
|
||||
this->addTab("root_view/tabs/gamecard"_i18n, new GameCardTab(this->gc_status_task));
|
||||
this->addSeparator();
|
||||
this->addTab("root_view/tabs/user_titles"_i18n, new UserTitlesTab(this->title_task));
|
||||
this->addTab("root_view/tabs/system_titles"_i18n, new brls::Rectangle(nvgRGB(0, 0, 255)));
|
||||
this->addTab("root_view/tabs/user_titles"_i18n, new TitlesTab(this->title_task, false));
|
||||
this->addTab("root_view/tabs/system_titles"_i18n, new TitlesTab(this->title_task, true));
|
||||
this->addSeparator();
|
||||
this->addTab("root_view/tabs/options"_i18n, new brls::Rectangle(nvgRGB(255, 255, 0)));
|
||||
this->addSeparator();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* user_titles_tab.cpp
|
||||
* titles_tab.cpp
|
||||
*
|
||||
* Copyright (c) 2020-2021, DarkMatterCore <pabloacurielz@gmail.com>.
|
||||
*
|
||||
|
@ -20,45 +20,56 @@
|
|||
*/
|
||||
|
||||
#include <nxdt_utils.h>
|
||||
#include <user_titles_tab.hpp>
|
||||
#include <titles_tab.hpp>
|
||||
|
||||
using namespace brls::i18n::literals; /* For _i18n. */
|
||||
|
||||
namespace nxdt::views
|
||||
{
|
||||
UserTitlesItem::UserTitlesItem(TitleApplicationMetadata *app_metadata) : brls::ListItem(std::string(app_metadata->lang_entry.name), "", std::string(app_metadata->lang_entry.author)), \
|
||||
title_id(app_metadata->title_id)
|
||||
TitlesTabItem::TitlesTabItem(TitleApplicationMetadata *app_metadata, bool is_system) : brls::ListItem(std::string(app_metadata->lang_entry.name), "", ""), \
|
||||
title_id(app_metadata->title_id),
|
||||
is_system(is_system)
|
||||
{
|
||||
if (app_metadata->icon && app_metadata->icon_size) this->setThumbnail(app_metadata->icon, app_metadata->icon_size);
|
||||
brls::Style* style = brls::Application::getStyle();
|
||||
|
||||
/* Set sublabel. */
|
||||
this->subLabel = (!this->is_system ? std::string(app_metadata->lang_entry.author) : fmt::format("{:016X}", this->title_id));
|
||||
this->setHeight(style->List.Item.heightWithSubLabel);
|
||||
|
||||
/* Set thumbnail if we're dealing with user metadata. */
|
||||
if (!this->is_system && app_metadata->icon && app_metadata->icon_size) this->setThumbnail(app_metadata->icon, app_metadata->icon_size);
|
||||
}
|
||||
|
||||
UserTitlesTab::UserTitlesTab(nxdt::tasks::TitleTask *title_task) : LayeredErrorFrame("user_titles_tab/no_titles_available"_i18n), title_task(title_task)
|
||||
TitlesTab::TitlesTab(nxdt::tasks::TitleTask *title_task, bool is_system) : LayeredErrorFrame("titles_tab/no_titles_available"_i18n), title_task(title_task), is_system(is_system)
|
||||
{
|
||||
/* Populate list. */
|
||||
this->PopulateList(this->title_task->GetApplicationMetadata(false));
|
||||
this->PopulateList(this->title_task->GetApplicationMetadata(this->is_system));
|
||||
|
||||
/* Subscribe to title event. */
|
||||
this->title_task_sub = this->title_task->RegisterListener([this](const nxdt::tasks::TitleApplicationMetadataVector* user_app_metadata) {
|
||||
/* Update list. */
|
||||
this->PopulateList(user_app_metadata);
|
||||
brls::Application::notify("user_titles_tab/notification"_i18n);
|
||||
});
|
||||
/* Subscribe to title event if this is the user titles tab. */
|
||||
if (!this->is_system)
|
||||
{
|
||||
this->title_task_sub = this->title_task->RegisterListener([this](const nxdt::tasks::TitleApplicationMetadataVector* app_metadata) {
|
||||
/* Update list. */
|
||||
this->PopulateList(app_metadata);
|
||||
brls::Application::notify("titles_tab/user_titles_notification"_i18n);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
UserTitlesTab::~UserTitlesTab(void)
|
||||
TitlesTab::~TitlesTab(void)
|
||||
{
|
||||
/* Unregister task listener. */
|
||||
this->title_task->UnregisterListener(this->title_task_sub);
|
||||
/* Unregister task listener if this is the user titles tab. */
|
||||
if (!this->is_system) this->title_task->UnregisterListener(this->title_task_sub);
|
||||
}
|
||||
|
||||
void UserTitlesTab::PopulateList(const nxdt::tasks::TitleApplicationMetadataVector* user_app_metadata)
|
||||
void TitlesTab::PopulateList(const nxdt::tasks::TitleApplicationMetadataVector* app_metadata)
|
||||
{
|
||||
if (!user_app_metadata) return;
|
||||
if (!app_metadata) return;
|
||||
|
||||
bool refocus = false;
|
||||
size_t user_app_metadata_count = user_app_metadata->size();
|
||||
size_t app_metadata_count = app_metadata->size();
|
||||
|
||||
if (user_app_metadata_count)
|
||||
if (app_metadata_count)
|
||||
{
|
||||
/* Determine if we need to refocus after updating the list. */
|
||||
brls::View *cur_view = brls::Application::getCurrentFocus();
|
||||
|
@ -82,10 +93,10 @@ namespace nxdt::views
|
|||
this->list->invalidate(true);
|
||||
|
||||
/* Immediately return if we have no user application metadata. */
|
||||
if (!user_app_metadata_count) return;
|
||||
if (!app_metadata_count) return;
|
||||
|
||||
/* Populate list. */
|
||||
for(TitleApplicationMetadata *cur_app_metadata : *user_app_metadata) this->list->addView(new UserTitlesItem(cur_app_metadata));
|
||||
for(TitleApplicationMetadata *cur_app_metadata : *app_metadata) this->list->addView(new TitlesTabItem(cur_app_metadata, this->is_system));
|
||||
|
||||
/* Switch to the list. */
|
||||
this->list->invalidate(true);
|
Loading…
Reference in a new issue