diff --git a/AATool/AATool.csproj b/AATool/AATool.csproj index a45f40f3..7892862f 100644 --- a/AATool/AATool.csproj +++ b/AATool/AATool.csproj @@ -34,7 +34,7 @@ true - assets\graphics\system\aatool.ico + assets\icons\aatool.ico @@ -83,18 +83,44 @@ app.manifest - - - - - + + + + + + + + + + + + + + + + + + - - + + - - + + + + + + + + + + + + + + + @@ -102,23 +128,21 @@ - + - + - + - - - + @@ -133,14 +157,12 @@ True Resources.resx - - - - + + @@ -215,12 +237,6 @@ CNetworkSettings.cs - - Form - - - FAbout.cs - Form @@ -241,10 +257,6 @@ - - - - @@ -270,12 +282,6 @@ - - Form - - - FUpdate.cs - @@ -324,2336 +330,2413 @@ - + PreserveNewest + + PreserveNewest + + + - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + Always - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + @@ -2689,6 +2772,9 @@ CCreditsGroup.cs + + CDebugSettings.cs + CTrackerSettings.cs @@ -2698,16 +2784,9 @@ CNetworkSettings.cs - - CDebugSettings.cs - COverlaySettings.cs - - FAbout.cs - Designer - FNetworkSetup.cs @@ -2718,9 +2797,6 @@ FSettings.cs Designer - - FUpdate.cs - diff --git a/AATool/Enums.cs b/AATool/Enums.cs index 408d5e7a..11ea6577 100644 --- a/AATool/Enums.cs +++ b/AATool/Enums.cs @@ -1,19 +1,18 @@ namespace AATool { - //data structures - public enum FrameType { Normal, Goal, Challenge } - - public enum SaveFolderState + //used for save reading + public enum SaveState { Valid, NoWorlds, - NonExistentPath, - EmptyPath, - InvalidPath, + PathNonExistent, + PathEmpty, + PathInvalid, PathTooLong, - PermissionError + PermissionError, } + //used for sftp public enum SyncState { Ready, @@ -24,19 +23,14 @@ public enum SyncState Statistics, } - //ui + //ui and rendering public enum HorizontalAlign { Center, Left, Right } - public enum VerticalAlign { Center, Top, Bottom } - public enum FlowDirection { LeftToRight, RightToLeft, TopToBottom, BottomToTop } - public enum SizeMode { Absolute, Relative } - public enum DrawMode { All, ThisOnly, ChildrenOnly, None } - public enum UIButtonState { Released, Hovered, Pressed, Disabled } - public enum UIRefreshStyle { Compass, Xp } - - //graphics - public enum Layer { Main, Glow, Fore } - - //misc - public enum Ease { Back, Bounce, Circular, Cubic, Elastic, Exponential, Quadratic, Quartic, Quintic, Sinusoidal } - public enum SupportTier { Developer, BetaTester, PatreonGold, PatreonDiamond, PatreonNetherite } + public enum VerticalAlign { Center, Top, Bottom } + public enum FlowDirection { LeftToRight, RightToLeft, TopToBottom, BottomToTop } + public enum SizeMode { Absolute, Relative } + public enum DrawMode { All, ThisOnly, ChildrenOnly, None } + public enum ButtonState { Released, Hovered, Pressed, Disabled } + public enum FrameType { Normal, Goal, Challenge, Statistic } + public enum Layer { Main, Glow, Fore } + public enum Ease { Back, Bounce, Circular, Cubic, Elastic, Exponential, Quadratic, Quartic, Quintic, Sinusoidal } } diff --git a/AATool/Main.cs b/AATool/Main.cs index c9fde3af..f39a1f9d 100644 --- a/AATool/Main.cs +++ b/AATool/Main.cs @@ -4,7 +4,7 @@ using System.Reflection; using AATool.Graphics; using AATool.UI.Screens; -using AATool.Settings; +using AATool.Configuration; using System.Diagnostics; using AATool.Utilities; using System.IO; @@ -37,9 +37,6 @@ public class Main : Game || || ====================================================HDWGH?*/ - - public static readonly bool IsBeta = false; - public static bool IsClosing { get; set; } public static string FullTitle { get; private set; } public static string ShortTitle { get; private set; } @@ -52,32 +49,25 @@ public class Main : Game public readonly Time Time; - private Display display; + private Canvas canvas; private FNotes notesWindow; private bool announceUpdate; + public static bool IsBeta => FullTitle.ToLower().Contains("beta"); public static bool IsModded => !string.IsNullOrEmpty(ModderName); - private void AddScreen(UIScreen screen) - { - if (SecondaryScreens.TryGetValue(screen.GetType(), out UIScreen old)) - old.Dispose(); - SecondaryScreens[screen.GetType()] = screen; - } - public Main() { - this.UpdateTitle(); - + Version = Assembly.GetExecutingAssembly().GetName().Version; Graphics = new GraphicsDeviceManager(this); RNG = new Random(); - if (Config.Main.FpsCap is 0) - this.TargetElapsedTime = TimeSpan.FromSeconds(1.0 / 60); - else - this.TargetElapsedTime = TimeSpan.FromSeconds(1.0 / Config.Main.FpsCap); + Config.Initialize(); + this.TargetElapsedTime = Config.Main.FpsCap == 0 + ? TimeSpan.FromSeconds(1.0 / 60) + : TimeSpan.FromSeconds(1.0 / Config.Main.FpsCap); this.InactiveSleepTime = TimeSpan.Zero; this.IsFixedTimeStep = true; this.IsMouseVisible = true; @@ -86,7 +76,7 @@ public Main() protected override void Initialize() { - this.display = new Display(Graphics); + this.canvas = new Canvas(Graphics); //load assets Tracker.Initialize(); @@ -94,11 +84,14 @@ protected override void Initialize() FontSet.Initialize(this.GraphicsDevice); NetRequest.Enqueue(new UpdateRequest()); - Version.TryParse(Config.Tracker.LastAAToolRun, out Version lastVersion); - if (lastVersion is null || lastVersion < Version.Parse("1.3.2")) + //check build number of last aatool session + Version.TryParse(Config.Tracking.LastSession, out Version lastSession); + if (lastSession is null || lastSession < Version.Parse("1.3.2")) this.announceUpdate = true; - Config.Tracker.LastAAToolRun = Version.ToString(); - Config.Tracker.Save(); + Config.Tracking.LastSession.Set(Version.ToString()); + Config.Tracking.Save(); + + this.UpdateTitle(); //instantiate screens SecondaryScreens = new (); @@ -112,11 +105,11 @@ protected override void Initialize() protected override void Update(GameTime gameTime) { this.Time.Update(gameTime); - this.display.Update(this.Time); + this.canvas.Update(this.Time); //check minecraft version GameVersionDetector.Update(); - Tracker.Update(this.Time); + Tracker.TryUpdate(this.Time); SftpSave.Update(this.Time); //update visibilty of update popup @@ -132,7 +125,7 @@ protected override void Update(GameTime gameTime) screen.UpdateRecursive(this.Time); //update notes screen - if (NotesSettings.Instance.Enabled) + if (Config.Notes.Enabled) { if (this.notesWindow is null || this.notesWindow.IsDisposed) { @@ -149,20 +142,20 @@ protected override void Update(GameTime gameTime) this.notesWindow.Close(); } - if (Config.Main.FpsCapChanged()) + if (Config.Main.FpsCap.Changed) { this.TargetElapsedTime = TimeSpan.FromSeconds(1.0 / Config.Main.FpsCap); this.UpdateTitle(); } - else if (Config.Tracker.GameVersionChanged() || Tracker.InGameTimeChanged) + else if (Tracker.ObjectivesChanged || Tracker.InGameTimeChanged) { this.UpdateTitle(); } - + NetRequest.Update(this.Time); SpriteSheet.Update(this.Time); base.Update(gameTime); - Config.ClearFlags(); + Config.ClearAllFlags(); Tracker.ClearFlags(); Peer.ClearFlags(); } @@ -174,19 +167,26 @@ protected override void Draw(GameTime gameTime) //render each secondary screen to its respective viewport foreach (UIScreen screen in SecondaryScreens.Values) { - screen.Prepare(this.display); - screen.DrawRecursive(this.display); - screen.Present(this.display); + screen.Prepare(this.canvas); + screen.DrawRecursive(this.canvas); + screen.Present(this.canvas); } //render main screen to default backbuffer - PrimaryScreen.Prepare(this.display); - PrimaryScreen.DrawRecursive(this.display); - PrimaryScreen.Present(this.display); + PrimaryScreen.Prepare(this.canvas); + PrimaryScreen.DrawRecursive(this.canvas); + PrimaryScreen.Present(this.canvas); base.Draw(gameTime); } } + private void AddScreen(UIScreen screen) + { + if (SecondaryScreens.TryGetValue(screen.GetType(), out UIScreen old)) + old.Dispose(); + SecondaryScreens[screen.GetType()] = screen; + } + private void ShowUpdateScreen() { this.AddScreen(new UIUpdateScreen(this, this.announceUpdate)); @@ -196,7 +196,6 @@ private void ShowUpdateScreen() private void UpdateTitle() { - Version = Assembly.GetExecutingAssembly().GetName().Version; string name = Assembly.GetExecutingAssembly().GetCustomAttribute().Title; string extra = Assembly.GetExecutingAssembly() .GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false) @@ -204,21 +203,21 @@ private void UpdateTitle() .FirstOrDefault()?.Description ?? string.Empty; ShortTitle = $"{name} {Version}"; - FullTitle = ShortTitle; - if (!string.IsNullOrWhiteSpace(extra)) - FullTitle += $" {extra}"; + ShortTitle += $" {extra}"; + FullTitle = ShortTitle; if (!string.IsNullOrWhiteSpace(ModderName)) FullTitle += $" - UNOFFICIALLY MODIFIED BY: {ModderName}"; - FullTitle += $" | Minecraft {Config.Tracker.GameVersion}"; - if (Config.Main.FpsCap < 60) - FullTitle += $" | {Config.Main.FpsCap} FPS Cap"; + FullTitle += $" | {Tracker.Category.CurrentVersion} {Tracker.Category.Name}"; if (Tracker.InGameTime > TimeSpan.Zero) - FullTitle += $" | { Tracker.InGameTime} IGT"; + FullTitle += $" | { Tracker.InGameTime:hh':'mm':'ss} IGT"; + if (Config.Main.FpsCap < 60) + FullTitle += $" | {Config.Main.FpsCap.Value} FPS Cap"; if (PrimaryScreen is not null) PrimaryScreen.Form.Text = " " + FullTitle; + } public static void QuitBecause(string reason, Exception exception = null) @@ -241,7 +240,7 @@ public static void QuitBecause(string reason, Exception exception = null) message += $"\n\n{exception.GetType()}:{exception.StackTrace}"; DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result is DialogResult.Yes) - _ = Process.Start(Paths.URL_GITHUB_LATEST); + _ = Process.Start(Paths.Web.LatestRelease); } } } diff --git a/AATool/Paths.cs b/AATool/Paths.cs index e347d789..fed9df69 100644 --- a/AATool/Paths.cs +++ b/AATool/Paths.cs @@ -1,78 +1,134 @@ -using AATool.Settings; +using AATool.Configuration; +using AATool.Data.Categories; +using AATool.UI.Screens; using System; using System.Collections.Generic; using System.IO; +using System.Security; namespace AATool { public static class Paths { - //constant settings paths - public const string DIR_SETTINGS = "settings/"; - public const string DIR_FAVORITES = DIR_SETTINGS + "favorites"; - public const string DIR_NOTES = "notes/"; + public static bool TryGetAllFiles(string path, string pattern, SearchOption search, out IEnumerable files) + { + files = default; + if (Directory.Exists(path)) + { + try + { + files = Directory.EnumerateFiles(path, pattern, search); + return true; + } + catch (ArgumentException) { } + catch (IOException) { } + catch (UnauthorizedAccessException) { } + catch (SecurityException) { } + } + return false; + } + public static class System + { + //constant settings paths + public const string ConfigFolder = "config/"; + public const string LegacySettingsFolder = "settings/"; + public const string ArchivedConfigFolder = "config/legacy_settings_(unused)/"; + public const string NotesFolder = "notes/"; - //remote world temp folder - public const string DIR_TEMP_WORLD = "assets/temp_world/"; - public const string DIR_REMOTE_WORLDS = "assets/remote_worlds"; + //remote world temp folder + public const string RemoteWorldsFolder = "assets/remote_worlds"; - //constant asset paths - public const string DIR_ASSETS = "assets/"; - public const string DIR_GAME_VERSIONS = DIR_ASSETS + "game_versions/"; - public const string DIR_UI_CONTROLS = DIR_ASSETS + "ui/controls"; - public const string DIR_THEMES = DIR_ASSETS + "ui/themes/"; - public const string DIR_GRAPHICS = DIR_ASSETS + "graphics/"; - public const string DIR_SPRITES = DIR_GRAPHICS + "sprites/"; - public const string DIR_FONTS = DIR_GRAPHICS + "fonts/"; - public const string DIR_AVATAR_CACHE = DIR_SPRITES + "skin_cache"; - public const string DIR_CREDITS = DIR_ASSETS + "credits/"; - public const string DIR_LOGS = "logs/"; + //constant asset paths + public const string AssetsFolder = "assets/"; + public const string ObjectivesFolder = AssetsFolder + "objectives/"; + public const string LayoutsFolder = AssetsFolder + "layouts/"; + public const string TemplatesFolder = AssetsFolder + "templates"; + public const string SpritesFolder = AssetsFolder + "sprites/"; + public const string FontsFolder = AssetsFolder + "fonts/"; + public const string AvatarCacheFolder = SpritesFolder + "avatar_cache"; + public const string CreditsFolder = AssetsFolder + "credits/"; + public const string LogsFolder = "logs/"; - //constant urls - public const string URL_GITHUB_LATEST = "https://github.com/DarwinBaker/AATool/releases/latest"; - public const string URL_HELP_OBS = "https://github.com/DarwinBaker/AATool/blob/master/info/obs.md"; - public const string URL_PATREON = "https://www.patreon.com/_ctm"; - public const string URL_PATREON_FRIENDLY = "Patreon.com/_CTM"; - public const string URL_API_MC_UUID = "https://api.mojang.com/users/profiles/minecraft/"; - public const string URL_API_MC_NAME = "https://api.mojang.com/user/profiles/"; + public const string MainIcon = "assets/icons/aatool.ico"; + public const string UpdateIcon = "assets/icons/aaupdate.ico"; - public const string UpdateExecutable = "AAUpdate.exe"; + //constant urls + public const string UpdateExecutable = "AAUpdate.exe"; - //getters for version-dependant folders - public static string CurrentVersionFolder => Path.Combine(DIR_GAME_VERSIONS, Config.Tracker.GameVersion ?? "1.17"); - public static string AdvancementsFolder => Path.Combine(CurrentVersionFolder, "advancements/"); - public static string LayoutsFolder => Path.Combine(CurrentVersionFolder, "layouts/"); + //dependant paths + public static string ObjectiveFolder => Path.Combine(ObjectivesFolder, Tracker.Category.CurrentVersion); + public static string AdvancementsFolder => Path.Combine(ObjectiveFolder, "advancements/"); + public static string BlocksFolder => Path.Combine(ObjectiveFolder, "blocks/"); + public static string AchievementsFile => Path.Combine(ObjectiveFolder, "achievements.xml"); + public static string StatisticsFile => Path.Combine(ObjectiveFolder, "statistics.xml"); + public static string PotionsFile => Path.Combine(ObjectiveFolder, "potions.xml"); - //getters for version-dependant files - public static string AchievementsFile => Path.Combine(CurrentVersionFolder, "achievements.xml"); - public static string StatisticsFile => Path.Combine(CurrentVersionFolder, "statistics.xml"); - public static string PotionsFile => Path.Combine(CurrentVersionFolder, "potions.xml"); - public static string CreditsFile => Path.Combine(DIR_CREDITS, "credits.xml"); + //file getters + public static string CrashLogFile => Path.Combine(LogsFolder, $"crash_report_{DateTime.Now:yyyy_M_dd_h_mm_ss}.txt"); + public static string CreditsFile => Path.Combine(CreditsFolder, "credits.xml"); - public static string CrashLogFile => - Path.Combine(DIR_LOGS, $"crash_report_{DateTime.Now:yyyy_M_dd_h_mm_ss}.txt"); + public static string GetLayoutFor(T screen) where T : UIScreen + { + if (screen is UIMainScreen) + { + string fileName = "main.xml"; + if (Tracker.Category is not (AdventuringTime or BalancedDiet or MonstersHunted)) + { + string variant = Config.Main.RelaxedMode ? "relaxed" : "compact"; + fileName = $"main_{variant}.xml"; + } - public static IEnumerable AdvancementFiles - => Directory.EnumerateFiles(AdvancementsFolder, "*.xml", SearchOption.TopDirectoryOnly); + return Path.Combine(LayoutsFolder, + Tracker.Category.LayoutName, + Tracker.Category.CurrentVersion, + fileName); + } + else if (screen is UIOverlayScreen) + { + return Path.Combine(LayoutsFolder, + Tracker.Category.LayoutName, + $"overlay.xml"); + } + else if (screen is UIUpdateScreen) + { + return Path.Combine(TemplatesFolder, "screen_update.xml"); + } + return string.Empty; + } + } - //getters for ui stuff - public static string GetLayoutFor(string name, string variant = null) + public static class Saves { - return string.IsNullOrEmpty(variant) - ? Path.Combine(LayoutsFolder, $"{name}.xml") - : Path.Combine(LayoutsFolder, $"{name}_{variant}.xml"); - } + public static string CurrentFolder() + { + if (Config.Tracking.UseSftp) + { + return System.RemoteWorldsFolder; + } + else + { + return Config.Tracking.UseDefaultPath + ? DefaultPath + : Config.Tracking.CustomSavePath; + } + } + public static string DefaultPath => Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + ".minecraft", + "saves"); + } - public static string GetStyleFor(string name) => - Path.Combine(DIR_THEMES, name + ".xml"); + public static class Web + { + public const string LatestRelease = "https://github.com/DarwinBaker/AATool/releases/latest"; + public const string ObsHelp = "https://github.com/DarwinBaker/AATool/blob/master/info/obs.md"; + public const string PatreonFull = "https://www.patreon.com/_ctm"; + public const string PatreonShort = "Patreon.com/_CTM"; - //getters for urls - public static string GetUrlForPlayerHead(string uuid, int resolution = 16) => - $"https://crafatar.com/avatars/{uuid}?size={resolution}&overlay=true"; - public static string GetUrlForUUID(string mojangName) => - URL_API_MC_UUID + mojangName; - public static string GetUrlForName(string uuid) => - URL_API_MC_NAME + uuid + "/names"; + public static string GetUuidUrl(string mojangName) => $"https://api.mojang.com/users/profiles/minecraft/{mojangName}"; + public static string GetNameUrl(string uuid) => $"https://api.mojang.com/user/profiles/{uuid}/names"; + public static string GetAvatarUrl(string uuid) => $"https://crafatar.com/avatars/{uuid}?size=16&overlay=true"; + } } } diff --git a/AATool/Program.cs b/AATool/Program.cs index f7d50c25..89e9811b 100644 --- a/AATool/Program.cs +++ b/AATool/Program.cs @@ -33,8 +33,8 @@ static void Main() private static void SaveCrashReport(Exception exception) { - Directory.CreateDirectory(Paths.DIR_LOGS); - using (StreamWriter stream = File.CreateText(Paths.CrashLogFile)) + Directory.CreateDirectory(Paths.System.LogsFolder); + using (StreamWriter stream = File.CreateText(Paths.System.CrashLogFile)) { var mos = new ManagementObjectSearcher("select * from Win32_OperatingSystem"); foreach (ManagementObject managementObject in mos.Get()) diff --git a/AATool/Utilities/ColorHelper.cs b/AATool/Utilities/ColorHelper.cs index bbd19d49..1d3dc056 100644 --- a/AATool/Utilities/ColorHelper.cs +++ b/AATool/Utilities/ColorHelper.cs @@ -18,7 +18,7 @@ public static System.Drawing.Color ToDrawing(Color color) => public static Color FromRGBA(int r, int g, int b, int a) => new (r, g, b, a); public static Color Fade(Color color, float opacity) => new (color.R, color.G, color.B, opacity); - public static Color ColorFromHSV(double hue, double sat, double val) + public static Color FromHSV(double hue, double sat, double val) { int primary = Convert.ToInt32(Math.Floor(hue / 60)) % 6; double f = (hue / 60) - Math.Floor(hue / 60); @@ -88,7 +88,7 @@ public static Color Amplify(Color color, float amount) float h = drawing.GetHue(); float s = drawing.GetSaturation(); float l = drawing.GetBrightness(); - return ColorFromHSV(h, s * amount, l); + return FromHSV(h, s * amount, l); } public static Color GetAccent(Texture2D texture) diff --git a/AATool/Utilities/GameVersionDetector.cs b/AATool/Utilities/GameVersionDetector.cs index 7e959814..7fc3b8e2 100644 --- a/AATool/Utilities/GameVersionDetector.cs +++ b/AATool/Utilities/GameVersionDetector.cs @@ -1,7 +1,7 @@ -using AATool.Settings; -using System; +using System; using System.Runtime.InteropServices; using System.Text; +using AATool.Configuration; namespace AATool.Utilities { @@ -16,7 +16,7 @@ public static class GameVersionDetector public static void Update() { //skip if disabled - if (!Config.Tracker.AutoDetectVersion) + if (!Config.Tracking.AutoDetectVersion) return; //attempt to read active window title @@ -28,7 +28,7 @@ public static void Update() //attempt to parse second word in title as version string[] title = builder.ToString().Split(' '); if (title.Length > 1 && title[0].StartsWith("Minecraft")) - Config.Tracker.TrySetGameVersion(title[1]); + Tracker.TrySetVersion(title[1]); } } } diff --git a/AATool/Utilities/UpdateHelper.cs b/AATool/Utilities/UpdateHelper.cs index 788d5d88..002729f8 100644 --- a/AATool/Utilities/UpdateHelper.cs +++ b/AATool/Utilities/UpdateHelper.cs @@ -15,7 +15,7 @@ public static class UpdateHelper public static void RunAAUpdate(int exitCode) { //start update executable with "return to AATool after" flag - Process.Start(Paths.UpdateExecutable, "-r"); + Process.Start(Paths.System.UpdateExecutable, "-r"); Environment.Exit(exitCode); } diff --git a/AATool/Utilities/XmlObject.cs b/AATool/Utilities/XmlObject.cs index 92c5c07b..b61b7038 100644 --- a/AATool/Utilities/XmlObject.cs +++ b/AATool/Utilities/XmlObject.cs @@ -67,7 +67,7 @@ private static void SetWriterFormatting(XmlTextWriter writer) writer.IndentChar = '\t'; } - public static T ParseAttribute(XmlNode node, string key, T defaultValue) => + public static T Attribute(XmlNode node, string key, T defaultValue) => ParseValue(node?.Attributes[key]?.Value, defaultValue); public static T ParseValue(string value, T defaultValue)