Initial commit. Needs debugging.

This commit is contained in:
J-D-K
2026-03-20 12:41:04 -04:00
parent d39fd80a20
commit 347f1bc75f
112 changed files with 1331 additions and 1109 deletions

View File

@@ -104,7 +104,8 @@ void data::DataContext::load_application_records(sys::Task *task)
NsApplicationRecord record{};
bool listError{};
do {
do
{
listError = error::libnx(nsListApplicationRecord(&record, 1, offset++, &count)) || count <= 0;
if (listError) { break; }
if (DataContext::title_is_loaded(record.application_id)) { continue; }
@@ -217,7 +218,8 @@ bool data::DataContext::read_cache(sys::Task *task)
task->set_status(statusLoadingCache);
NsApplicationControlData controlData{};
do {
do
{
const bool dataRead = cacheZip.read(&controlData, SIZE_CTRL_DATA) == SIZE_CTRL_DATA;
if (!dataRead) { continue; }
@@ -270,9 +272,9 @@ bool data::DataContext::write_cache(sys::Task *task)
return true;
}
void data::DataContext::process_icon_queue()
void data::DataContext::process_icon_queue(sdl2::Renderer &renderer)
{
std::lock_guard multiGuard{m_iconQueueMutex};
for (data::DataCommon *common : m_iconQueue) { common->load_icon(); }
for (data::DataCommon *common : m_iconQueue) { common->load_icon(renderer); }
m_iconQueue.clear();
}

View File

@@ -21,10 +21,10 @@ data::TitleInfo::TitleInfo(uint64_t applicationID) noexcept
// This will filter from even trying to fetch control data for system titles.
const bool isSystem = applicationID & 0x8000000000000000;
const bool getError = !isSystem && error::libnx(nsGetApplicationControlData(NsApplicationControlSource_Storage,
m_applicationID,
&m_data,
SIZE_CTRL_DATA,
&controlSize));
m_applicationID,
&m_data,
SIZE_CTRL_DATA,
&controlSize));
const bool entryError = !getError && error::libnx(nacpGetLanguageEntry(&m_data.nacp, &m_entry));
if (isSystem || getError)
{
@@ -149,8 +149,6 @@ bool data::TitleInfo::has_save_data_type(uint8_t saveType) const noexcept
return false;
}
sdl::SharedTexture data::TitleInfo::get_icon() const noexcept { return m_icon; }
void data::TitleInfo::set_path_safe_title(const char *newPathSafe) noexcept
{
const size_t length = std::char_traits<char>::length(newPathSafe);
@@ -160,20 +158,16 @@ void data::TitleInfo::set_path_safe_title(const char *newPathSafe) noexcept
std::memcpy(m_pathSafeTitle, newPathSafe, length);
}
void data::TitleInfo::load_icon()
void data::TitleInfo::load_icon(sdl2::Renderer &renderer)
{
// This is taken from the NacpStruct.
static constexpr size_t SIZE_ICON = 0x20000;
const std::string textureName = stringutil::get_formatted_string("%04X", m_applicationID & 0xFFFF);
if (m_hasData)
{
const std::string textureName = stringutil::get_formatted_string("%016llX", m_applicationID);
m_icon = sdl::TextureManager::load(textureName, m_data.icon, SIZE_ICON);
}
if (m_hasData) { m_icon = sdl2::TextureManager::create_load_resource(textureName, m_data.icon, SIZE_ICON); }
else
{
const std::string text = stringutil::get_formatted_string("%04X", m_applicationID & 0xFFFF);
m_icon = gfxutil::create_generic_icon(text, 48, colors::DIALOG_DARK, colors::WHITE);
m_icon = gfxutil::create_generic_icon(renderer, textureName, 48, colors::DIALOG_DARK, colors::WHITE);
}
}

View File

@@ -45,7 +45,10 @@ data::User::User(AccountUid accountID, FsSaveDataType saveType) noexcept
const bool profileError = error::libnx(accountGetProfile(&profile, m_accountID));
const bool baseError = !profileError && error::libnx(accountProfileGet(&profile, nullptr, &profileBase));
if (profileError || baseError) { User::create_account(); }
else { User::load_account(profile, profileBase); }
else
{
User::load_account(profile, profileBase);
}
accountProfileClose(&profile);
}
@@ -174,7 +177,10 @@ void data::User::load_user_data()
{
infoReader.open(SAVE_DATA_SPACE_ORDER[i], m_accountID, SIZE_SAVE_INFO_BUFFER);
}
else { infoReader.open(SAVE_DATA_SPACE_ORDER[i], m_saveType, SIZE_SAVE_INFO_BUFFER); }
else
{
infoReader.open(SAVE_DATA_SPACE_ORDER[i], m_saveType, SIZE_SAVE_INFO_BUFFER);
}
if (!infoReader.is_open()) { continue; }
while (infoReader.read())
@@ -218,7 +224,7 @@ void data::User::load_user_data()
User::sort_data();
}
void data::User::load_icon()
void data::User::load_icon(sdl2::Renderer &renderer)
{
const std::string iconName =
stringutil::get_formatted_string("%016llX%016llX", m_nickname, m_accountID.uid[0], m_accountID.uid[1]);
@@ -230,7 +236,7 @@ void data::User::load_icon()
const bool sizeError = !profileError && error::libnx(accountProfileGetImageSize(&profile, &iconSize));
if (profileError || sizeError)
{
m_icon = gfxutil::create_generic_icon(m_nickname, SIZE_ICON_FONT, colors::DIALOG_DARK, colors::WHITE);
m_icon = gfxutil::create_generic_icon(renderer, m_nickname, SIZE_ICON_FONT, colors::DIALOG_DARK, colors::WHITE);
return;
}
@@ -239,9 +245,12 @@ void data::User::load_icon()
if (loadError) { return; }
accountProfileClose(&profile);
m_icon = sdl::TextureManager::load(iconName, iconBuffer.get(), iconSize);
m_icon = sdl2::TextureManager::create_load_resource(iconName, iconBuffer.get(), iconSize);
}
else
{
m_icon = gfxutil::create_generic_icon(renderer, m_nickname, SIZE_ICON_FONT, colors::DIALOG_DARK, colors::WHITE);
}
else { m_icon = gfxutil::create_generic_icon(m_nickname, SIZE_ICON_FONT, colors::DIALOG_DARK, colors::WHITE); }
}
void data::User::load_account(AccountProfile &profile, AccountProfileBase &profileBase)

