Ejemplo n.º 1
0
        private void LoadFiles(IList <string> fileList = null)
        {
            string strMode  = Enum.GetName(typeof(ASMEncodingMode), asmUtility.EncodingMode);
            string readPath = Path.Combine(Path.Combine(Application.StartupPath, "XmlPatches"), strMode);

            string[] files = (fileList == null) ? Directory.GetFiles(readPath, "*.xml", SearchOption.TopDirectoryOnly) : fileList.ToArray();
            lsb_FilesList.SelectedIndices.Clear();

            clb_Patches.Items.Clear();
            ClearCurrentPatch();

            patchData = new PatchData(files, asmUtility);

            lsb_FilesList.Items.Clear();
            //lsb_FilesList.BackColors = new Color[files.Length + 1];
            lsb_FilesList.SetColorCapacity(files.Length + 1);
            lsb_FilesList.Items.Add("All");
            lsb_FilesList.SelectedIndices.Clear();

            for (int i = 0; i < files.Length; i++)
            {
                files[i] = files[i].Substring(files[i].LastIndexOf("\\") + 1);
                lsb_FilesList.Items.Add(files[i]);

                //lsb_FilesList.BackColors[i + 1] = Color.White;
                //lsb_FilesList.SetBackColor(i + 1, Color.White);
                if (!patchData.LoadedCorrectly[i])
                {
                    //lsb_FilesList.Items[i + 1].BackColor = Color.Red;
                    //lsb_FilesList.BackColors[i + 1] = Color.Red;
                    lsb_FilesList.SetBackColor(i + 1, Color.FromArgb(225, 125, 125));
                }
            }

            SetOriginalPatches();
        }
Ejemplo n.º 2
0
        private static bool HandleCommandLinePatch(string[] args)
        {
            System.Collections.Generic.KeyValuePair <string, string> patchFilepaths = PatcherLib.Utilities.Utilities.GetPatchFilepaths(args, ".xml");

            if ((string.IsNullOrEmpty(patchFilepaths.Key)) || (string.IsNullOrEmpty(patchFilepaths.Value)))
            {
                return(false);
            }
            else
            {
                System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
                //while (!System.Diagnostics.Debugger.IsAttached) System.Threading.Thread.Sleep(100);
                AttachConsole(ATTACH_PARENT_PROCESS);

                try
                {
                    ASMEncoding.ASMEncodingUtility asmUtility = new ASMEncoding.ASMEncodingUtility(ASMEncoding.ASMEncodingMode.PSX);
                    PatchData patchData = new PatchData(new string[1] {
                        patchFilepaths.Key
                    }, asmUtility);

                    if (patchFilepaths.Value.ToLower().Trim().EndsWith(".psv"))
                    {
                        PatcherLib.Iso.PatchPsxSaveStateResult patchResult = patchData.PatchAllSaveState(asmUtility, patchFilepaths.Value);
                        System.Text.StringBuilder sbResultMessage          = new System.Text.StringBuilder();

                        bool hasUnsupportedFiles = (patchResult.UnsupportedFiles.Count > 0);
                        bool hasAbsentFiles      = (patchResult.AbsentFiles.Count > 0);

                        if (hasUnsupportedFiles)
                        {
                            sbResultMessage.AppendLine("Files not supported for savestate patching:");
                            foreach (PatcherLib.Iso.PsxIso.Sectors sector in patchResult.UnsupportedFiles)
                            {
                                sbResultMessage.AppendFormat("\t{0}{1}", PatcherLib.Iso.PsxIso.GetSectorName(sector), Environment.NewLine);
                            }
                            sbResultMessage.AppendLine();
                        }
                        if (hasAbsentFiles)
                        {
                            sbResultMessage.AppendLine("Files not present in savestate:");
                            foreach (PatcherLib.Iso.PsxIso.Sectors sector in patchResult.AbsentFiles)
                            {
                                sbResultMessage.AppendFormat("\t{0}{1}", PatcherLib.Iso.PsxIso.GetSectorName(sector), Environment.NewLine);
                            }
                            sbResultMessage.AppendLine();
                        }

                        if (hasUnsupportedFiles || hasAbsentFiles)
                        {
                            Console.WriteLine(sbResultMessage.ToString());
                        }
                    }
                    else
                    {
                        patchData.PatchAllISO(asmUtility, patchFilepaths.Value);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message);
                }

                return(true);
            }
        }