72 lines
2.3 KiB
C++
72 lines
2.3 KiB
C++
#include <MainApplication.hpp>
|
|
#include <cinttypes>
|
|
#include <cstdio>
|
|
#include <data.h>
|
|
|
|
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());
|
|
titleItem->SetColor(COLOR("#FFFFFFFF"));
|
|
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) {
|
|
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);
|
|
switch (opt) {
|
|
case 0: {
|
|
// Transfert selected
|
|
break;
|
|
}
|
|
case 1: {
|
|
// Receive selected
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|