Beispiel #1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            //	Call the base.
            base.OnMouseDown(e);

            //	If we don't want any mouse operations then return.
            if(mouseOperation == MouseOperation.None)
                return;

            //	If we are either in select mode, or on always select, do a hit test.
            if(autoSelect || mouseOperation == MouseOperation.Select)
            {
                //	If we have control held down, then add to the selection.
                hits.Clear();
                hits = scene.DoHitTest(e.X, e.Y);

                //	If we hit nothing, then move the camera instead.
                if(hits.Count == 0)
                    hits.Add(scene.CurrentCamera);
            }

            //	If we've hit stuff, we hide the pointer.
            if(hits.Count > 0)
                Cursor.Current = null;

            //	If there is a Builder, then click it.
            if(currentBuilder != null)
            {
                //	Tell the builder there's been a click. It may return
                //	us an object, if so, we jam it into the scene.
                object val = currentBuilder.OnMouseDown(scene.OpenGL, e);
                if(val != null)
                {
                    //	Add the object.
                    scene.Jam(val);

                    //	We can now get rid of the builder and stop
                    //	capture.
                    Capture = false;
                    currentBuilder = null;
                }
            }

            curX = e.X;
            curY = e.Y;
        }
Beispiel #2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if(e.Clicks == 1)
            {
                if(SelectedItemChanged != null)
                    SelectedItemChanged(this, new EventArgs());
            }

            //	If there is a Builder, then update it.
            if(currentBuilder != null)
            {
                //	Tell the builder there's been a click. It may return
                //	us an object, if so, we jam it into the scene.
                object val = currentBuilder.OnMouseUp(scene.OpenGL, e);
                if(val != null)
                {
                    //	Add the object.
                    scene.Jam(val);

                    //	We can now get rid of the builder and stop
                    //	capture.
                    Capture = false;
                    currentBuilder = null;
                }
            }

            if(autoSelect)
                hits.Clear();
        }
Beispiel #3
0
        /// <summary>
        /// This function initialises the building of a building 
        /// object.
        /// </summary>
        /// <param name="builder">The builder.</param>
        public virtual void StartBuilding(Builder builder)
        {
            //	Set the current builder.
            currentBuilder = builder;

            //	Start mouse capture.
            Capture = true;
        }