コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: rotators/fonline-mapgen
        public bool LoadDat(string DatPath, List <string> crFiles, Color Transparency)
        {
            DatReaderError status;
            DAT            loadedDat = DATReader.ReadDat(DatPath, out status);

            if (status.Error != DatError.Success)
            {
                MessageBox.Show("Error loading " + DatPath + ": " + Environment.NewLine + status.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            List <DATFile> files = new List <DATFile>();

            foreach (string path in this.EditorData.GraphicsPaths)
            {
                files.AddRange(loadedDat.GetFilesByPattern(path));

                // Critters to load
                foreach (var crType in critterData.crTypeGraphic.Values)
                {
                    var file = loadedDat.GetFileByName("art\\critters\\" + crType.ToUpper() + "AA.FRM"); // Idle anim
                    if (file == null)
                    {
                        file = loadedDat.GetFileByName("art\\critters\\" + crType.ToLower() + "aa.frm");
                    }
                    if (file == null)
                    {
                        continue;
                    }
                    files.Add(file);
                }
            }

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

            foreach (DATFile file in files)
            {
                this.BeginInvoke((MethodInvoker) delegate { frmLoading.SetNextResource(file.FileName); });

                string ext = Path.GetExtension(file.FileName).ToLower();
                if (!(ext == ".frm" || ext == ".png"))
                {
                    continue;
                }

                byte[] data = file.GetData();
                if (data == null)
                {
                    WriteLog("Error opening " + file.FileName + ": " + file.ErrorMsg);
                    continue;
                }

                if (ext == ".frm")
                {
                    var frm = FalloutFRMLoader.LoadFRM(data, Transparency);
                    frm.FileName       = file.Path.ToLower();
                    Frms[frm.FileName] = frm;
                }
                else
                {
                    System.ComponentModel.TypeConverter tc = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Bitmap));
                    Bitmap bitmap = (Bitmap)tc.ConvertFrom(data);
                }
            }
            loadedDat.Close();
            return(true);
        }