Skip to content

Commit

Permalink
Merge pull request #143 from ChronosWS/BletchChanges
Browse files Browse the repository at this point in the history
ASM 301 & 302 Changes
  • Loading branch information
Bletch1971 authored Aug 15, 2017
2 parents 51a0f85 + 84d6e90 commit c244258
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 15 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 @@ -32,7 +32,7 @@
<PublisherName>Ark Server Manager</PublisherName>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.301.%2a</ApplicationVersion>
<ApplicationVersion>1.0.303.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>false</BootstrapperEnabled>
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
6 changes: 6 additions & 0 deletions ARK Server Manager/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@
<setting name="UpdaterFile" serializeAs="String">
<value>ServerManagerUpdater.exe</value>
</setting>
<setting name="PlayerImageFileExtension" serializeAs="String">
<value>.png</value>
</setting>
</ARK_Server_Manager.Config>
</applicationSettings>
<userSettings>
Expand Down Expand Up @@ -605,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>
3 changes: 3 additions & 0 deletions ARK Server Manager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Diagnostics;
using System.Linq;
using ArkServerManager.Plugin.Common;
using System.Net;

namespace ARK_Server_Manager
{
Expand Down Expand Up @@ -186,6 +187,8 @@ protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

_globalizer = GlobalizedApplication.Instance;
try
{
Expand Down
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;
}
}
}
21 changes: 21 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.

6 changes: 6 additions & 0 deletions ARK Server Manager/Config.settings
Original file line number Diff line number Diff line change
Expand Up @@ -527,5 +527,11 @@
<Setting Name="UpdaterFile" Type="System.String" Scope="Application">
<Value Profile="(Default)">ServerManagerUpdater.exe</Value>
</Setting>
<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>
4 changes: 3 additions & 1 deletion 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 Expand Up @@ -3065,7 +3067,7 @@
<sys:String x:Key="PrimalItemDye_Cyan_C">Cyan Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Forest_C">Forest Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Green_C">Green Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Magenta_C">Purple Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Magenta_C">Magenta Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Mud_C">Mud Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Navy_C">Navy Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Olive_C">Olive Coloring</sys:String>
Expand Down
2 changes: 1 addition & 1 deletion ARK Server Manager/Globalization/ru-RU/ru-RU.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2978,7 +2978,7 @@
<sys:String x:Key="PrimalItemDye_Cyan_C">Cyan Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Forest_C">Forest Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Green_C">Green Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Magenta_C">Purple Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Magenta_C">Magenta Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Mud_C">Mud Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Navy_C">Navy Coloring</sys:String>
<sys:String x:Key="PrimalItemDye_Olive_C">Olive Coloring</sys:String>
Expand Down
16 changes: 12 additions & 4 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 Expand Up @@ -1938,20 +1938,28 @@ public void CreateServerBackupArchiveFile(StringBuilder emailMessage, ProfileSna
var files = new List<string>();
files.Add(worldFile);

var saveFolderInfo = new DirectoryInfo(saveFolder);
var playerFileFilter = $"*{Config.Default.PlayerFileExtension}";
var playerFiles = new DirectoryInfo(saveFolder).GetFiles(playerFileFilter, SearchOption.TopDirectoryOnly);
var playerFiles = saveFolderInfo.GetFiles(playerFileFilter, SearchOption.TopDirectoryOnly);
foreach (var playerFile in playerFiles)
{
files.Add(playerFile.FullName);
}

var tribeFileFilter = $"*{Config.Default.TribeFileExtension}";
var tribeFiles = new DirectoryInfo(saveFolder).GetFiles(tribeFileFilter, SearchOption.TopDirectoryOnly);
var tribeFiles = saveFolderInfo.GetFiles(tribeFileFilter, SearchOption.TopDirectoryOnly);
foreach (var tribeFile in tribeFiles)
{
files.Add(tribeFile.FullName);
}

var playerImageFileFilter = $"*{Config.Default.PlayerImageFileExtension}";
var playerImageFiles = saveFolderInfo.GetFiles(playerImageFileFilter, SearchOption.TopDirectoryOnly);
foreach (var playerImageFile in playerImageFiles)
{
files.Add(playerImageFile.FullName);
}

var comment = new StringBuilder();
comment.AppendLine($"Windows Platform: {Environment.OSVersion.Platform}");
comment.AppendLine($"Windows Version: {Environment.OSVersion.VersionString}");
Expand Down
14 changes: 12 additions & 2 deletions ARK Server Manager/Lib/ServerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3782,21 +3782,31 @@ public int RestoreSaveFiles(string restoreFile, bool isArchiveFile, bool restore

if (restoreAll)
{
var saveFolderInfo = new DirectoryInfo(saveFolder);

// get the player files
var playerFileFilter = $"*{Config.Default.PlayerFileExtension}";
var playerFiles = new DirectoryInfo(saveFolder).GetFiles(playerFileFilter, SearchOption.TopDirectoryOnly);
var playerFiles = saveFolderInfo.GetFiles(playerFileFilter, SearchOption.TopDirectoryOnly);
foreach (var playerFile in playerFiles)
{
files.Add(playerFile.FullName);
}

// get the tribe files
var tribeFileFilter = $"*{Config.Default.TribeFileExtension}";
var tribeFiles = new DirectoryInfo(saveFolder).GetFiles(tribeFileFilter, SearchOption.TopDirectoryOnly);
var tribeFiles = saveFolderInfo.GetFiles(tribeFileFilter, SearchOption.TopDirectoryOnly);
foreach (var tribeFile in tribeFiles)
{
files.Add(tribeFile.FullName);
}

// get the player images files
var playerImageFileFilter = $"*{Config.Default.PlayerImageFileExtension}";
var playerImageFiles = saveFolderInfo.GetFiles(playerImageFileFilter, SearchOption.TopDirectoryOnly);
foreach (var playerImageFile in playerImageFiles)
{
files.Add(playerImageFile.FullName);
}
}

// delete the selected files
Expand Down
2 changes: 1 addition & 1 deletion ARK Server Manager/Lib/ServerRCON.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ private async Task UpdatePlayerDetails()
}

if (player != null)
player.UpdateDataAsync(playerData).DoNotWait();
player.UpdateDataAsync(playerData, savedPath).DoNotWait();
}

