示例#1
0
 public Config(LauncherProfile profile, FileInfo file, FileIniDataParser fileIniDataParser = null)
 {
     this.FileIniDataParser = fileIniDataParser;
     this.File = file;
     if (this.File.Exists)
     {
         this.Load();
     }
 }
示例#2
0
 // public string Name { get { return this.Config.Data.Global["name"]; } }
 public MMCInstance(LauncherProfile profile, DirectoryInfo directory, FileIniDataParser fileIniDataParser = null)
 {
     this.Directory = directory; this.Profile = profile;
     if (fileIniDataParser is null)
     {
         fileIniDataParser = new FileIniDataParser();
     }
     this.Config = new Config(profile, this.Directory.CombineFile("instance.cfg"), fileIniDataParser);
     // Console.WriteLine(this.ToJson());
 }
示例#3
0
 public MMCPack fromProfile(LauncherProfile profile)
 {
     Data = new
            return(this);
 }
示例#4
0
        static void Main(string[] args)
        {
            Console.WriteLine($"Reading {VanillaLauncherProfilesJSON.FullName.Quote()}");
            var launcherProfiles = LauncherProfiles.FromJson(VanillaLauncherProfilesJSON.ReadAllText());

            Console.WriteLine($"Loaded {launcherProfiles.Profiles.Count} profiles from {VanillaLauncherProfilesJSON.Name.Quote()}");
            foreach (var _profile in launcherProfiles.Profiles)
            {
                var profile = new LauncherProfile(_profile.Key, _profile.Value);
                Console.WriteLine($"Processing profile {profile.Data.Name} ({profile.Id}) ...");
                if (profile.Data.Type != "custom")
                {
                    continue;
                }

                if (!profile.MMCInstance.Directory.Exists)
                {
                    Console.WriteLine($"Creating directory {profile.MMCInstance.Directory.FullName.Quote()}");
                    profile.MMCInstance.Directory.Create();
                }

                if (!profile.MMCInstance.Config.File.Exists)
                {
                    Console.WriteLine($"Creating file {profile.MMCInstance.Config.File.FullName.Quote()}");
                    profile.MMCInstance.Config.Data = new MMCInstanceConfig().iniData;
                }

                profile.MMCInstance.Config.Data.Global["name"] = (string.IsNullOrWhiteSpace(profile.Data.Name) ? profile.Data.Name : profile.Id);
                // var JavaPath = new FileInfo();
                if (profile.Data.JavaDir != null)
                {
                    profile.MMCInstance.Config.Data.Global["JavaPath"] = profile.Data.JavaDir.FullName.Replace("\\", "/");
                }
                else
                {
                    profile.MMCInstance.Config.Data.Global["OverrideJavaLocation"] = "false";
                }
                if (profile.Data.JavaArgs != null)
                {
                    profile.MMCInstance.Config.Data.Global["JvmArgs"] = profile.Data.JavaArgs;
                }
                else
                {
                    profile.MMCInstance.Config.Data.Global["OverrideJavaArgs"] = "false";
                }
                if (profile.Data.Created.HasValue)
                {
                    profile.MMCInstance.Config.Data.Global["JavaTimestamp"] = profile.Data.Created.Value.ToUnixTimeMilliseconds().ToString();
                }
                if (profile.Data.LastUsed.HasValue)
                {
                    profile.MMCInstance.Config.Data.Global["lastLaunchTime"] = profile.Data.LastUsed.Value.ToUnixTimeMilliseconds().ToString();
                }

                // TODO: Convert RAM from JVMARGS
                profile.MMCInstance.Config.Save();


                /*sb = new StringBuilder("public string " + item.KeyName + " { get; set; }");
                 * if (!string.IsNullOrWhiteSpace(item.Value)) sb.Append(" = \"" + item.Value.ToString() + "\";");
                 * sb.Print();*/
                // new StringBuilder(" { \"" + item.KeyName + "\", \"" + item.Value + "\" },").Print();
                // new StringBuilder("iniData.Global.AddKey(\"" + item.KeyName + "\", \"" + item.Value + "\");").Print();
            }
        }