private void button_LoadFont_Click(object sender, EventArgs e)
        {
            if (_modifiedImage == null)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter = "Conan Font File|FONT.BIN";

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    _fontFile = new FONTFile(openFileDialog.FileName);
                }
            }
            else
            {
                PKNFile  graphPkn = _modifiedImage.PKNFiles?.Find(pkn => pkn.Name == "GRAPH");
                BaseFile fontFile = graphPkn?.Files?.Find(file => file.FileName == "FONT.BIN");
                if (fontFile == null)
                {
                    return;
                }

                _fontFile = new FONTFile(fontFile.FilePath);
            }
            _fontFile.Load();

            FontList = _fontFile.Characters.Select(character => character.GetBitmap()).ToList();
            pictureBox_CharacterMap.Image = Graphic.CombineBitmaps(FontList, 42);
            MessageBox.Show("Symbols loaded: " + FontList.Count + " (default engine maximum)");
        }
        private void OnClickPKNUnpackDecompAll(object sender, EventArgs eventArgs)
        {
            if (treeView1.SelectedNode == null)
            {
                return;
            }
            if (treeView1.SelectedNode.Tag == null)
            {
                return;
            }

            Enabled = false;

            if (treeView1.SelectedNode.Tag.GetType() == typeof(PKNFile))
            {
                PKNFile pknFile = (PKNFile)treeView1.SelectedNode.Tag;
                foreach (BaseFile file in pknFile.Files)
                {
                    if (file.GetType() == typeof(LZBFile))
                    {
                        LZBFile lzbFile = (LZBFile)file;
                        lzbFile.Decompress();
                    }
                }
            }
            _state.SaveProject();
            Enabled = true;
        }
Exemple #3
0
        private void GenerateFont()
        {
            PKNFile pknFile = ApplicationState.Instance.ProjectFile.ModifiedImage.PKNFiles.FirstOrDefault(p => p.Name == "GRAPH");

            if (pknFile != null)
            {
                BaseFile baseFile = pknFile.Files.FirstOrDefault(f => f.FileName == "FONT.BIN");
                if (baseFile != null)
                {
                    FONTFile fontFile = (FONTFile)baseFile;
                    fontFile.Characters = ScriptFile.GeneratedFont;
                    fontFile.Save();
                    return;
                }
            }
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "FONT.BIN|FONT.BIN";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                FONTFile fontFile = new FONTFile(saveFileDialog.FileName);
                fontFile.Characters = ScriptFile.GeneratedFont;
                fontFile.Save();
            }
        }
        public ScriptAnalyseWindow(ScriptCollection scriptFileCollection)
        {
            InitializeComponent();
            _scriptFileCollection = scriptFileCollection;
            List <string> lines = ParseScripts();

            foreach (string line in lines)
            {
                richTextBox1.AppendText(line + "\n");
            }

            HashSet <string> dictionary = CreateDictionary(lines);

            richTextBox1.AppendText("\nDictionary( " + dictionary.Count + " Symbols ):");
            foreach (string characters in dictionary)
            {
                richTextBox1.AppendText(characters + "\n");
            }

            string[] unsortedDictionary = dictionary.ToArray();
            string[] sortedDictionary   = dictionary.OrderBy(entry => entry).ToArray();

            if (ApplicationState.Instance.ProjectFile != null)
            {
                _modifiedImage = ApplicationState.Instance.ProjectFile.ModifiedImage;
            }

            if (_modifiedImage == null)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter = "Conan Font File|FONT.BIN";

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    _fontFile = new FONTFile(openFileDialog.FileName);
                }
            }
            else
            {
                PKNFile  graphPkn = _modifiedImage.PKNFiles?.Find(pkn => pkn.Name == "GRAPH");
                BaseFile fontFile = graphPkn?.Files?.Find(file => file.FileName == "FONT.BIN");
                if (fontFile == null)
                {
                    return;
                }

                _fontFile = new FONTFile(fontFile.FilePath);
            }
            _fontFile.Load();

            _fontFile.Generate(unsortedDictionary, new Font("ConanFont", 12));
            _fontFile.Save();
        }
