示例#1
0
        //public override void Update(TSOClient.Code.UI.Model.UpdateState state)
        //{
        //    base.Update(state);
        //    /** Hit test **/
        //    color = Color.White;
        //    if (HitTestArea(state, new Microsoft.Xna.Framework.Rectangle(0, 0, 50, 50)))
        //    {
        //    }
        //    //color
        //}
        public override void Draw(UISpriteBatch batch)
        {
            var whiteRectangle = new Texture2D(batch.GraphicsDevice, 1, 1);
            whiteRectangle.SetData(new[] { color });

            var pos = LocalRect(0, 0, 50, 50);
            batch.Draw(whiteRectangle, pos, Color.White);
        }
示例#2
0
 public override void Draw(UISpriteBatch batch)
 {
     for (int i = 0; i < 4; i++)
     {
         DrawMotive(batch, 20, 13 + 20 * i, i); //left side
         DrawMotive(batch, 120, 13 + 20 * i, i+4); //right side
     }
 }
示例#3
0
 public override void Draw(UISpriteBatch batch)
 {
     DrawLocalTexture(batch, Background, new Vector2(0, 0));
     if (Icon != null)
     {
         if (Icon.Width <= 45) {
             DrawLocalTexture(batch, Icon, new Rectangle(0, 0, Icon.Width, Icon.Height), new Vector2(4, 4), new Vector2(37f/Icon.Width, 37f/Icon.Height));
         }
         else DrawLocalTexture(batch, Icon, new Rectangle(0, 0, Icon.Width / 2, Icon.Height), new Vector2(4, 4));
     }
     if (Overlay != null) DrawLocalTexture(batch, Overlay, new Vector2(0, 0));
 }
示例#4
0
 public override void Draw(UISpriteBatch batch)
 {
     if (!Visible)
     {
         return;
     }
     if (Target != null)
     {
         DrawLocalTexture(batch, Target, null, -BackOffset.ToVector2(), new Vector2(1 / ScaleX, 1 / ScaleY));
     }
     DynamicOverlay.Draw(batch);
 }
示例#5
0
        public override void Draw(UISpriteBatch batch)
        {
            base.Draw(batch);
            if (Thumb != null)
            {
                Vector2 size = new Vector2(GameFacade.GraphicsDevice.Viewport.Width, GameFacade.GraphicsDevice.Viewport.Height);
                float minSize = Math.Min(size.X, size.Y);

                float scale = Math.Min(1, minSize / Math.Max(Thumb.Height, Thumb.Width));

                DrawLocalTexture(batch, Thumb, null, new Vector2(size.X / 2 - (Thumb.Width * scale / 2), size.Y / 2 - (Thumb.Height * scale / 2)), new Vector2(scale, scale));
            }
        }
示例#6
0
 public override void Draw(UISpriteBatch batch)
 {
     DrawLocalTexture(batch, Background, new Vector2(0, 0));
     if (Icon != null)
     {
         if (Icon.Height > 48) //poor mans way of saying "special icon" eg floors
         {
             float scale = 37.0f / Math.Max(Icon.Height, Icon.Width);
             DrawLocalTexture(batch, Icon, new Rectangle(0, 0, Icon.Width, Icon.Height), new Vector2(2 + ((37 - Icon.Width * scale) / 2), 2 + ((37 - Icon.Height * scale) / 2)), new Vector2(scale, scale));
         }
         else
             DrawLocalTexture(batch, Icon, new Rectangle((!Disabled && (Active || Hovered)) ? Icon.Width / 2 : 0, 0, Icon.Width / 2, Icon.Height), new Vector2(2, 2));
     }
 }
示例#7
0
        public void WidthHeightChange(int width, int height)
        {
            //this should be called on the UI thread, otherwise monogame will lose it.
            if (Batch != null)
            {
                Batch.Dispose();
            }
            Batch      = new UISpriteBatch(GameFacade.GraphicsDevice, 1, width, height, GlobalSettings.Default.AntiAlias?4:0);
            RawImage   = new byte[width * height * 4];
            BatchDirty = false;

            State.UIState.Width  = width;
            State.UIState.Height = height;
            DoRedraw             = true;
        }