View File

@@ -25,21 +25,19 @@ namespace
/// @brief The main routine for the task to load data.
static void data_initialize_task(sys::threadpool::JobData taskData);
void data::launch_initialization(bool clearCache, std::function<void()> onDestruction)
void data::launch_initialization(bool clearCache, sdl2::Renderer &renderer, std::function<void()> onDestruction)
{
auto taskData = std::make_shared<StateDataStruct>();
taskData->clearCache = clearCache;
auto loadingState = DataLoadingState::create(s_context, onDestruction, data_initialize_task, taskData);
auto loadingState = DataLoadingState::create(s_context, renderer, onDestruction, data_initialize_task, taskData);
StateManager::push_state(loadingState);
}
void data::get_users(data::UserList &userList) { s_context.get_users(userList); }
data::TitleInfo *data::get_title_info_by_id(uint64_t applicationID) noexcept
{
return s_context.get_title_by_id(applicationID);
}
{ return s_context.get_title_by_id(applicationID); }
void data::load_title_to_map(uint64_t applicationID) { s_context.load_title(applicationID); }
@@ -48,9 +46,7 @@ bool data::title_exists_in_map(uint64_t applicationID) noexcept { return s_conte
void data::get_title_info_list(data::TitleInfoList &listOut) { s_context.get_title_info_list(listOut); }
void data::get_title_info_by_type(FsSaveDataType saveType, data::TitleInfoList &listOut)
{
s_context.get_title_info_list_by_type(saveType, listOut);
}
{ s_context.get_title_info_list_by_type(saveType, listOut); }
static void data_initialize_task(sys::threadpool::JobData taskData)
{