Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

feat(ui): relocate playtime remaining under logo and hide from active UI

Rafael Abud Ferreiraca5b2e794d4d
diff --git a/src/app/worker.cpp b/src/app/worker.cpp
index 01df2b9..88f566c 100644
--- a/src/app/worker.cpp
+++ b/src/app/worker.cpp
@@ -60,6 +60,9 @@ bool g_gameClosedOnServer = false;
std::map<std::string, std::string> g_regionFallback;
std::shared_ptr<app::Library> s_library;
std::mutex s_libraryMutex;
+// Cloud playtime telemetry in seconds (-1 unknown/uncapped).
+// STRICTLY INFORMATIVE: The client never blocks gameplay, streams, or launches
+// based on playtime telemetry, as Microsoft does not enforce client-side blocking.
int64_t s_playtimeRemainingSeconds = -1;
} // namespace
diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cpp
index 1b711d2..0d90d7a 100644
--- a/src/ui/app_ui.cpp
+++ b/src/ui/app_ui.cpp
@@ -2725,6 +2725,18 @@ void AppUi::drawGamerscoreBadge(Canvas& c, float cx, float cy, float r) {
void AppUi::drawTopBar(Canvas& c) {
drawLogo(c, kMargin + 22, 72, 22);
fonts_.semibold.draw(c, tr(Str::CloudGaming), kMargin + 64, 60, 22, kWhite);
+
+ // Cloud playtime remaining badge positioned under the "PSBox Cloud Gaming" brand mark.
+ // Purely informative; hidden from the active UI for now until Xbox Cloud Gaming enforces limits.
+ constexpr bool kShowPlaytimeBadge = false;
+ if (kShowPlaytimeBadge && playtimeRemaining_ >= 0) {
+ int hours = static_cast<int>((playtimeRemaining_ + 3599) / 3600);
+ std::string pt = trf(Str::HoursRemaining, std::to_string(hours));
+ bool warn = playtimeRemaining_ <= 7200;
+ Color col = warn ? rgba(255, 160, 40) : kGray;
+ fonts_.semibold.draw(c, pt, kMargin + 64, 86, 14, col);
+ }
+
int x = kW - kMargin;
constexpr int kAvatar = 52;
x -= kAvatar;
@@ -2774,16 +2786,6 @@ void AppUi::drawTopBar(Canvas& c) {
drawGamerscoreBadge(c, nx - 13.0f, midY, 8.5f);
right = nx - 26;
}
- if (playtimeRemaining_ >= 0) {
- int hours = static_cast<int>((playtimeRemaining_ + 3599) / 3600);
- std::string pt = trf(Str::HoursRemaining, std::to_string(hours));
- int pw = fonts_.semibold.measure(pt, kLinePx);
- int px = right - pw;
- bool warn = playtimeRemaining_ <= 7200;
- Color col = warn ? rgba(255, 160, 40) : kGray;
- fonts_.semibold.draw(c, pt, px, fonts_.semibold.centeredY(kLineY, kLineH, kLinePx), kLinePx, col);
- right = px - 16;
- }
}
}
diff --git a/src/ui/app_ui.h b/src/ui/app_ui.h
index ffc2ce5..7ef22ac 100644
--- a/src/ui/app_ui.h
+++ b/src/ui/app_ui.h
@@ -258,7 +258,8 @@ public:
void setSearchPools(std::vector<GameTile> gamePass, std::vector<GameTile> library);
// Measured round trip to each region, ms (shown in Settings).
void setRegionLatency(std::map<std::string, int> ms);
- // Cloud playtime limit telemetry (remaining and max in seconds, -1 unknown)
+ // Cloud playtime limit telemetry (remaining and max in seconds, -1 unknown).
+ // Purely informative; never blocks launch or gameplay.
void setPlaytime(int64_t remainingSeconds, int64_t maxSeconds);
// Store prices, formatted: productId -> {now, regular (empty unless on sale)}.
void setPrices(const std::map<std::string, PriceInfo>& prices);
diff --git a/src/ui/stream_menu.cpp b/src/ui/stream_menu.cpp
index d1c6e3f..4a6372e 100644
--- a/src/ui/stream_menu.cpp
+++ b/src/ui/stream_menu.cpp
@@ -276,7 +276,11 @@ Canvas StreamMenu::renderMenu(const StreamInfo& info) const {
line(Str::StatLoss, fmt("%.1f %%", info.lossPct));
line(Str::StatDecode, info.decodeMs > 0 ? fmt("%.1f ms", info.decodeMs) : none);
line(Str::StatOnScreen, info.onScreenMs > 0 ? fmt("%.1f ms", info.onScreenMs) : none);
- if (info.playtimeHours >= 0) line(Str::PlaytimeRemaining, trf(Str::HoursRemaining, std::to_string(info.playtimeHours)));
+ // Cloud playtime is purely informative and hidden from the UI for now.
+ constexpr bool kShowPlaytimeInMenu = false;
+ if (kShowPlaytimeInMenu && info.playtimeHours >= 0) {
+ line(Str::PlaytimeRemaining, trf(Str::HoursRemaining, std::to_string(info.playtimeHours)));
+ }
// The controllers: numbered pads, each connected one with its user.
y += 8;
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index 9ce5661..426bd98 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -442,6 +442,32 @@ static void testPlaytimeLimit() {
// 5. Empty and invalid inputs
CHECK(!auth::parsePlaytimeLimit("", rem, max));
CHECK(!auth::parsePlaytimeLimit("not a valid payload", rem, max));
+
+ // 6. Zero playtime remains purely informational
+ std::string zeroJson = R"({"remainingGameplayTimeInSeconds": 0, "maxGameplayTimeInSeconds": 18000})";
+ CHECK(auth::parsePlaytimeLimit(zeroJson, rem, max));
+ CHECK(rem == 0 && max == 18000);
+
+ // 7. Client-side launch is never blocked by zero or low remaining playtime
+ ui::Fonts fonts;
+ ui::ImageCache images([] {});
+ ui::AppUi app(fonts, images);
+ ui::GameTile tile;
+ tile.titleId = "TEST_TITLE_1";
+ tile.productId = "TEST_PROD_1";
+ tile.playable = true;
+ ui::GameRow row;
+ row.title = "Popular";
+ row.tiles = {tile};
+ app.setRows({row});
+ app.setPlaytime(0, 18000); // 0 seconds remaining
+ app.showHome();
+ ui::NavInput in;
+ in.accept = true;
+ app.handle(in); // Home -> Details
+ ui::UiEvent ev = app.handle(in); // Details -> Play
+ CHECK(ev.action == ui::Action::Play);
+ CHECK(ev.game.titleId == "TEST_TITLE_1");
}
static void testStreamMenu() {