示例#8
0
        public override void Draw(UISpriteBatch batch)
        {
            base.Draw(batch);
            if (!Visible) return;
            Vector2 dir = new Vector2();
            var res = EditorResource.Get();

            if (MouseDrag || Destination != null)
            {
                //draw Line bg
                dir = new Vector2(ArrowVec.X, ArrowVec.Y);
                dir.Normalize();
                DrawLine(res.WhiteTex, dir * 10, ArrowVec - dir * 5, batch, 6, Color.White);
            }

            //draw Node
            DrawLocalTexture(batch, res.NodeOutline, new Vector2(res.NodeOutline.Width / -2, res.NodeOutline.Height / -2));
            DrawLocalTexture(batch, res.Node, null, new Vector2(res.Node.Width / -2, res.Node.Height / -2), new Vector2(1f, 1f), NodeColors[Type]);

            if (MouseDrag || Destination != null)
            {
                //draw Arrow
                var arrowDir = (float)Math.Atan2(-dir.X, dir.Y);
                var arrowPos = LocalPoint(ArrowVec);
                batch.Draw(res.ArrowHeadOutline, arrowPos, null, Color.White, arrowDir, new Vector2(9, 19), _Scale, SpriteEffects.None, 0);
                batch.Draw(res.ArrowHead, arrowPos, null, NodeColors[Type], arrowDir, new Vector2(9, 19), _Scale, SpriteEffects.None, 0);

                //draw Line
                DrawLine(res.WhiteTex, dir * 10, ArrowVec - dir * 5, batch, 4, NodeColors[Type]);
            }

            Texture2D icon;
            switch (Type)
            {
                case NodeType.False:
                    icon = res.FalseNode;
                    break;
                case NodeType.True:
                    icon = res.TrueNode;
                    break;
                default:
                    icon = res.DoneNode;
                    break;
            }
            DrawLocalTexture(batch, icon, IconPos[Direction]-new Vector2(icon.Width/2, icon.Height/2));
            var shadRect = SmallShad[Direction];
            DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(shadRect.X, shadRect.Y), new Vector2(shadRect.Width, shadRect.Height), Color.Black*0.15f);
        }
示例#9
0
        public UIRenderPlane(UISpriteBatch batch, Promise<Texture2D> texture)
        {
            this.GD = batch.GraphicsDevice;
            this.Target = batch.GetBuffer();
            this.Texture = texture;
            this.Batch = batch;

            if(!UISpriteBatch.Invalidated)
            {
                /** Switch the render target **/
                Batch.Pause();
                GD.SetRenderTarget(Target);
                GD.Clear(Color.Transparent);
                Batch.Resume();
            }
        }
示例#10
0
        public UIRenderPlane(UISpriteBatch batch, Promise <Texture2D> texture)
        {
            this.GD      = batch.GraphicsDevice;
            this.Target  = batch.GetBuffer();
            this.Texture = texture;
            this.Batch   = batch;

            if (!UISpriteBatch.Invalidated)
            {
                /** Switch the render target **/
                Batch.Pause();
                GD.SetRenderTarget(Target);
                GD.Clear(Color.Transparent);
                Batch.Resume();
            }
        }
示例#11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="batch"></param>
        /// <param name="mtx"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (Width == 0 || Height == 0 || !DoRedraw)
            {
                return;
            }
            DoRedraw = false;
            batch    = Batch;
            batch.UIBegin(BlendState.AlphaBlend, SpriteSortMode.Deferred);
            Promise <Texture2D> bufferTexture = null;

            using (batch.WithBuffer(ref bufferTexture))
            {
                lock (Children)
                {
                    foreach (var child in Children)
                    {
                        child.PreDraw(batch);
                    }
                    foreach (var child in Children)
                    {
                        child.Draw(batch);
                    }
                }
                batch.Pause();
                batch.Resume();
            }

            var tex = bufferTexture.Get();

            batch.End();

            tex.GetData(RawImage, 0, (GameFacade.DirectX) ? RawImage.Length : RawImage.Length / 4);

            for (int i = 0; i < RawImage.Length; i += 4)
            {
                var swap = RawImage[i];
                RawImage[i]     = RawImage[i + 2];
                RawImage[i + 2] = swap;
            }
            if (OnFrame != null)
            {
                OnFrame();
            }
            //batch.Draw(tex, Vector2.Zero, _BlendColor);
        }
示例#12
0
        private void DrawMotive(UISpriteBatch batch, int x, int y, int motive)
        {
            double p = (MotiveValues[motive]+100)/200.0;
            Color barcol = new Color((byte)(57 * (1 - p)), (byte)(213 * p + 97 * (1 - p)), (byte)(49 * p + 90 * (1 - p)));
            Color bgcol = new Color((byte)(57 * p + 214*(1-p)), (byte)(97 * p), (byte)(90 * p));

            batch.Draw(Filler, LocalRect(x, y, 60, 5), bgcol);
            batch.Draw(Filler, LocalRect(x, y, (int)(60*p), 5), barcol);
            batch.Draw(Filler, LocalRect(x+(int)(60 * p), y, 1, 5), Color.Black);
            var style = TextStyle.DefaultLabel.Clone();
            style.Size = 8;

            var temp = style.Color;
            style.Color = Color.Black;
            DrawLocalString(batch, MotiveNames[motive], new Vector2(x+1, y - 12), style, new Rectangle(0, 0, 60, 12), TextAlignment.Center); //shadow

            style.Color = temp;
            DrawLocalString(batch, MotiveNames[motive], new Vector2(x, y - 13), style, new Rectangle(0, 0, 60, 12), TextAlignment.Center);
        }
