diff --git a/OF DL.Gui/ViewModels/ConfigCategoryViewModel.cs b/OF DL.Gui/ViewModels/ConfigCategoryViewModel.cs index 8b2ae48..2b20cdc 100644 --- a/OF DL.Gui/ViewModels/ConfigCategoryViewModel.cs +++ b/OF DL.Gui/ViewModels/ConfigCategoryViewModel.cs @@ -16,6 +16,8 @@ public sealed class ConfigCategoryViewModel : ViewModelBase string.Equals(field.PropertyName, nameof(Config.DownloadDateSelection), StringComparison.Ordinal)); CustomDateField = fieldList.FirstOrDefault(field => string.Equals(field.PropertyName, nameof(Config.CustomDate), StringComparison.Ordinal)); + DownloadVideoResolutionField = fieldList.FirstOrDefault(field => + string.Equals(field.PropertyName, nameof(Config.DownloadVideoResolution), StringComparison.Ordinal)); LimitDownloadRateField = fieldList.FirstOrDefault(field => string.Equals(field.PropertyName, nameof(Config.LimitDownloadRate), StringComparison.Ordinal)); @@ -34,7 +36,8 @@ public sealed class ConfigCategoryViewModel : ViewModelBase IEnumerable visibleFields = IsDownloadBehavior ? fieldList.Where(field => field.PropertyName is not nameof(Config.DownloadOnlySpecificDates) and not nameof(Config.DownloadDateSelection) - and not nameof(Config.CustomDate)) + and not nameof(Config.CustomDate) + and not nameof(Config.DownloadVideoResolution)) : IsPerformance ? fieldList.Where(field => field.PropertyName is not nameof(Config.LimitDownloadRate) and not nameof(Config.DownloadLimitInMbPerSec)) @@ -71,6 +74,8 @@ public sealed class ConfigCategoryViewModel : ViewModelBase public ConfigFieldViewModel? CustomDateField { get; } + public ConfigFieldViewModel? DownloadVideoResolutionField { get; } + public ConfigFieldViewModel? LimitDownloadRateField { get; } public ConfigFieldViewModel? DownloadLimitInMbPerSecField { get; } @@ -88,6 +93,8 @@ public sealed class ConfigCategoryViewModel : ViewModelBase DownloadDateSelectionField != null && CustomDateField != null; + public bool HasDownloadVideoResolutionField => DownloadVideoResolutionField != null; + public bool HasRateLimitFields => LimitDownloadRateField != null && DownloadLimitInMbPerSecField != null; diff --git a/OF DL.Gui/ViewModels/MainWindowViewModel.cs b/OF DL.Gui/ViewModels/MainWindowViewModel.cs index d00d400..2cb6c2b 100644 --- a/OF DL.Gui/ViewModels/MainWindowViewModel.cs +++ b/OF DL.Gui/ViewModels/MainWindowViewModel.cs @@ -494,6 +494,7 @@ public partial class MainWindowViewModel( } _configReturnScreen = CurrentScreen; + EnforceGuiOnlyConfigValues(configService.CurrentConfig); BuildConfigFields(configService.CurrentConfig); ConfigScreenMessage = "Edit configuration values and save to apply changes."; StatusMessage = "Editing configuration."; @@ -504,6 +505,7 @@ public partial class MainWindowViewModel( private async Task CancelConfigAsync() { bool loaded = await configService.LoadConfigurationAsync([]); + EnforceGuiOnlyConfigValues(configService.CurrentConfig); BuildConfigFields(configService.CurrentConfig); if (!loaded) @@ -569,10 +571,12 @@ public partial class MainWindowViewModel( return; } + EnforceGuiOnlyConfigValues(newConfig); configService.UpdateConfig(newConfig); await configService.SaveConfigurationAsync(); bool reloaded = await configService.LoadConfigurationAsync([]); + EnforceGuiOnlyConfigValues(configService.CurrentConfig); if (!reloaded) { ConfigScreenMessage = "config.conf could not be loaded after saving. Please review your values."; @@ -901,11 +905,13 @@ public partial class MainWindowViewModel( ApplyThemeFromConfigFileIfAvailable(); _configReturnScreen = CurrentScreen; SetLoading("Loading configuration..."); + EnforceGuiOnlyConfigValues(configService.CurrentConfig); BuildConfigFields(configService.CurrentConfig); UserLists.Clear(); AvailableUsers.Clear(); bool configLoaded = await configService.LoadConfigurationAsync([]); + EnforceGuiOnlyConfigValues(configService.CurrentConfig); BuildConfigFields(configService.CurrentConfig); if (!configLoaded) { @@ -1110,6 +1116,7 @@ public partial class MainWindowViewModel( private bool TryBuildConfig(out Config config) { config = CloneConfig(configService.CurrentConfig); + EnforceGuiOnlyConfigValues(config); ClearSpecialConfigErrors(); Dictionary parsedValues = new(StringComparer.Ordinal); Dictionary fieldMap = ConfigFields @@ -1144,6 +1151,7 @@ public partial class MainWindowViewModel( } ApplySpecialConfigValues(config); + EnforceGuiOnlyConfigValues(config); config.CreatorConfigs = CreatorConfigEditor.ToDictionary(); ValidateSpecialConfigValues(); if (HasSpecialConfigErrors()) @@ -1218,25 +1226,36 @@ public partial class MainWindowViewModel( .OrderBy(group => GetCategoryOrder(group.Key)) .ThenBy(group => group.Key); - int categoryIndex = 0; + List orderedCategories = []; foreach (IGrouping group in grouped) { - IEnumerable orderedFields = group.Key == "File Naming" + IEnumerable orderedFields = group.Key is "File Naming" or "Download Behavior" ? group.OrderBy(field => GetFieldOrder(group.Key, field.PropertyName)) : group.OrderBy(field => field.DisplayName); ConfigCategoryViewModel category = new(group.Key, orderedFields); + orderedCategories.Add(category); ConfigCategories.Add(category); - if (categoryIndex % 2 == 0) - { - ConfigCategoriesLeft.Add(category); - } - else - { - ConfigCategoriesRight.Add(category); - } + } - categoryIndex++; + foreach (ConfigCategoryViewModel category in orderedCategories + .Where(category => IsLeftColumnCategory(category.CategoryName)) + .OrderBy(category => GetLeftColumnCategoryOrder(category.CategoryName))) + { + ConfigCategoriesLeft.Add(category); + } + + foreach (ConfigCategoryViewModel category in orderedCategories + .Where(category => IsRightColumnCategory(category.CategoryName)) + .OrderBy(category => GetRightColumnCategoryOrder(category.CategoryName))) + { + ConfigCategoriesRight.Add(category); + } + + foreach (ConfigCategoryViewModel category in orderedCategories.Where(category => + !IsLeftColumnCategory(category.CategoryName) && !IsRightColumnCategory(category.CategoryName))) + { + ConfigCategoriesLeft.Add(category); } } @@ -1256,6 +1275,22 @@ public partial class MainWindowViewModel( }; } + if (categoryName == "Download Behavior") + { + return propertyName switch + { + nameof(Config.DownloadVideoResolution) => 0, + nameof(Config.DownloadPostsIncrementally) => 1, + nameof(Config.DownloadDuplicatedMedia) => 2, + nameof(Config.SkipAds) => 3, + nameof(Config.IgnoreOwnMessages) => 4, + nameof(Config.DisableTextSanitization) => 5, + nameof(Config.BypassContentForCreatorsWhoNoLongerExist) => 6, + nameof(Config.ShowScrapeSize) => 7, + _ => 100 + }; + } + return 0; } @@ -1604,6 +1639,11 @@ public partial class MainWindowViewModel( return JsonConvert.DeserializeObject(json) ?? new Config(); } + private static void EnforceGuiOnlyConfigValues(Config config) + { + config.ShowScrapeSize = false; + } + private static bool IsHiddenConfigField(string propertyName) => propertyName is nameof(Config.NonInteractiveMode) or nameof(Config.NonInteractiveModeListName) @@ -1624,7 +1664,8 @@ public partial class MainWindowViewModel( or nameof(Config.DownloadStories) or nameof(Config.DownloadHighlights) or nameof(Config.DownloadMessages) - or nameof(Config.DownloadPaidMessages); + or nameof(Config.DownloadPaidMessages) + or nameof(Config.ShowScrapeSize); private static string GetConfigCategory(string propertyName) => propertyName switch @@ -1700,4 +1741,29 @@ public partial class MainWindowViewModel( "Logging" => 9, _ => 100 }; + + private static bool IsLeftColumnCategory(string categoryName) => + categoryName is "Appearance" or "Logging" or "Download Behavior" or "Subscriptions"; + + private static bool IsRightColumnCategory(string categoryName) => + categoryName is "File Naming" or "Folder Structure" or "Performance"; + + private static int GetLeftColumnCategoryOrder(string categoryName) => + categoryName switch + { + "Appearance" => 1, + "Logging" => 2, + "Download Behavior" => 3, + "Subscriptions" => 4, + _ => 100 + }; + + private static int GetRightColumnCategoryOrder(string categoryName) => + categoryName switch + { + "File Naming" => 1, + "Folder Structure" => 2, + "Performance" => 3, + _ => 100 + }; } diff --git a/OF DL.Gui/Views/MainWindow.axaml b/OF DL.Gui/Views/MainWindow.axaml index 3ce583c..82b4cd2 100644 --- a/OF DL.Gui/Views/MainWindow.axaml +++ b/OF DL.Gui/Views/MainWindow.axaml @@ -117,87 +117,8 @@ - - - - - - -