Skip to content

Commit

Permalink
Merge pull request #175 from ChronosWS/BletchChanges
Browse files Browse the repository at this point in the history
ASM 326 Changes
  • Loading branch information
Bletch1971 authored May 8, 2018
2 parents 038ab26 + 59e8a9f commit 2f2339c
Show file tree
Hide file tree
Showing 34 changed files with 1,475 additions and 738 deletions.
7 changes: 6 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>6</ApplicationRevision>
<ApplicationVersion>1.0.326.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down Expand Up @@ -161,20 +161,25 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Common\Converters\DoubleRangeValueConverter.cs" />
<Compile Include="Common\Converters\InvertBooleanToVisibilityConverter.cs" />
<Compile Include="Common\Converters\SecondsToMinutesConverter.cs" />
<Compile Include="Common\Converters\SecondsToHoursConverter.cs" />
<Compile Include="Common\Converters\IntRangeValueConverter.cs" />
<Compile Include="Common\Lib\BrowserBehavior.cs" />
<Compile Include="Common\Model\PublishedFileDetail.cs" />
<Compile Include="Common\Model\SteamCmdManifestDetails.cs" />
<Compile Include="Common\Model\VersionFeed.cs" />
<Compile Include="Common\Model\VersionFeedEntry.cs" />
<Compile Include="Common\Serialization\IniFile.cs" />
<Compile Include="Common\Serialization\IniKey.cs" />
<Compile Include="Common\Serialization\IniSection.cs" />
<Compile Include="Common\Utils\IOUtils.cs" />
<Compile Include="Common\Utils\VersionFeedUtils.cs" />
<Compile Include="Lib\Enums\LevelProgression.cs" />
<Compile Include="Lib\Enums\ServerProfileCategory.cs" />
<Compile Include="Lib\Model\ArkApplicationComboBoxItem.cs" />
<Compile Include="Lib\Model\PlayerListParameters.cs" />
<Compile Include="Lib\ServerBranchSnapshot.cs" />
<Compile Include="Lib\ServerPlayers.cs" />
<Compile Include="Lib\ServerProfileSnapshot.cs" />
<Compile Include="Lib\Utils\GameDataUtils.cs" />
Expand Down
35 changes: 31 additions & 4 deletions ARK Server Manager/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<value>+login anonymous +quit</value>
</setting>
<setting name="SteamCmdInstallServerArgsFormat" serializeAs="String">
<value>+login anonymous +force_install_dir "{0}" "+app_update 376030 {1}" +quit</value>
<value>+login anonymous +force_install_dir "{0}" "+app_update 376030 {1} {2}" +quit</value>
</setting>
<setting name="ServersInstallDir" serializeAs="String">
<value>Servers</value>
Expand Down Expand Up @@ -121,7 +121,7 @@
<setting name="ProfilesDir" serializeAs="String">
<value>Profiles</value>
</setting>
<setting name="ProfileExtension" serializeAs="String">
<setting name="ProfileExtensionOld" serializeAs="String">
<value>.profile</value>
</setting>
<setting name="DefaultServerMap" serializeAs="String">
Expand Down Expand Up @@ -167,7 +167,7 @@
<value>http://arkservermanager.freeforums.net/thread/1194/faq-frequently-asked</value>
</setting>
<setting name="SteamCmdInstallServerArgsFormat_SotF" serializeAs="String">
<value>+login anonymous +force_install_dir "{0}" "+app_update 445400 {1}" +quit</value>
<value>+login anonymous +force_install_dir "{0}" "+app_update 445400 {1} {2}" +quit</value>
</setting>
<setting name="ArkSE_PatchNotesUrl" serializeAs="String">
<value>https://survivetheark.com/index.php?/forums/forum/5-changelog-patch-notes/</value>
Expand Down Expand Up @@ -310,7 +310,7 @@
<setting name="ASMPluginUrl" serializeAs="String">
<value>http://arkservermanager.freeforums.net/board/22/plugins</value>
</setting>
<setting name="ProfileExtensionNew" serializeAs="String">
<setting name="ProfileExtension" serializeAs="String">
<value>.asmprofile</value>
</setting>
<setting name="PlayerFileExtension" serializeAs="String">
Expand Down Expand Up @@ -361,6 +361,27 @@
<setting name="ServerManagerVersionBetaFeedUrl" serializeAs="String">
<value>http://arksm.azurewebsites.net/downloads/arkservermanager/beta/versionfeed.xml</value>
</setting>
<setting name="DefaultServerBranchName" serializeAs="String">
<value>release</value>
</setting>
<setting name="SteamCmdInstallServerBetaNameArgsFormat" serializeAs="String">
<value>-beta {0}</value>
</setting>
<setting name="SteamCmdInstallServerBetaPasswordArgsFormat" serializeAs="String">
<value>-betapassword {0}</value>
</setting>
<setting name="ServerBranchFolderPrefix" serializeAs="String">
<value>__</value>
</setting>
<setting name="ArkSteamManifestFile" serializeAs="String">
<value>appmanifest_376030.acf</value>
</setting>
<setting name="ArkSteamManifestFile_SotF" serializeAs="String">
<value>appmanifest_407530.acf</value>
</setting>
<setting name="SteamManifestFolderRelativePath" serializeAs="String">
<value>steamapps</value>
</setting>
</ARK_Server_Manager.Config>
</applicationSettings>
<userSettings>
Expand Down Expand Up @@ -674,6 +695,12 @@
<setting name="RCON_ShowPlayerAvatars" serializeAs="String">
<value>True</value>
</setting>
<setting name="SectionPGMEnabled" serializeAs="String">
<value>False</value>
</setting>
<setting name="SectionSOTFEnabled" serializeAs="String">
<value>False</value>
</setting>
</ARK_Server_Manager.Config>
</userSettings>
</configuration>
16 changes: 0 additions & 16 deletions ARK Server Manager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,6 @@ private static void MigrateSettings()
Config.Default.Reload();
Config.Default.UpgradeConfig = false;

