public static bool LoadZip(String ZipPath, Color Transparency) { using (ZipFile zip = ZipFile.Read(ZipPath)) { foreach (ZipEntry e in zip) { string ext = Path.GetExtension(e.FileName).ToLower(); if (!(ext == ".frm" || ext == ".png")) { continue; } bool Valid = false; foreach (String path in GraphicsPaths) { if (e.FileName.Contains(path)) { Valid = true; } } if (!Valid) { continue; } if (!(e.FileName.Contains("art\\items") || e.FileName.Contains("art\\inven"))) { continue; } System.IO.MemoryStream memstream = new MemoryStream(); e.Extract(memstream); List <Byte> data = new List <Byte>(); Byte[] buffer = new Byte[4]; memstream.Seek(0, SeekOrigin.Begin); while (memstream.Read(buffer, 0, 4) > 0) { data.AddRange(new List <Byte>(buffer)); } if (ext == ".frm") { List <Bitmap> bmaps = FalloutFRM.Load(data.ToArray(), Transparency); Graphics[e.FileName.ToLower()] = bmaps[0]; } else { Image img = Bitmap.FromStream(memstream); Graphics[e.FileName.ToLower()] = (Bitmap)img; } } } return(true); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.CheckPathExists = true; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //FalloutFRM frm = new FalloutFRM(); loadedFrm = FalloutFRM.Load(fileDialog.FileName, Mask); pnlRender.Invalidate(); } }
public static bool LoadDat(string DatPath, Color Transparency) { DatReaderError status; DAT loadedDat = DATReader.ReadDat(DatPath, out status); if (status.Error != DatError.Success) { Message.Show("Error loading " + DatPath + ": " + Environment.NewLine + status.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } List <DATFile> files = new List <DATFile>(); foreach (string path in GraphicsPaths) { files.AddRange(loadedDat.GetFilesByPattern(path)); } foreach (DATFile file in files) { string ext = Path.GetExtension(file.FileName).ToLower(); if (!(ext == ".frm" || ext == ".png")) { continue; } if (ext == ".frm") { List <Bitmap> bmaps = FalloutFRM.Load(file.GetData(), Transparency); Graphics[file.Path.ToLower()] = bmaps[0]; } else { System.ComponentModel.TypeConverter tc = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Bitmap)); Bitmap bitmap = (Bitmap)tc.ConvertFrom(file.GetData()); } } loadedDat.Close(); return(true); }