Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Add a DLC picker to the install sheet

Leonardo Lobato7e377c76162b
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index 9cba866..207d4e2 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -2018,7 +2018,7 @@ void Controller::TickInstalls() {
// version's estimate is reserved, not the public one.
const auto estimate = request.install_bytes ? request.install_bytes
: game == games.end() ? std::nullopt : game->install_bytes;
- installs_->Install(request.game_id, estimate, request.volume_id, {request.language, request.branch});
+ installs_->Install(request.game_id, estimate, request.volume_id, {request.language, request.branch, request.excluded_dlc});
break;
}
case InstallRequestKind::Update: {
@@ -2158,6 +2158,7 @@ void Controller::TickInstalls() {
state == JobState::Downloading ? job.server_name : std::string(), update, job.locked,
update && running && job.step == steam::InstallStep::kCheckingFiles,
update && running && (job.step == steam::InstallStep::kApplying || job.locked)};
+ live.estimated_bytes = job.estimated_bytes;
if (move) {
using Step = LiveInstallJob::MoveStep;
live.move = true;
@@ -2205,6 +2206,7 @@ void Controller::TickAppDetails() {
model_.ResetSizeChecks();
requested_generation_ = generation;
requested_detail_.reset();
+ details_asked_.clear();
launch_options_.clear();
launch_options_reason_.clear();
launches_any_branch_.clear();
@@ -2277,12 +2279,19 @@ void Controller::TickAppDetails() {
// installed game is asked again at each visit: Steam may have a newer version since.
// Away from a game's page (or its session), the next visit asks again.
if (state.navigation.route != Route::Details && state.navigation.route != Route::Session) requested_detail_.reset();
- if (state.account().authentication == AuthState::SignedIn && state.navigation.detail_id &&
- state.navigation.detail_id != requested_detail_) {
- requested_detail_ = state.navigation.detail_id;
- if (auto* details = Details(requested_detail_->store); details && details == app_details_) {
- if (game_roots_.count(*requested_detail_)) details->Refresh(*requested_detail_, generation, true);
- else details->RequestFirst(*requested_detail_, generation);
+ if (state.account().authentication == AuthState::SignedIn && state.navigation.detail_id) {
+ const auto id = *state.navigation.detail_id;
+ const DetailsAsked now{licenses_read_, game_roots_.count(id) > 0};
+ const auto asked = details_asked_.find(id);
+ const auto ask = NextDetailsAsk(asked == details_asked_.end() ? std::nullopt : std::optional<DetailsAsked>(asked->second), now,
+ state.navigation.detail_id != requested_detail_);
+ if (ask != DetailsAsk::kNothing) {
+ requested_detail_ = id;
+ details_asked_[id] = now;
+ if (auto* details = Details(id.store); details && details == app_details_) {
+ if (ask == DetailsAsk::kAgain) details->Refresh(id, generation, true);
+ else details->RequestFirst(id, generation);
+ }
}
}
for (const auto& details : app_details_->Pump(8)) {
@@ -2297,8 +2306,16 @@ void Controller::TickAppDetails() {
game_version.languages.push_back({size.language, size.download_bytes, size.install_bytes});
versions.push_back(std::move(game_version));
}
+ std::vector<GameDlc> dlc;
+ for (const auto& choice : details.dlc)
+ {
+ dlc.push_back({choice.app_id, choice.name, choice.download_bytes, choice.install_bytes, choice.free, {}});
+ for (const auto& other : choice.other_sizes)
+ dlc.back().other_sizes.push_back({other.branch, other.language, other.download_bytes, other.install_bytes, other.optional});
+ dlc.back().optional = choice.optional;
+ }
model_.UpdateAppDetails(details.id, details.download_bytes, details.install_bytes, details.windows_installable,
- details.languages, details.dlc_count, std::move(versions),
+ details.languages, std::move(dlc), std::move(versions),
{details.update.newer, details.update.new_dlc, 0, 0, details.update.target, false}, !check_waits);
if (details.launches_any_branch) launches_any_branch_.insert(details.id);
else launches_any_branch_.erase(details.id);
@@ -2327,7 +2344,7 @@ void Controller::TickAppDetails() {
for (const auto& check : model_.TakeSizeChecks()) {
auto* details = Details(check.id.store);
// Not queued: as a check that failed, asked again when the sheet opens next.
- if (!signed_in || details != app_details_ || !details->Measure({check.id, check.branch, check.language}, generation))
+ if (!signed_in || details != app_details_ || !details->Measure({check.id, check.branch, check.language, false, check.excluded_dlc}, generation))
model_.UpdateMeasuredSize(check, false, true, {});
}
// Updates' sizes: the files that change, from the new manifests and each install's tree.
@@ -2342,7 +2359,7 @@ void Controller::TickAppDetails() {
app_details_->Refresh(size.request.id, generation);
continue;
}
- model_.UpdateMeasuredSize({size.request.id, size.request.branch, size.request.language}, size.measured, size.failed,
+ model_.UpdateMeasuredSize({size.request.id, size.request.branch, size.request.language, size.request.excluded_dlc}, size.measured, size.failed,
{size.install_bytes, size.download_bytes});
}
}
diff --git a/src/homebrew/controller.hpp b/src/homebrew/controller.hpp
index 33667d5..33307bd 100644
--- a/src/homebrew/controller.hpp
+++ b/src/homebrew/controller.hpp
@@ -1,5 +1,6 @@
#pragma once
#include <array>
+#include "homebrew/details_ask.hpp"
#include "homebrew/simulation.hpp"
#include "homebrew/uninstall_flow.hpp"
#include "steam/service.h"
@@ -359,6 +360,7 @@ class Controller {
std::chrono::steady_clock::time_point volume_refreshed_at_{};
std::optional<std::chrono::steady_clock::time_point> licenses_notice_at_; // when a license check starts showing
std::optional<GameId> requested_detail_;
+ std::map<GameId, DetailsAsked> details_asked_; // what each visited page's details were last asked with
std::uint64_t requested_generation_ = 0;
bool update_check_running_ = false; // an installed-games update check the details service runs
std::vector<GameId> update_check_ids_; // its games, to start it again after a language change
diff --git a/src/homebrew/details_ask.hpp b/src/homebrew/details_ask.hpp
new file mode 100644
index 0000000..53d3945
--- /dev/null
+++ b/src/homebrew/details_ask.hpp
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#pragma once
+
+#include <cstdint>
+#include <optional>
+
+namespace playden::homebrew {
+
+// What a game page's details were asked with. What an uninstalled game's page offers (its DLC list) comes from the
+// licenses and from it not being installed.
+struct DetailsAsked {
+ std::uint64_t licenses_read = 0;
+ bool installed = false;
+ bool operator==(const DetailsAsked& other) const { return licenses_read == other.licenses_read && installed == other.installed; }
+};
+
+enum class DetailsAsk { kNothing, kOnce, kAgain };
+
+// `new_visit`: the page just opened. An installed game is asked again at each visit, as Steam may have a newer version
+// since; any game whose answer is from before its licenses or install state changed is asked again, even while its
+// page stays open, and so is one this page never asked for: an update check may have answered it while it was installed.
+// Otherwise one answer per session will do.
+inline DetailsAsk NextDetailsAsk(const std::optional<DetailsAsked>& last, const DetailsAsked& now, bool new_visit) {
+ const bool outdated = !last || !(*last == now);
+ if (!new_visit && !outdated) return DetailsAsk::kNothing;
+ return now.installed || outdated ? DetailsAsk::kAgain : DetailsAsk::kOnce;
+}
+
+} // namespace playden::homebrew
diff --git a/src/homebrew/host.cpp b/src/homebrew/host.cpp
index bea769e..cef7a14 100644
--- a/src/homebrew/host.cpp
+++ b/src/homebrew/host.cpp
@@ -592,6 +592,7 @@ int main(int argc, char** argv) {
playden::app::AppendLogLine(log_directory, "install.log", "app=" + std::to_string(app) + " step=" + step + " result=" + result + " detail=" + detail);
});
details_source->SetLicensedDepots(&licensed_depots);
+ details_source->SetFreeDlcMemory(library_storage.get());
details_source->SetContentLanguage([] { return selected_content_language(); });
// Installed games' records, for their updates; the install service is made below and joined after the
// details worker (Controller::Shutdown).
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index 458ef4e..399feae 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -394,6 +394,7 @@ int main() {
playden::app::AppendLogLine(log_root, "install.log", "app=" + std::to_string(app) + " step=" + step + " result=" + result + " detail=" + detail);
});
details_source.SetLicensedDepots(&licensed_depots);
+ details_source.SetFreeDlcMemory(&library_storage);
details_source.SetContentLanguage([] { return selected_content_language(); });
playden::LocalSessionRepository details_sessions(user_root, {}, &session_vault);
playden::steam::AppDetailsService app_details(details_source, details_sessions);
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 4f43ed4..026bb48 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -29,6 +29,7 @@
#include <limits>
#include <map>
#include <set>
+#include <charconv>
#include <string_view>
#include <utility>
#include <type_traits>
@@ -507,6 +508,16 @@ std::vector<std::string> split_overrides(const std::string& list) {
return entries;
}
+// The app ID in an install sheet DLC row's action ("install-dlc-1234"); 0 for anything else.
+std::uint32_t parse_dlc_action(std::string_view action) {
+ constexpr std::string_view prefix = "install-dlc-";
+ if (action.substr(0, prefix.size()) != prefix) return 0;
+ const auto digits = action.substr(prefix.size());
+ std::uint32_t app = 0;
+ const auto parsed = std::from_chars(digits.data(), digits.data() + digits.size(), app);
+ return parsed.ec == std::errc{} && parsed.ptr == digits.data() + digits.size() ? app : 0;
+}
+
// A sheet row that only sets the others apart: a section heading ("heading-sort") or an untitled divider.
bool SheetDecoration(const std::string& key) { return key.rfind("heading-", 0) == 0 || key == "divider"; }
@@ -521,7 +532,7 @@ std::string action_label(const std::string& key) {
{"cloud-use-local", "Use console saves"}, {"cloud-confirm-account", "Use this account"},
{"cloud-confirm-account-all", "Upload all"},
{"saves-delete-confirm", "Delete saves"}, {"manage-saves", "Manage saves"}, {"saves-leftover-confirm", "Remove"}, {"saves-quit-anyway", "Play without syncing"},
- {"install-confirm", "Install"}, {"install-version", "Version"}, {"install-language", "Language"}, {"install-dlc", "Includes"}, {"update-confirm", "Download and install"}, {"storage-picker", "Change storage…"},
+ {"install-confirm", "Install"}, {"install-version", "Version"}, {"install-language", "Language"}, {"install-dlc", "DLC"}, {"install-dlc-all", "All DLC"}, {"install-dlc-done", "Done"}, {"heading-dlc-included", "Included"}, {"heading-dlc-optional", "Optional"}, {"update-confirm", "Download and install"}, {"storage-picker", "Change storage…"},
{"value-edit", "Edit…"}, {"value-reset", "Reset to recipe"}, {"override-add", "Add an override…"},
{"unlock-setting", "Change anyway"}, {"export-recipe", "Export as recipe"}, {"program-scan", "Looking for programs…"},
{"preset-picker", "Preset"}, {"game-settings", "Game settings"}, {"game-maintenance", "Maintenance"}, {"run-once", "Run a program once…"}, {"run-once-start", "Run once"}, {"game-move", "Move to…"}, {"runtime-check-again", "Check again"}, {"reset-settings", "Reset all to preset"}, {"clear-shader-cache", "Clear shader cache"},
@@ -2927,6 +2938,7 @@ void Simulation::UpdateInstalls(const std::vector<LiveInstallJob>& jobs, const s
job.completed_bytes = live_job.done_bytes;
job.total_bytes = live_job.total_bytes;
job.held_bytes = live_job.held_bytes;
+ job.estimated_bytes = live_job.estimated_bytes;
job.checking_licenses = live_job.state == JobState::Downloading && live_job.checking_licenses;
job.failure = live_job.failure;
job.volume_id = live_job.volume_id;
@@ -3069,8 +3081,10 @@ void Simulation::apply_live_volume_usage() {
if (job.volume_id != volume.id || job.state == JobState::Failed ||
job.state == JobState::Cancelled || job.state == JobState::Downloaded) continue;
const auto* game = find_game(state_, job.game_id);
- if (!game || !game->install_bytes) continue;
- const auto pending = steam::PendingInstallBytes(game->install_bytes, job.held_bytes);
+ // What this install was asked with: the game's figures count DLC it may have left out.
+ const auto estimate = job.estimated_bytes ? job.estimated_bytes : game ? game->install_bytes : std::nullopt;
+ if (!estimate) continue;
+ const auto pending = steam::PendingInstallBytes(estimate, job.held_bytes);
const auto maximum = std::numeric_limits<std::uint64_t>::max();
volume.reserved_bytes = pending > maximum - volume.reserved_bytes ? maximum : volume.reserved_bytes + pending;
}
@@ -3319,8 +3333,126 @@ SizeCheckRequest Simulation::install_size_check(GameId id) const {
const auto* version = install_sized_version(id);
// The language as an install asks for it (the sheet's choice, else Settings'): each part of the game falls
// back from it on its own.
- return {id, version ? version->name : std::string("public"),
- install_language_.empty() ? state_.content_language : install_language_};
+ SizeCheckRequest check{id, version ? version->name : std::string("public"),
+ install_language_.empty() ? state_.content_language : install_language_, {}};
+ // Free DLC isn't owned yet, so the check doesn't count it whether it is on or off.
+ for (const auto& dlc : install_dlc(id))
+ if (!dlc.free && install_dlc_off(dlc)) check.excluded_dlc.push_back(dlc.app_id);
+ std::sort(check.excluded_dlc.begin(), check.excluded_dlc.end());
+ return check;
+}
+
+std::vector<GameDlc> Simulation::install_dlc(GameId id) const {
+ auto offered = install_dlc_for_choice(id);
+ offered.erase(std::remove_if(offered.begin(), offered.end(), [](const GameDlc& dlc) { return dlc.install_bytes == 0; }), offered.end());
+ return offered;
+}
+
+std::vector<GameDlc> Simulation::install_dlc_for_choice(GameId id) const {
+ std::vector<GameDlc> offered;
+ const auto* game = find_game(state_, id);
+ if (!game) return offered;
+ const auto* version = install_sized_version(id);
+ const std::string branch = version ? version->name : std::string("public");
+ const std::string language = install_language_.empty() ? state_.content_language : install_language_;
+ for (auto dlc : game->dlc) {
+ for (const auto& other : dlc.other_sizes)
+ if (other.branch == branch && other.language == language) {
+ dlc.install_bytes = other.install_bytes;
+ dlc.download_bytes = other.download_bytes;
+ dlc.optional = other.optional;
+ }
+ offered.push_back(std::move(dlc));
+ }
+ return offered;
+}
+
+void Simulation::request_size_check(const SizeCheckRequest& check) {
+ const auto key = std::make_tuple(check.id, check.branch, check.language, check.excluded_dlc);
+ if (size_checks_running_.count(key) || size_checks_answered_.count(key) || size_checks_failed_.count(key)) return;
+ size_checks_.push_back(check);
+ size_checks_running_.insert(key);
+}
+
+SizeCheckRequest Simulation::default_size_check(const Game& game) const {
+ SizeCheckRequest check{game.id, "public", state_.content_language, {}};
+ // The same list the sheet asks with: this version's and language's figures, and only DLC with files in it.
+ for (auto dlc : game.dlc) {
+ for (const auto& other : dlc.other_sizes)
+ if (other.branch == check.branch && other.language == check.language) {
+ dlc.install_bytes = other.install_bytes;
+ dlc.optional = other.optional;
+ }
+ if (dlc.install_bytes != 0 && dlc.optional && !dlc.free) check.excluded_dlc.push_back(dlc.app_id);
+ }
+ std::sort(check.excluded_dlc.begin(), check.excluded_dlc.end());
+ return check;
+}
+
+std::optional<std::uint64_t> Simulation::default_install_size(const Game& game) const {
+ const auto check = default_size_check(game);
+ const auto found = measured_sizes_.find({check.id, check.branch, check.language, check.excluded_dlc});
+ if (found == measured_sizes_.end()) return default_install_bytes(game);
+ std::uint64_t bytes = found->second.install_bytes;
+ for (const auto& dlc : game.dlc)
+ if (dlc.free) bytes += dlc.install_bytes;
+ return bytes;
+}
+
+std::string Simulation::install_size_text(GameId id, const std::optional<std::uint64_t>& bytes, const char* unknown) const {
+ if (!bytes) return unknown;
+ // Free DLC that is on stays an estimate: the check can't read what isn't owned yet.
+ const bool exact = measured_install_size(id) != nullptr && install_dlc_sizes(id).free_install_bytes == 0;
+ return (exact ? "" : "About ") + format_bytes(*bytes);
+}
+
+void Simulation::refresh_install_sheet(GameId id) {
+ for (auto& modal : state_.navigation.modals) {
+ if (modal.id != "install") continue;
+ // Its focus stays on the same row.
+ const auto focused = modal.focused_action >= 0 && static_cast<std::size_t>(modal.focused_action) < modal.action_keys.size()
+ ? modal.action_keys[static_cast<std::size_t>(modal.focused_action)] : std::string();
+ modal.action_keys = live_install_sheet_actions(id);
+ 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());
+ }
+}
+
+bool Simulation::install_dlc_off(const GameDlc& dlc) const {
+ const auto chosen = install_dlc_choice_.find(dlc.app_id);
+ if (chosen != install_dlc_choice_.end()) return !chosen->second;
+ return dlc.optional && !dlc.free;
+}
+
+std::vector<std::uint32_t> Simulation::install_excluded_dlc(GameId id) const {
+ // Every version's list: the install may select from any, and what is off stays off in its updates.
+ std::vector<std::uint32_t> excluded;
+ for (const auto& dlc : install_dlc_for_choice(id))
+ if (install_dlc_off(dlc)) excluded.push_back(dlc.app_id);
+ std::sort(excluded.begin(), excluded.end());
+ return excluded;
+}
+
+InstallDlcSizes Simulation::install_dlc_sizes(GameId id) const {
+ InstallDlcSizes sizes;
+ for (const auto& dlc : install_dlc(id)) {
+ const bool off = install_dlc_off(dlc);
+ if (dlc.free && !off) {
+ sizes.free_install_bytes += dlc.install_bytes;
+ sizes.free_download_bytes += dlc.download_bytes;
+ } else if (!dlc.free && off) {
+ sizes.off_install_bytes += dlc.install_bytes;
+ sizes.off_download_bytes += dlc.download_bytes;
+ }
+ }
+ return sizes;
+}
+
+std::uint64_t Simulation::install_dlc_on_bytes(GameId id) const {
+ std::uint64_t bytes = 0;
+ for (const auto& dlc : install_dlc(id))
+ if (!install_dlc_off(dlc)) bytes += dlc.install_bytes;
+ return bytes;
}
void Simulation::ResetSizeChecks() {
@@ -3333,24 +3465,24 @@ void Simulation::ResetSizeChecks() {
const MeasuredInstallSize* Simulation::measured_install_size(GameId id) const {
const auto check = install_size_check(id);
- const auto found = measured_sizes_.find({check.id, check.branch, check.language});
+ const auto found = measured_sizes_.find({check.id, check.branch, check.language, check.excluded_dlc});
return found == measured_sizes_.end() ? nullptr : &found->second;
}
bool Simulation::install_size_checking(GameId id) const {
const auto check = install_size_check(id);
- return size_checks_running_.count({check.id, check.branch, check.language}) > 0;
+ return size_checks_running_.count({check.id, check.branch, check.language, check.excluded_dlc}) > 0;
}
InstallAssessment Simulation::install_assessment(GameId id) const {
return assess_install(state_, id, install_target(), steam::kInstallSpaceMargin, install_sized_version(id),
- install_language(id), measured_install_size(id));
+ install_language(id), measured_install_size(id), install_dlc_sizes(id));
}
std::vector<SizeCheckRequest> Simulation::TakeSizeChecks() { return std::exchange(size_checks_, {}); }
void Simulation::UpdateMeasuredSize(const SizeCheckRequest& request, bool measured, bool failed, MeasuredInstallSize size) {
- const auto key = std::make_tuple(request.id, request.branch, request.language);
+ const auto key = std::make_tuple(request.id, request.branch, request.language, request.excluded_dlc);
size_checks_running_.erase(key);
if (failed) size_checks_failed_.insert(key);
else size_checks_answered_.insert(key);
@@ -3363,8 +3495,8 @@ std::vector<std::string> Simulation::live_install_sheet_actions(GameId id) const
std::vector<std::string> actions{"install-confirm"};
if (game && game->versions.size() >= 2) actions.push_back("install-version");
if (game && game->content_languages.size() >= 2) actions.push_back("install-language");
- // Owned DLC the download includes, as a status row.
- if (game && game->dlc_count > 0) actions.push_back("install-dlc");
+ // DLC with files: the choice of which to install.
+ if (game && !install_dlc(id).empty()) actions.push_back("install-dlc");
actions.push_back("storage-picker");
actions.push_back("cancel");
return actions;
@@ -3418,7 +3550,7 @@ std::string held_play_text(const State& state, GameId id) {
bool Simulation::UpdateAppDetails(GameId id, std::optional<std::uint64_t> download_bytes,
std::optional<std::uint64_t> install_bytes,
std::optional<bool> windows_installable, std::vector<std::string> languages,
- std::uint32_t dlc_count, std::vector<GameVersion> versions, GameUpdate update,
+ std::vector<GameDlc> dlc, std::vector<GameVersion> versions, GameUpdate update,
bool updates_known) {
if (!live()) return false;
// New details may name other files (a newer build): the game's exact sizes are checked again.
@@ -3444,9 +3576,11 @@ bool Simulation::UpdateAppDetails(GameId id, std::optional<std::uint64_t> downlo
game->install_bytes = install_bytes;
game->windows_installable = windows_installable;
game->content_languages = std::move(languages);
- game->dlc_count = dlc_count;
+ game->dlc = std::move(dlc);
game->versions = std::move(versions);
game->update = update;
+ // A sheet opened before the answer gets the rows the game has.
+ if (id == state_.navigation.detail_id.value_or(state_.navigation.selected_game_id)) refresh_install_sheet(id);
apply_live_volume_usage();
rebuild_view();
return true;
@@ -5060,7 +5194,8 @@ bool Simulation::scenario(const std::string& name) {
state_.account().authentication = AuthState::SignedIn;
if (auto* game = const_cast<Game*>(find_game(state_, id))) {
game->content_languages = {"english", "german", "french", "japanese"};
- game->dlc_count = 2;
+ game->dlc = {{900101, "Art Book", 90'000'000, 120'000'000, false},
+ {900102, "Texture Pack", 3'400'000'000, 4'200'000'000, true}};
game->versions = {{"public", "", 1'760'000'000, 90, game->download_bytes, game->install_bytes},
{"4.04", "Patch 4.04 (DirectX 11)", 1'670'000'000, 40, game->download_bytes, game->install_bytes}};
}
@@ -5364,7 +5499,9 @@ void Simulation::rebuild_view() {
state_.navigation.focus_key = modals.front().opener_focus_key;
state_.navigation.modals.clear();
rebuilding_overlay_ = true;
+ page_under_install_sheet_ = std::any_of(modals.begin(), modals.end(), [](const ModalEntry& modal) { return modal.id == "install"; });
rebuild_view();
+ page_under_install_sheet_ = false;
rebuilding_overlay_ = false;
route_view_ = view_;
state_.editor.active = editor_active;
@@ -5379,10 +5516,6 @@ void Simulation::rebuild_view() {
!queue_return_focus_.empty();
if (state_.navigation.route != Route::Downloads && !queue_details) queue_shown_ = false;
if (state_.navigation.route != Route::Downloads && !queue_details) queue_return_focus_.clear();
- // A size check that failed is asked again when the install sheet opens next, not while it stays open.
- if (!rebuilding_overlay_ && std::none_of(state_.navigation.modals.begin(), state_.navigation.modals.end(),
- [](const ModalEntry& modal) { return modal.id == "install"; }))
- size_checks_failed_.clear();
view_.surface = route_name(state_.navigation.route);
view_.show_simulation_label = state_.simulation_mode;
if (state_.editor.active) view_.surface = "keyboard";
@@ -5475,22 +5608,17 @@ void Simulation::rebuild_view() {
const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
// Steam's figures add up each part of the game; its exact size, once checked, replaces them.
const auto check = install_size_check(id);
- const auto key = std::make_tuple(check.id, check.branch, check.language);
- if (!size_checks_running_.count(key) && !size_checks_answered_.count(key) && !size_checks_failed_.count(key)) {
- size_checks_.push_back(check);
- size_checks_running_.insert(key);
- }
+ request_size_check(check);
const auto assessment = install_assessment(id);
const bool checking = install_size_checking(id);
- const bool exact = measured_install_size(id) != nullptr;
const auto* volume = find_volume(state_, install_target());
const auto* fallback = find_volume(state_, selected_volume_id_);
- view_.subtitle = "To " + (volume ? volume->label : std::string("unavailable storage")) +
- (install_volume_id_.empty() ? "" : " (this game only)") + ". ";
- view_.subtitle += assessment.free_bytes ? format_bytes(*assessment.free_bytes) + " free. " : "";
- view_.subtitle += assessment.installed_bytes
- ? (exact ? "Needs " : "Needs about ") + format_bytes(*assessment.installed_bytes) + ". "
- : "Its size is checked when the download starts. ";
+ view_.facts.push_back({"Install to", (volume ? volume->label : std::string("Unavailable storage")) +
+ (install_volume_id_.empty() ? "" : " (this game only)")});
+ if (assessment.free_bytes) view_.facts.push_back({"Free space", format_bytes(*assessment.free_bytes)});
+ view_.facts.push_back({"Needs", install_size_text(id, assessment.installed_bytes, "Checked when the download starts")});
+ view_.facts.push_back({"Download", install_size_text(id, assessment.download_bytes, "Unknown")});
+ view_.subtitle.clear();
if (assessment.readiness == InstallReadiness::Insufficient && checking) view_.subtitle += "Checking its exact size…";
else if (assessment.readiness == InstallReadiness::Insufficient) view_.subtitle += "Not enough space: choose another drive or free up space.";
else if (assessment.readiness == InstallReadiness::Unavailable) view_.subtitle += "This drive is disconnected.";
@@ -5499,7 +5627,7 @@ void Simulation::rebuild_view() {
view_.subtitle += free_space_supported_ ? "Free space on this drive can't be read: choose another drive."
: "Free space can't be checked on this console.";
if (!install_volume_id_.empty() && fallback)
- view_.subtitle += (view_.subtitle.back() == ' ' ? "" : " ") + std::string("Other games still install to ") +
+ view_.subtitle += (view_.subtitle.empty() || view_.subtitle.back() == ' ' ? "" : " ") + std::string("Other games still install to ") +
fallback->label + ".";
}
if (modal.id == "update") {
@@ -5521,6 +5649,24 @@ void Simulation::rebuild_view() {
}
if (modal.id == "install-version")
view_.subtitle = "For this install only. Steam keeps older versions as branches; Public is the current one.";
+ // A fixture's sheet of a game with DLC says the same.
+ if (modal.id == "install" && !live() && std::count(modal.action_keys.begin(), modal.action_keys.end(), "install-dlc")) {
+ const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
+ const auto assessment = install_assessment(id);
+ view_.facts.push_back({"Needs", install_size_text(id, assessment.installed_bytes, "Unknown")});
+ view_.facts.push_back({"Download", install_size_text(id, assessment.download_bytes, "Unknown")});
+ }
+ if (modal.id == "install-dlc") {
+ const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
+ const auto assessment = install_assessment(id);
+ // Only the total: depots can share files, so the exact size can be less than the rows add up to.
+ const bool short_of_room = assessment.readiness == InstallReadiness::Insufficient && assessment.free_bytes;
+ view_.facts.push_back({install_dlc_on_bytes(id) ? "Total" : "Game only",
+ install_size_text(id, assessment.installed_bytes, "Unknown") +
+ (short_of_room ? " · " + format_bytes(*assessment.free_bytes) + " free" : std::string()),
+ short_of_room});
+ view_.facts.push_back({"Download", install_size_text(id, assessment.download_bytes, "Unknown")});
+ }
if (modal.id == "install-language")
view_.subtitle = "For this game only. New downloads of other games stay in " +
playden::steam::LanguageName(state_.content_language) + ".";
@@ -5681,9 +5827,37 @@ void Simulation::rebuild_view() {
}
if (modal.id == "install" && action_key == "install-dlc") {
const auto* game = find_game(state_, state_.navigation.detail_id.value_or(state_.navigation.selected_game_id));
- item.kind = RowKind::Status;
- item.value = std::to_string(game ? game->dlc_count : 0) + " DLC";
- item.enabled = false;
+ const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
+ const auto offered = install_dlc(id);
+ const auto on = std::count_if(offered.begin(), offered.end(), [this](const GameDlc& dlc) {
+ return !install_dlc_off(dlc);
+ });
+ const auto bytes = install_dlc_on_bytes(id);
+ item.value = !on ? std::string("None")
+ : std::to_string(on) + " of " + std::to_string(offered.size()) +
+ (bytes ? " · " + format_bytes(bytes) : std::string());
+ }
+ // This install's DLC: one toggle each, with its size, and one row for them all.
+ if (modal.id == "install-dlc" && action_key == "install-dlc-all") {
+ const auto offered = install_dlc(state_.navigation.detail_id.value_or(state_.navigation.selected_game_id));
+ const auto total = static_cast<std::ptrdiff_t>(offered.size());
+ const auto on = std::count_if(offered.begin(), offered.end(), [this](const GameDlc& dlc) {
+ return !install_dlc_off(dlc);
+ });
+ item.kind = RowKind::Toggle;
+ item.selected = on == total;
+ item.value = std::to_string(on) + " of " + std::to_string(total);
+ } else if (modal.id == "install-dlc" && action_key.rfind("install-dlc-", 0) == 0 && action_key != "install-dlc-done") {
+ const auto offered = install_dlc(state_.navigation.detail_id.value_or(state_.navigation.selected_game_id));
+ const auto app = parse_dlc_action(action_key);
+ item.kind = RowKind::Toggle;
+ item.title = "DLC " + std::to_string(app);
+ for (const auto& dlc : offered)
+ if (dlc.app_id == app) {
+ item.selected = !install_dlc_off(dlc);
+ if (!dlc.name.empty()) item.title = dlc.name;
+ item.value = (dlc.free ? "Free · " : "") + format_bytes(dlc.install_bytes);
+ }
}
if (modal.id == "install" && action_key == "install-language") {
const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
@@ -6339,6 +6513,7 @@ void Simulation::rebuild_view() {
else if (modal.id == "import-programs" || modal.id == "import-choice") view_.legends = {"Cross Select", "Circle Back"};
else if (modal.id == "steam-programs") view_.legends = {"Cross Choose", "Circle Cancel"};
else if (modal.id == "content-language") view_.legends = {"Cross Use this language", "L1/R1 Jump", "Circle Back"};
+ else if (modal.id == "install-dlc") view_.legends = {"Cross Turn on or off", "L1/R1 Jump", "Circle Back"};
else if (modal.id == "install-language") view_.legends = {"Cross Use this language", "L1/R1 Jump", "Circle Back"};
else if (modal.id == "install-version") view_.legends = {"Cross Use this version", "L1/R1 Jump", "Circle Back"};
else if (modal.id == "import-storage") view_.legends = {"Cross Import here", "Circle Back"};
@@ -6702,7 +6877,11 @@ void Simulation::rebuild_view() {
status.progress = job->total_bytes == 0 ? 0.0F : static_cast<float>(job->completed_bytes) / static_cast<float>(job->total_bytes);
} else if (game->windows_installable.value_or(false)) {
auto& install = row("details-install", RowKind::Action, "Install…", "live-install");
- install.value = game->install_bytes ? format_bytes(*game->install_bytes) : "Size unknown";
+ // What Install will say: its choices while the install sheet is open, else the ones it opens with, checked
+ // now so the sheet has them when it opens.
+ if (!page_under_install_sheet_) request_size_check(default_size_check(*game));
+ const auto bytes = page_under_install_sheet_ ? install_assessment(game->id).installed_bytes : default_install_size(*game);
+ install.value = bytes ? format_bytes(*bytes) : "Size unknown";
if (const auto* volume = find_volume(state_, selected_volume_id_)) {
const auto assessment = assess_install(state_, game->id, selected_volume_id_, steam::kInstallSpaceMargin);
install.subtitle = "To " + volume->label + (assessment.free_bytes
@@ -8521,6 +8700,7 @@ void Simulation::activate() {
[&](const GameVersion& version) { return version.name == name; }))
install_version_ = name == "public" ? std::string() : name; // public is no choice
close_modal();
+ refresh_install_sheet(id);
state_.navigation.focus_key = "install-confirm"; // back on the sheet, ready to install
return;
} else if (live() && action_name == "install-language") {
@@ -8548,8 +8728,37 @@ void Simulation::activate() {
? std::string() : code;
}
close_modal();
+ refresh_install_sheet(id);
state_.navigation.focus_key = "install-confirm"; // back on the sheet, ready to install
return;
+ } else if (action_name == "install-dlc") {
+ // From the install sheet: which DLC this install holds. Toggling keeps the list open.
+ const auto offered = install_dlc(state_.navigation.detail_id.value_or(state_.navigation.selected_game_id));
+ if (offered.empty()) return;
+ // By how each starts, so a row stays put when it is toggled; one kind needs no headings.
+ const auto starts_off = [](const GameDlc& dlc) { return dlc.optional && !dlc.free; };
+ const auto optional = std::count_if(offered.begin(), offered.end(), starts_off);
+ const bool sections = optional > 0 && optional < static_cast<std::ptrdiff_t>(offered.size());
+ std::vector<std::string> actions{"install-dlc-all"};
+ if (sections) actions.push_back("heading-dlc-included");
+ for (const auto& dlc : offered)
+ if (!starts_off(dlc)) actions.push_back("install-dlc-" + std::to_string(dlc.app_id));
+ if (sections) actions.push_back("heading-dlc-optional");
+ for (const auto& dlc : offered)
+ if (starts_off(dlc)) actions.push_back("install-dlc-" + std::to_string(dlc.app_id));
+ actions.push_back("divider");
+ actions.push_back("install-dlc-done");
+ open_modal({"install-dlc", "DLC", state_.navigation.focus_key, std::move(actions), 0, false});
+ } else if (action_name == "install-dlc-done") {
+ close_modal();
+ } else if (action_name == "install-dlc-all") {
+ const auto offered = install_dlc(state_.navigation.detail_id.value_or(state_.navigation.selected_game_id));
+ // Any DLC off: all on. All on: all off, for "only this one".
+ const bool any_off = std::any_of(offered.begin(), offered.end(), [this](const GameDlc& dlc) { return install_dlc_off(dlc); });
+ for (const auto& dlc : offered) install_dlc_choice_[dlc.app_id] = any_off;
+ } else if (const auto dlc_app = parse_dlc_action(action_name)) {
+ for (const auto& dlc : install_dlc(state_.navigation.detail_id.value_or(state_.navigation.selected_game_id)))
+ if (dlc.app_id == dlc_app) install_dlc_choice_[dlc_app] = install_dlc_off(dlc);
} 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";
@@ -8602,9 +8811,11 @@ void Simulation::activate() {
if (id.valid())
pending_install_requests_.push_back({InstallRequestKind::Install, id, install_volume_id_, false, install_language_,
install_version(id) ? install_version_ : std::string(),
- assessment.installed_bytes});
+ assessment.installed_bytes,
+ install_excluded_dlc(id)});
install_volume_id_.clear();
install_language_.clear();
+ install_dlc_choice_.clear();
install_version_.clear();
close_modal();
}
@@ -8956,8 +9167,11 @@ void Simulation::activate() {
const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
// Every install opens the sheet: it says where the game goes and how much room it takes, and its
// Storage row (with Language and Version when the game has a choice) sets them for this install.
+ // A size check that failed is asked again now, not at every redraw of the page or sheet.
+ size_checks_failed_.clear();
install_volume_id_.clear();
install_language_.clear();
+ install_dlc_choice_.clear();
install_version_.clear();
if (id.valid())
open_modal({"install", "Install game", "details-install", live_install_sheet_actions(id), 0, false});
@@ -10207,6 +10421,7 @@ bool Simulation::action(const std::string& logical_action) {
state_.navigation.modals.back().id == "game-maintenance" ||
state_.navigation.modals.back().id == "content-language" ||
state_.navigation.modals.back().id == "install-language" ||
+ state_.navigation.modals.back().id == "install-dlc" ||
state_.navigation.modals.back().id == "install-version" ||
state_.navigation.modals.back().id == "button-mapping" || state_.navigation.modals.back().id == "controller-tuning" ||
!state_.navigation.modals.back().setting_id.empty()))
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index e10f514..f1703ff 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -10,6 +10,7 @@
#include "runtime/game_settings.h"
#include "steam/backend/content_language.h"
+#include <algorithm>
#include <array>
#include <cstdint>
#include <filesystem>
@@ -91,6 +92,8 @@ struct InstallRequest {
// Install: the install-size estimate of the chosen version (the game's when Steam gives none for it),
// which the install service reserves on the drive; empty: unknown.
std::optional<std::uint64_t> install_bytes;
+ // Install: the DLC turned off in the install sheet, sorted.
+ std::vector<std::uint32_t> excluded_dlc;
};
// Game maintenance the details page offers (simulated in fixture mode).
enum class MaintenanceKind { ApplySettings, ClearShaderCache, Repair, BackupSaves, RecreateBottle, UpdateRuntime };
@@ -128,6 +131,7 @@ struct LiveInstallJob {
// While the move checks its copy: the files checked so far, of how many (0 of 0: no count).
std::uint64_t checked_files = 0;
std::uint64_t check_files = 0;
+ std::optional<std::uint64_t> estimated_bytes; // what the job was asked with, DLC choice included
};
struct LiveInstalledGame {
GameId game_id;
@@ -504,11 +508,41 @@ struct MeasuredInstallSize {
std::uint64_t download_bytes = 0;
};
-// A size check the install sheet asks for: a version (Steam branch) and a content language.
+// A size check the install sheet asks for: a version (Steam branch), a content language, and the owned DLC turned off.
struct SizeCheckRequest {
GameId id;
std::string branch;
std::string language;
+ std::vector<std::uint32_t> excluded_dlc;
+};
+
+// A DLC with files that an install can leave out.
+struct GameDlc {
+ std::uint32_t app_id = 0;
+ std::string name; // empty: Steam doesn't describe it
+ std::uint64_t download_bytes = 0;
+ std::uint64_t install_bytes = 0;
+ bool free = false; // not owned yet: the install claims it
+ // Where another version or language differs from the sizes above (public, the Settings language). No install
+ // bytes: that choice doesn't have the DLC.
+ struct OtherSize {
+ std::string branch;
+ std::string language;
+ std::uint64_t download_bytes = 0;
+ std::uint64_t install_bytes = 0;
+ bool optional = false;
+ };
+ std::vector<OtherSize> other_sizes;
+ bool optional = false; // Steam doesn't download it by itself
+};
+
+// What the DLC choice does to an install's size. Off: owned DLC turned off, which Steam's figures for the game count.
+// Free: free DLC left on, which they don't count, as the account doesn't own it yet.
+struct InstallDlcSizes {
+ std::uint64_t off_install_bytes = 0;
+ std::uint64_t off_download_bytes = 0;
+ std::uint64_t free_install_bytes = 0;
+ std::uint64_t free_download_bytes = 0;
};
// An installed game's update, from Steam app info compared with its install record.
@@ -557,7 +591,7 @@ struct Game {
std::optional<std::uint64_t> playtime_minutes;
std::optional<bool> windows_installable; // from Steam app info; absent until fetched
std::vector<std::string> content_languages; // from Steam app info: the languages an install can choose
- std::uint32_t dlc_count = 0; // from Steam app info: owned DLC an install includes
+ std::vector<GameDlc> dlc; // from Steam app info: what an install's DLC list offers
std::vector<GameVersion> versions; // from Steam app info: public first; two or more offer a choice
GameUpdate update; // from Steam app info, for an installed game
bool demo = false; // a Steam demo; Sort and filters › Demos hides it
@@ -566,6 +600,28 @@ struct Game {
bool art_failed = false;
};
+// What a game that isn't installed takes with the install sheet's defaults: Steam's figures count the owned DLC, so
+// optional DLC (which starts off) comes off them and free DLC (which starts on, not owned yet) goes on. Nothing when
+// Steam gave no figure.
+[[nodiscard]] inline std::optional<std::uint64_t> default_install_bytes(const Game& game) {
+ if (!game.install_bytes) return std::nullopt;
+ std::uint64_t off = 0, free = 0;
+ for (const auto& choice : game.dlc) {
+ if (choice.free) free += choice.install_bytes;
+ else if (choice.optional) off += choice.install_bytes;
+ }
+ return *game.install_bytes - std::min(*game.install_bytes, off) + free;
+}
+[[nodiscard]] inline std::optional<std::uint64_t> default_download_bytes(const Game& game) {
+ if (!game.download_bytes) return std::nullopt;
+ std::uint64_t off = 0, free = 0;
+ for (const auto& choice : game.dlc) {
+ if (choice.free) free += choice.download_bytes;
+ else if (choice.optional) off += choice.download_bytes;
+ }
+ return *game.download_bytes - std::min(*game.download_bytes, off) + free;
+}
+
struct Collection {
std::string id;
std::string name;
@@ -617,6 +673,7 @@ struct Job {
bool reservation_held = false;
bool completion_applied = false;
std::uint64_t held_bytes = 0; // live: installed bytes already on the drive
+ std::optional<std::uint64_t> estimated_bytes; // live: what the job was asked with
std::int64_t finished_at = 0; // live: when a Downloaded job finished (Unix seconds), 0 unknown
bool checking_licenses = false; // live: a slow Steam license check before the download starts
std::string server_name; // live, while downloading: the download server's display name
@@ -630,6 +687,14 @@ struct Job {
std::string state_text;
};
+// The size to show for a game that isn't installed: what its running install was asked with, else the sheet's defaults.
+[[nodiscard]] inline std::optional<std::uint64_t> uninstalled_size(const Game& game, const std::vector<Job>& jobs) {
+ for (const auto& job : jobs)
+ if (job.game_id == game.id && job.estimated_bytes && job.state != JobState::Failed && job.state != JobState::Cancelled)
+ return job.estimated_bytes;
+ return default_install_bytes(game);
+}
+
struct Volume {
std::string id;
std::string label;
@@ -831,7 +896,16 @@ struct ViewRow {
std::string qr; // Settings: a link drawn as a QR code beside the row's text (Web access)
};
+// A read-only label and value above a sheet's rows; the focus never goes there.
+struct ViewFact {
+ std::string label;
+ std::string value;
+ bool warn = false;
+ bool operator==(const ViewFact& other) const { return label == other.label && value == other.value && warn == other.warn; }
+};
+
struct ViewData {
+ std::vector<ViewFact> facts;
std::string surface;
std::string title;
std::string subtitle;
@@ -1017,13 +1091,13 @@ public:
// False on a console that cannot read free space at all: installs are then allowed without it.
void SetFreeSpaceSupported(bool supported) noexcept { free_space_supported_ = supported; }
// Live mode: Steam app-info estimates for one game (download/install size, installability).
- // `languages`: the content languages the game carries, as Steam names them. `dlc_count`: owned
- // DLC with content an install includes, shown on the install sheet. `versions`: the versions an
+ // `languages`: the content languages the game carries, as Steam names them. `dlc`: the DLC with
+ // files an install can leave out, which the install sheet lists. `versions`: the versions an
// install can choose, public first. `update`: an installed game's update or new DLC, which the account's
// saved update list takes only when `updates_known` (the library refresh has read the licenses).
bool UpdateAppDetails(GameId id, std::optional<std::uint64_t> download_bytes,
std::optional<std::uint64_t> install_bytes, std::optional<bool> windows_installable,
- std::vector<std::string> languages = {}, std::uint32_t dlc_count = 0,
+ std::vector<std::string> languages = {}, std::vector<GameDlc> dlc = {},
std::vector<GameVersion> versions = {}, GameUpdate update = {}, bool updates_known = true);
// Live mode: the Steam store's description, genres and controller support for one game;
// kept across library refreshes.
@@ -1150,6 +1224,8 @@ private:
// Live: the content language chosen in the install sheet for this one install (empty: the one the
// Settings download language resolves to for the game).
std::string install_language_;
+ std::map<std::uint32_t, bool> install_dlc_choice_; // what the install sheet's player changed (on?), for this install only
+ bool page_under_install_sheet_ = false; // while the page behind the install sheet is built
// Live: the version (branch) chosen in the install sheet for this one install (empty: public).
std::string install_version_;
bool free_space_supported_ = true;
@@ -1275,11 +1351,12 @@ private:
bool queue_shown_ = false; // Queue was on screen at the last rebuild
std::string queue_return_focus_; // Queue: the row a game page was opened from, focused again on Back
// Install sheet size checks by (game, branch, language): asked and not answered, and the answers.
+ using SizeCheckKey = std::tuple<GameId, std::string, std::string, std::vector<std::uint32_t>>;
std::vector<SizeCheckRequest> size_checks_;
- std::set<std::tuple<GameId, std::string, std::string>> size_checks_running_;
- std::set<std::tuple<GameId, std::string, std::string>> size_checks_answered_;
- std::set<std::tuple<GameId, std::string, std::string>> size_checks_failed_; // not asked again until the sheet reopens
- std::map<std::tuple<GameId, std::string, std::string>, MeasuredInstallSize> measured_sizes_;
+ std::set<SizeCheckKey> size_checks_running_;
+ std::set<SizeCheckKey> size_checks_answered_;
+ std::set<SizeCheckKey> size_checks_failed_; // not asked again until the sheet reopens
+ std::map<SizeCheckKey, MeasuredInstallSize> measured_sizes_;
std::string settings_focus_section_;
struct OrganizationJournalEntry {
@@ -1547,6 +1624,25 @@ private:
[[nodiscard]] std::string next_job_id();
// The language the install sheet would install `id` in, and the sheet's rows for it.
[[nodiscard]] std::string install_language(GameId id) const;
+ // Every DLC as the install sheet's version and language have it (no install bytes: that choice doesn't).
+ [[nodiscard]] std::vector<GameDlc> install_dlc_for_choice(GameId id) const;
+ // The DLC the install sheet's version and language offer, with their sizes for that choice.
+ [[nodiscard]] std::vector<GameDlc> install_dlc(GameId id) const;
+ // Off when the player turned it off; else optional DLC the account owns starts off and the rest on. Free DLC stays
+ // on: some games need it, and the list shows its size.
+ [[nodiscard]] bool install_dlc_off(const GameDlc& dlc) const;
+ [[nodiscard]] std::vector<std::uint32_t> install_excluded_dlc(GameId id) const;
+ // A size check of an install choice, unless it is under way, answered or has failed.
+ void request_size_check(const SizeCheckRequest& check);
+ // The check of the choice an install sheet opens with, and what that choice takes: a game's page says the same.
+ [[nodiscard]] SizeCheckRequest default_size_check(const Game& game) const;
+ [[nodiscard]] std::optional<std::uint64_t> default_install_size(const Game& game) const;
+ // The install sheet's choice in figures: "About" until its exact size is known.
+ [[nodiscard]] std::string install_size_text(GameId id, const std::optional<std::uint64_t>& bytes, const char* unknown) const;
+ [[nodiscard]] InstallDlcSizes install_dlc_sizes(GameId id) const;
+ [[nodiscard]] std::uint64_t install_dlc_on_bytes(GameId id) const;
+ // A sheet's rows depend on the game's details and on the version and language chosen.
+ void refresh_install_sheet(GameId id);
// The version chosen in the install sheet for `id`, when it is not the public one.
[[nodiscard]] const GameVersion* install_version(GameId id) const;
[[nodiscard]] const GameVersion* install_sized_version(GameId id) const;
diff --git a/src/homebrew/storage_sim.cpp b/src/homebrew/storage_sim.cpp
index 619c210..f4f5ec5 100644
--- a/src/homebrew/storage_sim.cpp
+++ b/src/homebrew/storage_sim.cpp
@@ -27,7 +27,7 @@ std::uint64_t add_saturated(std::uint64_t left, std::uint64_t right) noexcept {
InstallAssessment assess_install(const State& state, GameId game_id,
const std::string& volume_id, std::uint64_t safety_margin_bytes,
const GameVersion* version, const std::string& language,
- const MeasuredInstallSize* measured) noexcept {
+ const MeasuredInstallSize* measured, const InstallDlcSizes& dlc) noexcept {
InstallAssessment result;
const auto game = find_item(state.games, [game_id](const Game& value) {
return value.id == game_id;
@@ -48,7 +48,12 @@ InstallAssessment assess_install(const State& state, GameId game_id,
if (measured != nullptr && measured->install_bytes) {
result.installed_bytes = measured->install_bytes;
if (measured->download_bytes) result.download_bytes = measured->download_bytes;
+ } else {
+ if (result.installed_bytes) result.installed_bytes = *result.installed_bytes - std::min(*result.installed_bytes, dlc.off_install_bytes);
+ if (result.download_bytes) result.download_bytes = *result.download_bytes - std::min(*result.download_bytes, dlc.off_download_bytes);
}
+ if (result.installed_bytes) result.installed_bytes = add_saturated(*result.installed_bytes, dlc.free_install_bytes);
+ if (result.download_bytes) result.download_bytes = add_saturated(*result.download_bytes, dlc.free_download_bytes);
if (result.installed_bytes) result.required_bytes = add_saturated(*result.installed_bytes, safety_margin_bytes);
}
diff --git a/src/homebrew/storage_sim.hpp b/src/homebrew/storage_sim.hpp
index f39a724..10c969d 100644
--- a/src/homebrew/storage_sim.hpp
+++ b/src/homebrew/storage_sim.hpp
@@ -32,13 +32,15 @@ struct InstallAssessment {
// `version`: the version chosen for this install; its sizes, when known, replace the game's. `language`: the
// content language chosen for it; that language's sizes on `version`, when known, replace both. `measured`: that
-// choice's size from its manifests, which replaces them all.
+// choice's size from its manifests, which replaces them all. `dlc`: what the DLC choice takes off Steam's figures
+// (the measured size already leaves that out) and adds to any of them.
[[nodiscard]] InstallAssessment assess_install(const State& state, GameId game_id,
const std::string& volume_id,
std::uint64_t safety_margin_bytes = 0,
const GameVersion* version = nullptr,
const std::string& language = {},
- const MeasuredInstallSize* measured = nullptr) noexcept;
+ const MeasuredInstallSize* measured = nullptr,
+ const InstallDlcSizes& dlc = {}) noexcept;
void reconcile_storage(State& state) noexcept;
diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cpp
index 2a62888..6d03a8a 100644
--- a/src/homebrew/view.cpp
+++ b/src/homebrew/view.cpp
@@ -18,6 +18,7 @@
#include "gfx/font.hpp"
#include "gfx/gl.hpp"
#include "gfx/renderer.hpp"
+#include "ui/components/detail_list.hpp"
#include "ui/components/grid.hpp"
#include "ui/components/keyboard.hpp"
#include "ui/components/list.hpp"
@@ -1692,7 +1693,8 @@ class Render::Impl
return size + (game.playtime_minutes && *game.playtime_minutes > 0 ?
playtime_label(game.playtime_minutes) + " played" : std::string("Installed"));
}
- return game.download_bytes ? "Not installed · " + short_size(*game.download_bytes) : "Not installed";
+ const auto download = default_download_bytes(game);
+ return download ? "Not installed · " + short_size(*download) : "Not installed";
}
// reserve: room kept free at the right for the corner badges.
@@ -3408,8 +3410,12 @@ class Render::Impl
for (const auto &candidate : state.import_candidates)
if (candidate.imported == game->id && candidate.total_bytes > 0)
scanned_bytes = candidate.total_bytes;
+ // Not installed: as the Install button says it, what the install sheet will say.
+ const auto install_row = std::find_if(view.rows.begin(), view.rows.end(), [](const ViewRow &row) { return row.key == "details-install"; });
+ const auto bare_bytes = uninstalled_size(*game, state.jobs);
const std::string size = installed ? short_size(installation->installed_bytes) :
- game->install_bytes ? short_size(*game->install_bytes) :
+ install_row != view.rows.end() && !install_row->value.empty() && install_row->value != "Size unknown" ? install_row->value :
+ bare_bytes ? short_size(*bare_bytes) :
scanned_bytes ? short_size(*scanned_bytes) : std::string("Unknown");
const std::string playtime = game->playtime_minutes && *game->playtime_minutes > 0 ?
playtime_label(game->playtime_minutes) : std::string("Never played");
@@ -3856,9 +3862,12 @@ class Render::Impl
}
else
ui::text(overlay_, fonts_.display, view.title, panel.x + 48.0F, 142.0F, 48.0F, kText);
+ // Read-only facts sit above the rows, which are all things to press.
+ const float facts_height = draw_sheet_facts(view.facts, {panel.x + 32.0F, 160.0F + drop, panel.w - 64.0F});
if (!view.subtitle.empty())
- ui::paragraph(overlay_, fonts_.regular, view.subtitle, panel.x + 48.0F, 190.0F + drop, 23.0F,
- panel.w - 96.0F, 32.0F, kSecondary, view.surface == "install" ? 6 : 3);
+ ui::paragraph(overlay_, fonts_.regular, view.subtitle, panel.x + 48.0F,
+ (view.facts.empty() ? 190.0F : 160.0F + facts_height + 32.0F) + drop, 23.0F,
+ panel.w - 96.0F, 32.0F, kSecondary, view.surface == "install" ? (view.facts.empty() ? 6 : 2) : 3);
if (view.surface == "storage")
draw_storage_overlay_rows(view, {panel.x + 40.0F, 246.0F, panel.w - 80.0F, 710.0F});
else if (view.surface == "import-storage" || view.surface == "move-storage")
@@ -3871,13 +3880,54 @@ class Render::Impl
else if (view.surface == "controller")
draw_controller_overlay(view, {panel.x + 40.0F, 236.0F, panel.w - 80.0F, 720.0F});
else
- draw_overlay_rows(view, {panel.x + 40.0F, (view.surface == "install" ? 414.0F : 292.0F) + drop,
- panel.w - 80.0F, (view.surface == "install" ? 528.0F : 650.0F) - drop});
+ {
+ // Below the facts and a two-line message; six rows, the most an install sheet has, still fit.
+ const float rows_top = view.surface != "install" ? 292.0F : view.facts.empty() ? 414.0F : 444.0F;
+ draw_overlay_rows(view, {panel.x + 40.0F, rows_top + drop, panel.w - 80.0F, 942.0F - rows_top - drop});
+ }
if (view.comparison)
draw_preset_comparison(*view.comparison, {72.0F, 150.0F, panel.x - 144.0F, 760.0F}, ease);
overlay_.pop_opacity();
}
+ struct FactsBounds { float x, y, w; };
+ // A sheet's read-only labels and values, as the design system's DetailList. Returns the height they take.
+ float draw_sheet_facts(const std::vector<ViewFact> &facts, const FactsBounds &bounds)
+ {
+ if (facts.empty())
+ return 0.0F;
+ sheet_facts_.style.theme = theme_;
+ sheet_facts_.style.panel = false;
+ sheet_facts_.style.scroll_thumb = false;
+ sheet_facts_.style.max_lines = 1;
+ if (facts != sheet_facts_shown_)
+ {
+ // Only a different set of facts plays the list's entrance; a size that changes just changes.
+ const bool same_rows = facts.size() == sheet_facts_shown_.size();
+ if (!same_rows)
+ {
+ std::vector<ui::DetailItem> items;
+ for (const ViewFact &fact : facts)
+ items.push_back({fact.label, fact.value});
+ sheet_facts_.set_items(std::move(items));
+ }
+ for (std::size_t index = 0; index < facts.size(); ++index)
+ {
+ auto &item = sheet_facts_.item(static_cast<int>(index));
+ item.label = facts[index].label;
+ item.value = facts[index].value;
+ item.color = facts[index].warn ? kRed : gfx::Color{0.0F, 0.0F, 0.0F, 0.0F};
+ }
+ sheet_facts_shown_ = facts;
+ }
+ const float height = static_cast<float>(facts.size()) * (sheet_facts_.style.row_height + sheet_facts_.style.gap);
+ sheet_facts_.set_bounds({bounds.x, bounds.y, bounds.w, height});
+ sheet_facts_.update(frame_dt_);
+ ui::Canvas canvas{overlay_, fonts_, renderer_.glass_texture(), clock_};
+ sheet_facts_.draw(canvas);
+ return height;
+ }
+
// Preset chooser: what the focused preset changes, beside the sheet (Current → This preset).
void draw_preset_comparison(const ViewData::Comparison &comparison, const gfx::Rect &bounds, float ease)
{
@@ -4271,7 +4321,7 @@ class Render::Impl
return 30.0F;
if (row.kind == RowKind::Heading || row.kind == RowKind::Separator)
return 54.0F;
- const bool checkbox = (view.surface == "kept-data" || view.surface == "leftover-titles" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0)) &&
+ const bool checkbox = (view.surface == "kept-data" || view.surface == "leftover-titles" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0) || view.surface == "install-dlc") &&
row.kind == RowKind::Toggle;
const bool described = (settings_sheet || checkbox || import_sheet) && !row.subtitle.empty();
return (described ? 96.0F + hint_extra(row) : 72.0F) + 12.0F;
@@ -4374,7 +4424,7 @@ class Render::Impl
// Game settings rows carry an effect line under the name (or the reason a row is
// disabled), an accent dot when the player changed the value, and a tag.
// 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 == "leftover-titles" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0)) &&
+ const bool checkbox = (view.surface == "kept-data" || view.surface == "leftover-titles" || (view.surface == "collections" && row.action.rfind("collection-toggle-", 0) == 0) || view.surface == "install-dlc") &&
row.kind == RowKind::Toggle;
const bool described = (settings_sheet || checkbox || import_sheet) && !row.subtitle.empty() && row.kind != RowKind::Heading;
const gfx::Rect rect{bounds.x, y, bounds.w, described ? 96.0F + hint_extra(row) : 72.0F};
@@ -4410,7 +4460,7 @@ class Render::Impl
}
// Game names may need a fallback face (Greek, CJK, Arabic).
const ui::FontRef &face = font_for(overlay_label(row), fonts_.display);
- const std::string label = fit(face, overlay_label(row), 28.0F, rect.w - 64.0F - value_width);
+ const std::string label = fit(face, overlay_label(row), 28.0F, rect.w - (name_x - rect.x) - 40.0F - value_width);
ui::text(overlay_, face, label, name_x, name_y, 28.0F, ink);
if (settings_sheet && !row.badge.empty() && row.kind != RowKind::Heading)
{
@@ -4545,6 +4595,8 @@ class Render::Impl
OverlayTransition overlay_transition_;
std::string sheet_scroll_key_; // the sheet the scroll belongs to
float sheet_scroll_ = 0.0F;
+ ui::DetailList sheet_facts_;
+ std::vector<ViewFact> sheet_facts_shown_;
float sheet_scroll_target_ = 0.0F;
int last_width_ = 0;
int last_height_ = 0;
diff --git a/src/steam/app_details_service.cpp b/src/steam/app_details_service.cpp
index 6f3d36d..7d92991 100644
--- a/src/steam/app_details_service.cpp
+++ b/src/steam/app_details_service.cpp
@@ -96,13 +96,11 @@ bool AppDetailsService::Measure(SizeRequest request, std::uint64_t account_gener
[&](const SizeRequest& queued) { return queued.update == request.update; });
if (static_cast<std::size_t>(same_kind) >= kMaxPending) return false;
measure_requested_.insert(request);
- // The install sheet's choice is waited for on screen: ahead of the updates' sizes.
+ // The install sheet's choice is waited for on screen: ahead of the updates' sizes, and the page opened last first.
if (request.update) {
measure_pending_.push_back(std::move(request));
} else {
- const auto first_update = std::find_if(measure_pending_.begin(), measure_pending_.end(),
- [](const SizeRequest& queued) { return queued.update; });
- measure_pending_.insert(first_update, std::move(request));
+ measure_pending_.insert(measure_pending_.begin(), std::move(request));
}
wake_.notify_all();
return true;
diff --git a/src/steam/app_details_service.h b/src/steam/app_details_service.h
index 4eabfcd..892dbaa 100644
--- a/src/steam/app_details_service.h
+++ b/src/steam/app_details_service.h
@@ -44,6 +44,25 @@ struct AppVersion {
std::vector<LanguageSize> languages;
};
+// A DLC an install can include or leave out. Its sizes are for the public branch in the Settings language.
+struct DlcChoice {
+ std::uint32_t app_id = 0;
+ std::string name; // empty: Steam doesn't describe it
+ std::uint64_t download_bytes = 0;
+ std::uint64_t install_bytes = 0;
+ bool free = false; // not owned yet: an install claims it
+ // Where another version or language differs. No install bytes: this choice doesn't have the DLC.
+ struct OtherSize {
+ std::string branch;
+ std::string language;
+ std::uint64_t download_bytes = 0;
+ std::uint64_t install_bytes = 0;
+ bool optional = false; // Steam doesn't download it by itself on this choice
+ };
+ std::vector<OtherSize> other_sizes;
+ bool optional = false; // Steam doesn't download it by itself: an install starts with it off, if it is owned
+};
+
// What a game's Steam app info says about installing it on this console.
struct AppDetails {
GameId id;
@@ -60,9 +79,8 @@ struct AppDetails {
// The content languages the game's Windows depots carry, as Steam names them ("german"), in
// listing order; empty when nothing is localised. An install can pick one of them.
std::vector<std::string> languages;
- // Owned DLC with Windows content an install includes. Counted from the depots the game itself lists
- // for its DLC (dlcappid): depots only a DLC app lists, and DLC an install claims for free, are not counted.
- std::uint32_t dlc_count = 0;
+ // A game that isn't installed: the DLC with files an install can leave out, owned or free to claim (OfferedDlc).
+ std::vector<DlcChoice> dlc;
// The versions an install can choose: the public branch first, then branches with no password
// that carry the game's own content, the most recently updated first. One entry: nothing to choose.
std::vector<AppVersion> versions;
@@ -102,13 +120,16 @@ struct SizeRequest {
std::string branch;
std::string language;
bool update = false;
+ std::vector<std::uint32_t> excluded_dlc; // DLC turned off for this install, sorted
bool operator==(const SizeRequest& other) const {
- return id == other.id && branch == other.branch && language == other.language && update == other.update;
+ return id == other.id && branch == other.branch && language == other.language && update == other.update &&
+ excluded_dlc == other.excluded_dlc;
}
bool operator<(const SizeRequest& other) const {
if (!(id == other.id)) return id < other.id;
if (update != other.update) return other.update;
- return branch != other.branch ? branch < other.branch : language < other.language;
+ if (branch != other.branch) return branch < other.branch;
+ return language != other.language ? language < other.language : excluded_dlc < other.excluded_dlc;
}
};
diff --git a/src/steam/backend/app_info.cpp b/src/steam/backend/app_info.cpp
index 014b6d0..1751bde 100644
--- a/src/steam/backend/app_info.cpp
+++ b/src/steam/backend/app_info.cpp
@@ -131,6 +131,7 @@ DepotInfo ParseDepot(std::uint32_t id, const VdfNode& value) {
depot.depot_from_app = ChildU32(&value, "depotfromapp");
depot.dlc_app_id = ChildU32(&value, "dlcappid");
depot.is_dlc = depot.dlc_app_id.has_value();
+ depot.optional_dlc = ChildU32(config, "optionaldlc").value_or(0) != 0;
// Every branch's manifest. Old appinfo format: the gid directly as a string; new: a dict {gid, size, download}.
if (const VdfNode* manifests = value.Find("manifests"); manifests != nullptr && manifests->is_dict) {
for (const auto& [branch, entry] : manifests->children) {
@@ -647,6 +648,7 @@ std::vector<DlcOffer> OfferedDlc(const AppInfo& app, const std::vector<AppInfo>&
DlcOffer offer;
offer.app_id = owner;
offer.free = free.count(owner) > 0;
+ offer.optional = std::all_of(owned.begin(), owned.end(), [](const DepotInfo& depot) { return depot.optional_dlc; });
DepotBytes(owned, &offer.install_bytes, &offer.download_bytes);
if (offer.install_bytes == 0) continue;
for (const AppInfo& dlc : dlc_apps)
diff --git a/src/steam/backend/app_info.h b/src/steam/backend/app_info.h
index 28137ef..4ba178e 100644
--- a/src/steam/backend/app_info.h
+++ b/src/steam/backend/app_info.h
@@ -30,6 +30,8 @@ struct DepotInfo {
std::optional<std::uint32_t> depot_from_app;
bool is_dlc = false;
std::optional<std::uint32_t> dlc_app_id;
+ // config/optionaldlc: the DLC this depot belongs to doesn't download by itself (tools, language packs).
+ bool optional_dlc = false;
// The public branch's manifest; in SelectDepots' result, the selected branch's.
std::optional<std::uint64_t> manifest_gid;
std::uint64_t size = 0;
@@ -193,6 +195,7 @@ struct DlcOffer {
std::uint64_t install_bytes = 0;
std::uint64_t download_bytes = 0;
bool free = false; // not owned yet: an install claims it, unless it is turned off
+ bool optional = false; // every depot of it is marked optional: Steam doesn't download it by itself
};
// The DLC an install of the game could hold, as SelectDepots selects them: owned DLC and free DLC this account can
diff --git a/src/steam/backend/cm_app_details.cpp b/src/steam/backend/cm_app_details.cpp
index 7f6f84a..ccc085d 100644
--- a/src/steam/backend/cm_app_details.cpp
+++ b/src/steam/backend/cm_app_details.cpp
@@ -1,6 +1,7 @@
#include "steam/backend/cm_app_details.h"
#include "steam/backend/app_info.h"
+#include "steam/backend/steam_install_runner.h"
#include <algorithm>
#include <chrono>
@@ -71,7 +72,7 @@ AppDetails DetailsFromAppInfo(std::uint32_t id, const std::string& buffer,
const std::optional<LicensedDepots::Grant>& licensed,
std::string_view language,
const std::optional<installs::InstalledRecord>& installed,
- const std::vector<AppInfo>& dlc_apps) {
+ const std::vector<AppInfo>& dlc_apps, const std::set<std::uint32_t>* free_dlc_refused) {
AppDetails details;
details.id = GameId::Steam(id);
const auto app = ParseAppInfo(id, buffer);
@@ -116,10 +117,6 @@ AppDetails DetailsFromAppInfo(std::uint32_t id, const std::string& buffer,
}
details.languages = selected.languages;
const auto& depots = selected.depots;
- std::set<std::uint32_t> dlc;
- for (const auto& depot : depots)
- if (depot.owner_app != 0 && depot.owner_app != id) dlc.insert(depot.owner_app);
- details.dlc_count = static_cast<std::uint32_t>(dlc.size());
std::uint64_t install = 0;
std::uint64_t download = 0;
DepotBytes(depots, &install, &download);
@@ -133,6 +130,52 @@ AppDetails DetailsFromAppInfo(std::uint32_t id, const std::string& buffer,
version.languages.push_back({bytes.language, bytes.download_bytes, bytes.install_bytes});
details.versions.push_back(std::move(version));
}
+ // Only licenses say which DLC is owned or still free to claim. Without them the sheet has nothing to offer.
+ if (!installed && any) {
+ const std::set<std::uint32_t> refused_dlc = free_dlc_refused ? *free_dlc_refused : std::set<std::uint32_t>{};
+ auto offers = OfferedDlc(*app, dlc_apps, apps, depots_owned, selection, refused_dlc);
+ std::map<std::uint32_t, std::vector<DlcChoice::OtherSize>> other_sizes;
+ // Each version in each language the sheet can choose: what differs from the sizes above. A DLC only another
+ // version has joins the list, with no size here.
+ const auto base = offers;
+ const auto compare = [&](const std::string& branch, const std::string& language) {
+ DepotSelection other = selection;
+ other.branch = branch;
+ other.language = language;
+ const auto found = OfferedDlc(*app, dlc_apps, apps, depots_owned, other, refused_dlc);
+ for (const auto& offer : found) {
+ const auto known = std::find_if(offers.begin(), offers.end(), [&](const DlcOffer& seen) { return seen.app_id == offer.app_id; });
+ if (known == offers.end()) {
+ offers.push_back(offer);
+ offers.back().install_bytes = offers.back().download_bytes = 0;
+ }
+ const auto listed = std::find_if(base.begin(), base.end(), [&](const DlcOffer& seen) { return seen.app_id == offer.app_id; });
+ if (listed == base.end() || listed->install_bytes != offer.install_bytes || listed->download_bytes != offer.download_bytes ||
+ listed->optional != offer.optional)
+ other_sizes[offer.app_id].push_back({branch, language, offer.download_bytes, offer.install_bytes, offer.optional});
+ }
+ for (const auto& offer : base)
+ if (std::none_of(found.begin(), found.end(), [&](const DlcOffer& seen) { return seen.app_id == offer.app_id; }))
+ other_sizes[offer.app_id].push_back({branch, language, 0, 0, false});
+ };
+ // The sheet's language list doesn't change with its version: a version can be asked for one it doesn't carry,
+ // and each part of the game then falls back on its own.
+ std::set<std::string> languages{selection.language};
+ languages.insert(details.languages.begin(), details.languages.end());
+ std::vector<std::string> branches;
+ for (const auto& version : details.versions) {
+ branches.push_back(version.name);
+ for (const auto& size : version.languages) languages.insert(size.language);
+ }
+ if (branches.empty()) branches.push_back("public");
+ for (const auto& branch : branches)
+ for (const auto& choice : languages)
+ if (branch != "public" || choice != selection.language) compare(branch, choice);
+ SortDlcOffers(&offers);
+ for (auto& offer : offers)
+ details.dlc.push_back({offer.app_id, std::move(offer.name), offer.download_bytes, offer.install_bytes, offer.free,
+ std::move(other_sizes[offer.app_id]), offer.optional});
+ }
std::vector<AppLaunch> launches;
// An installed game starts as its branch does.
const std::string branch = installed && !installed->branch.empty() ? installed->branch : std::string("public");
@@ -197,25 +240,29 @@ std::vector<AppDetails> CmAppDetailsSource::Fetch(const StoredSession& session,
continue;
}
const auto record = installed_ ? installed_(id) : std::nullopt;
- // An installed game's DLC apps list depots of their own: an update selects them too. A batch Steam
- // doesn't answer only leaves those DLC out of the comparison.
+ // DLC apps list depots of their own: an update selects them too, and the install sheet offers them. A batch
+ // Steam doesn't answer only leaves those DLC out. An imported copy's record names no depots: nothing to compare.
std::vector<AppInfo> dlc_apps;
- if (record && !record->depots.empty()) dlc_apps = FetchDlcApps(client_, session, id, found->second, cancel);
+ if (!record || !record->depots.empty()) dlc_apps = FetchDlcApps(client_, session, id, found->second, cancel);
if (cancel.load()) return {};
+ std::set<std::uint32_t> refused;
+ if (!record && free_dlc_memory_) refused = LoadFreeDlcMemory(*free_dlc_memory_, session.steam_id);
result.push_back(DetailsFromAppInfo(id, found->second, licensed_ ? licensed_->Get(session.steam_id) : std::nullopt, language, record,
- dlc_apps));
+ dlc_apps, &refused));
}
return result;
}
std::vector<DepotInfo> DepotsToMeasure(std::uint32_t id, const std::string& buffer,
const std::optional<LicensedDepots::Grant>& licensed, const std::string& branch,
- std::string_view language, const std::vector<AppInfo>& dlc_apps) {
+ std::string_view language, const std::vector<AppInfo>& dlc_apps,
+ const std::vector<std::uint32_t>& excluded_dlc) {
const auto app = ParseAppInfo(id, buffer);
if (!app) return {};
DepotSelection selection;
selection.language = std::string(language);
if (!branch.empty()) selection.branch = branch;
+ selection.excluded_dlc.insert(excluded_dlc.begin(), excluded_dlc.end());
const std::set<std::uint32_t> owned{id};
SelectionResult selected;
bool any = false;
@@ -271,7 +318,7 @@ MeasuredSize CmAppDetailsSource::Measure(const StoredSession& session, const Siz
return result;
}
const auto depots = DepotsToMeasure(*app, buffer->second, licensed_ ? licensed_->Get(session.steam_id) : std::nullopt,
- request.branch, language, dlc_apps);
+ request.branch, language, dlc_apps, request.excluded_dlc);
depot_count = depots.size();
if (depots.empty()) {
log("skipped", {});
diff --git a/src/steam/backend/cm_app_details.h b/src/steam/backend/cm_app_details.h
index 32a5d45..2c043b2 100644
--- a/src/steam/backend/cm_app_details.h
+++ b/src/steam/backend/cm_app_details.h
@@ -9,6 +9,7 @@
#include <functional>
#include <map>
+#include <set>
#include <utility>
namespace playden::steam {
@@ -31,6 +32,9 @@ class CmAppDetailsSource final : public AppDetailsSource {
void SetInstalled(std::function<std::optional<installs::InstalledRecord>(std::uint32_t app)> installed) {
installed_ = std::move(installed);
}
+ // Where installs remember the free DLC Steam refused this account (SteamInstallRunner::SetFreeDlcMemory): the
+ // install sheet doesn't offer those.
+ void SetFreeDlcMemory(const Storage* storage) { free_dlc_memory_ = storage; }
// An installed game's folder, for an update's size (its tree says which files change). Called on the size worker.
void SetInstallRoot(std::function<std::optional<std::string>(std::uint32_t app)> root) { install_root_ = std::move(root); }
// What measures an install choice from its manifests (MeasuredSize), and the connection its size checks read
@@ -59,6 +63,7 @@ class CmAppDetailsSource final : public AppDetailsSource {
const std::string& buffer, const std::atomic<bool>& cancel);
CmClient& client_;
const LicensedDepots* licensed_ = nullptr;
+ const Storage* free_dlc_memory_ = nullptr;
std::function<std::string()> language_;
std::function<std::optional<installs::InstalledRecord>(std::uint32_t)> installed_;
std::function<std::optional<std::string>(std::uint32_t)> install_root_;
@@ -77,9 +82,11 @@ class CmAppDetailsSource final : public AppDetailsSource {
// hold kMeasureDepotBytes or more. Empty: Steam's figures stand.
inline constexpr std::uint64_t kMeasureDepotBytes = 64ull * 1000 * 1000;
// `dlc_apps`: the game's DLC apps' appinfo, for the depots only they list, as an install reads them.
+// `excluded_dlc`: DLC turned off for this install.
std::vector<DepotInfo> DepotsToMeasure(std::uint32_t id, const std::string& buffer,
const std::optional<LicensedDepots::Grant>& licensed, const std::string& branch,
- std::string_view language, const std::vector<AppInfo>& dlc_apps = {});
+ std::string_view language, const std::vector<AppInfo>& dlc_apps = {},
+ const std::vector<std::uint32_t>& excluded_dlc = {});
// Pure part, for tests: turns one parsed app buffer into details. With `licensed`, sizes count
// only the depots those licenses grant, as an install selects them. With `installed` (the game's
@@ -89,7 +96,8 @@ AppDetails DetailsFromAppInfo(std::uint32_t id, const std::string& buffer,
const std::optional<LicensedDepots::Grant>& licensed = std::nullopt,
std::string_view language = kDefaultContentLanguage,
const std::optional<installs::InstalledRecord>& installed = std::nullopt,
- const std::vector<AppInfo>& dlc_apps = {});
+ const std::vector<AppInfo>& dlc_apps = {},
+ const std::set<std::uint32_t>* free_dlc_refused = nullptr);
// The selection an update installs (depots and manifests, in order), as a number: an update's size is measured
// for one. Never 0.
diff --git a/tests/app_details_test.cpp b/tests/app_details_test.cpp
index 6431c1c..664f892 100644
--- a/tests/app_details_test.cpp
+++ b/tests/app_details_test.cpp
@@ -649,13 +649,106 @@ void IncludedDlcIsCounted() {
}
})";
// Without licenses no DLC counts as owned.
- assert(DetailsFromAppInfo(6000, buffer).dlc_count == 0);
+ assert(DetailsFromAppInfo(6000, buffer).dlc.empty());
LicensedDepots::Grant grant;
grant.apps = {6000, 6001, 6003};
grant.depots = {6000, 6011, 6012, 6021, 6031};
const auto details = DetailsFromAppInfo(6000, buffer, grant);
// 6001 counts once for its two depots; 6002 isn't owned and 6003 is Mac only.
- assert(details.dlc_count == 1 && details.install_bytes == 1020u);
+ assert(details.install_bytes == 1020u);
+ assert(details.dlc.size() == 1 && details.dlc[0].app_id == 6001 && details.dlc[0].install_bytes == 20 &&
+ details.dlc[0].download_bytes == 10 && !details.dlc[0].free);
+ // An installed game offers no choice.
+ installs::InstalledRecord record;
+ record.version = 2;
+ record.app_id = 6000;
+ record.depots = {{6000, 1, 6000, 6000}};
+ assert(DetailsFromAppInfo(6000, buffer, grant, "english", record).dlc.empty());
+ // A free pack on the game's own list, as Space Marine 2's: offered and sized, unless Steam refused it.
+ const std::string pack_game = R"("appinfo"
+{
+ "common" { "name" "Big Game" "type" "Game" }
+ "extended" { "listofdlc" "6101" }
+ "config" { "launch" { "0" { "executable" "game.exe" "config" { "oslist" "windows" } } } }
+ "depots"
+ {
+ "6100" { "manifests" { "public" { "gid" "1" "size" "100000000" "download" "1000" } } }
+ "6111" { "dlcappid" "6101" "manifests" { "public" { "gid" "2" "size" "300000000" "download" "2000" } } }
+ }
+})";
+ const auto pack = ParseAppInfo(6101, R"("appinfo" { "common" { "name" "Big Game - Pack" "type" "DLC" } "extended" { "isfreeapp" "1" } })");
+ assert(pack.has_value());
+ const LicensedDepots::Grant game_only{{6100}, {6100}};
+ auto offered = DetailsFromAppInfo(6100, pack_game, game_only, "english", std::nullopt, {*pack});
+ assert(offered.dlc.size() == 1 && offered.dlc[0].free && offered.dlc[0].name == "Pack" && offered.dlc[0].install_bytes == 300000000u);
+ assert(offered.install_bytes == 100000000u); // not owned: the game's own figure leaves it out
+ assert(!offered.dlc[0].optional);
+ const std::set<std::uint32_t> refused{6101};
+ assert(DetailsFromAppInfo(6100, pack_game, game_only, "english", std::nullopt, {*pack}, &refused).dlc.empty());
+ // Each version and language says where it differs: another size, no DLC at all, or a DLC only it has.
+ const std::string branched = R"("appinfo"
+{
+ "common" { "name" "Big Game" "type" "Game" }
+ "extended" { "listofdlc" "6201,6202,6203" }
+ "config" { "launch" { "0" { "executable" "game.exe" "config" { "oslist" "windows" } } } }
+ "depots"
+ {
+ "6200" { "manifests" { "public" { "gid" "1" "size" "100" "download" "50" } "beta" { "gid" "2" "size" "100" "download" "50" } } }
+ "6211" { "dlcappid" "6201" "manifests" { "public" { "gid" "3" "size" "20" "download" "10" } "beta" { "gid" "4" "size" "5" "download" "2" } } }
+ "6212" { "dlcappid" "6202" "manifests" { "public" { "gid" "5" "size" "30" "download" "20" } } }
+ "6213" { "dlcappid" "6203" "manifests" { "beta" { "gid" "6" "size" "40" "download" "30" } } }
+ "6221" { "dlcappid" "6201" "config" { "language" "german" } "manifests" { "public" { "gid" "7" "size" "60" "download" "45" } } }
+ "6222" { "config" { "language" "german" } "manifests" { "public" { "gid" "8" "size" "10" "download" "5" } } }
+ "branches" { "public" { "buildid" "1" } "beta" { "buildid" "2" } }
+ }
+})";
+ const LicensedDepots::Grant all{{6200, 6201, 6202, 6203}, {6200, 6211, 6212, 6213, 6221, 6222}};
+ const auto choices = DetailsFromAppInfo(6200, branched, all).dlc;
+ const auto choice = [&](std::uint32_t app) {
+ const auto found = std::find_if(choices.begin(), choices.end(), [&](const DlcChoice& dlc) { return dlc.app_id == app; });
+ assert(found != choices.end());
+ return *found;
+ };
+ const auto other = [](const DlcChoice& dlc, const std::string& branch, const std::string& language) -> const DlcChoice::OtherSize* {
+ for (const auto& size : dlc.other_sizes)
+ if (size.branch == branch && size.language == language) return &size;
+ return nullptr;
+ };
+ assert(choices.size() == 3);
+ assert(choice(6201).install_bytes == 20 && other(choice(6201), "beta", "english") && other(choice(6201), "beta", "english")->install_bytes == 5);
+ assert(choice(6202).install_bytes == 30 && other(choice(6202), "beta", "english") && other(choice(6202), "beta", "english")->install_bytes == 0);
+ assert(choice(6203).install_bytes == 0 && other(choice(6203), "beta", "english")->install_bytes == 40);
+ // A language only the public version carries, chosen with beta: beta's DLC, not the public list.
+ assert(other(choice(6201), "public", "german") && other(choice(6201), "public", "german")->install_bytes == 80);
+ assert(other(choice(6202), "beta", "german") && other(choice(6202), "beta", "german")->install_bytes == 0);
+ assert(other(choice(6203), "beta", "german") && other(choice(6203), "beta", "german")->install_bytes == 40);
+ // The same on another choice: nothing to say.
+ assert(!other(choice(6202), "public", "english"));
+ // Optional in one language only: that choice says so, even at the same size.
+ const std::string voiced = R"("appinfo"
+{
+ "extended" { "listofdlc" "6301" }
+ "config" { "launch" { "0" { "executable" "game.exe" "config" { "oslist" "windows" } } } }
+ "depots"
+ {
+ "6300" { "manifests" { "public" { "gid" "1" "size" "100" "download" "50" } } }
+ "6305" { "config" { "language" "german" } "manifests" { "public" { "gid" "2" "size" "10" "download" "5" } } }
+ "6311" { "dlcappid" "6301" "config" { "language" "english" } "manifests" { "public" { "gid" "3" "size" "20" "download" "10" } } }
+ "6312" { "dlcappid" "6301" "config" { "language" "german" "optionaldlc" "6301" } "manifests" { "public" { "gid" "4" "size" "20" "download" "10" } } }
+ "branches" { "public" { "buildid" "1" } }
+ }
+})";
+ const LicensedDepots::Grant voiced_grant{{6300, 6301}, {6300, 6305, 6311, 6312}};
+ const auto voiced_dlc = DetailsFromAppInfo(6300, voiced, voiced_grant).dlc;
+ assert(voiced_dlc.size() == 1 && !voiced_dlc[0].optional);
+ bool german_optional = false;
+ for (const auto& size : voiced_dlc[0].other_sizes)
+ if (size.branch == "public" && size.language == "german") german_optional = size.optional;
+ assert(german_optional);
+ // The exact size check measures what is left once DLC is turned off.
+ const LicensedDepots::Grant both{{6100, 6101}, {6100, 6111}};
+ assert(DepotsToMeasure(6100, pack_game, both, "public", "english", {*pack}).size() == 2);
+ assert(DepotsToMeasure(6100, pack_game, both, "public", "english", {*pack}, {6101}).empty());
}
// The versions an install can choose, with each one's own size; the licenses filter them as they do the sizes.
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index ac39aab..d5305ce 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT
#include "homebrew/queue_layout.hpp"
+#include "homebrew/details_ask.hpp"
#include "homebrew/simulation.hpp"
#include "homebrew/store_art.hpp"
@@ -21,6 +22,7 @@ namespace {
using playden::GameSummary;
using playden::homebrew::AuthState;
+using playden::homebrew::GameDlc;
using playden::homebrew::CloudRequestKind;
using playden::homebrew::CloudStatus;
using playden::homebrew::LibraryUpdate;
@@ -37,6 +39,13 @@ void check(bool condition, const char* message) {
}
}
+// A read-only fact above a sheet's rows.
+std::string fact(const playden::homebrew::Simulation& model, const std::string& label) {
+ for (const auto& item : model.view().facts)
+ if (item.label == label) return item.value;
+ return "(no " + label + ")";
+}
+
Simulation make_live() {
return Simulation("fixtures-not-used", "profile-not-used.json", ModelMode::Live);
}
@@ -476,7 +485,7 @@ void live_install_confirmation_checks_space_and_unknowns() {
model.state().navigation.focus_key == "storage-picker" && model.action("up") &&
model.state().navigation.focus_key == "install-confirm",
"the focus moves on from Install");
- check(model.view().subtitle.find("To M.2 SSD (this game only)") == 0 &&
+ check(fact(model, "Install to") == "M.2 SSD (this game only)" &&
model.view().subtitle.find("Other games still install to Console storage") != std::string::npos,
"the sheet names the one-off drive and the unchanged default");
check(model.TakeInstallRequests().empty() && model.state().default_volume_id == "internal",
@@ -536,28 +545,150 @@ void live_install_confirmation_checks_space_and_unknowns() {
check(model.TakeInstallRequests().size() == 1, "a console that cannot read free space still installs, as before");
}
-// Owned DLC the download includes: an "Includes" status row on the install sheet, only when there is some.
+// DLC with files: a DLC row on the install sheet, only when there is some, opens the list of which to install.
void live_install_dlc_row() {
+ using playden::homebrew::InstallRequestKind;
auto model = make_live();
model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
check(model.UpdateLibrary({{game(SteamId(42), "With DLC"), game(SteamId(43), "Without DLC")}, false, {}, false, false, {}}),
"library loaded");
model.UpdateVolumes({{"internal", "Console storage", true, 2'000'000'000, 1'000'000'000}}, "internal");
- model.UpdateAppDetails(SteamId(42), 100, 600, true, {"english", "german"}, 3);
+ const std::vector<GameDlc> dlc{{501, "Art Book", 40, 50, false}, {502, "Campaign", 200'000'000, 300'000'000, false},
+ {503, "Texture Pack", 100'000'000, 1'200'000'000, true}, {504, "", 10, 20, false}};
+ // The game's figures count owned DLC, not the free pack, which the account doesn't own yet.
+ model.UpdateAppDetails(SteamId(42), 300'000'000, 500'000'000, true, {"english", "german"}, dlc);
check(model.action("details:42"), "details open");
+ // The page says what Install will: everything starts on here, so 500 MB plus the free pack's 1.2 GB.
+ check(find_row(model, "details-install")->value == "1.7 GB", "the page says what Install will");
+ const auto page_install = [&model] {
+ for (const auto& item : model.route_view().rows)
+ if (item.key == "details-install") return item.value;
+ return std::string();
+ };
activate(model, "details-install");
const auto* row = find_row(model, "install-dlc");
- check(model.view().surface == "install" && row && row->title == "Includes" && row->value == "3 DLC" &&
- row->kind == RowKind::Status && !row->enabled,
- "the sheet says how many DLC the download includes");
+ check(page_install() == "1.7 GB", "behind the sheet it follows the choice");
+ check(model.view().surface == "install" && row && row->title == "DLC" && row->value == "4 of 4 · 1.5 GB" && row->enabled,
+ "the sheet says how much DLC the install holds");
+ // Everything on: the free pack counts, and it doesn't fit.
+ check(fact(model, "Needs") == "About 1.7 GB", "free DLC that is on counts");
+ check(!find_row(model, "install-confirm")->enabled, "it doesn't fit with the pack on");
+ auto size_check = model.TakeSizeChecks();
+ check(size_check.size() == 1 && size_check[0].excluded_dlc.empty(), "the size check has no DLC off");
+ model.UpdateMeasuredSize(size_check[0], false, false, {});
+
+ activate(model, "install-dlc");
+ check(model.view().surface == "install-dlc" && model.view().title == "DLC", "the row opens the list");
+ check(fact(model, "Total") == "About 1.7 GB · 1.0 GB free", "the list says the total");
+ row = find_row(model, "install-dlc-503");
+ check(row && row->title == "Texture Pack" && row->kind == RowKind::Toggle && row->selected &&
+ row->value == "Free · 1.2 GB",
+ "a free DLC says so, with its size and state");
+ row = find_row(model, "install-dlc-504");
+ check(row && row->title == "DLC 504", "a DLC without a name goes by its app ID");
+ check(!find_row(model, "heading-dlc-included") && find_row(model, "divider") && find_row(model, "install-dlc-done"),
+ "the list has its sections");
+ check(find_row(model, "install-dlc-all")->value == "4 of 4" && find_row(model, "install-dlc-all")->selected, "all DLC is on");
+ check(model.TakeSizeChecks().empty(), "the list asks for no size check");
+
+ // Toggling keeps the list open and changes the sizes.
+ activate(model, "install-dlc-503");
+ check(model.view().surface == "install-dlc", "a toggle keeps the list open");
+ row = find_row(model, "install-dlc-503");
+ check(row && !row->selected && row->value == "Free · 1.2 GB", "it turns off");
+ check(find_row(model, "install-dlc-all")->value == "3 of 4", "the all row counts");
+ activate(model, "install-dlc-502");
+ check(model.TakeSizeChecks().empty(), "toggling asks for no size check");
+ // Only "Art Book" (50 B) and the unnamed one are left; 500 MB less the 300 MB DLC.
+ check(fact(model, "Total") == "About 200 MB", "owned DLC that is off comes off Steam's figures");
+
+ activate(model, "install-dlc-done");
+ check(model.view().surface == "install", "Done returns to the sheet");
+ row = find_row(model, "install-dlc");
+ check(row && row->value.rfind("2 of 4", 0) == 0, "the sheet shows the choice");
+ size_check = model.TakeSizeChecks();
+ check(size_check.size() == 1 && (size_check[0].excluded_dlc == std::vector<std::uint32_t>{502}),
+ "the size check leaves out owned DLC only");
+ // A measured size has left the owned DLC out already; free DLC that is on is added to it.
+ model.UpdateMeasuredSize(size_check[0], true, false, {150'000'000, 100'000'000});
+ check(fact(model, "Download") == "100 MB", "the exact size has no \"About\"");
+ check(fact(model, "Needs") == "150 MB", "the exact size stands");
+ check(page_install() == "150 MB", "and the page behind it says the same");
+
+ activate(model, "install-confirm");
+ auto requests = model.TakeInstallRequests();
+ check(requests.size() == 1 && requests[0].kind == InstallRequestKind::Install && requests[0].install_bytes == 150'000'000u &&
+ (requests[0].excluded_dlc == std::vector<std::uint32_t>{502, 503}),
+ "the install carries the choice and the size it reserves");
+ // The drive reserves that size while it runs, not the game's figure with its DLC.
+ playden::homebrew::LiveInstallJob running;
+ running.game_id = SteamId(42);
+ running.state = playden::homebrew::JobState::Downloading;
+ running.volume_id = "internal";
+ running.held_bytes = 50'000'000;
+ running.estimated_bytes = requests[0].install_bytes;
+ model.UpdateInstalls({running}, {});
+ check(model.state().volumes[0].reserved_bytes == 100'000'000, "a running install reserves what was chosen");
+ model.UpdateInstalls({}, {{SteamId(42), 150'000'000}});
+ check(model.state().volumes[0].reserved_bytes == 0, "a finished one reserves nothing");
+ model.UpdateInstalls({}, {}); // uninstalled again, for what follows
+
+ // All off from everything on; all on from some off.
+ model.UpdateAppDetails(SteamId(43), 100, 600, true, {}, dlc);
+ check(model.action("details:43"), "details open");
+ activate(model, "details-install");
+ check(find_row(model, "install-dlc")->value == "4 of 4 · 1.5 GB", "a new sheet starts with everything on");
+ activate(model, "install-dlc");
+ activate(model, "install-dlc-all");
+ check(find_row(model, "install-dlc-all")->value == "0 of 4" && !find_row(model, "install-dlc-501")->selected, "all off");
+ activate(model, "install-dlc-501");
+ activate(model, "install-dlc-all");
+ check(find_row(model, "install-dlc-all")->value == "4 of 4" && find_row(model, "install-dlc-501")->selected, "all on");
+ activate(model, "install-dlc-all");
+ activate(model, "install-dlc-done");
+ check(find_row(model, "install-dlc")->value == "None", "the sheet says none");
+ activate(model, "cancel");
+ // Another version: its sizes, and only the DLC it has. A sheet opened with none gets the row when they arrive.
+ std::vector<GameDlc> versioned{{601, "Pack", 40, 50'000'000, false, {{"beta", "english", 20, 10'000'000}}},
+ {602, "Only public", 40, 70'000'000, false, {{"beta", "english", 0, 0}}},
+ {603, "Only beta", 0, 0, false, {{"beta", "english", 30, 30'000'000}}}};
+ const std::vector<playden::homebrew::GameVersion> versions{{"public", "", 1760000000, 9000, 100, 200'000'000, {}},
+ {"beta", "", 1760000000, 9001, 100, 100'000'000, {}}};
+ model.UpdateAppDetails(SteamId(43), 100, 200'000'000, true, {}, versioned, versions);
+ check(model.action("details:43"), "details open");
+ activate(model, "details-install");
+ check(find_row(model, "install-dlc")->value == "2 of 2 · 120 MB", "public: its two DLC");
+ activate(model, "install-version");
+ activate(model, "install-version-beta");
+ check(find_row(model, "install-dlc")->value == "2 of 2 · 40 MB", "beta: its two DLC, its sizes");
+ activate(model, "install-dlc");
+ check(find_row(model, "install-dlc-603") && !find_row(model, "install-dlc-602"), "beta lists what it has");
+ activate(model, "install-dlc-601");
+ // 100 MB for the version, less this version's 10 MB, not the public one's 50 MB.
+ check(fact(model, "Total") == "About 90 MB", "the sizes taken off are this version's");
+ activate(model, "install-dlc-done");
+ activate(model, "cancel");
+ // No DLC on the chosen version: no row, and it comes back with the version.
+ versioned = {{701, "Public DLC", 40, 70'000'000, false, {{"beta", "english", 0, 0}}}};
+ model.UpdateAppDetails(SteamId(43), 100, 200'000'000, true, {}, versioned, versions);
+ check(model.action("details:43"), "details open");
+ activate(model, "details-install");
+ activate(model, "install-version");
+ activate(model, "install-version-beta");
+ check(!find_row(model, "install-dlc"), "the row leaves with the DLC");
+ activate(model, "install-version");
+ activate(model, "install-version-public");
+ check(find_row(model, "install-dlc") != nullptr, "and comes back");
activate(model, "cancel");
- // DLC alone doesn't open the sheet; without DLC there is no row.
- model.UpdateAppDetails(SteamId(43), 100, 600, true, {"english", "german"}, 0);
+ // Without DLC there is no row; details arriving while the sheet is open bring it.
+ model.UpdateAppDetails(SteamId(43), 100, 600, true, {"english", "german"});
check(model.action("details:43"), "details open");
activate(model, "details-install");
check(model.view().surface == "install" && find_row(model, "install-dlc") == nullptr, "no DLC, no row");
+ model.UpdateAppDetails(SteamId(43), 100, 600, true, {"english", "german"}, dlc);
+ check(find_row(model, "install-dlc") != nullptr, "the open sheet gets the row");
activate(model, "cancel");
- model.UpdateAppDetails(SteamId(42), 100, 600, true, {"german"}, 3);
+ model.UpdateAppDetails(SteamId(42), 100, 600, true, {"german"}, dlc);
check(model.action("details:42"), "details open");
activate(model, "details-install");
check(model.view().surface == "install" && find_row(model, "install-language") == nullptr &&
@@ -565,6 +696,156 @@ void live_install_dlc_row() {
"a game with one language opens the sheet without a Language row");
}
+// Optional DLC the account owns starts off; other DLC and free DLC start on; the player's choice wins.
+void live_install_optional_dlc() {
+ auto model = make_live();
+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(model.UpdateLibrary({{game(SteamId(42), "With DLC"), game(SteamId(44), "By language")}, false, {}, false, false, {}}), "library loaded");
+ model.UpdateVolumes({{"internal", "Console storage", true, 20'000'000'000, 10'000'000'000}}, "internal");
+ std::vector<GameDlc> dlc{{501, "Expansion", 100'000'000, 100'000'000}, {502, "Tools", 200'000'000, 200'000'000},
+ {503, "Free tools", 300'000'000, 300'000'000, true}};
+ dlc[1].optional = true;
+ dlc[2].optional = true;
+ model.UpdateAppDetails(SteamId(42), 400'000'000, 500'000'000, true, {}, dlc);
+ check(model.action("details:42"), "details open");
+ check(find_row(model, "details-install")->value == "600 MB", "the page counts the defaults: less optional, plus free");
+ activate(model, "details-install");
+ check(find_row(model, "install-dlc")->value == "2 of 3 · 400 MB", "optional owned DLC starts off");
+ // What it downloads: 400 MB less the off 200 MB plus the free 300 MB.
+ check(fact(model, "Download") == "About 500 MB",
+ "the sheet says what the choice downloads");
+ check(model.action("down") && model.state().navigation.focus_key == "install-dlc", "only rows take the focus");
+ check(model.action("up") && model.state().navigation.focus_key == "install-confirm", "both ways");
+ auto checks = model.TakeSizeChecks();
+ check(checks.size() == 1 && (checks[0].excluded_dlc == std::vector<std::uint32_t>{502}), "the size check leaves it out");
+ model.UpdateMeasuredSize(checks[0], false, false, {});
+ check(fact(model, "Needs") == "About 600 MB", "the sheet's total leaves it out");
+ activate(model, "install-dlc");
+ check(find_row(model, "install-dlc-502")->value == "200 MB" && !find_row(model, "install-dlc-502")->selected, "the list shows it off");
+ check(find_row(model, "install-dlc-503")->value == "Free · 300 MB" && find_row(model, "install-dlc-503")->selected, "free DLC starts on even when optional");
+ check(find_row(model, "install-dlc-all")->value == "2 of 3", "the all row counts it");
+ check(fact(model, "Download") == "About 500 MB", "the list says the same");
+ // By how each starts: Included, then Optional, and a toggle doesn't move a row.
+ check(find_row(model, "heading-dlc-included") && find_row(model, "heading-dlc-optional"), "the list has both sections");
+ check(find_row(model, "install-dlc-503")->kind == RowKind::Toggle && find_row(model, "install-dlc-all")->kind == RowKind::Toggle, "rows are toggles");
+ check(model.action("down") && model.state().navigation.focus_key == "install-dlc-501", "focus goes past the heading");
+ check(model.action("up"), "back");
+ activate(model, "install-dlc-502");
+ check(find_row(model, "install-dlc-502")->selected, "the player can turn it on");
+ check(fact(model, "Download") == "About 700 MB", "the row follows the toggles");
+ activate(model, "install-dlc-501");
+ activate(model, "install-dlc-done");
+ activate(model, "install-confirm");
+ auto requests = model.TakeInstallRequests();
+ check(requests.size() == 1 && (requests[0].excluded_dlc == std::vector<std::uint32_t>{501}), "the choice wins over the default");
+ // Optional on one language only: the default follows the language chosen, same size or not.
+ model.UpdateInstalls({}, {});
+ std::vector<GameDlc> by_language{{601, "Voices", 10'000'000, 10'000'000}, {602, "Tools", 10'000'000, 10'000'000}};
+ by_language[0].other_sizes.push_back({"public", "german", 10'000'000, 10'000'000, true});
+ by_language[1].optional = true;
+ by_language[1].other_sizes.push_back({"public", "german", 10'000'000, 10'000'000, false});
+ model.UpdateAppDetails(SteamId(44), 400'000'000, 500'000'000, true, {"english", "german"}, by_language);
+ check(model.action("details:44"), "details open");
+ activate(model, "details-install");
+ (void)model.TakeSizeChecks();
+ check(find_row(model, "install-dlc")->value.rfind("1 of 2", 0) == 0, "one is optional in English");
+ activate(model, "install-language");
+ activate(model, "install-language-german");
+ (void)model.TakeSizeChecks();
+ activate(model, "install-confirm");
+ auto german = model.TakeInstallRequests();
+ check(german.size() == 1 && (german[0].excluded_dlc == std::vector<std::uint32_t>{601}), "German turns off German's optional DLC");
+ // Installing without opening the list leaves optional DLC out.
+ model.UpdateInstalls({}, {});
+ check(model.action("details:42"), "details open");
+ activate(model, "details-install");
+ (void)model.TakeSizeChecks();
+ activate(model, "install-confirm");
+ requests = model.TakeInstallRequests();
+ check(requests.size() == 1 && (requests[0].excluded_dlc == std::vector<std::uint32_t>{502}), "the default goes with the install");
+}
+
+// A game's page says what the install sheet will, before and after the exact check (DUSK flipped from 9.3 to 11.7 GB).
+void live_page_matches_install_sheet() {
+ auto model = make_live();
+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(model.UpdateLibrary({{game(SteamId(42), "Like DUSK"), game(SteamId(43), "Check fails")}, false, {}, false, false, {}}), "library loaded");
+ model.UpdateVolumes({{"internal", "Console storage", true, 40'000'000'000, 30'000'000'000}}, "internal");
+ // Owned: HD, which starts on, and optional Goodies, which starts off. Steam's figures count both.
+ std::vector<GameDlc> dlc{{601, "HD", 2'000'000'000, 2'400'000'000}, {602, "The Goodies", 3'000'000'000, 4'100'000'000}};
+ dlc[1].optional = true;
+ model.UpdateAppDetails(SteamId(42), 9'000'000'000, 15'800'000'000, true, {}, dlc);
+ check(model.action("details:42"), "details open");
+ check(find_row(model, "details-install")->value == "11.7 GB", "the page counts what starts on");
+ // The check runs with the page, for what the sheet opens with.
+ auto checks = model.TakeSizeChecks();
+ check(checks.size() == 1 && checks[0].id == SteamId(42) && (checks[0].excluded_dlc == std::vector<std::uint32_t>{602}),
+ "opening the page checks the sheet's choice");
+ model.UpdateMeasuredSize(checks[0], true, false, {11'500'000'000, 6'500'000'000});
+ check(find_row(model, "details-install")->value == "11.5 GB", "the page takes the exact size");
+ activate(model, "details-install");
+ check(model.TakeSizeChecks().empty(), "the sheet doesn't check it again");
+ check(fact(model, "Needs") == "11.5 GB" && fact(model, "Download") == "6.5 GB", "the sheet opens exact, the same as the page");
+ activate(model, "cancel");
+ // A choice changed and then canceled doesn't stay on the page.
+ activate(model, "details-install");
+ activate(model, "install-dlc");
+ activate(model, "install-dlc-602");
+ activate(model, "install-dlc-done");
+ (void)model.TakeSizeChecks();
+ activate(model, "cancel");
+ check(find_row(model, "details-install")->value == "11.5 GB", "the page goes back to the defaults");
+ // Optional DLC with no files on this version isn't in the sheet's list, so it isn't in the page's check either.
+ auto beta_only = dlc;
+ beta_only.push_back({603, "Beta extras", 0, 0});
+ beta_only.back().optional = true;
+ model.UpdateAppDetails(SteamId(42), 9'000'000'000, 15'800'000'000, true, {}, beta_only);
+ checks = model.TakeSizeChecks();
+ check(checks.size() == 1 && (checks[0].excluded_dlc == std::vector<std::uint32_t>{602}), "DLC without files isn't in the page's check");
+ model.UpdateMeasuredSize(checks[0], true, false, {11'500'000'000, 6'500'000'000});
+ activate(model, "details-install");
+ check(model.TakeSizeChecks().empty() && fact(model, "Needs") == "11.5 GB", "the sheet still has the page's answer");
+ activate(model, "cancel");
+ // During an install, the size is what that install was asked with.
+ playden::homebrew::Game installing;
+ installing.id = SteamId(44);
+ installing.install_bytes = 5'000'000'000;
+ check(playden::homebrew::uninstalled_size(installing, {}) == std::optional<std::uint64_t>(5'000'000'000), "no job: the defaults");
+ playden::homebrew::Job job;
+ job.game_id = installing.id;
+ job.estimated_bytes = 1'000'000'000;
+ check(playden::homebrew::uninstalled_size(installing, {job}) == std::optional<std::uint64_t>(1'000'000'000), "a job: what it was asked with");
+ job.state = playden::homebrew::JobState::Failed;
+ check(playden::homebrew::uninstalled_size(installing, {job}) == std::optional<std::uint64_t>(5'000'000'000), "a failed job: the defaults");
+ // A check that fails isn't asked again by redraws, only when the sheet opens.
+ model.UpdateAppDetails(SteamId(43), 100, 600, true);
+ check(model.action("details:43"), "details open");
+ checks = model.TakeSizeChecks();
+ check(checks.size() == 1, "the other page checks too");
+ model.UpdateMeasuredSize(checks[0], false, true, {});
+ model.UpdateVolumes({{"internal", "Console storage", true, 40'000'000'000, 29'000'000'000}}, "internal");
+ check(model.TakeSizeChecks().empty(), "a failed check isn't repeated on redraw");
+ activate(model, "details-install");
+ check(model.TakeSizeChecks().size() == 1, "opening the sheet asks again");
+}
+
+// When a page's details are asked (again): the DLC list must not come from before the licenses or an uninstall.
+void details_ask_follows_licenses_and_install_state() {
+ using playden::homebrew::DetailsAsk;
+ using playden::homebrew::DetailsAsked;
+ using playden::homebrew::NextDetailsAsk;
+ const DetailsAsked before{0, false};
+ check(NextDetailsAsk(std::nullopt, before, true) == DetailsAsk::kAgain, "a first visit asks, whatever an update check answered");
+ check(NextDetailsAsk(before, before, false) == DetailsAsk::kNothing, "an open page with its answer waits");
+ check(NextDetailsAsk(before, before, true) == DetailsAsk::kOnce, "an uninstalled game's answer lasts the session");
+ check(NextDetailsAsk(before, {1, false}, false) == DetailsAsk::kAgain, "licenses read while the page is open: asked again");
+ check(NextDetailsAsk(before, {1, false}, true) == DetailsAsk::kAgain, "licenses read since the last visit: asked again");
+ check(NextDetailsAsk(DetailsAsked{1, true}, {1, false}, true) == DetailsAsk::kAgain, "uninstalled since: asked again");
+ check(NextDetailsAsk(DetailsAsked{1, true}, {1, false}, false) == DetailsAsk::kAgain, "uninstalled on its page: asked again");
+ check(NextDetailsAsk(DetailsAsked{1, true}, {1, true}, true) == DetailsAsk::kAgain, "an installed game is asked at each visit");
+ check(NextDetailsAsk(DetailsAsked{1, true}, {1, true}, false) == DetailsAsk::kNothing, "but not all the time");
+}
+
// A game in several languages: the install sheet's Language row chooses one for this install only.
void live_install_language_row() {
using playden::homebrew::InstallRequestKind;
@@ -626,7 +907,7 @@ void live_install_version_row() {
check(model.UpdateLibrary({{game(SteamId(42), "Versions"), game(SteamId(43), "Single")}, false, {}, false, false, {}}),
"library loaded");
model.UpdateVolumes({{"internal", "Console storage", true, 2'000'000'000, 1'000'000'000}}, "internal");
- model.UpdateAppDetails(SteamId(43), 100, 600, true, {}, 0, {GameVersion{"public", "", 1760000000, 9000, 100, 600}});
+ model.UpdateAppDetails(SteamId(43), 100, 600, true, {}, {}, {GameVersion{"public", "", 1760000000, 9000, 100, 600}});
check(model.action("details:43"), "details open");
activate(model, "details-install");
check(model.view().surface == "install" && find_row(model, "install-version") == nullptr &&
@@ -634,7 +915,7 @@ void live_install_version_row() {
"a game with one version opens the sheet without a Version row");
activate(model, "cancel");
- model.UpdateAppDetails(SteamId(42), 100, 600, true, {}, 0,
+ model.UpdateAppDetails(SteamId(42), 100, 600, true, {}, {},
{GameVersion{"public", "", 1760000000, 9000, 100, 600},
GameVersion{"4.04", "Patch 4.04 (pre next-gen)", 1670000000, 4040, 200, 1'500'000'000}});
check(model.action("details:42"), "details open");
@@ -673,7 +954,7 @@ void live_install_version_row() {
check(requests[0].install_bytes == std::optional<std::uint64_t>(600), "Public's estimate goes with it");
// A branch that fits is sent with the install, and doesn't stay for the next one.
- model.UpdateAppDetails(SteamId(42), 100, 600, true, {}, 0,
+ model.UpdateAppDetails(SteamId(42), 100, 600, true, {}, {},
{GameVersion{"public", "", 1760000000, 9000, 100, 600},
GameVersion{"4.04", "Patch 4.04 (pre next-gen)", 1670000000, 4040, 200, 700}});
check(model.action("details:42"), "details open");
@@ -698,15 +979,15 @@ void live_install_language_size() {
model.UpdateVolumes({{"internal", "Console storage", true, 2'000'000'000, 1'000'000'000}}, "internal");
GameVersion version{"public", "", 1760000000, 9000, 300'000'000, 600'000'000, {}};
version.languages = {{"english", 300'000'000, 600'000'000}, {"russian", 900'000'000, 1'500'000'000}};
- model.UpdateAppDetails(SteamId(42), 300'000'000, 600'000'000, true, {"english", "russian"}, 0, {version});
+ model.UpdateAppDetails(SteamId(42), 300'000'000, 600'000'000, true, {"english", "russian"}, {}, {version});
check(model.action("details:42"), "details open");
activate(model, "details-install");
- check(model.view().surface == "install" && model.view().subtitle.find("Needs about 600 MB") != std::string::npos &&
+ check(model.view().surface == "install" && fact(model, "Needs") == "About 600 MB" &&
find_row(model, "install-confirm")->enabled,
"English: the Settings language's size");
activate(model, "install-language");
activate(model, "install-language-russian");
- check(model.view().surface == "install" && model.view().subtitle.find("Needs about 1.5 GB") != std::string::npos,
+ check(model.view().surface == "install" && fact(model, "Needs") == "About 1.5 GB",
"Russian: its own size");
check(!find_row(model, "install-confirm")->enabled, "and that size is the one checked");
}
@@ -722,19 +1003,19 @@ void live_install_exact_size() {
model.UpdateVolumes({{"internal", "Console storage", true, 2'000'000'000, 1'000'000'000}}, "internal");
GameVersion version{"public", "", 1760000000, 9000, 900'000'000, 1'500'000'000, {}};
version.languages = {{"english", 900'000'000, 1'500'000'000}, {"russian", 1'000'000'000, 1'600'000'000}};
- model.UpdateAppDetails(SteamId(400), 900'000'000, 1'500'000'000, true, {"english", "russian"}, 0, {version});
+ model.UpdateAppDetails(SteamId(400), 900'000'000, 1'500'000'000, true, {"english", "russian"}, {}, {version});
check(model.action("details:400"), "details open");
activate(model, "details-install");
auto checks = model.TakeSizeChecks();
check(checks.size() == 1 && checks[0].id == SteamId(400) && checks[0].branch == "public" && checks[0].language == "english",
"the sheet asks for its choice's exact size");
- check(model.view().subtitle.find("Needs about 1.5 GB") != std::string::npos &&
+ check(fact(model, "Needs") == "About 1.5 GB" &&
model.view().subtitle.find("Checking its exact size") != std::string::npos &&
!find_row(model, "install-confirm")->enabled && find_row(model, "install-confirm")->subtitle == "Checking size",
"Steam's sum doesn't fit: the sheet waits for the exact size");
check(model.TakeSizeChecks().empty(), "asked once");
model.UpdateMeasuredSize(checks[0], true, false, {600'000'000, 400'000'000});
- check(model.view().subtitle.find("Needs 600 MB") != std::string::npos && find_row(model, "install-confirm")->enabled,
+ check(fact(model, "Needs") == "600 MB" && find_row(model, "install-confirm")->enabled,
"the exact size fits");
// Another language is another check; one that fails keeps Steam's sum and isn't asked again while the sheet is open.
activate(model, "install-language");
@@ -742,7 +1023,7 @@ void live_install_exact_size() {
checks = model.TakeSizeChecks();
check(checks.size() == 1 && checks[0].language == "russian", "Russian is checked too");
model.UpdateMeasuredSize(checks[0], false, true, {});
- check(model.view().subtitle.find("Needs about 1.6 GB") != std::string::npos &&
+ check(fact(model, "Needs") == "About 1.6 GB" &&
model.view().subtitle.find("Not enough space") != std::string::npos && !find_row(model, "install-confirm")->enabled,
"a failed check keeps Steam's sum");
check(model.TakeSizeChecks().empty(), "not asked again while the sheet is open");
@@ -761,13 +1042,13 @@ void live_install_exact_size() {
check(model.view().subtitle.find("Not enough space") != std::string::npos, "a choice with nothing to check keeps Steam's sum");
check(model.TakeSizeChecks().empty(), "answered: not asked again");
// New details (a newer build) forget the game's exact sizes: the sheet checks again.
- model.UpdateAppDetails(SteamId(400), 900'000'000, 1'500'000'000, true, {"english", "russian"}, 0, {version});
+ model.UpdateAppDetails(SteamId(400), 900'000'000, 1'500'000'000, true, {"english", "russian"}, {}, {version});
checks = model.TakeSizeChecks();
check(checks.size() == 1 && checks[0].language == "russian", "new details are checked again");
activate(model, "install-language");
activate(model, "install-language-english");
model.TakeSizeChecks();
- check(model.view().subtitle.find("Needs about 1.5 GB") != std::string::npos, "the old exact size is gone");
+ check(fact(model, "Needs") == "About 1.5 GB", "the old exact size is gone");
}
// A branch named in lower case shows as the picker shows it.
@@ -777,7 +1058,7 @@ void live_install_version_title() {
model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
check(model.UpdateLibrary({{game(SteamId(42), "Beta")}, false, {}, false, false, {}}), "library loaded");
model.UpdateVolumes({{"internal", "Console storage", true, 2'000'000'000, 1'000'000'000}}, "internal");
- model.UpdateAppDetails(SteamId(42), 100, 600, true, {}, 0,
+ model.UpdateAppDetails(SteamId(42), 100, 600, true, {}, {},
{GameVersion{"public", "", 1760000000, 9000, 100, 600}, GameVersion{"beta", "", 1750000000, 9001, 100, 600}});
check(model.action("details:42"), "details open");
activate(model, "details-install");
@@ -3975,7 +4256,7 @@ void live_game_update() {
check(model.action("details:42"), "details open");
check(!has_row(model, "details-update") && !has_row(model, "details-update-note"), "nothing to update, no button");
- model.UpdateAppDetails(SteamId(42), 100, 6'000'000'000, true, {}, 0, {}, GameUpdate{true, false, 1'200'000'000, 1'400'000'000, 1, true});
+ model.UpdateAppDetails(SteamId(42), 100, 6'000'000'000, true, {}, {}, {}, GameUpdate{true, false, 1'200'000'000, 1'400'000'000, 1, true});
const auto& rows = model.view().rows;
const auto play_at = std::find_if(rows.begin(), rows.end(), [](const auto& row) { return row.key == "details-play"; });
const auto update_at = std::find_if(rows.begin(), rows.end(), [](const auto& row) { return row.key == "details-update"; });
@@ -3999,7 +4280,7 @@ void live_game_update() {
check(model.view().surface != "update", "the sheet closes");
// DLC bought since wins the label, even when an update downloads with it.
- model.UpdateAppDetails(SteamId(42), 100, 6'000'000'000, true, {}, 0, {}, GameUpdate{true, true, 300'000'000, 300'000'000, 2, true});
+ model.UpdateAppDetails(SteamId(42), 100, 6'000'000'000, true, {}, {}, {}, GameUpdate{true, true, 300'000'000, 300'000'000, 2, true});
check(find_row(model, "details-update")->title == "DLC available…" &&
find_row(model, "details-update-note")->title == "DLC available" &&
find_row(model, "details-update-note")->value == "300 MB",
@@ -4077,6 +4358,9 @@ int main() {
live_install_exact_size();
live_install_version_title();
live_install_dlc_row();
+ live_install_optional_dlc();
+ details_ask_follows_licenses_and_install_state();
+ live_page_matches_install_sheet();
leftover_titles_require_confirmation_and_follow_the_queue();
live_download_server_picker();
live_import_sheet_sends_requests();
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index 91d9c1f..1477851 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -1517,8 +1517,8 @@ void live_update_check(const std::filesystem::path& base) {
model.UpdateCheckProgress(8, 2, 2);
check(check_state.asked == 8 && check_state.answered == 2 && check_state.total == 2, "update check: progress shows");
// Answers replace what was saved: Portal is up to date now, Stray has new DLC.
- model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, 0, {}, {});
- model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, 0, {}, GameUpdate{false, true, 70});
+ model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, {}, {}, {});
+ model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, {}, {}, GameUpdate{false, true, 70});
model.FinishUpdateCheck(false);
check(!check_state.checking && !check_state.failed && check_state.checked_at == kNow + 2 * 60 * 60 &&
check_state.games.size() == 1 && check_state.games.at(SteamId(20)).new_dlc,
@@ -1541,7 +1541,7 @@ void live_update_check(const std::filesystem::path& base) {
check(!model.TakeUpdateCheckRequest(), "update check: the last full check is still recent");
// A finished update and an uninstall take games off the list.
- model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, 0, {}, GameUpdate{true, false, 5});
+ model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, {}, {}, GameUpdate{true, false, 5});
check(check_state.games.size() == 2, "update check: a game's page refreshes its entry");
playden::homebrew::LiveInstallJob job;
job.game_id = SteamId(10);
@@ -1662,17 +1662,17 @@ void live_manage_games_tabs(const std::filesystem::path& base) {
find_row(model, "manage-check")->title == "Checking…" && find_row(model, "manage-more"),
"manage: a running check shows its progress");
check(navigation.focus_key == "manage-sort", "manage: the focus leaves the button the check turned off");
- model.UpdateAppDetails(SteamId(30), 1, 1, true, {}, 0, {}, GameUpdate{true, false, 500'000'000});
+ model.UpdateAppDetails(SteamId(30), 1, 1, true, {}, {}, {}, GameUpdate{true, false, 500'000'000});
check(find_row(model, "manage-toggle-30") && find_row(model, "manage-toggle-30")->selected,
"manage: a game found while checking shows up checked");
check(navigation.focus_key == "manage-sort", "manage: a game found meanwhile doesn't take the focus");
- model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, 0, {}, {});
- model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, 0, {}, {});
+ model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, {}, {}, {});
+ model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, {}, {}, {});
model.FinishUpdateCheck(false);
check(!find_row(model, "manage-toggle-10") && find_row(model, "manage-toggle-30") &&
model.view().subtitle == "Checked just now · only games with an update or new DLC",
"manage: games without an update leave the list");
- model.UpdateAppDetails(SteamId(30), 1, 1, true, {}, 0, {}, {});
+ model.UpdateAppDetails(SteamId(30), 1, 1, true, {}, {}, {}, {});
const auto* empty = find_row(model, "manage-empty");
check(empty && empty->title == "Up to date" && navigation.focus_key == "manage-sort", "manage: nothing to update says so");
activate(model, "manage-check");
@@ -1878,8 +1878,8 @@ void live_settings_manage_rows(const std::filesystem::path& base) {
check(value("settings-game-updates") == "Checking 24 of 40…", "settings rows: checking with progress");
// Found: two updates, their sizes not measured yet.
- model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, 0, {}, playden::homebrew::GameUpdate{true, false, 0, 0, 11});
- model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, 0, {}, playden::homebrew::GameUpdate{false, true, 0, 0, 21});
+ model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, {}, {}, playden::homebrew::GameUpdate{true, false, 0, 0, 11});
+ model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, {}, {}, playden::homebrew::GameUpdate{false, true, 0, 0, 21});
model.FinishUpdateCheck(false);
check(value("settings-game-updates") == "2 updates" && subtitle("settings-game-updates") == "Checked just now",
"settings rows: updates found");
@@ -1893,8 +1893,8 @@ void live_settings_manage_rows(const std::filesystem::path& base) {
check(value("settings-game-updates") == "2 updates" && model.TakeUpdateSizeChecks().empty(),
"settings rows: a size for another update isn't used or asked again");
// Steam answers for the game again (the same update): its size is asked again, and a size stays with its update.
- model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, 0, {}, playden::homebrew::GameUpdate{false, true, 0, 0, 21});
- model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, 0, {}, playden::homebrew::GameUpdate{true, false, 0, 0, 11});
+ model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, {}, {}, playden::homebrew::GameUpdate{false, true, 0, 0, 21});
+ model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, {}, {}, playden::homebrew::GameUpdate{true, false, 0, 0, 11});
sizes = model.TakeUpdateSizeChecks();
check(sizes == std::vector<playden::GameId>{SteamId(20)}, "settings rows: Steam's answer asks an unmeasured size again");
model.UpdateMeasuredUpdate(SteamId(20), true, 21, 200'000'000, 200'000'000);
@@ -1924,14 +1924,14 @@ void live_settings_manage_rows(const std::filesystem::path& base) {
// Nothing new: Up to date, and Storage shows no update part.
model.action("update-check");
check(model.TakeUpdateCheckRequest(), "settings rows: checked again");
- model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, 0, {}, {});
- model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, 0, {}, {});
+ model.UpdateAppDetails(SteamId(10), 1, 1, true, {}, {}, {}, {});
+ model.UpdateAppDetails(SteamId(20), 1, 1, true, {}, {}, {}, {});
model.FinishUpdateCheck(false);
check(value("settings-game-updates") == "Up to date" && value("settings-installed") == "3 games · 60.0 GB",
"settings rows: up to date");
// One update is singular.
- model.UpdateAppDetails(SteamId(30), 1, 1, true, {}, 0, {}, playden::homebrew::GameUpdate{true, false, 48'000'000, 48'000'000, 5, true});
+ model.UpdateAppDetails(SteamId(30), 1, 1, true, {}, {}, {}, playden::homebrew::GameUpdate{true, false, 48'000'000, 48'000'000, 5, true});
check(value("settings-game-updates") == "1 update · 48 MB" && value("settings-installed") == "3 games · 60.0 GB · 1 update",
"settings rows: one update");
}
diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cpp
index 156a34b..ee85539 100644
--- a/tests/homebrew_simulation_test.cpp
+++ b/tests/homebrew_simulation_test.cpp
@@ -743,8 +743,13 @@ void game_update_scenarios(const std::filesystem::path& fixtures, const std::fil
check(simulation.scenario("dlc-available") && row("details-update")->title == "DLC available…",
"dlc-available says DLC available");
check(simulation.scenario("install-options") && simulation.view().surface == "install" && row("install-version") &&
- row("install-language") && row("install-dlc") && row("install-dlc")->value == "2 DLC",
- "install-options shows Version, Language and Includes");
+ row("install-language") && row("install-dlc") && row("install-dlc")->value == "2 of 2 · 4.3 GB",
+ "install-options shows Version, Language and DLC");
+ check(simulation.action("focus:install-dlc") && simulation.action("cross") && simulation.view().surface == "install-dlc" &&
+ row("install-dlc-900102") && row("install-dlc-900102")->title == "Texture Pack" &&
+ row("install-dlc-900102")->value == "Free · 4.2 GB",
+ "the DLC row opens the list");
+ check(simulation.action("circle") && simulation.view().surface == "install", "Back returns to the sheet");
check(simulation.scenario("updating") && simulation.state().navigation.route == playden::homebrew::Route::Downloads,
"updating opens the queue");
check(simulation.action("details:900001") && row("details-play") && !row("details-play")->enabled &&
diff --git a/tests/steam_app_info_test.cpp b/tests/steam_app_info_test.cpp
index 4c0f36e..3b91bd7 100644
--- a/tests/steam_app_info_test.cpp
+++ b/tests/steam_app_info_test.cpp
@@ -972,6 +972,25 @@ void TestDlcChoice() {
};
CHECK(reason(5012) == "dlc-off" && reason(5013) == "dlc-off" && reason(5011) == "licence");
+ // Optional when every depot of the DLC is marked so; a DLC with an unmarked depot downloads by itself.
+ const auto marked = ParseAppInfo(5100, R"("appinfo"
+{
+ "common" { "name" "Marked" "type" "Game" }
+ "extended" { "listofdlc" "5101,5102,5103" }
+ "depots"
+ {
+ "5100" { "manifests" { "public" { "gid" "1" "size" "10" "download" "5" } } }
+ "5111" { "dlcappid" "5101" "config" { "optionaldlc" "5101" } "manifests" { "public" { "gid" "2" "size" "10" "download" "5" } } }
+ "5112" { "dlcappid" "5102" "config" { "optionaldlc" "5102" } "manifests" { "public" { "gid" "3" "size" "10" "download" "5" } } }
+ "5113" { "dlcappid" "5102" "manifests" { "public" { "gid" "4" "size" "10" "download" "5" } } }
+ "5114" { "dlcappid" "5103" "manifests" { "public" { "gid" "5" "size" "10" "download" "5" } } }
+ }
+})");
+ CHECK(marked.has_value());
+ const auto marked_offers = OfferedDlc(*marked, {}, {5100, 5101, 5102, 5103}, std::nullopt, DepotSelection{});
+ CHECK(marked_offers.size() == 3);
+ for (const auto& offer : marked_offers) CHECK(offer.optional == (offer.app_id == 5101));
+
// A name that only starts like the game's stays whole.
const auto similar = dlc(5002, R"("common" { "name" "Big Gamers Pack" "type" "DLC" })");
offers = OfferedDlc(*game, {similar}, owned, depots, DepotSelection{});