Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions example_community_patch_settings_en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ auto_open_bulk_claim_flyout = false
# Prevent "escape" from prompting to exit the game
disable_escape_exit = true

# ⚠️ EXPERIMENTAL: Show only the first ad/interstitial popup after the game starts, then suppress the rest
only_show_first_popup = false

# Maximum gap in milliseconds between Escape presses that opens the exit prompt; 0 disables double-tap exit
disable_escape_exit_timer = 0

Expand Down
4 changes: 2 additions & 2 deletions mods/src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,8 @@ void Config::Load()
get_config_or_default(config, parsed, "ui", "disable_preview_locate", DCU::disable_preview_locate, write_config);
this->disable_preview_recall =
get_config_or_default(config, parsed, "ui", "disable_preview_recall", DCU::disable_preview_recall, write_config);
this->disable_first_popup =
get_config_or_default(config, parsed, "ui", "disable_first_popup", DCU::disable_first_popup, write_config);
this->only_show_first_popup = get_config_or_default(config, parsed, "ui", "only_show_first_popup",
DCU::only_show_first_popup, write_config);
this->disable_move_keys =
get_config_or_default(config, parsed, "ui", "disable_move_keys", DCU::disable_move_keys, write_config);
this->disable_toast_banners =
Expand Down
2 changes: 2 additions & 0 deletions mods/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ class Config final
bool reverse_haven_history;
bool arrow_keys_to_select_ship;

bool only_show_first_popup;

bool show_cargo_default;
bool show_player_cargo;
bool show_station_cargo;
Expand Down
1 change: 1 addition & 0 deletions mods/src/defaultconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ namespace UI
constexpr bool auto_open_bulk_claim_flyout = false;
constexpr const char* daily_bulk_claim_factions = "";
constexpr bool daily_bulk_claim_toggle_default_on = false;
constexpr bool only_show_first_popup = false;
constexpr bool disable_escape_exit = true;
// Maximum gap between Escape presses that opens the exit prompt.
// 0 disables double-tap and preserves the existing blocked behavior.
Expand Down
41 changes: 33 additions & 8 deletions mods/src/patches/parts/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#endif

#include <algorithm>
#include <atomic>
#include <prime/ActionQueueManager.h>
#include <prime/InterstitialViewController.h>

Expand Down Expand Up @@ -249,19 +250,36 @@ class ShopSectionContext
}
};

bool isFirstInterstitial = true;
static std::atomic_bool g_first_popup_shown{false};

bool ShouldSuppressAdditionalPopup()
{
bool expected = false;
return !g_first_popup_shown.compare_exchange_strong(expected, true);
}

void InterstitialViewController_AboutToShow(auto original, InterstitialViewController* _this)
{
if (false /* TEMP: disable_first_popup effect disabled */ && Config::Get().disable_first_popup
&& isFirstInterstitial && _this != nullptr) {
isFirstInterstitial = false;
_this->CloseWhenReady();
} else {
original(_this);
original(_this);
if (Config::Get().only_show_first_popup && _this != nullptr) {
if (ShouldSuppressAdditionalPopup()) {
spdlog::debug("InterstitialViewController_AboutToShow: suppressing interstitial popup (already shown one)");
_this->CloseWhenReady();
} else {
spdlog::debug("InterstitialViewController_AboutToShow: allowing first popup of the session to show");
}
}
}

void ShopSceneManager_ShowPlcOfferPopup(auto original, void* _this)
{
if (Config::Get().only_show_first_popup && ShouldSuppressAdditionalPopup()) {
spdlog::debug("ShopSceneManager_ShowPlcOfferPopup: suppressing PLC offer popup (already shown one)");
return;
}
original(_this);
}

void ActionQueueManager_AddActionToQueue(auto original, ActionQueueManager* _this, long fleet_id)
{
spdlog::warn("ActionQueueManager_AddActionToQueue({})", fleet_id);
Expand All @@ -285,7 +303,7 @@ void InstallTempCrashFixes()
}
}

auto shop_scene_manager = il2cpp_get_class_helper("Assembly-CSharp", "Digit.Prime.Shop", "ShopSceneManager");
static auto shop_scene_manager = il2cpp_get_class_helper("Assembly-CSharp", "Digit.Prime.Shop", "ShopSceneManager");
if (!shop_scene_manager.isValidHelper()) {
ErrorMsg::MissingHelper("Shop", "ShopSceneManager");
} else {
Expand All @@ -295,6 +313,13 @@ void InstallTempCrashFixes()
} else {
SPUD_STATIC_DETOUR(reveal_show, ShouldShowRevealHook);
}

auto show_plc = shop_scene_manager.GetMethod("ShowPlcOfferPopup", 0);
if (!show_plc) {
ErrorMsg::MissingMethod("ShopSceneManager", "ShowPlcOfferPopup");
} else {
SPUD_STATIC_DETOUR(show_plc, ShopSceneManager_ShowPlcOfferPopup);
}
}

static auto interstitial_controller =
Expand Down
Loading