Skip to content

Commit

Permalink
Misc Changes
Browse files Browse the repository at this point in the history
1. Added a worldsave delay setting
  • Loading branch information
Bletch1971 committed Aug 15, 2017
1 parent 5c9b741 commit 700d13b
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ARK Server Manager/ARK Server Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ProductName>Ark Server Manager</ProductName>
<PublisherName>Ark Server Manager</PublisherName>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.0.302.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down Expand Up @@ -160,6 +160,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Common\Converters\IntRangeValueConverter.cs" />
<Compile Include="Common\Model\PublishedFileDetail.cs" />
<Compile Include="Common\Serialization\IniFile.cs" />
<Compile Include="Common\Serialization\IniKey.cs" />
Expand Down
3 changes: 3 additions & 0 deletions ARK Server Manager/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@
<setting name="Alert_UpdateProcessError" serializeAs="String">
<value>The server update process was performed but an error occurred.</value>
</setting>
<setting name="ServerShutdown_WorldSaveDelay" serializeAs="String">
<value>60</value>
</setting>
</ARK_Server_Manager.Config>
</userSettings>
</configuration>
56 changes: 56 additions & 0 deletions ARK Server Manager/Common/Converters/IntRangeValueConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;

namespace ARK_Server_Manager.Lib.ViewModel
{
public class IntRangeValueConverter : MarkupExtension, IValueConverter
{
protected int MinValue { get; set; }
protected int MaxValue { get; set; }

public IntRangeValueConverter()
{
MinValue = int.MinValue;
MaxValue = int.MaxValue;
}

public IntRangeValueConverter(int minValue)
{
MinValue = minValue;
MaxValue = int.MaxValue;
}

public IntRangeValueConverter(int minValue, int maxValue)
{
MinValue = minValue;
MaxValue = maxValue;
}

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double scaledValue = System.Convert.ToInt32(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)
{
var sliderValue = System.Convert.ToInt32(value);
sliderValue = Math.Max(MinValue, sliderValue);
sliderValue = Math.Min(MaxValue, sliderValue);

var scaledValue = sliderValue;
return scaledValue;
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
12 changes: 12 additions & 0 deletions ARK Server Manager/Config.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ARK Server Manager/Config.settings
Original file line number Diff line number Diff line change
Expand Up @@ -530,5 +530,8 @@
<Setting Name="PlayerImageFileExtension" Type="System.String" Scope="Application">
<Value Profile="(Default)">.png</Value>
</Setting>
<Setting Name="ServerShutdown_WorldSaveDelay" Type="System.Int32" Scope="User">
<Value Profile="(Default)">60</Value>
</Setting>
</Settings>
</SettingsFile>
2 changes: 2 additions & 0 deletions ARK Server Manager/Globalization/en-US/en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@
<sys:String x:Key="GlobalSettings_ShutdownMessage3Tooltip">This message will be displayed when the server is about to shutdown.</sys:String>
<sys:String x:Key="GlobalSettings_ShutdownWorldSaveLabel">WorldSave Message:</sys:String>
<sys:String x:Key="GlobalSettings_ShutdownWorldSaveTooltip">This message will be displayed upon shutdown when the world is about to be saved.</sys:String>
<sys:String x:Key="GlobalSettings_WorldSaveDelayLabel">WorldSave Delay:</sys:String>
<sys:String x:Key="GlobalSettings_WorldSaveDelayTooltip">The number of seconds to wait for the worldsave command to complete before the server is shutdown.</sys:String>
<sys:String x:Key="GlobalSettings_ShutdownCancelLabel">Cancel Message:</sys:String>
<sys:String x:Key="GlobalSettings_ShutdownCancelTooltip">This message will be displayed when the server shutdown has been cancelled.</sys:String>
<sys:String x:Key="GlobalSettings_EmailSettingsLabel">SMTP Email Settings</sys:String>
Expand Down
4 changes: 2 additions & 2 deletions ARK Server Manager/Lib/ServerApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private void BackupServer()
SendCommand("saveworld", false);
emailMessage.AppendLine("sent saveworld command.");

Task.Delay(10000).Wait();
Task.Delay(Config.Default.ServerShutdown_WorldSaveDelay * 1000).Wait();
}
catch (Exception ex)
{
Expand Down Expand Up @@ -590,7 +590,7 @@ private void StopServer(CancellationToken cancellationToken)

SendCommand("saveworld", false);

Task.Delay(10000, cancellationToken).Wait(cancellationToken);
Task.Delay(Config.Default.ServerShutdown_WorldSaveDelay * 1000, cancellationToken).Wait(cancellationToken);
}
catch (Exception ex)
{
Expand Down
8 changes: 6 additions & 2 deletions ARK Server Manager/Windows/GlobalSettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand All @@ -455,8 +456,11 @@
<TextBox Grid.Row="5" Grid.Column="1" Margin="1" Text="{Binding CurrentConfig.ServerShutdown_GraceMessage3}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_ShutdownMessage3Tooltip}"/>
<Label Grid.Row="6" Grid.Column="0" Content="{DynamicResource GlobalSettings_ShutdownWorldSaveLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="6" Grid.Column="1" Margin="1" Text="{Binding CurrentConfig.ServerShutdown_WorldSaveMessage}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_ShutdownWorldSaveTooltip}"/>
<Label Grid.Row="7" Grid.Column="0" Content="{DynamicResource GlobalSettings_ShutdownCancelLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="7" Grid.Column="1" Margin="1" Text="{Binding CurrentConfig.ServerShutdown_CancelMessage}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_ShutdownCancelTooltip}"/>

<local:AnnotatedSlider Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2" Margin="1" Label="{DynamicResource GlobalSettings_WorldSaveDelayLabel}" Value="{Binding CurrentConfig.ServerShutdown_WorldSaveDelay, Converter={vm:IntRangeValueConverter 10, 300}}" Minimum="10" Maximum="300" SmallChange="10" LargeChange="50" TickFrequency="1" LabelRelativeWidth="Auto" SliderRelativeWidth="15*" SuffixRelativeWidth="Auto" Suffix="{DynamicResource SliderUnits_Seconds}" ToolTip="{DynamicResource GlobalSettings_WorldSaveDelayTooltip}"/>

<Label Grid.Row="8" Grid.Column="0" Content="{DynamicResource GlobalSettings_ShutdownCancelLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="8" Grid.Column="1" Margin="1" Text="{Binding CurrentConfig.ServerShutdown_CancelMessage}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_ShutdownCancelTooltip}"/>
</Grid>
</GroupBox>

Expand Down

0 comments on commit 700d13b

Please sign in to comment.