コード例 #1
0
        public static void RefreshSelectedModProperties(ref ModManager Instance)
        {
            RefreshModManagementButtons(ref Instance);
            if (Instance.ModViewer.SelectedItem != null)
            {
                AIR_API.Mod item = (Instance.ModViewer.SelectedItem as ModViewerItem).Source;
                if (item != null)
                {
                    string author      = $"{Program.LanguageResource.GetString("By")}: {item.Author}";
                    string version     = $"{Program.LanguageResource.GetString("Version")}: {item.ModVersion}";
                    string air_version = $"{Program.LanguageResource.GetString("AIRVersion")}: {item.GameVersion}";
                    string tech_name   = $"{item.TechnicalName}";

                    string description = item.Description;
                    if (description == "No Description Provided.")
                    {
                        description = Program.LanguageResource.GetString("NoModDescript");
                    }

                    Paragraph author_p      = new Paragraph(new Run(author));
                    Paragraph version_p     = new Paragraph(new Run(version));
                    Paragraph air_version_p = new Paragraph(new Run(air_version));
                    Paragraph tech_name_p   = new Paragraph(new Run(tech_name));
                    Paragraph description_p = new Paragraph(new Run($"{Management.MainDataModel.nL}{description}"));


                    author_p.FontWeight      = FontWeights.Normal;
                    version_p.FontWeight     = FontWeights.Normal;
                    air_version_p.FontWeight = FontWeights.Normal;
                    tech_name_p.FontWeight   = FontWeights.Bold;
                    description_p.FontWeight = FontWeights.Normal;


                    var no_margin = new Thickness(0);
                    author_p.Margin      = no_margin;
                    version_p.Margin     = no_margin;
                    air_version_p.Margin = no_margin;
                    tech_name_p.Margin   = no_margin;
                    description_p.Margin = no_margin;

                    Instance.ModViewer.PHost.modInfoTextBox.Document.Blocks.Clear();
                    Instance.ModViewer.PHost.modInfoTextBox.Document.Blocks.Add(author_p);
                    Instance.ModViewer.PHost.modInfoTextBox.Document.Blocks.Add(version_p);
                    Instance.ModViewer.PHost.modInfoTextBox.Document.Blocks.Add(air_version_p);
                    Instance.ModViewer.PHost.modInfoTextBox.Document.Blocks.Add(tech_name_p);
                    Instance.ModViewer.PHost.modInfoTextBox.Document.Blocks.Add(description_p);
                }
                else
                {
                    Instance.ModViewer.PHost.modInfoTextBox.Document.Blocks.Clear();
                }
            }
            else
            {
                Instance.ModViewer.PHost.modInfoTextBox.Document.Blocks.Clear();
            }
        }
コード例 #2
0
 public bool?ShowConfigEditDialog(AIR_API.Mod mod)
 {
     EditorNameField.Text        = mod.Name;
     EditorAuthorField.Text      = mod.Author;
     EditorDescriptionField.Text = mod.Description;
     EditorURLField.Text         = mod.URL;
     EditorGameVersionField.Text = mod.GameVersion;
     EditorModVersionField.Text  = mod.ModVersion;
     return(this.ShowDialog());
 }
コード例 #3
0
        private static void ModMoveConflictResolve(AIR_API.Mod ExistingMod, AIR_API.Mod NewMod, string newPath)
        {
            var result = new ItemConflictDialog().ShowDialog(ExistingMod, NewMod);

            if (result == DialogResult.Yes)
            {
                DeleteOldMod();
                MoveMod();
            }
            else if (result == DialogResult.No)
            {
                MakeModCopy();
            }
            else
            {
                //Don't Import the Mod
            }


            #region Inside Methods

            void MakeModCopy()
            {
                string OriginalFolderName = ExistingMod.FolderName;
                string NewFolderName      = ExistingMod.FolderName;
                string PathLocation       = Directory.GetParent(newPath).FullName;
                int    index = 1;

                while (Directory.Exists(PathLocation + "\\" + NewFolderName))
                {
                    NewFolderName = $"{OriginalFolderName}({index})";
                }
                string ModPath = PathLocation + "\\" + NewFolderName;

                Directory.Move(ExistingMod.FolderPath, ModPath);
            }

            void MoveMod()
            {
                Directory.Move(ExistingMod.FolderPath, newPath);
            }

            void DeleteOldMod()
            {
                Management.FileManagement.WipeFolderContents(newPath);
                Directory.Delete(newPath);
            }

            #endregion
        }
