Skip to content

Commit

Permalink
Fix stale reference issue and clean stuff up
Browse files Browse the repository at this point in the history
  • Loading branch information
DarwinBaker committed Mar 5, 2022
1 parent e20185e commit b8fe612
Show file tree
Hide file tree
Showing 25 changed files with 95 additions and 418 deletions.
4 changes: 2 additions & 2 deletions AATool/Configuration/ConfigStatic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public static void Save(Config config)
Formatting = Newtonsoft.Json.Formatting.Indented
}.Deserialize(stream, typeof(T));

if (config is null)
throw new InvalidDataException();
//if (config is null)
// throw new InvalidDataException();
}
}
catch (Exception e)
Expand Down
4 changes: 4 additions & 0 deletions AATool/Configuration/MainConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ public class MainConfig : Config
[JsonProperty] public readonly Setting<Color> TextColor = new (Hex("DCDDDE"));
[JsonProperty] public readonly Setting<Color> BorderColor = new (Hex("4E5156"));

[JsonIgnore]
public bool RelaxedMode => !this.CompactMode;

[JsonIgnore]
public string ViewMode => this.CompactMode ? "compact" : "relaxed";

[JsonIgnore]
public bool StyleChanged => this.FrameStyle.Changed
|| this.BorderColor.Changed
|| this.BackColor.Changed
Expand Down
101 changes: 0 additions & 101 deletions AATool/Configuration/MainConfig.cs.bak

This file was deleted.

6 changes: 4 additions & 2 deletions AATool/Configuration/TrackingConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class TrackingConfig : Config
[JsonProperty] public readonly Setting<string> LastSession = new (string.Empty);

[JsonProperty] public readonly Setting<string> GameCategory = new ("All Advancements");
[JsonProperty] public readonly Setting<string> GameVersion = new ("1.16");
[JsonProperty] public readonly Setting<string> GameVersion = new ("1.18");

[JsonProperty] public readonly Setting<bool> AutoDetectVersion = new (true);
[JsonProperty] public readonly Setting<bool> UseSftp = new (false);
Expand All @@ -30,9 +30,11 @@ public class TrackingConfig : Config
protected override string GetId() => "tracking";
protected override string GetLegacyId() => "tracker";

[JsonIgnore]
public bool WatchActiveInstance => !this.UseSftp
&& (this.Source == TrackerSource.ActiveInstance || this.AutoDetectVersion || Tracker.Category is AllDeaths);


[JsonIgnore]
public bool SourceChanged => this.UseSftp.Changed || this.Source.Changed
|| (this.Source == TrackerSource.CustomSavesPath && this.CustomSavesPath.Changed)
|| (this.Source == TrackerSource.SpecificWorld && this.CustomWorldPath.Changed);
Expand Down
6 changes: 3 additions & 3 deletions AATool/Data/Categories/AdventuringTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AdventuringTime : SingleAdvancement
};

public override IEnumerable<string> GetSupportedVersions() => SupportedVersions;
public override IEnumerable<Objective> GetOverlayObjectives() => this.Achievements.All.Values;
public override IEnumerable<Objective> GetOverlayObjectives() => Tracker.Achievements.All.Values;

public override int GetTargetCount() => this.Requirement?.Criteria.Count ?? 0;
public override int GetCompletedCount() => this.Requirement?.Criteria.MostCompleted ?? 0;
Expand All @@ -27,8 +27,8 @@ public AdventuringTime() : base()

public override void LoadObjectives()
{
this.Advancements.RefreshObjectives();
this.Advancements.TryGet(Id, out Advancement adventuringTime);
Tracker.Advancements.RefreshObjectives();
Tracker.Advancements.TryGet(Id, out Advancement adventuringTime);
this.Requirement = adventuringTime;
}
}
Expand Down
10 changes: 5 additions & 5 deletions AATool/Data/Categories/AllAchievements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public class AllAchievements : Category
};

public override IEnumerable<string> GetSupportedVersions() => SupportedVersions;
public override IEnumerable<Objective> GetOverlayObjectives() => this.Achievements.All.Values;
public override IEnumerable<Objective> GetOverlayObjectives() => Tracker.Achievements.All.Values;

public override int GetTargetCount() => this.Achievements.Count;
public override int GetCompletedCount() => this.Achievements.CompletedCount;
public override int GetTargetCount() => Tracker.Achievements.Count;
public override int GetCompletedCount() => Tracker.Achievements.CompletedCount;

public AllAchievements() : base ()
{
Expand All @@ -26,8 +26,8 @@ public AllAchievements() : base ()

public override void LoadObjectives()
{
this.Achievements.RefreshObjectives();
this.Pickups.RefreshObjectives();
Tracker.Achievements.RefreshObjectives();
Tracker.Pickups.RefreshObjectives();
}
}
}
10 changes: 5 additions & 5 deletions AATool/Data/Categories/AllAdvancements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public class AllAdvancements : Category
};

public override IEnumerable<string> GetSupportedVersions() => SupportedVersions;
public override IEnumerable<Objective> GetOverlayObjectives() => this.Advancements.All.Values;
public override IEnumerable<Objective> GetOverlayObjectives() => Tracker.Advancements.All.Values;

public override int GetCompletedCount() => this.Advancements.CompletedCount;
public override int GetTargetCount() => this.Advancements.Count;
public override int GetCompletedCount() => Tracker.Advancements.CompletedCount;
public override int GetTargetCount() => Tracker.Advancements.Count;

