160 lines
7.1 KiB
C#
160 lines
7.1 KiB
C#
using System;
|
|
|
|
namespace Mitria_Minecraft_Updater
|
|
{
|
|
public static class Settings
|
|
{
|
|
#pragma warning disable S1104 // Fields should not have public accessibility
|
|
#pragma warning disable S2223 // Non-constant static fields should not be visible
|
|
public static Config config;
|
|
#pragma warning restore S2223 // Non-constant static fields should not be visible
|
|
#pragma warning restore S1104 // Fields should not have public accessibility
|
|
public static readonly string configPath = "config.xml";
|
|
|
|
private static void InitializationConfig()
|
|
{
|
|
// 줄여야함
|
|
config.Source = "../Source";
|
|
config.Target = "../Target";
|
|
|
|
config.InformationToLauncher = "/launcher.xml";
|
|
config.InformationToData = "/data.xml";
|
|
config.InformationToServer = "/server.xml";
|
|
|
|
config.LauncherSource = "/Launcher";
|
|
config.LauncherUrl = "/Launcher";
|
|
config.LauncherSourceFileName = "MitriaMLauncher.exe";
|
|
config.LauncherFileName = "MitriaMLauncher.pack";
|
|
config.RuntimeSource = "/Runtime";
|
|
config.RuntimeUrl = "/Data/Runtime";
|
|
config.RuntimeFileName = "Runtime.pack";
|
|
config.PackageSource = "/Package";
|
|
config.PackageUrl = "/Data/Package";
|
|
config.PackageFileName = "Package.pack";
|
|
config.ComponentSource = "/Component";
|
|
config.ComponentUrl = "/Data/Component";
|
|
}
|
|
|
|
public static void LoadConfig()
|
|
{
|
|
if (System.IO.File.Exists(configPath))
|
|
{
|
|
config = CommonLibrary.XmlSystem.LoadFromPath<Config>(configPath);
|
|
}
|
|
else
|
|
{
|
|
InitializationConfig();
|
|
SaveConfig();
|
|
}
|
|
}
|
|
|
|
public static void SaveConfig()
|
|
{
|
|
CommonLibrary.XmlSystem.Save(configPath, config);
|
|
}
|
|
|
|
public static CommonLibrary.LauncherPatchInformation LoadLauncherPatchInformation()
|
|
{
|
|
CommonLibrary.LauncherPatchInformation launcherPatchInformation = new CommonLibrary.LauncherPatchInformation();
|
|
string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target, config.InformationToLauncher);
|
|
if (System.IO.File.Exists(fullPath))
|
|
{
|
|
launcherPatchInformation = CommonLibrary.XmlSystem.LoadFromPath<CommonLibrary.LauncherPatchInformation>(fullPath);
|
|
}
|
|
else
|
|
{
|
|
launcherPatchInformation.Version = "0.0.0.0";
|
|
}
|
|
// 혹시모를 변경 될수도 있음
|
|
launcherPatchInformation.LauncherUrl = config.LauncherUrl;
|
|
launcherPatchInformation.LauncherFileName = config.LauncherFileName;
|
|
return launcherPatchInformation;
|
|
}
|
|
|
|
public static CommonLibrary.ServerInformation LoadServerInformation()
|
|
{
|
|
CommonLibrary.ServerInformation serverInformation = new CommonLibrary.ServerInformation();
|
|
string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target, config.InformationToServer);
|
|
if(System.IO.File.Exists(fullPath))
|
|
{
|
|
serverInformation = CommonLibrary.XmlSystem.LoadFromPath<CommonLibrary.ServerInformation>(fullPath);
|
|
}
|
|
|
|
return serverInformation;
|
|
}
|
|
|
|
public static void SaveLauncherPatchInformation(CommonLibrary.LauncherPatchInformation launcherPatchInformation)
|
|
{
|
|
|
|
string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target, config.InformationToLauncher);
|
|
if (!System.IO.Directory.Exists(config.Target))
|
|
{
|
|
System.IO.Directory.CreateDirectory(config.Target);
|
|
}
|
|
CommonLibrary.XmlSystem.Save(fullPath, launcherPatchInformation);
|
|
}
|
|
|
|
public static CommonLibrary.DataPatchInformation LoadDataPatchInformation(string serverName)
|
|
{
|
|
CommonLibrary.DataPatchInformation dataPatchInformation = new CommonLibrary.DataPatchInformation();
|
|
string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target, "Servers", serverName, config.InformationToData);
|
|
if (System.IO.File.Exists(fullPath))
|
|
{
|
|
dataPatchInformation = CommonLibrary.XmlSystem.LoadFromPath<CommonLibrary.DataPatchInformation>(fullPath);
|
|
}
|
|
else
|
|
{
|
|
dataPatchInformation.RuntimeVersion = "0.0.0.0";
|
|
dataPatchInformation.PackageVersion = "0.0.0.0";
|
|
dataPatchInformation.PackageDirectorys = new System.Collections.Generic.List<string>();
|
|
dataPatchInformation.ComponentVersion = "0.0.0.0";
|
|
dataPatchInformation.ComponentDirectorys = new System.Collections.Generic.List<string>();
|
|
dataPatchInformation.ComponentList = new System.Collections.Generic.List<CommonLibrary.FileDetail>();
|
|
}
|
|
dataPatchInformation.RuntimeUrl = config.RuntimeUrl;
|
|
dataPatchInformation.RuntimeFileName = config.RuntimeFileName;
|
|
dataPatchInformation.PackageUrl = config.PackageUrl;
|
|
dataPatchInformation.PackageFileName = config.PackageFileName;
|
|
dataPatchInformation.ComponentUrl = config.ComponentUrl;
|
|
|
|
return dataPatchInformation;
|
|
}
|
|
|
|
public static void SaveDataPatchInformation(string serverName, CommonLibrary.DataPatchInformation dataPatchInformation)
|
|
{
|
|
string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target, "Servers", serverName, config.InformationToData);
|
|
if (!System.IO.Directory.Exists(config.Target))
|
|
{
|
|
System.IO.Directory.CreateDirectory(config.Target);
|
|
}
|
|
CommonLibrary.XmlSystem.Save(fullPath, dataPatchInformation);
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public struct Config
|
|
{
|
|
public string Source { get; set; } //./Source
|
|
public string Target { get; set; } ///usr/share/nginx/html/Patchdata
|
|
public string DataDirectory { get; set; } // {Target}/Data
|
|
|
|
public string InformationToLauncher { get; set; } //{InformationDirectory}/Launcher.xml
|
|
public string InformationToData { get; set; } // {InformationDirectory}/Data.xml
|
|
public string InformationToServer { get; set; }
|
|
public string LauncherSource { get; set; } // {Source}/Launcher
|
|
public string LauncherUrl { get; set; } // {Target}/Launcher
|
|
public string LauncherSourceFileName { get; set; }
|
|
public string LauncherFileName { get; set; } // 런처 파일이름
|
|
|
|
public string RuntimeSource { get; set; } // {Source}/Runtime
|
|
public string RuntimeUrl { get; set; } // {Target}/Runtime
|
|
public string RuntimeFileName { get; set; } // Runtime.pack
|
|
|
|
public string PackageSource { get; set; } // {Source}/Package
|
|
public string PackageUrl { get; set; } // {Target}/Package
|
|
public string PackageFileName { get; set; } // Package.pack
|
|
|
|
public string ComponentSource { get; set; } // {Source}/GameFile
|
|
public string ComponentUrl { get; set; } // {Target}/GameFile
|
|
}
|
|
} |