コード例 #4
0
        public static void MoveMod(AIR_API.Mod modToMove, string path, bool updateUI = true)
        {
            string newPath = Path.Combine(path, modToMove.FolderName);

            if (!Directory.Exists(newPath))
            {
                Directory.Move(modToMove.FolderPath, newPath);
            }
            else
            {
                AIR_API.Mod conflictingMod = new AIR_API.Mod();
                if (File.Exists(Path.Combine(newPath, "mod.json")))
                {
                    conflictingMod = new AIR_API.Mod(new FileInfo(Path.Combine(newPath, "mod.json")));
                }
                ModMoveConflictResolve(modToMove, conflictingMod, newPath);
            }

            if (updateUI)
            {
                new Action(ModManager.UpdateUIFromInvoke).Invoke();
            }
        }
コード例 #5
0
        public System.Windows.Forms.DialogResult ShowDialog(AIR_API.Mod NewMod, AIR_API.Mod ExistingMod)
        {
            string nL = Environment.NewLine;

            this.label1.Document.Blocks.Clear();
            this.label2.Document.Blocks.Clear();
            this.label3.Document.Blocks.Clear();


            string existingMod    = Program.LanguageResource.GetString("ExistingModSection");
            string conflictingMod = Program.LanguageResource.GetString("ConflictingModSection");
            string name           = Program.LanguageResource.GetString("NameSection");
            string author         = Program.LanguageResource.GetString("AuthorSection");
            string modVersion     = Program.LanguageResource.GetString("ModVersionSection");
            string gameVersion    = Program.LanguageResource.GetString("GameVersionSection");

            Bold(ref label1);
            this.label1.AppendText($"{existingMod} " + nL);
            Bold(ref label1);
            this.label1.AppendText(nL + $"{name} ");
            Normal(ref label1);
            this.label1.AppendText($"{(ExistingMod != null ? ExistingMod.Name : "N/A")}" + nL);
            Bold(ref label1);
            this.label1.AppendText($"{author} ");
            Normal(ref label1);
            this.label1.AppendText($"{(ExistingMod != null ? ExistingMod.Author : "N/A")}" + nL);
            Bold(ref label1);
            this.label1.AppendText($"{modVersion} ");
            Normal(ref label1);
            this.label1.AppendText($"{(ExistingMod != null ? ExistingMod.ModVersion : "N/A")}" + nL);
            Bold(ref label1);
            this.label1.AppendText($"{gameVersion} ");
            Normal(ref label1);
            this.label1.AppendText($"{(ExistingMod != null ? ExistingMod.GameVersion : "N/A")}" + nL);


            Bold(ref label2);
            this.label2.AppendText($"{conflictingMod} " + nL);
            Bold(ref label2);
            this.label2.AppendText(nL + $"{name} ");
            Normal(ref label2);
            this.label2.AppendText($"{(NewMod != null ? NewMod.Name : "N/A")}" + nL);
            Bold(ref label2);
            this.label2.AppendText($"{author} ");
            Normal(ref label2);
            this.label2.AppendText($"{(NewMod != null ? NewMod.Author : "N/A")}" + nL);
            Bold(ref label2);
            this.label2.AppendText($"{modVersion} ");
            Normal(ref label2);
            this.label2.AppendText($"{(NewMod != null ? NewMod.ModVersion : "N/A")}" + nL);
            Bold(ref label2);
            this.label2.AppendText($"{gameVersion} ");
            Normal(ref label2);
            this.label2.AppendText($"{(NewMod != null ? NewMod.GameVersion : "N/A")}" + nL);


            string message = Program.LanguageResource.GetString("ConflictDialogCaption");

            this.label3.Document.Blocks.Add(new Paragraph(new Run(message)));
            base.ShowDialog();
            return(this.DialogResultForms);


            void Bold(ref RichTextBox textBox)
            {
                textBox.Selection.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
            }

            void Normal(ref RichTextBox textBox)
            {
                textBox.Selection.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);
            }
        }
