Ejemplo n.º 1
0
 /// <summary>Creates a new instance of LevelEditorMode.</summary>
 /// <param name="graphics">The graphics device manager to use.</param>
 /// <param name="content">The content manager to use.</param>
 /// <param name="batch">The sprite batch to use.</param>
 /// <param name="bEffect">The basic effect to use.</param>
 public LevelEditorMode(GraphicsDeviceManager graphics, ContentManager content, SpriteBatch batch, BasicEffect bEffect)
     : base(graphics, content, batch, bEffect)
 {
     world = new World(true);
     world.Grid = new GridManager(1, 1, world);
     hoveredNode = null;
     selectedNode = null;
     hoveredSeg = null;
     selectedSeg = null;
     hoveredSegEnd = null;
     hoveredSegEndOwner = null;
     selectedSegEnd = null;
     hoveredGeo = null;
     hoveredGeoVertex = -1;
     hoveredGeoIsLine = false;
     selectedGeo = null;
     selectedGeoVertex = -1;
     selectedGeoIsLine = false;
     desktop = new Desktop();
     lastClickedPoint = new VectorF();
     dragOffset = new VectorF();
     isDragging = false;
 }
Ejemplo n.º 2
0
        /// <summary>Performs the specified mouse event on this control.</summary>
        /// <param name="evnt">The event to perform.</param>
        /// <param name="cursorPos">The position of the cursor at the time of the event.</param>
        /// <param name="input">The current input state.</param>
        /// <returns>Whether or not the event was performed.</returns>
        public virtual bool PerformMouseEvent(Desktop.Event evnt, Point cursorPos, Input.InpState input)
        {
            switch (evnt)
            {
                case Desktop.Event.MouseLeftUp:
                    OnMouseLeftUp();
                    break;
                case Desktop.Event.MouseLeftDown:
                    Focus();
                    OnMouseLeftDown();
                    break;
                case Desktop.Event.MouseLeftDoubleClick:
                    OnMouseLeftDoubleClick();
                    break;
                case Desktop.Event.MouseRightUp:
                    OnMouseRightUp();
                    break;
                case Desktop.Event.MouseRightDown:
                    Focus();
                    OnMouseRightDown();
                    break;
                case Desktop.Event.MouseRightDoubleClick:
                    OnMouseRightDoubleClick();
                    break;
                default:
                    throw new Exception("Unrecognized event: " + evnt.ToString());
            }

            return true;
        }
Ejemplo n.º 3
0
        /// <summary>Performs the specified mouse event on this control.</summary>
        /// <param name="evnt">The event to perform.</param>
        /// <param name="cursorPos">The position of the cursor at the time of the event.</param>
        /// <param name="input">The current input state.</param>
        /// <returns>Whether or not the event was performed.</returns>
        public override bool PerformMouseEvent(Desktop.Event evnt, Point cursorPos, Input.InpState input)
        {
            base.PerformMouseEvent(evnt, cursorPos, input);

            if (evnt == Desktop.Event.MouseLeftDown)
            {
                float cPos = (float)(cursorPos.Y - Top);
                float mPos = 0f;

                for (int i = 0; i < items.Count; i++)
                {
                    if (cPos >= mPos && cPos < mPos + itemSizes[i].Y)
                    {
                        OnOptionSelected(i);
                        break;
                    }
                    mPos += itemSizes[i].Y;
                }
            }

            return true;
        }
Ejemplo n.º 4
0
        /// <summary>Performs the specified mouse event on this control.</summary>
        /// <param name="evnt">The event to perform.</param>
        /// <param name="cursorPos">The position of the cursor at the time of the event.</param>
        /// <param name="input">The current input state.</param>
        /// <returns>Whether or not the event was performed.</returns>
        public override bool PerformMouseEvent(Desktop.Event evnt, Point cursorPos, Input.InpState input)
        {
            Point pos = cursorPos - Location;

            foreach (Control c in Controls)
            {
                if (c.inBounds(pos))
                    return c.PerformMouseEvent(evnt, pos, input);
            }

            return base.PerformMouseEvent(evnt, cursorPos, input);
        }
Ejemplo n.º 5
0
        /// <summary>Performs the specified mouse event on this control.</summary>
        /// <param name="evnt">The event to perform.</param>
        /// <param name="cursorPos">The position of the cursor at the time of the event.</param>
        /// <param name="input">The current input state.</param>
        /// <returns>Whether or not the event was performed.</returns>
        public override bool PerformMouseEvent(Desktop.Event evnt, Point cursorPos, InpState input)
        {
            if (evnt == Desktop.Event.MouseLeftDown)
            {
                cursBlinkOffset = DateTime.Now.Millisecond;

                if (input.Key.IsKeyDown(Keys.LeftShift) || input.Key.IsKeyDown(Keys.RightShift))
                {
                    if (selectedFromIndex == -1)
                        selectedFromIndex = editIndex;
                }
                else
                {
                    selectedFromIndex = -1;
                }

                editIndex = getCharPos((float)(cursorPos.X - Left), (float)(cursorPos.Y - Top));
                updateEditPosition();
                refreshDesiredEditPositionX();

                refreshHighlights();
            }

            return base.PerformMouseEvent(evnt, cursorPos, input);
        }
Ejemplo n.º 6
0
        /// <summary>Performs the specified mouse event on this control.</summary>
        /// <param name="evnt">The event to perform.</param>
        /// <param name="cursorPos">The position of the cursor at the time of the event.</param>
        /// <param name="input">The current input state.</param>
        /// <returns>Whether or not the event was performed.</returns>
        public override bool PerformMouseEvent(Desktop.Event evnt, Point cursorPos, InpState input)
        {
            if (evnt == Desktop.Event.MouseLeftDown)
            {
                editIndex = getCharPos((float)(cursorPos.X - Left));
                updateEditPosition();
            }

            return base.PerformMouseEvent(evnt, cursorPos, input);
        }
Ejemplo n.º 7
0
        /// <summary>Creates a new instance of PlayMode.</summary>
        /// <param name="graphics">The graphics device manager to use.</param>
        /// <param name="content">The content manager to use.</param>
        /// <param name="batch">The sprite batch to use.</param>
        /// <param name="bEffect">The basic effect to use.</param>
        public PlayMode(GraphicsDeviceManager graphics, ContentManager content, SpriteBatch batch, BasicEffect bEffect)
            : base(graphics, content, batch, bEffect)
        {
            hoveredNode = null;
            hoveredSeg = null;
            hoveredHotspot = null;
            selectedNode = null;
            desktop = new Desktop();

            lblCursorPos = new Label();
            lblCursorPos.Left = 0;
            lblCursorPos.Top = 0;
            lblCursorPos.Width = 0;
            lblCursorPos.Height = 0;
            lblCursorPos.ForeColor = Color.White;
            desktop.Controls.Add(lblCursorPos);

            /* TEMPORARY */
            loadWorld(@"..\..\..\testscripting.txt");//testLevel.txt");
            //map = WorldLoader.loadWorld(@"..\..\..\testLevel.txt", Graphics);
            /* TEMPORARY */
        }
Ejemplo n.º 8
0
 /// <summary>Creates a new instance of GUI.</summary>
 /// <param name="toClone">The Desktop to clone.</param>
 public Desktop(Desktop toClone)
     : base(toClone)
 {
     TopParent = this;
     Focused = null;
     Hovered = null;
     TBack = toClone.TBack;
     IsMouseLeftDown = false;
     IsMouseRightDown = false;
     CursorPos = new Point();
     CurMenu = null;
     RState = new RasterizerState() { ScissorTestEnable = true };
 }