internal static async Task <int> UnpackPak(FileInfo fileInfo, string outputDirectory, bool showContentInfo = false) { try { PakFile pak = PakFile.Open(fileInfo); if (showContentInfo) { CliUtilities.PrintRow("File", "FileSize"); ShowPakInfo(pak); Console.WriteLine(); } Console.WriteLine($"Total file count {pak.FileCount} \n"); bool unpack = CliUtilities.ShowConsolePrompt($"Do you want to unpack {fileInfo.Name}"); if (unpack) { await Unpack(pak, outputDirectory); } } catch (Exception ex) { Console.WriteLine(ex); return(1); } return(0); }
/// <summary> /// Adds the file at a given url to the currently compiling pak file. /// </summary> /// <param name="path">Url of file to add to pak file.</param> /// <param name="locator">Path that should be used by the pak file to locate the paked file in future.</param> private void PakFile(string path, string locator) { // Create a pak resource to represent this file and add it to the pak file. PakResource resource = new PakResource(_pakFile, locator, 0, 0); _pakFile.AddResource(resource); // Load the files data into a memory stream and attach it to the resource. Stream stream = StreamFactory.RequestStream(path, StreamMode.Open); // If the size of the data is over the maximum pak size then // create a new one. if (_pakFileMaximumSize != 0 && _pakFileSize + stream.Length > ((_pakFileMaximumSize * 1024) * 1024) && _pakFile.Resources.Count > 1) { _pakFile.RemoveResource(resource); // Find a new pak file we can create without overwriting anything, and save to it. string filePath = _buildDirectory + "\\" + _pakFilePrefix.Replace("#", _pakFileIndex.ToString()) + ".pk"; int fileIndex = 0; while (File.Exists(filePath) == true) { filePath = _buildDirectory + "\\" + _pakFilePrefix.Replace("#", _pakFileIndex.ToString()) + (fileIndex++) + ".pk"; } _pakFile.Save(filePath); _pakFileIndex++; _pakFileSize = 0; // Create a new pak file to put the rest of the resources into. _pakFile = new PakFile(); _pakFile.AddResource(resource); } resource.DataStream = stream; _pakFileSize += (int)stream.Length; }
void ExtractArt() { var artpak = new PakFile(@"MCG_DATA\ART\ART.PAK"); MCBitmap atlas; Dictionary <string, Rect> dict; for (int i = 0; i < artpak.PakInnerFileCount; i++) { var aux = artpak.GetFileInner(i); if (aux != null) { if (aux[0] == 71 && aux[1] == 73 && aux[2] == 70) { System.IO.File.WriteAllBytes(@"a\" + i + ".gif", aux); } else { System.IO.File.WriteAllBytes(@"a\" + i + ".shp", aux); try { var shp = new ShpFile(aux); ImageProcessing.CreateAtlas(shp.GetBitMaps(), out atlas, out dict); var MainText = ImageProcessing.MakeTexture2D(atlas, MechCommanderUnity.Instance.ContentReader.ShapesPakFile.Palette); ImageProcessing.SaveTextureAsPng(MainText, @"a\" + i); } catch (Exception) {} } } } }
public void LoadPak(string Filename) { if (cache != null) { cache.Close(); } cache = null; if (pak != null) { pak.Close(); } pak = null; this.Filename = Filename; HierarchyMode = false; pak = new PakFile(Filename); tv = new TagViewer(settings, extractor1); tvTags.Nodes.Clear(); LoadPakItems(); isCache = false; }
public SceneData(PakFile Pak, PakFile.PakTag Item) { var reader = Pak.Reader; reader.EndianType = EndianFormat.LittleEndian; reader.SeekTo(Item.Offset); unmapped0 = reader.ReadBytes(16); x0700 = reader.ReadInt16(); //0700 xADDE = reader.ReadInt16(); //ADDE var min = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); var max = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); unkBounds = new BoundingBox() { XBounds = new Range<float>(min.X, max.X), YBounds = new Range<float>(min.Y, max.Y), ZBounds = new Range<float>(min.Z, max.Z), }; var count = reader.ReadInt32(); //always bsp object count + 1 indices = new List<int>(); for (int i = 0; i < count; i++) indices.Add(reader.ReadInt32()); //last value is always struct0 count count = reader.ReadInt32(); unkS0 = new List<struct0>(); for (int i = 0; i < count; i++) unkS0.Add(new struct0(Pak, Item)); unmapped1 = reader.ReadBytes(13); //always the same }
public void LoadMap(string Filename, bool Hierarchy) { if (cache != null) { cache.Close(); } cache = null; if (pak != null) { pak.Close(); } pak = null; this.Filename = Filename; HierarchyMode = Hierarchy; cache = CacheManager.GetCache(Filename); tv = new TagViewer(settings, extractor1); tvTags.Nodes.Clear(); if (HierarchyMode) { LoadHierarchy(); } else { LoadClasses(); } isCache = true; }
public void LoadBitmapTag(PakFile Pak, PakFile.PakTag Item) { exportAllImagesToolStripMenuItem.Visible = false; pak = Pak; item = Item; pict = new Texture(pak, item); lstBitmaps.Items.Clear(); var list = new List <Bitmap>() { GetBitmapByTag(pak, pict, PixelFormat.Format32bppArgb) }; var map = list[0]; for (int i = 0; i < list.Count; i++) { lstBitmaps.Items.Add(new ListViewItem(new string[] { i.ToString(), pict.Width.ToString(), pict.Height.ToString(), "S3DPICT".ToString(), pict.Format.ToString() }) { Tag = (list[i] == null) ? GetErrorImage() : list[i] }); } lstBitmaps.FocusedItem = lstBitmaps.Items[0]; lstBitmaps_SelectedIndexChanged(null, null); }
public Texture(PakFile Pak, PakFile.PakTag Item) { var reader = Pak.Reader; reader.EndianType = EndianFormat.LittleEndian; reader.SeekTo(Item.Offset + 6); isLittleEndian = reader.ReadInt32() == 1346978644; //PICT if (!isLittleEndian) reader.EndianType = Endian.EndianFormat.BigEndian; reader.SeekTo(Item.Offset + (isLittleEndian ? 16 : 12)); Width = reader.ReadInt32(); Height = reader.ReadInt32(); reader.SeekTo(Item.Offset + (isLittleEndian ? 38 : 32)); Format = BitmapFormat.Dxt5; var intFormat = reader.ReadInt32(); switch (intFormat) { case 0: Format = BitmapFormat.A8R8G8B8; break; case 10: Format = BitmapFormat.A8Y8; break; case 12: Format = BitmapFormat.Dxt1; break; case 13: Format = BitmapFormat.Dxt1; break; case 15: Format = BitmapFormat.Dxt3; break; case 17: Format = BitmapFormat.Dxt5; break; case 22: Format = BitmapFormat.X8R8G8B8; break; case 36: Format = BitmapFormat.Dxn; break; case 37: Format = BitmapFormat.DXT5a; break; default: throw new Exception("CHECK THIS"); } reader.SeekTo(Item.Offset + (isLittleEndian ? 28 : 24)); int mapCount = reader.ReadInt32(); if (mapCount == 6) Type = BitmapType.CubeMap; else Type = BitmapType.Texture2D; if (mapCount > 1 && mapCount != 6) throw new Exception("CHECK THIS"); DataAddress = Item.Offset + (isLittleEndian ? 58 : 4096); reader.EndianType = Endian.EndianFormat.LittleEndian; //in case it was PICT }
private static void ExtractEntry(string inputFile, string entryName, string outputFile) { FileStream inputStream = OpenStream(inputFile, FileMode.Open, FileAccess.Read); PakFile pakFile = OpenPak(inputStream); byte[] buffer = new byte[4096]; if (!pakFile.HasEntry(entryName)) { Console.WriteLine("!!!ERROR!!! ExtractEntry::Could not find entry {0}", entryName); Environment.Exit(1); } Stream entryStream = pakFile.GetEntryStream(entryName); FileStream outputStream = OpenStream(outputFile, FileMode.Create, FileAccess.Write); while (true) { int bytesRead = entryStream.Read(buffer, 0, buffer.Length); if (bytesRead == 0) { break; } outputStream.Write(buffer, 0, bytesRead); } outputStream.Dispose(); pakFile.Close(); }
public static Task <IAssetUnityPack> GetCryAssetPackAsync(this Uri uri, Func <object> func = null) { uri.ToCryGame(func, out var proxySink, out var filePaths); var pakFile = new PakFile(filePaths[0]); return(Task.FromResult((IAssetUnityPack) new CryAssetPack(proxySink, pakFile))); }
public PakFile Read() { PakFile data = new PakFile(); try { var manifest = ReadManifest(); var archiveStream = File.OpenRead(_archiveFile); foreach (var dir in manifest.Directories) { foreach (var file in dir.Files) { if (file.Type != PakFileType.Directory) { data.Entries.Add(new PakEntry(archiveStream, dir.Name, file)); } } } } catch (Exception e) { throw new PakReaderException("Failed to parse manifest!", e); } return(data); }
static public void CellClick(object sender, EventArgs a) { DataGridViewCell Cell = Extractor.Data.CurrentCell; if (Extractor.Box.SelectedItem != null) { string FullName = (Extractor.Box.SelectedItem as FileInfo).FullName; PakFile Pak = _Paks[FullName]; PakElement Element = Pak._Elements.Find(info => info.Id == int.Parse(Cell.OwningRow.Cells[0].Value.ToString())); if (Cell.OwningColumn.Name == "Extract") { if (Element != null) { AddToExtract(Element); } } else if (Cell.OwningColumn.Name == "Software") { if (Element != null) { Element.OpenSoftware(); } } } }
public ObjectTypeManager(string objFileName) { string ObjFileName = System.IO.Path.ChangeExtension(objFileName, "pak"); this.objPakFile = new PakFile(MCGExtensions.PathCombine(new string[] { MechCommanderUnity.Instance.MCGPath, "objects", ObjFileName })); ObjectTypeList = new Dictionary <int, ObjectType>(); }
private TResource?ReadEmbeddedResource <TResource>(Record requestFile, PakFile file) { var outSt = requestFile.Unpack(file.FileStream); var request = new StreamReader(outSt).ReadToEnd(); var embed = JsonSerializer.Deserialize <TResource>(request, _parser.RelaxedOptions); return(embed); }
public PakElement(PakFile Owner, FileHeader Header, ExtendedFileStream Stream) { this.Owner = Owner; this.Id = Owner.GetId(); this.Stream = Stream; this.Header = Header; GetExtention(); }
public static void Init() { if (initialized) { for (int i = 0; i < paks.Count; i++) { paks[i].UnloadPak(); } paks.Clear(); } else { #if UNITY_EDITOR EditorApplication.playModeStateChanged += OnPlayModeStateChanged; #endif } if (!Utils.IsGamePathValid()) { Console.LogError("ResourceLoader: Couldn't verify game folder. Fix your paths!"); initialized = true; return; } if (!Utils.IsModnameValid()) { Console.LogWarning("ResourceLoader: Invalid modname!"); } //find paks and load them string gamepath = Globals.gamepath.Text; string pattern = "*.pak"; List <FileInfo> pakfiles = new List <FileInfo>(); //load moddir paks first (higher priority) - skip when mod is baseq2... if (Globals.modname.Text != "baseq2") { DirectoryInfo moddir = new DirectoryInfo(Globals.gamepath.Text + "/" + Globals.modname.Text); pakfiles.AddRange(moddir.GetFiles(pattern, SearchOption.TopDirectoryOnly)); } DirectoryInfo baseq2 = new DirectoryInfo(Globals.gamepath.Text + "/baseq2"); pakfiles.AddRange(baseq2.GetFiles(pattern, SearchOption.TopDirectoryOnly)); foreach (FileInfo i in pakfiles) { PakFile p = new PakFile(); p.LoadPak(gamepath + "/baseq2/" + i.Name); if (p.IsPakLoaded) { paks.Add(p); } } Console.DebugLog("Detected " + pakfiles.Count + " pak files containing " + paks.Select(i => i.Files.Count).Sum() + " files."); initialized = true; }
public AppearanceTypeManager(string spriteFileName) { spriteFileName = System.IO.Path.ChangeExtension(spriteFileName, "pak"); this.spritePakFile = new PakFile(MCGExtensions.PathCombine(new string[] { MechCommanderUnity.Instance.MCGPath, "sprites", spriteFileName })); AppearanceTypeList = new Dictionary <int, AppearanceType>(); }
public override void GetFilesToArchive(ProjectParams Params, DeploymentContext SC) { if (SC.StageTargetConfigurations.Count != 1) { throw new AutomationException("iOS is currently only able to package one target configuration at a time, but StageTargetConfigurations contained {0} configurations", SC.StageTargetConfigurations.Count); } string PackagePath = Path.Combine(Path.GetDirectoryName(Params.RawProjectPath), "Binaries", "HTML5"); string FinalDataLocation = Path.Combine(PackagePath, Params.ShortProjectName) + ".data"; // copy the "Executable" to the archive directory string GameExe = Path.GetFileNameWithoutExtension(Params.ProjectGameExeFilename); if (Params.ClientConfigsToBuild[0].ToString() != "Development") { GameExe += "-HTML5-" + Params.ClientConfigsToBuild[0].ToString(); } GameExe += ".js"; // put the HTML file to the package directory string OutputFile = Path.Combine(PackagePath, (Params.ClientConfigsToBuild[0].ToString() != "Development" ? (Params.ShortProjectName + "-HTML5-" + Params.ClientConfigsToBuild[0].ToString()) : Params.ShortProjectName)) + ".html"; // data file SC.ArchiveFiles(PackagePath, Path.GetFileName(FinalDataLocation + ".gz")); // data file js driver SC.ArchiveFiles(PackagePath, Path.GetFileName(FinalDataLocation + ".js.gz")); // main js file SC.ArchiveFiles(PackagePath, Path.GetFileName(GameExe + ".gz")); // memory init file SC.ArchiveFiles(PackagePath, Path.GetFileName(GameExe + ".mem.gz")); // symbols file SC.ArchiveFiles(PackagePath, Path.GetFileName(GameExe + ".symbols.gz")); // utilities SC.ArchiveFiles(PackagePath, Path.GetFileName("Utility.js.gz")); // landing page. SC.ArchiveFiles(PackagePath, Path.GetFileName(OutputFile)); // Archive HTML5 Server and a Readme. var LaunchHelperPath = CombinePaths(CmdEnv.LocalRoot, "Engine/Binaries/DotNET/"); SC.ArchiveFiles(LaunchHelperPath, "HTML5LaunchHelper.exe"); SC.ArchiveFiles(Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "HTML5"), "Readme.txt"); SC.ArchiveFiles(PackagePath, Path.GetFileName(Path.Combine(PackagePath, "RunMacHTML5LaunchHelper.command"))); if (HTMLPakAutomation.CanCreateMapPaks(Params)) { // find all paks. string[] Files = Directory.GetFiles(Path.Combine(PackagePath, Params.ShortProjectName), "*", SearchOption.AllDirectories); foreach (string PakFile in Files) { var DestPak = PakFile.Replace(PackagePath, ""); SC.ArchivedFiles.Add(PakFile, DestPak); } } UploadToS3(SC); }
private static async Task Unpack(PakFile pak, string outputDirectory) { foreach (KeyValuePair <string, PakEntry> file in pak.AbsoluteIndex) { DataSegment entry = await pak.ReadEntryAsync(file.Value); string outputPath = Path.Combine(outputDirectory, file.Value.FileName); await File.WriteAllBytesAsync(outputPath, entry.ToArray()); } }
public struct0(PakFile Pak, PakFile.PakTag Item) { unk0 = new int[12]; //not sure if signed or not //appears to be compressed floats, might be //coordinates relative to the bounds values for (int i = 0; i < 12; i++) unk0[i] = Pak.Reader.ReadInt16(); }
bool IPackageLoader.TryParsePackage(Stream s, string filename, FS context, out IReadOnlyPackage package) { if (!filename.EndsWith(".pak", StringComparison.InvariantCultureIgnoreCase)) { package = null; return(false); } package = new PakFile(s, filename); return(true); }
public IEnumerable <IEnumerable <KeyValuePair <string, EntValue> > > GetStaticPropKeyVals() { var propLump = GameLumps.FirstOrDefault(x => x.Id == 0x73707270); if (propLump == null) { yield break; } Debug.Assert(propLump.Version == 10); string[] modelNames; int propCount; int readOffset; using (var stream = new MemoryStream(propLump.Contents)) using (var reader = new BinaryReader(stream)) { var modelNameCount = reader.ReadInt32(); modelNames = new string[modelNameCount]; var nameBuffer = new byte[128]; for (var i = 0; i < modelNameCount; ++i) { stream.Read(nameBuffer, 0, 128); modelNames[i] = Encoding.ASCII.GetString(nameBuffer).TrimEnd('\0'); } var leafCount = reader.ReadInt32(); stream.Seek(leafCount * 2, SeekOrigin.Current); propCount = reader.ReadInt32(); readOffset = (int)reader.BaseStream.Position; } var props = ReadLumpWrapper <StaticPropV10> .ReadLump(propLump.Contents, readOffset, propCount *Marshal.SizeOf(typeof(StaticPropV10))); var index = 0; foreach (var prop in props) { var modelName = modelNames[prop.PropType]; var hdrLighting = string.Format("sp_hdr_{0}.vhv", index); var ldrLighting = string.Format("sp_{0}.vhv", index); var lightingFile = PakFile.ContainsFile(hdrLighting) ? hdrLighting : PakFile.ContainsFile(ldrLighting) ? ldrLighting : null; yield return(GetStaticPropKeyVals(prop, modelName, lightingFile)); ++index; } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { var dialogResult = this.openFileDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { var oldArchive = this.openArchive; this.openArchive = PakFile.Open(this.openFileDialog.FileName); oldArchive?.Dispose(); populateListView(); } }
/// <summary> /// Setup API file readers. /// </summary> private void SetupReaders() { // Setup general content readers // Ensure reader is created //palettePath = Path.Combine(mcPath, "logistic.pal"); //if (objPakFile == null) //{ // objPakFile = new PakFile(Path.Combine(mcPath, objpakpath), palettePath); //} //if (spritesPakFile == null) //{ // spritesPakFile = new PakFile(Path.Combine(mcPath, spritespakpath), palettePath); //} if (shapesPakFile == null) { shapesPakFile = new PakFile(Path.Combine(mcPath, shapespakpath), MechCommanderUnity.Instance.FileManager.File(PaletteXpansion? GpalettePath: palettePath)); } if (shapes90PakFile == null) { shapes90PakFile = new PakFile(Path.Combine(mcPath, shapes90pakpath), MechCommanderUnity.Instance.FileManager.File(PaletteXpansion? GpalettePath: palettePath)); } //if (torsoPakFile == null) //{ // torsoPakFile = new PakFile(Path.Combine(mcPath, pathTorso), palettePath); //} //if (legsPakFile == null) //{ // legsPakFile = new PakFile(Path.Combine(mcPath, pathLegs), palettePath); //} //if (rarmPakFile == null) //{ // rarmPakFile = new PakFile(Path.Combine(mcPath, pathRarm), palettePath); //} //if (larmPakFile == null) //{ // larmPakFile = new PakFile(Path.Combine(mcPath, pathLarm), palettePath); //} //if (tilesPakFile == null) //{ // tilesPakFile = new PakFile(Path.Combine(mcPath, pathTiles90), palettePath); //} //if (gtilesPakFile == null) //{ // gtilesPakFile = new PakFile(Path.Combine(mcPath, pathGTiles90), GpalettePath); //} isReady = true; }
public void OnExit(object sender, FormClosingEventArgs a) { lock (_ToExtract) _ToExtract.Clear(); Extracting = null; Decoding = null; Time.Stop(); ExtractorMgr.IsRunning = false; }
public void UnlinkPackage(string path) { // Make sure the package is actually linked. if (!linkedPackages.Contains(path)) { Engine.Log.WriteLine("warning/system/resourcemanager", "Tried to unlink non existing package {0}", path); return; } // Get the package to unlink from the linked packages map. PakFile pakFile = linkedPackages[path]; // Upmap all entries in the package. foreach (PakEntry entry in pakFile.Entries) { if (packageMapping[entry.Name].Peek().Equals(pakFile)) { // Entry is on top of the stack, simply pop it off. packageMapping[entry.Name].Pop(); } else { // Entry is somewhere in the stack, inefficient method to remove it and preserve the stack order, but required to properly unmap the entry. // Add all entries to a new temporary stack unless it's the entry to remove // then clear the original stack and push every entry in the temp stack back to the original stack. IStack <PakFile> mapping = packageMapping[entry.Name]; IStack <PakFile> temp = new ArrayStack <PakFile>(mapping.Count); while (mapping.Count != 0) { PakFile pakFileEntry = mapping.Pop(); if (!pakFileEntry.Equals(pakFile)) { temp.Push(pakFileEntry); } } while (temp.Count != 0) { mapping.Push(temp.Pop()); } } } // Close the package and the underlying stream. pakFile.Close(); // Remove the package from the linked packages map as it's now completely unlinked. linkedPackages.Remove(path); }
private static async Task UnpackDirectory(PakFile pak, string outputDirectory, IProgress <PakEntry> fileProgress) { foreach (KeyValuePair <string, PakEntry> file in pak.AbsoluteIndex) { DataSegment entry = await pak.ReadEntryAsync(file.Value); string outputPath = Path.Combine(outputDirectory, file.Key); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); await File.WriteAllBytesAsync(outputPath, entry.ToArray()); fileProgress.Report(file.Value); } }
static public PakFile DecodePak(FileInfo Info) { if (!_Paks.ContainsKey(Info.FullName)) { PakFile Pak = new PakFile(Info); _Paks.Add(Info.FullName, Pak); Pak.DelistThread = new Thread(new ThreadStart(Pak.DeList)); Pak.DelistThread.Start(); } return(_Paks[Info.FullName]); }
public void Dispose() { lock ( _threadStreams ) { foreach (var stream in _threadStreams) { stream.Dispose(); } _threadStreams.Clear(); } PakFile.Dispose(); }
private void Down_Click(object sender, RoutedEventArgs e) { var selectedIndex = mainList.SelectedIndex; if (selectedIndex + 1 < paksList.Count) { PakFile itemToMoveDown = paksList[selectedIndex]; paksList.RemoveAt(selectedIndex); paksList.Insert(selectedIndex + 1, itemToMoveDown); mainList.SelectedIndex = selectedIndex + 1; UpdateFileNames(paksList); } }
private void Up_Click(object sender, RoutedEventArgs e) { var selectedIndex = mainList.SelectedIndex; if (selectedIndex > 0) { PakFile itemToMoveUp = paksList[selectedIndex]; paksList.RemoveAt(selectedIndex); paksList.Insert(selectedIndex - 1, itemToMoveUp); mainList.SelectedIndex = selectedIndex - 1; UpdateFileNames(paksList); } }
public static Bitmap GetBitmapByTag(PakFile Pak, Texture pict, PixelFormat PF) { try { byte[] raw; Pak.Reader.SeekTo(pict.DataAddress); raw = Pak.Reader.ReadBytes(pict.RawSize); //change to BigEndian if (pict.isLittleEndian) { int block = 2; if (pict.Format == TextureFormat.A8R8G8B8 || pict.Format == TextureFormat.X8R8G8B8) { block = 4; } for (int i = 0; i < raw.Length; i += block) { Array.Reverse(raw, i, block); } } if (pict.Type == TextureType.CubeMap) { return(DXTDecoder.DecodeCubeMap(raw, pict, PF)); } raw = DXTDecoder.DecodeBitmap(raw, pict); //PixelFormat PF = (Alpha) ? PixelFormat.Format32bppArgb : PixelFormat.Format32bppRgb; Bitmap bitmap2 = new Bitmap(pict.Width, pict.Height, PF); Rectangle rect = new Rectangle(0, 0, pict.Width, pict.Height); BitmapData bitmapdata = bitmap2.LockBits(rect, ImageLockMode.WriteOnly, PF); byte[] destinationArray = new byte[(pict.Width * pict.Height) * 4]; for (int j = 0; j < pict.Height; j++) { Array.Copy(raw, j * pict.VirtualWidth * 4, destinationArray, j * pict.Width * 4, pict.Width * 4); } Marshal.Copy(destinationArray, 0, bitmapdata.Scan0, destinationArray.Length); bitmap2.UnlockBits(bitmapdata); return(bitmap2); } catch { return(null); } }
private void l_files_SelectedValueChanged(object sender, EventArgs e) { if (l_files.SelectedItem == null) { return; } if (Decoding != null && Decoding.Decoded == false) { return; } l_files.Enabled = false; ClearData(); Decoding = ExtractorMgr.DecodePak((l_files.SelectedItem as FileInfo)); }
public SceneCDT(PakFile Pak, PakFile.PakTag Item) { var reader = Pak.Reader; reader.EndianType = EndianFormat.LittleEndian; reader.SeekTo(Item.Offset); reader.ReadInt16(); //F000 reader.ReadInt32(); //07000000 reader.ReadByte(); //12 unmapped0 = reader.ReadBytes(16); //??? var count = reader.ReadInt32(); //03000000 [data set count] for (int i = 0; i < count; i++) sets.Add(new DataSet(Pak, Item)); }
public DataSet(PakFile Pak, PakFile.PakTag Item) { var reader = Pak.Reader; var count = reader.ReadInt32(); if (count == 0) return; for (int i = 0; i < count; i++) unkS0.Add(new struct0(Pak, Item)); unk0 = reader.ReadInt32(); //total faces MinBound = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); unkf0 = reader.ReadSingle(); DataLength = reader.ReadInt32(); reader.ReadBytes(DataLength); //unmapped }
public static PakFile DecodePak(FileInfo Info) { if (!_Paks.ContainsKey(Info.FullName)) { PakFile Pak = new PakFile(Info); _Paks.Add(Info.FullName, Pak); Pak.DelistThread = new Thread(new ThreadStart(Pak.DeList)); Pak.DelistThread.Start(); } return _Paks[Info.FullName]; }
public MatInfo(PakFile Pak) { var reader = Pak.Reader; reader.ReadInt16(); //0E01 reader.ReadInt32(); //address to 1401 reader.ReadInt32(); //mat ID reader.ReadInt32(); //FFFFFFFF reader.ReadInt16(); //00FF/FFFF reader.ReadInt16(); //1401 reader.ReadInt32(); //address to 1F01 reader.ReadInt16(); //FFFF/0001 reader.ReadInt16(); //1F01 reader.ReadInt32(); //address to BA01 reader.ReadInt16(); //00FF reader.ReadInt16(); //BA01 reader.ReadInt32(); //address to end of string (0100) reader.ReadNullTerminatedString(); reader.ReadInt16(); //0100 reader.ReadInt16(); //address of next }
public void Update(object sender,EventArgs a) { tool_progress.Value = ProgressValue; tip_status.Text = ToolText; if (datagrid.Rows.Count <= 0 && Decoding != null && Decoding.Decoded) { Decoding.PrintHeaders(); l_files.Enabled = true; } if (AllId >= 0 && (Decoding == null || Decoding.Decoded) && ExtractorMgr._ToExtract.Count <= 0) { if (Decoding != null) { foreach (PakElement Element in Decoding._Elements) if (Extractor.Instance.IsChecked(Element.Header.Ext)) ExtractorMgr.AddToExtract(Element); } if (AllId < l_files.Items.Count) { FileInfo Info = l_files.Items[AllId] as FileInfo; if (Info != null) { l_files.SelectedIndex = AllId; Decoding = ExtractorMgr.DecodePak(Info); l_files.Enabled = false; } ++AllId; } else AllId = -1; } }
private void l_files_SelectedValueChanged(object sender, EventArgs e) { if (l_files.SelectedItem == null) return; if (Decoding != null && Decoding.Decoded == false) return; l_files.Enabled = false; ClearData(); Decoding = ExtractorMgr.DecodePak((l_files.SelectedItem as FileInfo)); }
public struct0(PakFile Pak, PakFile.PakTag Item) { var reader = Pak.Reader; NodeID = reader.ReadInt16(); //ID for bsp node NodeFaces = reader.ReadInt32(); //face count for bsp node unk1 = reader.ReadInt32(); //??? //usually always large negative //may not actually be a float //(though always valid as one) unkf0 = reader.ReadSingle(); }
public Template(PakFile Pak, PakFile.PakTag Item, bool loadMesh) { var reader = Pak.Reader; reader.EndianType = EndianFormat.LittleEndian; reader.StreamOrigin = Item.Offset; reader.SeekTo(0); reader.ReadInt16(); //E402 reader.ReadInt32(); //filesize (EOB offset?) #region Block E502 reader.ReadInt16(); //E502 reader.ReadInt32(); //EOB offset reader.ReadInt32(); //LPTA (probs part of the string) Name = reader.ReadNullTerminatedString(); reader.ReadByte(); //00 #endregion #region Block 1603 reader.ReadInt16(); //1603 reader.ReadInt32(); //EOB offset reader.ReadBytes(3); //02 01 01 #endregion #region Block 5501 reader.ReadInt16(); //5501 reader.ReadInt32(); //address int count = reader.ReadInt32(); Materials = new List<MatRefBlock_5601>(); for (int i = 0; i < count; i++) Materials.Add(new MatRefBlock_5601(reader)); #endregion reader.ReadInt16(); //0100 reader.ReadInt32(); //address #region Block F000 xF000 = reader.ReadInt16(); reader.ReadInt32(); //EOB offset x2C01 = reader.ReadInt16(); reader.ReadInt32(); //EOB offset count = reader.ReadInt32(); Objects = new List<Node>(); for (int i = 0; i < count; i++) Objects.Add(new Node(reader, loadMesh)); foreach (var obj in Objects) if (obj.isInheritor) Objects[obj._2901.InheritID].isInherited = true; #endregion reader.ReadInt16(); //0100 reader.ReadInt32(); //address #region Block E802 reader.ReadInt16(); //E802 reader.ReadInt32(); //address count = reader.ReadInt32(); for (int i = 0; i < count; i++) Bones.Add(new BoneBlock_E902(reader)); #endregion //havent mapped this block, assumed anim/sound related _E602 = new unkBlock_XXXX(reader, 0xE602); reader.ReadInt16(); //0100 reader.ReadInt32(); //address if (reader.PeekUInt16() == 0xBA01) unkStrBlk = new StringBlock_BA01(reader); //contains data count, havent seen used _1D02 = new unkBlock_XXXX(reader, 0x1D02); //int16 count, [int16, int16] * count if (reader.PeekUInt16() == 0x1103) _1103 = new unkBlock_XXXX(reader, 0x1103); //contains null term string, used on IGA models _0403 = new unkBlock_XXXX(reader, 0x0403); if (reader.PeekUInt16() == 0x0503) _0503 = new Block_0503(reader); #region Block 0803 reader.ReadInt16(); //0803 reader.ReadInt32(); //address to end of bounds values reader.ReadInt32(); //bounds count? var min = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); var max = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); RenderBounds = new BoundingBox(); RenderBounds.XBounds = new Range<float>(min.X, max.X); RenderBounds.YBounds = new Range<float>(min.Y, max.Y); RenderBounds.ZBounds = new Range<float>(min.Z, max.Z); #endregion _0E03 = new Block_0E03(reader); //contains length prefixed string if (reader.PeekUInt16() == 0x1203) _1203 = new unkBlock_XXXX(reader, 0x1203); reader.ReadInt16(); //0100 reader.ReadInt32(); //address to EOF reader.StreamOrigin = 0; }
public Scene(PakFile Pak, PakFile.PakTag Item, bool loadMesh) { var reader = Pak.Reader; reader.EndianType = EndianFormat.LittleEndian; reader.StreamOrigin = Item.Offset; reader.SeekTo(0); Name = Item.Name; //contains 16bytes, maybe all uint16 _C003 = new unkBlock_XXXX(reader, 0xC003); #region Block 5501 reader.ReadInt16(); //5501 reader.ReadInt32(); //address int count = reader.ReadInt32(); Materials = new List<MatRefBlock_5601>(); for (int i = 0; i < count; i++) Materials.Add(new MatRefBlock_5601(Pak.Reader)); #endregion reader.ReadInt16(); //0100 reader.ReadInt32(); //address #region Block 1F02 reader.ReadInt16(); //1F02 reader.ReadInt32(); //EOB offset _2002 = new Block_2002(reader); _2102 = new Block_2102(reader); _2202 = new Block_2202(reader, _2102.unk0); #endregion reader.ReadInt16(); //0100 reader.ReadInt32(); //address #region Block 8204 reader.ReadInt16(); //8204 reader.ReadInt32(); //address count = reader.ReadInt32(); Scripts = new List<StringBlock_BA01>(); for (int i = 0; i < count; i++) Scripts.Add(new StringBlock_BA01(Pak.Reader)); #endregion _8404 = new unkBlock_XXXX(reader, 0x8404); #region Block F000 xF000 = reader.ReadInt16(); reader.ReadInt32(); x2C01 = reader.ReadInt16(); reader.ReadInt32(); //address to first object count = reader.ReadInt32(); Objects = new List<Node>(); for (int i = 0; i < count; i++) Objects.Add(new Node(Pak.Reader, loadMesh)); #endregion reader.ReadInt16(); //0100 reader.ReadInt32(); //address //additional geometry, mainly sky objects _EA01 = new unkBlock_XXXX(reader, 0xEA01); reader.ReadInt16(); //0100 reader.ReadInt32(); //address //additional objects, no geometry, lighting related _B801 = new unkBlock_XXXX(reader, 0xB801); reader.ReadInt16(); //0100 reader.ReadInt32(); //address //additional objects, no geometry, lighting related _8002 = new unkBlock_XXXX(reader, 0x8002); reader.ReadInt16(); //0100 reader.ReadInt32(); //address //6x int32 _2504 = new unkBlock_XXXX(reader, 0x2504); reader.ReadInt16(); //0100 reader.ReadInt32(); //address //empty? _1D02 = new unkBlock_XXXX(reader, 0x1D02); foreach (var obj in Objects) if (obj.isInheritor) Objects[obj._2901.InheritID].isInherited = true; reader.StreamOrigin = 0; }
public static void Start() { MapProvider.Register(new RmfProvider()); MapProvider.Register(new VmfProvider()); GameDataProvider.Register(new FgdProvider()); TextureProvider.Register(new WadProvider()); // var editor = new Editor.Editor(); // editor.Load += (sender, e) => PostStart(sender as Editor.Editor); // Application.Run(editor); // var settings = Context.DBContext.GetAllSettings().ToDictionary(x => x.Key, x => x.Value); // Serialise.DeserialiseSettings(settings); // var settingsform = new Editor.Settings.SettingsForm(); // Application.Run(settingsform); // var map = MapProvider.GetMapFromFile(MapFile); // Document.Game = Game; // Document.Map = map; // Document.GameData = GameDataProvider.GetGameDataFromFiles(Game.Fgds.Select(f => f.Path)); // var entity = new EntityEditor(); // entity.Objects.AddRange(map.WorldSpawn.Children.OfType<Entity>().Take(1)); // Application.Run(entity); /* var nat = new NativeFile(new DirectoryInfo(@"F:\Steam\steamapps\common\Half-Life")); var gcf1 = new GcfFile(@"F:\Steam\steamapps\half-life.gcf"); var gcf2 = new GcfFile(@"F:\Steam\steamapps\half-life engine.gcf"); //var gcf3 = new GcfFile(@"F:\Steam\steamapps\half-life base content.gcf"); var gcf4 = new GcfFile(@"F:\Steam\steamapps\platform.gcf"); var com = new CompositeFile(null, new IFile[] { nat, gcf1, gcf2, gcf4 }); */ var nat = new NativeFile(new DirectoryInfo(@"F:\Half-Life WON")); var pak = new PakFile(@"F:\Half-Life WON\valve\pak0.pak"); var vir = new VirtualFile(null, "valve", new[] {pak}); var com = new CompositeFile(null, new IFile[] { nat, vir }); var fsb = new FileSystemBrowserControl {Dock = DockStyle.Fill, File = nat};//, FilterText = "WAD Files", Filter = "*.wad"}; var form = new Form {Controls = {fsb}, Width = 500, Height = 500}; Application.Run(form); }