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
1 change: 1 addition & 0 deletions docs/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Features depend on the game client. A client update can break a hook until the m
| Haven | Extend camera range while keeping road surfaces above the ground. `graphics.haven_zoom = 0.0` uses the native range. |
| Fleet labels | Choose native, expanded, compact, or zoom-threshold detail separately for player and non-player fleets. |
| Window and cursor | Resize the game window freely on Windows and control whether the game replaces the system cursor. |
| Mirror space timer | Show the earliest remaining ship countdown in the viewed Mirror system, below Help All, Engage and Claim. Enable `mirror_space_timer` in `[graphics]`. Disabled by default. |
| Anomaly timer | Show the remaining time in a Galactic Anomaly system. Disabled by default. |

`fr_scale` scales system-view backdrop renderables.
Expand Down
4 changes: 4 additions & 0 deletions docs/configuration/example_community_patch_settings_en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ free_resize = true
# Show the remaining Galactic Anomaly time below Help All, Engage, and Claim
galactic_anomaly_timer = false

# Show the earliest Mirror space ship countdown in the viewed system in the same HUD panel.
# Both HUD timers use [patches] galacticanomalytimerhooks.
mirror_space_timer = false

# After using a zoom preset it will be set as default zoom
use_presets_as_default = true

Expand Down
1 change: 1 addition & 0 deletions src/mod/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ void Config::Read(const toml::table& file, toml::table& effective, bool log_valu
r.Read("graphics", "loader_logo_scale", g.loader_logo_scale);
r.Read("graphics", "loader_tip_enabled", g.loader_tip_enabled);
r.Read("graphics", "galactic_anomaly_timer", g.galactic_anomaly_timer);
r.Read("graphics", "mirror_space_timer", g.mirror_space_timer);

// [buffs]
r.Read("buffs", "use_out_of_dock_power", buffs.use_out_of_dock_power);
Expand Down
1 change: 1 addition & 0 deletions src/mod/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class Config final
float loader_logo_scale = 1.0f;
bool loader_tip_enabled = true;
bool galactic_anomaly_timer = false;
bool mirror_space_timer = false;
} graphics;

struct Buffs {
Expand Down
42 changes: 36 additions & 6 deletions src/mod/features/anomaly_timer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// [graphics] galactic_anomaly_timer: a countdown for the active galactic anomaly in the viewed system, under the HUD's
// Help All / Engage / Claim drawer. All Unity work runs on the frame tick; there are no detours of its own.
// Help All / Engage / Claim drawer. [graphics] mirror_space_timer shows the earliest fleet countdown in the viewed
// Mirror system in the same panel. All Unity work runs on the frame tick; there are no detours of its own.

#include "config.h"
#include "features/features.h"
Expand Down Expand Up @@ -68,6 +69,32 @@ int64_t AnomalyRemainingTicks(HudNavigationViewController* nav)
return timer ? timer->RemainingTime().ticks : 0;
}

int64_t MirrorRemainingTicks(HudNavigationViewController* nav)
{
auto* context = nav->CanvasContext();
auto* address = context ? context->ViewingAddress() : nullptr;
auto* bar = unity::Newest<FleetBarViewController>();
auto* fleets = bar ? bar->CanvasContext() : nullptr;
if (!address || !fleets)
return 0;

int64_t remaining = 0;
for (auto* fleet : il2cpp::Items(fleets->FleetData())) {
if (!fleet || !fleet->IsInMirrorUniverse())
continue;
auto* location = fleet->Address();
StatusEffect* effect = nullptr;
if (!location || location->System() != address->System()
|| !fleet->TryGetStatusEffectData(StatusEffectType::MirrorUniverseTimer, effect) || !effect
|| !effect->IsStatusActive())
continue;
const int64_t ticks = effect->GetRemainingTimespan().ticks;
if (ticks > 0 && (remaining == 0 || ticks < remaining))
remaining = ticks;
}
return remaining;
}

