Skip to content

Commit

Permalink
Fix plugin crash if loaded on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanawy committed Oct 2, 2024
1 parent 1e67636 commit 4537980
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "Run History"
author = "Vanawy"
category = "Overlay"
version = "0.6.1"
version = "0.6.2"

[script]
dependencies = ["MLHook", "MLFeedRaceData"]
Expand Down
22 changes: 13 additions & 9 deletions src/main.as
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ bool autoChangeTarget = true;

uint championMedalUpdateAttempts = 0;

CTrackMania@ trackmania = cast<CTrackMania>(GetApp());
bool isWindowVisible = false;

void Main()
{

string lastMapId = "";
string lastGhostId = "";

print("App loaded");
CTrackMania@ trackmania = cast<CTrackMania>(GetApp());

// init delta thresholds table
thresholdsTable.FromString(settingDeltasSerialized);
Expand Down Expand Up @@ -86,17 +85,22 @@ void Main()
}

auto map = @trackmania.RootMap;
if (map !is null && lastMapId != map.MapInfo.MapUid) {
lastMapId = map.MapInfo.MapUid;
OnMapChange(map);
isWindowVisible = false;
if (map !is null) {
isWindowVisible = map.MapInfo.MapUid != "";
if (trackmania.Editor !is null) {
isWindowVisible = false;
}
if (lastMapId != map.MapInfo.MapUid) {
lastMapId = map.MapInfo.MapUid;
OnMapChange(map);
}
}
}
}

void Render()
{
auto map = trackmania.RootMap;

if(!UI::IsGameUIVisible()) {
return;
}
Expand All @@ -109,7 +113,7 @@ void Render()
return;
}

if(map !is null && map.MapInfo.MapUid != "" && trackmania.Editor is null) {
if(isWindowVisible) {
if(settingWindowLockPosition) {
UI::SetNextWindowPos(int(settingWindowAnchor.x), int(settingWindowAnchor.y), UI::Cond::Always);
} else {
Expand Down

0 comments on commit 4537980

Please sign in to comment.