示例#13
0
        public override void Draw(UISpriteBatch batch)
        {
            base.Draw(batch);
            var bg = EditorComponent.EditorResource.Get().ViewBG;
            var viewport = GameFacade.GraphicsDevice.Viewport;
            var scale = 1.0f;

            switch (TempVM.Context.World.State.Zoom)
            {
                case LotView.WorldZoom.Far:
                    scale = 0.25f; break;
                case LotView.WorldZoom.Medium:
                    scale = 0.5f; break;
            }

            DrawLocalTexture(batch, bg, null, new Vector2(viewport.Width / 2 - 400*scale, viewport.Height / 2 - 300*scale), new Vector2(scale, scale));
            batch.Pause();
            GameFacade.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            if (TempVM == null) return;

            if (TargetTile != null)
            {
                Vector2 rot = new Vector2();
                switch (TempVM.Context.World.State.Rotation)
                {
                    case LotView.WorldRotation.TopLeft: rot = new Vector2(2.5f, 2.5f); break;
                    case LotView.WorldRotation.TopRight: rot = new Vector2(2.5f, -2.5f); break;
                    case LotView.WorldRotation.BottomRight: rot = new Vector2(-2.5f, -2.5f); break;
                    case LotView.WorldRotation.BottomLeft: rot = new Vector2(-2.5f, 2.5f); break;
                }
                var tile = TargetTile.VisualPosition;
                TempVM.Context.World.State.CenterTile = new Vector2(tile.X, tile.Y) - rot;
            }

            var world = TempVM.Context.World;
            world.State.SetDimensions(new Vector2(viewport.Width, viewport.Height));
            world.Draw(GameFacade.GraphicsDevice);
            GameFacade.GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
            batch.Resume();
        }
示例#14
0
        public override void Draw(UISpriteBatch batch)
        {
            base.Draw(batch);
            if (Placement != null)
            {
                Placement.ShadDraw(batch);
                Placement.Draw(batch);
            }
            var res = EditorResource.Get();
            DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(), new Vector2(4, batch.Height), Color.Black * 0.2f);
            DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(4, 0), new Vector2(batch.Width, 4), Color.Black * 0.2f);

            if (Placement != null)
            {
                DrawCutoutLines(CutoutPhase, 5, Color.Black * 0.2f, batch);
                DrawCutoutLines(CutoutPhase, 0, new Color(0, 102, 26), batch);
            }

            LastWidth = batch.Width;
            LastHeight = batch.Height;
        }
示例#15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="batch"></param>
        /// <param name="mtx"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (!Visible)
            {
                return;
            }

            /**
             * If opacity is not 100% we need to draw to a texture
             * and then paint that with our opacity value
             */
            {
                lock (Children)
                {
                    foreach (var child in Children)
                    {
                        child.Draw(batch);
                    }
                }
            }
        }
示例#16
0
        public override void Draw(UISpriteBatch SBatch)
        {
            base.Draw(SBatch);

            if (Icon != null)
            {
                var pos = (Small) ? new Vector2(1, 1) : new Vector2(2, 2);
                var targetSize = (Small) ? new Vector2(18, 18) : new Vector2(30, 30);
                if (Icon.Width <= 45)
                {
                    DrawLocalTexture(SBatch, Icon, new Rectangle(0, 0, Icon.Width, Icon.Height), pos, targetSize / new Vector2(Icon.Width, Icon.Height));
                }
                else DrawLocalTexture(SBatch, Icon, new Rectangle(0, 0, Icon.Width / 2, Icon.Height), pos, targetSize / new Vector2((Icon.Width/2), Icon.Height));
            }
            if (Overlay != null) DrawLocalTexture(SBatch, Overlay, new Vector2());

            if (Icon != null && vm.Context.World.State.ScrollAnchor == Avatar?.WorldUI)
            {
                DrawLocalTexture(SBatch, Target, new Vector2(Icon.Width-Target.Width, Icon.Height-Target.Height));
            }
            //draw the icon over the button
        }
