Files
NXST/source/TitlesLayout.cpp
2024-11-05 00:27:24 +03:00

60 lines
2.1 KiB
C++

#include <MainApplication.hpp>
#include <stdio.h>
#include <main.hpp>
#include <const.h>
#include <client.hpp>
static std::vector<uint64_t> accSids, devSids, bcatSids, cacheSids;
namespace ui {
extern MainApplication *mainApp;
void TitlesLayout::InitTitles() {
this->titlesMenu = pu::ui::elm::Menu::New(0, 0, 1280, COLOR("#67000000"), COLOR("#170909FF"), 94, 7);
for (size_t i = 0; i < getTitleCount(g_currentUId); i++) {
Title title;
getTitle(title, g_currentUId, i);
auto titleItem = pu::ui::elm::MenuItem::New(title.name().c_str());
titleItem->SetColor(COLOR("#FFFFFFFF"));
this->titlesMenu->AddItem(titleItem);
}
this->Add(this->titlesMenu);
this->SetBackgroundColor(BACKGROUND_COLOR);
}
void TitlesLayout::onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos) {
if (Down & HidNpadButton_Plus) {
mainApp->Close();
return;
}
if (Down & HidNpadButton_A) {
auto index = this->titlesMenu->GetSelectedIndex();
Title title;
getTitle(title, g_currentUId, index);
printf("userid is 0x%lX%lX\n", title.userId().uid[1], title.userId().uid[0]);
printf("current game index is %i\n", index);
int opt = mainApp->CreateShowDialog(title.name().c_str(), "What do you want?", { "Transfer", "Receive" }, true);
switch (opt) {
case 0: {
printf("path is %s\n", title.fullPath(0).c_str());
// Transfer selected
auto result = io::backup(index, g_currentUId);
if (std::get<0>(result)) {
printf("path is %s\n", std::get<2>(result).c_str());
std::string path = std::get<2>(result);
auto directory = std::filesystem::path(path);
transfer_files(directory);
}
break;
}
case 1: {
// Receive selected
break;
}
}
}
}
}