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.LauncherSource = "/Launcher"; config.LauncherUrl = "/Data/Launcher"; config.LauncherFileName = "MitriaMLauncher.exe"; 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(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(fullPath); } else { launcherPatchInformation.Version = "0.0.0.0"; } // 혹시모를 변경 될수도 있음 launcherPatchInformation.LauncherUrl = config.LauncherUrl; launcherPatchInformation.LauncherFileName = config.LauncherFileName; return launcherPatchInformation; } 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() { CommonLibrary.DataPatchInformation dataPatchInformation = new CommonLibrary.DataPatchInformation(); string fullPath = config.Target + config.InformationToData; if (System.IO.File.Exists(fullPath)) { dataPatchInformation = CommonLibrary.XMLSystem.LoadFromPath(fullPath); } else { dataPatchInformation.RuntimeVersion = "0.0.0.0"; dataPatchInformation.PackageVersion = "0.0.0.0"; dataPatchInformation.PackageDirectorys = new System.Collections.Generic.List(); dataPatchInformation.ComponentVersion = "0.0.0.0"; dataPatchInformation.ComponentDirectorys = new System.Collections.Generic.List(); dataPatchInformation.ComponentList = new System.Collections.Generic.List(); } 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(CommonLibrary.DataPatchInformation dataPatchInformation) { string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target , 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 LauncherSource { get; set; } // {Source}/Launcher public string LauncherUrl { get; set; } // {Target}/Launcher 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 } }