public AllAdvancements() : base ()
{
Expand All @@ -32,8 +32,8 @@ public AllAdvancements() : base ()

public override void LoadObjectives()
{
this.Advancements.RefreshObjectives();
this.Pickups.RefreshObjectives();
Tracker.Advancements.RefreshObjectives();
Tracker.Pickups.RefreshObjectives();
}
}
}
10 changes: 5 additions & 5 deletions AATool/Data/Categories/AllBlocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public class AllBlocks : Category
};

public override IEnumerable<string> GetSupportedVersions() => SupportedVersions;
public override IEnumerable<Objective> GetOverlayObjectives() => this.Blocks.All.Values;
public override IEnumerable<Objective> GetOverlayObjectives() => Tracker.Blocks.All.Values;

public override int GetTargetCount() => this.Blocks.Count;
public override int GetCompletedCount() => this.Blocks.PlacedCount;
public override int GetTargetCount() => Tracker.Blocks.Count;
public override int GetCompletedCount() => Tracker.Blocks.PlacedCount;

public AllBlocks() : base()
{
Expand All @@ -28,8 +28,8 @@ public AllBlocks() : base()

public override void LoadObjectives()
{
this.Blocks.RefreshObjectives();
this.Pickups.RefreshObjectives();
Tracker.Blocks.RefreshObjectives();
Tracker.Pickups.RefreshObjectives();
}
}
}
10 changes: 5 additions & 5 deletions AATool/Data/Categories/AllDeaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class AllDeaths : Category
};

public override IEnumerable<string> GetSupportedVersions() => SupportedVersions;
public override IEnumerable<Objective> GetOverlayObjectives() => this.Deaths.All.Values;
public override IEnumerable<Objective> GetOverlayObjectives() => Tracker.Deaths.All.Values;

public override int GetTargetCount() => this.Deaths.Count;
public override int GetCompletedCount() => this.Deaths.TotalExperienced;
public override int GetTargetCount() => Tracker.Deaths.Count;
public override int GetCompletedCount() => Tracker.Deaths.TotalExperienced;

public AllDeaths() : base()
{
Expand All @@ -30,8 +30,8 @@ public AllDeaths() : base()

public override void LoadObjectives()
{
this.Deaths.RefreshObjectives();
this.Pickups.RefreshObjectives();
Tracker.Deaths.RefreshObjectives();
Tracker.Pickups.RefreshObjectives();
}
}
}
4 changes: 2 additions & 2 deletions AATool/Data/Categories/BalancedDiet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public BalancedDiet() : base()

public override void LoadObjectives()
{
this.Advancements.RefreshObjectives();
this.Advancements.TryGet(Id, out Advancement balancedDiet);
Tracker.Advancements.RefreshObjectives();
Tracker.Advancements.TryGet(Id, out Advancement balancedDiet);
this.Requirement = balancedDiet;
}
}
Expand Down
16 changes: 1 addition & 15 deletions AATool/Data/Categories/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ namespace AATool.Data.Categories
{
public abstract class Category : ICategory
{
public readonly AdvancementManifest Advancements = new ();
public readonly AchievementManifest Achievements = new ();
public readonly PickupManifest Pickups = new ();
public readonly BlockManifest Blocks = new ();
public readonly DeathManifest Deaths = new ();

public string Name { get; protected set; }
public string Acronym { get; protected set; }
public string Action { get; protected set; }
Expand Down Expand Up @@ -56,7 +50,7 @@ public bool TrySetVersion(string version)
this.CurrentVersion = version;
this.CurrentMajorVersion = $"{number.Major}.{number.Minor}";
Config.Tracking.GameVersion.Set(this.CurrentVersion);
this.LoadObjectives();
Config.Tracking.Save();
return true;
}
return false;
Expand All @@ -74,13 +68,5 @@ public float GetCompletionRatio()
int clamped = Math.Min(this.GetCompletedCount(), target);
return (float)clamped / this.GetTargetCount();
}

public void SetState(WorldState state)
{
this.Advancements.SetState(state);
this.Achievements.SetState(state);
this.Blocks.SetState(state);
this.Pickups.SetState(state);
}
}
}
4 changes: 2 additions & 2 deletions AATool/Data/Categories/HalfDeaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public HalfDeaths() : base()

public override void LoadObjectives()
{
this.Deaths.RefreshObjectives();
this.Pickups.RefreshObjectives();
Tracker.Deaths.RefreshObjectives();
Tracker.Pickups.RefreshObjectives();
}
}
}
4 changes: 2 additions & 2 deletions AATool/Data/Categories/MonstersHunted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public MonstersHunted() : base()

public override void LoadObjectives()
{
this.Advancements.RefreshObjectives();
this.Advancements.TryGet(Id, out Advancement monstersHunted);
Tracker.Advancements.RefreshObjectives();
Tracker.Advancements.TryGet(Id, out Advancement monstersHunted);
this.Requirement = monstersHunted;
}
}
Expand Down
2 changes: 1 addition & 1 deletion AATool/Data/Objectives/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Block(XmlNode node) : base (node)
public void ToggleManualOverride()
{
this.ManuallyCompleted ^= true;
Tracker.Category.Blocks.UpdateTotal();
Tracker.Blocks.UpdateTotal();
}

public override void UpdateState(WorldState progress)
Expand Down
2 changes: 1 addition & 1 deletion AATool/Data/Objectives/Death.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Clear()
public void ToggleManualOverride()
{
this.ManuallyCompleted ^= true;
Tracker.Category.Deaths.UpdateTotal();
Tracker.Deaths.UpdateTotal();
}

public override void UpdateState(WorldState progress)
Expand Down
Loading

0 comments on commit b8fe612

Please sign in to comment.