示例#17
0
        public override void PreDraw(UISpriteBatch batch)
        {
            base.PreDraw(batch);
            if (!Visible)
            {
                return;
            }
            lock (Children)
            {
                foreach (var child in Children)
                {
                    child.PreDraw(batch);
                }
            }

            /** If we have opacity, draw ourself to a texture so we can blend it later **/

            /*
             * if (_HasOpacity)
             * {
             *
             *  Promise<Texture2D> bufferTexture = null;
             *  using (batch.WithBuffer(ref bufferTexture))
             *  {
             *      lock (Children)
             *      {
             *          foreach (var child in Children)
             *          {
             *              child.Draw(batch);
             *          }
             *      }
             *  }
             *
             *  AlphaBlendedScene = bufferTexture.Get();
             * }
             */
        }
示例#18
0
 public override void Draw(UISpriteBatch batch)
 {
     base.Draw(batch);
 }
示例#19
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="batch"></param>
        /// <param name="mtx"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (Width == 0 || Height == 0 || !DoRedraw) return;
            DoRedraw = false;
            batch = Batch;
            batch.UIBegin(BlendState.AlphaBlend, SpriteSortMode.Deferred);
            Promise<Texture2D> bufferTexture = null;
            using (batch.WithBuffer(ref bufferTexture))
            {
                lock (Children)
                {
                    foreach (var child in Children)
                    {
                        child.PreDraw(batch);
                    }
                    foreach (var child in Children)
                    {
                        child.Draw(batch);
                    }
                }
                batch.Pause();
                batch.Resume();
            }

            var tex = bufferTexture.Get();
            batch.End();

            tex.GetData(RawImage, 0, (GameFacade.DirectX) ? RawImage.Length : RawImage.Length/4);

            for (int i=0; i<RawImage.Length; i+=4)
            {
                var swap = RawImage[i];
                RawImage[i] = RawImage[i + 2];
                RawImage[i + 2] = swap;
            }
            if (OnFrame != null) OnFrame();
            //batch.Draw(tex, Vector2.Zero, _BlendColor);
        }
示例#20
0
文件: UISim.cs 项目: Daribon/FreeSO
 public override void Draw(UISpriteBatch batch)
 {
     if (!UISpriteBatch.Invalidated)
     {
         if (!_3DScene.IsInvalidated)
         {
             batch.Pause();
             Avatar.Draw(GameFacade.GraphicsDevice);
             batch.Resume();
         }
     }
 }
示例#21
0
 public override void PreDraw(UISpriteBatch batch)
 {
     HeadScene.Draw(GameFacade.GraphicsDevice);
     base.PreDraw(batch);
 }
示例#22
0
 public override void PreDraw(UISpriteBatch batch)
 {
     if (BatchDirty) WidthHeightChange(Width, Height);
 }
示例#23
0
 public override void Draw(UISpriteBatch batch)
 {
     base.Draw(batch);
     if (m_CurrentItem == m_PieTree)
     {
         //var oldd = GameFacade.GraphicsDevice.DepthStencilBuffer;
         //GameFacade.GraphicsDevice.DepthStencilBuffer = new DepthStencilBuffer(GameFacade.GraphicsDevice, oldd.Width, oldd.Height, oldd.Format);
         //todo: how to do this in xna4...
         GameFacade.GraphicsDevice.Clear(ClearOptions.DepthBuffer, new Vector4(0), 16777215, 0); //use a temp depth buffer for drawing this... this is an awful idea but will do until we get a better 3D UI element drawing system.
         batch.Pause();
         m_Head.Draw(GameFacade.GraphicsDevice);
         batch.Resume();
         //GameFacade.GraphicsDevice.DepthStencilBuffer = oldd;
     } //if we're top level, draw head!
 }
示例#24
0
 /// <summary>
 /// May be removed - Called before the draw method.
 /// </summary>
 /// <param name="batch"></param>
 public virtual void PreDraw(UISpriteBatch batch)
 {
 }
示例#25
0
        public override void Draw(UISpriteBatch batch)
        {
            base.Draw(batch);

            if (Caption != null && CaptionStyle != null)
            {
                DrawLocalString(batch, Caption, Vector2.Zero, CaptionStyle, GetBounds(), TextAlignment.Top | TextAlignment.Center, CaptionMargin);
            }
        }
示例#26
0
        public void ShadDraw(UISpriteBatch batch)
        {
            var res = EditorResource.Get();
            if (Style == null || Style.Background.A > 200) DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(5,5), new Vector2(Width, Height), ShadCol);
            else DrawTiledTexture(batch, res.DiagTile, new Rectangle(5, 5, Width, Height), ShadCol);

            if (Type == PrimBoxType.Primitive)
            {
                int topInd = 0;
                if (Instruction.Breakpoint) DrawLocalTexture(batch, res.Breakpoint, null, new Vector2(-15, 6+((topInd++)*18)), new Vector2(1, 1), Color.Black * 0.2f);
                if (Master.DebugPointer == this) DrawLocalTexture(batch, res.CurrentArrow, null, new Vector2(-15, 6 + ((topInd++) * 18)), new Vector2(1, 1), Color.Black * 0.2f);
            }

            foreach (var child in Nodes)
            {
                child.ShadDraw(batch);
            }
        }
