Esempio n. 1
0
        private void extractToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog fd = new OpenFileDialog();

            fd.Filter = "All *.pak packgets|*.pak;*.dat;*.sdat";
            if (fd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Stream Packget = new StreamReader(fd.FileName).BaseStream;

            string Outdir = fd.FileName + "~\\";

            Outdir = Outdir.Replace('\\', Path.AltDirectorySeparatorChar);

            if (Directory.Exists(Outdir))
            {
                Directory.Delete(Outdir, true);
            }
            Directory.CreateDirectory(Outdir);

            Entry[] Entries = PAK.Open(Packget);

            foreach (var File in Entries)
            {
                string OP     = Outdir + File.Filename;
                Stream Output = new StreamWriter(OP.Replace('\\', Path.AltDirectorySeparatorChar)).BaseStream;
                File.Content.CopyTo(Output);
                Output.Flush();
                Output.Close();
            }
            MessageBox.Show("Packget extracted");
        }
Esempio n. 2
0
        /// <inheritdoc />
        public void AddDataFS(string path)
        {
            Logger.Success("Reisalin", $"Loading {Path.GetFileName(path)}...");
            var pak = new PAK(path, !Options.ReisalinA17, Options.ReisalinKeyFix);

            EntryCount += pak.Entries.Count;
            PAKs.Add(pak);
        }