#if false
object previousEnableSettingsCache = null;
try { previousEnableSettingsCache = Config.Default.GetPreviousVersion(nameof(Config.Default.GLOBAL_EnableServerCache)); }
catch (SettingsPropertyNotFoundException) { /* this would get thrown if we were renaming a property, see http://www.codeproject.com/Articles/247333/Renaming-User-Settings-properties-between-software */ }

if (previousEnableSettingsCache == null)
{
int serverupdatePeriod = 0;
Int32.TryParse(Config.Default.GetPreviousVersion(nameof(Config.Default.AutoUpdate_UpdatePeriod)).ToString(), out serverupdatePeriod);
if (!String.IsNullOrWhiteSpace(Config.Default.GetPreviousVersion(nameof(Config.Default.AutoUpdate_CacheDir)).ToString()) &&
serverupdatePeriod > 0)
{
Config.Default.GLOBAL_EnableServerCache = true;
}
}
#endif
Config.Default.Save();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace ARK_Server_Manager.Lib.ViewModel
{
public class InvertBooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool flag = false;
if (value is bool)
{
flag = (bool)value;
}
else if (value is bool?)
{
bool? nullable = (bool?)value;
flag = nullable.HasValue && nullable.Value;
}
return flag ? Visibility.Collapsed : Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Visibility)
return (Visibility)value == Visibility.Collapsed;
return false;
}
}
}
2 changes: 0 additions & 2 deletions ARK Server Manager/Common/Lib/SteamCmdUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ enum Status
{ Status.Cancelled, Update.AsCancelled("AutoUpdater_Status_Cancelled") }
};

public static bool IsAutoUpdateCacheEnabled => Config.Default.AutoUpdate_EnableUpdate && Config.Default.AutoUpdate_UpdatePeriod >= 0 && !string.IsNullOrWhiteSpace(Config.Default.AutoUpdate_CacheDir) && Directory.Exists(Config.Default.AutoUpdate_CacheDir);

public static string GetLogFolder() => IOUtils.NormalizePath(Path.Combine(Config.Default.DataDir, Config.Default.LogsDir));

