Beispiel #1
0
        public void Process(ResourceID id)
        {
            reader = Burntime.Platform.IO.FileSystem.GetFile(id.File).GetSubFile(0, -1);

            charInfo = new Dictionary <char, CharInfo>();

            chars = new CharInfo[98];
            for (int i = 0; i < 98; i++)
            {
                chars[i].pos   = reader.ReadUShort();
                chars[i].width = reader.ReadUShort();

                charInfo.Add((char)(' ' + i), chars[i]);
            }

            for (int i = 0; i < 98; i++)
            {
                reader.Seek(chars[i].pos, Burntime.Platform.IO.SeekPosition.Begin);

                int unknown1 = reader.ReadUShort();
                int unknown2 = reader.ReadUShort();

                chars[i].imgWidth  = 4 * (unknown1 + 1);
                chars[i].imgHeight = unknown2;
            }
        }
Beispiel #2
0
        public void Import(Stream MatFile, int TileSize, TileSet TileSet)
        {
            Burntime.Platform.IO.File file = new Burntime.Platform.IO.File(MatFile);
            Burntime.Data.BurnGfx.Map map  = new Burntime.Data.BurnGfx.Map(file);

            Size          = new Size(map.width, map.height);
            this.TileSize = TileSize;
            Title         = "unnamed";
            Saved         = false;
            tiles         = new Tile[Size.Width, Size.Height];

            for (int y = 0; y < Size.Height; y++)
            {
                for (int x = 0; x < Size.Width; x++)
                {
                    Tile tile = TileSet.Find((byte)(map.data[x + y * Size.Width] & 0xff), (byte)(map.data[x + y * Size.Width] >> 8));
                    tiles[x, y] = tile;
                }
            }

            foreach (Burntime.Data.BurnGfx.Door d in map.Doors)
            {
                Entrance e = new Entrance();
                e.Rect = new Rectangle(d.Area.Left, d.Area.Top, d.Area.Width, d.Area.Height);
                entrances.Add(e);
            }

            file.Close();

            AttachedView.UpdateMap();
            AttachedView.UpdateTitle();
        }
Beispiel #3
0
        public bool Open(String name)
        {
            Burntime.Platform.IO.File file = FileSystem.GetFile(name);
            if (file == null)
            {
                return(false);
            }
            bool result = Open(file.Stream);

            file.Close();
            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes the soundbuffers
        /// </summary>
        /// <param name="FileName">The filename from which to pull the data to initialize the
        /// soundbuffers</param>
        public MusicPlayer(Burntime.Platform.IO.File file)
        {
            this.Filename = file.Name;
            Burntime.Platform.Log.Debug("prepare to play " + Filename);
            oggStream  = new OggVorbisFileStream(file.Stream);
            FullLength = (int)oggStream.Length;

            format                       = new WaveFormat();
            format.FormatTag             = WaveFormatTag.Pcm;
            format.SamplesPerSecond      = oggStream.Info.Rate;
            format.BitsPerSample         = 16;
            format.Channels              = (short)oggStream.Info.Channels;
            format.BlockAlignment        = (short)(format.Channels * (format.BitsPerSample / 8));
            format.AverageBytesPerSecond = format.SamplesPerSecond * format.BlockAlignment;

            SoundBufferDescription description = new SoundBufferDescription();

            description.Format      = format;
            description.SizeInBytes = StreamBufferSize;

            //if ( GameForm.Instance.GameSettings.ForceSoftwareMusicMixing )
            description.Flags = BufferFlags.ControlVolume | BufferFlags.GlobalFocus |
                                BufferFlags.ControlPositionNotify | BufferFlags.GetCurrentPosition2 |
                                BufferFlags.Software;

            //Create the buffer.
            buffer = new SecondarySoundBuffer(DirectSoundWrapper.Device, description);
            SecondaryBufferWritePosition = 0;

            this.UpdateVolume();

            // Create a notification Event object, to fire at each notify position
            NotificationEvent = new AutoResetEvent(false);

            // Preset as much of the EndNotificationPosition array as possible to avoid doing it
            // in real-time.
            EndNotificationPosition[0].Event = NotificationEvent;
            PredictedEndIndex = (int)(oggStream.Length % StreamBufferSize); //[bytes]

            // ready to go:
            MoreWaveDataAvailable = true;
            State = BufferPlayState.Idle;

            Play();
        }
Beispiel #5
0
        public bool Export(String File)
        {
            Burntime.Platform.IO.File file = new Burntime.Platform.IO.File(new FileStream(File, FileMode.Open, FileAccess.ReadWrite));
            Burntime.Data.BurnGfx.Map map  = new Burntime.Data.BurnGfx.Map(file);

            map.width  = Size.Width;
            map.height = Size.Height;
            // check size
            map.data = new ushort[Size.Width * Size.Height];

            for (int y = 0; y < Size.Height; y++)
            {
                for (int x = 0; x < Size.Width; x++)
                {
                    map.data[x + y * Size.Width] = (ushort)(tiles[x, y].SubSet + (((ushort)tiles[x, y].ID) << 8));
                }
            }

            // check door count
            if (map.Doors.Count != entrances.Count)
            {
                MessageBox.Show("Entrance count must be the same as the original.", "Export", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            for (int i = 0; i < map.Doors.Count; i++)
            {
                map.Doors[i].Area = new Burntime.Platform.Rect(entrances[i].Rect.Left, entrances[i].Rect.Top, entrances[i].Rect.Width, entrances[i].Rect.Height);
            }

            file.Seek(0, Burntime.Platform.IO.SeekPosition.Begin);
            map.SaveToRaw(file);

            file.Flush();
            file.Close();

            return(true);
        }