this.Players = new SortableObservableCollection<PlayerInfo>(players);
Expand Down
9 changes: 7 additions & 2 deletions ARK Server Manager/Lib/ViewModel/PlayerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,19 @@ public Player PlayerData
set { SetValue(PlayerDataProperty, value); }
}

internal async Task UpdateDataAsync(Player playerData)
internal async Task UpdateDataAsync(Player playerData, string imageSavePath)
{
if (!_dataUpdated)
return;
_dataUpdated = false;

try
{
if (string.IsNullOrWhiteSpace(imageSavePath))
imageSavePath = Path.GetTempPath();
if (!Directory.Exists(imageSavePath))
Directory.CreateDirectory(imageSavePath);

this.PlayerData = playerData;
this.LastUpdated = playerData.FileUpdated;
this.TribeName = playerData.Tribe?.Name;
Expand All @@ -147,7 +152,7 @@ internal async Task UpdateDataAsync(Player playerData)
}
else
{
var localImageFile = Path.Combine(Path.GetTempPath(), $"ASM.{this.SteamId}.tmp");
var localImageFile = Path.Combine(imageSavePath, $"{this.SteamId}{Config.Default.PlayerImageFileExtension}");

// check for a valid URL.
if (!String.IsNullOrWhiteSpace(playerData.AvatarUrl))
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
5 changes: 4 additions & 1 deletion Plugin.Common/PluginHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,12 @@ internal bool ProcessAlert(AlertType alertType, string profileName, string alert
if (plugins.Count() == 0)
return false;

var message = alertMessage.Replace("\\r\\n", "\\n");
message = message.Replace("\\n", "\n");

foreach (var pluginItem in plugins)
{
((IAlertPlugin)pluginItem.Plugin).HandleAlert(alertType, profileName, alertMessage);
((IAlertPlugin)pluginItem.Plugin).HandleAlert(alertType, profileName, message);
}
}

Expand Down

0 comments on commit c244258

Please sign in to comment.