示例#27
0
 public virtual void InternalDraw(UISpriteBatch batch)
 {
 }
示例#28
0
        public void DrawCutoutLines(int phase, int offset, Color color, UISpriteBatch batch)
        {
            var res = EditorResource.Get();
            int margin = 24;

            int boxWidth = batch.Width - margin * 2;
            int boxHeight = batch.Height - margin * 2;

            int i = phase%32;
            bool draw = ((phase/32)%2) == 1;
            i -= 32;
            while (i < boxWidth)
            {
                if (draw)
                {
                    DrawLine(res.WhiteTex,
                    new Vector2(Math.Max(margin, margin+i) + offset, margin + offset),
                    new Vector2(Math.Min(batch.Width - margin, margin + i + 32) + offset, margin + offset),
                    batch, 4, color);
                }

                i += 32; draw = !draw;
            }
            i -= boxWidth + 32;
            draw = !draw;

            while (i < boxHeight)
            {
                if (draw)
                {
                    DrawLine(res.WhiteTex,
                    new Vector2(offset + batch.Width - margin, Math.Max(margin, margin + i) + offset),
                    new Vector2(offset + batch.Width - margin, Math.Min(batch.Height - margin, margin + i + 32) + offset),
                    batch, 4, color);
                }

                i += 32; draw = !draw;
            }
            i -= boxHeight + 32;
            draw = !draw;

            while (i < boxWidth)
            {
                if (draw)
                {
                    DrawLine(res.WhiteTex,
                    new Vector2(batch.Width-Math.Max(margin, margin + i) + offset, (batch.Height-margin) + offset),
                    new Vector2(batch.Width-Math.Min(batch.Width - margin, margin + i + 32) + offset, (batch.Height - margin) + offset),
                    batch, 4, color);
                }

                i += 32; draw = !draw;
            }
            i -= boxWidth + 32;
            draw = !draw;

            while (i < boxHeight)
            {
                if (draw)
                {
                    DrawLine(res.WhiteTex,
                    new Vector2(offset + margin, batch.Height-Math.Max(margin, margin + i) + offset),
                    new Vector2(offset + margin, batch.Height-Math.Min(batch.Height - margin, margin + i + 32) + offset),
                    batch, 4, color);
                }

                i += 32; draw = !draw;
            }
        }
示例#29
0
        public override void PreDraw(UISpriteBatch batch)
        {
            //If our matrix is dirty, recalculate it
            if (_MtxDirty)
            {
                CalculateMatrix();
            }

            if (!Visible)
            {
                return;
            }

            var gd = batch.GraphicsDevice;

            if (Invalidated)
            {
                var size = Size * Scale;
                if (Target == null || (int)size.X != Target.Width || (int)size.Y != Target.Height)
                {
                    Target?.Dispose();
                    Target = new RenderTarget2D(gd, (int)size.X, (int)size.Y, UseMip, SurfaceFormat.Color, (UseZ)?DepthFormat.Depth24:DepthFormat.None, (UseMultisample && !FSOEnvironment.DirectX)?4:0, RenderTargetUsage.PreserveContents);
                }

                lock (Children)
                {
                    foreach (var child in Children)
                    {
                        if (child == DynamicOverlay)
                        {
                            continue;
                        }
                        child.PreDraw(batch);
                    }
                }

                try { batch.End(); } catch { }
                gd.SetRenderTarget(Target);
                gd.Clear(ClearColor);
                var pos = LocalPoint(0, 0);

                batch.Begin(transformMatrix:
                            Microsoft.Xna.Framework.Matrix.CreateTranslation(-(pos.X), -(pos.Y), 0) *
                            Microsoft.Xna.Framework.Matrix.CreateScale(1f / FSOEnvironment.DPIScaleFactor) *
                            Microsoft.Xna.Framework.Matrix.CreateTranslation(BackOffset.X, BackOffset.Y, 0)
                            , blendState: BlendState.AlphaBlend, sortMode: SpriteSortMode.Deferred);
                batch.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
                if (InternalBefore)
                {
                    InternalDraw(batch);
                }
                lock (Children)
                {
                    foreach (var child in Children)
                    {
                        if (child == DynamicOverlay)
                        {
                            continue;
                        }
                        child.Draw(batch);
                    }
                }
                if (!InternalBefore)
                {
                    InternalDraw(batch);
                }
                batch.End();
                gd.SetRenderTarget(null);
                Invalidated = false;
            }
            DynamicOverlay.PreDraw(batch);
        }
