62 lines
2.0 KiB
C++
62 lines
2.0 KiB
C++
#include <cstdio>
|
|
#include <MainApplication.hpp>
|
|
#include "main.hpp"
|
|
|
|
namespace ui {
|
|
extern MainApplication *mainApp;
|
|
|
|
UsersLayout::UsersLayout() : Layout::Layout() {
|
|
this->usersMenu = pu::ui::elm::Menu::New(0, 0, 1280, COLOR("#67000000"), COLOR("#170909FF"), 94, 7);
|
|
this->usersMenu->SetScrollbarColor(COLOR("#170909FF"));
|
|
|
|
for (AccountUid const& uid : Account::ids()) {
|
|
auto item = pu::ui::elm::MenuItem::New(Account::username(uid));
|
|
item->SetColor(COLOR("#FFFFFFFF"));
|
|
this->usersMenu->AddItem(item);
|
|
}
|
|
|
|
this->loadingBg = pu::ui::elm::Rectangle::New(0, 0, 1280, 720, pu::ui::Color(30, 30, 30, 220));
|
|
this->loadingBg->SetVisible(false);
|
|
|
|
this->loadingText = pu::ui::elm::TextBlock::New(480, 340, "Reading game list...");
|
|
this->loadingText->SetColor(pu::ui::Color(255, 255, 255, 255));
|
|
this->loadingText->SetVisible(false);
|
|
|
|
this->SetBackgroundColor(BACKGROUND_COLOR);
|
|
this->Add(this->usersMenu);
|
|
this->Add(this->loadingBg);
|
|
this->Add(this->loadingText);
|
|
}
|
|
|
|
int32_t UsersLayout::GetCurrentIndex() {
|
|
return this->usersMenu->GetSelectedIndex();
|
|
}
|
|
|
|
void UsersLayout::onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos) {
|
|
if (Down & HidNpadButton_Plus) {
|
|
mainApp->Close();
|
|
return;
|
|
}
|
|
|
|
if (Down & HidNpadButton_A) {
|
|
g_currentUId = Account::ids().at(this->usersMenu->GetSelectedIndex());
|
|
|
|
if (!areTitlesLoaded()) {
|
|
this->usersMenu->SetVisible(false);
|
|
this->loadingBg->SetVisible(true);
|
|
this->loadingText->SetVisible(true);
|
|
mainApp->CallForRender();
|
|
|
|
loadTitles();
|
|
|
|
this->loadingBg->SetVisible(false);
|
|
this->loadingText->SetVisible(false);
|
|
this->usersMenu->SetVisible(true);
|
|
}
|
|
|
|
mainApp->titlesLayout->InitTitles();
|
|
mainApp->LoadLayout(mainApp->titlesLayout);
|
|
}
|
|
}
|
|
}
|