finish refactor, add docs and CI
CI / Build NRO (push) Failing after 27s
CI / Format check (push) Successful in 11s
CI / Layering check (push) Successful in 1s

This commit is contained in:
2026-04-27 01:49:41 +03:00
parent dc65a4c8a9
commit b2de532bce
47 changed files with 1964 additions and 1470 deletions
+9 -8
View File
@@ -1,23 +1,24 @@
#pragma once
#include <nxst/ui/const.h>
#include <memory>
#include <switch.h>
#include <nxst/domain/account.hpp>
#include <nxst/domain/title.hpp>
#include <nxst/domain/util.hpp>
#include <memory>
#include <switch.h>
#include <nxst/infra/sys/logger.hpp>
#include <nxst/ui/const.h>
typedef enum { SORT_ALPHA, SORT_LAST_PLAYED, SORT_PLAY_TIME, SORT_MODES_COUNT } sort_t;
inline float g_currentTime = 0;
inline bool g_backupScrollEnabled = 0;
inline bool g_notificationLedAvailable = false;
inline bool g_shouldExitNetworkLoop = false;
inline bool g_backupScrollEnabled = 0;
inline bool g_notificationLedAvailable = false;
inline bool g_shouldExitNetworkLoop = false;
inline std::string g_selectedCheatKey;
inline std::vector<std::string> g_selectedCheatCodes;
inline u32 g_username_dotsize;
inline sort_t g_sortMode = SORT_ALPHA;
inline sort_t g_sortMode = SORT_ALPHA;
inline std::string g_currentFile = "";
inline bool g_isTransferringFile = false;
inline const std::string g_emptySave = "New...";
+12 -11
View File
@@ -1,22 +1,23 @@
#pragma once
#include <pu/Plutonium>
#include <nxst/service/transfer_service.hpp>
#include <nxst/ui/users_layout.hpp>
#include <nxst/ui/titles_layout.hpp>
#include <nxst/ui/users_layout.hpp>
namespace ui {
class MainApplication : public pu::ui::Application {
class MainApplication : public pu::ui::Application {
public:
using Application::Application;
PU_SMART_CTOR(MainApplication)
public:
using Application::Application;
PU_SMART_CTOR(MainApplication)
void OnLoad() override;
void OnLoad() override;
UsersLayout::Ref users_layout;
TitlesLayout::Ref titles_layout;
nxst::TransferService transfer;
};
}
UsersLayout::Ref users_layout;
TitlesLayout::Ref titles_layout;
nxst::TransferService transfer;
};
} // namespace ui
+20 -21
View File
@@ -28,31 +28,31 @@
#include <map>
#include <string.h>
#include <string>
#include <switch.h>
#include <vector>
#include <switch.h>
#define USER_ICON_SIZE 64
namespace std {
template <>
struct hash<AccountUid> {
size_t operator()(const AccountUid& a) const { return ((hash<u64>()(a.uid[0]) ^ (hash<u64>()(a.uid[1]) << 1)) >> 1); }
};
}
template <> struct hash<AccountUid> {
size_t operator()(const AccountUid& a) const {
return ((hash<u64>()(a.uid[0]) ^ (hash<u64>()(a.uid[1]) << 1)) >> 1);
}
};
} // namespace std
inline bool operator==(const AccountUid& x, const AccountUid& y)
{
inline bool operator==(const AccountUid& x, const AccountUid& y) {
return x.uid[0] == y.uid[0] && x.uid[1] == y.uid[1];
}
inline bool operator==(const AccountUid& x, u64 y)
{
inline bool operator==(const AccountUid& x, u64 y) {
return x.uid[0] == y && x.uid[1] == y;
}
inline bool operator<(const AccountUid& x, const AccountUid& y)
{
if (x.uid[0] != y.uid[0]) return x.uid[0] < y.uid[0];
inline bool operator<(const AccountUid& x, const AccountUid& y) {
if (x.uid[0] != y.uid[0])
return x.uid[0] < y.uid[0];
return x.uid[1] < y.uid[1];
}
@@ -62,12 +62,11 @@ struct User {
};
namespace Account {
Result init(void);
void exit(void);
std::vector<AccountUid> ids(void);
AccountUid selectAccount(void);
std::string username(AccountUid id);
std::string iconPath(AccountUid id);
}
Result init(void);
void exit(void);
std::vector<AccountUid> ids(void);
AccountUid selectAccount(void);
std::string username(AccountUid id);
std::string iconPath(AccountUid id);
} // namespace Account
+13 -14
View File
@@ -42,21 +42,20 @@
#define ATEXIT(func) atexit((void (*)())func)
namespace DateTime {
std::string timeStr(void);
std::string dateTimeStr(void);
std::string logDateTime(void);
}
std::string timeStr(void);
std::string dateTimeStr(void);
std::string logDateTime(void);
} // namespace DateTime
namespace StringUtils {
bool containsInvalidChar(const std::string& str);
std::string escapeJson(const std::string& s);
std::string format(const std::string fmt_str, ...);
std::string removeForbiddenCharacters(std::string src);
std::string UTF16toUTF8(const std::u16string& src);
void ltrim(std::string& s);
void rtrim(std::string& s);
void trim(std::string& s);
}
bool containsInvalidChar(const std::string& str);
std::string escapeJson(const std::string& s);
std::string format(const std::string fmt_str, ...);
std::string removeForbiddenCharacters(std::string src);
std::string UTF16toUTF8(const std::u16string& src);
void ltrim(std::string& s);
void rtrim(std::string& s);
void trim(std::string& s);
} // namespace StringUtils
char* getConsoleIP(void);
+12 -12
View File
@@ -2,16 +2,16 @@
#include <cstdint>
namespace proto {
constexpr uint16_t TCP_PORT = 8080;
constexpr uint16_t MULTICAST_PORT = 8081;
constexpr char MULTICAST_GROUP[] = "239.0.0.1";
constexpr size_t BUF_SIZE = 65536;
constexpr uint32_t MAX_FILENAME = 4096;
constexpr uint32_t EOF_SENTINEL = 0;
constexpr uint16_t TCP_PORT = 8080;
constexpr uint16_t MULTICAST_PORT = 8081;
constexpr char MULTICAST_GROUP[] = "239.0.0.1";
constexpr size_t BUF_SIZE = 65536;
constexpr uint32_t MAX_FILENAME = 4096;
constexpr uint32_t EOF_SENTINEL = 0;
// Wire layout per file:
// [filename_len : uint32_t LE] — 0 == end-of-stream
// [filename : filename_len bytes]
// [file_size : uint64_t LE]
// [file_data : file_size bytes]
}
// Wire layout per file:
// [filename_len : uint32_t LE] — 0 == end-of-stream
// [filename : filename_len bytes]
// [file_size : uint64_t LE]
// [file_data : file_size bytes]
} // namespace proto
+45 -22
View File
@@ -4,14 +4,13 @@
namespace nxst {
template <class T, class E = std::string>
class Result {
template <class T, class E = std::string> class Result {
bool ok;
alignas(T) alignas(E) unsigned char storage[sizeof(T) > sizeof(E) ? sizeof(T) : sizeof(E)];
Result() = default;
public:
public:
static Result success(T val) {
Result res;
res.ok = true;
@@ -27,37 +26,52 @@ public:
}
~Result() {
if (ok) reinterpret_cast<T*>(storage)->~T();
else reinterpret_cast<E*>(storage)->~E();
if (ok)
reinterpret_cast<T*>(storage)->~T();
else
reinterpret_cast<E*>(storage)->~E();
}
Result(const Result& other) : ok(other.ok) {
if (ok) new (storage) T(*reinterpret_cast<const T*>(other.storage));
else new (storage) E(*reinterpret_cast<const E*>(other.storage));
if (ok)
new (storage) T(*reinterpret_cast<const T*>(other.storage));
else
new (storage) E(*reinterpret_cast<const E*>(other.storage));
}
Result(Result&& other) : ok(other.ok) {
if (ok) new (storage) T(std::move(*reinterpret_cast<T*>(other.storage)));
else new (storage) E(std::move(*reinterpret_cast<E*>(other.storage)));
if (ok)
new (storage) T(std::move(*reinterpret_cast<T*>(other.storage)));
else
new (storage) E(std::move(*reinterpret_cast<E*>(other.storage)));
}
Result& operator=(const Result&) = delete;
bool isOk() const noexcept { return ok; }
const T& value() const { return *reinterpret_cast<const T*>(storage); }
const E& error() const { return *reinterpret_cast<const E*>(storage); }
bool isOk() const noexcept {
return ok;
}
const T& value() const {
return *reinterpret_cast<const T*>(storage);
}
const E& error() const {
return *reinterpret_cast<const E*>(storage);
}
};
// Specialisation for Result<void>
template <class E>
class Result<void, E> {
template <class E> class Result<void, E> {
bool ok;
alignas(E) unsigned char storage[sizeof(E)];
Result() = default;
public:
static Result success() { Result res; res.ok = true; return res; }
public:
static Result success() {
Result res;
res.ok = true;
return res;
}
static Result failure(E err) {
Result res;
@@ -66,20 +80,29 @@ public:
return res;
}
~Result() { if (!ok) reinterpret_cast<E*>(storage)->~E(); }
~Result() {
if (!ok)
reinterpret_cast<E*>(storage)->~E();
}
Result(const Result& other) : ok(other.ok) {
if (!ok) new (storage) E(*reinterpret_cast<const E*>(other.storage));
if (!ok)
new (storage) E(*reinterpret_cast<const E*>(other.storage));
}
Result(Result&& other) : ok(other.ok) {
if (!ok) new (storage) E(std::move(*reinterpret_cast<E*>(other.storage)));
if (!ok)
new (storage) E(std::move(*reinterpret_cast<E*>(other.storage)));
}
Result& operator=(const Result&) = delete;
bool isOk() const noexcept { return ok; }
const E& error() const { return *reinterpret_cast<const E*>(storage); }
bool isOk() const noexcept {
return ok;
}
const E& error() const {
return *reinterpret_cast<const E*>(storage);
}
};
} // namespace nxst
} // namespace nxst
+10 -8
View File
@@ -25,20 +25,23 @@
*/
#pragma once
#include <nxst/domain/account.hpp>
#include <nxst/infra/fs/filesystem.hpp>
#include <nxst/infra/fs/io.hpp>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <switch.h>
#include <unordered_map>
#include <utility>
#include <vector>
#include <switch.h>
#include <nxst/domain/account.hpp>
#include <nxst/infra/fs/filesystem.hpp>
#include <nxst/infra/fs/io.hpp>
class Title {
public:
void init(u8 saveDataType, u64 titleid, AccountUid userID, const std::string& name, const std::string& author);
public:
void init(u8 saveDataType, u64 titleid, AccountUid userID, const std::string& name,
const std::string& author);
~Title() = default;
std::string author(void);
@@ -60,7 +63,7 @@ public:
AccountUid userId(void);
std::string userName(void);
private:
private:
u64 mId;
u64 mSaveId;
AccountUid mUserId;
@@ -85,4 +88,3 @@ void sortTitles(void);
void rotateSortMode(void);
void refreshDirectories(u64 id);
std::unordered_map<std::string, std::string> getCompleteTitleList(void);
+9 -9
View File
@@ -4,22 +4,22 @@
#include <string>
struct TransferState {
std::atomic<bool> done{false};
std::atomic<bool> cancelled{false};
std::atomic<bool> connection_failed{false};
std::atomic<bool> done{false};
std::atomic<bool> cancelled{false};
std::atomic<bool> connection_failed{false};
std::atomic<uint64_t> bytes_done{0};
std::atomic<uint64_t> bytes_total{0};
std::string status;
std::string fail_reason;
std::string status;
std::string fail_reason;
mutable std::mutex status_mutex;
void reset() {
done = false;
cancelled = false;
done = false;
cancelled = false;
connection_failed = false;
bytes_done = 0;
bytes_total = 0;
bytes_done = 0;
bytes_total = 0;
fail_reason.clear();
std::lock_guard<std::mutex> lock(status_mutex);
status.clear();
+9 -9
View File
@@ -25,11 +25,13 @@
*/
#pragma once
#include <sys/stat.h>
#include <switch.h>
#include <nxst/domain/account.hpp>
#include <nxst/domain/common.hpp>
#include <nxst/infra/fs/io.hpp>
#include <switch.h>
#include <sys/stat.h>
// debug
#include <arpa/inet.h>
@@ -42,10 +44,8 @@ HidsysNotificationLedPattern blinkLedPattern(u8 times);
void blinkLed(u8 times);
namespace StringUtils {
std::string removeAccents(std::string str);
std::string removeNotAscii(std::string str);
std::u16string UTF8toUTF16(const char* src);
std::string elide(const std::string& s, size_t maxChars);
}
std::string removeAccents(std::string str);
std::string removeNotAscii(std::string str);
std::u16string UTF8toUTF16(const char* src);
std::string elide(const std::string& s, size_t maxChars);
} // namespace StringUtils
+4 -4
View File
@@ -28,16 +28,17 @@
#include <dirent.h>
#include <errno.h>
#include <string>
#include <switch.h>
#include <vector>
#include <switch.h>
struct DirectoryEntry {
std::string name;
bool directory;
};
class Directory {
public:
public:
Directory(const std::string& root);
~Directory() = default;
@@ -47,9 +48,8 @@ public:
bool good(void);
size_t size(void);
private:
private:
std::vector<struct DirectoryEntry> mList;
Result mError;
bool mGood;
};
+6 -6
View File
@@ -25,12 +25,12 @@
*/
#pragma once
#include <nxst/domain/account.hpp>
#include <switch.h>
namespace FileSystem {
Result mount(FsFileSystem* fileSystem, u64 titleID, AccountUid userID);
int mount(FsFileSystem fs);
void unmount(void);
}
#include <nxst/domain/account.hpp>
namespace FileSystem {
Result mount(FsFileSystem* fileSystem, u64 titleID, AccountUid userID);
int mount(FsFileSystem fs);
void unmount(void);
} // namespace FileSystem
+24 -9
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstdio>
#include <switch.h>
namespace nxst {
@@ -10,14 +11,21 @@ struct FsFileSystemHandle {
bool valid{false};
FsFileSystemHandle() = default;
~FsFileSystemHandle() { if (valid) fsFsClose(&fs); } // NOLINT(modernize-use-equals-default)
~FsFileSystemHandle() {
if (valid)
fsFsClose(&fs);
} // NOLINT(modernize-use-equals-default)
FsFileSystemHandle(const FsFileSystemHandle&) = delete;
FsFileSystemHandle(const FsFileSystemHandle&) = delete;
FsFileSystemHandle& operator=(const FsFileSystemHandle&) = delete;
FsFileSystem* get() { return &fs; }
FsFileSystem* get() {
return &fs;
}
void release() { valid = false; } // transfer ownership to devfs
void release() {
valid = false;
} // transfer ownership to devfs
};
// RAII wrapper for FILE* — auto-fclose on destruction.
@@ -25,13 +33,20 @@ struct FileHandle {
FILE* ptr{nullptr};
explicit FileHandle(FILE* file) : ptr(file) {}
~FileHandle() { if (ptr != nullptr) fclose(ptr); } // NOLINT(modernize-use-equals-default)
~FileHandle() {
if (ptr != nullptr)
fclose(ptr);
} // NOLINT(modernize-use-equals-default)
FileHandle(const FileHandle&) = delete;
FileHandle(const FileHandle&) = delete;
FileHandle& operator=(const FileHandle&) = delete;
explicit operator bool() const { return ptr != nullptr; }
FILE* get() const { return ptr; }
explicit operator bool() const {
return ptr != nullptr;
}
FILE* get() const {
return ptr;
}
};
} // namespace nxst
} // namespace nxst
+18 -16
View File
@@ -25,27 +25,29 @@
*/
#pragma once
#include <nxst/domain/account.hpp>
#include <nxst/domain/result.hpp>
#include <nxst/infra/fs/directory.hpp>
#include <nxst/domain/title.hpp>
#include <nxst/domain/util.hpp>
#include <dirent.h>
#include <switch.h>
#include <sys/stat.h>
#include <unistd.h>
#include <switch.h>
#include <nxst/domain/account.hpp>
#include <nxst/domain/result.hpp>
#include <nxst/domain/title.hpp>
#include <nxst/domain/util.hpp>
#include <nxst/infra/fs/directory.hpp>
#define BUFFER_SIZE 0x80000
namespace io {
nxst::Result<std::string> backup(size_t index, AccountUid uid);
nxst::Result<std::string> restore(size_t index, AccountUid uid, size_t cellIndex, const std::string& nameFromCell);
Result copyDirectory(const std::string& srcPath, const std::string& dstPath);
void copyFile(const std::string& srcPath, const std::string& dstPath);
Result createDirectory(const std::string& path);
Result deleteFolderRecursively(const std::string& path);
bool directoryExists(const std::string& path);
bool fileExists(const std::string& path);
}
nxst::Result<std::string> backup(size_t index, AccountUid uid);
nxst::Result<std::string> restore(size_t index, AccountUid uid, size_t cellIndex,
const std::string& nameFromCell);
Result copyDirectory(const std::string& srcPath, const std::string& dstPath);
void copyFile(const std::string& srcPath, const std::string& dstPath);
Result createDirectory(const std::string& path);
Result deleteFolderRecursively(const std::string& path);
bool directoryExists(const std::string& path);
bool fileExists(const std::string& path);
} // namespace io
+17 -6
View File
@@ -6,13 +6,24 @@ struct Socket {
Socket() = default;
explicit Socket(int fd) : fd(fd) {}
~Socket() { if (fd >= 0) close(fd); }
~Socket() {
if (fd >= 0)
close(fd);
}
Socket(const Socket&) = delete;
Socket(const Socket&) = delete;
Socket& operator=(const Socket&) = delete;
Socket(Socket&& o) : fd(o.fd) { o.fd = -1; }
Socket(Socket&& o) : fd(o.fd) {
o.fd = -1;
}
operator int() const { return fd; }
bool valid() const { return fd >= 0; }
void release() { fd = -1; }
operator int() const {
return fd;
}
bool valid() const {
return fd >= 0;
}
void release() {
fd = -1;
}
};
+22 -18
View File
@@ -9,47 +9,51 @@ namespace nxst::log {
enum class Level { Debug, Info, Warn, Error };
void write(Level level, const char* fmt, ...) __attribute__((format(printf, 2, 3)));
void debug(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
void info (const char* fmt, ...) __attribute__((format(printf, 1, 2)));
void warn (const char* fmt, ...) __attribute__((format(printf, 1, 2)));
void error(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
void debug(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
void info(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
void warn(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
void error(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
// No-op: writes are immediate. Kept for source compatibility during migration.
inline void flush() {}
} // namespace nxst::log
} // namespace nxst::log
// Backward-compat shim — existing Logger::getInstance().log(...) call sites compile
// unchanged. Format args are dropped (same behavior as broken original). Migrate
// call sites to nxst::log::* in Phase 3.
struct Logger {
static Logger& getInstance()
{
static Logger& getInstance() {
static Logger instance;
return instance;
}
// clang-tidy naming suppressed: these must match existing call sites during migration.
static constexpr const char* INFO = "[INFO]"; // NOLINT(readability-identifier-naming)
static constexpr const char* INFO = "[INFO]"; // NOLINT(readability-identifier-naming)
static constexpr const char* DEBUG = "[DEBUG]"; // NOLINT(readability-identifier-naming)
static constexpr const char* ERROR = "[ERROR]"; // NOLINT(readability-identifier-naming)
static constexpr const char* WARN = "[WARN]"; // NOLINT(readability-identifier-naming)
static constexpr const char* WARN = "[WARN]"; // NOLINT(readability-identifier-naming)
static void flush() { nxst::log::flush(); }
static void flush() {
nxst::log::flush();
}
// Args intentionally dropped — format string still logged for visibility.
template <typename... Args>
void log(const std::string& level, const std::string& fmt, Args&&... /*args*/)
{
if (level == ERROR) nxst::log::error("%s", fmt.c_str());
else if (level == WARN) nxst::log::warn("%s", fmt.c_str());
else if (level == DEBUG) nxst::log::debug("%s", fmt.c_str());
else nxst::log::info("%s", fmt.c_str());
void log(const std::string& level, const std::string& fmt, Args&&... /*args*/) {
if (level == ERROR)
nxst::log::error("%s", fmt.c_str());
else if (level == WARN)
nxst::log::warn("%s", fmt.c_str());
else if (level == DEBUG)
nxst::log::debug("%s", fmt.c_str());
else
nxst::log::info("%s", fmt.c_str());
}
Logger() = default;
Logger() = default;
~Logger() = default;
Logger(const Logger&) = delete; // NOLINT(modernize-use-equals-delete)
Logger(const Logger&) = delete; // NOLINT(modernize-use-equals-delete)
Logger& operator=(const Logger&) = delete; // NOLINT(modernize-use-equals-delete)
};
+76 -39
View File
@@ -2,75 +2,112 @@
#include <atomic>
#include <pthread.h>
#include <string>
#include <switch.h>
#include <nxst/domain/transfer_state.hpp>
namespace nxst {
class TransferService {
public:
int startSend(size_t title_index, AccountUid uid);
public:
int startSend(size_t title_index, AccountUid uid);
void cancelSend();
bool isSendDone() const { return sender_state.done.load(); }
bool isSendCancelled() const { return sender_state.cancelled.load(); }
bool isSendConnectionFailed() const { return sender_state.connection_failed.load(); }
bool isSendProgressKnown() const { return sender_state.bytes_total.load() > 0; }
bool isSendWorkersIdle() const { return !sender_active.load(); }
double sendProgress() const { return sender_state.progress(); }
std::string sendStatusText() const { return sender_state.getStatus(); }
std::string sendFailReason() const { return sender_state.fail_reason; }
bool isSendDone() const {
return sender_state.done.load();
}
bool isSendCancelled() const {
return sender_state.cancelled.load();
}
bool isSendConnectionFailed() const {
return sender_state.connection_failed.load();
}
bool isSendProgressKnown() const {
return sender_state.bytes_total.load() > 0;
}
bool isSendWorkersIdle() const {
return !sender_active.load();
}
double sendProgress() const {
return sender_state.progress();
}
std::string sendStatusText() const {
return sender_state.getStatus();
}
std::string sendFailReason() const {
return sender_state.fail_reason;
}
int startReceive(size_t title_index, AccountUid uid, std::string title_name);
int startReceive(size_t title_index, AccountUid uid, std::string title_name);
void cancelReceive();
bool isReceiveDone() const { return receiver_state.done.load(); }
bool isReceiveCancelled() const { return receiver_state.cancelled.load(); }
bool isReceiveWorkersIdle() const {
bool isReceiveDone() const {
return receiver_state.done.load();
}
bool isReceiveCancelled() const {
return receiver_state.cancelled.load();
}
bool isReceiveWorkersIdle() const {
return !receiver_accept_active.load() && !receiver_broadcast_active.load();
}
double receiveProgress() const { return receiver_state.progress(); }
std::string receiveStatusText() const { return receiver_state.getStatus(); }
bool restoreSucceeded() const { return restore_ok; }
std::string restoreError() const { return restore_error; }
double receiveProgress() const {
return receiver_state.progress();
}
std::string receiveStatusText() const {
return receiver_state.getStatus();
}
bool restoreSucceeded() const {
return restore_ok;
}
std::string restoreError() const {
return restore_error;
}
private:
private:
// Sender
TransferState sender_state;
std::atomic<int> sender_udp_sock{-1};
std::atomic<int> sender_tcp_sock{-1};
TransferState sender_state;
std::atomic<int> sender_udp_sock{-1};
std::atomic<int> sender_tcp_sock{-1};
std::atomic<bool> sender_active{false};
// Receiver
TransferState receiver_state;
std::atomic<int> receiver_client_sock{-1};
std::atomic<int> receiver_listen_sock{-1};
std::atomic<int> receiver_bcast_sock{-1};
TransferState receiver_state;
std::atomic<int> receiver_client_sock{-1};
std::atomic<int> receiver_listen_sock{-1};
std::atomic<int> receiver_bcast_sock{-1};
std::atomic<bool> receiver_accept_active{false};
std::atomic<bool> receiver_broadcast_active{false};
pthread_t receiver_bcast_thread{};
pthread_t receiver_bcast_thread{};
// Stored at startReceive, read after network transfer completes
size_t restore_title_index{0};
AccountUid restore_uid{};
size_t restore_title_index{0};
AccountUid restore_uid{};
std::string restore_title_name;
bool restore_ok{false};
bool restore_ok{false};
std::string restore_error;
// Sender thread
struct SenderArgs { TransferService* svc; size_t title_index; AccountUid uid; };
struct SenderArgs {
TransferService* svc;
size_t title_index;
AccountUid uid;
};
static void* senderEntry(void* arg);
void runSender(size_t title_index, AccountUid uid);
void failSend(const std::string& reason);
int findServer(char* out_ip);
void runSender(size_t title_index, AccountUid uid);
void failSend(const std::string& reason);
int findServer(char* out_ip);
// Receiver threads
struct AcceptArgs { TransferService* svc; int server_fd; };
struct AcceptArgs {
TransferService* svc;
int server_fd;
};
static void* broadcastEntry(void* arg);
static void* acceptEntry(void* arg);
void runBroadcast();
void runAccept(int server_fd);
std::string replaceUsername(const std::string& file_path) const;
void runBroadcast();
void runAccept(int server_fd);
std::string replaceUsername(const std::string& file_path) const;
};
} // namespace nxst
} // namespace nxst
+11 -11
View File
@@ -1,18 +1,18 @@
#pragma once
#include <pu/Plutonium>
#include <nxst/ui/theme.hpp>
namespace ui {
class Card {
public:
pu::ui::elm::Rectangle::Ref bg;
class Card {
public:
pu::ui::elm::Rectangle::Ref bg;
Card(pu::ui::Layout* parent, int x, int y, int w, int h,
pu::ui::Color color = theme::color::BgSurface,
int rad = theme::radius::lg) {
bg = pu::ui::elm::Rectangle::New(x, y, w, h, color, rad);
parent->Add(bg);
}
};
}
Card(pu::ui::Layout* parent, int x, int y, int w, int h, pu::ui::Color color = theme::color::BgSurface,
int rad = theme::radius::lg) {
bg = pu::ui::elm::Rectangle::New(x, y, w, h, color, rad);
parent->Add(bg);
}
};
} // namespace ui
+62 -65
View File
@@ -1,86 +1,83 @@
#pragma once
#include <pu/Plutonium>
#include <nxst/domain/account.hpp>
#include <nxst/ui/theme.hpp>
#include <nxst/ui/ui_context.hpp>
#include <nxst/domain/account.hpp>
namespace ui {
class HeaderBar {
private:
pu::ui::elm::Rectangle::Ref bg;
pu::ui::elm::Rectangle::Ref divider;
pu::ui::elm::TextBlock::Ref appName;
pu::ui::elm::TextBlock::Ref subtitle;
pu::ui::elm::Rectangle::Ref chipBg;
pu::ui::elm::Image::Ref avatar;
pu::ui::elm::TextBlock::Ref userName;
class HeaderBar {
private:
pu::ui::elm::Rectangle::Ref bg;
pu::ui::elm::Rectangle::Ref divider;
pu::ui::elm::TextBlock::Ref appName;
pu::ui::elm::TextBlock::Ref subtitle;
pu::ui::elm::Rectangle::Ref chipBg;
pu::ui::elm::Image::Ref avatar;
pu::ui::elm::TextBlock::Ref userName;
public:
HeaderBar(pu::ui::Layout* parent, const std::string& sub = "Save Transfer") {
using namespace theme;
public:
HeaderBar(pu::ui::Layout* parent, const std::string& sub = "Save Transfer") {
using namespace theme;
bg = pu::ui::elm::Rectangle::New(
0, 0, layout::ScreenW, layout::HeaderH, color::BgSurface);
divider = pu::ui::elm::Rectangle::New(
0, layout::HeaderH - 1, layout::ScreenW, 1, color::Divider);
bg = pu::ui::elm::Rectangle::New(0, 0, layout::ScreenW, layout::HeaderH, color::BgSurface);
divider = pu::ui::elm::Rectangle::New(0, layout::HeaderH - 1, layout::ScreenW, 1, color::Divider);
appName = pu::ui::elm::TextBlock::New(space::lg, 8, "NXST");
appName->SetFont(type::font(type::Title));
appName->SetColor(color::TextPrimary);
appName = pu::ui::elm::TextBlock::New(space::lg, 8, "NXST");
appName->SetFont(type::font(type::Title));
appName->SetColor(color::TextPrimary);
subtitle = pu::ui::elm::TextBlock::New(space::lg, 46, sub);
subtitle->SetFont(type::font(type::Caption));
subtitle->SetColor(color::TextMuted);
subtitle = pu::ui::elm::TextBlock::New(space::lg, 46, sub);
subtitle->SetFont(type::font(type::Caption));
subtitle->SetColor(color::TextMuted);
const int chipW = 280;
const int chipX = layout::ScreenW - chipW - space::lg;
chipBg = pu::ui::elm::Rectangle::New(
chipX, 16, chipW, 40,
color::BgSurface2, radius::pill);
chipBg->SetVisible(false);
const int chipW = 280;
const int chipX = layout::ScreenW - chipW - space::lg;
chipBg = pu::ui::elm::Rectangle::New(chipX, 16, chipW, 40, color::BgSurface2, radius::pill);
chipBg->SetVisible(false);
avatar = pu::ui::elm::Image::New(chipX + 4, 20, "");
avatar->SetWidth(32);
avatar->SetHeight(32);
avatar->SetVisible(false);
avatar = pu::ui::elm::Image::New(chipX + 4, 20, "");
avatar->SetWidth(32);
avatar->SetHeight(32);
avatar->SetVisible(false);
userName = pu::ui::elm::TextBlock::New(chipX + 44, 24, "");
userName->SetFont(type::font(type::Body));
userName->SetColor(color::TextPrimary);
userName->SetVisible(false);
userName = pu::ui::elm::TextBlock::New(chipX + 44, 24, "");
userName->SetFont(type::font(type::Body));
userName->SetColor(color::TextPrimary);
userName->SetVisible(false);
parent->Add(bg);
parent->Add(divider);
parent->Add(appName);
parent->Add(subtitle);
parent->Add(chipBg);
parent->Add(avatar);
parent->Add(userName);
}
parent->Add(bg);
parent->Add(divider);
parent->Add(appName);
parent->Add(subtitle);
parent->Add(chipBg);
parent->Add(avatar);
parent->Add(userName);
}
void SetUser(const std::optional<AccountUid>& uid, const std::string& name) {
const bool show = uid.has_value();
chipBg->SetVisible(show);
userName->SetVisible(show);
if (show) {
userName->SetText(name);
std::string path = Account::iconPath(*uid);
if (!path.empty()) {
avatar->SetImage(path);
avatar->SetWidth(32);
avatar->SetHeight(32);
avatar->SetVisible(avatar->IsImageValid());
} else {
avatar->SetVisible(false);
}
void SetUser(const std::optional<AccountUid>& uid, const std::string& name) {
const bool show = uid.has_value();
chipBg->SetVisible(show);
userName->SetVisible(show);
if (show) {
userName->SetText(name);
std::string path = Account::iconPath(*uid);
if (!path.empty()) {
avatar->SetImage(path);
avatar->SetWidth(32);
avatar->SetHeight(32);
avatar->SetVisible(avatar->IsImageValid());
} else {
avatar->SetVisible(false);
}
} else {
avatar->SetVisible(false);
}
}
void SetSubtitle(const std::string& text) {
subtitle->SetText(text);
}
};
}
void SetSubtitle(const std::string& text) {
subtitle->SetText(text);
}
};
} // namespace ui
+48 -47
View File
@@ -1,55 +1,56 @@
#pragma once
#include <pu/Plutonium>
#include <nxst/ui/theme.hpp>
#include <vector>
#include <string>
#include <vector>
#include <pu/Plutonium>
#include <nxst/ui/theme.hpp>
namespace ui {
struct Hint {
std::string glyph;
std::string label;
};
struct Hint {
std::string glyph;
std::string label;
};
class HintBar {
private:
pu::ui::Layout* parent;
pu::ui::elm::Rectangle::Ref bg;
pu::ui::elm::Rectangle::Ref divider;
std::vector<pu::ui::elm::TextBlock::Ref> labels;
class HintBar {
private:
pu::ui::Layout* parent;
pu::ui::elm::Rectangle::Ref bg;
pu::ui::elm::Rectangle::Ref divider;
std::vector<pu::ui::elm::TextBlock::Ref> labels;
public:
HintBar(pu::ui::Layout* p) : parent(p) {
using namespace theme;
bg = pu::ui::elm::Rectangle::New(
0, layout::ScreenH - layout::HintH,
layout::ScreenW, layout::HintH, color::BgSurface);
divider = pu::ui::elm::Rectangle::New(
0, layout::ScreenH - layout::HintH,
layout::ScreenW, 1, color::Divider);
parent->Add(bg);
parent->Add(divider);
public:
HintBar(pu::ui::Layout* p) : parent(p) {
using namespace theme;
bg = pu::ui::elm::Rectangle::New(0, layout::ScreenH - layout::HintH, layout::ScreenW, layout::HintH,
color::BgSurface);
divider = pu::ui::elm::Rectangle::New(0, layout::ScreenH - layout::HintH, layout::ScreenW, 1,
color::Divider);
parent->Add(bg);
parent->Add(divider);
}
void SetHints(const std::vector<Hint>& hints) {
using namespace theme;
for (auto& l : labels)
l->SetVisible(false);
labels.clear();
int x = layout::ScreenW - space::lg;
int y = layout::ScreenH - layout::HintH + 18;
for (auto it = hints.rbegin(); it != hints.rend(); ++it) {
std::string text = it->glyph + " " + it->label;
auto tb = pu::ui::elm::TextBlock::New(0, y, text);
tb->SetFont(type::font(type::Label));
tb->SetColor(color::TextSecondary);
int w = tb->GetWidth();
x -= w;
tb->SetX(x);
x -= space::xl;
parent->Add(tb);
labels.push_back(tb);
}
void SetHints(const std::vector<Hint>& hints) {
using namespace theme;
for (auto& l : labels) l->SetVisible(false);
labels.clear();
int x = layout::ScreenW - space::lg;
int y = layout::ScreenH - layout::HintH + 18;
for (auto it = hints.rbegin(); it != hints.rend(); ++it) {
std::string text = it->glyph + " " + it->label;
auto tb = pu::ui::elm::TextBlock::New(0, y, text);
tb->SetFont(type::font(type::Label));
tb->SetColor(color::TextSecondary);
int w = tb->GetWidth();
x -= w;
tb->SetX(x);
x -= space::xl;
parent->Add(tb);
labels.push_back(tb);
}
}
};
}
}
};
} // namespace ui
+64 -63
View File
@@ -1,78 +1,79 @@
#pragma once
#include <pu/Plutonium>
#include <string>
#include <pu/Plutonium>
namespace theme {
using pu::ui::Color;
using pu::ui::Color;
namespace color {
constexpr Color BgBase{0x10, 0x14, 0x1C, 0xFF};
constexpr Color BgSurface{0x18, 0x1F, 0x2A, 0xFF};
constexpr Color BgSurface2{0x22, 0x2B, 0x39, 0xFF};
constexpr Color Scrim{0x00, 0x00, 0x00, 0xB8};
namespace color {
constexpr Color BgBase{0x10, 0x14, 0x1C, 0xFF};
constexpr Color BgSurface{0x18, 0x1F, 0x2A, 0xFF};
constexpr Color BgSurface2{0x22, 0x2B, 0x39, 0xFF};
constexpr Color Scrim{0x00, 0x00, 0x00, 0xB8};
constexpr Color Primary{0xE2, 0x4B, 0x55, 0xFF};
constexpr Color PrimaryDim{0x9C, 0x33, 0x3A, 0xFF};
constexpr Color Accent{0x4A, 0xC2, 0xE0, 0xFF};
constexpr Color Primary{0xE2, 0x4B, 0x55, 0xFF};
constexpr Color PrimaryDim{0x9C, 0x33, 0x3A, 0xFF};
constexpr Color Accent{0x4A, 0xC2, 0xE0, 0xFF};
constexpr Color TextPrimary{0xF2, 0xF4, 0xF8, 0xFF};
constexpr Color TextSecondary{0xB6, 0xBE, 0xCB, 0xFF};
constexpr Color TextMuted{0x70, 0x7A, 0x8C, 0xFF};
constexpr Color TextPrimary{0xF2, 0xF4, 0xF8, 0xFF};
constexpr Color TextSecondary{0xB6, 0xBE, 0xCB, 0xFF};
constexpr Color TextMuted{0x70, 0x7A, 0x8C, 0xFF};
constexpr Color Success{0x55, 0xC8, 0x8A, 0xFF};
constexpr Color Error{0xE0, 0x6C, 0x6C, 0xFF};
constexpr Color Warning{0xE6, 0xB4, 0x55, 0xFF};
constexpr Color Success{0x55, 0xC8, 0x8A, 0xFF};
constexpr Color Error{0xE0, 0x6C, 0x6C, 0xFF};
constexpr Color Warning{0xE6, 0xB4, 0x55, 0xFF};
constexpr Color Divider{0x2A, 0x33, 0x42, 0xFF};
constexpr Color FocusRing{0xE2, 0x4B, 0x55, 0xFF};
}
constexpr Color Divider{0x2A, 0x33, 0x42, 0xFF};
constexpr Color FocusRing{0xE2, 0x4B, 0x55, 0xFF};
} // namespace color
namespace space {
constexpr int xs = 4;
constexpr int sm = 8;
constexpr int md = 16;
constexpr int lg = 24;
constexpr int xl = 32;
constexpr int xxl = 48;
}
namespace space {
constexpr int xs = 4;
constexpr int sm = 8;
constexpr int md = 16;
constexpr int lg = 24;
constexpr int xl = 32;
constexpr int xxl = 48;
} // namespace space
namespace radius {
constexpr int sm = 6;
constexpr int md = 12;
constexpr int lg = 20;
constexpr int pill = 9999;
}
namespace radius {
constexpr int sm = 6;
constexpr int md = 12;
constexpr int lg = 20;
constexpr int pill = 9999;
} // namespace radius
namespace type {
constexpr int Display = 38;
constexpr int Title = 30;
constexpr int Body = 25;
constexpr int Label = 20;
constexpr int Caption = 18;
namespace type {
constexpr int Display = 38;
constexpr int Title = 30;
constexpr int Body = 25;
constexpr int Label = 20;
constexpr int Caption = 18;
inline std::string font(int size) {
return "DefaultFont@" + std::to_string(size);
}
}
namespace layout {
constexpr int ScreenW = 1280;
constexpr int ScreenH = 720;
constexpr int HeaderH = 72;
constexpr int HintH = 56;
constexpr int ContentTop = HeaderH;
constexpr int ContentH = ScreenH - HeaderH - HintH;
}
namespace motion {
constexpr int FadeFrames = 20;
constexpr int SlideFrames = 14;
constexpr int SpinnerFrames = 72;
}
namespace font {
constexpr const char* Default = "Inter";
constexpr const char* Medium = "InterMedium";
}
inline std::string font(int size) {
return "DefaultFont@" + std::to_string(size);
}
} // namespace type
namespace layout {
constexpr int ScreenW = 1280;
constexpr int ScreenH = 720;
constexpr int HeaderH = 72;
constexpr int HintH = 56;
constexpr int ContentTop = HeaderH;
constexpr int ContentH = ScreenH - HeaderH - HintH;
} // namespace layout
namespace motion {
constexpr int FadeFrames = 20;
constexpr int SlideFrames = 14;
constexpr int SpinnerFrames = 72;
} // namespace motion
namespace font {
constexpr const char* Default = "Inter";
constexpr const char* Medium = "InterMedium";
} // namespace font
} // namespace theme
+48 -44
View File
@@ -1,59 +1,63 @@
#pragma once
#include <pu/Plutonium>
#include <nxst/ui/const.h>
#include <nxst/domain/title.hpp>
#include <nxst/domain/account.hpp>
#include <memory>
#include <unordered_map>
#include <vector>
#include <memory>
#include <pu/Plutonium>
#include <nxst/domain/account.hpp>
#include <nxst/domain/title.hpp>
#include <nxst/ui/const.h>
#include <nxst/ui/header_bar.hpp>
#include <nxst/ui/hint_bar.hpp>
namespace ui {
enum class TitlesFocus { List, Actions };
enum class TitlesAction { Transfer, Receive };
enum class TitlesFocus { List, Actions };
enum class TitlesAction { Transfer, Receive };
class TitlesLayout : public pu::ui::Layout {
private:
class TitlesLayout : public pu::ui::Layout {
private:
pu::ui::elm::Menu::Ref titlesMenu;
std::unordered_map<AccountUid, std::vector<pu::ui::elm::MenuItem::Ref>> menuCache;
bool m_inputLocked = false;
std::unique_ptr<HeaderBar> header;
std::unique_ptr<HintBar> hints;
pu::ui::elm::Menu::Ref titlesMenu;
std::unordered_map<AccountUid, std::vector<pu::ui::elm::MenuItem::Ref>> menuCache;
bool m_inputLocked = false;
std::unique_ptr<HeaderBar> header;
std::unique_ptr<HintBar> hints;
pu::ui::elm::Rectangle::Ref panelBg;
pu::ui::elm::TextBlock::Ref panelTitle;
pu::ui::elm::TextBlock::Ref panelHint;
pu::ui::elm::Rectangle::Ref btnTransferBg;
pu::ui::elm::TextBlock::Ref btnTransferText;
pu::ui::elm::Rectangle::Ref btnReceiveBg;
pu::ui::elm::TextBlock::Ref btnReceiveText;
pu::ui::elm::TextBlock::Ref panelFooter;
pu::ui::elm::TextBlock::Ref emptyText;
pu::ui::elm::TextBlock::Ref emptySub;
pu::ui::elm::Rectangle::Ref panelBg;
pu::ui::elm::TextBlock::Ref panelTitle;
pu::ui::elm::TextBlock::Ref panelHint;
pu::ui::elm::Rectangle::Ref btnTransferBg;
pu::ui::elm::TextBlock::Ref btnTransferText;
pu::ui::elm::Rectangle::Ref btnReceiveBg;
pu::ui::elm::TextBlock::Ref btnReceiveText;
pu::ui::elm::TextBlock::Ref panelFooter;
pu::ui::elm::TextBlock::Ref emptyText;
pu::ui::elm::TextBlock::Ref emptySub;
AccountUid current_uid{};
TitlesFocus focus = TitlesFocus::List;
TitlesAction action = TitlesAction::Transfer;
int lockedListIndex = 0;
AccountUid current_uid{};
TitlesFocus focus = TitlesFocus::List;
TitlesAction action = TitlesAction::Transfer;
int lockedListIndex = 0;
void refreshPanel();
void refreshButtons();
void updateHints();
void runTransfer(int index, Title& title);
void runReceive(int index, Title& title);
void refreshPanel();
void refreshButtons();
void updateHints();
void runTransfer(int index, Title& title);
void runReceive(int index, Title& title);
public:
TitlesLayout();
void InitTitles(AccountUid uid);
void LockInput() {
m_inputLocked = true;
}
void UnlockInput() {
m_inputLocked = false;
}
public:
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos);
TitlesLayout();
void InitTitles(AccountUid uid);
void LockInput() { m_inputLocked = true; }
void UnlockInput() { m_inputLocked = false; }
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos);
PU_SMART_CTOR(TitlesLayout)
};
}
PU_SMART_CTOR(TitlesLayout)
};
} // namespace ui
+63 -73
View File
@@ -1,94 +1,84 @@
#pragma once
#include <pu/Plutonium>
#include <nxst/ui/theme.hpp>
#include <nxst/domain/util.hpp>
#include <nxst/ui/theme.hpp>
namespace ui {
class TransferOverlay : public pu::ui::Overlay {
private:
pu::ui::elm::Rectangle::Ref card;
pu::ui::elm::TextBlock::Ref titleText;
pu::ui::elm::TextBlock::Ref statusText;
pu::ui::elm::Rectangle::Ref progressTrack;
pu::ui::elm::ProgressBar::Ref progressBar;
pu::ui::elm::TextBlock::Ref indeterminateText;
pu::ui::elm::TextBlock::Ref hintText;
class TransferOverlay : public pu::ui::Overlay {
private:
pu::ui::elm::Rectangle::Ref card;
pu::ui::elm::TextBlock::Ref titleText;
pu::ui::elm::TextBlock::Ref statusText;
pu::ui::elm::Rectangle::Ref progressTrack;
pu::ui::elm::ProgressBar::Ref progressBar;
pu::ui::elm::TextBlock::Ref indeterminateText;
pu::ui::elm::TextBlock::Ref hintText;
static constexpr int CardW = 720;
static constexpr int CardH = 360;
static constexpr int CardX = (theme::layout::ScreenW - CardW) / 2;
static constexpr int CardY = (theme::layout::ScreenH - CardH) / 2;
static constexpr int CardW = 720;
static constexpr int CardH = 360;
static constexpr int CardX = (theme::layout::ScreenW - CardW) / 2;
static constexpr int CardY = (theme::layout::ScreenH - CardH) / 2;
public:
TransferOverlay(const std::string &title)
: Overlay(0, 0, theme::layout::ScreenW, theme::layout::ScreenH, theme::color::Scrim)
{
using namespace theme;
public:
TransferOverlay(const std::string& title)
: Overlay(0, 0, theme::layout::ScreenW, theme::layout::ScreenH, theme::color::Scrim) {
using namespace theme;
card = pu::ui::elm::Rectangle::New(
CardX, CardY, CardW, CardH, color::BgSurface, radius::lg);
card = pu::ui::elm::Rectangle::New(CardX, CardY, CardW, CardH, color::BgSurface, radius::lg);
titleText = pu::ui::elm::TextBlock::New(
CardX + space::lg, CardY + space::lg, title);
titleText->SetFont(type::font(type::Title));
titleText->SetColor(color::TextPrimary);
titleText = pu::ui::elm::TextBlock::New(CardX + space::lg, CardY + space::lg, title);
titleText->SetFont(type::font(type::Title));
titleText->SetColor(color::TextPrimary);
statusText = pu::ui::elm::TextBlock::New(
CardX + space::lg,
CardY + space::lg + 56,
"");
statusText->SetFont(type::font(type::Body));
statusText->SetColor(color::TextSecondary);
statusText = pu::ui::elm::TextBlock::New(CardX + space::lg, CardY + space::lg + 56, "");
statusText->SetFont(type::font(type::Body));
statusText->SetColor(color::TextSecondary);
int barX = CardX + space::lg;
int barY = CardY + space::lg + 56 + 56;
int barW = CardW - 2 * space::lg;
int barX = CardX + space::lg;
int barY = CardY + space::lg + 56 + 56;
int barW = CardW - 2 * space::lg;
progressTrack = pu::ui::elm::Rectangle::New(
barX, barY, barW, 8, color::Divider, radius::sm);
progressTrack = pu::ui::elm::Rectangle::New(barX, barY, barW, 8, color::Divider, radius::sm);
progressBar = pu::ui::elm::ProgressBar::New(
barX, barY, barW, 8, 100.0);
progressBar->SetProgressColor(color::Primary);
progressBar->SetBackgroundColor(color::Divider);
progressBar = pu::ui::elm::ProgressBar::New(barX, barY, barW, 8, 100.0);
progressBar->SetProgressColor(color::Primary);
progressBar->SetBackgroundColor(color::Divider);
indeterminateText = pu::ui::elm::TextBlock::New(
barX, barY - 4, "Preparing transfer...");
indeterminateText->SetFont(type::font(type::Body));
indeterminateText->SetColor(color::TextMuted);
indeterminateText->SetVisible(false);
indeterminateText = pu::ui::elm::TextBlock::New(barX, barY - 4, "Preparing transfer...");
indeterminateText->SetFont(type::font(type::Body));
indeterminateText->SetColor(color::TextMuted);
indeterminateText->SetVisible(false);
hintText = pu::ui::elm::TextBlock::New(
CardX + space::lg,
CardY + CardH - space::lg - 18,
"B to cancel");
hintText->SetFont(type::font(type::Caption));
hintText->SetColor(color::TextMuted);
hintText =
pu::ui::elm::TextBlock::New(CardX + space::lg, CardY + CardH - space::lg - 18, "B to cancel");
hintText->SetFont(type::font(type::Caption));
hintText->SetColor(color::TextMuted);
this->Add(card);
this->Add(titleText);
this->Add(statusText);
this->Add(progressTrack);
this->Add(progressBar);
this->Add(indeterminateText);
this->Add(hintText);
}
PU_SMART_CTOR(TransferOverlay)
this->Add(card);
this->Add(titleText);
this->Add(statusText);
this->Add(progressTrack);
this->Add(progressBar);
this->Add(indeterminateText);
this->Add(hintText);
}
PU_SMART_CTOR(TransferOverlay)
void SetStatus(const std::string &status) {
statusText->SetText(StringUtils::elide(status, 56));
}
void SetStatus(const std::string& status) {
statusText->SetText(StringUtils::elide(status, 56));
}
void SetProgress(double val) {
progressBar->SetProgress(val);
}
void SetProgress(double val) {
progressBar->SetProgress(val);
}
void SetProgressVisible(bool visible) {
progressTrack->SetVisible(visible);
progressBar->SetVisible(visible);
indeterminateText->SetVisible(!visible);
}
};
void SetProgressVisible(bool visible) {
progressTrack->SetVisible(visible);
progressBar->SetVisible(visible);
indeterminateText->SetVisible(!visible);
}
};
}
} // namespace ui
+8 -6
View File
@@ -1,12 +1,14 @@
#pragma once
#include <string>
#include <optional>
#include <string>
#include <switch.h>
#include <nxst/domain/account.hpp>
namespace ui {
struct UiContext {
std::optional<AccountUid> selectedUser;
std::string selectedUserName;
};
}
struct UiContext {
std::optional<AccountUid> selectedUser;
std::string selectedUserName;
};
} // namespace ui
+17 -18
View File
@@ -1,29 +1,28 @@
#include <memory>
#include <pu/Plutonium>
#include <nxst/ui/const.h>
#include <nxst/ui/header_bar.hpp>
#include <nxst/ui/hint_bar.hpp>
#include <memory>
namespace ui {
class UsersLayout : public pu::ui::Layout {
private:
class UsersLayout : public pu::ui::Layout {
private:
pu::ui::elm::Menu::Ref usersMenu;
pu::ui::elm::Rectangle::Ref loadingBg;
pu::ui::elm::TextBlock::Ref loadingText;
std::unique_ptr<HeaderBar> header;
std::unique_ptr<HintBar> hints;
pu::ui::elm::Menu::Ref usersMenu;
pu::ui::elm::Rectangle::Ref loadingBg;
pu::ui::elm::TextBlock::Ref loadingText;
std::unique_ptr<HeaderBar> header;
std::unique_ptr<HintBar> hints;
public:
UsersLayout();
public:
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos);
UsersLayout();
int32_t GetCurrentIndex();
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos);
int32_t GetCurrentIndex();
PU_SMART_CTOR(UsersLayout)
};
}
PU_SMART_CTOR(UsersLayout)
};
} // namespace ui