diff --git a/src/ARKServerManager/Globalization/en-US/en-US.xaml b/src/ARKServerManager/Globalization/en-US/en-US.xaml
index 855acd75..68f515f5 100644
--- a/src/ARKServerManager/Globalization/en-US/en-US.xaml
+++ b/src/ARKServerManager/Globalization/en-US/en-US.xaml
@@ -1553,6 +1553,18 @@
Hexagon Cost Multiplier
Specifies the multiplier for the hexagon cost of items.
+ Enable Ragnarok Settings
+ Allow Multiple Tamed Unicorns
+ If enabled, will allow one wild and unlimited tamed Unicorns on the map. Otherwise only one unicorn on the map at a time.
+ Unicorn Spawn Interval
+ How long the game should wait before spawning a new Unicorn if the wild one is killed (or tamed, if AllowMultipleTamedUnicorns is enabled). This value sets the minimum amount of time (in hours), and the maximum is equal to 2x this value.
+ Enable Volcano
+ If enabled, will allow the volcano to become active.
+ Volcano Interval
+ 0 = 5000 (min) - 15000 (max) seconds between instances of the volcano becoming active. Any number above 0 acts as a multiplier.
+ Volcano Intensity
+ The lower the value, the more intense the volcano's eruption will be. Recommended to leave at 1.0, the minimum value is 0.25, and for multiplayer games, it should not go below 0.5. Very high numbers will basically disable the flaming rocks flung out of the volcano.
+
Enable Fjordur Settings
Enable Fjordur Biome Teleport
If enabled, will allow biome teleport on Fjordur map.
diff --git a/src/ARKServerManager/Lib/Serialization/IniSections.cs b/src/ARKServerManager/Lib/Serialization/IniSections.cs
index da299dbe..6376b65a 100644
--- a/src/ARKServerManager/Lib/Serialization/IniSections.cs
+++ b/src/ARKServerManager/Lib/Serialization/IniSections.cs
@@ -10,6 +10,7 @@
GUS_GameSession,
GUS_MultiHome,
GUS_MessageOfTheDay,
+ GUS_Ragnarok,
// Game.ini
Game_ShooterGameMode,
diff --git a/src/ARKServerManager/Lib/Serialization/SystemIniFile.cs b/src/ARKServerManager/Lib/Serialization/SystemIniFile.cs
index a80c9fe5..504113d1 100644
--- a/src/ARKServerManager/Lib/Serialization/SystemIniFile.cs
+++ b/src/ARKServerManager/Lib/Serialization/SystemIniFile.cs
@@ -23,6 +23,7 @@ namespace ServerManagerTool.Lib
{ IniSections.GUS_GameSession, "/Script/Engine.GameSession"},
{ IniSections.GUS_MultiHome, "MultiHome" },
{ IniSections.GUS_MessageOfTheDay, "MessageOfTheDay" },
+ { IniSections.GUS_Ragnarok, "Ragnarok" },
// GameUserSettings sections, not used by server manager
diff --git a/src/ARKServerManager/Lib/ServerProfile.cs b/src/ARKServerManager/Lib/ServerProfile.cs
index 5c95a7cd..fcdf3998 100644
--- a/src/ARKServerManager/Lib/ServerProfile.cs
+++ b/src/ARKServerManager/Lib/ServerProfile.cs
@@ -1811,22 +1811,69 @@ namespace ServerManagerTool.Lib
set { SetValue(HexagonCostMultiplierProperty, value); }
}
- public static readonly DependencyProperty EnableFjordurSettingsProperty = DependencyProperty.Register(nameof(EnableFjordurSettings), typeof(bool), typeof(ServerProfile), new PropertyMetadata(false));
- [DataMember]
- public bool EnableFjordurSettings
+ public static readonly DependencyProperty Ragnarok_EnableSettingsProperty = DependencyProperty.Register(nameof(Ragnarok_EnableSettings), typeof(bool), typeof(ServerProfile), new PropertyMetadata(false));
+ public bool Ragnarok_EnableSettings
{
- get { return (bool)GetValue(EnableFjordurSettingsProperty); }
- set { SetValue(EnableFjordurSettingsProperty, value); }
+ get { return (bool)GetValue(Ragnarok_EnableSettingsProperty); }
+ set { SetValue(Ragnarok_EnableSettingsProperty, value); }
+ }
+
+ public static readonly DependencyProperty Ragnarok_AllowMultipleTamedUnicornsProperty = DependencyProperty.Register(nameof(Ragnarok_AllowMultipleTamedUnicorns), typeof(bool), typeof(ServerProfile), new PropertyMetadata(false));
+ [IniFileEntry(IniFiles.GameUserSettings, IniSections.GUS_Ragnarok, ServerProfileCategory.Rules, "AllowMultipleTamedUnicorns", ConditionedOn = nameof(Ragnarok_EnableSettings), ClearSectionIfEmpty = true)]
+ public bool Ragnarok_AllowMultipleTamedUnicorns
+ {
+ get { return (bool)GetValue(Ragnarok_AllowMultipleTamedUnicornsProperty); }
+ set { SetValue(Ragnarok_AllowMultipleTamedUnicornsProperty, value); }
+ }
+
+ public static readonly DependencyProperty Ragnarok_UnicornSpawnIntervalProperty = DependencyProperty.Register(nameof(Ragnarok_UnicornSpawnInterval), typeof(int), typeof(ServerProfile), new PropertyMetadata(24));
+ [IniFileEntry(IniFiles.GameUserSettings, IniSections.GUS_Ragnarok, ServerProfileCategory.Rules, "UnicornSpawnInterval", ConditionedOn = nameof(Ragnarok_EnableSettings), ClearSectionIfEmpty = true)]
+ public int Ragnarok_UnicornSpawnInterval
+ {
+ get { return (int)GetValue(Ragnarok_UnicornSpawnIntervalProperty); }
+ set { SetValue(Ragnarok_UnicornSpawnIntervalProperty, value); }
+ }
+
+ public static readonly DependencyProperty Ragnarok_EnableVolcanoProperty = DependencyProperty.Register(nameof(Ragnarok_EnableVolcano), typeof(bool), typeof(ServerProfile), new PropertyMetadata(true));
+ [IniFileEntry(IniFiles.GameUserSettings, IniSections.GUS_Ragnarok, ServerProfileCategory.Rules, "EnableVolcano", ConditionedOn = nameof(Ragnarok_EnableSettings), ClearSectionIfEmpty = true)]
+ public bool Ragnarok_EnableVolcano
+ {
+ get { return (bool)GetValue(Ragnarok_EnableVolcanoProperty); }
+ set { SetValue(Ragnarok_EnableVolcanoProperty, value); }
+ }
+
+ public static readonly DependencyProperty Ragnarok_VolcanoIntervalProperty = DependencyProperty.Register(nameof(Ragnarok_VolcanoInterval), typeof(int), typeof(ServerProfile), new PropertyMetadata(0));
+ [IniFileEntry(IniFiles.GameUserSettings, IniSections.GUS_Ragnarok, ServerProfileCategory.Rules, "VolcanoInterval", ConditionedOn = nameof(Ragnarok_EnableSettings), ClearSectionIfEmpty = true)]
+ public int Ragnarok_VolcanoInterval
+ {
+ get { return (int)GetValue(Ragnarok_VolcanoIntervalProperty); }
+ set { SetValue(Ragnarok_VolcanoIntervalProperty, value); }
+ }
+
+ public static readonly DependencyProperty Ragnarok_VolcanoIntensityProperty = DependencyProperty.Register(nameof(Ragnarok_VolcanoIntensity), typeof(float), typeof(ServerProfile), new PropertyMetadata(1.0f));
+ [IniFileEntry(IniFiles.GameUserSettings, IniSections.GUS_Ragnarok, ServerProfileCategory.Rules, "VolcanoIntensity", ConditionedOn = nameof(Ragnarok_EnableSettings), ClearSectionIfEmpty = true)]
+ public float Ragnarok_VolcanoIntensity
+ {
+ get { return (float)GetValue(Ragnarok_VolcanoIntensityProperty); }
+ set { SetValue(Ragnarok_VolcanoIntensityProperty, value); }
+ }
+
+ public static readonly DependencyProperty Fjordur_EnableSettingsProperty = DependencyProperty.Register(nameof(Fjordur_EnableSettings), typeof(bool), typeof(ServerProfile), new PropertyMetadata(false));
+ public bool Fjordur_EnableSettings
+ {
+ get { return (bool)GetValue(Fjordur_EnableSettingsProperty); }
+ set { SetValue(Fjordur_EnableSettingsProperty, value); }
}
public static readonly DependencyProperty UseFjordurTraversalBuffProperty = DependencyProperty.Register(nameof(UseFjordurTraversalBuff), typeof(bool), typeof(ServerProfile), new PropertyMetadata(true));
- [IniFileEntry(IniFiles.GameUserSettings, IniSections.GUS_ServerSettings, ServerProfileCategory.Rules, ConditionedOn = nameof(EnableFjordurSettings))]
+ [IniFileEntry(IniFiles.GameUserSettings, IniSections.GUS_ServerSettings, ServerProfileCategory.Rules, ConditionedOn = nameof(Fjordur_EnableSettings))]
public bool UseFjordurTraversalBuff
{
get { return (bool)GetValue(UseFjordurTraversalBuffProperty); }
set { SetValue(UseFjordurTraversalBuffProperty, value); }
}
+
public bool ClampItemStats
{
get
@@ -5677,6 +5724,14 @@ namespace ServerManagerTool.Lib
this.ClearValue(HexagonRewardMultiplierProperty);
this.ClearValue(HexagonCostMultiplierProperty);
+ this.ClearValue(Ragnarok_EnableSettingsProperty);
+ this.ClearValue(Ragnarok_AllowMultipleTamedUnicornsProperty);
+ this.ClearValue(Ragnarok_UnicornSpawnIntervalProperty);
+ this.ClearValue(Ragnarok_EnableVolcanoProperty);
+ this.ClearValue(Ragnarok_VolcanoIntervalProperty);
+ this.ClearValue(Ragnarok_VolcanoIntensityProperty);
+
+ this.ClearValue(Fjordur_EnableSettingsProperty);
this.ClearValue(UseFjordurTraversalBuffProperty);
this.ClearNullableValue(ItemStatClamps_GenericQualityProperty);
@@ -6395,6 +6450,14 @@ namespace ServerManagerTool.Lib
this.SetValue(HexagonRewardMultiplierProperty, sourceProfile.HexagonRewardMultiplier);
this.SetValue(HexagonCostMultiplierProperty, sourceProfile.HexagonCostMultiplier);
+ this.SetValue(Ragnarok_EnableSettingsProperty, sourceProfile.Ragnarok_EnableSettings);
+ this.SetValue(Ragnarok_AllowMultipleTamedUnicornsProperty, sourceProfile.Ragnarok_AllowMultipleTamedUnicorns);
+ this.SetValue(Ragnarok_UnicornSpawnIntervalProperty, sourceProfile.Ragnarok_UnicornSpawnInterval);
+ this.SetValue(Ragnarok_EnableVolcanoProperty, sourceProfile.Ragnarok_EnableVolcano);
+ this.SetValue(Ragnarok_VolcanoIntervalProperty, sourceProfile.Ragnarok_VolcanoInterval);
+ this.SetValue(Ragnarok_VolcanoIntensityProperty, sourceProfile.Ragnarok_VolcanoIntensity);
+
+ this.SetValue(Fjordur_EnableSettingsProperty, sourceProfile.Fjordur_EnableSettings);
this.SetValue(UseFjordurTraversalBuffProperty, sourceProfile.UseFjordurTraversalBuff);
this.SetNullableValue(ItemStatClamps_GenericQualityProperty, sourceProfile.ItemStatClamps_GenericQuality);
diff --git a/src/ARKServerManager/UserControls/ServerSettingsControl.xaml b/src/ARKServerManager/UserControls/ServerSettingsControl.xaml
index 42cdc15d..adfebbb1 100644
--- a/src/ARKServerManager/UserControls/ServerSettingsControl.xaml
+++ b/src/ARKServerManager/UserControls/ServerSettingsControl.xaml
@@ -2151,10 +2151,62 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ARKServerManager/VersionFeedBeta.xml b/src/ARKServerManager/VersionFeedBeta.xml
index 91d94595..ead18690 100644
--- a/src/ARKServerManager/VersionFeedBeta.xml
+++ b/src/ARKServerManager/VersionFeedBeta.xml
@@ -19,7 +19,8 @@
CHANGE
- - Fjordur Settings - added checkbox to enable/disable settings.
+ - Rules Section - Fjordur Settings - added checkbox to enable/disable settings.
+ - Rules Section - Ragnarok Settings - added settings for Ragnarok, located at the bottom of the section.
diff --git a/src/ServerManager.Common/Attibutes/BaseIniFileEntryAttribute.cs b/src/ServerManager.Common/Attibutes/BaseIniFileEntryAttribute.cs
index 514bfedb..cc2641fe 100644
--- a/src/ServerManager.Common/Attibutes/BaseIniFileEntryAttribute.cs
+++ b/src/ServerManager.Common/Attibutes/BaseIniFileEntryAttribute.cs
@@ -67,6 +67,12 @@ namespace ServerManagerTool.Common.Attibutes
///
public bool ClearSection;
+ ///
+ /// Clear the section after processing this value and the section is empty.
+ /// NOTE: DO NOT USE this setting for the standard setting sections, only use for custom sections or mod sections.
+ ///
+ public bool ClearSectionIfEmpty;
+
///
/// If true, the value will always be written with quotes, if remove, the value will always be written without quotes even if added.
///
diff --git a/src/ServerManager.Common/Controls/AnnotatedIntSlider.xaml b/src/ServerManager.Common/Controls/AnnotatedIntSlider.xaml
new file mode 100644
index 00000000..9caabc17
--- /dev/null
+++ b/src/ServerManager.Common/Controls/AnnotatedIntSlider.xaml
@@ -0,0 +1,292 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ServerManager.Common/Controls/AnnotatedIntSlider.xaml.cs b/src/ServerManager.Common/Controls/AnnotatedIntSlider.xaml.cs
new file mode 100644
index 00000000..c0b4dfcf
--- /dev/null
+++ b/src/ServerManager.Common/Controls/AnnotatedIntSlider.xaml.cs
@@ -0,0 +1,156 @@
+using System.Windows;
+using System.Windows.Controls;
+
+namespace ServerManagerTool.Common.Controls
+{
+ ///
+ /// Interaction logic for AnnotatedSlider.xaml
+ ///
+ public partial class AnnotatedIntSlider : UserControl
+ {
+ public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(nameof(Label), typeof(string), typeof(AnnotatedIntSlider));
+ public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(nameof(Value), typeof(int), typeof(AnnotatedIntSlider), new FrameworkPropertyMetadata(default(int), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
+ public static readonly DependencyProperty SuffixProperty = DependencyProperty.Register(nameof(Suffix), typeof(string), typeof(AnnotatedIntSlider));
+ public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(nameof(Minimum), typeof(int), typeof(AnnotatedIntSlider));
+ public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(nameof(Maximum), typeof(int), typeof(AnnotatedIntSlider));
+ public static readonly DependencyProperty LargeChangeProperty = DependencyProperty.Register(nameof(LargeChange), typeof(int), typeof(AnnotatedIntSlider));
+ public static readonly DependencyProperty SmallChangeProperty = DependencyProperty.Register(nameof(SmallChange), typeof(int), typeof(AnnotatedIntSlider));
+ public static readonly DependencyProperty TickFrequencyProperty = DependencyProperty.Register(nameof(TickFrequency), typeof(int), typeof(AnnotatedIntSlider));
+ public static readonly DependencyProperty LabelRelativeWidthProperty = DependencyProperty.Register(nameof(LabelRelativeWidth), typeof(string), typeof(AnnotatedIntSlider), new PropertyMetadata("4*"));
+ public static readonly DependencyProperty LabelRelativeMinWidthProperty = DependencyProperty.Register(nameof(LabelRelativeMinWidth), typeof(string), typeof(AnnotatedIntSlider), new PropertyMetadata("0"));
+ public static readonly DependencyProperty SliderRelativeWidthProperty = DependencyProperty.Register(nameof(SliderRelativeWidth), typeof(string), typeof(AnnotatedIntSlider), new PropertyMetadata("8*"));
+ public static readonly DependencyProperty SliderRelativeMinWidthProperty = DependencyProperty.Register(nameof(SliderRelativeMinWidth), typeof(string), typeof(AnnotatedIntSlider), new PropertyMetadata("0"));
+ public static readonly DependencyProperty ValueRelativeWidthProperty = DependencyProperty.Register(nameof(ValueRelativeWidth), typeof(string), typeof(AnnotatedIntSlider), new PropertyMetadata("2*"));
+ public static readonly DependencyProperty ValueRelativeMinWidthProperty = DependencyProperty.Register(nameof(ValueRelativeMinWidth), typeof(string), typeof(AnnotatedIntSlider), new PropertyMetadata("50"));
+ public static readonly DependencyProperty ValueRelativeMinHeightProperty = DependencyProperty.Register(nameof(ValueRelativeMinHeight), typeof(string), typeof(AnnotatedIntSlider), new PropertyMetadata("25"));
+ public static readonly DependencyProperty SuffixRelativeWidthProperty = DependencyProperty.Register(nameof(SuffixRelativeWidth), typeof(string), typeof(AnnotatedIntSlider), new PropertyMetadata("1*"));
+ public static readonly DependencyProperty SuffixRelativeMinWidthProperty = DependencyProperty.Register(nameof(SuffixRelativeMinWidth), typeof(string), typeof(AnnotatedIntSlider), new PropertyMetadata("0"));
+
+ public AnnotatedIntSlider()
+ {
+ InitializeComponent();
+
+ this.Focusable = true;
+
+ (this.Content as FrameworkElement).DataContext = this;
+ }
+
+ public string Label
+ {
+ get { return (string)GetValue(LabelProperty); }
+ set { SetValue(LabelProperty, value); }
+ }
+
+ public int Value
+ {
+ get { return (int)GetValue(ValueProperty); }
+ set { SetValue(ValueProperty, value); }
+ }
+
+ public string Suffix
+ {
+ get { return (string)GetValue(SuffixProperty); }
+ set { SetValue(SuffixProperty, value); }
+ }
+
+ public int Minimum
+ {
+ get { return (int)GetValue(MinimumProperty); }
+ set { SetValue(MinimumProperty, value); }
+ }
+
+ public int Maximum
+ {
+ get { return (int)GetValue(MaximumProperty); }
+ set { SetValue(MaximumProperty, value); }
+ }
+
+ public int LargeChange
+ {
+ get { return (int)GetValue(LargeChangeProperty); }
+ set { SetValue(LargeChangeProperty, value); }
+ }
+
+ public int SmallChange
+ {
+ get { return (int)GetValue(SmallChangeProperty); }
+ set { SetValue(SmallChangeProperty, value); }
+ }
+
+ public int TickFrequency
+ {
+ get { return (int)GetValue(TickFrequencyProperty); }
+ set { SetValue(TickFrequencyProperty, value); }
+ }
+
+ public string LabelRelativeWidth
+ {
+ get { return (string)GetValue(LabelRelativeWidthProperty); }
+ set { SetValue(LabelRelativeWidthProperty, value); }
+ }
+
+ public string LabelRelativeMinWidth
+ {
+ get { return (string)GetValue(LabelRelativeMinWidthProperty); }
+ set { SetValue(LabelRelativeMinWidthProperty, value); }
+ }
+
+ public string SliderRelativeWidth
+ {
+ get { return (string)GetValue(SliderRelativeWidthProperty); }
+ set { SetValue(SliderRelativeWidthProperty, value); }
+ }
+
+ public string SliderRelativeMinWidth
+ {
+ get { return (string)GetValue(SliderRelativeMinWidthProperty); }
+ set { SetValue(SliderRelativeMinWidthProperty, value); }
+ }
+
+ public string ValueRelativeWidth
+ {
+ get { return (string)GetValue(ValueRelativeWidthProperty); }
+ set { SetValue(ValueRelativeWidthProperty, value); }
+ }
+
+ public string ValueRelativeMinWidth
+ {
+ get { return (string)GetValue(ValueRelativeMinWidthProperty); }
+ set { SetValue(ValueRelativeMinWidthProperty, value); }
+ }
+
+ public string ValueRelativeMinHeight
+ {
+ get { return (string)GetValue(ValueRelativeMinHeightProperty); }
+ set { SetValue(ValueRelativeMinHeightProperty, value); }
+ }
+
+ public string SuffixRelativeWidth
+ {
+ get { return (string)GetValue(SuffixRelativeWidthProperty); }
+ set { SetValue(SuffixRelativeWidthProperty, value); }
+ }
+
+ public string SuffixRelativeMinWidth
+ {
+ get { return (string)GetValue(SuffixRelativeMinWidthProperty); }
+ set { SetValue(SuffixRelativeMinWidthProperty, value); }
+ }
+
+ private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ if (Slider.IsFocused)
+ {
+ unchecked
+ {
+ Value = (int)e.NewValue;
+ }
+ }
+ }
+
+ public new bool Focus()
+ {
+ return Slider.Focus();
+ }
+ }
+}
diff --git a/src/ServerManager.Common/Converters/DoubleRangeValueConverter.cs b/src/ServerManager.Common/Converters/DoubleRangeValueConverter.cs
index 9945f4e6..4a661ebc 100644
--- a/src/ServerManager.Common/Converters/DoubleRangeValueConverter.cs
+++ b/src/ServerManager.Common/Converters/DoubleRangeValueConverter.cs
@@ -30,7 +30,7 @@ namespace ServerManagerTool.Common.Converters
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- double scaledValue = System.Convert.ToDouble(value);
+ var scaledValue = System.Convert.ToDouble(value);
var sliderValue = scaledValue;
sliderValue = Math.Max(MinValue, sliderValue);
diff --git a/src/ServerManager.Common/Converters/EnumConverter.cs b/src/ServerManager.Common/Converters/EnumConverter.cs
index d582c021..923a1915 100644
--- a/src/ServerManager.Common/Converters/EnumConverter.cs
+++ b/src/ServerManager.Common/Converters/EnumConverter.cs
@@ -11,8 +11,8 @@ namespace ServerManagerTool.Common.Converters
if (value == null || parameter == null)
return false;
- string checkValue = value.ToString();
- string targetValue = parameter.ToString();
+ var checkValue = value.ToString();
+ var targetValue = parameter.ToString();
return checkValue.Equals(targetValue, StringComparison.InvariantCultureIgnoreCase);
}
@@ -21,8 +21,8 @@ namespace ServerManagerTool.Common.Converters
if (value == null || parameter == null)
return null;
- bool useValue = (bool)value;
- string targetValue = parameter.ToString();
+ var useValue = System.Convert.ToBoolean(value);
+ var targetValue = parameter.ToString();
if (useValue)
return Enum.Parse(targetType, targetValue);
diff --git a/src/ServerManager.Common/Converters/EnumFlagsConverter.cs b/src/ServerManager.Common/Converters/EnumFlagsConverter.cs
index 24fc701e..d5285999 100644
--- a/src/ServerManager.Common/Converters/EnumFlagsConverter.cs
+++ b/src/ServerManager.Common/Converters/EnumFlagsConverter.cs
@@ -4,11 +4,9 @@ using System.Windows.Data;
namespace ServerManagerTool.Common.Converters
{
-
public class EnumFlagsConverter : IValueConverter
{
- public object Convert(object value, Type targetType,
- object parameter, CultureInfo culture)
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || parameter == null)
return false;
@@ -18,8 +16,7 @@ namespace ServerManagerTool.Common.Converters
return (flagsValue & targetFlagValue) == targetFlagValue;
}
- public object ConvertBack(object value, Type targetType,
- object parameter, CultureInfo culture)
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException("Cannot convert flags value back");
}
diff --git a/src/ServerManager.Common/Converters/FloatRangeValueConverter.cs b/src/ServerManager.Common/Converters/FloatRangeValueConverter.cs
new file mode 100644
index 00000000..5fec2c6b
--- /dev/null
+++ b/src/ServerManager.Common/Converters/FloatRangeValueConverter.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using System.Windows.Markup;
+
+namespace ServerManagerTool.Common.Converters
+{
+ public class FloatRangeValueConverter : MarkupExtension, IValueConverter
+ {
+ public const string DEFAULT_CULTURE_CODE = "en-US";
+ protected float MinValue { get; set; }
+ protected float MaxValue { get; set; }
+
+ public FloatRangeValueConverter()
+ {
+ MinValue = float.MinValue;
+ MaxValue = float.MaxValue;
+ }
+
+ public FloatRangeValueConverter(float minValue)
+ {
+ MinValue = minValue;
+ MaxValue = float.MaxValue;
+ }
+
+ public FloatRangeValueConverter(float minValue, float maxValue)
+ {
+ MinValue = minValue;
+ MaxValue = maxValue;
+ }
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ var scaledValue = System.Convert.ToSingle(value);
+
+ var sliderValue = scaledValue;
+ sliderValue = Math.Max(MinValue, sliderValue);
+ sliderValue = Math.Min(MaxValue, sliderValue);
+ return sliderValue;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is null || value.ToString() == string.Empty)
+ return default;
+
+ if (!float.TryParse(value.ToString(), NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out float sliderValue))
+ return default;
+
+ sliderValue = Math.Max(MinValue, sliderValue);
+ sliderValue = Math.Min(MaxValue, sliderValue);
+
+ var scaledValue = sliderValue;
+ return scaledValue;
+ }
+
+ public override object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return this;
+ }
+ }
+}
diff --git a/src/ServerManager.Common/Converters/HasStringValueConverter.cs b/src/ServerManager.Common/Converters/HasStringValueConverter.cs
index 40d4111c..4b02ec7e 100644
--- a/src/ServerManager.Common/Converters/HasStringValueConverter.cs
+++ b/src/ServerManager.Common/Converters/HasStringValueConverter.cs
@@ -1,9 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Data;
namespace ServerManagerTool.Common.Converters
@@ -12,13 +8,13 @@ namespace ServerManagerTool.Common.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- if(value == null)
+ if (value == null)
{
return false;
}
var strValue = value as string;
- if(String.IsNullOrWhiteSpace(strValue))
+ if (string.IsNullOrWhiteSpace(strValue))
{
return false;
}
diff --git a/src/ServerManager.Common/Converters/IntRangeValueConverter.cs b/src/ServerManager.Common/Converters/IntRangeValueConverter.cs
index dc5fe025..49336330 100644
--- a/src/ServerManager.Common/Converters/IntRangeValueConverter.cs
+++ b/src/ServerManager.Common/Converters/IntRangeValueConverter.cs
@@ -7,6 +7,7 @@ namespace ServerManagerTool.Common.Converters
{
public class IntRangeValueConverter : MarkupExtension, IValueConverter
{
+ public const string DEFAULT_CULTURE_CODE = "en-US";
protected int MinValue { get; set; }
protected int MaxValue { get; set; }
@@ -30,7 +31,7 @@ namespace ServerManagerTool.Common.Converters
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- double scaledValue = System.Convert.ToInt32(value);
+ var scaledValue = System.Convert.ToInt32(value);
var sliderValue = scaledValue;
sliderValue = Math.Max(MinValue, sliderValue);
@@ -43,7 +44,7 @@ namespace ServerManagerTool.Common.Converters
if (value is null || value.ToString() == string.Empty)
return default;
- if (!int.TryParse(value.ToString(), out int sliderValue))
+ if (!int.TryParse(value.ToString(), NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out int sliderValue))
return default;
sliderValue = Math.Max(MinValue, sliderValue);
diff --git a/src/ServerManager.Common/Converters/IntToVisibilityConverter.cs b/src/ServerManager.Common/Converters/IntToVisibilityConverter.cs
index c350e744..251c7428 100644
--- a/src/ServerManager.Common/Converters/IntToVisibilityConverter.cs
+++ b/src/ServerManager.Common/Converters/IntToVisibilityConverter.cs
@@ -9,7 +9,7 @@ namespace ServerManagerTool.Common.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- double scaledValue = System.Convert.ToInt32(value);
+ var scaledValue = System.Convert.ToInt32(value);
return scaledValue == 0 ? Visibility.Collapsed : Visibility.Visible;
}
diff --git a/src/ServerManager.Common/Converters/InvertBooleanToVisibilityConverter.cs b/src/ServerManager.Common/Converters/InvertBooleanToVisibilityConverter.cs
index f0485305..9ac58cf4 100644
--- a/src/ServerManager.Common/Converters/InvertBooleanToVisibilityConverter.cs
+++ b/src/ServerManager.Common/Converters/InvertBooleanToVisibilityConverter.cs
@@ -9,7 +9,7 @@ namespace ServerManagerTool.Common.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- bool flag = false;
+ var flag = false;
if (value is bool)
{
flag = (bool)value;
diff --git a/src/ServerManager.Common/Converters/InvertIntToVisibilityConverter.cs b/src/ServerManager.Common/Converters/InvertIntToVisibilityConverter.cs
index c7030bb8..25ec8ff5 100644
--- a/src/ServerManager.Common/Converters/InvertIntToVisibilityConverter.cs
+++ b/src/ServerManager.Common/Converters/InvertIntToVisibilityConverter.cs
@@ -9,7 +9,7 @@ namespace ServerManagerTool.Common.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- double scaledValue = System.Convert.ToInt32(value);
+ var scaledValue = System.Convert.ToInt32(value);
return scaledValue == 0 ? Visibility.Visible : Visibility.Collapsed;
}
diff --git a/src/ServerManager.Common/Converters/IsNullOrWhiteSpaceValueConverter.cs b/src/ServerManager.Common/Converters/IsNullOrWhiteSpaceValueConverter.cs
index 42ea117e..b8460351 100644
--- a/src/ServerManager.Common/Converters/IsNullOrWhiteSpaceValueConverter.cs
+++ b/src/ServerManager.Common/Converters/IsNullOrWhiteSpaceValueConverter.cs
@@ -1,9 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Data;
namespace ServerManagerTool.Common.Converters
@@ -12,13 +8,13 @@ namespace ServerManagerTool.Common.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- if(value == null)
+ if (value == null)
{
return true;
}
var strValue = value as string;
- if(String.IsNullOrWhiteSpace(strValue))
+ if (string.IsNullOrWhiteSpace(strValue))
{
return true;
}
diff --git a/src/ServerManager.Common/Converters/IsNullValueConverter.cs b/src/ServerManager.Common/Converters/IsNullValueConverter.cs
index 1e546bb1..6b9d98ec 100644
--- a/src/ServerManager.Common/Converters/IsNullValueConverter.cs
+++ b/src/ServerManager.Common/Converters/IsNullValueConverter.cs
@@ -1,9 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Data;
namespace ServerManagerTool.Common.Converters
diff --git a/src/ServerManager.Common/Converters/MinutesToTimeValueConverter.cs b/src/ServerManager.Common/Converters/MinutesToTimeValueConverter.cs
index 4ee9f096..3f9301fb 100644
--- a/src/ServerManager.Common/Converters/MinutesToTimeValueConverter.cs
+++ b/src/ServerManager.Common/Converters/MinutesToTimeValueConverter.cs
@@ -27,11 +27,8 @@ namespace ServerManagerTool.Common.Converters
return 0;
}
- int hours;
- Int32.TryParse(split[0], out hours);
-
- int minutes;
- Int32.TryParse(split[1], out minutes);
+ int.TryParse(split[0], out int hours);
+ int.TryParse(split[1], out int minutes);
return hours * 60 + minutes;
}
diff --git a/src/ServerManager.Common/Converters/SecondsToHoursConverter.cs b/src/ServerManager.Common/Converters/SecondsToHoursConverter.cs
index 3b280918..a42a0a2c 100644
--- a/src/ServerManager.Common/Converters/SecondsToHoursConverter.cs
+++ b/src/ServerManager.Common/Converters/SecondsToHoursConverter.cs
@@ -11,7 +11,7 @@ namespace ServerManagerTool.Common.Converters
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- double scaledValue = System.Convert.ToInt32(value);
+ var scaledValue = System.Convert.ToInt32(value);
var sliderValue = (int)TimeSpan.FromSeconds(scaledValue).TotalHours;
sliderValue = Math.Max(MIN_VALUE, sliderValue);
diff --git a/src/ServerManager.Common/Converters/SecondsToMinutesConverter.cs b/src/ServerManager.Common/Converters/SecondsToMinutesConverter.cs
index 1f5bea10..6874a1aa 100644
--- a/src/ServerManager.Common/Converters/SecondsToMinutesConverter.cs
+++ b/src/ServerManager.Common/Converters/SecondsToMinutesConverter.cs
@@ -11,7 +11,7 @@ namespace ServerManagerTool.Common.Converters
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- double scaledValue = System.Convert.ToInt32(value);
+ var scaledValue = System.Convert.ToInt32(value);
var sliderValue = (int)TimeSpan.FromSeconds(scaledValue).TotalMinutes;
sliderValue = Math.Max(MIN_VALUE, sliderValue);
diff --git a/src/ServerManager.Common/Converters/SecondsToTimeValueConverter.cs b/src/ServerManager.Common/Converters/SecondsToTimeValueConverter.cs
index 71b375aa..e0b2a245 100644
--- a/src/ServerManager.Common/Converters/SecondsToTimeValueConverter.cs
+++ b/src/ServerManager.Common/Converters/SecondsToTimeValueConverter.cs
@@ -8,26 +8,23 @@ namespace ServerManagerTool.Common.Converters
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
// Value is seconds since midnight.
- var seconds = (int)value;
+ var seconds = System.Convert.ToInt32(value);
var hours = Math.Min(Math.Max(seconds / 3600, 0), 23);
var minutes = Math.Min(Math.Max((seconds % 3600) / 60, 0), 59);
- return String.Format("{0:00}:{1:00}", hours, minutes);
+ return string.Format("{0:00}:{1:00}", hours, minutes);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var strTime = (string)value;
var split = strTime.Split(':');
- if(split.Length != 2)
+ if (split.Length != 2)
{
return 0;
}
- int hours;
- Int32.TryParse(split[0], out hours);
-
- int minutes;
- Int32.TryParse(split[1], out minutes);
+ int.TryParse(split[0], out int hours);
+ int.TryParse(split[1], out int minutes);
return hours * 3600 + minutes * 60;
}
diff --git a/src/ServerManager.Common/Converters/UnixTimeToDateTimeConverter.cs b/src/ServerManager.Common/Converters/UnixTimeToDateTimeConverter.cs
index d38e7bed..763f7bcc 100644
--- a/src/ServerManager.Common/Converters/UnixTimeToDateTimeConverter.cs
+++ b/src/ServerManager.Common/Converters/UnixTimeToDateTimeConverter.cs
@@ -9,7 +9,7 @@ namespace ServerManagerTool.Common.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- int unixTimestamp = (int)value;
+ var unixTimestamp = System.Convert.ToInt32(value);
return DateTimeUtils.UnixTimeStampToDateTime(unixTimestamp).ToString(culture);
}
diff --git a/src/ServerManager.Common/Serialization/BaseSystemIniFile.cs b/src/ServerManager.Common/Serialization/BaseSystemIniFile.cs
index b4d89f88..b8dec04a 100644
--- a/src/ServerManager.Common/Serialization/BaseSystemIniFile.cs
+++ b/src/ServerManager.Common/Serialization/BaseSystemIniFile.cs
@@ -218,6 +218,7 @@ namespace ServerManagerTool.Common.Serialization
if (attr.ClearSection)
{
WriteValue(iniFiles, attr.File, attr.Section, null, null);
+ ClearSectionIfEmpty(iniFiles, attr);
}
//
@@ -240,6 +241,7 @@ namespace ServerManagerTool.Common.Serialization
{
// The condition value was not set to true, so clear this attribute instead of writing it
WriteValue(iniFiles, attr.File, attr.Section, keyName, null);
+ ClearSectionIfEmpty(iniFiles, attr);
continue;
}
}
@@ -252,6 +254,7 @@ namespace ServerManagerTool.Common.Serialization
{
// The attributed value was set to false, so clear this attribute instead of writing it
WriteValue(iniFiles, attr.File, attr.Section, keyName, null);
+ ClearSectionIfEmpty(iniFiles, attr);
}
continue;
}
@@ -325,6 +328,7 @@ namespace ServerManagerTool.Common.Serialization
{
// The attributed value does not have a value, so clear this attribute instead of writing it.
WriteValue(iniFiles, attr.File, attr.Section, keyName, null);
+ ClearSectionIfEmpty(iniFiles, attr);
continue;
}
@@ -338,6 +342,7 @@ namespace ServerManagerTool.Common.Serialization
{
// The attributed value is the same as the specified value, so clear this attribute instead of writing it.
WriteValue(iniFiles, attr.File, attr.Section, keyName, null);
+ ClearSectionIfEmpty(iniFiles, attr);
continue;
}
}
@@ -369,6 +374,8 @@ namespace ServerManagerTool.Common.Serialization
}
}
}
+
+ ClearSectionIfEmpty(iniFiles, attr);
}
catch (Exception)
{
@@ -380,6 +387,19 @@ namespace ServerManagerTool.Common.Serialization
SaveFiles(iniFiles);
}
+ private void ClearSectionIfEmpty(Dictionary iniFiles, BaseIniFileEntryAttribute attr)
+ {
+ if (attr.ClearSectionIfEmpty)
+ {
+ var section = ReadSection(iniFiles, attr.File, attr.Section);
+ var hasKeys = section?.Any() ?? false;
+ if (!hasKeys)
+ {
+ WriteValue(iniFiles, attr.File, attr.Section, null, null);
+ }
+ }
+ }
+
public IEnumerable ReadSection(Enum iniFile, Enum section)
{
return ReadSection(iniFile, SectionNames[section]);
diff --git a/src/ServerManager.Common/ServerManager.Common.csproj b/src/ServerManager.Common/ServerManager.Common.csproj
index 0f99d811..fdb7fc83 100644
--- a/src/ServerManager.Common/ServerManager.Common.csproj
+++ b/src/ServerManager.Common/ServerManager.Common.csproj
@@ -13,6 +13,7 @@
+
@@ -32,6 +33,9 @@
MSBuild:Compile
+
+ MSBuild:Compile
+
Designer
diff --git a/src/ServerManager.Common/Utils/IniFileUtils.cs b/src/ServerManager.Common/Utils/IniFileUtils.cs
index 1cbc29ab..18df8dfc 100644
--- a/src/ServerManager.Common/Utils/IniFileUtils.cs
+++ b/src/ServerManager.Common/Utils/IniFileUtils.cs
@@ -58,7 +58,7 @@ namespace ServerManagerTool.Common.Utils
if (!result)
return false;
- return result = SaveToFile(file, iniFile);
+ return SaveToFile(file, iniFile);
}
///
@@ -80,7 +80,7 @@ namespace ServerManagerTool.Common.Utils
if (!result)
return false;
- return result = SaveToFile(file, iniFile);
+ return SaveToFile(file, iniFile);
}
public static IniFile ReadFromFile(string file)