From a54f1e538141554b0c80241de33904dcc7ef3408 Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Sat, 19 Jun 2021 15:34:44 +1000 Subject: [PATCH] Added new section to handle the PreventTransferForClassNames settings. --- src/ARKServerManager/ARKServerManager.csproj | 1 + src/ARKServerManager/App.config | 6 + src/ARKServerManager/Config.Designer.cs | 24 +++ src/ARKServerManager/Config.settings | 6 + .../Enums/ServerProfileCategory.cs | 1 + .../Globalization/en-US/en-US.xaml | 20 +++ .../Lib/Model/PreventTransferOverride.cs | 76 +++++++++ src/ARKServerManager/Lib/ServerProfile.cs | 45 ++++++ src/ARKServerManager/VersionFeed.xml | 11 +- src/ARKServerManager/VersionFeedBeta.xml | 25 ++- .../Windows/GlobalSettingsControl.xaml | 1 + .../Windows/ProfileSyncWindow.xaml.cs | 2 + .../Windows/ServerSettingsControl.xaml | 120 +++++++++++++- .../Windows/ServerSettingsControl.xaml.cs | 147 ++++++++++++++++-- .../AggregateIniValueEntryAttribute.cs | 14 +- .../Model/AggregateIniValue.cs | 11 +- src/ServerManager.Common/Utils/StringUtils.cs | 9 +- 17 files changed, 484 insertions(+), 35 deletions(-) create mode 100644 src/ARKServerManager/Lib/Model/PreventTransferOverride.cs diff --git a/src/ARKServerManager/ARKServerManager.csproj b/src/ARKServerManager/ARKServerManager.csproj index 0bd0383b..409d4826 100644 --- a/src/ARKServerManager/ARKServerManager.csproj +++ b/src/ARKServerManager/ARKServerManager.csproj @@ -180,6 +180,7 @@ + diff --git a/src/ARKServerManager/App.config b/src/ARKServerManager/App.config index 56eb9eca..76a5db80 100644 --- a/src/ARKServerManager/App.config +++ b/src/ARKServerManager/App.config @@ -735,6 +735,12 @@ True + + False + + + True + diff --git a/src/ARKServerManager/Config.Designer.cs b/src/ARKServerManager/Config.Designer.cs index 764390b4..1f386aee 100644 --- a/src/ARKServerManager/Config.Designer.cs +++ b/src/ARKServerManager/Config.Designer.cs @@ -2539,5 +2539,29 @@ namespace ServerManagerTool { return ((string)(this["VersionFile"])); } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool SectionPreventTransferOverridesIsExpanded { + get { + return ((bool)(this["SectionPreventTransferOverridesIsExpanded"])); + } + set { + this["SectionPreventTransferOverridesIsExpanded"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool SectionPreventTransferOverridesEnabled { + get { + return ((bool)(this["SectionPreventTransferOverridesEnabled"])); + } + set { + this["SectionPreventTransferOverridesEnabled"] = value; + } + } } } diff --git a/src/ARKServerManager/Config.settings b/src/ARKServerManager/Config.settings index a99d4ecf..0a55a9a5 100644 --- a/src/ARKServerManager/Config.settings +++ b/src/ARKServerManager/Config.settings @@ -710,5 +710,11 @@ version.txt + + False + + + True + \ No newline at end of file diff --git a/src/ARKServerManager/Enums/ServerProfileCategory.cs b/src/ARKServerManager/Enums/ServerProfileCategory.cs index 3bd44fe5..c923ae2e 100644 --- a/src/ARKServerManager/Enums/ServerProfileCategory.cs +++ b/src/ARKServerManager/Enums/ServerProfileCategory.cs @@ -22,6 +22,7 @@ CraftingOverrides, SupplyCrateOverrides, StackSizeOverrides, + PreventTransferOverrides, PGM, SOTF, } diff --git a/src/ARKServerManager/Globalization/en-US/en-US.xaml b/src/ARKServerManager/Globalization/en-US/en-US.xaml index e76aa8e0..b733ae53 100644 --- a/src/ARKServerManager/Globalization/en-US/en-US.xaml +++ b/src/ARKServerManager/Globalization/en-US/en-US.xaml @@ -445,6 +445,8 @@ If enabled, the map spawner overrides will be managed by the server manager. Enable Supply Crate Overrides If enabled, the supply crate overrides will be managed by the server manager. + Enable Prevent Transfer Overrides + If enabled, the prevent transfer overrides will be managed by the server manager. Enable PGM Ark Settings If enabled, the PGM settings will be managed by the server manager. Enable SotF Settings @@ -2270,6 +2272,23 @@ + + + Prevent Transfer Overrides + Prevent Transfers + Prevent Transfer Override Settings + NOTE: If you want to manage your overrides manually or with another application, you can disable the option that will prevent the server manager managing the overrides. See the 'Custom Override Options' in the global settings. + WARNING: Adding dinos to this list will prevent them from being transferred to and from the server. + + Dino + Dino Class String + + Add prevent transfer item + Delete all prevent transfer items + Paste prevent transfer items data + Delete prevent transfer item + Save prevent transfer items data + Player Details @@ -5451,6 +5470,7 @@ Constructing Map Spawner Information... Constructing Supply Crate Information... Constructing Stack Size Information... + Constructing Prevent Transfer Information... Saving Profile File... Saving Config Files... Saving Launcher File... diff --git a/src/ARKServerManager/Lib/Model/PreventTransferOverride.cs b/src/ARKServerManager/Lib/Model/PreventTransferOverride.cs new file mode 100644 index 00000000..7cfbf519 --- /dev/null +++ b/src/ARKServerManager/Lib/Model/PreventTransferOverride.cs @@ -0,0 +1,76 @@ +using ServerManagerTool.Common.Attibutes; +using ServerManagerTool.Common.Model; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Windows; + +namespace ServerManagerTool.Lib +{ + [DataContract] + public class PreventTransferOverrideList : AggregateIniValueList + { + public PreventTransferOverrideList(string aggregateValueName) + : base(aggregateValueName, null) + { + } + + public string[] RenderToView() + { + List errors = new List(); + + + return errors.ToArray(); + } + + public void RenderToModel() + { + } + + public void UpdateForLocalization() + { + } + } + + [DataContract] + public class PreventTransferOverride : AggregateIniValue + { + public static readonly DependencyProperty DinoClassStringProperty = DependencyProperty.Register(nameof(DinoClassString), typeof(string), typeof(PreventTransferOverride), new PropertyMetadata(string.Empty)); + [DataMember] + [AggregateIniValueEntry(QuotedString = false, ExcludePropertyName = true)] + public string DinoClassString + { + get { return (string)GetValue(DinoClassStringProperty); } + set { SetValue(DinoClassStringProperty, value); } + } + + public override string GetSortKey() + { + return null; + } + + public override bool IsEquivalent(AggregateIniValue other) + { + return false; + } + + public override void InitializeFromINIValue(string value) + { + if (string.IsNullOrWhiteSpace(value)) + return; + + var kvPair = value.Split(new[] { '=' }, 2); + var kvValue = kvPair[1].Trim(' '); + + DinoClassString = kvValue; + } + + public override string ToINIValue() + { + return base.ToComplexINIValue(false); + } + + public string DisplayName => GameData.FriendlyItemNameForClass(DinoClassString); + + public bool IsValid => !string.IsNullOrWhiteSpace(DinoClassString); + } +} diff --git a/src/ARKServerManager/Lib/ServerProfile.cs b/src/ARKServerManager/Lib/ServerProfile.cs index 69660eda..8d76d116 100644 --- a/src/ARKServerManager/Lib/ServerProfile.cs +++ b/src/ARKServerManager/Lib/ServerProfile.cs @@ -94,6 +94,7 @@ namespace ServerManagerTool.Lib this.ConfigOverrideItemCraftingCosts = new AggregateIniValueList(nameof(ConfigOverrideItemCraftingCosts), null); this.ConfigOverrideItemMaxQuantity = new StackSizeOverrideList(nameof(ConfigOverrideItemMaxQuantity)); this.ConfigOverrideSupplyCrateItems = new SupplyCrateOverrideList(nameof(ConfigOverrideSupplyCrateItems)); + this.PreventTransferForClassNames = new PreventTransferOverrideList(nameof(PreventTransferForClassNames)); this.ConfigAddNPCSpawnEntriesContainer = new NPCSpawnContainerList(nameof(ConfigAddNPCSpawnEntriesContainer), NPCSpawnContainerType.Add); this.ConfigSubtractNPCSpawnEntriesContainer = new NPCSpawnContainerList(nameof(ConfigSubtractNPCSpawnEntriesContainer), NPCSpawnContainerType.Subtract); @@ -3202,6 +3203,16 @@ namespace ServerManagerTool.Lib } #endregion + #region Prevent Transfer Overrides + public static readonly DependencyProperty PreventTransferForClassNamesProperty = DependencyProperty.Register(nameof(PreventTransferForClassNames), typeof(PreventTransferOverrideList), typeof(ServerProfile), new PropertyMetadata(null)); + [IniFileEntry(IniFiles.Game, IniSections.Game_ShooterGameMode, ServerProfileCategory.PreventTransferOverrides)] + public PreventTransferOverrideList PreventTransferForClassNames + { + get { return (PreventTransferOverrideList)GetValue(PreventTransferForClassNamesProperty); } + set { SetValue(PreventTransferForClassNamesProperty, value); } + } + #endregion + #region Survival of the Fittest public static readonly DependencyProperty SOTF_EnabledProperty = DependencyProperty.Register(nameof(SOTF_Enabled), typeof(bool), typeof(ServerProfile), new PropertyMetadata(false)); [DataMember] @@ -3520,6 +3531,11 @@ namespace ServerManagerTool.Lib exclusions.Add(ServerProfileCategory.StackSizeOverrides); } + if (!Config.Default.SectionPreventTransferOverridesEnabled) + { + exclusions.Add(ServerProfileCategory.PreventTransferOverrides); + } + if (!Config.Default.SectionPGMEnabled) { exclusions.Add(ServerProfileCategory.PGM); @@ -3909,6 +3925,8 @@ namespace ServerManagerTool.Lib profile.ConfigOverrideSupplyCrateItems.RenderToView(); if (Config.Default.SectionStackSizeOverridesEnabled) profile.ConfigOverrideItemMaxQuantity.RenderToView(); + if (Config.Default.SectionPreventTransferOverridesEnabled) + profile.PreventTransferForClassNames.RenderToView(); return profile; } @@ -4024,6 +4042,8 @@ namespace ServerManagerTool.Lib profile.ConfigOverrideSupplyCrateItems.RenderToView(); if (Config.Default.SectionStackSizeOverridesEnabled) profile.ConfigOverrideItemMaxQuantity.RenderToView(); + if (Config.Default.SectionPreventTransferOverridesEnabled) + profile.PreventTransferForClassNames.RenderToView(); profile.LoadServerFileAdministrators(); profile.LoadServerFileExclusive(); @@ -4130,6 +4150,12 @@ namespace ServerManagerTool.Lib this.ConfigOverrideItemMaxQuantity.RenderToModel(); } + if (Config.Default.SectionPreventTransferOverridesEnabled) + { + progressCallback?.Invoke(0, _globalizer.GetResourceString("ProfileSave_ConstructingPreventTransferInformation")); + this.PreventTransferForClassNames.RenderToModel(); + } + if (!Config.Default.SectionPGMEnabled) { PGM_Enabled = false; @@ -5327,6 +5353,12 @@ namespace ServerManagerTool.Lib this.PerLevelStatsMultiplier_Player = new StatsMultiplierArray(nameof(PerLevelStatsMultiplier_Player), GameData.GetPerLevelStatsMultipliers_Player, GameData.GetStatMultiplierInclusions_PlayerPerLevel(), true); } + public void ResetPreventTransferOverridesSection() + { + this.PreventTransferForClassNames = new PreventTransferOverrideList(nameof(PreventTransferForClassNames)); + this.PreventTransferForClassNames.Reset(); + } + public void ResetRulesSection() { this.ClearValue(EnableHardcoreProperty); @@ -5613,6 +5645,9 @@ namespace ServerManagerTool.Lib case ServerProfileCategory.StackSizeOverrides: SyncStackSizeOverridesSection(sourceProfile); break; + case ServerProfileCategory.PreventTransferOverrides: + SyncPreventTransferOverridesSection(sourceProfile); + break; case ServerProfileCategory.PGM: SyncPGMSection(sourceProfile); break; @@ -5996,6 +6031,16 @@ namespace ServerManagerTool.Lib this.PerLevelStatsMultiplier_Player.IsEnabled = sourceProfile.PerLevelStatsMultiplier_Player.IsEnabled; } + private void SyncPreventTransferOverridesSection(ServerProfile sourceProfile) + { + sourceProfile.PreventTransferForClassNames.RenderToModel(); + + this.PreventTransferForClassNames.Clear(); + this.PreventTransferForClassNames.FromIniValues(sourceProfile.PreventTransferForClassNames.ToIniValues()); + this.PreventTransferForClassNames.IsEnabled = this.PreventTransferForClassNames.Count > 0; + this.PreventTransferForClassNames.RenderToView(); + } + private void SyncRulesSection(ServerProfile sourceProfile) { this.SetValue(EnableHardcoreProperty, sourceProfile.EnableHardcore); diff --git a/src/ARKServerManager/VersionFeed.xml b/src/ARKServerManager/VersionFeed.xml index b9678a46..436674e8 100644 --- a/src/ARKServerManager/VersionFeed.xml +++ b/src/ARKServerManager/VersionFeed.xml @@ -5,14 +5,14 @@ Ark Server Manager Version Feed This is the Ark Server Manager release version feed. - 2021-06-19T00:00:00Z + 2021-06-19T01:00:00Z urn:uuid:0A751BBA-54B5-40A6-AB09-C6B2539DAFE7 - 1.1.399 (1.1.399.1) - 1.1.399.1 + 1.1.399 (1.1.399.2) + 1.1.399.2 - 2021-06-19T00:00:00Z + 2021-06-19T01:00:00Z

