コード例 #1
0
 private void InjectCmxToIceGroup(byte[][] group, byte[] cmxRaw)
 {
     //Loop through files to get what we need
     for (int i = 0; i < group.Length; i++)
     {
         if (IceFile.getFileName(group[i]).ToLower().Contains(".cmx"))
         {
             group[i] = cmxRaw;
             //We can break here since we're really only expecting an NGS cmx and there's only one of those.
             break;
         }
     }
 }
コード例 #2
0
        public void BackupCMX()
        {
            bool isOldCmx = false;
            //Check original CMX to see if we need to do a new backup.
            string cmxPath = Path.Combine(pso2_binDir, dataDir, CharacterMakingIndexMethods.GetFileHash(classicCMX));

            if (File.Exists(cmxPath))
            {
                //bool foundCmx = false;
                var strm = new MemoryStream(File.ReadAllBytes(cmxPath));
                cmxIce = IceFile.LoadIceFile(strm);
                strm.Dispose();

                List <byte[]> files = (new List <byte[]>(cmxIce.groupOneFiles));
                files.AddRange(cmxIce.groupTwoFiles);

                //Loop through files to get what we need
                foreach (byte[] file in files)
                {
                    if (IceFile.getFileName(file).ToLower().Contains(".cmx"))
                    {
                        //If the filesize is actually different, since it should be the same between modded ones and the originals, we want to back it up
                        if (cmxRaw == null || file.Length != cmxRaw.Length)
                        {
                            isOldCmx = true;
                            cmxRaw   = file;
                            cmx      = CharacterMakingIndexMethods.ReadCMX(file);
                        }
                        //foundCmx = true;

                        //We can break here since we're really only expecting an NGS cmx and there's only one of those.
                        break;
                    }
                }
                files.Clear();
            }
            else
            {
                throw new Exception("Cannot find CMX ice!");
            }

            //Backup if the file didn't exist or the CMX was old
            if (!File.Exists(backupPath + "\\pl_data_info.cmx") || isOldCmx)
            {
                Directory.CreateDirectory(backupPath);
                File.WriteAllBytes(backupPath + "\\pl_data_info.cmx", cmxRaw);
            }
            readyToMod = true;
        }
コード例 #3
0
        public static PSO2Text GetTextConditional(string normalPath, string overridePath, string textFileName)
        {
            PSO2Text partsText = new PSO2Text();

            string partsPath = null;

            if (File.Exists(overridePath))
            {
                partsPath = overridePath;
            }
            else if (File.Exists(normalPath))
            {
                partsPath = normalPath;
            }
            else
            {
                return(null);
            }

            if (partsPath != null)
            {
                var strm     = new MemoryStream(File.ReadAllBytes(partsPath));
                var partsIce = IceFile.LoadIceFile(strm);
                strm.Dispose();

                List <byte[]> files = (new List <byte[]>(partsIce.groupOneFiles));
                files.AddRange(partsIce.groupTwoFiles);

                //Loop through files to get what we need
                foreach (byte[] file in files)
                {
                    if (IceFile.getFileName(file).ToLower().Contains(textFileName))
                    {
                        partsText = ReadPSO2Text(file);
                    }
                }

                partsIce = null;
            }

            return(partsText);
        }
コード例 #4
0
        public static byte[] ShowDialog(string iceName, string filter)
        {
            var strm              = new MemoryStream(File.ReadAllBytes(iceName));
            var fVarIce           = IceFile.LoadIceFile(strm);
            var filteredFiles     = new List <byte[]>();
            var filteredFileNames = new List <string>();

            strm.Dispose();

            List <byte[]> files = new List <byte[]>(fVarIce.groupOneFiles);

            files.AddRange(fVarIce.groupTwoFiles);

            //Loop through files to get what we need
            foreach (byte[] file in files)
            {
                var name = IceFile.getFileName(file).ToLower();
                if (name.Contains(filter))
                {
                    filteredFileNames.Add(name);
                    filteredFiles.Add(file);
                }
            }
            files = null;

            Form prompt = new Form();

            prompt.Width  = 200;
            prompt.Height = 100;
            prompt.Text   = $"Select a file:";
            Label label = new Label()
            {
                Text = "Select a file: ", Left = 30, Top = 1, Width = 100
            };
            ComboBox cb = new ComboBox()
            {
                Left = 40, Top = 18, Width = 100
            };

            foreach (var name in filteredFileNames)
            {
                cb.Items.Add(name);
            }
            if (cb.Items.Count == 0)
            {
                return(null);
            }
            cb.SelectedIndex = 0;
            Button confirmation = new Button()
            {
                Text = "Ok", Dock = DockStyle.Bottom
            };

            confirmation.Click += (sender, e) => { prompt.Close(); };

            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cb);
            prompt.Controls.Add(label);
            prompt.ShowDialog();

            fVarIce = null;

            return(filteredFiles[cb.SelectedIndex]);
        }