示例#30
0
        public override void Draw(UISpriteBatch batch)
        {
            if (Alpha == 0) return;
            base.Draw(batch);
            Color bgCol = new Color(8,8,128) * Alpha;

            //draw corners
            DrawLocalTexture(batch, BTiles, new Rectangle(0, 0, 40, 40), new Vector2(DisplayRect.Left-20, DisplayRect.Top-20), Vector2.One, bgCol);
            DrawLocalTexture(batch, BTiles, new Rectangle(40, 0, 40, 40), new Vector2(DisplayRect.Right + 20, DisplayRect.Top - 20), new Vector2(-1,1), bgCol);
            DrawLocalTexture(batch, BTiles, new Rectangle(80, 0, 40, 40), new Vector2(DisplayRect.Right + 20, DisplayRect.Bottom + 20), new Vector2(-1, -1), bgCol);
            DrawLocalTexture(batch, BTiles, new Rectangle(120, 0, 40, 40), new Vector2(DisplayRect.Left - 20, DisplayRect.Bottom + 20), new Vector2(1, -1), bgCol);

            //draw edges
            //if the pointer is on this edge, it needs to be split into 3... Before point, point and after point.

            var vertH = DisplayRect.Height - 40;
            var vertPt = Math.Max(DisplayRect.Top + 20, Math.Min(DisplayRect.Bottom - 60, TargetPt.Y-20)) - (DisplayRect.Top + 20);

            var horizW = DisplayRect.Width - 40;
            var horizPt = Math.Max(DisplayRect.Left + 20, Math.Min(DisplayRect.Right - 60, TargetPt.X-20)) - (DisplayRect.Left + 20);

            int ptSel = 0;

            //left
            if (ClosestDir == 0)
            {
                ptSel = Math.Max(0, Math.Min(3, (int)Math.Floor((DisplayRect.Left - TargetPt.X) / 40f)));
                DrawLocalTexture(batch, BTiles, new Rectangle(0, 40, 40, 40), new Vector2(DisplayRect.Left - 20, DisplayRect.Top + 20), new Vector2(1, vertPt / 40f), bgCol);
                DrawLocalTexture(batch, BPointerSide, new Rectangle(0, ptSel * 40, 200, 40), new Vector2(DisplayRect.Left - 180, DisplayRect.Top + 20 + vertPt), Vector2.One, bgCol);
                DrawLocalTexture(batch, BTiles, new Rectangle(0, 40, 40, 40), new Vector2(DisplayRect.Left - 20, DisplayRect.Top + 60 + vertPt), new Vector2(1, (vertH-(vertPt+40)) / 40f), bgCol);
            }
            else DrawLocalTexture(batch, BTiles, new Rectangle(0, 40, 40, 40), new Vector2(DisplayRect.Left - 20, DisplayRect.Top + 20), new Vector2(1, (DisplayRect.Height-40)/40f), bgCol);

            //top
            if (ClosestDir == 1)
            {
                ptSel = Math.Max(0, Math.Min(3, (int)Math.Floor((DisplayRect.Top - TargetPt.Y) / 40f)));
                DrawLocalTexture(batch, BTiles, new Rectangle(0, 80, 40, 40), new Vector2(DisplayRect.Left + 20, DisplayRect.Top - 20), new Vector2(horizPt / 40f, 1), bgCol);
                DrawLocalTexture(batch, BPointerBottom, new Rectangle(ptSel * 40, 0, 40, 200), new Vector2(DisplayRect.Left + 20 + horizPt, DisplayRect.Top + 20), new Vector2(1, -1), bgCol);
                DrawLocalTexture(batch, BTiles, new Rectangle(0, 80, 40, 40), new Vector2(DisplayRect.Left + 60 + horizPt, DisplayRect.Top - 20), new Vector2(((horizW - (horizPt + 40)) / 40f), 1), bgCol);
            }
            else DrawLocalTexture(batch, BTiles, new Rectangle(0, 80, 40, 40), new Vector2(DisplayRect.Left + 20, DisplayRect.Top - 20), new Vector2((DisplayRect.Width - 40) / 40f, 1), bgCol);

            //right
            if (ClosestDir == 2)
            {
                ptSel = Math.Max(0, Math.Min(3, (int)Math.Floor((TargetPt.X - DisplayRect.Right) / 40f)));
                DrawLocalTexture(batch, BTiles, new Rectangle(0, 40, 40, 40), new Vector2(DisplayRect.Right + 20, DisplayRect.Top + 20), new Vector2(-1, vertPt / 40f), bgCol);
                DrawLocalTexture(batch, BPointerSide, new Rectangle(0, ptSel * 40, 200, 40), new Vector2(DisplayRect.Right + 180, DisplayRect.Top + 20 + vertPt), new Vector2(-1, 1), bgCol);
                DrawLocalTexture(batch, BTiles, new Rectangle(0, 40, 40, 40), new Vector2(DisplayRect.Right + 20, DisplayRect.Top + 60 + vertPt), new Vector2(-1, (vertH - (vertPt + 40)) / 40f), bgCol);
            }
            else DrawLocalTexture(batch, BTiles, new Rectangle(0, 40, 40, 40), new Vector2(DisplayRect.Right + 20, DisplayRect.Top + 20), new Vector2(-1, (DisplayRect.Height - 40) / 40f), bgCol);

            //bottom
            if (ClosestDir == 3)
            {
                ptSel = Math.Max(0, Math.Min(3, (int)Math.Floor((TargetPt.Y - DisplayRect.Bottom) / 40f)));
                DrawLocalTexture(batch, BTiles, new Rectangle(0, 120, 40, 40), new Vector2(DisplayRect.Left + 20, DisplayRect.Bottom - 20), new Vector2(horizPt / 40f, 1), bgCol);
                DrawLocalTexture(batch, BPointerBottom, new Rectangle(ptSel * 40, 0, 40, 200), new Vector2(DisplayRect.Left + 20 + horizPt, DisplayRect.Bottom - 20), Vector2.One, bgCol);
                DrawLocalTexture(batch, BTiles, new Rectangle(0, 120, 40, 40), new Vector2(DisplayRect.Left + 60 + horizPt, DisplayRect.Bottom - 20), new Vector2(((horizW - (horizPt + 40)) / 40f), 1), bgCol);
            }
            else DrawLocalTexture(batch, BTiles, new Rectangle(0, 120, 40, 40), new Vector2(DisplayRect.Left + 20, DisplayRect.Bottom - 20), new Vector2((DisplayRect.Width - 40) / 40f, 1), bgCol);

            //draw middle
            DrawLocalTexture(batch, BTiles, new Rectangle(40, 120, 1, 1), new Vector2(DisplayRect.Left + 20, DisplayRect.Top + 20), new Vector2(DisplayRect.Width-40, DisplayRect.Height-40), bgCol);

            Vector2 offpos = new Vector2(DisplayRect.X + 1, DisplayRect.Y + 1);
            int posi = 0;
            foreach (var cmd in BodyTextLabels.DrawingCommands)
            {
                if (cmd is TextDrawCmd_Text)
                {
                    ((TextDrawCmd_Text)cmd).Style = ShadowStyle;
                    ((TextDrawCmd_Text)cmd).Position = BTOffsets[posi++] + offpos;
                }
            }

            ShadowStyle.Color = Color.Black * Alpha;
            TextRenderer.DrawText(BodyTextLabels.DrawingCommands, this, batch);

            posi = 0;
            offpos = new Vector2(DisplayRect.X, DisplayRect.Y);
            foreach (var cmd in BodyTextLabels.DrawingCommands)
            {
                if (cmd is TextDrawCmd_Text) {
                    ((TextDrawCmd_Text)cmd).Style = BodyTextStyle;
                    ((TextDrawCmd_Text)cmd).Position = BTOffsets[posi++] + offpos;
                }
            }
            BodyTextStyle.Color = this.Color * Alpha;
            TextRenderer.DrawText(BodyTextLabels.DrawingCommands, this, batch);

            this.Position = new Vector2();
        }
