diff --git a/FloatTool/Common/Utils.cs b/FloatTool/Common/Utils.cs index 7b1dcb5..e155bf4 100644 --- a/FloatTool/Common/Utils.cs +++ b/FloatTool/Common/Utils.cs @@ -96,7 +96,7 @@ public static string FirstCharToUpper(this string input) => public static class Utils { - public const string API_URL = "https://prevterapi.000webhostapp.com"; + public const string API_URL = "https://git.prevter.ml/api/floattool"; private static readonly HttpClient Client = new(); public static async Task GetWearFromInspectURL(string inspect_url) diff --git a/FloatTool/Languages/Lang.uk.xaml b/FloatTool/Languages/Lang.uk.xaml index 97afd5a..68681fc 100644 --- a/FloatTool/Languages/Lang.uk.xaml +++ b/FloatTool/Languages/Lang.uk.xaml @@ -60,7 +60,8 @@ Потоків Поток Опублікувати результат - + Показувати тільки поточну версію + Скопіювати Можливий флоат: diff --git a/FloatTool/Languages/Lang.xaml b/FloatTool/Languages/Lang.xaml index 22833ae..27e4c31 100644 --- a/FloatTool/Languages/Lang.xaml +++ b/FloatTool/Languages/Lang.xaml @@ -60,6 +60,7 @@ Threads Thread Publish result + Show only current version Copy diff --git a/FloatTool/ViewModels/BenchmarkViewModel.cs b/FloatTool/ViewModels/BenchmarkViewModel.cs index 19e2593..c13ff1a 100644 --- a/FloatTool/ViewModels/BenchmarkViewModel.cs +++ b/FloatTool/ViewModels/BenchmarkViewModel.cs @@ -48,7 +48,16 @@ public class BenchmarkResult private int progressPercentage; private bool buttonsEnabled = true; private bool canPublish = false; + private bool showOnlyCurrent = false; + private int multithreadedSpeed = 0; + private int threadCount = Environment.ProcessorCount; + private int singlethreadedSpeed = 0; + private bool isUpdatingEnabled; + private static readonly LinearGradientBrush AMDBrush = Application.Current.Resources["AmdBenchmarkFill"] as LinearGradientBrush; + private static readonly LinearGradientBrush IntelBrush = Application.Current.Resources["IntelBenchmarkFill"] as LinearGradientBrush; + private static readonly LinearGradientBrush CurrentBrush = Application.Current.Resources["CurrentBenchmarkFill"] as LinearGradientBrush; + public int ProgressPercentage { get { return progressPercentage; } @@ -77,8 +86,7 @@ public bool CanPublish OnPropertyChanged(); } } - - private int threadCount = Environment.ProcessorCount; + public int ThreadCount { get @@ -91,8 +99,20 @@ public int ThreadCount OnPropertyChanged(); } } + public bool ShowOnlyCurrent + { + get + { + return showOnlyCurrent; + } + set + { + showOnlyCurrent = value; + PollBenchmarkResults(); + OnPropertyChanged(); + } + } - private int multithreadedSpeed = 0; public int MultithreadedSpeed { get { return multithreadedSpeed; } @@ -104,7 +124,6 @@ public int MultithreadedSpeed } public string MultithreadedSpeedText { get { return $"{multithreadedSpeed:n0}"; } } - private int singlethreadedSpeed = 0; public int SinglethreadedSpeed { get { return singlethreadedSpeed; } @@ -120,11 +139,6 @@ public int SinglethreadedSpeed public string CurrentCpuName { get; set; } public static string CurrentCpuThreads { get { return $"{Environment.ProcessorCount}"; } } - private static readonly LinearGradientBrush AMDBrush = Application.Current.Resources["AmdBenchmarkFill"] as LinearGradientBrush; - private static readonly LinearGradientBrush IntelBrush = Application.Current.Resources["IntelBenchmarkFill"] as LinearGradientBrush; - private static readonly LinearGradientBrush CurrentBrush = Application.Current.Resources["CurrentBenchmarkFill"] as LinearGradientBrush; - - private bool isUpdatingEnabled; public bool IsUpdatingEnabled { get { return isUpdatingEnabled; } @@ -133,13 +147,16 @@ public bool IsUpdatingEnabled public async void PollBenchmarkResults() { - Logger.Log.Info("Getting benchmark results"); + var url = Utils.API_URL + "/load"; + if (ShowOnlyCurrent) url += $"?version={AppHelpers.VersionCode}"; + Logger.Log.Info($"Getting benchmark results from {url}"); IsUpdatingEnabled = false; try { BenchmarkResults.Clear(); using var client = new HttpClient(); - HttpResponseMessage response = await client.GetAsync(Utils.API_URL + "/LoadBenchmarks.php"); + + HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); dynamic result = JsonConvert.DeserializeObject(responseBody); @@ -181,13 +198,16 @@ public async void PollBenchmarkResults() } } - Logger.Log.Info("Benchmark results loaded"); + Logger.Log.Info($"Benchmark results loaded: {BenchmarkResults.Count} items"); + + if (BenchmarkResults.Count == 0) + throw new Exception("0 results"); } catch (Exception ex) { BenchmarkResults.Add(new BenchmarkResult { - CpuName = "Error loading benchmark table.", + CpuName = "Error loading benchmark table: " + ex.Message, FillSize = new GridLength(0, GridUnitType.Star), EmptySize = new GridLength(1, GridUnitType.Star), }); @@ -205,7 +225,7 @@ public async void PushBenchmarkResults() using var client = new HttpClient(); var version = Assembly.GetExecutingAssembly().GetName().Version; client.DefaultRequestHeaders.Add("User-Agent", $"FloatTool/{AppHelpers.VersionCode}"); - string paramedURL = $"/AddBenchmark.php?cpu={CurrentCpuName}&threads={ThreadCount}&multicore={MultithreadedSpeed}&singlecore={SinglethreadedSpeed}"; + string paramedURL = $"/submit?cpu={CurrentCpuName}&threads={ThreadCount}&multicore={MultithreadedSpeed}&singlecore={SinglethreadedSpeed}"; HttpResponseMessage response = await client.GetAsync(Utils.API_URL + paramedURL); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/FloatTool/Views/BenchmarkWindow.xaml b/FloatTool/Views/BenchmarkWindow.xaml index 26ae912..902d159 100644 --- a/FloatTool/Views/BenchmarkWindow.xaml +++ b/FloatTool/Views/BenchmarkWindow.xaml @@ -83,6 +83,12 @@ + diff --git a/FloatTool/Views/MainWindow.xaml.cs b/FloatTool/Views/MainWindow.xaml.cs index e8ef4ff..c460f82 100644 --- a/FloatTool/Views/MainWindow.xaml.cs +++ b/FloatTool/Views/MainWindow.xaml.cs @@ -123,10 +123,10 @@ private void Window_KeyUp(object sender, KeyEventArgs e) switch (e.Key) { case Key.F1: - Process.Start(new ProcessStartInfo { FileName = "https://prevter.github.io/FloatTool/table.html", UseShellExecute = true }); + Process.Start(new ProcessStartInfo { FileName = "https://git.prevter.ml/floattool/table", UseShellExecute = true }); break; case Key.F2: - Process.Start(new ProcessStartInfo { FileName = "https://prevter.github.io/FloatTool/utils.html", UseShellExecute = true }); + Process.Start(new ProcessStartInfo { FileName = "https://git.prevter.ml/floattool/tools", UseShellExecute = true }); break; case Key.F3: string skin = $"{ViewModel.WeaponName} | {ViewModel.SkinName}";