示例#1
0
        public void LoadFilm(ref LfdFile lfd, object tag)
        {
            Debug.WriteLine("View loading...");
            _film = (Film)lfd.Resources.GetResourceByTag(tag);
            lstBlocks.Items.Clear();
            for (int c = 0; c < 256; c++)
            {
                _palette.Entries[c] = _empirePalette.Entries[c];
            }
            _drawOrder = new short[_film.NumberOfBlocks];
            _images    = new Image[_film.NumberOfBlocks];
            #region populate lstBlocks
            foreach (Film.Block b in _film.Blocks)
            {
                string str = b.ToString() + "*";
                Debug.WriteLine(str);
                for (int i = 0; i < _lfd.Resources.Count; i++)
                {
                    if (str == (_lfd.Resources[i].ToString() + "*"))
                    {
                        str = str.Replace("*", "");                             // leaves anything not in the LFD marked, typ VOIC
                        break;
                    }
                }
                Resource res = null;
                for (int i = 0; i < _tiesfx.Resources.Count; i++)
                {
                    if (str == (_tiesfx.Resources[i].ToString() + "*"))
                    {
                        str = str.Replace("*", "");                         // start finding VOIC
                        res = _tiesfx.Resources[i];
                        break;
                    }
                }
                for (int i = 0; i < _tiesfx2.Resources.Count; i++)
                {
                    if (str == (_tiesfx2.Resources[i].ToString() + "*"))
                    {
                        str = str.Replace("*", "");
                        res = _tiesfx2.Resources[i];
                        break;
                    }
                }
                for (int i = 0; i < _tiespch.Resources.Count; i++)
                {
                    if (str == (_tiespch.Resources[i].ToString() + "*"))
                    {
                        str = str.Replace("*", "");
                        res = _tiespch.Resources[i];
                        break;
                    }
                }
                for (int i = 0; i < _tiespch2.Resources.Count; i++)
                {
                    if (str == (_tiespch2.Resources[i].ToString() + "*"))
                    {
                        str = str.Replace("*", "");
                        res = _tiespch2.Resources[i];
                        break;
                    }
                }
                if (b.Type == Film.Block.BlockType.View)
                {
                    str = str.Replace("*", "");
                }
                lstBlocks.Items.Add(str);

                if (res != null)
                {
                    if (!Directory.Exists(MainForm._tempDir))
                    {
                        Directory.CreateDirectory(MainForm._tempDir);
                    }
                    if (!File.Exists(MainForm._tempDir + res.ToString() + ".wav"))
                    {
                        using (FileStream fs = new FileStream(MainForm._tempDir + res.ToString() + ".wav", FileMode.OpenOrCreate))
                        {
                            using (BinaryWriter bw = new BinaryWriter(fs))
                            {
                                Blas blas = (Blas)res;
                                if (blas.SoundBlocks[0].NumberOfRepeats > -1)
                                {
                                    bw.Write(blas.GetWavBytes(true));
                                }
                                else
                                {
                                    bw.Write(blas.GetWavBytes(false));
                                }
                                fs.SetLength(fs.Position);
                            }
                        }
                    }
                }
            }
            #endregion
            buildEvents();
            _loading        = true;             // this prevents double-paint
            hsbTime.Value   = 0;
            hsbTime.Maximum = _film.NumberOfFrames;
            _loading        = false;
            performEvents();
            PaintFilm();
        }