示例#31
0
        public override void Draw(UISpriteBatch batch)
        {
            var res = EditorResource.Get();
            DrawTiledTexture(batch, res.Background, new Rectangle((int)Math.Floor(this.Position.X/-200)*200, (int)Math.Floor(this.Position.Y/ -200)*200, batch.Width+200, batch.Height+200), Color.White);

            foreach (var child in Primitives)
            {
                child.ShadDraw(batch);
            }

            base.Draw(batch);
        }
示例#32
0
        /// <summary>
        /// Render
        /// </summary>
        /// <param name="batch"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (m_Slider != null) m_Slider.Visible = Visible;
            if (!Visible) { return; }

            if (m_DrawDirty)
            {
                ComputeDrawingCommands();
            }

            /** Can have a text box without a background **/
            if (m_BackgroundTex != null && NineSliceMargins != null)
            {
                NineSliceMargins.DrawOnto(batch, this, m_BackgroundTex, m_Width, m_Height);
            }
            if (m_BackgroundTexRef != null)
            {
                m_BackgroundTexRef.Draw(batch, this, 0, 0, m_Width, m_Height);
            }

            /**
             * Draw border
             */
            if (m_frameBlinkOn && m_frameBlink)
            {
                DrawingUtils.DrawBorder(batch, LocalRect(0, 0, m_Width, m_Height), 1, m_FrameTexture, m_FrameColor);
            }

            /**
             * Draw text
             */
            foreach (var cmd in m_DrawCmds)
            {
                cmd.Draw(this, batch);
            }
        }
