Exemple #1
0
 public Box(float width, float height, float depth, BoxFlags flags = BoxFlags.IsOrientable) :
     base(ShapeTypes3D.Box)
 {
     Width           = width;
     Height          = height;
     Depth           = depth;
     IsOrientable    = (flags & BoxFlags.IsOrientable) > 0;
     IsFixedVertical = (flags & BoxFlags.IsFixedVertical) > 0;
 }
Exemple #2
0
        /// <summary>Handles the MouseDown event of the pictureBox1 control to start a resize, placement or movement event.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            // Starting point of the selection:
            if (e.Button == MouseButtons.Left)
            {
                if (!_placed)
                {
                    _selection      = new Rectangle(new Point(e.X, e.Y), new Size());
                    _movement_point = new Point(e.X, e.Y);
                    _placed         = true;

                    _state = BoxState.Placing;
                }
                else
                {
                    if ((e.X > _selection.X - BoxWidth && e.X < _selection.X + _selection.Width + BoxWidth) &&
                        (e.Y > _selection.Y - BoxWidth && e.Y < _selection.Y + _selection.Height + BoxWidth))
                    {
                        var resizeMask = GetFlags(e.X, e.Y);
                        if (resizeMask == BoxFlags.All)
                        {
                            _state          = BoxState.Moving;
                            _box_flags      = resizeMask;
                            _movement_point = new Point(e.X - _selection.X, e.Y - _selection.Y);

                            this.Text = string.Format("MouseDown({0}, {1}, {2})", e.X, e.Y, _state);
                        }
                        else if (resizeMask != BoxFlags.None)
                        {
                            _state     = BoxState.Resizing;
                            _box_flags = resizeMask;

                            int x = e.X, y = e.Y;
                            if ((_box_flags | BoxFlags.Right) == BoxFlags.Right)
                            {
                                x = (_selection.X + _selection.Width) - e.X;
                            }
                            if ((_box_flags | BoxFlags.Bottom) == BoxFlags.Bottom)
                            {
                                y = (_selection.Y + _selection.Height) - e.Y;
                            }

                            _movement_point = new Point(x, y);
                            this.Text       = string.Format("MouseDown({0}, {1}, {2})", e.X, e.Y, _state);
                        }
                    }
                    else
                    {
                        _selection      = new Rectangle(new Point(e.X, e.Y), new Size());
                        _movement_point = new Point(e.X, e.Y);
                        _state          = BoxState.Placing;
                    }
                }
            }

            pcFullImage.Refresh();
        }
Exemple #3
0
 public ScummBox(Point topLeft, Point topRight, Point bottomRight, Point bottomLeft, uint zPlane, BoxFlags flags, uint scale, uint scaleSlot)
 {
     TopLeft     = topLeft;
     TopRight    = topRight;
     BottomRight = bottomRight;
     BottomLeft  = bottomLeft;
     ZPlane      = zPlane;
     Flags       = flags;
     Scale       = scale;
     ScaleSlot   = scaleSlot;
 }
Exemple #4
0
        /// <summary>Gets the box flags in relation to the selection rectangle.</summary>
        /// <param name="x">The mouse x position.</param>
        /// <param name="y">The mouse y position.</param>
        /// <returns></returns>
        private BoxFlags GetFlags(int x, int y)
        {
            BoxFlags resizeMask = BoxFlags.None;

            if ((x > _selection.X - BoxWidth && x < _selection.X + _selection.Width + BoxWidth) &&
                (y > _selection.Y - BoxWidth && y < _selection.Y + _selection.Height + BoxWidth))
            {
                // We're resizing, or moving!
            }
            else
            {
                return(BoxFlags.None);
            }

            if ((x > _selection.X - BoxWidth && x < _selection.X + _selection.Width + BoxWidth) &&
                (y > _selection.Y - BoxWidth && y < _selection.Y + BoxWidth))
            {
                resizeMask |= BoxFlags.Top;
            }

            if ((x > _selection.X - BoxWidth && x < _selection.X + BoxWidth) &&
                (y > _selection.Y - BoxWidth && y < _selection.Y + _selection.Height + BoxWidth))
            {
                resizeMask |= BoxFlags.Left;
            }

            if ((x > _selection.X - BoxWidth && x < _selection.X + _selection.Width + BoxWidth) &&
                (y > _selection.Y + _selection.Height - BoxWidth && y < _selection.Y + _selection.Height + BoxWidth))
            {
                resizeMask |= BoxFlags.Bottom;
            }

            if ((x > _selection.X + _selection.Width - BoxWidth && x < _selection.X + _selection.Width + BoxWidth) &&
                (y > _selection.Y - BoxWidth && y < _selection.Y + _selection.Height + BoxWidth))
            {
                resizeMask |= BoxFlags.Right;
            }

            if (resizeMask == BoxFlags.None)
            {
                resizeMask = BoxFlags.All;
            }

            return(resizeMask);
        }
Exemple #5
0
 // This constructor creates a cube (i.e. all dimensions the same size).
 public Box(float size, BoxFlags flags = BoxFlags.IsOrientable) : this(size, size, size, flags)
 {
 }
        public override List <ScummBox> Decode(Chunk chunk)
        {
            BinReader reader = chunk.GetReader();

            reader.Position = 8;
            uint count = reader.ReadU16LE();

            List <ScummBox> boxes = new List <ScummBox>();

            if (count * 20 + 10 < chunk.Size)
            {
                // CMI (SCUMM 8)
                reader.Position = 12;
                for (uint i = 0; i < count; i++)
                {
                    Point topLeft     = new Point(reader.ReadS32LE(), reader.ReadS32LE());
                    Point topRight    = new Point(reader.ReadS32LE(), reader.ReadS32LE());
                    Point bottomRight = new Point(reader.ReadS32LE(), reader.ReadS32LE());
                    Point bottomLeft  = new Point(reader.ReadS32LE(), reader.ReadS32LE());

                    uint zPlane    = reader.ReadU32LE();
                    uint intFlags  = reader.ReadU32LE();
                    uint scaleSlot = reader.ReadU32LE();
                    uint scale     = reader.ReadU32LE();

                    BoxFlags flags = (BoxFlags)intFlags;

                    uint unknown1 = reader.ReadU32LE(); // TODO: Figure out what these are

                    ScummBox box = new ScummBox(topLeft, topRight, bottomRight, bottomLeft, zPlane, flags, scale, scaleSlot);
                    boxes.Add(box);
                }
            }
            else
            {
                // Pre v8 SCUMM
                reader.Position = 10;
                for (uint i = 0; i < count; i++)
                {
                    Point topLeft     = new Point(reader.ReadS16LE(), reader.ReadS16LE());
                    Point topRight    = new Point(reader.ReadS16LE(), reader.ReadS16LE());
                    Point bottomRight = new Point(reader.ReadS16LE(), reader.ReadS16LE());
                    Point bottomLeft  = new Point(reader.ReadS16LE(), reader.ReadS16LE());

                    uint zPlane    = reader.ReadU8();
                    uint intFlags  = reader.ReadU8();
                    uint scale     = reader.ReadU16LE();
                    uint scaleSlot = 0;

                    BoxFlags flags = (BoxFlags)intFlags;

                    if ((scale & 0x8000) != 0)
                    {
                        scaleSlot = scale & 0x7fff;
                        scale     = 0;
                    }

                    ScummBox box = new ScummBox(topLeft, topRight, bottomRight, bottomLeft, zPlane, flags, scale, scaleSlot);
                    boxes.Add(box);
                }
            }

            return(boxes);
        }