draft transfer implementation
This commit is contained in:
@@ -1,43 +1,21 @@
|
||||
#include <MainApplication.hpp>
|
||||
#include <cinttypes>
|
||||
#include <cstdio>
|
||||
#include <data.h>
|
||||
#include <stdio.h>
|
||||
#include <main.hpp>
|
||||
#include <const.h>
|
||||
#include <client.hpp>
|
||||
|
||||
static std::vector<uint64_t> accSids, devSids, bcatSids, cacheSids;
|
||||
|
||||
//Sort save create tids alphabetically by title from data
|
||||
static struct
|
||||
{
|
||||
bool operator()(const uint64_t& tid1, const uint64_t& tid2)
|
||||
{
|
||||
std::string tid1Title = data::getTitleNameByTID(tid1);
|
||||
std::string tid2Title = data::getTitleNameByTID(tid2);
|
||||
|
||||
uint32_t pointA = 0, pointB = 0;
|
||||
for(unsigned i = 0, j = 0; i < tid1Title.length(); )
|
||||
{
|
||||
ssize_t tid1Cnt = decode_utf8(&pointA, (const uint8_t *)&tid1Title.c_str()[i]);
|
||||
ssize_t tid2Cnt = decode_utf8(&pointB, (const uint8_t *)&tid2Title.c_str()[j]);
|
||||
|
||||
pointA = tolower(pointA), pointB = tolower(pointB);
|
||||
if(pointA != pointB)
|
||||
return pointA < pointB;
|
||||
|
||||
i += tid1Cnt, j += tid2Cnt;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} sortCreateTIDs;
|
||||
|
||||
namespace ui {
|
||||
extern MainApplication *mainApp;
|
||||
void TitlesLayout::InitTitles() {
|
||||
this->titlesMenu = pu::ui::elm::Menu::New(0, 0, 1280, COLOR("#67000000"), COLOR("#170909FF"), 94, 7);
|
||||
const data::user *u = data::getCurrentUser();
|
||||
for(const data::userTitleInfo& t : u->titleInfo) {
|
||||
auto titleItem = pu::ui::elm::MenuItem::New(data::getTitleNameByTID(t.tid).c_str());
|
||||
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"));
|
||||
titlesMenu->AddItem(titleItem);
|
||||
this->titlesMenu->AddItem(titleItem);
|
||||
}
|
||||
|
||||
this->Add(this->titlesMenu);
|
||||
@@ -52,13 +30,32 @@ namespace ui {
|
||||
}
|
||||
|
||||
if (Down & HidNpadButton_A) {
|
||||
printf("current game index is %i\n", this->titlesMenu->GetSelectedIndex());
|
||||
data::setTitleIndex(this->titlesMenu->GetSelectedIndex());
|
||||
int opt = mainApp->CreateShowDialog("", "What do you want?", { "Transfer", "Receive" }, true);
|
||||
printf("opt is %d\n", opt);
|
||||
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: {
|
||||
// Transfert selected
|
||||
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);
|
||||
std::vector<std::string> files;
|
||||
std::vector<char*> cstrings{};
|
||||
auto directory = std::filesystem::path(path);
|
||||
for (const auto & entry : std::filesystem::directory_iterator(path)) {
|
||||
std::cout << entry.path() << std::endl;
|
||||
files.push_back(entry.path().string());
|
||||
}
|
||||
for (auto& file : files) {
|
||||
cstrings.push_back(&file.front());
|
||||
}
|
||||
transfer_files(directory, cstrings.data(), cstrings.size());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
|
||||
Reference in New Issue
Block a user