protected override IEnumerable <HpiArchive.FileInfo> EnumerateFiles(HpiArchive r) { return(r.GetFilesRecursive("objects3d") .Where(x => x.Name.EndsWith(".3do", StringComparison.OrdinalIgnoreCase) && this.objectMap.ContainsKey(HpiPath.GetFileNameWithoutExtension(x.Name)))); }
private bool IsNeededFile(HpiArchive.FileInfo entry) { var file = entry.Name; return(file.EndsWith(".gaf", StringComparison.OrdinalIgnoreCase) && this.filenameFeatureMap.ContainsKey( HpiPath.GetFileNameWithoutExtension(file))); }
protected override void LoadFile(HpiArchive archive, HpiArchive.FileInfo file) { // extract and read the file var fileBuffer = new byte[file.Size]; archive.Extract(file, fileBuffer); var adapter = new GafEntryArrayAdapter(); using (var b = new GafReader(new MemoryStream(fileBuffer), adapter)) { b.Read(); } var gaf = adapter.Entries; var records = this.filenameFeatureMap[HpiPath.GetFileNameWithoutExtension(file.Name)]; // retrieve the anim for each record foreach (var record in records) { var sequenceName = record.SequenceName; if (string.IsNullOrEmpty(sequenceName)) { // Skip if this record has no sequence name. continue; } var entry = gaf.FirstOrDefault( x => string.Equals(x.Name, sequenceName, StringComparison.OrdinalIgnoreCase)); if (entry == null) { // skip if the sequence is not in this gaf file continue; } var frame = entry.Frames[0]; Bitmap bmp; if (frame.Data == null || frame.Width == 0 || frame.Height == 0) { bmp = new Bitmap(50, 50); } else { bmp = BitmapConvert.ToBitmap( frame.Data, frame.Width, frame.Height, frame.TransparencyIndex); } var offsetImage = new OffsetBitmap(-frame.OffsetX, -frame.OffsetY, bmp); this.Records.Add(new KeyValuePair <string, OffsetBitmap>(record.Name, offsetImage)); } }
protected override void LoadFile(HpiArchive archive, HpiArchive.FileInfo file) { var records = this.objectMap[HpiPath.GetFileNameWithoutExtension(file.Name)]; var fileBuffer = new byte[file.Size]; archive.Extract(file, fileBuffer); using (var b = new MemoryStream(fileBuffer)) { var adapter = new ModelEdgeReaderAdapter(); var reader = new ModelReader(b, adapter); reader.Read(); var wire = Util.RenderWireframe(adapter.Edges); foreach (var record in records) { this.Records.Add(new KeyValuePair <string, OffsetBitmap>(record.Name, wire)); } } }
protected override void LoadFile(HpiArchive archive, HpiArchive.FileInfo file) { var fileBuffer = new byte[file.Size]; archive.Extract(file, fileBuffer); using (var s = new SctReader(new MemoryStream(fileBuffer))) { var section = new Section(archive.FileName, file.FullPath); section.Name = HpiPath.GetFileNameWithoutExtension(file.Name); section.Minimap = SectionFactory.MinimapFromSct(s); section.DataWidth = s.DataWidth; section.DataHeight = s.DataHeight; var directoryString = HpiPath.GetDirectoryName(file.FullPath); Debug.Assert(directoryString != null, "Null directory for section in HPI."); var directories = directoryString.Split('\\'); section.World = directories[1]; section.Category = directories[2]; this.Records.Add(section); } }
private static IEnumerable <string> GetMapNames(HpiArchive hpi) { return(hpi.GetFiles("maps") .Where(x => x.Name.EndsWith(".tnt", StringComparison.OrdinalIgnoreCase)) .Select(x => HpiPath.GetFileNameWithoutExtension(x.Name))); }