예제 #1
0
        private void InitSubfileLists()
        {
            xxSubfilesList.Items.Clear();
            xaSubfilesList.Items.Clear();
            imageSubfilesList.Items.Clear();
            soundSubfilesList.Items.Clear();
            otherSubfilesList.Items.Clear();

            adjustSubfileListsEnabled(false);
            List <ListViewItem> xxFiles    = new List <ListViewItem>(Editor.Parser.Subfiles.Count);
            List <ListViewItem> xaFiles    = new List <ListViewItem>(Editor.Parser.Subfiles.Count);
            List <ListViewItem> imageFiles = new List <ListViewItem>(Editor.Parser.Subfiles.Count);
            List <ListViewItem> soundFiles = new List <ListViewItem>(Editor.Parser.Subfiles.Count);
            List <ListViewItem> otherFiles = new List <ListViewItem>(Editor.Parser.Subfiles.Count);

            for (int i = 0; i < Editor.Parser.Subfiles.Count; i++)
            {
                IWriteFile   subfile = Editor.Parser.Subfiles[i];
                ListViewItem item    = new ListViewItem(subfile.Name);
                item.Tag = subfile;

                string ext = Path.GetExtension(subfile.Name).ToLower();
                if (ext.Equals(".xx"))
                {
                    xxFiles.Add(item);
                }
                else if (ext.Equals(".xa"))
                {
                    xaFiles.Add(item);
                }
                else if (ext.Equals(".ema") || Utility.ImageSupported(ext))
                {
                    imageFiles.Add(item);
                }
                else if (ext.Equals(".ogg") || ext.Equals(".wav"))
                {
                    soundFiles.Add(item);
                }
                else
                {
                    otherFiles.Add(item);
                }
            }
            xxSubfilesList.Items.AddRange(xxFiles.ToArray());
            xaSubfilesList.Items.AddRange(xaFiles.ToArray());
            imageSubfilesList.Items.AddRange(imageFiles.ToArray());
            soundSubfilesList.Items.AddRange(soundFiles.ToArray());
            otherSubfilesList.Items.AddRange(otherFiles.ToArray());
            adjustSubfileLists();
            adjustSubfileListsEnabled(true);

            if (soundSubfilesList.Items.Count > 0 && soundLib == null)
            {
                soundLib = new Utility.SoundLib();
            }
        }
예제 #2
0
        private static ppFormat TryFile(ppSubfile subfile, ppFormat[] formats)
        {
            Func <ppSubfile, bool> tryFunc = null;

            string ext = Path.GetExtension(subfile.Name).ToLower();

            if (ext == ".xx")
            {
                tryFunc = new Func <ppSubfile, bool>(TryFileXX);
            }
            else if (ext == ".xa")
            {
                tryFunc = new Func <ppSubfile, bool>(TryFileXA);
            }
            else if (ext == ".bmp")
            {
                tryFunc = new Func <ppSubfile, bool>(TryFileBMP);
            }
            else if (ext == ".tga")
            {
                tryFunc = new Func <ppSubfile, bool>(TryFileTGA);
            }
            else if (ext == ".ema")
            {
                tryFunc = new Func <ppSubfile, bool>(TryFileEMA);
            }
            else if (Utility.ImageSupported(ext))
            {
                tryFunc = new Func <ppSubfile, bool>(TryFileImage);
            }
            else if (ext == ".lst")
            {
                tryFunc = new Func <ppSubfile, bool>(TryFileLst);
            }
            else if (ext == ".wav" || ext == ".ogg")
            {
                tryFunc = new Func <ppSubfile, bool>(TryFileSound);
            }

            if (tryFunc != null)
            {
                for (int i = 0; i < formats.Length; i++)
                {
                    subfile.ppFormat = formats[i];
                    if (tryFunc(subfile))
                    {
                        return(subfile.ppFormat);
                    }
                }
            }

            return(null);
        }
예제 #3
0
파일: ppFormat.cs 프로젝트: ezdiy/GDImport
        private static ppFormat TryFile(Stream stream, ppSubfile subfile, ppFormat[] formats)
        {
            Func <Stream, ppSubfile, bool> tryFunc = null;

            string ext = Path.GetExtension(subfile.Name).ToLower();

            if (ext == ".xx")
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileXX);
            }
            else if (ext == ".xa")
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileXA);
            }
            else if (ext == ".svi")
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileSVI);
            }
            else if (ext == ".sviex")
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileSVIEX);
            }
            else if (ext == ".bmp")
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileBMP);
            }
            else if (ext == ".tga")
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileTGA);
            }
            else if (ext == ".ema")
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileEMA);
            }
            else if (Utility.ImageSupported(ext))
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileImage);
            }
            else if (ext == ".lst")
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileLst);
            }
            else if (ext == ".wav" || ext == ".ogg")
            {
                tryFunc = new Func <Stream, ppSubfile, bool>(TryFileSound);
            }

            if (tryFunc != null)
            {
                for (int i = 0; i < formats.Length; i++)
                {
                    subfile.ppFormat = formats[i];
                    stream.Position  = subfile.offset;
                    if (tryFunc(subfile.ppFormat.ReadStream(new PartialStream(stream, subfile.size)), subfile))
                    {
                        return(subfile.ppFormat);
                    }
                }
            }

            return(null);
        }