Skip to content

Commit b66f3df

Browse files
Bugfix/suppress store popups (#244)
* feat: suppress ad, store offer, login streak, and tutorial popups Broaden the existing disable_first_popup from a single first-only interstitial to suppress all ad/interstitial popups via InterstitialViewController.AboutToShow. Add hooks for store pack offer popups (ShopSceneManager.ShowPlcOfferPopup), login streak popups (LoginStreakManager.TryShowStreakPopupForGameSessionStarted), and tutorial/hint popups (TutorialManager.ShowTutorialScreen, both no-arg and 2-arg overloads) behind a new disable_tutorials config setting. Both settings default to false and are documented in all four localized example config files (en, de, fr, nl). * refactor: remove experimental tutorial skipping * fix: suppress interstitial popups by skipping AboutToShow instead of calling CloseWhenReady * fix: call original AboutToShow before closing to avoid empty screen * feat: change to only_show_first_popup config --------- Co-authored-by: netniV <netniv@hotmail.com>
1 parent ef4f434 commit b66f3df

5 files changed

Lines changed: 41 additions & 10 deletions

File tree

‎example_community_patch_settings_en.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,9 @@ auto_open_bulk_claim_flyout = false
685685
# Prevent "escape" from prompting to exit the game
686686
disable_escape_exit = true
687687

688+
# ⚠️ EXPERIMENTAL: Show only the first ad/interstitial popup after the game starts, then suppress the rest
689+
only_show_first_popup = false
690+
688691
# Maximum gap in milliseconds between Escape presses that opens the exit prompt; 0 disables double-tap exit
689692
disable_escape_exit_timer = 0
690693

‎mods/src/config.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,8 +1100,8 @@ void Config::Load()
11001100
get_config_or_default(config, parsed, "ui", "disable_preview_locate", DCU::disable_preview_locate, write_config);
11011101
this->disable_preview_recall =
11021102
get_config_or_default(config, parsed, "ui", "disable_preview_recall", DCU::disable_preview_recall, write_config);
1103-
this->disable_first_popup =
1104-
get_config_or_default(config, parsed, "ui", "disable_first_popup", DCU::disable_first_popup, write_config);
1103+
this->only_show_first_popup = get_config_or_default(config, parsed, "ui", "only_show_first_popup",
1104+
DCU::only_show_first_popup, write_config);
11051105
this->disable_move_keys =
11061106
get_config_or_default(config, parsed, "ui", "disable_move_keys", DCU::disable_move_keys, write_config);
11071107
this->disable_toast_banners =

‎mods/src/config.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ class Config final
253253
bool reverse_haven_history;
254254
bool arrow_keys_to_select_ship;
255255

256+
bool only_show_first_popup;
257+
256258
bool show_cargo_default;
257259
bool show_player_cargo;
258260
bool show_station_cargo;

‎mods/src/defaultconfig.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ namespace UI
259259
constexpr bool auto_open_bulk_claim_flyout = false;
260260
constexpr const char* daily_bulk_claim_factions = "";
261261
constexpr bool daily_bulk_claim_toggle_default_on = false;
262+
constexpr bool only_show_first_popup = false;
262263
constexpr bool disable_escape_exit = true;
263264
// Maximum gap between Escape presses that opens the exit prompt.
264265
// 0 disables double-tap and preserves the existing blocked behavior.

‎mods/src/patches/parts/misc.cc‎

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#endif
1919

2020
#include <algorithm>
21+
#include <atomic>
2122
#include <prime/ActionQueueManager.h>
2223
#include <prime/InterstitialViewController.h>
2324

@@ -249,19 +250,36 @@ class ShopSectionContext
249250
}
250251
};
251252

252-
bool isFirstInterstitial = true;
253+
static std::atomic_bool g_first_popup_shown{false};
254+
255+
bool ShouldSuppressAdditionalPopup()
256+
{
257+
bool expected = false;
258+
return !g_first_popup_shown.compare_exchange_strong(expected, true);
259+
}
253260

254261
void InterstitialViewController_AboutToShow(auto original, InterstitialViewController* _this)
255262
{
256-
if (false /* TEMP: disable_first_popup effect disabled */ && Config::Get().disable_first_popup
257-
&& isFirstInterstitial && _this != nullptr) {
258-
isFirstInterstitial = false;
259-
_this->CloseWhenReady();
260-
} else {
261-
original(_this);
263+
original(_this);
264+
if (Config::Get().only_show_first_popup && _this != nullptr) {
265+
if (ShouldSuppressAdditionalPopup()) {
266+
spdlog::debug("InterstitialViewController_AboutToShow: suppressing interstitial popup (already shown one)");
267+
_this->CloseWhenReady();
268+
} else {
269+
spdlog::debug("InterstitialViewController_AboutToShow: allowing first popup of the session to show");
270+
}
262271
}
263272
}
264273

274+
void ShopSceneManager_ShowPlcOfferPopup(auto original, void* _this)
275+
{
276+
if (Config::Get().only_show_first_popup && ShouldSuppressAdditionalPopup()) {
277+
spdlog::debug("ShopSceneManager_ShowPlcOfferPopup: suppressing PLC offer popup (already shown one)");
278+
return;
279+
}
280+
original(_this);
281+
}
282+
265283
void ActionQueueManager_AddActionToQueue(auto original, ActionQueueManager* _this, long fleet_id)
266284
{
267285
spdlog::warn("ActionQueueManager_AddActionToQueue({})", fleet_id);
@@ -285,7 +303,7 @@ void InstallTempCrashFixes()
285303
}
286304
}
287305

288-
auto shop_scene_manager = il2cpp_get_class_helper("Assembly-CSharp", "Digit.Prime.Shop", "ShopSceneManager");
306+
static auto shop_scene_manager = il2cpp_get_class_helper("Assembly-CSharp", "Digit.Prime.Shop", "ShopSceneManager");
289307
if (!shop_scene_manager.isValidHelper()) {
290308
ErrorMsg::MissingHelper("Shop", "ShopSceneManager");
291309
} else {
@@ -295,6 +313,13 @@ void InstallTempCrashFixes()
295313
} else {
296314
SPUD_STATIC_DETOUR(reveal_show, ShouldShowRevealHook);
297315
}
316+
317+
auto show_plc = shop_scene_manager.GetMethod("ShowPlcOfferPopup", 0);
318+
if (!show_plc) {
319+
ErrorMsg::MissingMethod("ShopSceneManager", "ShowPlcOfferPopup");
320+
} else {
321+
SPUD_STATIC_DETOUR(show_plc, ShopSceneManager_ShowPlcOfferPopup);
322+
}
298323
}
299324

300325
static auto interstitial_controller =

0 commit comments

Comments
 (0)