ui improve

This commit is contained in:
2026-04-25 10:34:50 +03:00
parent 7515e0334b
commit a2e874de85
9 changed files with 162 additions and 108 deletions
+48 -19
View File
@@ -26,7 +26,11 @@ namespace ui {
}
void TitlesLayout::onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos) {
if (m_inputLocked) return;
if (Down & HidNpadButton_Plus) {
cancelClientTransfer();
cancelServerTransfer();
mainApp->Close();
return;
}
@@ -42,14 +46,24 @@ namespace ui {
switch (opt) {
case 0: {
// 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);
auto backupResult = io::backup(index, g_currentUId);
if (!std::get<0>(backupResult)) {
mainApp->CreateShowDialog("Transfer", "Failed to create backup:\n" + std::get<2>(backupResult), {"OK"}, true);
break;
}
auto directory = std::filesystem::path(std::get<2>(backupResult));
{
auto ovl = TransferOverlay::New("Transferring save data...");
this->titlesMenu->SetVisible(false);
mainApp->StartOverlay(ovl);
this->LockInput();
if (transfer_files(directory) != 0) {
mainApp->EndOverlay();
this->titlesMenu->SetVisible(true);
this->UnlockInput();
mainApp->CreateShowDialog("Transfer", "Failed to start transfer.", {"OK"}, true);
break;
}
while (!isClientTransferDone()) {
ovl->SetStatus(getClientStatusText());
ovl->SetProgress(getClientProgress());
@@ -60,17 +74,29 @@ namespace ui {
svcSleepThread(16666666LL);
}
mainApp->EndOverlay();
this->titlesMenu->SetVisible(true);
this->UnlockInput();
}
if (isClientConnectionFailed()) {
mainApp->CreateShowDialog("Transfer", "No receiver found.\nMake sure the other Switch is in Receive mode.", {"OK"}, true);
} else if (isClientTransferCancelled()) {
mainApp->CreateShowDialog("Transfer", "Transfer cancelled.", {"OK"}, true);
} else {
mainApp->CreateShowDialog("Transfer", "Save data sent successfully!", {"OK"}, true);
}
break;
}
case 1: {
// Receive selected
printf("startSendingThread\n");
int result = startSendingThread();
printf("result is %i\n", result);
if (result == 0) {
if (startSendingThread() != 0) {
mainApp->CreateShowDialog("Receive", "Failed to start receiver.\nCheck network connection.", {"OK"}, true);
break;
}
{
auto ovl = TransferOverlay::New("Receiving save data...");
this->titlesMenu->SetVisible(false);
mainApp->StartOverlay(ovl);
this->LockInput();
while (!isServerTransferDone()) {
ovl->SetStatus(getServerStatusText());
ovl->SetProgress(getServerProgress());
@@ -81,16 +107,19 @@ namespace ui {
svcSleepThread(16666666LL);
}
mainApp->EndOverlay();
if (!isServerTransferCancelled()) {
auto restoreResult = io::restore(index, g_currentUId, 0, title.name());
if (std::get<0>(restoreResult)) {
printf("%s\n", std::get<2>(restoreResult).c_str());
} else {
printf("Failed to restore with error %s\n", std::get<2>(restoreResult).c_str());
}
}
this->titlesMenu->SetVisible(true);
this->UnlockInput();
}
if (isServerTransferCancelled()) {
mainApp->CreateShowDialog("Receive", "Transfer cancelled.", {"OK"}, true);
break;
}
auto restoreResult = io::restore(index, g_currentUId, 0, title.name());
if (std::get<0>(restoreResult)) {
mainApp->CreateShowDialog("Receive", "Save data received and restored successfully!", {"OK"}, true);
} else {
mainApp->CreateShowDialog("Receive", "Restore failed:\n" + std::get<2>(restoreResult), {"OK"}, true);
}
break;
}
}