// Builds the panel: the native rounded sprite twice, with a narrow inset making the border, and a countdown in the
// system-name font. A missing sprite still gives a visible frame. Null while the drawer or the HUD's font is not up
// yet; the next tick tries again.
Expand Down Expand Up @@ -128,11 +155,14 @@ void AnomalyTimerFrame()
return;

// View only returns a HUD that is up on a visible canvas, so nothing about it needs holding between ticks.
auto* nav = Config::Get().graphics.galactic_anomaly_timer && Hub::CurrentSection() == SectionID::Navigation_System
? ScreenManager::View<HudNavigationViewController>()
: nullptr;
const int64_t ticks = nav && nav->CanShowGalacticAnomaly() ? AnomalyRemainingTicks(nav) : 0;
auto* label = anomaly_label.Get<unity::TMP_Text>();
auto* nav = (Config::Get().graphics.galactic_anomaly_timer || Config::Get().graphics.mirror_space_timer)
&& Hub::CurrentSection() == SectionID::Navigation_System
? ScreenManager::View<HudNavigationViewController>()
: nullptr;
int64_t ticks = nav && Config::Get().graphics.mirror_space_timer ? MirrorRemainingTicks(nav) : 0;
if (ticks <= 0 && nav && Config::Get().graphics.galactic_anomaly_timer && nav->CanShowGalacticAnomaly())
ticks = AnomalyRemainingTicks(nav);
auto* label = anomaly_label.Get<unity::TMP_Text>();
if (!unity::Alive(label))
label = nullptr;
if (ticks <= 0) {
Expand Down
54 changes: 54 additions & 0 deletions src/mod/game/fleet.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,63 @@ struct ForbiddenTechManager : MonoSingleton<ForbiddenTechManager> {
}
};

// Client status effects, including the per-fleet Mirror space countdown.
enum class StatusEffectType : int32_t {
Invalid = 0,
Cloaked = 1,
Supported = 2,
Debuffed = 3,
WarShieldActivated = 4,
ArmadaSupported = 5,
WeaponDamageActivated = 6,
WeaponPenetrationActivated = 7,
WeaponShotsActivated = 8,
CriticalDamageActivated = 9,
Detected = 10,
SystemWideBuffed = 11,
SystemWideSupremeBuffed = 12,
IsoDamageBoosted = 14,
DamageToExplorersBoosted = 15,
DamageToBattleshipsBoosted = 16,
DamageToInterceptorsBoosted = 17,
CuttingBeamHit = 18,
SystemPeek = 19,
WormholeInstaRecallAvailable = 20,
MirrorUniverseTimer = 21,
Indestructible = 22,
PostWormholeBuff = 70001,
TauntAsaActivated = 71001,
Static = 75001,
Charged = 75002,
Weakened = 77001,
ChainShotImmunityActivated = 78001,
AutoHuntingActivated = 83001,
Enhanced = 86001,
BorgProtocolActivated = 89001,
Amplified = 91001,
TempAutoHuntingActivated = 96001,
NoEffect = -1,
};

struct StatusEffect : il2cpp::Object {
using Class = il2cpp::Class<"Digit.Client.PrimeLib.Runtime", "Digit.PrimeServer.Models", "StatusEffect">;

bool IsStatusActive()
{ return Get<"IsStatusActive", bool>(); }
unity::TimeSpan GetRemainingTimespan()
{ return Call<"GetRemainingTimespan", unity::TimeSpan>(); }
};

struct FleetPlayerData : il2cpp::Object {
using Class = il2cpp::Class<"Digit.Client.PrimeLib.Runtime", "Digit.PrimeServer.Models", "FleetPlayerData">;

bool IsInMirrorUniverse()
{ return Get<"IsInMirrorUniverse", bool>(); }
NodeAddress* Address()
{ return Get<"Address", NodeAddress*>(); }
bool TryGetStatusEffectData(StatusEffectType type, StatusEffect*& effect)
{ return Call<"TryGetStatusEffectData", bool(StatusEffectType, StatusEffect*&)>(type, effect); }

// No property for the mining timer, so read the private field.
ITimerData* miningSlotTimer()
{ return Field<"_miningSlotTimer", ITimerData*>(); }
Expand Down
Loading