From 905ab7cf98e8cdc860eaa2e00da5c8f3a161c68e Mon Sep 17 00:00:00 2001 From: Asval Date: Fri, 11 Oct 2024 18:20:35 +0200 Subject: [PATCH] actually removed update modes + uemodel texture export --- CUE4Parse | 2 +- FModel/Enums.cs | 21 +++--- FModel/MainWindow.xaml.cs | 2 +- FModel/Settings/UserSettings.cs | 7 -- .../ApiEndpoints/FModelApiEndpoint.cs | 40 +++-------- .../ApiEndpoints/GitHubApiEndpoint.cs | 2 - FModel/ViewModels/Commands/RemindMeCommand.cs | 4 +- FModel/ViewModels/SettingsViewModel.cs | 17 ----- FModel/ViewModels/UpdateViewModel.cs | 2 +- .../Resources/Controls/CommitControl.xaml | 4 +- FModel/Views/SettingsView.xaml | 71 ++++++++----------- FModel/Views/SettingsView.xaml.cs | 3 - 12 files changed, 57 insertions(+), 118 deletions(-) diff --git a/CUE4Parse b/CUE4Parse index 5c20bd5d..9530c271 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 5c20bd5d322a7cc0eb4ad45e911adbf2ce30c55a +Subproject commit 9530c271c8d61e03c678200fea760b0660ebe029 diff --git a/FModel/Enums.cs b/FModel/Enums.cs index 8231f7b6..1412b013 100644 --- a/FModel/Enums.cs +++ b/FModel/Enums.cs @@ -20,8 +20,7 @@ public enum EErrorKind public enum SettingsOut { ReloadLocres, - ReloadMappings, - CheckForUpdates + ReloadMappings } public enum EStatusKind @@ -64,15 +63,15 @@ public enum ELoadingMode AllButModified } -public enum EUpdateMode -{ - [Description("Stable")] - Stable, - [Description("Beta")] - Beta, - [Description("QA Testing")] - Qa -} +// public enum EUpdateMode +// { +// [Description("Stable")] +// Stable, +// [Description("Beta")] +// Beta, +// [Description("QA Testing")] +// Qa +// } public enum ECompressedAudio { diff --git a/FModel/MainWindow.xaml.cs b/FModel/MainWindow.xaml.cs index 6dcede02..1fe3623a 100644 --- a/FModel/MainWindow.xaml.cs +++ b/FModel/MainWindow.xaml.cs @@ -47,7 +47,7 @@ public partial class MainWindow { var newOrUpdated = UserSettings.Default.ShowChangelog; #if !DEBUG - ApplicationService.ApiEndpointView.FModelApi.CheckForUpdates(UserSettings.Default.UpdateMode, true); + ApplicationService.ApiEndpointView.FModelApi.CheckForUpdates(true); #endif switch (UserSettings.Default.AesReload) diff --git a/FModel/Settings/UserSettings.cs b/FModel/Settings/UserSettings.cs index e11863fe..f6d31036 100644 --- a/FModel/Settings/UserSettings.cs +++ b/FModel/Settings/UserSettings.cs @@ -179,13 +179,6 @@ namespace FModel.Settings set => SetProperty(ref _loadingMode, value); } - private EUpdateMode _updateMode = EUpdateMode.Beta; - public EUpdateMode UpdateMode - { - get => _updateMode; - set => SetProperty(ref _updateMode, value); - } - private DateTime _lastUpdateCheck = DateTime.MinValue; public DateTime LastUpdateCheck { diff --git a/FModel/ViewModels/ApiEndpoints/FModelApiEndpoint.cs b/FModel/ViewModels/ApiEndpoints/FModelApiEndpoint.cs index 04691521..90684479 100644 --- a/FModel/ViewModels/ApiEndpoints/FModelApiEndpoint.cs +++ b/FModel/ViewModels/ApiEndpoints/FModelApiEndpoint.cs @@ -17,7 +17,6 @@ using Serilog; using MessageBox = AdonisUI.Controls.MessageBox; using MessageBoxButton = AdonisUI.Controls.MessageBoxButton; using MessageBoxImage = AdonisUI.Controls.MessageBoxImage; -using MessageBoxResult = AdonisUI.Controls.MessageBoxResult; namespace FModel.ViewModels.ApiEndpoints; @@ -47,19 +46,6 @@ public class FModelApiEndpoint : AbstractApiProvider return _news ??= GetNewsAsync(token, game).GetAwaiter().GetResult(); } - public async Task GetInfosAsync(CancellationToken token, EUpdateMode updateMode) - { - var request = new FRestRequest($"https://api.fmodel.app/v1/infos/{updateMode}"); - var response = await _client.ExecuteAsync(request, token).ConfigureAwait(false); - Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, response.ResponseUri?.OriginalString); - return response.Data; - } - - public Info GetInfos(CancellationToken token, EUpdateMode updateMode) - { - return _infos ?? GetInfosAsync(token, updateMode).GetAwaiter().GetResult(); - } - public async Task GetDonatorsAsync() { var request = new FRestRequest($"https://api.fmodel.app/v1/donations/donators"); @@ -117,7 +103,7 @@ public class FModelApiEndpoint : AbstractApiProvider return communityDesign; } - public void CheckForUpdates(EUpdateMode updateMode, bool launch = false) + public void CheckForUpdates(bool launch = false) { if (DateTime.Now < UserSettings.Default.NextUpdateCheck) return; @@ -126,7 +112,7 @@ public class FModelApiEndpoint : AbstractApiProvider AutoUpdater.ParseUpdateInfoEvent += ParseUpdateInfoEvent; AutoUpdater.CheckForUpdateEvent += CheckForUpdateEvent; } - AutoUpdater.Start($"https://api.fmodel.app/v1/infos/{updateMode}"); + AutoUpdater.Start("https://api.fmodel.app/v1/infos/Qa"); } private void ParseUpdateInfoEvent(ParseUpdateInfoEventArgs args) @@ -139,10 +125,9 @@ public class FModelApiEndpoint : AbstractApiProvider CurrentVersion = _infos.Version.SubstringBefore('-'), ChangelogURL = _infos.ChangelogUrl, DownloadURL = _infos.DownloadUrl, - Mandatory = new CustomMandatory + Mandatory = new Mandatory { - Value = UserSettings.Default.UpdateMode == EUpdateMode.Qa, - CommitHash = _infos.Version.SubstringAfter('+') + MinimumVersion = _infos.Version.SubstringAfter('+') } }; } @@ -154,16 +139,17 @@ public class FModelApiEndpoint : AbstractApiProvider { UserSettings.Default.LastUpdateCheck = DateTime.Now; - var qa = (CustomMandatory) args.Mandatory; - var currentVersion = new System.Version(args.CurrentVersion); - if ((qa.Value && qa.CommitHash == Constants.APP_COMMIT_ID) || // qa branch : same commit id - (!qa.Value && currentVersion == args.InstalledVersion)) // stable - beta branch : same version + commit id = version + if (args.Mandatory.MinimumVersion == Constants.APP_COMMIT_ID) { if (UserSettings.Default.ShowChangelog) ShowChangelog(args); + return; } + var currentVersion = new System.Version(args.CurrentVersion); + UserSettings.Default.ShowChangelog = currentVersion != args.InstalledVersion; + const string message = "A new update is available!"; Helper.OpenWindow(message, () => new UpdateView { Title = message, ResizeMode = ResizeMode.NoResize }.ShowDialog()); } @@ -179,7 +165,7 @@ public class FModelApiEndpoint : AbstractApiProvider { var request = new FRestRequest(args.ChangelogURL); var response = _client.Execute(request); - if (string.IsNullOrEmpty(response.Content)) return; + if (!response.IsSuccessful || string.IsNullOrEmpty(response.Content)) return; _applicationView.CUE4Parse.TabControl.AddTab($"Release Notes: {args.CurrentVersion}"); _applicationView.CUE4Parse.TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("changelog"); @@ -187,9 +173,3 @@ public class FModelApiEndpoint : AbstractApiProvider UserSettings.Default.ShowChangelog = false; } } - -public class CustomMandatory : Mandatory -{ - public string CommitHash { get; set; } - public string ShortCommitHash => CommitHash[..7]; -} diff --git a/FModel/ViewModels/ApiEndpoints/GitHubApiEndpoint.cs b/FModel/ViewModels/ApiEndpoints/GitHubApiEndpoint.cs index e6b2761d..94fbb075 100644 --- a/FModel/ViewModels/ApiEndpoints/GitHubApiEndpoint.cs +++ b/FModel/ViewModels/ApiEndpoints/GitHubApiEndpoint.cs @@ -7,8 +7,6 @@ namespace FModel.ViewModels.ApiEndpoints; public class GitHubApiEndpoint : AbstractApiProvider { - private GitHubCommit[] _commits; - public GitHubApiEndpoint(RestClient client) : base(client) { } public async Task GetCommitHistoryAsync(string branch = "dev", int page = 1, int limit = 20) diff --git a/FModel/ViewModels/Commands/RemindMeCommand.cs b/FModel/ViewModels/Commands/RemindMeCommand.cs index 7c78a952..21464761 100644 --- a/FModel/ViewModels/Commands/RemindMeCommand.cs +++ b/FModel/ViewModels/Commands/RemindMeCommand.cs @@ -20,8 +20,8 @@ public class RemindMeCommand : ViewModelCommand break; case "Week": // check for update next week (a week starts on Monday) - var delay = DayOfWeek.Monday - DateTime.Now.DayOfWeek; - UserSettings.Default.NextUpdateCheck = DateTime.Now.AddDays(delay); + var delay = (DayOfWeek.Monday - DateTime.Now.DayOfWeek + 7) % 7; + UserSettings.Default.NextUpdateCheck = DateTime.Now.AddDays(delay == 0 ? 7 : delay); break; case "Month": // check for update next month (if today is 31st, it will be 1st of next month) diff --git a/FModel/ViewModels/SettingsViewModel.cs b/FModel/ViewModels/SettingsViewModel.cs index b75ebf5b..c5601724 100644 --- a/FModel/ViewModels/SettingsViewModel.cs +++ b/FModel/ViewModels/SettingsViewModel.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Windows; using CUE4Parse.UE4.Assets.Exports.Texture; using CUE4Parse.UE4.Objects.Core.Serialization; using CUE4Parse.UE4.Versions; @@ -27,13 +26,6 @@ public class SettingsViewModel : ViewModel set => SetProperty(ref _useCustomOutputFolders, value); } - private EUpdateMode _selectedUpdateMode; - public EUpdateMode SelectedUpdateMode - { - get => _selectedUpdateMode; - set => SetProperty(ref _selectedUpdateMode, value); - } - private ETexturePlatform _selectedUePlatform; public ETexturePlatform SelectedUePlatform { @@ -168,7 +160,6 @@ public class SettingsViewModel : ViewModel public bool SocketSettingsEnabled => SelectedMeshExportFormat == EMeshFormat.ActorX; public bool CompressionSettingsEnabled => SelectedMeshExportFormat == EMeshFormat.UEFormat; - public ReadOnlyObservableCollection UpdateModes { get; private set; } public ReadOnlyObservableCollection UeGames { get; private set; } public ReadOnlyObservableCollection AssetLanguages { get; private set; } public ReadOnlyObservableCollection AesReloads { get; private set; } @@ -190,7 +181,6 @@ public class SettingsViewModel : ViewModel private string _audioSnapshot; private string _modelSnapshot; private string _gameSnapshot; - private EUpdateMode _updateModeSnapshot; private ETexturePlatform _uePlatformSnapshot; private EGame _ueGameSnapshot; private IList _customVersionsSnapshot; @@ -222,7 +212,6 @@ public class SettingsViewModel : ViewModel _audioSnapshot = UserSettings.Default.AudioDirectory; _modelSnapshot = UserSettings.Default.ModelDirectory; _gameSnapshot = UserSettings.Default.GameDirectory; - _updateModeSnapshot = UserSettings.Default.UpdateMode; _uePlatformSnapshot = UserSettings.Default.CurrentDir.TexturePlatform; _ueGameSnapshot = UserSettings.Default.CurrentDir.UeVersion; _customVersionsSnapshot = UserSettings.Default.CurrentDir.Versioning.CustomVersions; @@ -247,7 +236,6 @@ public class SettingsViewModel : ViewModel _materialExportFormatSnapshot = UserSettings.Default.MaterialExportFormat; _textureExportFormatSnapshot = UserSettings.Default.TextureExportFormat; - SelectedUpdateMode = _updateModeSnapshot; SelectedUePlatform = _uePlatformSnapshot; SelectedUeGame = _ueGameSnapshot; SelectedCustomVersions = _customVersionsSnapshot; @@ -265,7 +253,6 @@ public class SettingsViewModel : ViewModel SelectedAesReload = UserSettings.Default.AesReload; SelectedDiscordRpc = UserSettings.Default.DiscordRpc; - UpdateModes = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUpdateModes())); UeGames = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateUeGames())); AssetLanguages = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateAssetLanguages())); AesReloads = new ReadOnlyObservableCollection(new ObservableCollection(EnumerateAesReloads())); @@ -290,8 +277,6 @@ public class SettingsViewModel : ViewModel whatShouldIDo.Add(SettingsOut.ReloadLocres); if (_mappingsUpdate) whatShouldIDo.Add(SettingsOut.ReloadMappings); - if (_updateModeSnapshot != SelectedUpdateMode) - whatShouldIDo.Add(SettingsOut.CheckForUpdates); if (_ueGameSnapshot != SelectedUeGame || _customVersionsSnapshot != SelectedCustomVersions || _uePlatformSnapshot != SelectedUePlatform || _optionsSnapshot != SelectedOptions || // combobox @@ -305,7 +290,6 @@ public class SettingsViewModel : ViewModel _gameSnapshot != UserSettings.Default.GameDirectory) // textbox restart = true; - UserSettings.Default.UpdateMode = SelectedUpdateMode; UserSettings.Default.CurrentDir.UeVersion = SelectedUeGame; UserSettings.Default.CurrentDir.TexturePlatform = SelectedUePlatform; UserSettings.Default.CurrentDir.Versioning.CustomVersions = SelectedCustomVersions; @@ -330,7 +314,6 @@ public class SettingsViewModel : ViewModel return restart; } - private IEnumerable EnumerateUpdateModes() => Enum.GetValues(); private IEnumerable EnumerateUeGames() => Enum.GetValues() .GroupBy(value => (int)value) diff --git a/FModel/ViewModels/UpdateViewModel.cs b/FModel/ViewModels/UpdateViewModel.cs index 55d85209..f1ee7567 100644 --- a/FModel/ViewModels/UpdateViewModel.cs +++ b/FModel/ViewModels/UpdateViewModel.cs @@ -57,7 +57,7 @@ public class UpdateViewModel : ViewModel Sha = commitSha, Commit = new Commit { - Message = "No commit message", + Message = $"FModel ({commitSha[..7]})", Author = new Author { Name = asset.Uploader.Login, Date = asset.CreatedAt } }, Author = asset.Uploader, diff --git a/FModel/Views/Resources/Controls/CommitControl.xaml b/FModel/Views/Resources/Controls/CommitControl.xaml index 00d331e4..c1cf82b4 100644 --- a/FModel/Views/Resources/Controls/CommitControl.xaml +++ b/FModel/Views/Resources/Controls/CommitControl.xaml @@ -27,7 +27,7 @@ - +