@@ -20,6 +20,7 @@

  • Server Settings - Rules Section - Added new Genesis: Part 2 settings, bDisableWorldBuffs, bEnableWorldBuffScaling and WorldBuffScalingEfficacy.
  • +
  • Server Settings - Prevent Transfer Section - Added new section to handle the PreventTransferForClassNames settings. This section can be enabled/disables from the global settings, if you want to management these manually.

@@ -1081,7 +1082,7 @@ NEW
    -
  • Server Settings - Dino Section - added missing server setting Mating Speed Multiplier. This has been added to the Dino Breeding Multipliers group near the bottom of the section. (thanks @Norlinri)
  • +
  • Server Settings - Dino Section - added missing server setting Mating Speed Multiplier. This has been added to the Dino Breeding Multipliers group near the bottom of the section. (thanks @Norlini)
CHANGE
diff --git a/src/ARKServerManager/VersionFeedBeta.xml b/src/ARKServerManager/VersionFeedBeta.xml index aab358df..16484573 100644 --- a/src/ARKServerManager/VersionFeedBeta.xml +++ b/src/ARKServerManager/VersionFeedBeta.xml @@ -5,7 +5,30 @@ Ark Server Manager Version Feed This is the Ark Server Manager beta version feed. - 2021-06-19T00:00:00Z + 2021-06-19T01:00:00Z + + + urn:uuid:0A751BBA-54B5-40A6-AB09-C6B2539DAFE7 + 1.1.399 (1.1.399.2) + 1.1.399.2 + + 2021-06-19T01:00:00Z + +
+

