/// <summary>
        /// Invalidates the specified region of the canvas (adds it to the canvas's update region,
        /// which is the area that will be repainted at the next paint operation), and causes a paint
        /// message to be sent to the canvas.
        /// </summary>
        /// <param name="bounds">A rectangle object that represents the region to invalidate.</param>
        public virtual void InvalidateBounds(RectangleF bounds)
        {
            PDebug.ProcessInvalidate();

            if (regionManagement)
            {
                // Hack: Invalidate the bounds of the previously invalidated rectangle
                // and the current rectangle, since invalidating lots of small rectangles
                // causes a performance hit.
                if (invalidatedBounds.IsEmpty)
                {
                    invalidatedBounds = bounds;
                }
                else
                {
                    invalidatedBounds = RectangleF.Union(invalidatedBounds, bounds);
                }

                RectangleF insetRect = new RectangleF(invalidatedBounds.X - 1, invalidatedBounds.Y - 1,
                                                      invalidatedBounds.Width + 2, invalidatedBounds.Height + 2);

                int x      = (int)Math.Floor(insetRect.X);
                int y      = (int)Math.Floor(insetRect.Y);
                int width  = (int)Math.Ceiling(insetRect.Right - x);
                int height = (int)Math.Ceiling(insetRect.Bottom - y);
                Invalidate(new Rectangle(x, y, width, height));
            }
            else
            {
                Invalidate();
            }
        }
Exemple #2
0
        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw()
        {
            UpdateTimer();
            Update();

            // Clear to the default control background color.
            //Color backColor = new Color(BackColor.R, BackColor.G, BackColor.B);
            Microsoft.Xna.Framework.Color backColor = Microsoft.Xna.Framework.Color.LightCyan;

            GraphicsDevice.Clear(backColor);

            if (XnaGraphics != null && DrawingContext != null && Texture != null && SpriteFont != null)
            {
                PDebug.StartProcessingOutput();

                // Clear the invalidatedBounds cache.
                invalidatedBounds = RectangleFx.Empty;

                PPaintContext paintContext = new PPaintContext(XnaGraphics, this);
                PaintPiccolo(paintContext);

                // Calling the base class OnPaint
                //base.OnPaint(pe);

                PDebug.EndProcessingOutput(paintContext);
            }
        }
Exemple #3
0
        /// <summary>
        /// Invalidates the specified region of the canvas (adds it to the canvas's update region,
        /// which is the area that will be repainted at the next paint operation), and causes a paint
        /// message to be sent to the canvas.
        /// </summary>
        /// <param name="bounds">A rectangle object that represents the region to invalidate.</param>
        public void InvalidateBounds(RectangleF bounds)
        {
            PDebug.ProcessInvalidate();

            Rectangle insetRect = new Rectangle((int)Math.Floor(bounds.X) - 1, (int)Math.Floor(bounds.Y) - 1,
                                                (int)Math.Ceiling(bounds.Width) + 2, (int)Math.Ceiling(bounds.Height) + 2);

            Invalidate(insetRect);
        }
Exemple #4
0
    public UIAtlas GetAtals(string name)
    {
        var obj = GetPrefab(name);

        if (obj == null)
        {
            PDebug.Break();
            PDebug.Log("<size=20> : error: " + name + "</size>");
        }
        return(obj.GetComponent <UIAtlas>());
    }
Exemple #5
0
    public static byte[] GetRelativeFileBytes(string relativePath)
    {
        PDebug.Log("Load from Resouces! " + relativePath);
        TextAsset data = Resources.Load(relativePath) as TextAsset;

        byte[] bytes = null;
        if (data != null)
        {
            bytes = data.bytes;
        }
        return(bytes);
    }
Exemple #6
0
        /// <summary>
        /// Overridden.  See <see cref="Control.OnPaint">Control.OnPaint</see>.
        /// </summary>
        protected override void OnPaint(PaintEventArgs pe)
        {
            PDebug.StartProcessingOutput();

            Graphics2D g = new Graphics2D(offscreenGraphics);

            g.Clip = new Region(pe.ClipRectangle);
            //Graphics2D g = new Graphics2D(pe.Graphics);

            // create new paint context and set render quality to lowest common
            // denominator render quality.
            //Rectangle clipRect = pe.ClipRectangle;
            //RectangleF fClipRect = new RectangleF(clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
            PPaintContext paintContext = new PPaintContext(g, this);

            if (Interacting || Animating)
            {
                if (interactingRenderQuality < animatingRenderQuality)
                {
                    paintContext.RenderQuality = interactingRenderQuality;
                }
                else
                {
                    paintContext.RenderQuality = animatingRenderQuality;
                }
            }
            else
            {
                paintContext.RenderQuality = defaultRenderQuality;
            }

            // paint
            camera.FullPaint(paintContext);

            // if switched state from animating to not animating invalidate the entire
            // screen so that it will be drawn with the default instead of animating
            // render quality.
            if (!Animating && animatingOnLastPaint)
            {
                Invalidate();
            }
            animatingOnLastPaint = Animating;

            // Calling the base class OnPaint
            base.OnPaint(pe);
            realGraphics.DrawImage(this.offscreenBitmap, 0, 0);

            PDebug.EndProcessingOutput(g);
        }
