private void ProcessCharacterGeneralModFiles(string[] files, string baseDirectory) { string[] xmlFiles = Utils.FindFilesByFilename(files, "kamimod.xml"); List <string> XmlModFiles = new List <string>(); List <CharacterGeneralModXML> XmlMods = new List <CharacterGeneralModXML>(); if (xmlFiles != null) { foreach (string xmlFile in xmlFiles) { if (Path.GetFileName(xmlFile) != "kamimod.xml") { continue; } CharacterGeneralModXML mod = Utils.DeserializeXML <CharacterGeneralModXML>(xmlFile); if (mod == null) { continue; } XmlMods.Add(mod); XmlModFiles.Add(xmlFile); } } if (XmlMods.Count > 0) { for (int i = 0; i < XmlMods.Count; ++i) { string oldBasePath = Path.GetDirectoryName(XmlModFiles[0]); string modFolderName = oldBasePath.Split(Path.DirectorySeparatorChar).Last(); if (modFolderName == "unzip") { modFolderName = XmlMods[i].DisplayName; } CharacterGeneralModXML xmlTest = Utils.OpenCharacterGeneralKamiModFile(_CurrentFighter.name, modFolderName); if (xmlTest != null) { MessageBox.Show(String.Format("Mod already exists under the same folder name '{0}'. Skipping...", modFolderName)); return; } oldBasePath = oldBasePath + Path.DirectorySeparatorChar; string newBasePath = PathHelper.FolderCharGeneralMods + _CurrentFighter.name + Path.DirectorySeparatorChar + modFolderName + Path.DirectorySeparatorChar; Utils.CopyAllValidFilesBetweenDirectories(oldBasePath, newBasePath); LogHelper.Info(String.Format("KamiMod {0} imported successfully!", modFolderName)); RefreshRowData(); } } else { string baseDirectoryTopFolderExcluded = baseDirectory.Remove(baseDirectory.LastIndexOf(Path.DirectorySeparatorChar, baseDirectory.Length - 2)); string cameraFolder = Utils.FindDirectoryInFiles(files, "camera", baseDirectoryTopFolderExcluded); string modelFolder = Utils.FindDirectoryInFiles(files, "model", baseDirectoryTopFolderExcluded); string effectFolder = Utils.FindDirectoryInFiles(files, "effect", baseDirectoryTopFolderExcluded); string motionFolder = Utils.FindDirectoryInFiles(files, "motion", baseDirectoryTopFolderExcluded); string scriptFolder = Utils.FindDirectoryInFiles(files, "script", baseDirectoryTopFolderExcluded); string soundFolder = Utils.FindDirectoryInFiles(files, "sound", baseDirectoryTopFolderExcluded); if (string.IsNullOrEmpty(cameraFolder) && string.IsNullOrEmpty(modelFolder) && string.IsNullOrEmpty(effectFolder) && string.IsNullOrEmpty(motionFolder) && string.IsNullOrEmpty(scriptFolder) && string.IsNullOrEmpty(soundFolder)) { MessageBox.Show("No valid folder found. Make sure the directory or zip file contains one of the following folders: camera, model, effect, motion, script, sound"); LogHelper.Error("No valid folder found. Make sure the directory or zip file contains one of the following folders: camera, model, effect, motion, script, sound"); return; } string name = baseDirectory.Split(Path.DirectorySeparatorChar).Last(); Forms.NewModNamePopup popup = new Forms.NewModNamePopup(); popup.nameText = name; bool nameValid = false; while (!nameValid) { popup.ShowDialog(); if (!popup.confirmPressed) { return; } popup.confirmPressed = false; name = popup.nameText; name = PathHelper.RemoveInvalidFilenameChars(name); if (name.Length < 1) { MessageBox.Show("Invalid mod name given. Please enter a new one."); continue; } CharacterGeneralModXML xmlTest = Utils.OpenCharacterGeneralKamiModFile(_CurrentFighter.name, name); if (xmlTest != null) { MessageBox.Show("Mod already exists under the same folder name. Please enter a new one."); continue; } nameValid = true; } string newModDirectory = PathHelper.FolderCharGeneralMods + Path.DirectorySeparatorChar + _CurrentFighter.name + Path.DirectorySeparatorChar + name + Path.DirectorySeparatorChar; #region XML File Creation CharacterGeneralModXML xml = new CharacterGeneralModXML(); xml.DisplayName = name; xml.WifiSafe = true; //Assuming wifi-safe Utils.SerializeXMLToFile(xml, newModDirectory + "kamimod.xml"); #endregion #region Mod Files if (!cameraFolder.Equals(String.Empty)) { Utils.CopyAllValidFilesBetweenDirectories(cameraFolder, newModDirectory + "camera" + Path.DirectorySeparatorChar); } if (!modelFolder.Equals(String.Empty)) { Utils.CopyAllValidFilesBetweenDirectories(modelFolder, newModDirectory + "model" + Path.DirectorySeparatorChar); } if (!effectFolder.Equals(String.Empty)) { Utils.CopyAllValidFilesBetweenDirectories(effectFolder, newModDirectory + "effect" + Path.DirectorySeparatorChar); } if (!motionFolder.Equals(String.Empty)) { Utils.CopyAllValidFilesBetweenDirectories(motionFolder, newModDirectory + "motion" + Path.DirectorySeparatorChar); } if (!scriptFolder.Equals(String.Empty)) { Utils.CopyAllValidFilesBetweenDirectories(scriptFolder, newModDirectory + "script" + Path.DirectorySeparatorChar); } if (!soundFolder.Equals(String.Empty)) { Utils.CopyAllValidFilesBetweenDirectories(soundFolder, newModDirectory + "sound" + Path.DirectorySeparatorChar); } #endregion LogHelper.Info(String.Format("Mod {0} imported successfully!", name)); RefreshRowData(); } }
public void RefreshRowData() { _RowData = new List <RowData>(); _Project = _SmashProjectManager.CurrentProject; if (_IsActiveList) { if (_ModListType == ModListType.CharacterGeneral) { for (int j = 0; j < _Project.ActiveCharacterGeneralMods.Count; ++j) { if (_Project.ActiveCharacterGeneralMods[j].CharacterID != _CurrentFighter.id) { continue; } RowData row = new RowData(); row.modFolder = _Project.ActiveCharacterGeneralMods[j].FolderName; CharacterGeneralModXML data = Globals.Utils.OpenCharacterGeneralKamiModFile(_CurrentFighter.name, row.modFolder); if (data != null) { row.name = data.DisplayName; row.wifiSafe = data.WifiSafe; } else { row.name = String.Format("{0} (Mod is missing!)", row.modFolder); row.modMissing = true; row.propertiesEnabled = false; } _RowData.Add(row); } } else if (_ModListType == ModListType.Stage) { for (int j = 0; j < _Project.ActiveStageMods.Count; ++j) { RowData row = new RowData(); row.modFolder = _Project.ActiveStageMods[j].FolderName; StageModXML data = Globals.Utils.OpenStageKamiModFile(row.modFolder); if (data != null) { row.name = data.DisplayName; row.wifiSafe = data.WifiSafe; } else { row.name = String.Format("{0} (Mod is missing!)", row.modFolder); row.modMissing = true; row.propertiesEnabled = false; } _RowData.Add(row); } } else if (_ModListType == ModListType.General) { for (int j = 0; j < _Project.ActiveGeneralMods.Count; ++j) { RowData row = new RowData(); row.modFolder = _Project.ActiveGeneralMods[j]; GeneralModXML data = Globals.Utils.OpenGeneralKamiModFile(row.modFolder); if (data != null) { row.name = data.DisplayName; row.wifiSafe = data.WifiSafe; } else { row.name = String.Format("{0} (Mod is missing!)", row.modFolder); row.modMissing = true; row.propertiesEnabled = false; } _RowData.Add(row); } } } else { string baseDirectory = String.Empty; switch (_ModListType) { case (ModListType.CharacterSlots): baseDirectory = PathHelper.FolderCharSlotsMods + _CurrentFighter.name + Path.DirectorySeparatorChar; break; case (ModListType.CharacterGeneral): baseDirectory = PathHelper.FolderCharGeneralMods + _CurrentFighter.name + Path.DirectorySeparatorChar; break; case (ModListType.Stage): baseDirectory = PathHelper.FolderStageMods; break; case (ModListType.General): baseDirectory = PathHelper.FolderGeneralMods; break; } string[] kamiFiles = Directory.GetFiles(baseDirectory, "kamimod.xml", SearchOption.AllDirectories); for (int i = 0; i < kamiFiles.Count(); ++i) { string modFolderName = kamiFiles[i].Replace(baseDirectory, String.Empty).Split(Path.DirectorySeparatorChar).First(); //Check if the mod is already active. If it is, don't include it in this list. bool modIsActive = false; switch (_ModListType) { case (ModListType.CharacterSlots): for (int j = 0; j < _Project.ActiveCharacterSlotMods.Count; ++j) { if (_Project.ActiveCharacterSlotMods[j].CharacterID == _CurrentFighter.id) { if (_Project.ActiveCharacterSlotMods[j].FolderName.Equals(modFolderName)) { modIsActive = true; break; } } } break; case (ModListType.CharacterGeneral): for (int j = 0; j < _Project.ActiveCharacterGeneralMods.Count; ++j) { if (_Project.ActiveCharacterGeneralMods[j].FolderName.Equals(modFolderName)) { modIsActive = true; break; } } break; case (ModListType.Stage): for (int j = 0; j < _Project.ActiveStageMods.Count; ++j) { if (_Project.ActiveStageMods[j].FolderName.Equals(modFolderName)) { modIsActive = true; break; } } break; case (ModListType.General): for (int j = 0; j < _Project.ActiveGeneralMods.Count; ++j) { if (_Project.ActiveGeneralMods[j].Equals(modFolderName)) { modIsActive = true; break; } } break; } if (modIsActive) { continue; } RowData row = new RowData(); row.modFolder = modFolderName; switch (_ModListType) { case (ModListType.CharacterSlots): CharacterSlotModXML data = Utils.DeserializeXML <CharacterSlotModXML>(kamiFiles[i]); row.name = data.DisplayName; row.missingPortraits = (!data.chr_00 || !data.chr_11 || !data.chr_13 || !data.stock_90); if (data.UseCustomName && !row.missingPortraits) { if (!data.chrn_11 || data.BoxingRingText == null) { row.missingPortraits = true; } else if (data.BoxingRingText.Equals(string.Empty)) { row.missingPortraits = true; } } row.metal = data.MetalModel; row.hasAudio = data.Sound || data.Voice; row.hasCustomName = data.UseCustomName; row.wifiSafe = data.WifiSafe; break; case (ModListType.CharacterGeneral): CharacterGeneralModXML data2 = Utils.DeserializeXML <CharacterGeneralModXML>(kamiFiles[i]); row.name = data2.DisplayName; row.wifiSafe = data2.WifiSafe; break; case (ModListType.Stage): StageModXML data3 = Utils.DeserializeXML <StageModXML>(kamiFiles[i]); row.name = data3.DisplayName; row.wifiSafe = data3.WifiSafe; break; case (ModListType.General): GeneralModXML data4 = Utils.DeserializeXML <GeneralModXML>(kamiFiles[i]); row.name = data4.DisplayName; row.wifiSafe = data4.WifiSafe; break; } _RowData.Add(row); } } PopulateRows(); }
public static CharacterGeneralModXML OpenCharacterGeneralKamiModFile(string characterName, string modName) { CharacterGeneralModXML data = DeserializeXML <CharacterGeneralModXML>(PathHelper.FolderCharGeneralMods + characterName + Path.DirectorySeparatorChar + modName + Path.DirectorySeparatorChar + "kamimod.xml"); return(data); }
public static void SaveCharacterGeneralKamiModFile(string characterName, string modName, CharacterGeneralModXML data) { SerializeXMLToFile(data, PathHelper.FolderCharGeneralMods + characterName + Path.DirectorySeparatorChar + modName + Path.DirectorySeparatorChar + "kamimod.xml"); }
public ModProperties(string modPath, ModsList.ModListType modListType, string charName = "") { InitializeComponent(); ModPath = modPath; ModListType = modListType; CharName = charName; PathKami = ModPath + Path.DirectorySeparatorChar + "kamimod.xml"; switch (ModListType) { case ModsList.ModListType.CharacterGeneral: XMLDataCharGeneral = Utils.DeserializeXML <CharacterGeneralModXML>(PathKami); if (XMLDataCharGeneral == null) { return; } XMLDataCharGeneral.isDirty = false; textBoxDisplayName.Text = XMLDataCharGeneral.DisplayName; checkBoxWifiSafe.Checked = XMLDataCharGeneral.WifiSafe; if (XMLDataCharGeneral.Notes == null) { XMLDataCharGeneral.Notes = String.Empty; } textBoxNotes.Text = XMLDataCharGeneral.Notes.Replace("\n", "\r\n"); groupBoxPortaits.Visible = false; groupBoxStageData.Visible = false; this.Height -= groupBoxPortaits.Height + groupBoxStageData.Height; break; case ModsList.ModListType.Stage: XMLDataStage = Utils.DeserializeXML <StageModXML>(PathKami); if (XMLDataStage == null) { return; } XMLDataStage.isDirty = false; textBoxDisplayName.Text = XMLDataStage.DisplayName; checkBoxWifiSafe.Checked = XMLDataStage.WifiSafe; if (XMLDataStage.Notes == null) { XMLDataStage.Notes = String.Empty; } textBoxNotes.Text = XMLDataStage.Notes.Replace("\n", "\r\n"); for (int i = 0; i < DB.StagesDB.Stages.Count; ++i) { if (DB.StagesDB.Stages[i].ID == XMLDataStage.IntendedStage) { labelStageName.Text = DB.StagesDB.Stages[i].LabelHuman; } } PathStage10 = ModPath + Path.DirectorySeparatorChar + "ui" + Path.DirectorySeparatorChar + "stage_10_XX.nut"; PathStage11 = ModPath + Path.DirectorySeparatorChar + "ui" + Path.DirectorySeparatorChar + "stage_11_XX.nut"; PathStage12 = ModPath + Path.DirectorySeparatorChar + "ui" + Path.DirectorySeparatorChar + "stage_12_XX.nut"; PathStage13 = ModPath + Path.DirectorySeparatorChar + "ui" + Path.DirectorySeparatorChar + "stage_13_XX.nut"; PathStage30 = ModPath + Path.DirectorySeparatorChar + "ui" + Path.DirectorySeparatorChar + "stage_30_XX.nut"; PathStagen10 = ModPath + Path.DirectorySeparatorChar + "ui" + Path.DirectorySeparatorChar + "stagen_10_XX.nut"; XMLDataStage.stage_10 = File.Exists(PathStage10); XMLDataStage.stage_11 = File.Exists(PathStage11); XMLDataStage.stage_12 = File.Exists(PathStage12); XMLDataStage.stage_13 = File.Exists(PathStage13); XMLDataStage.stage_30 = File.Exists(PathStage30); XMLDataStage.stagen_10 = File.Exists(PathStagen10); buttonExport_stage10.Enabled = XMLDataStage.stage_10; buttonExport_stage11.Enabled = XMLDataStage.stage_11; buttonExport_stage12.Enabled = XMLDataStage.stage_12; buttonExport_stage13.Enabled = XMLDataStage.stage_13; buttonExport_stage30.Enabled = XMLDataStage.stage_30; buttonExport_stagen10.Enabled = XMLDataStage.stagen_10; if (XMLDataStage.stage_10) { pictureBox_stage10.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathStage10); UpdatePictureBoxClickable(pictureBox_stage10); } if (XMLDataStage.stage_11) { pictureBox_stage11.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathStage11); UpdatePictureBoxClickable(pictureBox_stage11); } if (XMLDataStage.stage_12) { pictureBox_stage12.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathStage12); UpdatePictureBoxClickable(pictureBox_stage12); } if (XMLDataStage.stage_13) { pictureBox_stage13.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathStage13); UpdatePictureBoxClickable(pictureBox_stage13); } if (XMLDataStage.stage_30) { pictureBox_stage30.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathStage30); UpdatePictureBoxClickable(pictureBox_stage30); } if (XMLDataStage.stagen_10) { pictureBox_stagen10.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathStagen10, true); UpdatePictureBoxClickable(pictureBox_stagen10); } break; case ModsList.ModListType.General: XMLDataGeneral = Utils.DeserializeXML <GeneralModXML>(PathKami); if (XMLDataGeneral == null) { return; } XMLDataGeneral.isDirty = false; textBoxDisplayName.Text = XMLDataGeneral.DisplayName; checkBoxWifiSafe.Checked = XMLDataGeneral.WifiSafe; if (XMLDataGeneral.Notes == null) { XMLDataGeneral.Notes = String.Empty; } textBoxNotes.Text = XMLDataGeneral.Notes.Replace("\n", "\r\n"); groupBoxPortaits.Visible = false; groupBoxStageData.Visible = false; this.Height -= groupBoxPortaits.Height + groupBoxStageData.Height; break; } IsInitialized = true; }