diff --git a/AATool/AATool.csproj b/AATool/AATool.csproj index 69f350ff..a964d31a 100644 --- a/AATool/AATool.csproj +++ b/AATool/AATool.csproj @@ -193,7 +193,6 @@ - @@ -3523,6 +3522,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/AATool/Configuration/SftpConfig.cs b/AATool/Configuration/SftpConfig.cs index 2058943b..3a5ad4b2 100644 --- a/AATool/Configuration/SftpConfig.cs +++ b/AATool/Configuration/SftpConfig.cs @@ -13,6 +13,8 @@ public class SftpConfig : Config [JsonProperty] public readonly Setting Username = new (string.Empty); [JsonProperty] public readonly Setting Password = new (string.Empty); [JsonProperty] public readonly Setting Port = new (22); + [JsonProperty] public readonly Setting AutoSaveMinutes = new (5); + [JsonProperty] public readonly Setting Linux = new (false); [JsonProperty] public readonly Setting ServerRoot = new (string.Empty); diff --git a/AATool/Main.cs b/AATool/Main.cs index 0088b753..1ef791d4 100644 --- a/AATool/Main.cs +++ b/AATool/Main.cs @@ -139,7 +139,6 @@ protected override void Update(GameTime gameTime) ActiveInstance.Update(this.Time); MinecraftServer.Update(this.Time); Tracker.Update(this.Time); - OpenTracker.Update(this.Time); SpriteSheet.Update(this.Time); Canvas.Update(this.Time); diff --git a/AATool/Net/OpenTracker.cs b/AATool/Net/OpenTracker.cs deleted file mode 100644 index 47015b68..00000000 --- a/AATool/Net/OpenTracker.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Net.Http; -using AATool.Configuration; -using AATool.Utilities; - -namespace AATool.Net -{ - static class OpenTracker - { - public static Exception LastError { get; private set; } - public static string WatchUrl { get; private set; } - - private static readonly HttpClient Client = new (); - private static readonly Timer Cooldown = new (5); - - private static bool Invalidated = false; - - public static void Update(Time time) - { - Cooldown.Update(time); - if (Invalidated && !IsOnCooldown) - BroadcastProgress(); - } - - public static bool IsOnCooldown => Cooldown.IsRunning; - - public static async void BroadcastProgress() - { - if (IsOnCooldown) - { - Invalidated = true; - return; - } - - if (string.IsNullOrEmpty(Config.Tracking.OpenTrackerKey)) - return; - if (string.IsNullOrEmpty(Config.Tracking.OpenTrackerUrl)) - return; - - Cooldown.Reset(); - Invalidated = false; - - try - { - string aaKey = AAKey.Strip(Config.Tracking.OpenTrackerKey); - var content = new StringContent(aaKey);// + Tracker.State.ToJsonString()); - HttpResponseMessage response = await Client.PostAsync(Config.Tracking.OpenTrackerUrl, content); - string message = await response.Content.ReadAsStringAsync(); - WatchUrl = message; - LastError = null; - } - catch (Exception e) { LastError = e; } - } - } -} diff --git a/AATool/Properties/AssemblyInfo.cs b/AATool/Properties/AssemblyInfo.cs index 3eb0c60b..a9d360f7 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.7.0.0")] -[assembly: AssemblyFileVersion("1.7.0.0")] +[assembly: AssemblyVersion("1.7.1.0")] +[assembly: AssemblyFileVersion("1.7.1.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/AATool/Saves/MinecraftServer.cs b/AATool/Saves/MinecraftServer.cs index 79993518..61859687 100644 --- a/AATool/Saves/MinecraftServer.cs +++ b/AATool/Saves/MinecraftServer.cs @@ -17,7 +17,6 @@ namespace AATool.Saves public static class MinecraftServer { private const string SftpPrefix = "sftp://"; - private const double SaveInterval = (5 * 60) + 5; private const double RetryInterval = 10; private const int MaximumRetries = 3; private const int AttemptIntervalMs = 5000; @@ -27,14 +26,15 @@ public static class MinecraftServer public static SyncState State { get; private set; } public static string MessageOfTheDay { get; private set; } public static string WorldName { get; private set; } - public static bool LinuxMode { get; private set; } private static readonly Utilities.Timer RefreshTimer = new (); private static ConnectionInfo Credentials; private static int CurrentDownloadPercent; private static float SmoothDownloadPercent; + private static bool LinuxMode; + public static double SaveInterval => (Config.Sftp.AutoSaveMinutes * 60) + 5; public static bool CredentialsValidated => Credentials is not null; public static bool LastSyncFailed => LastError is not null; public static bool IsDownloading => State is SyncState.Advancements or SyncState.Statistics; @@ -48,8 +48,9 @@ public static DateTime GetRefreshEstimate() => IsEnabled ? LastWorldSave.Add(TimeSpan.FromSeconds(SaveInterval)) : default; - public static string HostAwarePath(params string[] paths) => - LinuxMode ? Path.Combine(paths).Replace("\\", "/") : Path.Combine(paths); + public static string HostAwarePath(params string[] paths) => LinuxMode + ? Path.Combine(paths).Replace(@"\", "/") + : Path.Combine(paths).Replace("/", @"\"); public static void Update(Time time) { @@ -80,6 +81,7 @@ public static void Sync() { SftpClient sftp = null; double remaining = 0; + bool success = false; try { if (!TryConnect(out sftp)) @@ -105,7 +107,7 @@ public static void Sync() if (Server.TryGet(out Server server)) server.SendNextRefresh(); - Tracker.Invalidate(); + success = true; } } finally @@ -122,6 +124,12 @@ public static void Sync() if (RefreshTimer.IsExpired || (LastSyncFailed && LastError is not ArgumentException)) RefreshTimer.SetAndStart(RetryInterval); SetState(SyncState.Ready); + + if (success) + { + Tracker.FileSystemChanged(null, null); + Tracker.Invalidate(); + } } }); } @@ -213,6 +221,8 @@ private static void ApplyCredentials() private static bool TryConnect(out SftpClient sftp) { + LinuxMode = Config.Sftp.Linux; + LastError = null; sftp = null; ApplyCredentials(); @@ -321,16 +331,9 @@ private static bool TryGetWorldSaveTime(SftpClient sftp, out DateTime lastWorldS { if (exception is SftpPathNotFoundException) { - if (!LinuxMode) - { - //try switching to linux mode - LinuxMode = true; - Thread.Sleep(AttemptIntervalMs); - return TryGetWorldSaveTime(sftp, out lastWorldSave, failures + 1); - } - //folder not found, world name might be wrong. refresh it next time - LastError = new SftpPathNotFoundException($"File not found: \"{remotePath}\"."); + string otherOS = Config.Sftp.Linux ? "Windows" : "Linux"; + LastError = new SftpPathNotFoundException($"File not found (server might be {otherOS}): \"{remotePath}\"."); InvalidateWorld(); return false; } diff --git a/AATool/Tracker.cs b/AATool/Tracker.cs index bee2fa60..4a3b1214 100644 --- a/AATool/Tracker.cs +++ b/AATool/Tracker.cs @@ -213,7 +213,7 @@ public static void Initialize() TrySetVersion(lastVersion); } - private static void FileSystemChanged(object sender, FileSystemEventArgs e) + public static void FileSystemChanged(object sender, FileSystemEventArgs e) { FileSystemEventRaised = true; } @@ -550,9 +550,6 @@ private static void ParseCoOpProgress(Time time, Client client) SetState(State); - if (Config.Tracking.BroadcastProgress) - OpenTracker.BroadcastProgress(); - LastRefresh = time.TotalSeconds; } } @@ -580,10 +577,6 @@ private static void ReadLocalFiles(Time time) if (Server.TryGet(out Server server) && server.Connected()) server.SendProgress(); - //broadcast progress to opentracker - if (Config.Tracking.BroadcastProgress) - OpenTracker.BroadcastProgress(); - LastRefresh = time.TotalSeconds; } } diff --git a/AATool/UI/Controls/UIPersonalBest.cs b/AATool/UI/Controls/UIPersonalBest.cs index c3905fec..1f9f4719 100644 --- a/AATool/UI/Controls/UIPersonalBest.cs +++ b/AATool/UI/Controls/UIPersonalBest.cs @@ -232,7 +232,22 @@ public override void InitializeRecursive(UIScreen screen) if (!this.IsSmall && this.Run is AllVersionsRun avRun) { - this.age.SetText($"({avRun.Range})"); + this.age.SetText(avRun.NoF3 + ? $"No-F3 ({avRun.Range})" + : $"({avRun.Range})"); + + if (avRun.Hardcore) + { + var icon = new UIPicture() { + FlexWidth = new(9), + FlexHeight = new(9), + HorizontalAlign = HorizontalAlign.Left, + VerticalAlign = VerticalAlign.Top, + Margin = new Margin(108, 0, 29, 0) + }; + icon.SetTexture("av_hardcore"); + this.AddControl(icon); + } } this.face.Glow(); diff --git a/AATool/Winforms/Controls/CTrackerSettings.Designer.cs b/AATool/Winforms/Controls/CTrackerSettings.Designer.cs index 12856356..918c2528 100644 --- a/AATool/Winforms/Controls/CTrackerSettings.Designer.cs +++ b/AATool/Winforms/Controls/CTrackerSettings.Designer.cs @@ -60,7 +60,6 @@ private void InitializeComponent() this.toggleCredentials = new System.Windows.Forms.Button(); this.label4 = new System.Windows.Forms.Label(); this.sftpPass = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.sftpHost = new System.Windows.Forms.TextBox(); this.sftpUser = new System.Windows.Forms.TextBox(); @@ -78,6 +77,11 @@ private void InitializeComponent() this.filterSoloName = new System.Windows.Forms.TextBox(); this.keyboardTimer = new System.Windows.Forms.Timer(this.components); this.label12 = new System.Windows.Forms.Label(); + this.sftpAutoSaveMinutes = new System.Windows.Forms.NumericUpDown(); + this.label14 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.sftpType = new System.Windows.Forms.ComboBox(); + this.label15 = new System.Windows.Forms.Label(); this.localGroup.SuspendLayout(); this.groupBox3.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -86,6 +90,7 @@ private void InitializeComponent() this.groupBox4.SuspendLayout(); this.groupBox5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.soloAvatar)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.sftpAutoSaveMinutes)).BeginInit(); this.SuspendLayout(); // // autoVersion @@ -303,6 +308,10 @@ private void InitializeComponent() // // remoteGroup // + this.remoteGroup.Controls.Add(this.label15); + this.remoteGroup.Controls.Add(this.sftpType); + this.remoteGroup.Controls.Add(this.label14); + this.remoteGroup.Controls.Add(this.sftpAutoSaveMinutes); this.remoteGroup.Controls.Add(this.sftpValidate); this.remoteGroup.Controls.Add(this.label13); this.remoteGroup.Controls.Add(this.sftpCompatibility); @@ -437,16 +446,6 @@ private void InitializeComponent() this.sftpPass.UseSystemPasswordChar = true; this.sftpPass.TextChanged += new System.EventHandler(this.OnTextChanged); // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(6, 68); - this.label3.Margin = new System.Windows.Forms.Padding(3, 6, 3, 0); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(58, 13); - this.label3.TabIndex = 28; - this.label3.Text = "Username:"; - // // label6 // this.label6.AutoSize = true; @@ -641,6 +640,72 @@ private void InitializeComponent() this.label12.TabIndex = 71; this.label12.Text = "🛈 You can open this window by pressing Escape"; // + // sftpAutoSaveMinutes + // + this.sftpAutoSaveMinutes.Location = new System.Drawing.Point(9, 134); + this.sftpAutoSaveMinutes.Maximum = new decimal(new int[] { + 60, + 0, + 0, + 0}); + this.sftpAutoSaveMinutes.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.sftpAutoSaveMinutes.Name = "sftpAutoSaveMinutes"; + this.sftpAutoSaveMinutes.Size = new System.Drawing.Size(45, 20); + this.sftpAutoSaveMinutes.TabIndex = 72; + this.sftpAutoSaveMinutes.Value = new decimal(new int[] { + 5, + 0, + 0, + 0}); + this.sftpAutoSaveMinutes.ValueChanged += new System.EventHandler(this.OnValueChanged); + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(6, 118); + this.label14.Margin = new System.Windows.Forms.Padding(3, 6, 3, 0); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(134, 13); + this.label14.TabIndex = 73; + this.label14.Text = "Server Autosave (minutes):"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 68); + this.label3.Margin = new System.Windows.Forms.Padding(3, 6, 3, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(58, 13); + this.label3.TabIndex = 28; + this.label3.Text = "Username:"; + // + // sftpType + // + this.sftpType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.sftpType.FormattingEnabled = true; + this.sftpType.Items.AddRange(new object[] { + "Windows", + "Linux"}); + this.sftpType.Location = new System.Drawing.Point(175, 129); + this.sftpType.Name = "sftpType"; + this.sftpType.Size = new System.Drawing.Size(96, 21); + this.sftpType.TabIndex = 74; + this.sftpType.SelectedIndexChanged += new System.EventHandler(this.OnIndexChanged); + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(172, 113); + this.label15.Margin = new System.Windows.Forms.Padding(3, 6, 3, 0); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(68, 13); + this.label15.TabIndex = 75; + this.label15.Text = "Server Type:"; + // // CTrackerSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -670,6 +735,7 @@ private void InitializeComponent() this.groupBox5.ResumeLayout(false); this.groupBox5.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.soloAvatar)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.sftpAutoSaveMinutes)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -687,7 +753,6 @@ private void InitializeComponent() private System.Windows.Forms.GroupBox remoteGroup; private System.Windows.Forms.Button sftpValidate; private System.Windows.Forms.TextBox sftpUser; - private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox sftpPass; private System.Windows.Forms.Button toggleCredentials; @@ -724,5 +789,10 @@ private void InitializeComponent() private System.Windows.Forms.Timer keyboardTimer; private System.Windows.Forms.PictureBox soloAvatar; private System.Windows.Forms.Label label12; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.NumericUpDown sftpAutoSaveMinutes; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.ComboBox sftpType; } } diff --git a/AATool/Winforms/Controls/CTrackerSettings.cs b/AATool/Winforms/Controls/CTrackerSettings.cs index 932b2995..014f9832 100644 --- a/AATool/Winforms/Controls/CTrackerSettings.cs +++ b/AATool/Winforms/Controls/CTrackerSettings.cs @@ -52,6 +52,8 @@ public void LoadSettings() this.sftpUser.Text = Config.Sftp.Username; this.sftpPass.Text = Config.Sftp.Password; this.sftpRoot.Text = Config.Sftp.ServerRoot; + this.sftpAutoSaveMinutes.Value = Config.Sftp.AutoSaveMinutes; + this.sftpType.Text = Config.Sftp.Linux ? "Linux" : "Windows"; this.UpdateSaveGroupPanel(); this.UpdateFilterPanel(); @@ -109,6 +111,8 @@ private void SaveSettings() Config.Sftp.Username.Set(this.sftpUser.Text); Config.Sftp.Password.Set(this.sftpPass.Text); Config.Sftp.ServerRoot.Set(this.sftpRoot.Text); + Config.Sftp.AutoSaveMinutes.Set((int)Math.Max(1, this.sftpAutoSaveMinutes.Value)); + Config.Sftp.Linux.Set(this.sftpType.Text == "Linux"); Config.Sftp.TrySave(); } } @@ -305,5 +309,10 @@ private async void TryUpdateSoloFilterAsync(CancellationToken? cancelToken = nul catch { } } } + + private void OnValueChanged(object sender, EventArgs e) + { + this.SaveSettings(); + } } } diff --git a/AATool/assets/sprites/global/gui/icons/av_hardcore.png b/AATool/assets/sprites/global/gui/icons/av_hardcore.png new file mode 100644 index 00000000..d9d6662e Binary files /dev/null and b/AATool/assets/sprites/global/gui/icons/av_hardcore.png differ diff --git a/AATool/assets/views/other/challenges.xml b/AATool/assets/views/other/challenges.xml index 7a54cf4e..5c3fe58f 100644 --- a/AATool/assets/views/other/challenges.xml +++ b/AATool/assets/views/other/challenges.xml @@ -34,27 +34,26 @@ - - - + + - + - + - + - + @@ -69,15 +68,15 @@ - + - + - + - + - +