示例#33
0
 public override void Draw(UISpriteBatch batch)
 {
     base.Draw(batch);
     var selected = SelectedAvatar;
     if (selected != null) {
         var moodPos = MoodPanelButton.Position;
         var moodFrac = selected.GetMotiveData(VMMotive.Mood) / 4;
         if (moodFrac >= 0) {
             DrawLocalTexture(batch, MoodPositiveImg, new Rectangle(0, 0, moodFrac, 33), moodPos + new Vector2(69, 11));
         } else
         {
             DrawLocalTexture(batch, MoodNegativeImg, new Rectangle(25+moodFrac, 0, -moodFrac, 33), moodPos + new Vector2(30+moodFrac, 11));
         }
     }
 }
示例#34
0
        /// <summary>
        /// Render
        /// </summary>
        /// <param name="batch"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (!Visible) return;
            if (m_DrawDirty)
            {
                ComputeDrawingCommands();
            }

            /** Can have a text box without a background **/
            if (m_BackgroundTex != null && NineSliceMargins != null)
            {
                NineSliceMargins.DrawOnto(batch, this, m_BackgroundTex, m_Width, m_Height);
            }

            /**
             * Draw text
             */
            foreach (var cmd in m_DrawCmds)
            {
                cmd.Draw(this, batch);
            }
        }
示例#35
0
 public override void Draw(UISpriteBatch batch)
 {
     base.Draw(batch);
     if (m_CurrentItem == m_PieTree)
     {
         var invScale = new Vector2(1 / TrueScale, 1 / TrueScale);
         DrawLocalTexture(batch, HeadScene.Target, null, new Vector2(-100, -100)*invScale, invScale);
     } //if we're top level, draw head!
 }
示例#36
0
        public override void Draw(UISpriteBatch batch)
        {
            base.Draw(batch);

            var res = EditorResource.Get();

            if (Type == PrimBoxType.Primitive)
            {
                if (InstPtr == 0)
                {
                    DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(-3, -3), new Vector2(Width + 6, Height + 6), new Color(0x96, 0xFF, 0x73));
                    DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(-2, -2), new Vector2(Width + 4, Height + 4), new Color(0x46, 0x8C, 0x00)); //start point green
                }

                if (Style.Background.A > 200) DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(), new Vector2(Width, Height), Master.Selected.Contains(this)?Color.Red:Color.White); //white outline
                DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(1, 1), new Vector2(Width - 2, Height - 2), Style.Background); //background
                DrawTiledTexture(batch, res.DiagTile, new Rectangle(1, 1, Width - 2, Height - 2), Color.White * Style.DiagBrightness);
                DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(1, 1), new Vector2(Width - 2, 20), Color.White * 0.66f); //title bg

                Title.Draw(batch);
                if (BodyTextLabels != null) TextRenderer.DrawText(BodyTextLabels.DrawingCommands, this, batch);

                int topInd = 0;
                if (Instruction.Breakpoint)
                    DrawLocalTexture(batch, res.Breakpoint, null, new Vector2(-20, 1 + ((topInd++) * 18)), new Vector2(1, 1), Color.White);
                if (Master.DebugPointer == this)
                    DrawLocalTexture(batch, res.CurrentArrow, null, new Vector2(-20, 1 + ((topInd++) * 18)), new Vector2(1, 1), Color.White);
            }
            else
            {
                DrawLocalTexture(batch, (Type == PrimBoxType.True)?res.TrueReturn:res.FalseReturn, new Vector2());
            }
        }
示例#37
0
 /// <summary>
 /// Basic draw method. Your component should implement this
 /// and add any drawing behavior it needs.
 /// </summary>
 /// <param name="batch"></param>
 public abstract void Draw(UISpriteBatch batch);
示例#38
0
 public override void Draw(UISpriteBatch batch)
 {
     if (!Visible) return;
     base.Draw(batch);
 }
示例#39
0
 public override void Draw(UISpriteBatch batch)
 {
 }
示例#40
0
        public void WidthHeightChange(int width, int height)
        {
            //this should be called on the UI thread, otherwise monogame will lose it.
            if (Batch != null) Batch.Dispose();
            Batch = new UISpriteBatch(GameFacade.GraphicsDevice, 1, width, height, GlobalSettings.Default.AntiAlias?4:0);
            RawImage = new byte[width * height * 4];
            BatchDirty = false;

            State.UIState.Width = width;
            State.UIState.Height = height;
            DoRedraw = true;
        }