A frame of a spriteset direction.
コード例 #1
0
ファイル: FramePanel.cs プロジェクト: Radnen/spherestudio
 public FramePanel(Frame frame, Spriteset sprite, ISettings settings)
 {
     _sprite = sprite;
     _frame = frame;
     DoubleBuffered = true;
     BackgroundImage = Properties.Resources.EditAreaBG2;
     Dock = DockStyle.Left;
     _showDelay = settings.GetBoolean("spriteset-showdelay", false);
     Margin = new Padding(3);
 }
コード例 #2
0
 public void AddImage(Frame frame)
 {
     FramePanel panel = new FramePanel(frame, _sprite, _parent_editor.Settings);
     panel.Zoom = _zoom;
     ImagesPanel.Controls.Add(panel);
     panel.BringToFront();
     panel.MouseClick += new MouseEventHandler(Panel_MouseClick);
     panel.MouseEnter += new System.EventHandler(Panel_MouseEnter);
     Invalidate(true);
     if (Modified != null) Modified(this, new EventArgs());
 }
コード例 #3
0
 private void AddFrameButton_Click(object sender, System.EventArgs e)
 {
     Frame f = new Frame();
     AddImage(f);
     _direction.Frames.Add(f);
 }
コード例 #4
0
ファイル: Spriteset.cs プロジェクト: Radnen/spherestudio
        /// <summary>
        /// Attempts to load the spriteset from the given filename.
        /// </summary>
        /// <param name="filename">The filename of the Spriteset to load.</param>
        /// <returns>True if successful.</returns>
        public bool Load(String filename)
        {
            if (!File.Exists(filename)) return false;
            using (BinaryReader stream = new BinaryReader(File.OpenRead(filename)))
            {

                // purge anything already inside this object:
                Purge();

                // start reading the header //
                string sig = new string(stream.ReadChars(4));
                if (sig != ".rss") return false;

                _version = stream.ReadInt16();
                short numImages = stream.ReadInt16();
                _frameWidth = stream.ReadInt16();
                _frameHeight = stream.ReadInt16();
                short numDirs = stream.ReadInt16();

                // read sprite base //
                _spriteBase.X1 = stream.ReadInt16();
                _spriteBase.Y1 = stream.ReadInt16();
                _spriteBase.X2 = stream.ReadInt16();
                _spriteBase.Y2 = stream.ReadInt16();

                // reserved //
                stream.ReadBytes(106);
                switch (_version)
                {
                    case 3:
                        BitmapLoader loader = new BitmapLoader(_frameWidth, _frameHeight);
                        int amt = _frameWidth * _frameHeight * 4;
                        while (numImages-- > 0) _images.Add(loader.LoadFromStream(stream, amt));
                        loader.Close();

                        while (numDirs-- > 0)
                        {
                            short numFrames = stream.ReadInt16();
                            stream.ReadBytes(6);
                            short length = stream.ReadInt16();
                            string name = new String(stream.ReadChars(length)).Substring(0, length - 1);
                            Direction dir = new Direction(name);
                            while (numFrames-- > 0)
                            {
                                Frame f = new Frame {Index = stream.ReadInt16(), Delay = stream.ReadInt16()};
                                dir.Frames.Add(f);
                                stream.ReadBytes(4);
                            }
                            _directions.Add(dir);
                        }
                        break;
                }
            }
            return true;
        }