Play your Steam library's Windows games on a jailbroken PS5.
C++
Add Import games screens and document them
Leonardo Lobato003176cfa7c2
diff --git a/COMPATIBILITY.md b/COMPATIBILITY.mdindex c8f02a9..8493104 100644--- a/COMPATIBILITY.md+++ b/COMPATIBILITY.md@@ -206,3 +206,4 @@ To see which kit your console has, run the [log script](tools/collect_logs.py):- **Denuvo Anti-Tamper** games (for example Hi-Fi RUSH) cannot run, and support is not planned.- **Kernel anti-cheat** games (for example Easy Anti-Cheat or BattlEye in kernel mode) cannot run.- Games that need a **third-party launcher or account** (EA app, Ubisoft Connect, Rockstar) are not supported yet.+- **Imported games** (added from a folder, see [Import Windows games](README.md#import-windows-games)) are not in this list. If you test one, [open a test report](../../issues/new?template=test-report.yml) and say it was imported.diff --git a/README.md b/README.mdindex 5053880..92df5f9 100644--- a/README.md+++ b/README.md@@ -42,6 +42,8 @@ private Windows environment and its own tile on the PS5 Home screen.with rumble. Games see the DualSense as an Xbox controller.- **Mouse and keyboard.** Plug a USB mouse and keyboard into the PS5, or use a controller preset: the left stick as amouse, or the D-pad as the arrow keys.+- **Import Windows games.** Add game folders you already have, from a USB drive, an M.2 SSD or over FTP. No Steam+ account is needed. See [Import Windows games](#import-windows-games).- **Install to internal or external disks.** Console storage, or an exFAT USB drive formatted on a Mac or PC.See the [compatibility list](COMPATIBILITY.md) for the games we have tested.@@ -87,7 +89,7 @@ you sign in:- For installing and updating Playden: an FTP server such as [zftpd](https://github.com/seregonwar/zftpd)(port 2120), and optionally [ps5-web-file-manager](https://github.com/owendswang/ps5-web-file-manager)(port 8888).-- **A Steam account** with Windows games.+- **Windows games:** a Steam account with games, or game folders you already have (see [Import Windows games](#import-windows-games)).- **A computer with Python 3** on the same network as the PS5, to copy Playden and the kit to it.- **To build it yourself (optional):** a Mac with Apple Silicon. Linux should also work, but we have not tested ityet. See [Build from source](#build-from-source).@@ -160,6 +162,9 @@ version opens again, it says so and puts its kit back. If the new version itselfdescribed above (your games, sign-in and settings are kept), and put the previous kit folder back in place of`hl2-fw1360-dev1` if the new kit is at fault.+After the version that added import, going back to an older version keeps your old favorites, but loses the favorites+and collections you changed since. The console's organization data now lives in one file that older versions don't read.+You can also update by hand: run the install command without `--install`. It copies only the changed files, keeps abackup of what it replaced, and puts those three folders' modes right if they changed.@@ -194,6 +199,43 @@ private. With it, you can read and write everything in `prospero`. The folders alisted, so type the full path in your FTP client instead of browsing to it. New saves a game writes are privateat first. Playden opens them to FTP when it starts, when a game it started ends, and before it starts a game.+## Import Windows games++You can add Windows games you already have, without a Steam account.++**Put the game folders in place:**++- On an exFAT USB drive or M.2 SSD, in `playden/import/<game folder>` at the root of the drive.+- Or over FTP, in `/data/playden-import/<game folder>` on the console.++The drive must be exFAT. The PS5 can't read NTFS, and FAT32 can't hold files over 4 GB.++**Add a game:**++1. Open **Import games**: on the Startup screen, on Home when your library is empty, or in Settings › Storage.+2. Choose **Look for games**. Playden lists the folders it finds, with their size.+3. Pick a folder, then pick the program that starts the game. Installers and tools are labelled as such.+4. Choose how to play it:+ - **Play from the drive** (or from the drop folder): nothing is copied. The drive must stay plugged in.+ - **Copy into Playden:** copies the game to Playden's games folder. The console copies about 11 MB/s, so a large+ game takes a while.+ - **Move into Playden:** for the drop folder only. It is instant.++The PS5 adds the game's title to Home when Playden quits. Copying or moving a game later keeps its saves.++**Limits:**++- To play from where it is, the folder's path must be plain ASCII. Otherwise, copy the game.+- Playden refuses a game folder that holds links.+- Removing an imported game from the library leaves its files, and keeps its saves.+- Cloud saves are only for Steam games.++**Steam games copied from a PC** usually run without Steam. If a game needs Steam, Playden uses the game's+`steam_appid.txt`, or the **Steam app ID** in Game settings. Most games run without either.++Games that need their own launcher, or DRM beyond SteamStub (Denuvo, or the Ubisoft, EA or Rockstar launchers), won't+run.+## Build from source### What you needdiff --git a/docs/community-recipes.md b/docs/community-recipes.mdindex 3fdc8dc..bbac132 100644--- a/docs/community-recipes.md+++ b/docs/community-recipes.md@@ -87,6 +87,21 @@ contributions until it is.Applying community recipes from the preset chooser is planned.+## Other stores++A recipe can name a game that is not from Steam, with two more fields:++```json+"store": "local",+"game": "local-<uuid>"+```++Give both or neither; a file with only one is refused, as is an unknown `store`. `local` is the only store so far: it+is a game imported from a folder. Without them, the recipe is for the Steam game `app_id`, as before.++An imported game is keyed by its local ID, which Playden makes when you add it, so a recipe for one only fits the+console that exported it. Community recipes still target Steam games.+## Registry valuesUse `registry` only for a value the game reads from the registry and that nodiff --git a/src/homebrew/browse.cpp b/src/homebrew/browse.cppindex 918552c..0a21863 100644--- a/src/homebrew/browse.cpp+++ b/src/homebrew/browse.cpp@@ -123,6 +123,8 @@ std::vector<const Game*> filtered_games(const State& state)continue;if (state.library.scope == "hidden" && !state.library.hidden.contains(game.id))continue;+ if (state.library.scope == "imported" && game.id.store != Store::kLocal)+ continue;if (collection != nullptr && !collection->members.contains(game.id))continue;if (state.library.scope != "hidden" && state.library.hidden.contains(game.id))@@ -265,9 +267,17 @@ ShelfWindow shelf_window(int item_count, int focused_item, int capacity) noexcepreturn {first, count};}+bool has_imported_games(const State& state)+{+ return std::any_of(state.games.begin(), state.games.end(),+ [](const Game& game) { return game.id.store == Store::kLocal; });+}+std::vector<std::string> library_rail_scopes(const State& state){std::vector<std::string> result{"installed", "all", "favorites", "hidden"};+ if (has_imported_games(state))+ result.push_back("imported");for (const Collection& collection : state.library.collections)result.push_back(collection.id);result.push_back("new-collection");@@ -279,8 +289,9 @@ bool move_browser(State& state, int delta_x, int delta_y)if (state.navigation.route == Route::Home){const std::vector<Shelf> projected = shelves(state);+ // No shelves: Home's empty state has only its buttons, which Up and Down step through.if (projected.empty())- return true;+ return false;int shelf_index = std::clamp(state.navigation.home_shelf, 0,static_cast<int>(projected.size()) - 1);int child = std::clamp(state.navigation.home_shelf_focus[projected[static_cast<std::size_t>(shelf_index)].key],diff --git a/src/homebrew/browse.hpp b/src/homebrew/browse.hppindex 231aaef..7eaac17 100644--- a/src/homebrew/browse.hpp+++ b/src/homebrew/browse.hpp@@ -38,6 +38,8 @@ struct ShelfWindow {[[nodiscard]] ShelfWindow shelf_window(int item_count, int focused_item,int capacity = 7) noexcept;[[nodiscard]] std::vector<std::string> library_rail_scopes(const State& state);+// The library has games imported from a drive or the drop folder: the rail shows "Imported".+[[nodiscard]] bool has_imported_games(const State& state);// Moves only Home and Library browse focus. Returning true means the route// consumed the direction even when focus was already against an edge.diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cppindex 447a082..7e6aa51 100644--- a/src/homebrew/controller.cpp+++ b/src/homebrew/controller.cpp@@ -1095,6 +1095,11 @@ void Controller::TickRuntime() {std::vector<LiveRuntimeGame> games;for (const auto& [id, root] : game_roots_) {LiveRuntimeGame game; game.game_id = id;+ // The Steam app ID its Steamworks emulator was given, for Game settings' "Steam app ID".+ if (const auto steam_app = snapshot.steamworks_apps.find(NumberIn(snapshot, id)); steam_app != snapshot.steamworks_apps.end()) {+ game.steam_app_id = steam_app->second.app_id;+ game.steam_app_from_game_file = steam_app->second.source == SteamworksAppView::Source::kGameFile;+ }const RuntimeInstallView* record = nullptr;for (const auto& view : snapshot.installs) if (view.game == id) record = &view;const auto refusal = snapshot.refusals.find(NumberIn(snapshot, id));@@ -1380,10 +1385,16 @@ void Controller::TickImports() {if (!local_) return;// The locations reflect a Local snapshot once one was seen on an earlier tick (TickInstalls projects them).const bool locations_known = local_revision_ != 0;+ const auto track = [this](std::uint64_t number, const ImportRequest& request) {+ if (number == 0) return;+ import_requests_[number] = request;+ // Outcomes are kept for the latest requests only: one never answered is dropped with the oldest.+ while (import_requests_.size() > stores::local::LocalLibrarySource::kMaxOutcomes * 2) import_requests_.erase(import_requests_.begin());+ };for (const auto& request : model_.TakeImportRequests()) {switch (request.kind) {case ImportRequestKind::LookForGames: local_->LookForGames(); break;- case ImportRequestKind::Add: local_->Add(request.volume_id, request.folder, request.program); break;+ case ImportRequestKind::Add: track(local_->Add(request.volume_id, request.folder, request.program), request); break;case ImportRequestKind::Remove:if (request.game_id.store == Store::kLocal) held_import_removals_.push_back(request.game_id);break;@@ -1392,13 +1403,13 @@ void Controller::TickImports() {// The copy's install record carries the game's runtime number (given out now if it has// none); a game set up from its drive folder keeps its PS5 title, which follows the copy.const auto number = runtime_ ? RuntimeApp(*runtime_, request.game_id).value_or(0u) : 0u;- local_->CopyIntoPlayden(request.game_id.value, request.volume_id, number);+ track(local_->CopyIntoPlayden(request.game_id.value, request.volume_id, number), request);}break;case ImportRequestKind::MoveIntoPlayden:if (request.game_id.store == Store::kLocal) {const auto number = runtime_ ? RuntimeApp(*runtime_, request.game_id).value_or(0u) : 0u;- local_->MoveIntoPlayden(request.game_id.value, number);+ track(local_->MoveIntoPlayden(request.game_id.value, number), request);}break;}@@ -1407,7 +1418,7 @@ void Controller::TickImports() {for (const auto& id : std::exchange(held_import_removals_, {})) {// A game with a folder to play from goes like an uninstall: its PS5 title first.if (LocationOf(id)) BeginUninstall(id, false);- else local_->Remove(id.value);+ else track(local_->Remove(id.value), {ImportRequestKind::Remove, id});}// A drive plugged in or out: its games become (un)available and its folders are looked at.const auto now = std::chrono::steady_clock::now();@@ -1416,6 +1427,14 @@ void Controller::TickImports() {local_volumes_checked_at_ = now;}const auto snapshot = local_->Snapshot();+ // Requests the store answered: a refusal is said to the player, not only logged.+ for (auto it = import_requests_.begin(); it != import_requests_.end();) {+ const auto outcome = std::find_if(snapshot->outcomes.begin(), snapshot->outcomes.end(),+ [&](const stores::local::ImportOutcome& o) { return o.request == it->first; });+ if (outcome == snapshot->outcomes.end()) { ++it; continue; }+ if (!outcome->ok) model_.NotifyImportFailed(it->second, outcome->message);+ it = import_requests_.erase(it);+ }// Once imports.json is read: copies that finished or stopped while Playden was closed are settled.// A move a restart interrupted is finished then too, once the runtime has started (its PS5 title// follows the folder).diff --git a/src/homebrew/controller.hpp b/src/homebrew/controller.hppindex aca5e5e..ee1fbf3 100644--- a/src/homebrew/controller.hpp+++ b/src/homebrew/controller.hpp@@ -139,6 +139,9 @@ class Controller {// Removals asked for before the Local store's first snapshot reached the locations: until then a// game's folder (and so its PS5 title's removal first) isn't known.std::vector<GameId> held_import_removals_;+ // The player's add, copy, move and removal requests sent to the Local store, by request number,+ // until their outcome: a refusal reaches the model as a notice.+ std::map<std::uint64_t, ImportRequest> import_requests_;// Copies into Playden were reconciled with the install service after the first imports.json read.bool copies_reconciled_ = false;// Play and Prepare of a game playing from the drop folder wait for its files to be openeddiff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cppindex 9a264a5..3a0c6e1 100644--- a/src/homebrew/simulation.cpp+++ b/src/homebrew/simulation.cpp@@ -455,7 +455,7 @@ std::string action_label(const std::string& key) {static const std::map<std::string, std::string> labels = {{"cancel", "Cancel"}, {"confirm-destructive", "Confirm"}, {"ready-later", "Later"}, {"alert-ok", "OK"}, {"alert-settings", "Game settings"}, {"runtime-cleanup-confirm", "Clean up"}, {"quit-to-home", "Play"}, {"favorite", "Favorite"},{"collection", "Collections"}, {"note", "Compatibility and note"}, {"verify", "Verify files"},- {"uninstall", "Uninstall"}, {"uninstall-delete-saves", "Delete saves too"}, {"logs", "Open logs"}, {"logs-back", "Back"},+ {"uninstall", "Uninstall"}, {"import-remove", "Remove from library"}, {"uninstall-delete-saves", "Delete saves too"}, {"logs", "Open logs"}, {"logs-back", "Back"},{"logs-pick", "Logs"}, {"log-install", "Install log"}, {"log-auth", "Sign-in log"},{"log-launch", "Launch log"}, {"log-cloud", "Cloud saves log"}, {"logs-refresh", "Refresh"},{"cloud-sync", "Cloud saves"}, {"cloud-choose", "Cloud saves"}, {"cloud-use-cloud", "Use Cloud saves"},@@ -607,6 +607,66 @@ void replay_organization_delta(playden::OrganizationSnapshot& base,base.selected_game_id = after.selected_game_id;}+// The Import sheet's drive groups, in the order it lists them (ImportRoots' volume ids).+constexpr std::array<std::pair<const char*, const char*>, 5> kImportGroups = {{+ {"usb0", "USB drive"}, {"usb1", "USB drive 2"}, {"m2", "M.2 SSD"}, {"extended", "Extended storage"},+ {"internal", "Console drop folder"}}};+constexpr const char* kImportEmptyText =+ "Copy game folders into playden/import on an exFAT drive, or into /data/playden-import over FTP, then choose "+ "Look for games.";+constexpr const char* kImportCopyOnlyText =+ "This folder's name has characters the PS5 can't start a game from. Copy it into Playden instead.";++constexpr const char* kImportDropVolume = "internal";+++// A drive's name as the Import sheet groups it ("USB drive", "Console drop folder").+std::string import_volume_name(const std::string& volume) {+ for (const auto& [id, name] : kImportGroups)+ if (volume == id) return name;+ return volume;+}++// How long a copy takes at the console's copy speed (about 11 MB/s): "about 14 min".+std::string import_copy_estimate(std::uint64_t bytes) {+ constexpr std::uint64_t kBytesPerSecond = 11'000'000;+ const auto minutes = std::max<std::uint64_t>(1, (bytes / kBytesPerSecond + 59) / 60);+ if (minutes <= 90) return "about " + std::to_string(minutes) + " min";+ return "about " + std::to_string((minutes + 30) / 60) + " h";+}++std::string import_candidate_key(const LiveImportCandidate& candidate) {+ return "import-candidate-" + candidate.volume_id + ":" + candidate.folder;+}++// Fixture mode: what Look for games finds (one game added already, one copy only, one without a program).+std::vector<LiveImportCandidate> fixture_import_candidates() {+ std::vector<LiveImportCandidate> candidates;+ const auto add = [&](std::string volume, std::string folder, std::string path, std::string title,+ std::uint64_t bytes, bool ascii_ok, std::vector<LiveImportProgram> programs) {+ LiveImportCandidate candidate;+ candidate.volume_id = std::move(volume); candidate.folder = std::move(folder); candidate.path = std::move(path);+ candidate.title = std::move(title); candidate.total_bytes = bytes; candidate.ascii_ok = ascii_ok;+ candidate.programs = std::move(programs);+ candidates.push_back(std::move(candidate));+ };+ add("usb0", "playden/import/Night Sky", "/mnt/usb0/playden/import/Night Sky", "Night Sky", 412'000'000, true,+ {{"NightSky.exe", 18'000'000, false}});+ add("usb0", "playden/import/Old School Rally", "/mnt/usb0/playden/import/Old School Rally", "Old School Rally",+ 938'000'000, true, {{"OldSchoolRally.exe", 640'000'000, false}, {"UnityCrashHandler64.exe", 1'400'000, true}});+ add("usb0", "playden/import/Café Étoile", "/mnt/usb0/playden/import/Café Étoile", "Café Étoile", 1'250'000'000,+ false, {{"CafeEtoile.exe", 96'000'000, false}, {"redist/vcredist_x64.exe", 14'000'000, true}});+ add("m2", "playden/import/Delores", "/mnt/ext1/playden/import/Delores", "Delores", 230'000'000, true,+ {{"Delores.exe", 9'000'000, false}});+ add("internal", "playden-import/Hollow Knight", "/data/playden-import/Hollow Knight", "Hollow Knight",+ 8'900'000'000, true, {{"hollow_knight.exe", 650'000, false}});+ add("internal", "playden-import/Tools", "/data/playden-import/Tools", "Tools", 3'000'000, true, {});+ return candidates;+}++// The fixture's imported game (Night Sky, already added from the USB drive).+GameId fixture_imported_game() { return GameId::Local("6d1f3a52-0c55-4f3e-9b2a-5d1c7e0a9f11"); }+} // namespaceSimulation::Simulation(std::filesystem::path fixture_directory, std::filesystem::path profile_path, ModelMode mode)@@ -774,6 +834,8 @@ void Simulation::UpdateImportCandidates(std::vector<LiveImportCandidate> candidaif (!live() || (candidates == state_.import_candidates && scanning == state_.import_scanning)) return;state_.import_candidates = std::move(candidates);state_.import_scanning = scanning;+ refresh_import_sheet();+ settle_pending_imports();rebuild_view();}@@ -783,6 +845,258 @@ void Simulation::RequestImport(ImportRequest request) {std::vector<ImportRequest> Simulation::TakeImportRequests() { return std::exchange(pending_import_requests_, {}); }+std::vector<std::string> Simulation::import_sheet_actions() const {+ std::vector<std::string> actions{"import-look"};+ for (const auto& [volume, name] : kImportGroups) {+ bool heading = false;+ for (const auto& candidate : state_.import_candidates) {+ if (candidate.volume_id != volume) continue;+ if (!heading) { actions.push_back(std::string("import-group-") + volume); heading = true; }+ actions.push_back(import_candidate_key(candidate));+ }+ }+ actions.push_back("cancel");+ return actions;+}++const LiveImportCandidate* Simulation::import_candidate(const std::string& key) const {+ for (const auto& candidate : state_.import_candidates)+ if (import_candidate_key(candidate) == key) return &candidate;+ return nullptr;+}++void Simulation::open_import_sheet() {+ auto actions = import_sheet_actions();+ // The first game not added yet, else the first game, else Look for games.+ int focus = 0, first = -1;+ for (int index = 0; index < static_cast<int>(actions.size()); ++index) {+ const auto* candidate = import_candidate(actions[static_cast<std::size_t>(index)]);+ if (!candidate) continue;+ if (first < 0) first = index;+ if (!candidate->imported.valid()) { focus = index; break; }+ }+ if (focus == 0 && first >= 0) focus = first;+ open_modal({"import-games", "Import games", state_.navigation.focus_key, std::move(actions), focus, false});+}++void Simulation::refresh_import_sheet() {+ auto& modals = state_.navigation.modals;+ for (std::size_t index = 0; index < modals.size(); ++index) {+ auto& modal = modals[index];+ if (modal.id == "import-games") {+ const auto focused = modal.action_keys[static_cast<std::size_t>(modal.focused_action)];+ modal.action_keys = import_sheet_actions();+ const auto found = std::find(modal.action_keys.begin(), modal.action_keys.end(), focused);+ modal.focused_action = found == modal.action_keys.end() ? 0 : static_cast<int>(found - modal.action_keys.begin());+ if (index + 1 == modals.size()) state_.navigation.focus_key = modal.action_keys[static_cast<std::size_t>(modal.focused_action)];+ } else if ((modal.id == "import-programs" || (modal.id == "import-choice" && !import_choice_game_.valid())) &&+ !import_candidate(import_programs_key_)) {+ // The folder went away in a new scan: its program list closes.+ modals.erase(modals.begin() + static_cast<std::ptrdiff_t>(index));+ if (index == modals.size() && !modals.empty())+ state_.navigation.focus_key = modals.back().action_keys[static_cast<std::size_t>(modals.back().focused_action)];+ --index;+ }+ }+}++void Simulation::move_import_sheet(int delta) {+ auto& modal = state_.navigation.modals.back();+ if (delta == 0) return;+ const int step = delta > 0 ? 1 : -1;+ for (int next = modal.focused_action + step; next >= 0 && next < static_cast<int>(modal.action_keys.size()); next += step) {+ if (modal.action_keys[static_cast<std::size_t>(next)].rfind("import-group-", 0) == 0) continue;+ modal.focused_action = next;+ break;+ }+ state_.navigation.focus_key = modal.action_keys[static_cast<std::size_t>(modal.focused_action)];+}++void Simulation::look_for_games() {+ if (state_.import_scanning) return;+ // The sheet shows the scan at once, so a second press before the store answers asks nothing more.+ state_.import_scanning = true;+ // Fixture mode: the scan runs until the next tick, which fills in the fixture's folders.+ if (live()) RequestImport({ImportRequestKind::LookForGames});+}++const LiveExternalGame* Simulation::external_game(GameId id) const {+ for (const auto& external : state_.external_games)+ if (external.game_id == id) return &external;+ return nullptr;+}++const Job* Simulation::import_copy_job(GameId id) const {+ if (id.store != Store::kLocal) return nullptr;+ for (const auto& job : state_.jobs)+ if (job.game_id == id && job.kind == "install" && job.state != JobState::Downloaded && job.state != JobState::Cancelled)+ return &job;+ return nullptr;+}++std::string Simulation::import_copy_target() const {+ return import_copy_volume_.empty() ? selected_volume_id_ : import_copy_volume_;+}++void Simulation::open_import_choice(std::size_t program, GameId game) {+ import_program_index_ = program;+ import_choice_game_ = game;+ import_copy_volume_.clear();+ std::string title, volume;+ bool ascii_ok = true;+ if (game.valid()) {+ const auto* found = find_game(state_, game);+ const auto* external = external_game(game);+ if (!found || !external) return;+ title = found->title;+ volume = external->volume_id;+ } else {+ const auto* candidate = import_candidate(import_programs_key_);+ if (!candidate || program >= candidate->programs.size()) return;+ title = candidate->title;+ volume = candidate->volume_id;+ ascii_ok = candidate->ascii_ok;+ }+ // Play in place (a folder the PS5 can start a game from), then Copy (a drive) or Move (the drop+ // folder), then Back.+ std::vector<std::string> actions;+ const bool drop = volume == kImportDropVolume;+ if (!game.valid() && ascii_ok) actions.push_back("import-play-in-place");+ if (drop) actions.push_back("import-move");+ else { actions.push_back("import-copy"); actions.push_back("storage-picker"); }+ actions.push_back("cancel");+ open_modal({"import-choice", std::move(title), state_.navigation.focus_key, std::move(actions), 0, false});+}++void Simulation::open_game_page(GameId id) {+ if (!find_game(state_, id)) return;+ state_.navigation.modals.clear();+ if (live()) force_organization_selection_ = true;+ // From Startup (no library page yet) Circle goes Home.+ if (state_.navigation.route != Route::Details)+ state_.navigation.detail_origin = state_.navigation.route == Route::Startup ? Route::Home : state_.navigation.route;+ state_.navigation.detail_id = id;+ state_.navigation.selected_game_id = id;+ state_.navigation.route = Route::Details;+ details_primary_pending_ = live();+ state_.navigation.focus_key = live() ? "details-favorite" : "details-play";+}++void Simulation::start_import_transfer(GameId id, ImportRequestKind kind, const std::string& volume_id) {+ if (live()) {+ RequestImport({kind, id, kind == ImportRequestKind::CopyIntoPlayden ? volume_id : std::string()});+ return;+ }+ // Fixture mode: a copy is a job in Queue (its drive, or the default); a move is instant.+ const auto* game = find_game(state_, id);+ const auto bytes = game && game->install_bytes ? *game->install_bytes : std::uint64_t{0};+ if (kind == ImportRequestKind::CopyIntoPlayden) {+ if (import_copy_job(id)) return;+ state_.jobs.push_back({next_job_id(), id, "install", next_queue_order(state_), JobStage::Download, JobState::Queued, 0,+ std::max<std::uint64_t>(bytes, 1), std::nullopt, std::nullopt, {}, JobStage::Download,+ volume_id.empty() ? selected_volume_id_ : volume_id, 0, bytes, true, false});+ } else {+ std::erase_if(state_.external_games, [id](const LiveExternalGame& external) { return external.game_id == id; });+ if (!find_installation(state_, id))+ state_.installations.push_back({id, kImportDropVolume, std::max<std::uint64_t>(bytes, 1), true, true, true});+ reconcile_storage(state_);+ }+}++void Simulation::choose_import(const std::string& action) {+ const bool copy = action == "import-copy", move = action == "import-move";+ std::optional<ImportRequestKind> then;+ if (copy) then = ImportRequestKind::CopyIntoPlayden;+ if (move) then = ImportRequestKind::MoveIntoPlayden;+ if (import_choice_game_.valid()) {+ // A game already added: Copy or Move from its page.+ const auto id = import_choice_game_;+ if (then) start_import_transfer(id, *then, import_copy_volume_);+ import_choice_game_ = {};+ close_modal();+ return;+ }+ const auto* candidate = import_candidate(import_programs_key_);+ if (!candidate || import_program_index_ >= candidate->programs.size() || candidate->imported.valid()) return;+ if (action == "import-play-in-place" && !candidate->ascii_ok) return;+ const auto key = import_programs_key_;+ RequestImport({ImportRequestKind::Add, {}, candidate->volume_id, candidate->folder, candidate->programs[import_program_index_].path});+ pending_imports_[key] = {then, copy ? import_copy_volume_ : std::string(), state_.navigation.route};+ import_failures_.erase(key);+ if (!live()) {+ // Fixture mode: the folder becomes a library game at once.+ Game game;+ // A UUID made from the folder, so adding it again finds the same game.+ const auto hash = static_cast<unsigned long long>(std::hash<std::string>{}(key));+ char uuid[40];+ std::snprintf(uuid, sizeof(uuid), "%08llx-%04llx-4%03llx-8%03llx-%012llx", hash & 0xffffffffULL,+ (hash >> 32) & 0xffffULL, (hash >> 48) & 0xfffULL, (hash >> 20) & 0xfffULL, hash & 0xffffffffffffULL);+ game.id = GameId::Local(uuid);+ game.title = candidate->title;+ game.source = "Imported";+ game.install_bytes = candidate->total_bytes;+ if (!find_game(state_, game.id)) state_.games.push_back(game);+ if (!external_game(game.id)) state_.external_games.push_back({game.id, candidate->volume_id, true, ""});+ for (auto& entry : state_.import_candidates)+ if (import_candidate_key(entry) == key) entry.imported = game.id;+ }+ // Back on the Import sheet until the game is in the library; then its page opens.+ while (!state_.navigation.modals.empty() && state_.navigation.modals.back().id != "import-games") close_modal();+ settle_pending_imports();+}++void Simulation::settle_pending_imports() {+ for (auto it = pending_imports_.begin(); it != pending_imports_.end();) {+ const auto* candidate = import_candidate(it->first);+ // The folder went away in a new scan: nothing waits on it any more.+ if (!candidate) { it = pending_imports_.erase(it); continue; }+ if (!candidate->imported.valid()) { ++it; continue; }+ const auto id = candidate->imported;+ if (it->second.then) {+ // The copy or move chosen with the add goes once the game has its ID.+ const auto kind = *it->second.then;+ it->second.then.reset();+ start_import_transfer(id, kind, it->second.volume_id);+ }+ // The library lists it: its page opens over the Import sheet, or where the sheet was when the+ // library's arrival closed it (Startup gives way to Home); not once the player went elsewhere.+ if (!find_game(state_, id)) { ++it; continue; }+ const auto from = it->second.from;+ it = pending_imports_.erase(it);+ const auto& modals = state_.navigation.modals;+ const auto route = state_.navigation.route;+ if ((!modals.empty() && modals.back().id == "import-games") ||+ (modals.empty() && !state_.editor.active && (route == from || (from == Route::Startup && route == Route::Home))))+ open_game_page(id);+ }+}++void Simulation::NotifyImportFailed(const ImportRequest& request, const std::string& message) {+ std::string title, verb;+ switch (request.kind) {+ case ImportRequestKind::LookForGames: verb = "Can't look for games"; break;+ case ImportRequestKind::Add: verb = "Can't add"; break;+ case ImportRequestKind::Remove: verb = "Can't remove"; break;+ case ImportRequestKind::CopyIntoPlayden: verb = "Can't copy"; break;+ case ImportRequestKind::MoveIntoPlayden: verb = "Can't move"; break;+ }+ if (request.kind == ImportRequestKind::Add) {+ for (const auto& candidate : state_.import_candidates)+ if (candidate.volume_id == request.volume_id && candidate.folder == request.folder) {+ title = candidate.title;+ pending_imports_.erase(import_candidate_key(candidate));+ import_failures_[import_candidate_key(candidate)] = message;+ }+ if (title.empty()) title = request.folder.substr(request.folder.find_last_of('/') + 1);+ } else if (const auto* game = find_game(state_, request.game_id)) {+ title = game->title;+ }+ if (request.kind == ImportRequestKind::LookForGames) state_.import_scanning = false;+ push_notice({"import-" + (request.game_id.valid() ? ToKey(request.game_id) : request.volume_id + ":" + request.folder),+ verb + (title.empty() ? std::string() : " " + title), "", false, kLiveNoticeSeconds * 2, true, message});+ rebuild_view();+}+bool Simulation::SeedGameProgram(GameId id, const std::string& program) {if (!live() || !id.valid() || settings_load_failed_ || game_settings_file_.empty()) return false;if (!rt::ValidateSettingValue(rt::GameRecipe{}, "program", program, nullptr)) return false;@@ -1963,6 +2277,8 @@ bool Simulation::UpdateLibrary(LibraryUpdate update) {account.cache_available = update.cache_available;account.error = std::move(update.error);if (update.retrieved_at) account.last_sync = *update.retrieved_at;+ // A game just added from the Import sheet is listed now: its page opens (from Startup too).+ if (!pending_imports_.empty()) settle_pending_imports();// A store without an account brought games while nothing is signed in (or Steam's saved sign-in// failed to restore): they open on Home.const bool waiting_route = state_.navigation.route == Route::Startup ||@@ -2984,6 +3300,65 @@ bool Simulation::scenario(const std::string& name) {state_.library_syncing = false;state_.account().authentication = AuthState::SignedIn;state_.navigation.route = Route::Home;+ } else if (name == "import-empty" || name == "import-candidates" || name == "import-programs" || name == "import-choice" ||+ name == "import-details" || name == "import-copying" || name == "import-library") {+ // The Import sheet over Settings › Storage: nothing found yet, or the fixture's folders; then+ // a folder's programs, the add choice, and the imported game's page (in place, then copying).+ state_.account().authentication = AuthState::SignedIn;+ state_.import_scanning = false;+ state_.import_candidates.clear();+ pending_imports_.clear();+ state_.navigation.modals.clear();+ if (name != "import-empty") {+ const auto id = fixture_imported_game();+ if (!find_game(state_, id)) {+ Game game;+ game.id = id;+ game.title = "Night Sky";+ game.source = "Imported";+ game.install_bytes = 412'000'000;+ game.description = "A quiet night drive under the stars.";+ state_.games.push_back(std::move(game));+ }+ if (!external_game(id)) state_.external_games.push_back({id, "usb0", true, ""});+ std::erase_if(state_.jobs, [id](const Job& job) { return job.game_id == id; });+ state_.import_candidates = fixture_import_candidates();+ state_.import_candidates.front().imported = id;+ }+ if (name == "import-details" || name == "import-copying") {+ const auto id = fixture_imported_game();+ state_.navigation.route = Route::Library;+ open_game_page(id);+ if (name == "import-copying") {+ start_import_transfer(id, ImportRequestKind::CopyIntoPlayden, {});+ auto& job = state_.jobs.back();+ job.state = JobState::Downloading;+ job.completed_bytes = job.total_bytes * 2 / 5;+ }+ rebuild_view();+ return true;+ }+ if (name == "import-library") {+ // The Library's Imported scope: imported games' tiles carry their title, no store art.+ state_.library.scope = "imported";+ state_.navigation.route = Route::Library;+ state_.navigation.library_rail_focused = false;+ reconcile_library_selection(state_);+ rebuild_view();+ return true;+ }+ state_.navigation.route = Route::Settings;+ state_.navigation.settings_rail_focused = false;+ state_.navigation.tabs_focused = false;+ state_.navigation.focus_key = "settings-import";+ rebuild_view();+ open_import_sheet();+ if (name == "import-programs" || name == "import-choice") {+ rebuild_view();+ action("focus:import-candidate-usb0:playden/import/Old School Rally");+ action("cross");+ if (name == "import-choice") action("cross");+ }} else {last_error_ = "Unknown scenario: " + name;return false;@@ -3179,6 +3554,32 @@ void Simulation::rebuild_view() {}}}+ if (modal.id == "import-games")+ view_.subtitle = state_.import_candidates.empty() ? kImportEmptyText+ : "Games found in playden/import on your drives and in /data/playden-import. Choose one to add it.";+ const auto* import_programs = modal.id == "import-programs" ? import_candidate(import_programs_key_) : nullptr;+ if (import_programs)+ view_.subtitle = import_programs->ascii_ok ? "Choose the program that starts the game." : kImportCopyOnlyText;+ // The add choice: its folder's candidate, or the game added already (its page's Copy or Move).+ const LiveImportCandidate* import_choice = nullptr;+ std::uint64_t import_choice_bytes = 0;+ std::string import_choice_volume;+ if (modal.id == "import-choice") {+ if (import_choice_game_.valid()) {+ const auto* game = find_game(state_, import_choice_game_);+ if (game && game->install_bytes) import_choice_bytes = *game->install_bytes;+ if (const auto* external = external_game(import_choice_game_)) import_choice_volume = external->volume_id;+ } else if ((import_choice = import_candidate(import_programs_key_))) {+ import_choice_bytes = import_choice->total_bytes;+ import_choice_volume = import_choice->volume_id;+ }+ const bool drop = import_choice_volume == kImportDropVolume;+ view_.subtitle = import_choice && !import_choice->ascii_ok ? kImportCopyOnlyText+ : drop ? (import_choice ? "Play the game from the drop folder, or move it into Playden's games folder."+ : "The game's folder moves from the drop folder into Playden's games folder.")+ : import_choice ? "Play the game from the drive, or copy it into Playden to play without the drive."+ : "A copy in Playden plays without the drive. The folder on the drive stays as it is.";+ }if (modal.id == "kept-data")view_.subtitle = "Saves and settings kept when a game was uninstalled. Installing a game again brings its saves ""back. Saves in Steam Cloud stay in Steam Cloud.";@@ -3253,6 +3654,19 @@ void Simulation::rebuild_view() {modal.action_keys[static_cast<std::size_t>(modal.focused_action)] == action_key;if (focused_row && !definition->also_called.empty() && modal.id != "button-mapping")item.subtitle += " · Also called " + definition->also_called;+ } else if (settings_ready && action_key == "steam-app-id") {+ // Saved in the game's settings record; the game's own steam_appid.txt wins over it.+ item.kind = RowKind::Text;+ item.title = "Steam app ID";+ const auto record = state_.game_settings.find(settings_game);+ const std::uint32_t saved = record == state_.game_settings.end() ? 0 : record->second.steam_app_id;+ const auto runtime_game = state_.runtime_games.find(settings_game);+ const bool from_file = runtime_game != state_.runtime_games.end() && runtime_game->second.steam_app_from_game_file &&+ runtime_game->second.steam_app_id != 0;+ item.value = from_file ? std::to_string(runtime_game->second.steam_app_id)+ : saved ? std::to_string(saved) : std::string("None");+ item.subtitle = from_file ? "From the game's steam_appid.txt" : "Only for games that need Steam. Most run without it.";+ item.modified = saved != 0;} else if (settings_ready && action_key == "button-mapping") {item.kind = RowKind::Choice;item.title = "Button mapping";@@ -3430,7 +3844,8 @@ void Simulation::rebuild_view() {item.value = "Free space unknown";item.subtitle = !volume->available ? "Disconnected" : !volume->writable ? "No write access" : "Available";item.enabled = volume->available && volume->writable;- item.selected = volume->id == (live() && picking_install_volume_ ? install_target() : selected_volume_id_);+ item.selected = volume->id == (picking_import_volume_ ? import_copy_target()+ : live() && picking_install_volume_ ? install_target() : selected_volume_id_);}}else if (action_key == "quit-to-home") item.dangerous = true; // the dialog's primary action@@ -3506,6 +3921,70 @@ void Simulation::rebuild_view() {item.dangerous = true;item.enabled = !installed_selected_.empty();}+ else if (modal.id == "import-games" && action_key == "import-look") {+ item.title = state_.import_scanning ? "Looking for games…" : "Look for games";+ if (state_.import_scanning) { item.kind = RowKind::Status; item.enabled = false; }+ }+ else if (modal.id == "import-games" && action_key.rfind("import-group-", 0) == 0) {+ item.kind = RowKind::Heading;+ item.action.clear();+ item.enabled = false;+ for (const auto& [volume, name] : kImportGroups)+ if (action_key == std::string("import-group-") + volume) item.title = name;+ }+ else if (modal.id == "import-games" && action_key.rfind("import-candidate-", 0) == 0) {+ if (const auto* candidate = import_candidate(action_key)) {+ item.title = candidate->title;+ item.value = candidate->imported.valid() ? std::string("Added") : format_bytes(candidate->total_bytes);+ item.subtitle = candidate->path;+ if (candidate->imported.valid()) item.game_id = candidate->imported;+ else if (candidate->programs.empty()) { item.subtitle = "No Windows program found"; item.enabled = false; }+ else if (!candidate->ascii_ok) item.subtitle += " · Copy only";+ // An add on its way, or why the last one was refused.+ if (!candidate->imported.valid() && pending_imports_.count(action_key)) {+ item.value = "Adding…";+ item.enabled = false;+ } else if (const auto failure = import_failures_.find(action_key);+ !candidate->imported.valid() && failure != import_failures_.end()) {+ item.subtitle = "Not added · " + failure->second;+ }+ }+ }+ else if (import_programs && action_key.rfind("import-program-", 0) == 0) {+ const auto index = static_cast<std::size_t>(std::stoul(action_key.substr(15)));+ if (index < import_programs->programs.size()) {+ const auto& program = import_programs->programs[index];+ item.title = program.path;+ item.value = format_bytes(program.bytes);+ if (program.helper) item.subtitle = "Installer or tool";++ }+ }+ else if (modal.id == "import-choice" && action_key == "import-play-in-place") {+ item.title = import_choice_volume == kImportDropVolume ? "Play from the drop folder" : "Play from the drive";+ item.value = import_volume_name(import_choice_volume);+ }+ else if (modal.id == "import-choice" && action_key == "import-copy") {+ item.title = "Copy into Playden";+ item.value = format_bytes(import_choice_bytes);+ item.value += (item.value.empty() ? "" : " · ") + import_copy_estimate(import_choice_bytes);+ }+ else if (modal.id == "import-choice" && action_key == "import-move") {+ item.title = "Move into Playden";+ item.value = "Instant";+ }+ else if (modal.id == "import-choice" && action_key == "storage-picker") {+ // The drive the copy goes to, as the install sheet's drive choice.+ item.title = "Copy to";+ if (const auto* volume = find_volume(state_, import_copy_target())) {+ item.value = volume->label;+ } else {+ item.value = "Default drive";+ }+ }+ else if ((modal.id == "import-games" || modal.id == "import-programs" || modal.id == "import-choice") && action_key == "cancel") {+ item.title = modal.id == "import-games" ? "Close" : "Back";+ }else if (action_key == "kept-select-all") {const bool all = !state_.kept_bottles.empty() && kept_selected_.size() == state_.kept_bottles.size();item.title = all ? "Clear selection" : "Select all";@@ -3649,6 +4128,8 @@ void Simulation::rebuild_view() {else if (modal.id == "preset-picker") view_.legends = {"Cross Use this preset", "L1/R1 Jump", "Circle Back"};else if (modal.id == "button-mapping") view_.legends = {"Cross Change", "L1/R1 Jump", "Circle Back"};else if (modal.id == "game-maintenance") view_.legends = {"Cross Select", "L1/R1 Jump", "Circle Cancel"};+ else if (modal.id == "import-games") view_.legends = {"Cross Select", "Circle Close"};+ else if (modal.id == "import-programs" || modal.id == "import-choice") view_.legends = {"Cross Select", "Circle Back"};else if (modal.id == "installed-games")// The batch's rows only report; Cross does something only on its buttons.view_.legends = !uninstall_batch_ ? std::vector<std::string>{"Cross Select", "Triangle Uninstall", "Circle Close"}@@ -3671,7 +4152,7 @@ void Simulation::rebuild_view() {view_.legends = {"Cross Quit to Home"};} else if (state_.navigation.route == Route::Startup) {view_.title = "Welcome to Playden";- view_.subtitle = live() ? "Connect Steam to load your library." : "Browse the local UI fixture or connect a simulated Steam account.";+ view_.subtitle = live() ? "Connect a store or import games to fill your library." : "Browse the local UI fixture or connect a simulated Steam account.";if (state_.startup_loading || state_.account().authentication == AuthState::Restoring) {row("startup-loading", RowKind::Status, live() ? "Restoring your accounts…" : "Loading saved fixture state…", "").enabled = false;if (!live()) row("startup-advance", RowKind::Action, "Advance fixture clock", "advance-clock");@@ -3681,6 +4162,8 @@ void Simulation::rebuild_view() {row("startup-continue", RowKind::Action, "Continue without saving", "continue-without-saving");} else {row("startup-connect", RowKind::Action, "Connect Steam", "connect");+ // Games from a drive or the drop folder need no store account.+ row("startup-import", RowKind::Action, "Import games", "import-manage");row("startup-skip", RowKind::Action, "Skip for now", "skip");}} else if (state_.navigation.route == Route::SignIn && state_.sign_in.step != SignInStep::Qr &&@@ -3765,9 +4248,14 @@ void Simulation::rebuild_view() {item.badge = state_.library.favorites.contains(game->id) ? "Favorite" : "";steam_shown = steam_shown || game->id.store == Store::kSteam;}- // Signed out with only other stores' games (imported ones) listed, Steam is still offered.+ // Signed out with only other stores' games (imported ones) listed, Steam is still offered, and+ // Home is about those games rather than the account.const bool connect = state_.account().authentication != AuthState::SignedIn && !steam_shown;- if (view_.rows.empty()) row("home-library", RowKind::Action, "Open Library", "library");+ if (connect && !view_.rows.empty() && state_.account().authentication != AuthState::Offline) view_.subtitle = "Your library";+ if (view_.rows.empty()) {+ row("home-library", RowKind::Action, "Open Library", "library");+ row("home-import", RowKind::Action, "Import games", "import-manage");+ }if (connect) row("home-connect", RowKind::Action, "Connect a store", "connect");auto add_shelf = [this](const playden::homebrew::Shelf& source, int shelf_index) {ViewData::Shelf shelf;@@ -3832,15 +4320,18 @@ void Simulation::rebuild_view() {// rows as an installed one; it is never in Installed games.std::optional<Installation> in_place;std::string in_place_reason;- if (!installation && game && live())- for (const auto& external : state_.external_games)- if (external.game_id == game->id) {- const auto runtime_game = state_.runtime_games.find(game->id);- in_place = Installation{game->id, external.volume_id, 0, external.available && external.reason.empty(),- runtime_game != state_.runtime_games.end() && runtime_game->second.ready, false};- in_place_reason = external.reason;- installation = &*in_place;- }+ if (!installation && game)+ if (const auto* external = external_game(game->id)) {+ const auto runtime_game = state_.runtime_games.find(game->id);+ // Fixture mode: a folder there plays at once (its size stands for the install).+ in_place = Installation{game->id, external->volume_id, live() ? 0 : std::max<std::uint64_t>(game->install_bytes.value_or(1), 1),+ external->available && external->reason.empty(),+ live() ? runtime_game != state_.runtime_games.end() && runtime_game->second.ready : true, false};+ in_place_reason = external->reason;+ installation = &*in_place;+ }+ const bool imported = game && game->id.store == Store::kLocal;+ const Job* copying = imported && in_place ? import_copy_job(game->id) : nullptr;// Live installations are only finished installs; their size may be unknown on an absent drive.const bool installed = installation && (live() || installation->installed_bytes > 0);if (!live()) {@@ -3963,6 +4454,31 @@ void Simulation::rebuild_view() {row("details-kept-delete", RowKind::Action, "Delete saves", "kept-delete-" + ToKey(game->id)).dangerous = true;}}+ if (imported) {+ // An imported game: Copy or Move into Playden while it plays from its folder (the copy's+ // progress while it runs), then Remove from library; a copy in Playden uninstalls.+ if (copying) {+ auto& status = row("details-download", RowKind::Action, "Copying", "import-open-copy");+ status.value = job_state_name(copying->state);+ status.progress = copying->total_bytes == 0 ? 0.0F+ : static_cast<float>(copying->completed_bytes) / static_cast<float>(copying->total_bytes);+ } else if (const auto* external = in_place ? external_game(game->id) : nullptr; external && external->available) {+ // Its drive is there: a folder the PS5 can't play from (its name) can still be copied.+ row("details-copy", RowKind::Action, in_place->volume_id == kImportDropVolume ? "Move into Playden" : "Copy into Playden",+ "import-copy-game");+ }+ if (in_place) {+ row("details-remove", RowKind::Action, "Remove from library", "import-remove").enabled = !copying;+ // Where it plays from, under the buttons.+ for (const auto& candidate : state_.import_candidates)+ if (candidate.imported == game->id && installation->available) {+ auto& folder = row("details-folder", RowKind::Status, "Plays from " + candidate.path, "");+ folder.enabled = false;+ }+ } else if (installed) {+ row("details-uninstall", RowKind::Action, "Uninstall", "uninstall");+ }+ }if (installed) {const auto found = state_.runtime_games.find(game->id);const auto* runtime = found == state_.runtime_games.end() ? nullptr : &found->second;@@ -4008,6 +4524,7 @@ void Simulation::rebuild_view() {if (position > 0 && queue.waiting.size() > 1)hint = std::to_string(position) + " of " + std::to_string(queue.waiting.size()) + " waiting. " + hint;}+ else if (waiting && imported) hint = "The PS5 adds the game to Home when Playden quits.";else if (waiting) hint = "Quit Playden and " + game->title + " appears on the PS5 Home screen.";else if (status == "Registration pending") hint = "The PS5 hasn't confirmed " + game->title + " yet.";else if (status == "Removal incomplete") hint = "Removing " + game->title + " from the PS5 Home screen stopped partway.";@@ -4238,6 +4755,14 @@ void Simulation::rebuild_view() {storage.subtitle = "Where new games are installed";if (state_.volumes.empty()) { storage.kind = RowKind::Status; storage.action.clear(); storage.enabled = false; storage.subtitle = "Storage is unavailable"; }}+ {+ // Windows games in a drive's playden/import or the console drop folder: the Import sheet.+ auto& entry = add("settings-import", RowKind::Action, "Import games", "import-manage");+ entry.subtitle = "Add Windows games from a drive or the console drop folder";+ const auto found = std::count_if(state_.import_candidates.begin(), state_.import_candidates.end(),+ [](const LiveImportCandidate& candidate) { return !candidate.imported.valid(); });+ if (found > 0) entry.value = std::to_string(found) + " found";+ }if (live()) {// Installed games: one row that opens the list, sorted by size or last played, where// the player picks games to uninstall together.@@ -4470,6 +4995,8 @@ void Simulation::open_modal(ModalEntry modal) {void Simulation::close_modal() {if (state_.navigation.modals.empty()) return;const auto opener = state_.navigation.modals.back().opener_focus_key;+ if (state_.navigation.modals.back().id == "storage") picking_import_volume_ = false;+ if (state_.navigation.modals.back().id == "import-choice") import_choice_game_ = {};state_.navigation.modals.pop_back();state_.navigation.focus_key = opener;}@@ -4738,6 +5265,28 @@ void Simulation::commit_editor() {return;}if (state_.editor.purpose == "Search") { state_.library.query = state_.editor.value; reconcile_library_selection(state_); }+ else if (state_.editor.purpose == "Steam app ID") {+ // A Steam app ID in plain decimal ("440"), or nothing to clear it.+ if (!can_change_game_settings()) return;+ const auto value = trimmed(state_.editor.value);+ const auto parsed = value.empty() ? std::optional<std::uint32_t>{0} : rt::ParseSteamAppId(value);+ if (!parsed || (!value.empty() && std::to_string(*parsed) != value)) {+ state_.notices.push_back({"setting-validation", "Steam app ID: use the number in the game's Steam store address",+ "", true, 0, true});+ return;+ }+ std::erase_if(state_.notices, [](const Notice& notice) { return notice.id == "setting-validation"; });+ auto& record = state_.game_settings[state_.navigation.selected_game_id];+ if (record.steam_app_id != *parsed) {+ record.steam_app_id = *parsed;+ ++record.revision;+ }+ state_.editor.active = false;+ state_.navigation.focus_key = state_.editor.opener_focus_key;+ refresh_game_settings();+ save_profile();+ return;+ }else if (!editing_setting_id_.empty()) {if (!can_change_game_settings()) return;auto value = trimmed(state_.editor.value);@@ -4890,6 +5439,7 @@ void Simulation::move(int delta_x, int delta_y) {return;}if (modal.id == "installed-games") { move_installed_manager(delta_x, delta_y); return; }+ if (modal.id == "import-games") { move_import_sheet(delta_y != 0 ? delta_y : delta_x); return; }const int delta = delta_y != 0 ? delta_y : delta_x;modal.focused_action = std::clamp(modal.focused_action + delta, 0, static_cast<int>(modal.action_keys.size()) - 1);state_.navigation.focus_key = modal.action_keys[static_cast<std::size_t>(modal.focused_action)];@@ -5304,7 +5854,10 @@ void Simulation::activate() {state_.navigation.selected_game_id = shelf.game_ids[static_cast<std::size_t>(item)];}}- if (state_.navigation.route == Route::Home && state_.navigation.modals.empty() && state_.navigation.selected_game_id.valid()) {+ // Home's empty state has only its buttons (Open Library, Import games, Connect a store): a game+ // selected before is not under the focus.+ if (state_.navigation.route == Route::Home && state_.navigation.modals.empty() && state_.navigation.selected_game_id.valid() &&+ state_.navigation.focus_key.rfind("home-", 0) != 0) {if (live()) force_organization_selection_ = true;state_.navigation.detail_origin = Route::Home;state_.navigation.detail_id = state_.navigation.selected_game_id;@@ -5375,13 +5928,23 @@ void Simulation::activate() {else if (action_name == "storage-picker") {// From the install sheet the choice is for that install only; Settings changes the default.picking_install_volume_ = live() && !state_.navigation.modals.empty() && state_.navigation.modals.back().id == "install";+ // From the add choice, the drive is for that copy only.+ picking_import_volume_ = !state_.navigation.modals.empty() && state_.navigation.modals.back().id == "import-choice";std::vector<std::string> actions;for (const auto& volume : state_.volumes) actions.push_back("volume-" + volume.id);actions.push_back("cancel");- open_modal({"storage", picking_install_volume_ ? "Install to" : "Choose storage", state_.navigation.focus_key,- std::move(actions), 0, false});+ open_modal({"storage", picking_install_volume_ ? "Install to" : picking_import_volume_ ? "Copy to" : "Choose storage",+ state_.navigation.focus_key, std::move(actions), 0, false});} else if (action_name.rfind("volume-", 0) == 0) {const auto id = action_name.substr(7);+ if (picking_import_volume_) {+ const auto* volume = find_volume(state_, id);+ if (volume && volume->available && volume->writable) import_copy_volume_ = id == selected_volume_id_ ? std::string() : id;+ picking_import_volume_ = false;+ close_modal();+ state_.navigation.focus_key = "import-copy"; // back on the choice, ready to copy+ return;+ }if (live() && picking_install_volume_) {const auto* volume = find_volume(state_, id);if (volume && volume->available) install_volume_id_ = id == selected_volume_id_ ? std::string() : id;@@ -5807,10 +6370,14 @@ void Simulation::activate() {const bool no_cloud = !Traits(id.store).cloud_saves ||(cloud != state_.cloud.end() && cloud->second.status == CloudStatus::Unsupported);title = "Uninstall this game?";+ const bool steam = id.store == Store::kSteam;body = has_title ? uninstall_body_kept- : "The game's files are removed from this console. You can install it again from Steam.";- body += no_cloud ? " This game has no Steam Cloud saves: its saves exist only on this console."- : " Steam Cloud saves are synced first; if that fails, Playden asks before going on.";+ : steam ? "The game's files are removed from this console. You can install it again from Steam."+ : "The game's files are removed from this console.";+ // Only a store with Cloud saves is worth a word about them.+ if (!Traits(id.store).cloud_saves) body += " Its saves exist only on this console.";+ else body += no_cloud ? " This game has no Steam Cloud saves: its saves exist only on this console."+ : " Steam Cloud saves are synced first; if that fails, Playden asks before going on.";}}std::vector<std::string> actions{"cancel", "confirm-destructive"};@@ -5909,9 +6476,11 @@ void Simulation::activate() {if (installed_selected_.empty()) return;std::vector<std::string> names;std::uint64_t bytes = 0;- bool any_title = false;+ bool any_title = false, any_cloud = false, all_steam = true;for (const auto id : installed_list()) {if (!installed_selected_.contains(id)) continue;+ any_cloud = any_cloud || Traits(id.store).cloud_saves;+ all_steam = all_steam && id.store == Store::kSteam;const auto* game = find_game(state_, id);names.push_back(game && !game->title.empty() ? game->title : "Steam app " + ToKey(id));if (const auto* installation = find_installation(state_, id)) bytes += installation->installed_bytes;@@ -5932,8 +6501,10 @@ void Simulation::activate() {0, true};confirmation.body = listed + ". Frees about " + format_bytes(bytes) + ". ";confirmation.body += any_title ? uninstall_batch_body_kept- : "Their files are removed from this console. You can install them again from Steam.";- confirmation.body += " Steam Cloud saves are synced first. If that fails for a game, that game stays installed and its row says why.";+ : all_steam ? "Their files are removed from this console. You can install them again from Steam."+ : "Their files are removed from this console.";+ if (any_cloud)+ confirmation.body += " Steam Cloud saves are synced first. If that fails for a game, that game stays installed and its row says why.";open_modal(std::move(confirmation));} else if (action_name == "confirm-destructive" && live() && pending_destructive_action_ == "installed-selection-uninstall") {GameId first;@@ -5967,6 +6538,53 @@ void Simulation::activate() {state_.navigation.focus_key = *found;}}+ } else if (action_name == "import-manage") {+ open_import_sheet();+ } else if (action_name == "import-look") {+ look_for_games();+ } else if (action_name.rfind("import-candidate-", 0) == 0) {+ const auto* candidate = import_candidate(action_name);+ if (!candidate) return;+ if (candidate->imported.valid()) {+ // Added already: its page, with the sheets closed.+ open_game_page(candidate->imported);+ return;+ }+ if (pending_imports_.count(action_name)) return; // being added+ if (candidate->programs.empty()) return;+ import_programs_key_ = action_name;+ std::vector<std::string> actions;+ for (std::size_t index = 0; index < candidate->programs.size(); ++index)+ actions.push_back("import-program-" + std::to_string(index));+ actions.push_back("cancel");+ open_modal({"import-programs", candidate->title, state_.navigation.focus_key, std::move(actions), 0, false});+ } else if (action_name.rfind("import-program-", 0) == 0) {+ const auto* candidate = import_candidate(import_programs_key_);+ const auto index = static_cast<std::size_t>(std::stoul(action_name.substr(15)));+ if (!candidate || index >= candidate->programs.size()) return;+ // Where the game plays from: its folder, a copy or a move into Playden.+ open_import_choice(index);+ } else if (action_name == "import-play-in-place" || action_name == "import-copy" || action_name == "import-move") {+ choose_import(action_name);+ } else if (action_name == "import-copy-game") {+ // An imported game playing from its folder: Copy (a drive) or Move (the drop folder) into Playden.+ const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);+ if (const auto* external = external_game(id); external && external->available && !import_copy_job(id)) open_import_choice(0, id);+ } else if (action_name == "import-open-copy") {+ const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);+ state_.navigation.route = Route::Downloads;+ if (const auto* job = import_copy_job(id)) state_.navigation.focus_key = "job-" + job->id;+ } else if (action_name == "import-remove") {+ // Out of the library; the folder stays where it is.+ const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);+ const auto* game = find_game(state_, id);+ if (!game || !external_game(id)) return;+ pending_destructive_action_ = action_name;+ ModalEntry confirmation{"confirmation", "Remove " + game->title + " from the library?", state_.navigation.focus_key,+ {"cancel", "confirm-destructive"}, 0, true};+ confirmation.body = "The game's folder and files stay where they are, and Import games can add it again. Its PS5 "+ "title is removed; its saves and settings on this console are kept.";+ open_modal(std::move(confirmation));} else if (live() && action_name == "kept-manage") {if (state_.kept_bottles.empty()) return;kept_selected_.clear();@@ -6029,6 +6647,23 @@ void Simulation::activate() {} else {request_maintenance(state_.navigation.selected_game_id, kind);}+ } else if (action_name == "confirm-destructive" && pending_destructive_action_ == "import-remove") {+ const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);+ pending_destructive_action_.clear();+ state_.navigation.modals.clear();+ RequestImport({ImportRequestKind::Remove, id});+ if (!live()) {+ // Fixture mode: the game leaves the library at once and its folder can be added again.+ std::erase_if(state_.external_games, [id](const LiveExternalGame& external) { return external.game_id == id; });+ std::erase_if(state_.games, [id](const Game& game) { return game.id == id; });+ for (auto& candidate : state_.import_candidates)+ if (candidate.imported == id) candidate.imported = {};+ }+ // Back where the page was opened from; the library loses the game on its next refresh.+ state_.navigation.route = state_.navigation.detail_origin == Route::Details ? Route::Home : state_.navigation.detail_origin;+ state_.navigation.selected_game_id = {};+ state_.navigation.detail_id.reset();+ state_.navigation.focus_key.clear();} else if (action_name == "confirm-destructive" && live() && pending_destructive_action_.rfind("kept-delete-", 0) == 0) {pending_kept_delete_requests_.push_back(key_id(std::string_view(pending_destructive_action_).substr(12)));pending_destructive_action_.clear();@@ -6193,6 +6828,11 @@ void Simulation::activate() {close_modal(); refresh_game_settings(); save_profile();} else if (action_name.rfind("setting-", 0) == 0) {open_setting(action_name.substr(8));+ } else if (action_name == "steam-app-id") {+ const auto record = state_.game_settings.find(state_.navigation.selected_game_id);+ const std::uint32_t saved = record == state_.game_settings.end() ? 0 : record->second.steam_app_id;+ start_editor("Steam app ID", saved ? std::to_string(saved) : std::string());+ state_.editor.symbols = true; // digits first} else if (action_name == "unlock-setting" && !state_.navigation.modals.empty()) {// "Change anyway" on a row the recipe locks: the player's value may now win.const auto id = state_.navigation.modals.back().setting_id;@@ -6406,7 +7046,7 @@ void Simulation::activate() {}else if (kOfferGoBack && live() && action_name == "self-update-back-confirm") { close_modal(); request_self_update_restart("rollback"); }else if (action_name == "scenario-picker") open_modal({"scenarios", "Fixture scenarios", state_.navigation.focus_key,- {"scenario-default", "scenario-first-run", "scenario-signed-out", "scenario-qr-waiting", "scenario-offline", "scenario-empty", "scenario-no-results", "scenario-delayed-art", "scenario-failed-art", "scenario-install-ready", "scenario-unknown-size", "scenario-insufficient-space", "scenario-storage-disconnect", "scenario-paused", "scenario-download-failed", "scenario-verification-failed", "scenario-restart-recovery", "scenario-save-failure", "scenario-runtime-unavailable", "scenario-launch-failure", "scenario-crash", "scenario-stop-failure", "scenario-controller-disconnected", "scenario-reduced-motion", "scenario-stress", "cancel"}, 0, false});+ {"scenario-default", "scenario-first-run", "scenario-signed-out", "scenario-qr-waiting", "scenario-offline", "scenario-empty", "scenario-no-results", "scenario-delayed-art", "scenario-failed-art", "scenario-install-ready", "scenario-unknown-size", "scenario-insufficient-space", "scenario-storage-disconnect", "scenario-paused", "scenario-download-failed", "scenario-verification-failed", "scenario-restart-recovery", "scenario-save-failure", "scenario-runtime-unavailable", "scenario-launch-failure", "scenario-crash", "scenario-stop-failure", "scenario-controller-disconnected", "scenario-reduced-motion", "scenario-stress", "scenario-import-empty", "scenario-import-candidates", "scenario-import-programs", "scenario-import-choice", "scenario-import-details", "scenario-import-copying", "scenario-import-library", "cancel"}, 0, false});else if (action_name.rfind("scenario-", 0) == 0) { state_.navigation.modals.clear(); scenario(action_name.substr(9)); }else if (action_name == "session-fixture-controls") open_modal({"session-controls", "Session fixture controls", state_.navigation.focus_key,{"advance-clock", "inject-stop-failure", "inject-crash", "cancel"}, 0, false});@@ -6971,6 +7611,14 @@ void Simulation::tick(int ticks) {if (!state_.screenshot_mode) {++state_.clock_ticks;advance_jobs();+ // A finished copy of an imported game: it plays from Playden's storage, not its folder.+ for (const auto& job : state_.jobs)+ if (job.kind == "install" && job.state == JobState::Downloaded && job.game_id.store == Store::kLocal &&+ external_game(job.game_id)) {+ const auto id = job.game_id;+ std::erase_if(state_.external_games, [id](const LiveExternalGame& external) { return external.game_id == id; });+ if (auto* installation = find_installation(state_, id)) installation->runtime_ready = true;+ }if (state_.account().authentication == AuthState::Waiting && state_.clock_ticks >= state_.account().challenge_expiry) {state_.account().authentication = AuthState::Expired;state_.navigation.focus_key = "qr-refresh";@@ -6987,6 +7635,17 @@ void Simulation::tick(int ticks) {else if (state_.session == SessionState::Launching) state_.session = SessionState::Running;else if (state_.session == SessionState::Stopping) { state_.session = SessionState::Idle; state_.navigation.route = Route::Details; state_.navigation.detail_id = state_.session_game_id; }if (state_.runtime == RuntimeState::Checking) state_.runtime = RuntimeState::Ready;+ if (state_.import_scanning) {+ // Folders added before stay added.+ auto found = fixture_import_candidates();+ for (auto& candidate : found)+ for (const auto& known : state_.import_candidates)+ if (import_candidate_key(known) == import_candidate_key(candidate)) candidate.imported = known.imported;+ if (find_game(state_, fixture_imported_game())) found.front().imported = fixture_imported_game();+ state_.import_candidates = std::move(found);+ state_.import_scanning = false;+ refresh_import_sheet();+ }if (state_.log_state == LogState::Loading) finish_logs();state_.startup_loading = false;state_.library_loading = false;@@ -7218,6 +7877,8 @@ std::vector<std::string> Simulation::game_settings_actions() const {std::vector<std::string> actions = {"preset-picker"};for (const auto& definition : rt::SettingsCatalogue())if (definition.tier == rt::SettingTier::kBasic && shown(definition)) actions.push_back("setting-" + definition.id);+ // Another store's game may use Steamworks: the Steam app ID its emulator is given.+ if (game.store == Store::kLocal) actions.push_back("steam-app-id");for (const auto& [section, tier] : {std::pair<const char*, rt::SettingTier>{"section-more", rt::SettingTier::kCompatibility},std::pair<const char*, rt::SettingTier>{"section-advanced", rt::SettingTier::kAdvanced}}) {actions.push_back(section);@@ -7260,7 +7921,12 @@ std::vector<std::string> Simulation::details_context_actions() const {// itself up first, so Game settings is there before Play is pressed once (#46).// Maintenance is there for every installed game, whatever its state (a title waiting for// recovery gets out through Recreate bottle); rows that can't run say why.- const bool installed = live() && is_installed(state_, state_.navigation.selected_game_id);+ const auto selected = state_.navigation.selected_game_id;+ // An imported game playing from its folder is "installed" there: its settings apply, and it+ // leaves the library rather than being uninstalled.+ const bool in_place = external_game(selected) != nullptr;+ if (in_place) std::replace(actions.begin(), actions.end(), std::string("uninstall"), std::string("import-remove"));+ const bool installed = (live() && is_installed(state_, selected)) || in_place;if (installed || game_prepared(state_.navigation.selected_game_id))actions.insert(actions.begin(), {"game-settings", "game-maintenance"});else if (refused)@@ -7270,8 +7936,8 @@ std::vector<std::string> Simulation::details_context_actions() const {if (live() && runtime != state_.runtime_games.end() && runtime->second.awaiting_registration &&runtime->second.can_prepare)actions.insert(actions.begin(), "runtime-check-again");- // The game's saves in the Saves tab, after Game settings and Maintenance.- if (live() && is_installed(state_, state_.navigation.selected_game_id)) {+ // The game's saves in the Saves tab, after Game settings and Maintenance; imported games have no link.+ if (live() && is_installed(state_, state_.navigation.selected_game_id) && selected.store != Store::kLocal) {const auto maintenance = std::find(actions.begin(), actions.end(), "game-maintenance");actions.insert(maintenance == actions.end() ? actions.begin() : maintenance + 1, "manage-saves");}diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hppindex 09ca205..d7125a8 100644--- a/src/homebrew/simulation.hpp+++ b/src/homebrew/simulation.hpp@@ -168,6 +168,10 @@ struct LiveRuntimeGame {std::string failure_code; // Recorded preparation failure; detail remains available in diagnostics.// Its setup waits for another game's to finish: Playden sets up one game at a time.bool queued = false;+ // Another store's game that uses Steamworks: the Steam app ID it was set up with, and whether that+ // came from the game's own steam_appid.txt (which wins over the one in Game settings).+ std::uint32_t steam_app_id = 0;+ bool steam_app_from_game_file = false;};// A preparation that ended Ready, listed in Queue after the waiting games.struct LiveCompletedPreparation {@@ -702,6 +706,9 @@ public:// Live mode: requests for the Local store (the Import sheet, the dev request file).void RequestImport(ImportRequest request);[[nodiscard]] std::vector<ImportRequest> TakeImportRequests();+ // Live mode: a request from TakeImportRequests that the Local store refused (an add, copy, move+ // or removal), with its sentence for the player: shown as a notice, and what waited on it dropped.+ void NotifyImportFailed(const ImportRequest& request, const std::string& message);// Writes the program an imported game starts with into its Game settings, unless the player// chose one already; saved at once so the next preparation reads it. True when it was written.bool SeedGameProgram(GameId id, const std::string& program);@@ -1006,6 +1013,41 @@ private:void advance_jobs();[[nodiscard]] std::vector<std::string> game_settings_actions() const;[[nodiscard]] std::vector<std::string> kept_manager_actions() const;+ // The Import sheet: Look for games, then the candidates grouped by drive (headings never take+ // the focus), then Close. Opened from Startup, Home's empty state and Settings › Storage.+ [[nodiscard]] std::vector<std::string> import_sheet_actions() const;+ [[nodiscard]] const LiveImportCandidate* import_candidate(const std::string& key) const;+ void open_import_sheet();+ void refresh_import_sheet();+ void move_import_sheet(int delta);+ void look_for_games();+ std::string import_programs_key_; // the candidate whose program list is open+ // The add choice (surface import-choice): play in place, copy or move, for the program picked in+ // the open program list, or for a game already added (import_choice_game_ valid: Copy or Move).+ void open_import_choice(std::size_t program, GameId game = {});+ void choose_import(const std::string& action);+ // An add sent to the Local store waits for its game: then the copy or move chosen with it is sent+ // and its page opens.+ struct PendingImport {+ std::optional<ImportRequestKind> then; // CopyIntoPlayden or MoveIntoPlayden+ std::string volume_id; // the copy's install volume (empty: the default)+ Route from = Route::Startup; // where the Import sheet was open+ };+ void settle_pending_imports();+ void start_import_transfer(GameId id, ImportRequestKind kind, const std::string& volume_id);+ void open_game_page(GameId id);+ // Imported games playing in place from their folder (State::external_games), and a copy running.+ [[nodiscard]] const LiveExternalGame* external_game(GameId id) const;+ [[nodiscard]] const Job* import_copy_job(GameId id) const;+ [[nodiscard]] std::string import_copy_target() const;+ std::size_t import_program_index_ = 0;+ GameId import_choice_game_;+ std::string import_copy_volume_; // empty: the default drive+ bool picking_import_volume_ = false; // the drive picker chooses the copy's drive+ std::map<std::string, PendingImport> pending_imports_; // by candidate key+ // Why the latest add of a folder was refused, by candidate key: its row on the Import sheet says it+ // (a dialog waits until the sheet closes).+ std::map<std::string, std::string> import_failures_;// Installed games list: its games in the chosen order (those a running batch uninstalled// included), why a game cannot be picked now (empty when it can), and the list's refresh.[[nodiscard]] std::vector<GameId> installed_list() const;diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cppindex a7a6917..f88a519 100644--- a/src/homebrew/view.cpp+++ b/src/homebrew/view.cpp@@ -1553,6 +1553,11 @@ class Render::Impl{"rail-favorites", "Favorites", std::to_string(state.library.favorites.size()),state.library.scope == "favorites"},{"rail-hidden", "Hidden", std::to_string(state.library.hidden.size()), state.library.scope == "hidden"}};+ if (has_imported_games(state))+ entries.push_back({"rail-imported", "Imported",+ std::to_string(std::count_if(state.games.begin(), state.games.end(),+ [](const Game &game) { return game.id.store == Store::kLocal; })),+ state.library.scope == "imported"});for (const Collection &collection : state.library.collections)entries.push_back({"rail-" + collection.id, collection.name,std::to_string(collection.members.size()),@@ -1622,6 +1627,7 @@ class Render::Implconst Installation *installation = nullptr;bool installed = false;bool disconnected = false;+ bool in_place = false; // an imported game playing from its folder (no installation)};TileStatus tile_status(GameId id) const@@ -1652,6 +1658,14 @@ class Render::Implstatus.disconnected = !installation->available || (volume != state.volumes.end() && !volume->available);status.installed = !status.disconnected;}+ else if (const auto external = std::find_if(state.external_games.begin(), state.external_games.end(),+ [id](const LiveExternalGame &item) { return item.game_id == id; });+ external != state.external_games.end())+ {+ status.in_place = true;+ status.disconnected = !external->available;+ status.installed = external->available;+ }return status;}@@ -1670,8 +1684,9 @@ class Render::Implreturn "Reconnect its drive";if (status.installed){- const std::string size = status.installation->installed_bytes > 0 ?- short_size(status.installation->installed_bytes) + " · " : std::string{};+ const std::uint64_t bytes = status.installation != nullptr ? status.installation->installed_bytes :+ game.install_bytes.value_or(0);+ const std::string size = bytes > 0 ? short_size(bytes) + " · " : std::string{};return size + (game.playtime_minutes && *game.playtime_minutes > 0 ?playtime_label(game.playtime_minutes) + " played" : std::string("Installed"));}@@ -1711,8 +1726,9 @@ class Render::Implconst std::size_t texture_index = number >= 900001 ? (number - 900001) % art_.size() :number % art_.size();const bool simulated = current_state_ != nullptr && current_state_->simulation_mode;+ // Fixture posters belong to the fixture's Steam games; an imported game has none (its title shows).const std::uint32_t texture = simulated- ? (game.art_failed || game.art_pending ? 0 : art_[texture_index])+ ? (game.art_failed || game.art_pending || !game.id.steam_app() ? 0 : art_[texture_index]): (live_artwork_ && current_state_ && !current_state_->account().id.empty()? store_texture(game.id, CoverUrl(game)) : 0);const TileStatus status = tile_status(game.id);@@ -1743,7 +1759,7 @@ class Render::Implconst bool downloading = status.job != nullptr &&(status.job->state == JobState::Downloading || status.job->state == JobState::Verifying ||status.job->state == JobState::Pausing || status.job->state == JobState::Paused);- const bool show_download_mark = status.job == nullptr && status.installation == nullptr;+ const bool show_download_mark = status.job == nullptr && status.installation == nullptr && !status.in_place;if (title_overlay && amount > 0.0F && !game.art_pending && !downloading){scene_.push_opacity(amount);@@ -1771,7 +1787,7 @@ class Render::Impltile_badge(rect, "Drive disconnected", kAmber);if (show_download_mark)download_mark(rect.x + rect.w - 25.0F, rect.y + rect.h - 25.0F, 1.0F);- else if (status.installed && status.installation->installed_bytes > 0 && amount < 1.0F && title_overlay)+ else if (status.installed && status.installation != nullptr && status.installation->installed_bytes > 0 && amount < 1.0F && title_overlay){const std::string size = short_size(status.installation->installed_bytes);const float width = fonts_.semibold.measure(size, 16.0F) + 20.0F;@@ -2451,7 +2467,7 @@ class Render::Implvoid save_art(const State &state, GameId id, const gfx::Rect &rect){// The cover when it is loaded; a small tile would wrap the poster's title letter by letter.- if (const Game *game = game_by_id(state, id); game != nullptr && state.simulation_mode)+ if (const Game *game = game_by_id(state, id); game != nullptr && state.simulation_mode && id.steam_app()){const std::uint32_t number = id.steam_app().value_or(0);const std::size_t index = number >= 900001 ? (number - 900001) % art_.size() : number % art_.size();@@ -2897,8 +2913,11 @@ class Render::Imply += 52.0F;break;}- // Non-installed games retain their download, destination and kept-save notes.- if (!state.simulation_mode)+ // Non-installed games retain their download, destination and kept-save notes; an imported+ // game says where it plays from (the fixture's too).+ const bool folder_note = std::any_of(view.rows.begin(), view.rows.end(),+ [](const ViewRow &row) { return row.key == "details-folder"; });+ if (!state.simulation_mode || folder_note){std::string note;gfx::Color tone = kSecondary;@@ -2927,7 +2946,7 @@ class Render::Implif (row.key == "details-download"){if (row.progress > 0.0F && row.value != "downloading")- note = "Download " + row.value;+ note = row.title + " " + row.value; // "Download paused", "Copying paused"break;}}@@ -3007,6 +3026,19 @@ class Render::Implif (found_installation != state.installations.end())installation = &*found_installation;std::string location = "Not installed";+ // An imported game playing from its folder: the drive it is on, as the Import sheet names it.+ const auto external = std::find_if(state.external_games.begin(), state.external_games.end(),+ [&game](const LiveExternalGame &item) { return item.game_id == game->id; });+ if (installation == nullptr && external != state.external_games.end())+ {+ static const std::map<std::string, std::string> drives = {+ {"usb0", "USB drive"}, {"usb1", "USB drive 2"}, {"m2", "M.2 SSD"}, {"extended", "Extended storage"},+ {"internal", "Console drop folder"}};+ const auto drive = drives.find(external->volume_id);+ location = drive == drives.end() ? external->volume_id : drive->second;+ if (!external->available)+ location += " · Disconnected";+ }if (installation != nullptr){const auto volume = std::find_if(state.volumes.begin(), state.volumes.end(),@@ -3048,7 +3080,8 @@ class Render::Implconst float facts_top = setup == view.rows.end() ? 754.0F : setup_detail.empty() ? 694.0F : 662.0F;detail_cell("Playtime", playtime, left, facts_top, 240.0F);detail_cell("Size", size, right, facts_top, 240.0F);- detail_cell("Store", game->source.empty() ? "Steam" : game->source, left, facts_top + 76.0F, 240.0F);+ detail_cell("Store", game->id.store == Store::kLocal ? std::string("Imported") : game->source.empty() ? "Steam" : game->source,+ left, facts_top + 76.0F, 240.0F);detail_cell("Location", location, right, facts_top + 76.0F, 240.0F);detail_cell("Compatibility", compat, left, facts_top + 152.0F, 240.0F);if (game->last_played && setup == view.rows.end())@@ -3396,6 +3429,7 @@ class Render::Implstatic const std::map<std::string, std::string> names = {{"choice-picker", "Game settings"}, {"preset-picker", "Game settings"}, {"button-mapping", "Game settings"},{"game-settings", "Playden"}, {"game-maintenance", "Playden"}, {"kept-data", "Settings"}, {"installed-games", "Settings"},+ {"import-games", "Library"}, {"import-programs", "Import games"}, {"import-choice", "Import games"},{"job-actions", "Downloads"}, {"prep-actions", "Preparation"}, {"storage-details", "Storage"}, {"context", "Game"}, {"compatibility", "Game"}, {"collections", "Game"}, {"collections-manage", "Library"},{"filters", "Library"}, {"logs-controls", "Logs"}, {"setting-value", "Settings"}, {"diagnostics", "Settings"},{"notices", "Notifications"}, {"qr-controls", "Sign in"}, {"session-controls", "Simulation"},@@ -3441,7 +3475,8 @@ class Render::Implview.surface == "button-mapping" || view.surface == "game-maintenance" ||view.surface == "controller" || view.surface == "logs" ||view.surface == "storage" || view.surface == "install" || view.surface == "kept-data" ||- view.surface == "installed-games";+ view.surface == "installed-games" || view.surface == "import-games" ||+ view.surface == "import-programs";const float width = overlay_transition_.panel_width(wide ? 960.0F : 640.0F);const gfx::Rect panel{kWidth - width + (1.0F - ease) * width, 0.0F, width, kHeight};overlay_.shadow({panel.x - 18.0F, 0.0F, panel.w + 18.0F, panel.h}, 0.0F, 36.0F,@@ -3767,13 +3802,15 @@ class Render::Implstd::string overlay_label(const ViewRow &row) const{+ // A sheet that only shows things says Close or Back on its cancel row.if (row.action == "cancel")- return "Cancel";+ return row.title == "Close" || row.title == "Back" ? row.title : "Cancel";// Titles come labeled from the model; only a bare action key needs its dashes softened.std::string label = row.title.empty() ? row.action : row.title;if (row.title.empty())std::replace(label.begin(), label.end(), '-', ' ');- if (!label.empty() && label.front() >= 'a' && label.front() <= 'z')+ // A program path ("redist/setup.exe") is shown as it is on the drive.+ if (!label.empty() && label.front() >= 'a' && label.front() <= 'z' && row.action.rfind("import-program-", 0) != 0)label.front() = static_cast<char>(label.front() - 'a' + 'A');return label;}@@ -3884,6 +3921,8 @@ class Render::Implconst bool settings_sheet = view.surface == "game-settings" || view.surface == "choice-picker" ||view.surface == "preset-picker" || view.surface == "button-mapping" ||view.surface == "game-maintenance";+ // The Import sheets: each folder's path (or why it can't be added) under its name.+ const bool import_sheet = view.surface == "import-games" || view.surface == "import-programs";// Every row's place in the list; the list scrolls only when it is taller than the sheet,// just enough to keep the focused row and a little of its neighbours in view, and eases there.const auto pitch = [&](const ViewRow &row) {@@ -3893,7 +3932,7 @@ class Render::Implreturn 54.0F;const bool checkbox = (view.surface == "kept-data" || view.surface == "installed-games" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0)) &&row.kind == RowKind::Toggle;- const bool described = (settings_sheet || checkbox || view.surface == "installed-games") && !row.subtitle.empty();+ const bool described = (settings_sheet || checkbox || view.surface == "installed-games" || import_sheet) && !row.subtitle.empty();return (described ? 96.0F : 72.0F) + 12.0F;};std::vector<float> tops;@@ -3966,7 +4005,7 @@ class Render::Impl// Kept game data: each game is a checkbox row with its kept date under the name.const bool checkbox = (view.surface == "kept-data" || view.surface == "installed-games" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0)) &&row.kind == RowKind::Toggle;- const bool described = (settings_sheet || checkbox || view.surface == "installed-games") && !row.subtitle.empty() && row.kind != RowKind::Heading;+ const bool described = (settings_sheet || checkbox || view.surface == "installed-games" || import_sheet) && !row.subtitle.empty() && row.kind != RowKind::Heading;const gfx::Rect rect{bounds.x, y, bounds.w, described ? 96.0F : 72.0F};const float amount = control_focus("sheet-" + row.key, index == view.focused_row);focus_glow(overlay_, rect, amount);diff --git a/tests/homebrew_browse_test.cpp b/tests/homebrew_browse_test.cppindex 3641b08..4ed678d 100644--- a/tests/homebrew_browse_test.cpp+++ b/tests/homebrew_browse_test.cpp@@ -292,6 +292,30 @@ void live_unicode_query() {check(filtered_games(state).size()==6,"clearing live query restores records");}+// The rail's "Imported" scope shows only once the library has an imported game, after Hidden, and+// lists only the imported games.+void imported_scope_lists_local_games(const std::filesystem::path& fixtures)+{+ State state = fixture_state(fixtures);+ state.navigation.route = Route::Library;+ auto scopes = library_rail_scopes(state);+ check(std::find(scopes.begin(), scopes.end(), "imported") == scopes.end() && !has_imported_games(state),+ "no Imported scope without imported games");+ Game imported;+ imported.id = playden::GameId::Local("0f8fad5b-d9cb-469f-a165-70867728950e");+ imported.title = "Night Sky";+ state.games.push_back(imported);+ scopes = library_rail_scopes(state);+ const auto hidden = std::find(scopes.begin(), scopes.end(), "hidden");+ check(has_imported_games(state) && hidden != scopes.end() && hidden + 1 != scopes.end() && *(hidden + 1) == "imported",+ "the Imported scope follows Hidden");+ state.library.scope = "imported";+ const auto games = filtered_games(state);+ check(games.size() == 1 && games.front()->id == imported.id, "the Imported scope lists only imported games");+ state.library.scope = "all";+ check(filtered_games(state).size() > 1, "All still lists every game");+}+} // namespacevoid continue_playing_ends_in_more(const std::filesystem::path& fixtures)@@ -349,6 +373,7 @@ int main(int argc, char** argv)download_window_keeps_late_jobs_visible(fixtures);utf8_caret_boundaries();disconnected_installations_remain_installed(fixtures);+ imported_scope_lists_local_games(fixtures);std::cout << "homebrew browse tests passed\n";return 0;}diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cppindex 748c98d..bde0dd5 100644--- a/tests/homebrew_library_model_test.cpp+++ b/tests/homebrew_library_model_test.cpp@@ -1129,14 +1129,14 @@ void live_storage_section_and_installed_games() {const auto* row = find_row(model, key);return row ? row->section : std::string("missing");};- for (const auto* key : {"settings-storage", "settings-installed", "settings-kept", "settings-runtime"})+ for (const auto* key : {"settings-storage", "settings-import", "settings-installed", "settings-kept", "settings-runtime"})check(section_of(key) == "Storage", "the storage rows are in the Storage section");check(section_of("settings-title-store") == "Library" && section_of("settings-cloud-saves") == "Library","Library keeps its two toggles");check(find_row(model, "settings-storage")->action == "storage-picker", "Games storage opens the drive picker");std::vector<std::string> order;for (const auto& row : model.view().rows) if (row.section == "Storage") order.push_back(row.key);- check(order == std::vector<std::string>{"settings-storage", "settings-installed", "settings-kept",+ check(order == std::vector<std::string>{"settings-storage", "settings-import", "settings-installed", "settings-kept","settings-runtime", "settings-downloads-slow"},"Storage lists its rows in order, without the hidden cleanup row");// Downloads for slow networks (#29): off by default, a toggle saved with the preferences.@@ -1159,7 +1159,7 @@ void live_storage_section_and_installed_games() {model.SetRuntimeLeftovers(1);order.clear();for (const auto& row : model.view().rows) if (row.section == "Storage") order.push_back(row.key);- check(order == std::vector<std::string>{"settings-storage", "settings-installed", "settings-kept",+ check(order == std::vector<std::string>{"settings-storage", "settings-import", "settings-installed", "settings-kept","settings-runtime-cleanup", "settings-runtime", "settings-downloads-slow"},"unused settings data sits before Runtime status when there is some");model.SetRuntimeLeftovers(0);@@ -2508,8 +2508,10 @@ void live_store_without_cloud_never_asks_the_cloud() {// Uninstalling it says its saves exist only on this console.check(model.action("details:" + key) && model.action("focus:details-more") && model.action("cross"), "context opens");activate(model, "uninstall");- check(model.state().navigation.modals.back().body.find("its saves exist only on this console") != std::string::npos,- "no Cloud sync before uninstalling");+ check(model.state().navigation.modals.back().body.find("Its saves exist only on this console") != std::string::npos &&+ model.state().navigation.modals.back().body.find("Cloud") == std::string::npos &&+ model.state().navigation.modals.back().body.find("Steam") == std::string::npos,+ "no Cloud sync before uninstalling, and no word of Steam");check(model.action("circle") && model.TakeCloudRequests().empty(), "nothing asked of the Cloud");// A new Steam sign-in takes Steam's installs and downloads away, not the imported ones.model.UpdateAccount({AuthState::Waiting, {}, {}, "https://s.team/q/synthetic", {}, true});@@ -2526,7 +2528,192 @@ void live_store_without_cloud_never_asks_the_cloud() {}}+// Live: the Import sheet sends Look for games and the add to the Local store, follows the scan, and+// keeps the focus on its row when the candidates change.+void live_import_sheet_sends_requests() {+ using playden::homebrew::ImportRequestKind;+ using playden::homebrew::LiveImportCandidate;+ auto model = make_live();+ check(model.state().navigation.route == Route::Startup && has_row(model, "startup-import"), "Startup offers Import games");+ activate(model, "startup-import");+ check(model.view().surface == "import-games" && model.view().rows.size() == 2, "the empty sheet opens");+ activate(model, "import-look");+ auto requests = model.TakeImportRequests();+ check(requests.size() == 1 && requests.front().kind == ImportRequestKind::LookForGames, "Look for games reaches the store");+ model.UpdateImportCandidates({}, true);+ check(find_row(model, "import-look")->title == "Looking for games…" && !find_row(model, "import-look")->enabled,+ "the scan shows");+ model.action("cross");+ check(model.TakeImportRequests().empty(), "no second scan while one runs");+ LiveImportCandidate delores;+ delores.volume_id = "usb0"; delores.folder = "playden/import/Delores"; delores.path = "/mnt/usb0/playden/import/Delores";+ delores.title = "Delores"; delores.total_bytes = 230'000'000; delores.ascii_ok = true;+ delores.programs = {{"Delores.exe", 9'000'000, false}, {"setup.exe", 1'000'000, true}};+ LiveImportCandidate drop = delores;+ drop.volume_id = "internal"; drop.folder = "playden-import/Delores"; drop.path = "/data/playden-import/Delores";+ model.UpdateImportCandidates({delores, drop}, false);+ check(model.state().navigation.focus_key == "import-look" && find_row(model, "import-look")->enabled,+ "the focus stays on Look for games when the scan ends");+ check(has_row(model, "import-group-usb0") && has_row(model, "import-group-internal") &&+ find_row(model, "import-candidate-usb0:playden/import/Delores")->value == "230 MB",+ "candidates are listed by drive");+ activate(model, "import-candidate-internal:playden-import/Delores");+ check(model.view().surface == "import-programs" && find_row(model, "import-program-1")->title == "setup.exe",+ "the program list opens, paths as they are");+ activate(model, "import-program-0");+ check(model.view().surface == "import-choice" && find_row(model, "import-play-in-place")->title == "Play from the drop folder" &&+ find_row(model, "import-move")->value == "Instant" && !has_row(model, "import-copy"),+ "a drop-folder game plays from there or moves into Playden");+ activate(model, "import-play-in-place");+ requests = model.TakeImportRequests();+ check(requests.size() == 1 && requests.front().kind == ImportRequestKind::Add && requests.front().volume_id == "internal" &&+ requests.front().folder == "playden-import/Delores" && requests.front().program == "Delores.exe",+ "choosing the program adds the folder");+ check(model.view().surface == "import-games" &&+ model.state().navigation.focus_key == "import-candidate-internal:playden-import/Delores",+ "back on the sheet at the folder");+ // A new scan without the focused folder gives the focus to Look for games; an open program+ // list of a folder that went away closes.+ activate(model, "import-candidate-usb0:playden/import/Delores");+ model.UpdateImportCandidates({drop}, false);+ check(model.view().surface == "import-games" && model.state().navigation.focus_key == "import-look",+ "a folder that went away closes its program list");+ check(model.action("circle") && model.state().navigation.modals.empty(), "the sheet closes");+}++// Live: the add choice (play in place, copy with its drive, move), the copy or move sent once the+// store gives the game its ID, the game's page once the library lists it, refusals said to the+// player, and the page of an imported game (Copy/Move, progress, Remove from library).+void live_import_choice_and_details() {+ using playden::homebrew::ImportRequest;+ using playden::homebrew::ImportRequestKind;+ using playden::homebrew::LiveImportCandidate;+ auto model = make_live();+ check(model.view().subtitle == "Connect a store or import games to fill your library.", "Startup mentions importing");+ model.UpdateVolumes({{"internal", "Console storage", true, 900'000'000'000, 500'000'000'000},+ {"usb1", "USB drive 2", true, 900'000'000'000, 500'000'000'000}}, "internal");+ LiveImportCandidate rally;+ rally.volume_id = "usb0"; rally.folder = "playden/import/Rally"; rally.path = "/mnt/usb0/playden/import/Rally";+ rally.title = "Rally"; rally.total_bytes = 8'900'000'000; rally.ascii_ok = true;+ rally.programs = {{"Rally.exe", 9'000'000, false}};+ LiveImportCandidate cafe = rally;+ cafe.folder = "playden/import/Café"; cafe.path = "/mnt/usb0/playden/import/Café"; cafe.title = "Café"; cafe.ascii_ok = false;+ LiveImportCandidate drop = rally;+ drop.volume_id = "internal"; drop.folder = "playden-import/Drop"; drop.path = "/data/playden-import/Drop"; drop.title = "Drop";+ model.UpdateImportCandidates({rally, cafe, drop}, false);+ activate(model, "startup-import");+ // Look for games pressed twice before the store answers asks once.+ activate(model, "import-look");+ model.action("cross");+ auto requests = model.TakeImportRequests();+ check(requests.size() == 1 && requests[0].kind == ImportRequestKind::LookForGames &&+ find_row(model, "import-look")->title == "Looking for games…",+ "a second Look for games before the store answers is ignored");+ model.UpdateImportCandidates({rally, cafe, drop}, false);++ // A copy-only folder: no Play from the drive, and why.+ activate(model, "import-candidate-usb0:playden/import/Café");+ activate(model, "import-program-0");+ check(model.view().surface == "import-choice" && !has_row(model, "import-play-in-place") && has_row(model, "import-copy") &&+ model.view().subtitle.find("characters the PS5 can't start a game from") != std::string::npos,+ "a folder the PS5 can't play from can only be copied");+ model.action("circle");+ model.action("circle");++ // A drive folder: play in place, or copy with its size, an estimate and the drive.+ activate(model, "import-candidate-usb0:playden/import/Rally");+ activate(model, "import-program-0");+ check(find_row(model, "import-play-in-place")->title == "Play from the drive" &&+ find_row(model, "import-copy")->value == "8.9 GB · about 14 min" && !has_row(model, "import-move") &&+ find_row(model, "storage-picker")->title == "Copy to" && find_row(model, "storage-picker")->value == "Console storage",+ "a drive folder plays from there or is copied, with its size, time and drive");+ activate(model, "storage-picker");+ check(model.view().surface == "storage" && find_row(model, "volume-internal")->selected, "the drive picker opens");+ activate(model, "volume-usb1");+ check(model.view().surface == "import-choice" && model.state().navigation.focus_key == "import-copy" &&+ find_row(model, "storage-picker")->value == "USB drive 2",+ "choosing a drive returns to Copy into Playden");+ activate(model, "import-copy");+ requests = model.TakeImportRequests();+ check(requests.size() == 1 && requests[0].kind == ImportRequestKind::Add && requests[0].volume_id == "usb0" &&+ requests[0].program == "Rally.exe",+ "Copy into Playden adds the folder first");+ check(model.view().surface == "import-games" && find_row(model, "import-candidate-usb0:playden/import/Rally")->value == "Adding…",+ "the sheet says the folder is being added");+ const auto id = playden::GameId::Local("6d1f3a52-0c55-4f3e-9b2a-5d1c7e0a9f11");+ rally.imported = id;+ model.UpdateImportCandidates({rally, cafe, drop}, false);+ requests = model.TakeImportRequests();+ check(requests.size() == 1 && requests[0].kind == ImportRequestKind::CopyIntoPlayden && requests[0].game_id == id &&+ requests[0].volume_id == "usb1",+ "the copy goes to the chosen drive once the game has its ID");+ LibraryUpdate imported{{game(id, "Rally")}, false, {}, false, false, {}};+ imported.source = playden::Store::kLocal;+ check(model.UpdateLibrary(imported), "imported library");+ check(model.state().navigation.route == Route::Details && model.state().navigation.detail_id == id &&+ model.state().navigation.detail_origin == Route::Home && model.state().navigation.modals.empty(),+ "the added game's page opens, even from Startup");++ // Its page while it plays from the drive, then while it copies.+ model.UpdateExternalGames({{id, "usb0", true, ""}});+ check(find_row(model, "details-copy") && find_row(model, "details-copy")->title == "Copy into Playden" &&+ find_row(model, "details-remove") && !has_row(model, "details-cloud") && !has_row(model, "details-uninstall"),+ "an imported game on a drive offers Copy into Playden and Remove from library");+ // A folder the PS5 can't play from (its name) still offers the copy.+ model.UpdateExternalGames({{id, "usb0", true, "The game's folder name has characters the PS5 can't play from."}});+ check(has_row(model, "details-installed") && has_row(model, "details-copy") && has_row(model, "details-remove"),+ "a copy-only folder says why and offers Copy into Playden");+ model.UpdateExternalGames({{id, "usb0", true, ""}});+ model.UpdateInstalls({{id, playden::homebrew::JobState::Downloading, 4'450'000'000, 8'900'000'000, {}, "usb1"}}, {});+ const auto* copying = find_row(model, "details-download");+ check(copying && copying->title == "Copying" && copying->progress > 0.49F && copying->progress < 0.51F &&+ !has_row(model, "details-copy") && !find_row(model, "details-remove")->enabled,+ "the copy's progress replaces Copy into Playden");+ // Copied: Uninstall, not Remove from library.+ model.UpdateInstalls({}, {{id, 8'900'000'000, "usb1", true}});+ model.UpdateExternalGames({});+ check(has_row(model, "details-uninstall") && !has_row(model, "details-remove") && !has_row(model, "details-copy"),+ "a copied game uninstalls");++ // A refused copy or add is said to the player.+ model.NotifyImportFailed({ImportRequestKind::CopyIntoPlayden, id, "usb1"}, "Not enough space on USB drive 2.");+ check(!model.state().navigation.modals.empty() && model.state().navigation.modals.back().title == "Can't copy Rally" &&+ model.state().navigation.modals.back().body == "Not enough space on USB drive 2.",+ "a refused copy opens a dialog");+ model.action("cross");++ // Home with only the imported game, signed out: about the library, not the account.+ model.action("circle");+ check(model.state().navigation.route == Route::Home && model.view().subtitle == "Your library", "Home is neutral");++ // The drop folder: play from there, or move.+ activate(model, "home-connect");+ while (!model.state().navigation.modals.empty()) model.action("circle");+ model.action("l1");+ for (int step = 0; step < 4 && model.state().navigation.route != Route::Settings; ++step) model.action("r1");+ model.action("focus:settings-import");+ model.action("cross");+ activate(model, "import-candidate-internal:playden-import/Drop");+ activate(model, "import-program-0");+ check(find_row(model, "import-play-in-place")->title == "Play from the drop folder" && find_row(model, "import-move")->value == "Instant" &&+ !has_row(model, "import-copy") && !has_row(model, "storage-picker"),+ "a drop-folder game plays from there or moves");+ activate(model, "import-move");+ requests = model.TakeImportRequests();+ check(requests.size() == 1 && requests[0].kind == ImportRequestKind::Add, "Move adds the folder first");+ model.NotifyImportFailed(requests[0], "The game's folder can't be used.");+ const auto* refused = find_row(model, "import-candidate-internal:playden-import/Drop");+ check(refused && refused->enabled && refused->value != "Adding…" &&+ refused->subtitle == "Not added · The game's folder can't be used.",+ "a refused add shows on its row");+ drop.imported = playden::GameId::Local("7c9e6679-7425-40de-944b-e07fc1f90ae7");+ model.UpdateImportCandidates({rally, cafe, drop}, false);+ check(model.TakeImportRequests().empty(), "a refused add sends nothing more when the folder is added later");+}+int main() {+ live_import_sheet_sends_requests();+ live_import_choice_and_details();store_art_follows_the_store();non_canonical_game_keys_select_nothing();live_launch_failure_remains_visible_without_a_details_status_line();diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cppindex 76b43f9..c927b38 100644--- a/tests/homebrew_live_model_test.cpp+++ b/tests/homebrew_live_model_test.cpp@@ -676,6 +676,70 @@ void live_root_access_missing() {check(!fixture.state().root_access_missing, "root access: the fixture model ignores it");}+const playden::homebrew::ViewRow* find_view_row(const Simulation& model, const std::string& key) {+ for (const auto& row : model.view().rows) if (row.key == key) return &row;+ return nullptr;+}++// An imported game's Game settings: Program, and a "Steam app ID" that takes plain decimal only,+// shows the game's own steam_appid.txt when that one wins, and clears when emptied.+void live_imported_game_steam_app_id(const std::filesystem::path& base) {+ std::filesystem::create_directories(base);+ auto model = make_live(base);+ model.SetGameSettingsFile(base / "imported-settings.json");+ model.SetSettingsData({{"playden-default", "Playden default", "Most games", "", {}}}, {});+ const auto id = playden::GameId::Local("6d1f3a52-0c55-4f3e-9b2a-5d1c7e0a9f11");+ playden::GameSummary game;+ game.id = id;+ game.title = "Night Sky";+ playden::homebrew::LibraryUpdate update{{game}, false, {}, false, true, 100};+ update.source = playden::Store::kLocal;+ check(model.UpdateLibrary(update), "imported library delivered");+ model.UpdateExternalGames({{id, "usb0", true, ""}});+ playden::homebrew::LiveRuntimeGame runtime;+ runtime.game_id = id;+ runtime.status = "Ready";+ runtime.ready = runtime.prepared = runtime.has_title = true;+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});+ check(model.action("details:" + playden::ToKey(id)), "imported game details");+ activate(model, "details-more");+ check(find_view_row(model, "game-settings") && find_view_row(model, "import-remove") &&+ !find_view_row(model, "uninstall") && !find_view_row(model, "manage-saves"),+ "an imported game playing in place has Game settings and Remove from library, no Saves link");+ activate(model, "game-settings");+ const auto* row = find_view_row(model, "steam-app-id");+ check(row && row->title == "Steam app ID" && row->value == "None" &&+ row->subtitle == "Only for games that need Steam. Most run without it." && find_view_row(model, "setting-launch_option"),+ "Game settings lists Program and Steam app ID");+ activate(model, "steam-app-id");+ check(model.state().editor.active && model.state().editor.purpose == "Steam app ID" && model.state().editor.symbols,+ "Steam app ID opens the keyboard on its digits");+ model.SubmitEditorText("0440");+ const auto saved = [&] {+ const auto found = model.state().game_settings.find(id);+ return found == model.state().game_settings.end() ? 0u : found->second.steam_app_id;+ };+ check(saved() == 0 && std::any_of(model.state().notices.begin(), model.state().notices.end(),+ [](const auto& notice) { return notice.id == "setting-validation"; }),+ "a number that is not plain decimal is refused");+ model.SubmitEditorText("abc");+ check(saved() == 0, "letters are refused");+ model.SubmitEditorText("440");+ check(saved() == 440 && !model.state().editor.active && find_view_row(model, "steam-app-id")->value == "440" &&+ std::none_of(model.state().notices.begin(), model.state().notices.end(),+ [](const auto& notice) { return notice.id == "setting-validation"; }),+ "a plain Steam app ID is saved");+ runtime.steam_app_id = 620;+ runtime.steam_app_from_game_file = true;+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});+ row = find_view_row(model, "steam-app-id");+ check(row && row->value == "620" && row->subtitle == "From the game's steam_appid.txt",+ "the game's own steam_appid.txt shows when it wins");+ activate(model, "steam-app-id");+ model.SubmitEditorText("");+ check(saved() == 0, "an empty Steam app ID clears it");+}+} // namespaceint main() {@@ -689,6 +753,7 @@ int main() {settings_survive_account_restore_and_cache_action_is_honest(base);live_settings_follow_the_prepared_title(base);live_program_change_applies_like_other_settings(base);+ live_imported_game_steam_app_id(base);live_starts_clean_and_never_reads_or_writes_fixtures(base);live_dispatches_bounded_service_effects_and_replaces_challenges(base);failed_signout_preserves_account_until_external_clear(base);diff --git a/tests/homebrew_management_tour_test.cpp b/tests/homebrew_management_tour_test.cppindex 6e67389..cdee07f 100644--- a/tests/homebrew_management_tour_test.cpp+++ b/tests/homebrew_management_tour_test.cpp@@ -34,6 +34,9 @@ static void choose(Simulation& simulation, const std::string& key) {const int index = static_cast<int>(std::distance(rows.begin(), target));for (int count = 0; count < 100 && simulation.view().focused_row != index; ++count)press(simulation, simulation.view().focused_row < index ? "down" : "up");+ if (simulation.state().navigation.focus_key != key)+ std::fprintf(stderr, "focus %s, wanted %s on %s\n", simulation.state().navigation.focus_key.c_str(), key.c_str(),+ simulation.view().surface.c_str());require(simulation.state().navigation.focus_key == key, "navigation reaches requested visible row");press(simulation, "cross");}@@ -168,6 +171,63 @@ int main(int argc, char** argv) {require(std::count_if(simulation.state().jobs.begin(), simulation.state().jobs.end(),[game](const Job& entry) { return entry.kind == "uninstall" && entry.game_id == game; }) == 1,"confirming Uninstall queues one uninstall operation");++ // Import: Skip at Startup, Import games from Home, add a folder to play from its drive and Play+ // it; then copy it into Playden, follow the copy, and uninstall the copy.+ // A console with nothing queued: the earlier journeys' jobs stay with their own model.+ std::filesystem::remove(profile, error);+ Simulation importing(argv[1], profile);+ importing.scenario("signed-out");+ choose(importing, "startup-skip");+ require(importing.state().navigation.route == Route::Home, "Skip for now reaches Home");+ choose(importing, "home-import");+ require(importing.view().surface == "import-games", "Home's Import games opens the sheet");+ if (importing.state().import_candidates.empty()) {+ choose(importing, "import-look");+ importing.tick(1);+ }+ choose(importing, "import-candidate-usb0:playden/import/Old School Rally");+ require(importing.view().surface == "import-programs", "a folder lists its programs");+ choose(importing, "import-program-0");+ require(importing.view().surface == "import-choice" && has_row(importing, "import-copy"),+ "the program leads to the choice of where the game plays from");+ choose(importing, "import-play-in-place");+ const auto imported = importing.state().navigation.detail_id.value_or(playden::GameId{});+ require(importing.state().navigation.route == Route::Details && imported.store == playden::Store::kLocal &&+ importing.state().navigation.detail_origin == Route::Home,+ "adding the game opens its page, which returns Home");+ require(has_row(importing, "details-copy") && has_row(importing, "details-remove") && !has_row(importing, "details-cloud"),+ "an imported game playing from its drive offers Copy and Remove, no Cloud saves");+ choose(importing, "details-play");+ require(importing.state().navigation.route == Route::Session && importing.state().session_game_id == imported,+ "Play launches the imported game");+ importing.tick(2);+ require(importing.state().session == SessionState::Running, "the imported game runs");+ choose(importing, "session-quit");+ if (importing.view().surface == "confirmation") choose(importing, "confirm-destructive");+ importing.tick(1);+ require(importing.state().navigation.route == Route::Details && importing.state().session == SessionState::Idle,+ "quitting the game returns to its page");+ choose(importing, "details-copy");+ require(importing.view().surface == "import-choice" && has_row(importing, "storage-picker") &&+ !has_row(importing, "import-play-in-place"),+ "Copy into Playden asks for the drive");+ choose(importing, "import-copy");+ require(importing.state().navigation.route == Route::Details && has_row(importing, "details-download") &&+ !has_row(importing, "details-copy"),+ "the page shows the copy's progress");+ // The fixture queue runs its own downloads first, one at a time.+ for (int tick = 0; tick < 600 && has_row(importing, "details-download"); ++tick) importing.tick(1);+ require(!has_row(importing, "details-download") && has_row(importing, "details-uninstall") &&+ !has_row(importing, "details-remove") && has_row(importing, "details-play"),+ "the copy finishes: the game plays from Playden and uninstalls");+ choose(importing, "details-uninstall");+ require(importing.state().navigation.focus_key == "cancel", "uninstall defaults to decline");+ choose(importing, "confirm-destructive");+ require(std::count_if(importing.state().jobs.begin(), importing.state().jobs.end(),+ [imported](const Job& entry) { return entry.kind == "uninstall" && entry.game_id == imported; }) == 1,+ "uninstalling the copy queues one uninstall operation");+std::filesystem::remove(profile, error);- std::puts("PASS: install, storage, space, queue, pause/resume, cancel, retry, recovery, verify, uninstall by controller");+ std::puts("PASS: install, storage, space, queue, pause/resume, cancel, retry, recovery, verify, uninstall, import by controller");}diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cppindex 6f5a89e..7020dda 100644--- a/tests/homebrew_simulation_test.cpp+++ b/tests/homebrew_simulation_test.cpp@@ -716,9 +716,12 @@ void t13_settings_sections_rail(const std::filesystem::path& fixtures, const std"T13 Cross on the rail enters the section without activating its row");simulation.action("down");simulation.action("down");+ simulation.action("down");check(section() == "Storage" && simulation.state().navigation.focus_key == "settings-runtime","T13 Down on a section's last row stays in the section");simulation.action("up");+ check(simulation.state().navigation.focus_key == "settings-import", "T13 Up moves to Import games");+ simulation.action("up");check(section() == "Storage" && simulation.state().navigation.focus_key == "settings-storage" &&!simulation.state().navigation.tabs_focused, "T13 Up stops on the section's first row");simulation.action("up");@@ -1096,6 +1099,187 @@ void t16_system_keyboard_text(const std::filesystem::path& fixtures, const std::check(simulation.state().sign_in.code == "AB12C", "T16 text with no open field is ignored");}+// T17: the Import sheet opens from Startup, Home's empty state and Settings › Storage; it lists the+// drives' folders by drive with their size, says what to do when there are none, shows the scan,+// and adds a game from its program list.+static void t17_import_sheet(const std::filesystem::path& fixtures, const std::filesystem::path& profile) {+ using playden::homebrew::RowKind;+ using playden::homebrew::Route;+ playden::homebrew::Simulation simulation(fixtures, profile);+ const auto row = [&](const std::string& key) -> const playden::homebrew::ViewRow* {+ for (const auto& item : simulation.view().rows) if (item.key == key) return &item;+ return nullptr;+ };+ const auto keys = [&] {+ std::vector<std::string> result;+ for (const auto& item : simulation.view().rows) result.push_back(item.key);+ return result;+ };+ const auto press = [&](const std::string& key) {+ check(simulation.action("focus:" + key) && simulation.action("cross"), "T17 row activates");+ };+ // Startup: Import games sits between Connect Steam and Skip for now, and opens the sheet.+ simulation.scenario("signed-out");+ check((keys() == std::vector<std::string>{"startup-connect", "startup-import", "startup-skip"}),+ "T17 Startup offers Import games under Connect Steam");+ press("startup-import");+ check(simulation.view().surface == "import-games" && simulation.state().navigation.route == Route::Startup &&+ simulation.state().account().authentication == playden::homebrew::AuthState::SignedOut,+ "T17 Import games opens the sheet, not the sign-in");+ simulation.action("circle");+ check(simulation.state().navigation.modals.empty() && simulation.state().navigation.focus_key == "startup-import",+ "T17 Circle returns to Startup's Import games");+ // Home's empty state.+ press("startup-skip");+ check(row("home-import") && row("home-import")->title == "Import games", "T17 Home's empty state offers Import games");+ press("home-import");+ check(simulation.view().surface == "import-games", "T17 Home opens the sheet");++ // Empty: the instructions, Look for games, and a scan that fills the list.+ check(simulation.scenario("import-empty"), "T17 import-empty scenario");+ check(simulation.view().surface == "import-games" && simulation.state().navigation.route == Route::Settings,+ "T17 the scenario opens the sheet over Settings");+ check((keys() == std::vector<std::string>{"import-look", "cancel"}) &&+ simulation.view().subtitle.find("Copy game folders into playden/import on an exFAT drive") == 0 &&+ simulation.state().navigation.focus_key == "import-look",+ "T17 the empty sheet says where to copy games");+ check(simulation.view().rows.back().title == "Close", "T17 the sheet closes with Close");+ simulation.action("cross");+ check(row("import-look")->title == "Looking for games…" && row("import-look")->kind == RowKind::Status &&+ !row("import-look")->enabled && simulation.state().import_scanning,+ "T17 Look for games shows the scan");+ simulation.tick(1);+ check(!simulation.state().import_scanning && simulation.state().import_candidates.size() == 6,+ "T17 the scan finds the fixture folders");+ check(simulation.state().navigation.focus_key == "import-look", "T17 the focus stays on Look for games");+ check(row("import-group-usb0") && row("import-group-usb0")->kind == RowKind::Heading &&+ row("import-group-usb0")->title == "USB drive" && row("import-group-m2")->title == "M.2 SSD" &&+ row("import-group-internal")->title == "Console drop folder" && !row("import-group-usb1"),+ "T17 folders are grouped by drive");+ simulation.action("down");+ check(simulation.state().navigation.focus_key == "import-candidate-usb0:playden/import/Night Sky",+ "T17 Down steps over the drive heading");+ simulation.action("down"); simulation.action("down"); simulation.action("down");+ check(simulation.state().navigation.focus_key == "import-candidate-m2:playden/import/Delores",+ "T17 Down steps over the next drive's heading too");+ simulation.action("up");+ check(simulation.state().navigation.focus_key == "import-candidate-usb0:playden/import/Café Étoile",+ "T17 Up steps back over it");+ simulation.action("circle");+ check(simulation.state().navigation.modals.empty() && simulation.state().navigation.focus_key == "settings-import" &&+ row("settings-import")->value == "6 found",+ "T17 Settings › Storage counts the folders found");++ // Candidates: sizes, Added, copy only, no program.+ check(simulation.scenario("import-candidates"), "T17 import-candidates scenario");+ check(simulation.state().navigation.focus_key == "import-candidate-usb0:playden/import/Old School Rally",+ "T17 the focus starts on the first game not added");+ check(row("import-candidate-usb0:playden/import/Night Sky")->value == "Added", "T17 an added folder says Added");+ const auto* rally = row("import-candidate-usb0:playden/import/Old School Rally");+ check(rally->value == "938 MB" && rally->subtitle == "/mnt/usb0/playden/import/Old School Rally", "T17 size and path");+ check(row("import-candidate-usb0:playden/import/Café Étoile")->subtitle.find(" · Copy only") != std::string::npos,+ "T17 a non-ASCII path can only be copied");+ const auto* tools = row("import-candidate-internal:playden-import/Tools");+ check(!tools->enabled && tools->subtitle == "No Windows program found", "T17 a folder without a program can't be added");+ check(simulation.view().subtitle.find("Games found in playden/import") == 0, "T17 the sheet's subtitle with games");++ // Copy only: its programs wait for Copy into Playden.+ press("import-candidate-usb0:playden/import/Café Étoile");+ check(simulation.view().surface == "import-programs" &&+ simulation.view().subtitle == "This folder's name has characters the PS5 can't start a game from. "+ "Copy it into Playden instead." &&+ row("import-program-0")->enabled && row("import-program-1")->subtitle == "Installer or tool",+ "T17 a copy-only folder says why");+ simulation.action("circle");+ check(simulation.view().surface == "import-games", "T17 Back returns to the sheet");++ // Add: the program list, then the folder is in the library.+ press("import-candidate-usb0:playden/import/Old School Rally");+ check(simulation.view().surface == "import-programs" && simulation.view().title == "Old School Rally" &&+ row("import-program-0")->title == "OldSchoolRally.exe" && row("import-program-0")->subtitle.empty() &&+ row("import-program-1")->subtitle == "Installer or tool" && simulation.view().rows.back().title == "Back" &&+ simulation.state().navigation.focus_key == "import-program-0",+ "T17 the program list puts the game first and labels helpers");+ simulation.action("cross");+ check(simulation.view().surface == "import-choice" && row("import-play-in-place")->title == "Play from the drive",+ "T17 choosing the program asks where the game plays from");+ simulation.action("cross");+ check(simulation.state().navigation.route == Route::Details && simulation.state().navigation.modals.empty() &&+ simulation.state().navigation.detail_id && simulation.state().navigation.detail_id->store == playden::Store::kLocal,+ "T17 playing from the drive adds the game and opens its page");+ const auto& games = simulation.state().games;+ check(std::count_if(games.begin(), games.end(), [](const playden::homebrew::Game& game) {+ return game.id.store == playden::Store::kLocal; }) == 2,+ "T17 the library has both imported games");+ // An added folder opens its game's page.+ check(simulation.scenario("import-candidates"), "T17 import-candidates scenario again");+ press("import-candidate-usb0:playden/import/Night Sky");+ check(simulation.state().navigation.route == Route::Details && simulation.state().navigation.modals.empty() &&+ simulation.state().navigation.detail_id &&+ simulation.state().navigation.detail_id->store == playden::Store::kLocal,+ "T17 an added folder opens its game");+}++// T18: an imported game's page (Store "Imported", its drive, Copy and Remove from library), the+// copy's progress, removing it from the library, and a drop-folder game moved into Playden.+static void t18_imported_game_page(const std::filesystem::path& fixtures, const std::filesystem::path& profile) {+ using playden::homebrew::Route;+ playden::homebrew::Simulation simulation(fixtures, profile);+ const auto row = [&](const std::string& key) -> const playden::homebrew::ViewRow* {+ for (const auto& item : simulation.view().rows) if (item.key == key) return &item;+ return nullptr;+ };+ const auto press = [&](const std::string& key) {+ check(simulation.action("focus:" + key) && simulation.action("cross"), "T18 row activates");+ };+ check(simulation.scenario("import-details"), "T18 import-details scenario");+ check(simulation.state().navigation.route == Route::Details && row("details-play") && row("details-play")->title == "Play" &&+ row("details-copy")->title == "Copy into Playden" && row("details-remove")->title == "Remove from library" &&+ row("details-folder")->title == "Plays from /mnt/usb0/playden/import/Night Sky" && !row("details-cloud"),+ "T18 an imported game's page plays in place and offers Copy and Remove");+ // Copy: the drive choice, then the copy's progress on the page.+ press("details-copy");+ check(simulation.view().surface == "import-choice" && !row("import-play-in-place") && row("import-copy")->value == "412 MB · about 1 min",+ "T18 Copy into Playden from the page asks for the drive");+ press("storage-picker");+ check(simulation.view().surface == "storage" && simulation.view().title == "Copy to", "T18 the copy's drive picker");+ press("volume-internal");+ check(simulation.view().surface == "import-choice" && row("storage-picker")->value == "Console fixture storage",+ "T18 the chosen drive shows on the choice");+ press("import-copy");+ check(simulation.state().jobs.back().volume_id == "internal" && row("details-download") &&+ row("details-download")->title == "Copying" && !row("details-copy"),+ "T18 the copy runs on the chosen drive and shows on the page");+ check(simulation.scenario("import-copying"), "T18 import-copying scenario");+ check(row("details-download")->progress > 0.39F && row("details-download")->progress < 0.41F, "T18 the copy is 40% done");++ // Remove from library: the folder stays, and can be added again.+ check(simulation.scenario("import-details"), "T18 import-details again");+ press("details-remove");+ check(simulation.view().surface == "confirmation" && simulation.state().navigation.focus_key == "cancel" &&+ simulation.state().navigation.modals.back().body.find("stay where they are") != std::string::npos,+ "T18 Remove from library asks first and says the files stay");+ press("confirm-destructive");+ check(simulation.state().navigation.route == Route::Library && simulation.state().navigation.modals.empty() &&+ !simulation.state().import_candidates.front().imported.valid() &&+ std::none_of(simulation.state().games.begin(), simulation.state().games.end(),+ [](const playden::homebrew::Game& game) { return game.title == "Night Sky"; }),+ "T18 the game leaves the library and its folder can be added again");++ // The drop folder: Move into Playden, instant.+ check(simulation.scenario("import-candidates"), "T18 import-candidates scenario");+ press("import-candidate-internal:playden-import/Hollow Knight");+ press("import-program-0");+ check(row("import-play-in-place")->title == "Play from the drop folder" && row("import-move")->value == "Instant" &&+ !row("import-copy"),+ "T18 a drop-folder game plays from there or moves");+ press("import-move");+ const auto id = simulation.state().navigation.detail_id.value_or(playden::GameId{});+ check(simulation.state().navigation.route == Route::Details && id.store == playden::Store::kLocal &&+ row("details-uninstall") && !row("details-remove") && !row("details-copy"),+ "T18 a moved game is in Playden at once and uninstalls");+}+int main(int argc, char** argv) {check(argc == 2, "fixture directory argument is required");const std::filesystem::path fixtures(argv[1]);@@ -1143,6 +1327,10 @@ int main(int argc, char** argv) {clean();t16_system_keyboard_text(fixtures, profile);clean();+ t17_import_sheet(fixtures, profile);+ clean();+ t18_imported_game_page(fixtures, profile);+ clean();public_contract_and_snapshot(fixtures, profile);std::error_code error;std::filesystem::remove(profile, error);