From 5bf91f189154aa6e65546fa5be30d904c3e26736 Mon Sep 17 00:00:00 2001 From: John Gross Date: Tue, 24 Jul 2018 12:51:13 -0700 Subject: [PATCH] Improve UI layout, add flags enum editor to PropertyGrid --- .../ViewModels/SessionSettingsViewModel.cs | 5 +- Torch.Server/Views/ConfigControl.xaml | 18 ++-- Torch/Torch.csproj | 7 ++ Torch/Views/FlagsEditor.xaml | 30 ++++++ Torch/Views/FlagsEditor.xaml.cs | 85 ++++++++++++++++ Torch/Views/PropertyGrid.xaml | 6 +- Torch/Views/PropertyGrid.xaml.cs | 96 ++++++++++++++++--- 7 files changed, 221 insertions(+), 26 deletions(-) create mode 100644 Torch/Views/FlagsEditor.xaml create mode 100644 Torch/Views/FlagsEditor.xaml.cs diff --git a/Torch.Server/ViewModels/SessionSettingsViewModel.cs b/Torch.Server/ViewModels/SessionSettingsViewModel.cs index 43ecae9..97b6299 100644 --- a/Torch.Server/ViewModels/SessionSettingsViewModel.cs +++ b/Torch.Server/ViewModels/SessionSettingsViewModel.cs @@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using Torch; using Torch.Collections; +using Torch.Views; using VRage.Game; using VRage.Library.Utils; using VRage.Serialization; @@ -202,7 +203,7 @@ namespace Torch.Server.ViewModels public bool EnableSpiders { get => _settings.EnableSpiders; set => SetValue(ref _settings.EnableSpiders, value); } [Torch.Views.Display(Name = "Block Type World Limits", GroupName = "Block Limits")] - public SerializableDictionary BlockTypeLimits; + public Dictionary BlockTypeLimits { get => _settings.BlockTypeLimits.Dictionary; set => SetValue(x => _settings.BlockTypeLimits.Dictionary = x, value); } [Torch.Views.Display(Description = "Enables scripter role for administration.", Name = "Enable Scripter Role", GroupName = "Others")] public bool EnableScripterRole { get => _settings.EnableScripterRole; set => SetValue(ref _settings.EnableScripterRole, value); } @@ -235,7 +236,7 @@ namespace Torch.Server.ViewModels public bool TrashRemovalEnabled { get => _settings.TrashRemovalEnabled; set => SetValue(ref _settings.TrashRemovalEnabled, value); } [Torch.Views.Display(Description = "Defines flags for trash removal system.", Name = "Trash Removal Flags", GroupName = "Trash Removal")] - public int TrashFlagsValue { get => _settings.TrashFlagsValue; set => SetValue(ref _settings.TrashFlagsValue, value); } + public MyTrashRemovalFlags TrashFlagsValue { get => (MyTrashRemovalFlags)_settings.TrashFlagsValue; set => SetValue(ref _settings.TrashFlagsValue, (int)value); } [Torch.Views.Display(Description = "Defines block count threshold for trash removal system.", Name = "Block Count Threshold", GroupName = "Trash Removal")] public int BlockCountThreshold { get => _settings.BlockCountThreshold; set => SetValue(ref _settings.BlockCountThreshold, value); } diff --git a/Torch.Server/Views/ConfigControl.xaml b/Torch.Server/Views/ConfigControl.xaml index 43ac44e..dc8507b 100644 --- a/Torch.Server/Views/ConfigControl.xaml +++ b/Torch.Server/Views/ConfigControl.xaml @@ -26,7 +26,7 @@