예제 #1
0
        public void SyncDependentConfigToDisk()
        {
            var newConfig = new ModConfig();

            newConfig.GamePath      = GamePath;
            newConfig.LaunchCommand = LaunchCommand;
            newConfig.RefuseMismatchedConnections = OurIntegrator.RefuseMismatchedConnections;
            newConfig.Profiles   = ProfileList;
            newConfig.ModsOnDisk = GenerateProfile();

            File.WriteAllBytes(Path.Combine(DownloadPath, "modconfig.json"), Encoding.UTF8.GetBytes(AMLUtils.SerializeObject(newConfig)));
        }
        private void ForceExportProfile()
        {
            if (listBox1.SelectedValue == null || SelectedProfile == null)
            {
                this.ShowBasicButton("Please select a profile to export it as a .zip file.", "OK", null, null);
                return;
            }

            var dialog = new SaveFileDialog();

            dialog.Filter           = "ZIP files (*.zip)|*.zip|All files (*.*)|*.*";
            dialog.Title            = "Export a profile";
            dialog.RestoreDirectory = true;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string targetFolderPath = Path.Combine(Path.GetTempPath(), "AstroModLoader", "export");
                Directory.CreateDirectory(targetFolderPath);

                ModProfile creatingProfile = new ModProfile();
                creatingProfile.ProfileData = new Dictionary <string, Mod>();
                creatingProfile.Name        = listBox1.SelectedValue as string;
                creatingProfile.Info        = "Exported by " + AMLUtils.UserAgent + " at " + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffK");

                List <KeyValuePair <string, Mod> > plannedOrdering = new List <KeyValuePair <string, Mod> >();
                foreach (KeyValuePair <string, Mod> entry in SelectedProfile.ProfileData)
                {
                    if (entry.Value.Enabled)
                    {
                        plannedOrdering.Add(entry);
                    }
                }
                plannedOrdering = new List <KeyValuePair <string, Mod> >(plannedOrdering.OrderBy(o => o.Value.Priority).ToList());

                for (int i = 0; i < plannedOrdering.Count; i++)
                {
                    plannedOrdering[i].Value.Priority = i + 1;
                    creatingProfile.ProfileData[plannedOrdering[i].Key] = plannedOrdering[i].Value;

                    // Copy mod pak to the zip as well
                    string onePathOnDisk = OurParentForm.ModManager.GetPathOnDisk(plannedOrdering[i].Value, plannedOrdering[i].Key);
                    if (!string.IsNullOrEmpty(onePathOnDisk))
                    {
                        File.Copy(onePathOnDisk, Path.Combine(targetFolderPath, Path.GetFileName(onePathOnDisk)));
                    }
                }

                File.WriteAllBytes(Path.Combine(targetFolderPath, "profile1.json"), Encoding.UTF8.GetBytes(AMLUtils.SerializeObject(creatingProfile)));

                ZipFile.CreateFromDirectory(targetFolderPath, dialog.FileName);
                Directory.Delete(targetFolderPath, true);

                RefreshBox();
                statusLabel.Text = "Successfully exported profile.";
            }
        }
예제 #3
0
        public void SyncIndependentConfigToDisk()
        {
            var newIndConfig = new IndependentConfig();

            if (Program.CommandLineOptions.ServerMode)
            {
                newIndConfig.Platform = FirstRecordedIndependentConfigPlatform;
            }
            else
            {
                newIndConfig.Platform = Platform;
            }
            newIndConfig.Theme           = AMLPalette.CurrentTheme;
            newIndConfig.AccentColor     = AMLUtils.ColorToHTML(AMLPalette.AccentColor);
            newIndConfig.CustomBasePath  = CustomBasePath;
            newIndConfig.PlayFabCustomID = PlayFabAPI.CustomID;
            newIndConfig.PlayFabToken    = PlayFabAPI.Token;

            Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AstroModLoader"));
            File.WriteAllBytes(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AstroModLoader", "config.json"), Encoding.UTF8.GetBytes(AMLUtils.SerializeObject(newIndConfig)));
        }