Esempio n. 3
0
        private void Package_archive_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.Description = "Folder to pack";
            if (fbd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            SaveFileDialog fd = new SaveFileDialog();

            fd.Title  = "Save as...";
            fd.Filter = "All *.sdat packgets|*.sdat";

            if (fd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            bool SteamVer   = MessageBox.Show("Pack in Steam version format?", "APEGUI", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
            bool BigEnddian = !SteamVer && MessageBox.Show("Pack with BigEnddian?\nYes: PS3 Format\nNo: PSV/PS4 Format", "APEGUI", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;

            if (!fbd.SelectedPath.EndsWith("\\"))
            {
                fbd.SelectedPath += '\\';
            }

            string[] Files = Directory.GetFiles(fbd.SelectedPath.Replace('\\', Path.AltDirectorySeparatorChar), "*.*");

            Entry[] Entries = (from x in Files
                               orderby x
                               select new Entry()
            {
                Filename = x.Substring(fbd.SelectedPath.Length),
                Content = new StreamReader(x).BaseStream
            }).ToArray();

            Stream Output = new StreamWriter(fd.FileName).BaseStream;

            PAK.Save(Output, Entries, BigEnddian, SteamVer);
            MessageBox.Show("Packget Saved");
        }
Esempio n. 4
0
        public static byte[] OpenResource(string fileName, string resName)
        {
            try {
                PAK    pak = (PAK)CollectionUtils.Get(pakRes, fileName);
                Stream ins = Resources.OpenStream(fileName);

                ArrayByte result = null;

                if (CACHE)
                {
                    if (cacheRes == null)
                    {
                        cacheRes = new System.Collections.Generic.Dictionary <string, ArrayByte>(
                            CollectionUtils.INITIAL_CAPACITY);
                    }
                    result = (ArrayByte)CollectionUtils.Get(cacheRes, fileName);
                    if (result == null)
                    {
                        result = new ArrayByte(ins, ArrayByte.LITTLE_ENDIAN);
                        CollectionUtils.Put(cacheRes, fileName, result);
                    }
                    else
                    {
                        result.Reset(ArrayByte.LITTLE_ENDIAN);
                    }
                }
                else
                {
                    result = new ArrayByte(ins, ArrayByte.LITTLE_ENDIAN);
                }

                if (pak == null)
                {
                    pak = new PAK();
                    LPKHeader header = ReadHeader(result);
                    pak.tables    = ReadLPKTable(result, (int)header.GetTables());
                    pak.head_size = (int)(LPKHeader.Size() + header.GetTables()
                                          * LPKTable.Size());
                    pak.skip   = result.Position();
                    pak.length = result.Length();
                    CollectionUtils.Put(pakRes, fileName, pak);
                }
                else
                {
                    result.SetPosition(pak.skip);
                }

                bool       find      = false;
                int        fileIndex = 0;
                string     innerName = null;
                LPKTable[] tables_0  = pak.tables;
                int        size      = tables_0.Length;

                for (int i = 0; i < size; i++)
                {
                    innerName = tables_0[i].GetFileName();
                    if (resName.Equals(innerName, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        find      = true;
                        fileIndex = i;
                        break;
                    }
                }

                if (!find)
                {
                    throw new Exception("File not found. ( " + fileName
                                        + " )");
                }
                else
                {
                    return(ReadFileFromPak(result, pak.head_size, tables_0[fileIndex]));
                }
            } catch (Exception) {
                throw new Exception("File not found. ( " + fileName + " )");
            }
        }
Esempio n. 5
0
        //Run on init
        private void AlienModToolsAdditions()
        {
            this.Text = "OpenCAGE Content Editor";
            if (LaunchMode == AlienContentType.NONE_SPECIFIED)
            {
                return;
            }
            openToolStripMenuItem.Enabled = false;

            //Populate the form with the UI.PAK if launched as so, and exit early
            if (LaunchMode == AlienContentType.UI)
            {
                this.Text += " - UI";
                OpenFileAndPopulateGUI(SharedData.pathToAI + "/DATA/UI.PAK");
                return;
            }

            //Populate the form with the ANIMATION.PAK if launched as so, and exit early
            if (LaunchMode == AlienContentType.ANIMATION)
            {
                this.Text += " - Animations";
                OpenFileAndPopulateGUI(SharedData.pathToAI + "/DATA/GLOBAL/ANIMATION.PAK");
                return;
            }

            //Work out what file to use from our launch type
            string levelFileToUse  = "";
            string globalFileToUse = "";

            switch (LaunchMode)
            {
            case AlienContentType.MODEL:
                levelFileToUse  = "LEVEL_MODELS.PAK";
                globalFileToUse = "GLOBAL_MODELS.PAK";
                this.Text      += " - Models";
                break;

            case AlienContentType.TEXTURE:
                levelFileToUse  = "LEVEL_TEXTURES.ALL.PAK";
                globalFileToUse = "GLOBAL_TEXTURES.ALL.PAK";
                this.Text      += " - Textures";
                break;

            case AlienContentType.SCRIPT:
                levelFileToUse = "COMMANDS.PAK";
                this.Text     += " - Scripts";
                break;
            }

            //Load the files for all levels
            Cursor.Current = Cursors.WaitCursor;
            List <string> allLevelPAKs = Directory.GetFiles(SharedData.pathToAI + "/DATA/ENV/PRODUCTION/", levelFileToUse, SearchOption.AllDirectories).ToList <string>();

            if (globalFileToUse != "")
            {
                allLevelPAKs.Add(SharedData.pathToAI + "/DATA/ENV/GLOBAL/WORLD/" + globalFileToUse);
            }
            List <string> parsedFiles = new List <string>();

            foreach (string levelPAK in allLevelPAKs)
            {
                PAK thisPAK = new PAK();
                thisPAK.Open(levelPAK);
                List <string> theseFiles = thisPAK.Parse();
                foreach (string thisPAKEntry in theseFiles)
                {
                    if (!parsedFiles.Contains(thisPAKEntry))
                    {
                        parsedFiles.Add(thisPAKEntry);
                    }
                }
                AlienPAKs.Add(thisPAK);
            }
            treeHelper.UpdateFileTree(parsedFiles);
            UpdateSelectedFilePreview();
            Cursor.Current = Cursors.Default;
            groupBox3.Hide();

            //If we got here, we are using multiple PAKs, so disable some bits for one only
            exportAllFilesToolStripMenuItem.Enabled = false;
        }
Esempio n. 6
0
		public static byte[] OpenResource(string fileName, string resName) {
			try {
				PAK pak = (PAK)CollectionUtils.Get(pakRes,fileName);
				Stream ins = Resources.OpenStream(fileName);
             
				ArrayByte result = null;
	
				if (CACHE) {
					if (cacheRes == null) {
						cacheRes = new System.Collections.Generic.Dictionary<string, ArrayByte>(
								CollectionUtils.INITIAL_CAPACITY);
					}
					result = (ArrayByte)CollectionUtils.Get(cacheRes,fileName);
					if (result == null) {
						result = new ArrayByte(ins, ArrayByte.LITTLE_ENDIAN);
                        CollectionUtils.Put(cacheRes,fileName, result);
					} else {
						result.Reset(ArrayByte.LITTLE_ENDIAN);
					}
				} else {
					result = new ArrayByte(ins, ArrayByte.LITTLE_ENDIAN);
				}
    
				if (pak == null) {
					pak = new PAK();
					LPKHeader header = ReadHeader(result);
					pak.tables = ReadLPKTable(result, (int) header.GetTables());
					pak.head_size = (int) (LPKHeader.Size() + header.GetTables()
							* LPKTable.Size());
					pak.skip = result.Position();
					pak.length = result.Length();
					CollectionUtils.Put(pakRes,fileName, pak);
				} else {
					result.SetPosition(pak.skip);
				}
	
				bool find = false;
				int fileIndex = 0;
				string innerName = null;
				LPKTable[] tables_0 = pak.tables;
				int size = tables_0.Length;
	
				for (int i = 0; i < size; i++) {
					innerName = tables_0[i].GetFileName();
					if (resName.Equals(innerName,System.StringComparison.InvariantCultureIgnoreCase)) {
						find = true;
						fileIndex = i;
						break;
					}
				}
	
				if (!find) {
					throw new Exception("File not found. ( " + fileName
							+ " )");
				} else {
					return ReadFileFromPak(result, pak.head_size, tables_0[fileIndex]);
				}
			} catch (Exception) {
				throw new Exception("File not found. ( " + fileName + " )");
			}
		}