public void ReloadFile(int index, ASMEncodingUtility asmUtility) { PatchFile patchFile = FilePatches[index]; IList <AsmPatch> tryPatches; List <Color> fileColorList = new List <Color>(); Color normalColor = Color.White; Color errorColor = Color.FromArgb(225, 125, 125); patchFile.Patches.Clear(); if (PatchXmlReader.TryGetPatches(File.ReadAllText(patchFile.Filename, Encoding.UTF8), patchFile.Filename, asmUtility, out tryPatches)) { foreach (AsmPatch patch in tryPatches) { if (!patch.IsHidden) { Color bgColor = string.IsNullOrEmpty(patch.ErrorText) ? normalColor : errorColor; patchFile.Patches.Add(patch); fileColorList.Add(bgColor); } } LoadedCorrectly[index] = true; } else { LoadedCorrectly[index] = false; } BackgroundColors[index + 1] = fileColorList.ToArray(); FileOrdinalMaps[index] = GetFileOrdinalMap(index); }
public PatchList(string[] files, ASMEncodingUtility asmUtility) { FilePatches = new PatchFile[files.Length]; LoadedCorrectly = new bool[files.Length]; IList <AsmPatch> tryPatches; int i = 0; foreach (string file in files) { if (PatchXmlReader.TryGetPatches(File.ReadAllText(file, Encoding.UTF8), file, asmUtility, out tryPatches)) { AllPatches.AddRange(tryPatches); FilePatches[i] = new PatchFile(tryPatches.Count); FilePatches[i].filename = file; FilePatches[i].Patches.AddRange(tryPatches); LoadedCorrectly[i] = true; } else { LoadedCorrectly[i] = false; //MessageBox.Show(file.Substring(file.LastIndexOf("\\")) + " Did not load correctly"); } i++; } AllCheckStates = new CheckState[AllPatches.Count]; for (int j = 0; j < AllCheckStates.Length; j++) { AllCheckStates[j] = new CheckState(); AllCheckStates[j] = CheckState.Unchecked; } }
public PatchData(string[] files, ASMEncodingUtility asmUtility) { FilePatches = new PatchFile[files.Length]; LoadedCorrectly = new bool[files.Length]; IList <AsmPatch> tryPatches; List <Color> allColorList = new List <Color>(); Color normalColor = Color.White; Color errorColor = Color.FromArgb(225, 125, 125); BackgroundColors = new Color[files.Length + 1][]; for (int index = 0; index < files.Length; index++) { string file = files[index]; List <Color> fileColorList = new List <Color>(); FilePatches[index] = new PatchFile(file); if (PatchXmlReader.TryGetPatches(File.ReadAllText(file, Encoding.UTF8), file, asmUtility, out tryPatches)) { foreach (AsmPatch patch in tryPatches) { if (!patch.IsHidden) { Color bgColor = string.IsNullOrEmpty(patch.ErrorText) ? normalColor : errorColor; FilePatches[index].Patches.Add(patch); fileColorList.Add(bgColor); AllPatches.Add(patch); if (!patch.HideInDefault) { AllShownPatches.Add(patch); allColorList.Add(bgColor); } } } LoadedCorrectly[index] = true; } else { LoadedCorrectly[index] = false; } BackgroundColors[index + 1] = fileColorList.ToArray(); } BackgroundColors[0] = allColorList.ToArray(); BuildOrdinalMaps(); }
void reloadButton_Click(object sender, EventArgs e) { List <AsmPatch> result = new List <AsmPatch>(); string[] files = Directory.GetFiles(Application.StartupPath, "*.xml", SearchOption.TopDirectoryOnly); foreach (string file in files) { IList <AsmPatch> tryPatches; if (PatchXmlReader.TryGetPatches(File.ReadAllText(file, Encoding.UTF8), out tryPatches)) { result.AddRange(tryPatches); } } LoadPatches(result); }
private void LoadFiles(IList <string> files) { List <AsmPatch> result = new List <AsmPatch>(); foreach (string file in files) { IList <AsmPatch> tryPatches; if (PatchXmlReader.TryGetPatches(File.ReadAllText(file, Encoding.UTF8), file, asmUtility, out tryPatches)) { result.AddRange(tryPatches); } else { // MessageBox.Show(file.Substring(file.LastIndexOf("\\")) + " Did not load correctly"); } } LoadPatches(result); }
public MainForm() { InitializeComponent(); versionLabel.Text = string.Format("v0.{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString()); XmlDocument doc = new XmlDocument(); reloadButton_Click(reloadButton, EventArgs.Empty); if (patches == null || patches.Length == 0) { IList <AsmPatch> temp; if (PatchXmlReader.TryGetPatches(FFTorgASM.Properties.Resources.DefaultHacks, out temp)) { LoadPatches(temp); } } patchButton.Click += new EventHandler(patchButton_Click); reloadButton.Click += new EventHandler(reloadButton_Click); checkedListBox1.ItemCheck += new ItemCheckEventHandler(checkedListBox1_ItemCheck); patchButton.Enabled = false; checkedListBox1.SelectedIndexChanged += new EventHandler(checkedListBox1_SelectedIndexChanged); variableSpinner.ValueChanged += new EventHandler(variableSpinner_ValueChanged); variableComboBox.SelectedIndexChanged += new EventHandler(variableComboBox_SelectedIndexChanged); }