コード例 #1
0
ファイル: FalloutFrm.cs プロジェクト: ghost2238/junktown
        public static FalloutFRM LoadFRM(byte[] buffer, Color transparency)
        {
            FalloutFRM frm = new FalloutFRM();

            frm.Frames     = Load(buffer, transparency);
            frm.PixelShift = new Point(FalloutFRMLoader.GetPixelShiftX(buffer),
                                       FalloutFRMLoader.GetPixelShiftY(buffer));
            frm.FramesPerDir = (short)((buffer[0x08] << 8) + buffer[0x08 + 1]);

            return(frm);
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: MisterDr/fonline-mapgen
        public bool LoadZip( string ZipPath, List<string> crFiles, Color Transparency )
        {
            if (!File.Exists(ZipPath))
            {
                MessageBox.Show("Unable to load " + ZipPath + ", doesn't exist.", "Mapper", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            var zip = ZipStorer.Open(ZipPath, FileAccess.Read);
            if(zip == null)
            {
                MessageBox.Show("Unable to load " + ZipPath + ".", "Mapper", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            var patternToCheck = new List<string>();
            foreach (var cr in crFiles)
                patternToCheck.Add(cr);
            foreach (var path in this.EditorData.GraphicsPaths)
                patternToCheck.Add(path);

            var filesToLoad = new List<ZipStorer.ZipFileEntry>();

            var entries = zip.ReadCentralDir();
            foreach (var entry in entries)
            {
                foreach(var path in patternToCheck)
                {
                    if (!entry.FilenameInZip.Replace('/', '\\').Contains(path))
                        continue;
                    if (entry.CompressedSize == 0) continue;

                    string filename = entry.FilenameInZip.ToLower().Replace('/', '\\');
                    string ext = Path.GetExtension( filename ).ToLower();

                    if( !(ext == ".frm" || ext == ".png") )
                        continue;

                    filesToLoad.Add(entry);
                }
            }

            this.BeginInvoke((MethodInvoker)delegate
            {
                frmLoading.SetNextFile(Path.GetFileName(ZipPath));
                frmLoading.SetResourceNum(filesToLoad.Count);
            });

            foreach(var entry in filesToLoad)
            {
                    string filename = entry.FilenameInZip.ToLower().Replace('/', '\\');
                    string ext = Path.GetExtension(filename).ToLower();

                    this.BeginInvoke((MethodInvoker)delegate
                    {
                        frmLoading.SetNextResource(filename);
                    });

                    byte[] bytes;
                    using (MemoryStream stream = new MemoryStream())
                    {
                        zip.ExtractFile(entry, stream);
                        bytes = stream.ToArray();
                    }
                    if (ext == ".frm")
                    {
                        var frm = FalloutFRMLoader.LoadFRM(bytes, Transparency);
                        Frms[filename] = frm;
                    }
                    else
                    {
                        System.ComponentModel.TypeConverter tc = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Bitmap));
                        Bitmap bitmap = (Bitmap)tc.ConvertFrom(bytes);
                        Frms[filename] = new FalloutFRM();
                        Frms[filename].Frames = new List<Bitmap>();
                        Frms[filename].Frames.Add(bitmap);
                        Frms[filename].FileName = entry.FilenameInZip;
                    }
            }
            return true;
        }
コード例 #3
0
ファイル: frmMain.cs プロジェクト: MisterDr/fonline-mapgen
        public bool LoadDir(string DirPath, List<string> crFiles, Color Transparency)
        {
            List<string> filenames = new List<string>();
            foreach (var path in this.EditorData.GraphicsPaths)
            {
                var fullPath = DirPath + Path.DirectorySeparatorChar + path;
                if(Directory.Exists(fullPath))
                    filenames.AddRange(Directory.GetFiles(fullPath));
            }
            foreach(var crFile in crFiles)

            foreach (var filename in filenames)
            {
                string ext = Path.GetExtension(filename).ToLower();
                if (!(ext == ".frm" || ext == ".png"))
                    continue;
                byte[] bytes = File.ReadAllBytes(filename);
                if (ext == ".frm")
                {
                    var frm = FalloutFRMLoader.LoadFRM(bytes, Transparency);
                    Frms[filename] = frm;
                }
                else
                {
                    System.ComponentModel.TypeConverter tc = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Bitmap));
                    Bitmap bitmap = (Bitmap)tc.ConvertFrom(bytes);
                    Frms[filename] = new FalloutFRM();
                    Frms[filename].Frames = new List<Bitmap>();
                    Frms[filename].Frames.Add(bitmap);
                    Frms[filename].FileName = filename.Remove(filename.IndexOf(DirPath), DirPath.Length);
                }
            }
            return true;
        }
コード例 #4
0
ファイル: FalloutFrm.cs プロジェクト: MisterDr/FOCommon
        public static FalloutFRM LoadFRM(byte[] buffer, Color transparency)
        {
            FalloutFRM frm = new FalloutFRM();
            frm.Frames = Load(buffer, transparency);
            frm.PixelShift = new Point(FalloutFRMLoader.GetPixelShiftX(buffer),
                                       FalloutFRMLoader.GetPixelShiftY(buffer));
            frm.FramesPerDir = (short)((buffer[0x08] << 8) + buffer[0x08 + 1]);

            return frm;
        }