#include namespace ui { extern MainApplication* mainApp; UsersLayout::UsersLayout() : Layout::Layout() { using namespace theme; this->usersMenu = pu::ui::elm::Menu::New(0, layout::ContentTop + space::md, layout::ScreenW, color::BgBase, color::BgSurface2, 88, 6); this->usersMenu->SetScrollbarColor(color::Primary); this->usersMenu->SetItemsFocusColor(color::BgSurface2); for (AccountUid const& uid : Account::ids()) { auto item = pu::ui::elm::MenuItem::New(Account::username(uid)); item->SetColor(color::TextPrimary); this->usersMenu->AddItem(item); } this->loadingBg = pu::ui::elm::Rectangle::New(0, 0, layout::ScreenW, layout::ScreenH, color::Scrim); this->loadingBg->SetVisible(false); this->loadingText = pu::ui::elm::TextBlock::New(layout::ScreenW / 2 - 120, layout::ScreenH / 2 - 12, "Loading saves..."); this->loadingText->SetFont(type::font(type::Body)); this->loadingText->SetColor(color::TextSecondary); this->loadingText->SetVisible(false); this->SetBackgroundColor(color::BgBase); this->Add(this->usersMenu); this->Add(this->loadingBg); this->Add(this->loadingText); this->header = std::make_unique(this, "Select a user"); this->hints = std::make_unique(this); this->hints->SetHints({{"A", "Select"}, {"+", "Quit"}}); } 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) { AccountUid uid = 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->titles_layout->InitTitles(uid); mainApp->LoadLayout(mainApp->titles_layout); } } } // namespace ui