+ NEW +
+

    +
  • Server Settings - Prevent Transfer Section - Added new section to handle the PreventTransferForClassNames settings. This section can be enabled/disables from the global settings, if you want to management these manually.
  • +
+

+
+
+ + bletch + bletch1971@hotmail.com + +
urn:uuid:0A751BBA-54B5-40A6-AB09-C6B2539DAFE7 diff --git a/src/ARKServerManager/Windows/GlobalSettingsControl.xaml b/src/ARKServerManager/Windows/GlobalSettingsControl.xaml index 4489cc10..a6c44298 100644 --- a/src/ARKServerManager/Windows/GlobalSettingsControl.xaml +++ b/src/ARKServerManager/Windows/GlobalSettingsControl.xaml @@ -296,6 +296,7 @@ + diff --git a/src/ARKServerManager/Windows/ProfileSyncWindow.xaml.cs b/src/ARKServerManager/Windows/ProfileSyncWindow.xaml.cs index 7f75e030..aefcf251 100644 --- a/src/ARKServerManager/Windows/ProfileSyncWindow.xaml.cs +++ b/src/ARKServerManager/Windows/ProfileSyncWindow.xaml.cs @@ -237,6 +237,8 @@ namespace ServerManagerTool SyncSections.Add(new SyncSection() { Selected = false, Category = ServerProfileCategory.SupplyCrateOverrides, SectionName = _globalizer.GetResourceString("ServerSettings_SupplyCrateOverridesLabel") }); if (Config.Default.SectionStackSizeOverridesEnabled) SyncSections.Add(new SyncSection() { Selected = false, Category = ServerProfileCategory.StackSizeOverrides, SectionName = _globalizer.GetResourceString("ServerSettings_StackSizeOverridesLabel") }); + if (Config.Default.SectionPreventTransferOverridesEnabled) + SyncSections.Add(new SyncSection() { Selected = false, Category = ServerProfileCategory.PreventTransferOverrides, SectionName = _globalizer.GetResourceString("ServerSettings_PreventTransferOverridesLabel") }); if (Config.Default.SectionPGMEnabled) SyncSections.Add(new SyncSection() { Selected = false, Category = ServerProfileCategory.PGM, SectionName = _globalizer.GetResourceString("ServerSettings_PGMLabel") }); if (Config.Default.SectionSOTFEnabled) diff --git a/src/ARKServerManager/Windows/ServerSettingsControl.xaml b/src/ARKServerManager/Windows/ServerSettingsControl.xaml index f522d4f1..3a623236 100644 --- a/src/ARKServerManager/Windows/ServerSettingsControl.xaml +++ b/src/ARKServerManager/Windows/ServerSettingsControl.xaml @@ -2849,7 +2849,7 @@ - + @@ -5322,7 +5322,7 @@ - + @@ -5390,8 +5390,7 @@ - - + @@ -5788,6 +5787,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ARKServerManager/Windows/ServerSettingsControl.xaml.cs b/src/ARKServerManager/Windows/ServerSettingsControl.xaml.cs index a17fb9cc..9f7170fc 100644 --- a/src/ARKServerManager/Windows/ServerSettingsControl.xaml.cs +++ b/src/ARKServerManager/Windows/ServerSettingsControl.xaml.cs @@ -6,7 +6,6 @@ using ServerManagerTool.Common.Serialization; using ServerManagerTool.Common.Utils; using ServerManagerTool.Enums; using ServerManagerTool.Lib; -using ServerManagerTool.Lib.Model; using ServerManagerTool.Lib.ViewModel; using ServerManagerTool.Plugin.Common; using ServerManagerTool.Utils; @@ -24,7 +23,6 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; using WPFSharp.Globalizer; @@ -59,6 +57,7 @@ namespace ServerManagerTool CraftingOverridesSection, SupplyCrateOverridesSection, StackSizeOverridesSection, + PreventTransferOverridesSection, // Properties MapNameTotalConversionProperty, @@ -90,9 +89,8 @@ namespace ServerManagerTool public static readonly DependencyProperty BaseDinoModListProperty = DependencyProperty.Register(nameof(BaseDinoModList), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); public static readonly DependencyProperty BaseEngramModListProperty = DependencyProperty.Register(nameof(BaseEngramModList), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); public static readonly DependencyProperty BaseResourceModListProperty = DependencyProperty.Register(nameof(BaseResourceModList), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); - public static readonly DependencyProperty BaseDinoSettingsDinoListProperty = DependencyProperty.Register(nameof(BaseDinoSettingsDinoList), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); + public static readonly DependencyProperty BaseDinoListProperty = DependencyProperty.Register(nameof(BaseDinoList), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); public static readonly DependencyProperty BaseMapSpawnerListProperty = DependencyProperty.Register(nameof(BaseMapSpawnerList), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); - public static readonly DependencyProperty BaseMapSpawnerDinoListProperty = DependencyProperty.Register(nameof(BaseMapSpawnerDinoList), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); public static readonly DependencyProperty BasePrimalItemListProperty = DependencyProperty.Register(nameof(BasePrimalItemList), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); public static readonly DependencyProperty BaseSupplyCrateListProperty = DependencyProperty.Register(nameof(BaseSupplyCrateList), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); public static readonly DependencyProperty BaseGameMapsProperty = DependencyProperty.Register(nameof(BaseGameMaps), typeof(ComboBoxItemList), typeof(ServerSettingsControl), new PropertyMetadata(null)); @@ -146,10 +144,10 @@ namespace ServerManagerTool set { SetValue(BaseResourceModListProperty, value); } } - public ComboBoxItemList BaseDinoSettingsDinoList + public ComboBoxItemList BaseDinoList { - get { return (ComboBoxItemList)GetValue(BaseDinoSettingsDinoListProperty); } - set { SetValue(BaseDinoSettingsDinoListProperty, value); } + get { return (ComboBoxItemList)GetValue(BaseDinoListProperty); } + set { SetValue(BaseDinoListProperty, value); } } public ComboBoxItemList BaseMapSpawnerList @@ -158,12 +156,6 @@ namespace ServerManagerTool set { SetValue(BaseMapSpawnerListProperty, value); } } - public ComboBoxItemList BaseMapSpawnerDinoList - { - get { return (ComboBoxItemList)GetValue(BaseMapSpawnerDinoListProperty); } - set { SetValue(BaseMapSpawnerDinoListProperty, value); } - } - public ComboBoxItemList BasePrimalItemList { get { return (ComboBoxItemList)GetValue(BasePrimalItemListProperty); } @@ -380,9 +372,8 @@ namespace ServerManagerTool RefreshBaseResourceModList(); RefreshCustomLevelProgressionsInformation(); - this.BaseDinoSettingsDinoList = new ComboBoxItemList(); + this.BaseDinoList = new ComboBoxItemList(); this.BaseMapSpawnerList = new ComboBoxItemList(); - this.BaseMapSpawnerDinoList = new ComboBoxItemList(); this.BasePrimalItemList = new ComboBoxItemList(); this.BaseSupplyCrateList = new ComboBoxItemList(); this.BaseGameMaps = new ComboBoxItemList(); @@ -933,6 +924,7 @@ namespace ServerManagerTool comment.AppendLine($"SectionMapSpawnerOverridesEnabled: {Config.Default.SectionMapSpawnerOverridesEnabled}"); comment.AppendLine($"SectionSupplyCrateOverridesEnabled: {Config.Default.SectionSupplyCrateOverridesEnabled}"); comment.AppendLine($"SectionStackSizeOverridesEnabled: {Config.Default.SectionStackSizeOverridesEnabled}"); + comment.AppendLine($"SectionPreventTransferOverridesEnabled: {Config.Default.SectionPreventTransferOverridesEnabled}"); comment.AppendLine($"AutoBackup_EnableBackup: {Config.Default.AutoBackup_EnableBackup}"); comment.AppendLine($"AutoBackup_BackupPeriod: {Config.Default.AutoBackup_BackupPeriod}"); @@ -3301,6 +3293,106 @@ namespace ServerManagerTool } #endregion + #region Prevent Transfer Overrides + private void AddPreventTransferOverride_Click(object sender, RoutedEventArgs e) + { + Settings.PreventTransferForClassNames.Add(new PreventTransferOverride()); + Settings.PreventTransferForClassNames.IsEnabled = true; + } + + private void ClearPreventTransferOverrides_Click(object sender, RoutedEventArgs e) + { + if (MessageBox.Show(_globalizer.GetResourceString("ServerSettings_ClearLabel"), _globalizer.GetResourceString("ServerSettings_ClearTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) + return; + + Settings.PreventTransferForClassNames.Clear(); + Settings.PreventTransferForClassNames.IsEnabled = false; + } + + private void PastePreventTransferOverride_Click(object sender, RoutedEventArgs e) + { + var window = new CustomConfigDataWindow(); + window.Owner = Window.GetWindow(this); + window.Closed += Window_Closed; + var result = window.ShowDialog(); + + if (!result.HasValue || !result.Value) + return; + + // read the pasted data into an ini file. + var iniFile = IniFileUtils.ReadString(window.ConfigData.Replace(" ", "")); + + Server.Profile.PreventTransferForClassNames.RenderToModel(); + + // cycle through the sections, adding them to the list. Will bypass any sections that are named as per the ARK default sections. + foreach (var section in iniFile.Sections.Where(s => s.SectionName != null && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName))) + { + var preventTransferForClassNames = new AggregateIniValueList(nameof(Server.Profile.PreventTransferForClassNames), null); + preventTransferForClassNames.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{preventTransferForClassNames.IniCollectionKey}="))); + Server.Profile.PreventTransferForClassNames.AddRange(preventTransferForClassNames); + Server.Profile.PreventTransferForClassNames.IsEnabled |= preventTransferForClassNames.IsEnabled; + } + + var errors = Server.Profile.PreventTransferForClassNames.RenderToView(); + + RefreshBaseDinoList(); + + if (errors.Length > 0) + { + var error = $"The following errors have been found:\r\n\r\n{string.Join("\r\n", errors)}"; + + var window2 = new CommandLineWindow(error); + window2.OutputTextWrapping = TextWrapping.NoWrap; + window2.Height = 500; + window2.Title = "Import Errors"; + window2.Owner = Window.GetWindow(this); + window2.ShowDialog(); + } + } + + private void RemovePreventTransferOverrideItem_Click(object sender, RoutedEventArgs e) + { + if (MessageBox.Show(_globalizer.GetResourceString("ServerSettings_DeleteLabel"), _globalizer.GetResourceString("ServerSettings_DeleteTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) + return; + + var item = ((PreventTransferOverride)((Button)e.Source).DataContext); + Settings.PreventTransferForClassNames.Remove(item); + Settings.PreventTransferForClassNames.IsEnabled = Settings.PreventTransferForClassNames.Count > 0; + } + + private void SavePreventTransferOverride_Click(object sender, RoutedEventArgs e) + { + Settings.PreventTransferForClassNames.RenderToModel(); + + var iniValues = Settings.PreventTransferForClassNames.ToIniValues().ToList(); + var iniValue = string.Join("\r\n", iniValues); + + var window = new CommandLineWindow(iniValue); + window.OutputTextWrapping = TextWrapping.NoWrap; + window.Height = 500; + window.Title = _globalizer.GetResourceString("ServerSettings_PreventTransferOverrides_SaveTitle"); + window.Owner = Window.GetWindow(this); + window.ShowDialog(); + } + + private void SavePreventTransferOverrideItem_Click(object sender, RoutedEventArgs e) + { + var item = ((PreventTransferOverride)((Button)e.Source).DataContext); + if (item == null) + return; + + var iniName = Settings.PreventTransferForClassNames.IniCollectionKey; + var iniValue = $"{iniName}={item.ToINIValue()}"; + + var window = new CommandLineWindow(iniValue); + window.OutputTextWrapping = TextWrapping.Wrap; + window.Height = 500; + window.Title = _globalizer.GetResourceString("ServerSettings_PreventTransferOverrides_SaveTitle"); + window.Owner = Window.GetWindow(this); + window.ShowDialog(); + } + #endregion + #endregion #region Methods @@ -3445,18 +3537,34 @@ namespace ServerManagerTool } } + foreach (var preventTransfer in this.Settings.PreventTransferForClassNames) + { + if (string.IsNullOrWhiteSpace(preventTransfer.DinoClassString)) + continue; + + if (!newList.Any(s => s.ValueMember.Equals(preventTransfer.DinoClassString, StringComparison.OrdinalIgnoreCase))) + { + newList.Add(new Common.Model.ComboBoxItem + { + DisplayMember = preventTransfer.DinoClassString, + ValueMember = preventTransfer.DinoClassString, + }); + } + } + try { this.DinoSettingsGrid.BeginInit(); this.NPCSpawnEntrySettingsGrid.BeginInit(); + this.PreventTransferOverrideGrid.BeginInit(); - this.BaseDinoSettingsDinoList = newList; - this.BaseMapSpawnerDinoList = newList; + this.BaseDinoList = newList; } finally { this.DinoSettingsGrid.EndInit(); this.NPCSpawnEntrySettingsGrid.EndInit(); + this.PreventTransferOverrideGrid.EndInit(); } } @@ -3934,6 +4042,11 @@ namespace ServerManagerTool RefreshBasePrimalItemList(); break; + case ServerSettingsResetAction.PreventTransferOverridesSection: + this.Settings.ResetPreventTransferOverridesSection(); + RefreshBaseDinoList(); + break; + // Properties case ServerSettingsResetAction.MapNameTotalConversionProperty: // set the map name to the ARK default. diff --git a/src/ServerManager.Common/Attibutes/AggregateIniValueEntryAttribute.cs b/src/ServerManager.Common/Attibutes/AggregateIniValueEntryAttribute.cs index 7c7f2855..c2f58b19 100644 --- a/src/ServerManager.Common/Attibutes/AggregateIniValueEntryAttribute.cs +++ b/src/ServerManager.Common/Attibutes/AggregateIniValueEntryAttribute.cs @@ -35,13 +35,23 @@ namespace ServerManagerTool.Common.Attibutes public int BracketsAroundValueDelimiter = 1; /// - /// If true, then the property with not be written if empty. This does not work for collections, only value types. + /// If true, then the property will not be written if empty. This does not work for collections, only value types. /// public bool ExcludeIfEmpty; /// - /// If true, then the property with not be written if false. This does not work for collections, only BOOLEAN types. + /// If true, then the property will not be written if false. This does not work for collections, only BOOLEAN types. /// public bool ExcludeIfFalse = false; + + /// + /// If true, the value will always be written with quotes; otherwise without quotes. + /// + public bool QuotedString = true; + + /// + /// If true, then the property name will not be written. This does not work for collections, only value types. + /// + public bool ExcludePropertyName = false; } } diff --git a/src/ServerManager.Common/Model/AggregateIniValue.cs b/src/ServerManager.Common/Model/AggregateIniValue.cs index b7416aae..291a7faa 100644 --- a/src/ServerManager.Common/Model/AggregateIniValue.cs +++ b/src/ServerManager.Common/Model/AggregateIniValue.cs @@ -113,7 +113,7 @@ namespace ServerManagerTool.Common.Model var propName = string.IsNullOrWhiteSpace(attr?.Key) ? prop.Name : attr.Key; var val = prop.GetValue(this); - var propValue = StringUtils.GetPropertyValue(val, prop); + var propValue = StringUtils.GetPropertyValue(val, prop, attr?.QuotedString ?? true); if ((attr?.ExcludeIfEmpty ?? false) && string.IsNullOrWhiteSpace(propValue)) { @@ -121,7 +121,9 @@ namespace ServerManagerTool.Common.Model } else { - result.Append($"{propName}={propValue}"); + if (!(attr?.ExcludePropertyName ?? false)) + result.Append($"{propName}="); + result.Append($"{propValue}"); delimiter = DELIMITER.ToString(); } @@ -242,10 +244,11 @@ namespace ServerManagerTool.Common.Model } else { - var propValue = StringUtils.GetPropertyValue(val, prop); + var propValue = StringUtils.GetPropertyValue(val, prop, attr?.QuotedString ?? true); result.Append(delimiter); - result.Append($"{propName}="); + if (!(attr?.ExcludePropertyName ?? false)) + result.Append($"{propName}="); if (attr?.ValueWithinBrackets ?? false) result.Append("("); diff --git a/src/ServerManager.Common/Utils/StringUtils.cs b/src/ServerManager.Common/Utils/StringUtils.cs index bde4ee85..2d6fa05d 100644 --- a/src/ServerManager.Common/Utils/StringUtils.cs +++ b/src/ServerManager.Common/Utils/StringUtils.cs @@ -10,14 +10,19 @@ namespace ServerManagerTool.Common.Utils { public const string DEFAULT_CULTURE_CODE = "en-US"; - public static string GetPropertyValue(object value, PropertyInfo property) + public static string GetPropertyValue(object value, PropertyInfo property, bool quotedString = true) { string convertedVal; if (property.PropertyType == typeof(float)) convertedVal = ((float)value).ToString("0.000000####", CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE)); else if (property.PropertyType == typeof(string)) - convertedVal = $"\"{value}\""; + { + if (quotedString) + convertedVal = $"\"{value}\""; + else + convertedVal = $"{value}"; + } else convertedVal = Convert.ToString(value, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE));