Beispiel #1
0
        private IEnumerable <Category> GetDzbData(VirtualFilesystemDirectory dir)
        {
            DZB loader = new DZB();

            VirtualFilesystemFile dzbFile;

            // We'll search for room.dzb and load that if we can find it
            foreach (VirtualFilesystemNode node in dir.Children)
            {
                if ((node.Name == "room") && (node.Type == NodeType.File))
                {
                    dzbFile = node as VirtualFilesystemFile;

                    EndianBinaryReader reader = new EndianBinaryReader(dzbFile.File.GetData(), Endian.Big);

                    return(loader.Load(reader));
                }
            }

            // If we get here, this isn't a room arc, so let's just load the first DZB file
            if (dir.Children[0].Type == NodeType.File)
            {
                dzbFile = dir.Children[0] as VirtualFilesystemFile;

                EndianBinaryReader reader = new EndianBinaryReader(dzbFile.File.GetData(), Endian.Big);

                return(loader.Load(reader));
            }

            // If this happens, my tool has serious issues
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Reads the file specified by fileName into the program.
        /// </summary>
        /// <param name="fileName">File to read into the program</param>
        public void Open(string fileName)
        {
            if (isDataLoaded)
            {
                Close();
            }

            IModelSource source = null;

            try
            {
                string[] fileNameExtension = fileName.Split('.');

                if (fileNameExtension.Count() >= 2)
                {
                    switch (fileNameExtension[fileNameExtension.Count() - 1])
                    {
                        case "arc":
                        case "rarc":
                            source = new ARC();
                            break;
                        case "dae":
                            source = new DAE();
                            break;
                        case "dzb":
                            source = new DZB();
                            break;
                        case "obj":
                            source = new OBJ();
                            break;
                        default:
                            Console.WriteLine("Unknown file type " + 
                                fileNameExtension[fileNameExtension.Count() - 1] + ". Aborting...");
                            return;
                    }

                    Categories = (ObservableCollection<Category>)source.Load(fileName);

                    // Probably a hotfix. If the user tried to open an archive, but the archive didn't have any DZBs in it,
                    // the archive loader will return null.
                    if (Categories == null)
                    {
                        MessageBox.Show("The archive you opened did not contain any DZB collision files.", "No DZB files found");

                        return;
                    }

                    AddRenderableObjs();

                    FocusCameraAll();

                    CurrentFile = fileName;

                    m_recentFileList.InsertFile(CurrentFile);

                    isDataLoaded = true;
                }
            }

            catch
            {
                if (m_recentFileList.RecentFiles.Contains(fileName))
                {
                    MessageBox.Show("The file '" + fileName + "' no longer exists. It will be removed from the recently used files.", "File Not Found");

                    m_recentFileList.RemoveFile(fileName);
                }
            }
        }