Exemple #5
0
 public bool CheckPKNs()
 {
     foreach (ConanImageFile pkn in ConanImage.PKNFiles)
     {
         string  path    = Path.Combine(RippedDirectory, pkn.FilePath);
         PKNFile pknFile = PKNFiles.FirstOrDefault(p => p.FilePath == path);
         if (pknFile == null)
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #6
0
        public void DecompressScripts()
        {
            if (ApplicationState.Instance.ProjectFile == null)
            {
                MessageBox.Show("Open a project file before decompressing!", "Project file not found!");
                return;
            }
            PSXImage modifiedImage = ApplicationState.Instance.ProjectFile.ModifiedImage;

            _scriptPKN = modifiedImage.PKNFiles.Find(pkn => pkn.Name == "SCRIPT");
            if (_scriptPKN == null)
            {
                return;
            }
            if (_scriptPKN.Files.Count == 0) //cheap fix for when pkn files dont save files
            {
                _scriptPKN.Unpack();
            }
            Enabled = false;

            ScriptFile = new ScriptFile();

            richTextBox_ScriptFile.Text = "";
            for (int i = 0; i < _scriptPKN.Files.Count; i++)
            {
                BaseFile baseFile = _scriptPKN.Files[i];
                if (baseFile.GetType() == typeof(LZBFile))
                {
                    LZBFile lzbFile = (LZBFile)baseFile;
                    lzbFile.Decompress();
                }
                ScriptDocument scriptFile = new ScriptDocument(baseFile);
                ScriptFile.Scripts.Add(scriptFile);
                progressBar_Progress.Value = (int)((double)i / _scriptPKN.Files.Count * 100);
            }
            listBox_ScriptFiles.Items.Clear();
            foreach (ScriptDocument scriptFile in ScriptFile.Scripts)
            {
                listBox_ScriptFiles.Items.Add(scriptFile);
            }

            progressBar_Progress.Value = 0;
            Enabled = true;
        }
        private void OnClickPKNReset(object sender, EventArgs eventArgs)
        {
            TreeNode pknNode = treeView1.SelectedNode;

            pknNode.Nodes.Clear();

            PKNFile pkn = (PKNFile)pknNode.Tag;

            pkn.Clear();
            pkn.Unpack();
            _state.SaveProject();

            if (pkn.Files.Count != 0)
            {
                foreach (BaseFile file in pkn.Files)
                {
                    TreeNode fileNode = new TreeNode(file.FileName);
                    fileNode.Tag = file;
                    pknNode.Nodes.Add(fileNode);
                }
            }
            pknNode.Expand();
        }
        private void UpdateTreeNodes()
        {
            treeView1.Nodes.Clear();
            if (_state.ProjectFile == null)
            {
                return;
            }

            PSXImage image     = _state.ProjectFile.ModifiedImage;
            TreeNode imageNode = new TreeNode(image.ToString());

            imageNode.Tag     = image;
            imageNode.Checked = false;

            foreach (string directory in ConanImage.Directories)
            {
                TreeNode directoryNode = new TreeNode(directory);
                directoryNode.ImageIndex = 0;

                PKNFile pkn = image.PKNFiles.Find(e => e.Name == directory);
                if (pkn != null)
                {
                    TreeNode pknNode = new TreeNode(pkn.FileName);
                    pknNode.ImageIndex         = 1;
                    pknNode.SelectedImageIndex = 1;
                    pknNode.Tag = pkn;

                    if (pkn.Files.Count != 0)
                    {
                        foreach (BaseFile file in pkn.Files)
                        {
                            TreeNode fileNode = new TreeNode(file.FileName);
                            fileNode.Tag = file;

                            if (file.GetType() == typeof(PBFile))
                            {
                                PBFile pbFile = (PBFile)file;
                                foreach (PBFileEntry entry in pbFile.Files)
                                {
                                    TreeNode entryNode = new TreeNode(entry.File.FileName);
                                    entryNode.Tag = entry.File;
                                    fileNode.Nodes.Add(entryNode);
                                }
                            }
                            if (file.GetType() == typeof(BGFile))
                            {
                                BGFile bgFile = (BGFile)file;
                                foreach (BaseFile entry in bgFile.Files)
                                {
                                    TreeNode entryNode = new TreeNode(entry.FileName);
                                    entryNode.Tag = entry;
                                    fileNode.Nodes.Add(entryNode);
                                }
                            }
                            pknNode.Nodes.Add(fileNode);
                        }
                    }
                    directoryNode.Nodes.Add(pknNode);
                }
                else
                {
                    foreach (ConanImageFile file in ConanImage.Files)
                    {
                        if (Path.GetDirectoryName(file.FilePath) == directory)
                        {
                            TreeNode fileNode = new TreeNode(Path.GetFileName(file.FilePath));
                            fileNode.Tag = file;
                            //fileNode.Tag = HeaderList.GetTypeFromFile(Path.Combine(_state.ProjectFile.ModifiedImage.RippedDirectory,file.FilePath)); //LAAAAG
                            directoryNode.Nodes.Add(fileNode);
                        }
                    }
                }
                imageNode.Nodes.Add(directoryNode);
            }
            treeView1.Nodes.Add(imageNode);
        }