Пример #1
0
        public void open(Stream data, string name)
        {
            WindowManager.flush();

            FileIO.fileFormat format = FileIO.identify(data);
            if (FileIO.isCompressed(format)) FileIO.decompress(ref data, ref format);

            byte[] buffer;
            OContainerForm containerForm;
            switch (format)
            {
                case FileIO.fileFormat.dq7DMP:
                    OSingleTextureWindow singleTextureWindow = new OSingleTextureWindow();

                    singleTextureWindow.Title = name;

                    launchWindow(singleTextureWindow);
                    DockContainer.dockMainWindow();
                    WindowManager.Refresh();

                    singleTextureWindow.initialize(DMP.load(data).texture);
                    break;
                case FileIO.fileFormat.dq7FPT0:
                    containerForm = new OContainerForm();
                    containerForm.launch(FPT0.load(data));
                    containerForm.Show(this);
                    break;
                case FileIO.fileFormat.dq7Model:
                    containerForm = new OContainerForm();
                    containerForm.launch(DQVIIPack.load(data));
                    containerForm.Show(this);
                    break;
                case FileIO.fileFormat.flZMdl: launchModel(ZMDL.load(data), name); break;
                case FileIO.fileFormat.flZTex:
                    OTextureWindow textureWindow = new OTextureWindow();

                    textureWindow.Title = name;

                    launchWindow(textureWindow);
                    DockContainer.dockMainWindow();
                    WindowManager.Refresh();

                    textureWindow.initialize(ZTEX.load(data));
                    break;
                case FileIO.fileFormat.fmNLK2:
                    buffer = new byte[data.Length - 0x80];
                    data.Seek(0x80, SeekOrigin.Begin);
                    data.Read(buffer, 0, buffer.Length);
                    data.Close();
                    launchModel(CGFX.load(new MemoryStream(buffer)), name);
                    break;
                case FileIO.fileFormat.nlpSMes: launchModel(NLP.loadMesh(data), name); break;
                case FileIO.fileFormat.nw4cCGfx: launchModel(CGFX.load(data), name); break;
                case FileIO.fileFormat.nw4cH3D:
                    buffer = new byte[data.Length];
                    data.Read(buffer, 0, buffer.Length);
                    data.Close();
                    launchModel(BCH.load(new MemoryStream(buffer)), name);
                    break;
                case FileIO.fileFormat.pkmnContainer:
                    GenericContainer.OContainer container = PkmnContainer.load(data);
                    switch (container.fileIdentifier)
                    {
                        case "PC": //Pokémon model
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "MM": //Pokémon Overworld model
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "GR": //Pokémon Map model
                            launchModel(BCH.load(new MemoryStream(container.content[1].data)), name);
                            break;
                        case "PT": //Pokémon texture
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "PK": //Pokemon Visibility/Skeletal animations
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "PB": //Pokémon material animations
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "AD": //???
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                    }
                    //TODO: Add windows for extra data
                    break;
                default:
                    MessageBox.Show("Unsupported file format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    data.Close();
                    break;
            }
        }
Пример #2
0
        public void open(string fileName)
        {
            string name = Path.GetFileNameWithoutExtension(fileName);
            string extension = Path.GetExtension(fileName).ToLower();
            switch (extension) //Handle case-specific files than can't be identified by signature here
            {
                case ".mbn":
                    WindowManager.flush();
                    launchModel(MBN.load(fileName), name);
                    return;
                case ".xml":
                    switch (Path.GetExtension(Path.GetFileNameWithoutExtension(fileName)).ToLower())
                    {
                        case ".mdl":
                            WindowManager.flush();
                            launchModel(NLP.load(fileName), name);
                            return;
                        case ".texi":
                            WindowManager.flush();
                            OSingleTextureWindow singleTextureWindow = new OSingleTextureWindow();

                            singleTextureWindow.Title = name;

                            launchWindow(singleTextureWindow);
                            DockContainer.dockMainWindow();
                            WindowManager.Refresh();

                            singleTextureWindow.initialize(NLP.loadTexture(fileName).texture);
                            return;
                    }
                    break;
            }
            open(new FileStream(fileName, FileMode.Open), name);
        }