source code checkin

This commit is contained in:
Brett Hewitson 2021-01-07 16:23:23 +10:00
parent 5f8fb2c825
commit 7e57b72e35
675 changed files with 168433 additions and 0 deletions

View file

@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<SccProjectName>%24/Development/ServerManagers/Main/ConanServerManager.Common</SccProjectName>
<SccProvider>{4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}</SccProvider>
<SccAuxPath>https://dev.azure.com/bretthewitson</SccAuxPath>
<SccLocalPath>.</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RootNamespace>ServerManagerTool</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Enums\**" />
<Compile Remove="Lib\**" />
<EmbeddedResource Remove="Enums\**" />
<EmbeddedResource Remove="Lib\**" />
<None Remove="Enums\**" />
<None Remove="Lib\**" />
</ItemGroup>
<ItemGroup>
<None Remove="ConanServerManager.Common.csproj.vspscc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ServerManager.Common\ServerManager.Common.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConanServerManager Common Library")]
[assembly: AssemblyDescription("The library is used to provide common functionality to the conan server manager.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Bletch1971")]
[assembly: AssemblyProduct("Server Managers")]
[assembly: AssemblyCopyright("Copyright © 2015-2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("630422ca-4bcc-4d1d-9701-87d8eaf0b209")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,151 @@
using ServerManagerTool.Common.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
namespace ServerManagerTool.Utils
{
public static class GameDataUtils
{
public static void ReadAllData(out MainGameData data, string dataFolder, string extension, string application, bool isUserData = false)
{
data = new MainGameData();
if (string.IsNullOrWhiteSpace(dataFolder))
return;
if (!Directory.Exists(dataFolder))
return;
foreach (var file in Directory.GetFiles(dataFolder, $"*{extension}", SearchOption.TopDirectoryOnly))
{
try
{
var fileData = MainGameData.Load(file, isUserData);
if (fileData == null)
continue;
if (!fileData.Application.Equals(application, StringComparison.OrdinalIgnoreCase))
continue;
data.GameMaps.AddRange(fileData.GameMaps);
data.Branches.AddRange(fileData.Branches);
data.ServerRegions.AddRange(fileData.ServerRegions);
}
catch
{
// do nothing, just swallow the error
}
}
}
}
[DataContract]
public class BaseGameData
{
public string GameDataFile = string.Empty;
[DataMember]
public string Application = string.Empty;
[DataMember]
public string Version = "1.0.0";
[DataMember]
public DateTime Created = DateTime.UtcNow;
[DataMember]
public string Color = "White";
public static BaseGameData Load(string file)
{
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
return null;
var data = JsonUtils.DeserializeFromFile<BaseGameData>(file);
if (data != null)
{
data.GameDataFile = file;
}
return data;
}
public bool Save(string file)
{
var folder = Path.GetDirectoryName(file);
if (!Directory.Exists(folder))
Directory.CreateDirectory(folder);
return JsonUtils.SerializeToFile(this, file);
}
}
[DataContract]
public class MainGameData : BaseGameData
{
[DataMember(IsRequired = false)]
public List<GameMapDataItem> GameMaps = new List<GameMapDataItem>();
[DataMember(IsRequired = false)]
public List<BranchDataItem> Branches = new List<BranchDataItem>();
[DataMember(IsRequired = false)]
public List<ServerRegionDataItem> ServerRegions = new List<ServerRegionDataItem>();
public static MainGameData Load(string file, bool isUserData)
{
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
return null;
var data = JsonUtils.DeserializeFromFile<MainGameData>(file);
if (data != null)
{
data.GameDataFile = file;
data.GameMaps.ForEach(c => c.IsUserData = isUserData);
data.Branches.ForEach(c => c.IsUserData = isUserData);
data.ServerRegions.ForEach(c => c.IsUserData = isUserData);
}
return data;
}
}
[DataContract]
public class BaseDataItem
{
[DataMember]
public string ClassName = string.Empty;
[DataMember]
public string Description = string.Empty;
[DataMember]
public string Mod = string.Empty;
public bool IsUserData = false;
}
[DataContract]
public class GameMapDataItem : BaseDataItem
{
[DataMember]
public string SaveFileName = string.Empty;
}
[DataContract]
public class BranchDataItem
{
[DataMember]
public string BranchName = string.Empty;
[DataMember]
public string Description = string.Empty;
public bool IsUserData = false;
}
[DataContract]
public class ServerRegionDataItem
{
[DataMember]
public string RegionNumber = string.Empty;
[DataMember]
public string Description = string.Empty;
public bool IsUserData = false;
}
}