diff --git a/AATool/Data/Categories/AdventuringTime.cs b/AATool/Data/Categories/AdventuringTime.cs index a2f5b2c9..62a9453a 100644 --- a/AATool/Data/Categories/AdventuringTime.cs +++ b/AATool/Data/Categories/AdventuringTime.cs @@ -12,7 +12,7 @@ public class AdventuringTime : SingleAdvancement }; public override IEnumerable GetSupportedVersions() => SupportedVersions; - public override IEnumerable GetOverlayObjectives() => Tracker.Achievements.All.Values; + public override IEnumerable GetOverlayObjectives() => Tracker.Achievements.AllAdvancements.Values; public override int GetTargetCount() => this.Requirement?.Criteria.Count ?? 0; public override int GetCompletedCount() => this.Requirement?.Criteria.MostCompleted ?? 0; diff --git a/AATool/Data/Categories/AllAchievements.cs b/AATool/Data/Categories/AllAchievements.cs index 7a211657..49b05d09 100644 --- a/AATool/Data/Categories/AllAchievements.cs +++ b/AATool/Data/Categories/AllAchievements.cs @@ -11,7 +11,7 @@ public class AllAchievements : Category }; public override IEnumerable GetSupportedVersions() => SupportedVersions; - public override IEnumerable GetOverlayObjectives() => Tracker.Achievements.All.Values; + public override IEnumerable GetOverlayObjectives() => Tracker.Achievements.AllAdvancements.Values; public override int GetTargetCount() => Tracker.Achievements.Count; public override int GetCompletedCount() => Tracker.Achievements.CompletedCount; diff --git a/AATool/Data/Categories/AllAdvancements.cs b/AATool/Data/Categories/AllAdvancements.cs index 04919e7b..6fa7b954 100644 --- a/AATool/Data/Categories/AllAdvancements.cs +++ b/AATool/Data/Categories/AllAdvancements.cs @@ -17,7 +17,7 @@ public class AllAdvancements : Category }; public override IEnumerable GetSupportedVersions() => SupportedVersions; - public override IEnumerable GetOverlayObjectives() => Tracker.Advancements.All.Values; + public override IEnumerable GetOverlayObjectives() => Tracker.Advancements.AllAdvancements.Values; public override int GetCompletedCount() => Tracker.Advancements.CompletedCount; public override int GetTargetCount() => Tracker.Advancements.Count; diff --git a/AATool/Data/Objectives/AchievementManifest.cs b/AATool/Data/Objectives/AchievementManifest.cs index ba4502f6..ffe3e3a9 100644 --- a/AATool/Data/Objectives/AchievementManifest.cs +++ b/AATool/Data/Objectives/AchievementManifest.cs @@ -21,16 +21,16 @@ public override void RefreshObjectives() { //recursively build achievement tree this.Root = new Achievement(document.DocumentElement); - this.Root.GetAllChildrenRecursive(this.All); + this.Root.GetAllChildrenRecursive(this.AllAdvancements); //add sub-criteria - foreach (Advancement advancement in this.All.Values) + foreach (Advancement advancement in this.AllAdvancements.Values) { if (!advancement.HasCriteria) continue; foreach (KeyValuePair criterion in advancement.Criteria.All) - this.Criteria[(advancement.Id, criterion.Key)] = criterion.Value; + this.AllCriteria[(advancement.Id, criterion.Key)] = criterion.Value; } } } diff --git a/AATool/Data/Objectives/Advancement.cs b/AATool/Data/Objectives/Advancement.cs index c0a3ad88..61187710 100644 --- a/AATool/Data/Objectives/Advancement.cs +++ b/AATool/Data/Objectives/Advancement.cs @@ -56,9 +56,14 @@ public void Designate(Uuid id) if (id == Uuid.Empty) return; - this.DesignatedPlayer = id; - if (Server.TryGet(out Server server)) - server.DesignatePlayer(this.Id, this.DesignatedPlayer); + if (id != this.DesignatedPlayer) + { + this.DesignatedPlayer = id; + Tracker.InvalidateDesignations(); + + if (Server.TryGet(out Server server)) + server.DesignatePlayer(this.Id, this.DesignatedPlayer); + } } public Uuid GetDesignatedPlayer() diff --git a/AATool/Data/Objectives/AdvancementManifest.cs b/AATool/Data/Objectives/AdvancementManifest.cs index a624fceb..e6ceccc7 100644 --- a/AATool/Data/Objectives/AdvancementManifest.cs +++ b/AATool/Data/Objectives/AdvancementManifest.cs @@ -9,26 +9,28 @@ namespace AATool.Data.Objectives { public class AdvancementManifest : IManifest { - public readonly Dictionary All = new (); + public readonly Dictionary AllAdvancements = new (); + public readonly Dictionary RemainingAdvancements = new (); public readonly Dictionary> Groups = new (); - public readonly Dictionary<(string adv, string crit), Criterion> Criteria = new (); + public readonly Dictionary<(string adv, string crit), Criterion> AllCriteria = new (); + public readonly Dictionary<(string adv, string crit), Criterion> RemainingCriteria = new (); public int CompletedCount { get; private set; } - public int Count => this.All.Count; + public int Count => this.AllAdvancements.Count; public AdvancementManifest() { - this.All = new Dictionary(); + this.AllAdvancements = new Dictionary(); this.Groups = new Dictionary>(); - this.Criteria = new Dictionary<(string adv, string crit), Criterion>(); + this.AllCriteria = new Dictionary<(string adv, string crit), Criterion>(); } public bool TryGet(string advId, out Advancement advancement) => - this.All.TryGetValue(advId, out advancement); + this.AllAdvancements.TryGetValue(advId, out advancement); public bool TryGet(string advId, string critId, out Criterion criterion) => - this.Criteria.TryGetValue((advId, critId), out criterion); + this.AllCriteria.TryGetValue((advId, critId), out criterion); public bool TryGet(string groupId, out HashSet group) => this.Groups.TryGetValue(groupId, out group); @@ -36,8 +38,10 @@ public bool TryGet(string groupId, out HashSet group) => public void ClearObjectives() { this.Groups.Clear(); - this.All.Clear(); - this.Criteria.Clear(); + this.AllAdvancements.Clear(); + this.RemainingAdvancements.Clear(); + this.AllCriteria.Clear(); + this.RemainingCriteria.Clear(); this.CompletedCount = 0; } @@ -77,25 +81,43 @@ private void ParseFile(string file) private void RequireAdvancement(XmlNode node, HashSet group) { var advancement = new Advancement(node); - this.All[advancement.Id] = advancement; + this.AllAdvancements[advancement.Id] = advancement; group.Add(advancement); if (advancement.HasCriteria) { foreach (KeyValuePair criterion in advancement.Criteria.All) - this.Criteria[(advancement.Id, criterion.Key)] = criterion.Value; + this.AllCriteria[(advancement.Id, criterion.Key)] = criterion.Value; } } public void SetState(WorldState progress) { + this.RemainingAdvancements.Clear(); this.CompletedCount = 0; - foreach (Advancement advancement in this.All.Values) + + foreach (KeyValuePair advancement in this.AllAdvancements) { //update advancement and completion count - advancement.UpdateState(progress); - if (advancement.CompletedByAnyone()) + advancement.Value.UpdateState(progress); + if (advancement.Value.CompletedByAnyone()) this.CompletedCount++; + else + this.RemainingAdvancements.Add(advancement.Key, advancement.Value); + } + + this.RefreshRemainingCriteria(); + } + + public void RefreshRemainingCriteria() + { + this.RemainingCriteria.Clear(); + + //update global remaining criteria for overlay + foreach (var criterion in this.AllCriteria) + { + if (!criterion.Value.Owner.CompletedByAnyone() && !criterion.Value.CompletedByDesignated()) + this.RemainingCriteria.Add(criterion.Key, criterion.Value); } } } diff --git a/AATool/Data/Progress/WorldState.cs b/AATool/Data/Progress/WorldState.cs index 19b54be3..40910437 100644 --- a/AATool/Data/Progress/WorldState.cs +++ b/AATool/Data/Progress/WorldState.cs @@ -184,7 +184,7 @@ private void SyncAdvancements(WorldFolder world) foreach (Uuid id in world.GetAllUuids()) this.Players[id] = new Contribution(id); - foreach (Advancement advancement in Tracker.Advancements.All.Values) + foreach (Advancement advancement in Tracker.Advancements.AllAdvancements.Values) { //add advancement if completed if (world.Advancements.TryGetAdvancementCompletionFor(advancement.Id, out List ids)) @@ -217,7 +217,7 @@ private void SyncAchievements(WorldFolder world) foreach (Uuid id in world.GetAllUuids()) this.Players[id] = new Contribution(id); - foreach (Achievement achievement in Tracker.Achievements.All.Values) + foreach (Achievement achievement in Tracker.Achievements.AllAdvancements.Values) { //add advancement if completed if (world.Achievements.TryGetAchievementCompletionFor(achievement.Id, out List ids)) diff --git a/AATool/Main.cs b/AATool/Main.cs index 92efc71b..83889658 100644 --- a/AATool/Main.cs +++ b/AATool/Main.cs @@ -113,7 +113,7 @@ protected override void Update(GameTime gameTime) //check minecraft version ActiveInstance.Update(this.Time); - SftpSave.Update(this.Time); + MinecraftServer.Update(this.Time); Tracker.Update(this.Time); OpenTracker.Update(this.Time); SpriteSheet.Update(this.Time); @@ -227,7 +227,7 @@ private void UpdateTitle() //add igt to title if (Tracker.InGameTime > TimeSpan.Zero) - this.AppendTitle($"{Tracker.GetPrettyIGT()} IGT"); + this.AppendTitle($"{Tracker.GetPrettyIgt()} IGT"); //add fps cap to title if (Config.Main.FpsCap < 60) diff --git a/AATool/Net/Client.cs b/AATool/Net/Client.cs index 16da2180..6e8867e4 100644 --- a/AATool/Net/Client.cs +++ b/AATool/Net/Client.cs @@ -14,7 +14,7 @@ public sealed class Client : Peer public bool IsConnecting { get; private set; } public bool WasKickedByServer { get; private set; } public bool LostConnection { get; private set; } - public DateTime EstimatedRefresh { get; private set; } + public DateTime NextRefresh { get; private set; } private readonly Dictionary recieved; private readonly Queue sendQueue; @@ -46,7 +46,7 @@ public string GetStatusText() if (!this.Connected()) return "Attempting connection..."; - int remaining = (int)(this.EstimatedRefresh - DateTime.UtcNow).TotalSeconds; + int remaining = (int)(this.NextRefresh - DateTime.UtcNow).TotalSeconds; if (remaining > 0) { string time = remaining >= 60 @@ -321,8 +321,8 @@ private void CopyData(Message message) { //deserialize datetime message.TryGetItem(0, out string dateString); - if (DateTime.TryParse(dateString, out DateTime refreshEstimate)) - this.EstimatedRefresh = refreshEstimate; + if (DateTime.TryParse(dateString, out DateTime nextEstimate)) + this.NextRefresh = nextEstimate; } else if (message.TryGetItem(0, out string jsonString)) { diff --git a/AATool/Net/Message.cs b/AATool/Net/Message.cs index b676ff6d..e6e17923 100644 --- a/AATool/Net/Message.cs +++ b/AATool/Net/Message.cs @@ -33,7 +33,7 @@ public static Message LogIn(string uuid, string password, string pronouns, strin public static Message Kick(string reason) => NewCommand(Protocol.Headers.Kick, reason); public static Message Progress(string jsonString) => NewData(Protocol.Headers.Progress, jsonString); public static Message Lobby(string jsonString) => NewData(Protocol.Headers.Lobby, jsonString); - public static Message SftpEstimate(string nextRefresh) => NewData(Protocol.Headers.RefreshEstimate, nextRefresh); + public static Message SftpEstimate(DateTime nextRefresh) => NewData(Protocol.Headers.RefreshEstimate, nextRefresh.ToString()); private static Message NewCommand(string header, params string[] items) => new(Protocol.CommandPrefix, header, items); private static Message NewData(string header, string data) => new(Protocol.DataPrefix, header, data); diff --git a/AATool/Net/Server.cs b/AATool/Net/Server.cs index 7e91ce3a..929917c4 100644 --- a/AATool/Net/Server.cs +++ b/AATool/Net/Server.cs @@ -78,7 +78,7 @@ public void SendProgress(Socket client = null) public void SendNextRefresh(Socket client = null) { - var message = Message.SftpEstimate(SftpSave.GetRefreshEstimate().ToString()); + var message = Message.SftpEstimate(MinecraftServer.GetRefreshEstimate()); //send last to client(s) if (client is null) diff --git a/AATool/Properties/AssemblyInfo.cs b/AATool/Properties/AssemblyInfo.cs index 367c5cb6..e28ca395 100644 --- a/AATool/Properties/AssemblyInfo.cs +++ b/AATool/Properties/AssemblyInfo.cs @@ -33,6 +33,6 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.2.1")] -[assembly: AssemblyFileVersion("1.4.2.1")] +[assembly: AssemblyVersion("1.4.2.2")] +[assembly: AssemblyFileVersion("1.4.2.2")] [assembly: NeutralResourcesLanguage("en")] diff --git a/AATool/Saves/SftpSave.cs b/AATool/Saves/SftpSave.cs index 17ab9913..4eeb3fd5 100644 --- a/AATool/Saves/SftpSave.cs +++ b/AATool/Saves/SftpSave.cs @@ -14,7 +14,7 @@ namespace AATool.Saves { - public static class SftpSave + public static class MinecraftServer { private const string SftpPrefix = "sftp://"; private const double SaveInterval = (5 * 60) + 5; @@ -56,13 +56,6 @@ public static string GetEstimateString(int seconds) public static void Update(Time time) { - if (Config.Tracking.UseSftp) - { - //update client refresh estimates if hosting - if (Server.TryGet(out Server server)) - server.SendNextRefresh(); - } - if (LastError is ArgumentException) { //invalid login credentials, don't try reconnecting @@ -102,7 +95,7 @@ public static void Sync() DateTime next = latest.Add(TimeSpan.FromSeconds(SaveInterval)); remaining = (next - DateTime.UtcNow).TotalSeconds; if (remaining > 0) - RefreshTimer.SetAndStart(remaining); + RefreshTimer.SetAndStart(Math.Min(remaining, SaveInterval)); if (latest != LastWorldSave) { @@ -110,12 +103,12 @@ public static void Sync() return; LastWorldSave = latest; + //update client refresh estimates if hosting if (Server.TryGet(out Server server)) server.SendNextRefresh(); - //DODO: implement - //Tracker.Invalidate(); + Tracker.Invalidate(); } } finally @@ -316,7 +309,7 @@ private static bool TryGetWorldSaveTime(SftpClient sftp, out DateTime lastWorldS { if (exception is SftpPathNotFoundException) { - //folder not found, so world name might be wrong. refresh it next time + //folder not found, world name might be wrong. refresh it next time LastError = new SftpPathNotFoundException($"File not found: \"{remote}\"."); InvalidateWorld(); return false; diff --git a/AATool/Saves/WorldFolder.cs b/AATool/Saves/WorldFolder.cs index ffd7663d..a6b03ae4 100644 --- a/AATool/Saves/WorldFolder.cs +++ b/AATool/Saves/WorldFolder.cs @@ -17,7 +17,7 @@ public class WorldFolder public DirectoryInfo CurrentFolder { get; private set; } public bool ProgressChanged { get; private set; } public bool Invalidated { get; private set; } - public bool ChangedPath { get; private set; } + public bool PathChanged { get; private set; } public bool IsEmpty => this.CurrentFolder is null; @@ -29,7 +29,7 @@ public WorldFolder() this.Advancements = new AdvancementsFolder(); this.Achievements = new AchievementsFolder(); this.Statistics = new StatisticsFolder(); - this.ChangedPath = true; + this.PathChanged = true; this.ProgressChanged = true; } @@ -52,7 +52,7 @@ public WorldState GetState() public void ClearFlags() { - this.ChangedPath = false; + this.PathChanged = false; this.ProgressChanged = false; } @@ -81,7 +81,7 @@ public void SetPath(DirectoryInfo worldFolder) death.Clear(); this.CurrentFolder = worldFolder; - this.ChangedPath = true; + this.PathChanged = true; string advancementsFolder = Path.Combine(this.CurrentFolder.FullName, "advancements"); string statisticsFolder = Path.Combine(this.CurrentFolder.FullName, "stats"); @@ -107,7 +107,7 @@ public bool TryRefresh() this.ProgressChanged |= this.Invalidated; this.Invalidated = false; - return this.ProgressChanged || this.ChangedPath; + return this.ProgressChanged || this.PathChanged; } } } \ No newline at end of file diff --git a/AATool/Tracker.cs b/AATool/Tracker.cs index 61950e4e..2ccf6892 100644 --- a/AATool/Tracker.cs +++ b/AATool/Tracker.cs @@ -26,34 +26,45 @@ public static class Tracker public static Category Category { get; private set; } public static WorldState State { get; private set; } public static Exception LastError { get; private set; } + public static bool DesignationsChanged { get; private set; } public static bool CoOpStateChanged { get; private set; } public static bool WorldLocked { get; private set; } public static string Status { get; private set; } - public static bool ObjectivesChanged => Config.Tracking.GameCategory.Changed || Config.Tracking.GameVersion.Changed; - public static bool SavesFolderChanged => PreviousSavesPath != Paths.Saves.CurrentFolder(); - public static bool ProgressChanged => World.ProgressChanged || World.ChangedPath || World.Invalidated || CoOpStateChanged; - public static bool Invalidated => SavesFolderChanged || ProgressChanged || ObjectivesChanged; - public static bool IsWorking => LastError is null; + public static bool Invalidated => + SavesFolderChanged || ObjectivesChanged || ProgressChanged; + + public static bool SavesFolderChanged => + PreviousSavesPath != Paths.Saves.CurrentFolder(); + + public static bool ObjectivesChanged => + Config.Tracking.GameCategory.Changed || Config.Tracking.GameVersion.Changed; + + public static bool ProgressChanged => + World.ProgressChanged || World.PathChanged || World.Invalidated || CoOpStateChanged; + public static bool IsWorking => LastError is null; public static string CurrentCategory => Category.Name; public static string CurrentVersion => Category.CurrentVersion; - public static void ToggleWorldLock() => WorldLocked ^= true; - public static AdvancementManifest CurrentAdvancementSet => Category is not AllAchievements ? Advancements : Achievements; - public static Dictionary<(string adv, string crit), Criterion> CurrentCriteriaSet => - CurrentAdvancementSet.Criteria; + public static Dictionary<(string adv, string crit), Criterion> AllCriteria => + CurrentAdvancementSet.AllCriteria; + + public static Dictionary<(string adv, string crit), Criterion> RemainingCriteria => + CurrentAdvancementSet.RemainingCriteria; public static string WorldName => World.Name; public static TimeSpan InGameTime => State.InGameTime; public static bool InGameTimeChanged => State.InGameTime != LastInGameTime; public static TrackerSource Source => Config.Tracking.Source; - public static string GetPrettyIGT() + public static void ToggleWorldLock() => WorldLocked ^= true; + + public static string GetPrettyIgt() { return InGameTime.TotalDays > 1 ? $"{(int)InGameTime.TotalHours}:{InGameTime:mm':'ss}" @@ -67,11 +78,17 @@ public static string GetPrettyIGT() private static string PreviousWorldPath; private static string LastServerMessage; + public static void InvalidateDesignations() + { + DesignationsChanged = true; + CurrentAdvancementSet.RefreshRemainingCriteria(); + } + public static bool TryGetAdvancement(string id, out Advancement advancement) => CurrentAdvancementSet.TryGet(id, out advancement); public static bool TryGetCriterion(string adv, string crit, out Criterion criterion) => - CurrentCriteriaSet.TryGetValue((adv, crit), out criterion); + AllCriteria.TryGetValue((adv, crit), out criterion); public static bool TryGetAdvancementGroup(string id, out HashSet group) => Advancements.TryGet(id, out group); @@ -187,6 +204,7 @@ public static void Invalidate(bool invalidateWorld = false) public static void ClearFlags() { LastInGameTime = InGameTime; + DesignationsChanged = false; CoOpStateChanged = false; World.ClearFlags(); } @@ -217,7 +235,7 @@ private static void UpdateCurrentWorld() DirectoryInfo latestWorld = null; try { - if (Source is TrackerSource.SpecificWorld) + if (Source is TrackerSource.SpecificWorld && !Config.Tracking.UseSftp) { //set world to user-defined path WorldLocked = true; @@ -369,7 +387,7 @@ private static void ReadLocalFiles() Category.LoadObjectives(); //wait to refresh until sftp transer is complete - if (Config.Tracking.UseSftp && SftpSave.IsDownloading) + if (Config.Tracking.UseSftp && MinecraftServer.IsDownloading) return; //update progress if source has been invalidated diff --git a/AATool/UI/Controls/UIAdvancementCarousel.cs b/AATool/UI/Controls/UIAdvancementCarousel.cs index 038c630d..7ab9b973 100644 --- a/AATool/UI/Controls/UIAdvancementCarousel.cs +++ b/AATool/UI/Controls/UIAdvancementCarousel.cs @@ -6,11 +6,12 @@ namespace AATool.UI.Controls { - class UIAdvancementCarousel : UICarousel + class UIObjectiveCarousel : UICarousel { protected override void UpdateThis(Time time) { - this.UpdateSourceList(); + if (Tracker.Invalidated) + this.RefreshSourceList(); if (Tracker.ObjectivesChanged) this.Clear(); @@ -32,7 +33,7 @@ protected override void UpdateThis(Time time) this.Fill(); - //remove completed advancements from carousel + //remove existing overlay advancements that have since been completed for (int i = this.Children.Count - 1; i >= 0; i--) { if ((this.Children[i] as UIObjectiveFrame).ObjectiveCompleted) @@ -42,15 +43,15 @@ protected override void UpdateThis(Time time) base.UpdateThis(time); } - protected override void UpdateSourceList() + protected override void RefreshSourceList() { - var objectives = new List(Tracker.Category.GetOverlayObjectives()); - this.SourceList = new List(objectives); + this.SourceList.Clear(); + this.SourceList.AddRange(Tracker.Category.GetOverlayObjectives()); - //remove all completed advancements from pool + //remove completed advancements from pool for (int i = this.SourceList.Count - 1; i >= 0; i--) { - if (objectives[i].CompletedByAnyone()) + if ((this.SourceList[i] as Objective).CompletedByAnyone()) this.SourceList.RemoveAt(i); } diff --git a/AATool/UI/Controls/UIAvatar.cs b/AATool/UI/Controls/UIAvatar.cs index 20c3531a..d78c096d 100644 --- a/AATool/UI/Controls/UIAvatar.cs +++ b/AATool/UI/Controls/UIAvatar.cs @@ -15,7 +15,6 @@ class UIAvatar : UIPicture { public Uuid Player { get; private set; } public bool ShowName { get; set; } - public bool HideTrophy { get; set; } public int Scale { get; set; } private UIPicture face; @@ -74,7 +73,7 @@ protected override void UpdateThis(Time time) private void UpdateTrophy(bool forceRecheck = false) { - if (this.HideTrophy || (this.leaderboardChecked && !forceRecheck)) + if (this.leaderboardChecked && !forceRecheck) return; if (!LeaderboardRequest.Runs.Any()) return; diff --git a/AATool/UI/Controls/UICarousel.cs b/AATool/UI/Controls/UICarousel.cs index c5b465b4..431f0ade 100644 --- a/AATool/UI/Controls/UICarousel.cs +++ b/AATool/UI/Controls/UICarousel.cs @@ -31,7 +31,7 @@ public UICarousel() public void Continue() => this.isScrolling = true; protected abstract UIControl NextControl(); - protected abstract void UpdateSourceList(); + protected abstract void RefreshSourceList(); public void SetSpeed(double speed) { @@ -91,9 +91,11 @@ protected virtual void Fill() if (this.SourceList.Count == 0) return; + //loop if (this.NextIndex >= this.SourceList.Count) this.NextIndex = 0; + //instantate control and add to carousel UIControl control = this.NextControl(); control.ResizeRecursive(this.Bounds); control.VerticalAlign = VerticalAlign.Top; diff --git a/AATool/UI/Controls/UICriteriaCarousel.cs b/AATool/UI/Controls/UICriteriaCarousel.cs index b9c6a2fb..3506311a 100644 --- a/AATool/UI/Controls/UICriteriaCarousel.cs +++ b/AATool/UI/Controls/UICriteriaCarousel.cs @@ -10,48 +10,43 @@ class UICriteriaCarousel : UICarousel { public override void InitializeThis(UIScreen screen) { - this.UpdateSourceList(); + this.RefreshSourceList(); } protected override void UpdateThis(Time time) { - this.UpdateSourceList(); this.Fill(); - //remove ones that have been completed - for (int i = this.Children.Count - 1; i >= 0; i--) + if (Tracker.ProgressChanged || Tracker.DesignationsChanged) { - if ((this.Children[i] as UICriterion).IsCompleted) - this.Children.RemoveAt(i); + this.RefreshSourceList(); + + //remove existing overlay items that have since been completed + for (int i = this.Children.Count - 1; i >= 0; i--) + { + if ((this.Children[i] as UICriterion).HideFromOverlay) + this.Children.RemoveAt(i); + } } base.UpdateThis(time); } - protected override void UpdateSourceList() + protected override void RefreshSourceList() { //populate source list with all criteria this.SourceList.Clear(); - foreach (Criterion criterion in Tracker.CurrentCriteriaSet.Values) - { - if (!criterion.CompletedByAnyone()) - this.SourceList.Add(criterion); - } - - //remove all completed criteria from pool if configured to do so - for (int i = this.SourceList.Count - 1; i >= 0; i--) - { - if ((this.SourceList[i] as Criterion).CompletedByAnyone()) - this.SourceList.RemoveAt(i); - } + this.SourceList.AddRange(Tracker.RemainingCriteria.Values); } protected override void Fill() { //calculate widths - int x = this.Children.Count > 0 ? this.Children.Last().Right : 0; + int x; if (this.Children.Count > 0) x = this.RightToLeft ? this.Children.Last().Right : this.Width - this.Children.Last().Left; + else + x = this.Children.Count > 0 ? this.Children.Last().Right : 0; //while more controls will fit, add them while (x < this.Width) diff --git a/AATool/UI/Controls/UICriterion.cs b/AATool/UI/Controls/UICriterion.cs index c5ea9e84..4d9d9d23 100644 --- a/AATool/UI/Controls/UICriterion.cs +++ b/AATool/UI/Controls/UICriterion.cs @@ -20,7 +20,8 @@ class UICriterion : UIControl private float iconBrightness; private float textBrightness; - public bool IsCompleted => this.criterion?.CompletedBy(this.criterion.Owner.GetDesignatedPlayer()) ?? false; + public bool HideFromOverlay => (this.criterion?.Owner?.CompletedByAnyone() ?? false) || this.CriterionCompleted; + public bool CriterionCompleted => this.criterion?.CompletedByDesignated() ?? false; public UICriterion() { @@ -88,11 +89,11 @@ protected override void UpdateThis(Time time) { if (!this.IsStatic) { - float iconTarget = this.IsCompleted ? 1f : 0.35f; + float iconTarget = this.CriterionCompleted ? 1f : 0.35f; this.iconBrightness = MathHelper.Lerp(this.iconBrightness, iconTarget, (float)(10 * time.Delta)); this.icon?.SetTint(Color.White * this.iconBrightness); - float textTarget = this.IsCompleted ? 1f : 0.5f; + float textTarget = this.CriterionCompleted ? 1f : 0.5f; this.textBrightness = MathHelper.Lerp(this.textBrightness, textTarget, (float)(10 * time.Delta)); this.label?.SetTextColor(Config.Main.TextColor.Value * textTarget); } diff --git a/AATool/UI/Controls/UIFlowCarousel.cs b/AATool/UI/Controls/UIFlowCarousel.cs index 3c129534..cac6061d 100644 --- a/AATool/UI/Controls/UIFlowCarousel.cs +++ b/AATool/UI/Controls/UIFlowCarousel.cs @@ -16,7 +16,7 @@ public class UIFlowCarousel : UICarousel public override void InitializeRecursive(UIScreen screen) { base.InitializeRecursive(screen); - this.UpdateSourceList(); + this.RefreshSourceList(); } public override void ResizeRecursive(Rectangle rectangle) @@ -43,7 +43,7 @@ protected override void UpdateThis(Time time) } } - protected override void UpdateSourceList() + protected override void RefreshSourceList() { //keep copy of children so we can remove them without dereferencing foreach (UIControl child in this.Children) diff --git a/AATool/UI/Controls/UIPersonalBest.cs b/AATool/UI/Controls/UIPersonalBest.cs index c8e87600..bae39618 100644 --- a/AATool/UI/Controls/UIPersonalBest.cs +++ b/AATool/UI/Controls/UIPersonalBest.cs @@ -27,7 +27,6 @@ protected override void UpdateThis(Time time) public override void InitializeRecursive(UIScreen screen) { this.face = this.First(); - //this.face.HideTrophy = true; this.face.Scale = 4; this.face.InitializeRecursive(screen); this.face.SetPlayer(this.Run.Runner); @@ -37,12 +36,14 @@ public override void InitializeRecursive(UIScreen screen) this.First("igt").SetText(this.Run.InGameTime.ToString("hh':'mm':'ss")); this.First("status").SetText(this.Run.Status); - int days = (int)(DateTime.Now - this.Run.Date).TotalDays; + int days = (int)(DateTime.UtcNow - this.Run.Date).TotalDays; if (days is 0) this.First("date").SetText("Set Today"); + else if (days is 1) + this.First("date").SetText($"Set Yesterday"); else this.First("date").SetText($"{days} days ago"); - + base.InitializeRecursive(screen); } diff --git a/AATool/UI/Controls/UIRefreshIcon.cs b/AATool/UI/Controls/UIRefreshIcon.cs index 84faafc6..8be95358 100644 --- a/AATool/UI/Controls/UIRefreshIcon.cs +++ b/AATool/UI/Controls/UIRefreshIcon.cs @@ -56,7 +56,7 @@ private void OnClick(UIControl sender) { if (Config.Tracking.UseSftp) { - SftpSave.Sync(); + MinecraftServer.Sync(); } else if (Config.Tracking.Source != TrackerSource.SpecificWorld) { @@ -100,7 +100,7 @@ protected override void UpdateThis(Time time) else { //configure appearance as sftp button - bool ready = SftpSave.State is SyncState.Ready; + bool ready = MinecraftServer.State is SyncState.Ready; this.button.Enabled = ready; this.icon.SetTexture(ready ? SyncTexture : SyncingTexture); this.icon.SetTint(Config.Main.TextColor); diff --git a/AATool/UI/Controls/UIRunComplete.cs b/AATool/UI/Controls/UIRunComplete.cs index 4c784f74..e980cfe0 100644 --- a/AATool/UI/Controls/UIRunComplete.cs +++ b/AATool/UI/Controls/UIRunComplete.cs @@ -202,7 +202,7 @@ public void Show() string title = Tracker.Category.GetCompletionMessage(); string body = $" \nMinecraft: Java Edition ({Tracker.Category.CurrentVersion})\n" + $"{Tracker.Category.Name.Replace(" ", "\0")}\n \n" + - $"{Tracker.GetPrettyIGT()}\nApproximate IGT\n"; + $"{Tracker.GetPrettyIgt()}\nApproximate IGT\n"; this.First("head").SetText(title); this.First("head_shadow").SetText(title); diff --git a/AATool/UI/Controls/UIStatusBar.cs b/AATool/UI/Controls/UIStatusBar.cs index 3a4ab9ee..27caec4c 100644 --- a/AATool/UI/Controls/UIStatusBar.cs +++ b/AATool/UI/Controls/UIStatusBar.cs @@ -149,7 +149,7 @@ protected override void UpdateThis(Time time) this.refreshTimer.Reset(); this.statusLabel.SetText(this.GetLabelText()); } - else if (Tracker.ProgressChanged || Peer.StateChanged || !string.IsNullOrEmpty(SftpSave.GetStatusText())) + else if (Tracker.ProgressChanged || Peer.StateChanged || !string.IsNullOrEmpty(MinecraftServer.GetStatusText())) { this.statusLabel.SetText(this.GetLabelText()); } @@ -162,11 +162,11 @@ protected override void UpdateThis(Time time) if (Config.Main.ProgressBarStyle != "None") { if (this.progressBar.Width > 250) - progress += $" - {Tracker.GetPrettyIGT()} IGT"; + progress += $" - {Tracker.GetPrettyIgt()} IGT"; } else { - progress += $"\n{Tracker.GetPrettyIGT()} IGT\n{new string('-', this.progressBar.Width / 7)}"; + progress += $"\n{Tracker.GetPrettyIgt()} IGT\n{new string('-', this.progressBar.Width / 7)}"; } this.progressLabel.SetText(progress); @@ -182,7 +182,7 @@ private string GetLabelText() return client.GetStatusText(); if (Config.Tracking.UseSftp) - return SftpSave.GetStatusText(); + return MinecraftServer.GetStatusText(); return Tracker.GetStatusText(); } diff --git a/AATool/UI/Screens/UIOverlayScreen.cs b/AATool/UI/Screens/UIOverlayScreen.cs index 9424dcf0..ee015279 100644 --- a/AATool/UI/Screens/UIOverlayScreen.cs +++ b/AATool/UI/Screens/UIOverlayScreen.cs @@ -251,7 +251,7 @@ protected override void UpdateThis(Time time) if (Client.TryGet(out Client client)) { this.status.SetFont("minecraft", 24); - int seconds = (int)Math.Ceiling((client.EstimatedRefresh - DateTime.UtcNow).TotalSeconds); + int seconds = (int)Math.Ceiling((client.NextRefresh - DateTime.UtcNow).TotalSeconds); if (seconds <= 0) { string hostName = "host"; @@ -264,20 +264,20 @@ protected override void UpdateThis(Time time) } else { - this.status?.SetText($"Refreshing in {SftpSave.GetEstimateString(seconds).Replace(" ", "\0")}"); + this.status?.SetText($"Refreshing in {MinecraftServer.GetEstimateString(seconds).Replace(" ", "\0")}"); } } - else if (SftpSave.IsEnabled) + else if (MinecraftServer.IsEnabled) { this.status.SetFont("minecraft", 24); - if (SftpSave.State is SyncState.Ready) + if (MinecraftServer.State is SyncState.Ready) { - if (SftpSave.CredentialsValidated) - this.status?.SetText($"Refreshing in {SftpSave.GetEstimateString(SftpSave.GetNextRefresh()).Replace(" ", "\0")}"); + if (MinecraftServer.CredentialsValidated) + this.status?.SetText($"Refreshing in {MinecraftServer.GetEstimateString(MinecraftServer.GetNextRefresh()).Replace(" ", "\0")}"); else this.status?.SetText($"SFTP Offline"); } - else if (SftpSave.State is SyncState.Connecting) + else if (MinecraftServer.State is SyncState.Connecting) { this.status?.SetText($"Connecting..."); } @@ -290,7 +290,7 @@ protected override void UpdateThis(Time time) { this.status?.SetFont("minecraft", 48); if (Config.Overlay.ShowIgt && Tracker.InGameTime != default) - this.status?.SetText(Tracker.GetPrettyIGT()); + this.status?.SetText(Tracker.GetPrettyIgt()); else this.status?.SetText(string.Empty); } diff --git a/AATool/Winforms/Controls/CTrackerSettings.cs b/AATool/Winforms/Controls/CTrackerSettings.cs index f794cef7..c33bd3e5 100644 --- a/AATool/Winforms/Controls/CTrackerSettings.cs +++ b/AATool/Winforms/Controls/CTrackerSettings.cs @@ -162,7 +162,7 @@ private void OnClicked(object sender, EventArgs e) } else if (sender == this.sftpValidate) { - SftpSave.Sync(); + MinecraftServer.Sync(); } else if (sender == this.toggleCredentials) { diff --git a/AATool/assets/views/adventuring_time/overlay.xml b/AATool/assets/views/adventuring_time/overlay.xml index 77150b47..8155f722 100644 --- a/AATool/assets/views/adventuring_time/overlay.xml +++ b/AATool/assets/views/adventuring_time/overlay.xml @@ -6,6 +6,6 @@ - + \ No newline at end of file diff --git a/AATool/assets/views/all_achievements/overlay.xml b/AATool/assets/views/all_achievements/overlay.xml index 4f82deda..049c87f8 100644 --- a/AATool/assets/views/all_achievements/overlay.xml +++ b/AATool/assets/views/all_achievements/overlay.xml @@ -9,7 +9,7 @@ - + diff --git a/AATool/assets/views/all_advancements/overlay.xml b/AATool/assets/views/all_advancements/overlay.xml index 2c43e42e..f1372dce 100644 --- a/AATool/assets/views/all_advancements/overlay.xml +++ b/AATool/assets/views/all_advancements/overlay.xml @@ -9,7 +9,7 @@ - + diff --git a/AATool/assets/views/all_blocks/overlay.xml b/AATool/assets/views/all_blocks/overlay.xml index 86cfba91..d79f5406 100644 --- a/AATool/assets/views/all_blocks/overlay.xml +++ b/AATool/assets/views/all_blocks/overlay.xml @@ -6,7 +6,7 @@ - + diff --git a/AATool/assets/views/all_deaths/overlay.xml b/AATool/assets/views/all_deaths/overlay.xml index f3a22538..a3b1867d 100644 --- a/AATool/assets/views/all_deaths/overlay.xml +++ b/AATool/assets/views/all_deaths/overlay.xml @@ -6,7 +6,7 @@ - + diff --git a/AATool/assets/views/balanced_diet/overlay.xml b/AATool/assets/views/balanced_diet/overlay.xml index 77150b47..8155f722 100644 --- a/AATool/assets/views/balanced_diet/overlay.xml +++ b/AATool/assets/views/balanced_diet/overlay.xml @@ -6,6 +6,6 @@ - + \ No newline at end of file diff --git a/AATool/assets/views/half_percent/overlay.xml b/AATool/assets/views/half_percent/overlay.xml index 77150b47..8155f722 100644 --- a/AATool/assets/views/half_percent/overlay.xml +++ b/AATool/assets/views/half_percent/overlay.xml @@ -6,6 +6,6 @@ - + \ No newline at end of file diff --git a/AATool/assets/views/monsters_hunted/overlay.xml b/AATool/assets/views/monsters_hunted/overlay.xml index ef1edbfc..096401c0 100644 --- a/AATool/assets/views/monsters_hunted/overlay.xml +++ b/AATool/assets/views/monsters_hunted/overlay.xml @@ -6,6 +6,6 @@ - + \ No newline at end of file