public static Version GetServerVersion(string versionFile)
Expand Down
90 changes: 90 additions & 0 deletions ARK Server Manager/Common/Model/SteamCmdManifestDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using NeXt.Vdf;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ARK_Server_Manager.Lib.Model
{
public class SteamCmdManifestDetailsResult
{
public static void ClearUserConfigBetaKeys(VdfValue data)
{
var vdfTable = data as VdfTable;
if (vdfTable != null)
{
var value = vdfTable.FirstOrDefault(v => v.Name.Equals("UserConfig", StringComparison.OrdinalIgnoreCase));
var tableValue = value as VdfTable;
if (tableValue != null && tableValue.Count > 0)
{
var betaKeyItems = tableValue.Where(v => v.Name.Equals("betakey", StringComparison.OrdinalIgnoreCase)).ToArray();
foreach (var item in betaKeyItems)
{
tableValue.Remove(item);
}
}
}
}

public static SteamCmdAppManifest Deserialize(VdfValue data)
{
var result = new SteamCmdAppManifest();

var vdfTable = data as VdfTable;
if (vdfTable != null)
{
var value = vdfTable.FirstOrDefault(v => v.Name.Equals("appid", StringComparison.OrdinalIgnoreCase));
if (value != null) result.appid = GetValue(value);

value = vdfTable.FirstOrDefault(v => v.Name.Equals("UserConfig", StringComparison.OrdinalIgnoreCase));
var tableValue = value as VdfTable;
if (tableValue != null && tableValue.Count > 0)
{
result.UserConfig = new List<SteamCmdManifestUserConfig>();

foreach (var item in tableValue)
{
if (item is VdfTable)
{
var temp = new SteamCmdManifestUserConfig();
temp.betakey = item.Name;

result.UserConfig.Add(temp);
}
}
}
}

return result;
}

public static string GetValue(VdfValue data)
{
if (data == null)
return null;

switch (data.Type)
{
case VdfValueType.Decimal:
return ((VdfDecimal)data).Content.ToString("G0");
case VdfValueType.Long:
return ((VdfLong)data).Content.ToString("G0");
case VdfValueType.String:
return ((VdfString)data).Content;
default:
return null;
}
}
}

public class SteamCmdAppManifest
{
public string appid { get; set; }

public List<SteamCmdManifestUserConfig> UserConfig { get; set; }
}

public class SteamCmdManifestUserConfig
{
public string betakey { get; set; }
}
}
28 changes: 17 additions & 11 deletions ARK Server Manager/Common/Serialization/SystemIniFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ public class IniFileEntryAttribute : Attribute
/// <param name="File">The file into which the setting should be serialized.</param>
/// <param name="Section">The section in the ini file.</param>
/// <param name="Key">The key within the section. Defaults to the same name as the attributed field.</param>
public IniFileEntryAttribute(IniFiles file, IniFileSections section, string key = "")
public IniFileEntryAttribute(IniFiles file, IniFileSections section, string key = "", ServerProfileCategory category = ServerProfileCategory.Unknown)
{
this.File = file;
this.Section = section;
this.Key = key;
this.Category = category;

this.QuotedString = QuotedStringType.False;
}
Expand All @@ -68,6 +69,11 @@ public IniFileEntryAttribute(IniFiles file, IniFileSections section, string key
/// </summary>
public IniFileSections Section;

/// <summary>
/// The category of the setting.
/// </summary>
public ServerProfileCategory Category;

/// <summary>
/// The key within the section.
/// </summary>
Expand Down Expand Up @@ -147,22 +153,22 @@ public SystemIniFile(string INIPath)
basePath = INIPath;
}

public void Deserialize(object obj, string[] exclusions)
public void Deserialize(object obj, ServerProfileCategory[] exclusions)
{
var iniFiles = new Dictionary<string, IniFile>();
var fields = obj.GetType().GetProperties().Where(f => f.IsDefined(typeof(IniFileEntryAttribute), false));

if (exclusions == null)
exclusions = new string[0];
exclusions = new ServerProfileCategory[0];

foreach (var field in fields)
{
if (exclusions.Contains(field.Name))
continue;

var attributes = field.GetCustomAttributes(typeof(IniFileEntryAttribute), false);
foreach (var attr in attributes.OfType<IniFileEntryAttribute>())
{
if (exclusions.Contains(attr.Category))
continue;

if (attr.Section == IniFileSections.Custom)
{
// this code is to handle custom sections
Expand Down Expand Up @@ -258,22 +264,22 @@ public void Deserialize(object obj, string[] exclusions)
}
}

public void Serialize(object obj, string[] exclusions)
public void Serialize(object obj, ServerProfileCategory[] exclusions)
{
var iniFiles = new Dictionary<string, IniFile>();
var fields = obj.GetType().GetProperties().Where(f => f.IsDefined(typeof(IniFileEntryAttribute), false));

if (exclusions == null)
exclusions = new string[0];
exclusions = new ServerProfileCategory[0];

foreach (var field in fields)
{
if (exclusions.Contains(field.Name))
continue;

var attributes = field.GetCustomAttributes(typeof(IniFileEntryAttribute), false).OfType<IniFileEntryAttribute>();
foreach (var attr in attributes)
{
if (exclusions.Contains(attr.Category))
continue;

if (attr.Section == IniFileSections.Custom)
{
// this code is to handle custom sections
Expand Down
11 changes: 11 additions & 0 deletions ARK Server Manager/Common/Utils/SteamUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ public static SteamUserDetailResponse GetSteamUserDetails(List<string> steamIdLi
}
}

public static SteamCmdAppManifest ReadSteamCmdAppManifestFile(string file)
{
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
return null;

var vdfSerializer = VdfDeserializer.FromFile(file);
var vdf = vdfSerializer.Deserialize();

return SteamCmdManifestDetailsResult.Deserialize(vdf);
}

public static SteamCmdAppWorkshop ReadSteamCmdAppWorkshopFile(string file)
{
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
Expand Down
Loading

0 comments on commit 2f2339c

Please sign in to comment.