コード例 #6
0
 public static void EnableMod(AIR_API.Mod mod)
 {
     S3AIRActiveMods.ActiveMods.Add(mod.FolderName);
 }
コード例 #7
0
 public static void DisableMod(AIR_API.Mod mod)
 {
     S3AIRActiveMods.ActiveMods.Remove(mod.FolderName);
 }
コード例 #8
0
        public static void PraseMods()
        {
            IList <Tuple <ModViewerItem, int> > ActiveMods = new List <Tuple <ModViewerItem, int> >();

            ModSearch(new DirectoryInfo(Management.ProgramPaths.Sonic3AIRModsFolder));
            AddActiveMods();

            void ModSearch(DirectoryInfo d, bool isSubFolder = false)
            {
                DirectoryInfo[] folders = d.GetDirectories();
                foreach (DirectoryInfo folder in folders)
                {
                    DirectoryInfo f    = new DirectoryInfo(folder.FullName);
                    var           root = f.GetFiles("mod.json").FirstOrDefault();
                    if (root != null)
                    {
                        PraseMod(root, folder, isSubFolder, d.Name);
                    }
                    else
                    {
                        if (!isSubFolder)
                        {
                            ModSearch(new DirectoryInfo(folder.FullName), true);
                        }
                    }
                }
            }

            void AddActiveMods()
            {
                foreach (var enabledMod in ActiveMods.OrderBy(x => x.Item2).ToList())
                {
                    ActiveModsList.Insert(0, enabledMod.Item1);
                }
            }

            void PraseMod(FileInfo root, DirectoryInfo folder, bool isSubFolder = false, string subFolderName = "")
            {
                try
                {
                    var    mod     = new AIR_API.Mod(root);
                    string modPath = mod.FolderName;
                    if (isSubFolder)
                    {
                        modPath = string.Format("{0}/{1}", subFolderName, mod.FolderName);
                    }
                    if (S3AIRActiveMods.ActiveMods.Contains(modPath))
                    {
                        mod.IsEnabled    = true;
                        mod.EnabledLocal = true;
                        ActiveMods.Add(new Tuple <ModViewerItem, int>(new ModViewerItem(mod, !isSubFolder), S3AIRActiveMods.ActiveMods.IndexOf(modPath)));
                    }
                    else
                    {
                        mod.IsEnabled    = false;
                        mod.EnabledLocal = false;
                        ModsList.Add(new ModViewerItem(mod, !isSubFolder));
                    }
                }
                catch (Newtonsoft.Json.JsonReaderException ex)
                {
                    MessageBox.Show(Management.UserLanguage.LegacyModError1(folder.Name, ex.Message));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Management.UserLanguage.LegacyModError2(folder.Name, ex.Message));
                }
            }
        }
コード例 #9
0
        private static void ModImportConflictResolve(string meta, string file)
        {
            string ModPath      = Path.GetFileNameWithoutExtension(file);
            string existingMeta = Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath + "\\" + "mod.json";

            AIR_API.Mod ExistingMod = null;
            AIR_API.Mod NewMod      = null;

            if (File.Exists(Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath + "\\" + "mod.json"))
            {
                ExistingMod = new AIR_API.Mod(new FileInfo(existingMeta));
                NewMod      = new AIR_API.Mod(new FileInfo(meta));
            }
            else
            {
                NewMod = new AIR_API.Mod(new FileInfo(meta));
            }



            var result = new ItemConflictDialog().ShowDialog(ExistingMod, NewMod);

            if (result == DialogResult.Yes)
            {
                DeleteOldMod();
                MoveMod();
            }
            else if (result == DialogResult.No)
            {
                MakeModCopy();
            }
            else
            {
                //Don't Import the Mod
            }


            #region Inside Methods

            void MakeModCopy()
            {
                int    index        = 1;
                string OriginalPath = ModPath;

                while (Directory.Exists(Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath))
                {
                    ModPath = $"{ModPath}({index})";
                }
                MoveMod();
            }

            void MoveMod()
            {
                Directory.Move(System.IO.Path.GetDirectoryName(meta), Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath);
            }

            void DeleteOldMod()
            {
                Directory.Delete(Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath, true);
            }

            #endregion
        }