Exemple #7
0
 public static Vector3 ParseCfgVector3(string vectorString) {
   string[] strArray = vectorString.Split(new char[] { '(', ',', ' ', ')' },
                                          StringSplitOptions.RemoveEmptyEntries);
   if (strArray.Length == 3) {
     try {
       var parsedVector = new Vector3(float.Parse(strArray[0]),
                                      float.Parse(strArray[1]),
                                      float.Parse(strArray[2]));
       return parsedVector;
     } catch (Exception exception) {
       PDebug.Error(exception.Message);
     }
   }
   return Vector3.zero;
 }
        /// <summary>
        /// Overridden.  See <see cref="Control.OnPaint">Control.OnPaint</see>.
        /// </summary>
        protected override void OnPaint(PaintEventArgs pe)
        {
            PDebug.StartProcessingOutput();

            // Clear the invalidatedBounds cache.
            invalidatedBounds = RectangleF.Empty;

            PPaintContext paintContext = CreatePaintContext(pe);

            PaintPiccolo(paintContext);

            // Calling the base class OnPaint
            base.OnPaint(pe);

            PDebug.EndProcessingOutput(paintContext);
        }
Exemple #9
0
        /// <summary>
        /// This is the heartbeat of the Piccolo framework, where all processing is done.
        /// </summary>
        /// <remarks>
        /// In this method, pending input events are processed, Activities are given a
        /// chance to run, and the bounds caches and any paint damage are validated.
        /// </remarks>
        public virtual void ProcessInputs()
        {
            PDebug.StartProcessingInput();
            processingInputs = true;

            globalTime = PUtil.CurrentTimeMillis;
            foreach (InputSource each in inputSources)
            {
                each.ProcessInput();
            }

            activityScheduler.ProcessActivities(globalTime);
            ValidateFullBounds();
            ValidateFullPaint();

            processingInputs = false;
            PDebug.EndProcessingInput();
        }
Exemple #10
0
        public override void OnUpdate()
        {
            if (Input.GetKey(KeyCode.E))
            {
                Transform obj = part.FindModelTransform("cargobay");
                //Transform pivot = part.FindModelTransform("GEO_CargoBay07");

                /*obj.Rotate(Vector3.up * 10, Space.Self);
                 * obj.Rotate(Vector3.right * 10, Space.Self);
                 * obj.Rotate(Vector3.forward * 10, Space.Self);*/
                obj.eulerAngles = obj.eulerAngles + new Vector3(1, 1, 1);
                PDebug.Log(obj.localEulerAngles.x);
                PDebug.Log(obj.localEulerAngles.y);
                PDebug.Log(obj.localEulerAngles.z);
            }
            if (Input.GetKey(KeyCode.W))
            {
                PDebug.Log("W");
                this.transform.Rotate(Vector3.up * 10, Space.Self);
            }
        }
Exemple #11
0
        /// <summary>
        /// If something in the scene graph needs to be updated, this method will schedule
        /// ProcessInputs run at a later time.
        /// </summary>
        public virtual void ScheduleProcessInputsIfNeeded()
        {
            PDebug.ScheduleProcessInputs();

            if (!Application.MessageLoop)
            {
                // Piccolo is not thread safe and should almost always be called from the
                // event dispatch thread. It should only reach this point when a new canvas
                // is being created.
                return;
            }

            if (!processInputsScheduled && !processingInputs &&
                (FullBoundsInvalid || ChildBoundsInvalid || PaintInvalid || ChildPaintInvalid))
            {
                PCanvas canvas = InvokeCanvas;
                if (canvas != null && canvas.IsHandleCreated &&
                    processScheduledInputsDelegate != null)
                {
                    processInputsScheduled = true;
                    canvas.BeginInvoke(processScheduledInputsDelegate);
                }
            }
        }
Exemple #12
0
 public override string ToString()
 {
     return(string.Format("{0}({1}, {2}, {3})", GetType().Name, field.Name, field.FieldType.Name, PDebug.ToString(value)));
 }
Exemple #13
0
 public override string ToString()
 {
     return(string.Format("{0}({1})", GetType().Name, PDebug.ToString(value)));
 }
 public static void Error(string msg)
 {
     PDebug.Error("[CountdownToLaunch]: " + msg);
 }
 public static void Log(string msg)
 {
     PDebug.Log("[CountdownToLaunch]: " + msg);
 }