public override void Removed() { base.Removed(); Target?.Dispose(); Batch?.Dispose(); Target = null; Batch = null; }
public override void Draw(UISpriteBatch batch) { if (!Visible) { return; } //draw the pedestal var tintCol = (AltColor) ? new Color(217, 245, 255) : Color.White; var halfW = Tile.Width / 2; var halfH = Tile.Height / 2; var halfV = new Vector2(-halfW, -halfH); var scale = new Vector2(Tile.Width / TileFill.Width); //shadow DrawLocalTexture(batch, TileFill, null, new Vector2(1, 1) + halfV, scale, Color.Black); //fill var fillCol = new Color(new Color(164, 188, 210).ToVector4() * tintCol.ToVector4()); var shad = fillCol * 0.88f; shad.A = 255; DrawLocalTexture(batch, TileFill, null, halfV, scale, fillCol); DrawLocalTexture(batch, TileFill, new Rectangle(TileFill.Width / 2, 0, TileFill.Width / 2, TileFill.Height), new Vector2(0, -halfH), scale, shad); var pxWhite = TextureGenerator.GetPxWhite(batch.GraphicsDevice); DrawLocalTexture(batch, pxWhite, null, new Vector2(-halfW, -Height), new Vector2(halfW, Height + 0.5f), fillCol); DrawLocalTexture(batch, pxWhite, null, new Vector2(0, -Height), new Vector2(halfW, Height + 0.5f), shad); //tile DrawLocalTexture(batch, Tile, null, new Vector2(0, -Height) + halfV, Vector2.One, tintCol); //bottom and top var intensity = Math.Min(1f, Height / 10f); DrawLocalTexture(batch, TileBtm, null, new Vector2(0, 6) + halfV, scale, tintCol * intensity); DrawLocalTexture(batch, TileTop, null, new Vector2(0, 16 - Height) + halfV, scale, tintCol * intensity); if (Hovered) { var hoverCol = (Clicked)?(Color.Black * 0.2f):(Color.White * 0.3f); DrawLocalTexture(batch, TileFill, new Rectangle(0, 0, TileFill.Width, halfH), new Vector2(-halfW, -(halfH + Height)), scale, hoverCol); DrawLocalTexture(batch, TileFill, new Rectangle(0, halfH, TileFill.Width, halfH), new Vector2(-halfW, 0), scale, hoverCol); DrawLocalTexture(batch, pxWhite, null, new Vector2(-halfW, -Height), new Vector2(halfW * 2, Height + 0.5f), hoverCol); } if (ThumbLock != null && ThumbLock.Loaded && ThumbLock.LotTexture != null) { var tex = ThumbLock.LotTexture; DrawLocalTexture(batch, tex, null, new Vector2(-halfW, -(halfW + Height)), new Vector2((halfW * 2f) / tex.Width)); } base.Draw(batch); }
public override void Draw(UISpriteBatch batch) { //DrawLocalTexture(batch, World.State.Light.LightMap, new Rectangle(0,0, World.State.Light.LightMap.Width/3, World.State.Light.LightMap.Height/2), new Vector2()); if (RMBScroll) { DrawLocalTexture(batch, RMBCursor, new Vector2(RMBScrollX - RMBCursor.Width / 2, RMBScrollY - RMBCursor.Height / 2)); } base.Draw(batch); }
public override void Draw(UISpriteBatch batch) { if (!Visible) { return; } base.Draw(batch); //DrawLocalTexture(batch, Cross, new Vector2(UIScreen.Current.ScreenWidth - 98, UIScreen.Current.ScreenHeight - 98)/2); }
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); } }
public override void Draw(UISpriteBatch batch) { batch.GraphicsDevice.DepthStencilState = DepthStencilState.Default; batch.GraphicsDevice.BlendState = BlendState.NonPremultiplied; Camera.ProjectionOrigin = new Vector2(batch.GraphicsDevice.Viewport.Width, batch.GraphicsDevice.Viewport.Height) / 2; Scene.Draw(batch.GraphicsDevice); batch.DrawString(GameFacade.MainFont.GetNearest(8).Font, (Comp3D?.Sum(x => x.Mesh?.Geoms?.FirstOrDefault()?.Sum(y => y.Value.PrimCount) ?? 0) ?? 0) + " tris", new Vector2(10, 10), Color.Red); }
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); } //if we're top level, draw head! }
public override void PreDraw(UISpriteBatch batch) { base.PreDraw(batch); Camera.Position = new Vector3(10f, 4f, 0); Camera.Target = new Vector3(4f, Pet?0f:0.8f, 0); GameFacade.GraphicsDevice.RasterizerState = Microsoft.Xna.Framework.Graphics.RasterizerState.CullCounterClockwise; Scene.Draw(GameFacade.GraphicsDevice); GameFacade.GraphicsDevice.RasterizerState = Microsoft.Xna.Framework.Graphics.RasterizerState.CullNone; }
public override void Draw(UISpriteBatch batch) { base.Draw(batch); if (DrawBounds) { DrawLocalTexture(batch, ScrollEdgeL, new Vector2(0, Size.Y / 2 - 64)); DrawLocalTexture(batch, ScrollEdgeR, new Vector2(Size.X - 15, Size.Y / 2 - 64)); } }
public override void Draw(UISpriteBatch batch) { var realFrame = (FrameNum >= Frames.Length) ? (Frames.Length - 2 - (FrameNum - Frames.Length)) : FrameNum; var fm2 = (TotalFrames != 0) ? ((FrameNum + 1) % TotalFrames) : 0; var realFrame2 = (fm2 >= Frames.Length) ? (Frames.Length - 2 - (fm2 - Frames.Length)) : fm2; DrawLocalTexture(batch, Frames[Math.Max(0, realFrame)], Vector2.Zero); DrawLocalTexture(batch, Frames[Math.Max(0, realFrame2)], null, Vector2.Zero, Vector2.One, Color.White * (1 - ((float)SubFrame / FrameTime))); }
public override void Draw(UISpriteBatch spriteBatch) { if (Visible) { DrawLocalTexture(spriteBatch, TextureGenerator.GetPxWhite(spriteBatch.GraphicsDevice), null, new Vector2(), new Vector2(m_Width, m_Height), new Color(Color.Black, 0.5f)); } //spriteBatch.Draw(TextureGenerator.GetPxWhite(spriteBatch.GraphicsDevice), new Vector2(0, 0), null, new Color(Color.Black, 0.3f), 0, new Vector2(0,0), //new Vector2(m_Width, m_Height), SpriteEffects.None, 0); }
public override void Draw(UISpriteBatch batch) { base.Draw(batch); //DebugTexture = Common.Utils.TextureGenerator.GetTerrainNoise(batch.GraphicsDevice); if (DebugTexture != null) { DrawLocalTexture(batch, DebugTexture, new Vector2(20, 20)); } }
public override void Draw(UISpriteBatch SBatch) { if (!Visible) { return; } if (m_CalcAutoSize) { CalculateAutoSize(); } /** Draw the button as a 3 slice **/ var frame = m_CurrentFrame; if (Selected) { frame = 1; } if (m_Disabled) { frame = 3; } frame = Math.Min(m_ImageStates - 1, frame); int offset = frame * m_Width; int vOffset = m_ButtonFrame * m_Height; if (Width != 0) { //TODO: Work out these numbers once & cache them. Invalidate when texture or width changes /** left **/ base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset, vOffset, m_WidthDiv3, m_Height), Vector2.Zero); /** center **/ base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset + m_WidthDiv3, vOffset, m_WidthDiv3, m_Height), new Vector2(m_WidthDiv3, 0), new Vector2((Width - (m_WidthDiv3 * 2)) / m_WidthDiv3, 1.0f)); /** right **/ base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset + (m_Width - m_WidthDiv3), vOffset, m_WidthDiv3, m_Height), new Vector2(Width - m_WidthDiv3, 0)); } else { base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset, vOffset, m_Width, m_Height), Vector2.Zero); } /** * Label */ if (m_Caption != null && m_CaptionStyle != null) { var box = GetBounds(); //Little hack to get slightly better centering on text on buttons box.Height -= 2; this.DrawLocalString(SBatch, m_Caption, Vector2.Zero, m_CaptionStyle, box, TextAlignment.Center | TextAlignment.Middle, Rectangle.Empty, m_State); } }
public UILayer(Microsoft.Xna.Framework.Game G, SpriteFont SprFontBig, SpriteFont SprFontSmall) { m_G = G; m_SprFontBig = SprFontBig; m_SprFontSmall = SprFontSmall; GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionNormalTexture.VertexElements); m_WorldMatrix = Matrix.Identity; m_ViewMatrix = Matrix.CreateLookAt(Vector3.Right * 5, Vector3.Zero, Vector3.Forward); m_ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.Pi / 4.0f, (float)GraphicsDevice.PresentationParameters.BackBufferWidth / (float)GraphicsDevice.PresentationParameters.BackBufferHeight, 1.0f, 100.0f); TextStyle.DefaultTitle = new TextStyle { Font = GameFacade.MainFont, Size = 10, Color = new Color(255, 249, 157), SelectedColor = new Color(0x00, 0x38, 0x7B), SelectionBoxColor = new Color(255, 249, 157) }; TextStyle.DefaultButton = new TextStyle { Font = GameFacade.MainFont, Size = 10, Color = new Color(255, 249, 157), SelectedColor = new Color(0x00, 0x38, 0x7B), SelectionBoxColor = new Color(255, 249, 157) }; TextStyle.DefaultLabel = new TextStyle { Font = GameFacade.MainFont, Size = 10, Color = new Color(255, 249, 157), SelectedColor = new Color(0x00, 0x38, 0x7B), SelectionBoxColor = new Color(255, 249, 157) }; Tween = new UITween(); this.AddProcess(Tween); inputManager = new InputManager(); mainUI = new UIContainer(); dialogContainer = new UIContainer(); mainUI.Add(dialogContainer); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new UISpriteBatch(GraphicsDevice, 3); GameFacade.OnContentLoaderReady += new BasicEventHandler(GameFacade_OnContentLoaderReady); m_G.GraphicsDevice.DeviceReset += new EventHandler(GraphicsDevice_DeviceReset); }
public static void DrawArrow(UISpriteBatch batch, Terrain terrain, Vector2 from, int location) { if (!terrain.Visible) { return; } var x = location >> 16; var y = location & 0xFFFF; if (x > 511 || y > 511) { return; } var f1 = terrain.Get2DFromTile(x, y); var f2 = terrain.Get2DFromTile(x + 1, y + 1); if (f1.X == float.MaxValue || f2.X == float.MaxValue) { return; } var to = (terrain.Get2DFromTile(x, y) + terrain.Get2DFromTile(x + 1, y + 1)) / 2; var vector = to - from; var norm = vector; norm.Normalize(); var fill = TextureGenerator.GetPxWhite(batch.GraphicsDevice); var normr = new Vector2(-norm.Y, norm.X); var shadOffset = new Vector2(0, 4f); var col = Color.Black * 0.5f; from += shadOffset; to += shadOffset; for (var j = 0; j < 2; j++) { if (j == 1) { col = new Color(200, 225, 255); from -= shadOffset; to -= shadOffset; } DrawLine(fill, from, to, batch, 5, col); for (int i = 0; i < 5; i++) { DrawLine(fill, to - (norm * (15 - i)) - normr * (8 - i), to + norm * (3 - i), batch, i + 1, col); DrawLine(fill, to - (norm * (15 - i)) + normr * (8 - i), to + norm * (3 - i), batch, i + 1, col); DrawLine(fill, to - (norm * (15 - i)) + normr * (8 - i), to - (norm * (15 - i)) - normr * (8 - i), batch, i + 1, col); } } }
//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); }
public override void Draw(UISpriteBatch batch) { if (!Visible) { return; } var scale = Math.Max(GameFacade.Screens.CurrentUIScreen.ScreenWidth / 1136f, GameFacade.Screens.CurrentUIScreen.ScreenHeight / 640f); DrawLocalTexture(batch, Bg, null, new Vector2(Bg.Width, Bg.Height) / -2 * scale, new Vector2(scale)); }
public override void Draw(UISpriteBatch batch) { base.Draw(batch); if (m_TextDirty) { ComputeText(); } TextRenderer.DrawText(MessageText.DrawingCommands, this, batch); }
public override void Draw(UISpriteBatch batch) { var whitePx = TextureGenerator.GetPxWhite(batch.GraphicsDevice); if (TextBox.Visible) { DrawLocalTexture(batch, whitePx, null, TextBox.Position, TextBox.Size, new Color(0x00, 0x33, 0x66) * 0.75f); } base.Draw(batch); }
//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(_Mouse.Region.X, _Mouse.Region.Y, _Mouse.Region.Width, _Mouse.Region.Height); batch.Draw(whiteRectangle, pos, Color.White); }
public override void Draw(UISpriteBatch batch) { for (var i = 0; i < VisibleRows; i++) { int j = i + VerticalScrollPosition; if (j >= m_Items.Count) { break; } var row = m_Items[j]; var rowY = i * RowHeight; var columnX = 0; var selected = j == m_SelectedRow; var hover = j == m_HoverRow; if (selected) { /** Draw selection background **/ DrawLocalTexture(batch, m_SelectionTexture, null, new Vector2(0, rowY), new Vector2(m_Width, RowHeight)); } var ts = TextStyle; if (row.CustomStyle != null) { ts = row.CustomStyle; } var style = ts.Normal; if (selected) { style = ts.Selected; } else if (hover) { style = ts.Highlighted; } else if (row.Disabled) { style = ts.Disabled; } for (var x = 0; x < row.Columns.Length; x++) { var columnValue = row.Columns[x]; var columnSpec = m_Columns[x]; var columnBounds = new Rectangle(0, 0, columnSpec.Width, RowHeight); if (columnValue is string) { DrawLocalString(batch, (string)columnValue, new Vector2(columnX, rowY), style, columnBounds, columnSpec.Alignment); } columnX += columnSpec.Width; } } }
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); }
public override void Draw(UISpriteBatch batch) { DrawLocalTexture(batch, ItemBg, null, new Vector2(20, 40), Vector2.One, new Color(104, 164, 184, 255)); if (Item != null) { DrawLocalTexture(batch, Item, new Rectangle(0, 0, Item.Width / 2, Item.Height), new Vector2(45 + 42 / -2, 65 + 42 / -2), new Vector2(42f / Item.Height, 42f / Item.Height)); } base.Draw(batch); }
public override void Draw(UISpriteBatch batch) { if (!Visible || Thumb == null) { return; } var ThumbImg = Thumb.LotTexture; if (ThumbImg != null && BgImg != null && HoverImg != null) { var terrain = ((CoreGameScreen)GameFacade.Screens.CurrentUIScreen).CityRenderer; var Size = new Vector2(80, 50); Vector2 startVec = new Vector2(40, 25) + Position, end = UITerrainHighlight.GetEndpointFromLotId(terrain, startVec, (int)LotId); Vector2 start = end; // position line around border float threshold = 5f; if (start.X > Position.X + Size.X) { start.X = Position.X + Size.X - threshold; } else if (start.X < Position.X) { start.X = Position.X + threshold; } if (start.Y > Position.Y + Size.Y) { start.Y = Position.Y + Size.Y - threshold; } else if (start.Y < Position.Y) { start.Y = Position.Y + threshold; } if (Math.Abs(start.X - end.X) < 30) { start.X = Size.X / 2 + Position.X; } if (Math.Abs(start.Y - end.Y) < 30) { start.Y = Size.Y / 2 + Position.Y; } UITerrainHighlight.DrawArrow(batch, terrain, start * FSOEnvironment.DPIScaleFactor, (int)LotId, Target.Value.Lot_IsOnline ? default : new Color(80, 80, 80)); DrawLocalTexture(batch, (m_isOver && !m_isDown) ? HoverImg : BgImg, new Vector2()); var scale = new Vector2(0.25f, 0.25f); DrawLocalTexture(batch, ThumbImg, null, new Vector2(40, 25) - new Vector2(32, 32), scale); var px = TextureGenerator.GetPxWhite(batch.GraphicsDevice); DrawLocalTexture(batch, px, null, new Vector2(0, 50), new Vector2(80, 16 * NameLabel.NumLines + 7), Color.Black * 0.6f); base.Draw(batch); } }
public override void Draw(UISpriteBatch batch) { if (!Visible) { return; } DrawLocalTexture(batch, Bg, new Rectangle(0, 0, 12, 24), Vector2.Zero, Vector2.One, UIStyle.Current.Bg); DrawLocalTexture(batch, Bg, new Rectangle(12, 0, 12, 24), new Vector2(12, 0), new Vector2(8.666667f, 1), UIStyle.Current.Bg); DrawLocalTexture(batch, Bg, new Rectangle(24, 0, 12, 24), new Vector2(116, 0), Vector2.One, UIStyle.Current.Bg); base.Draw(batch); }
public override void Draw(UISpriteBatch batch) { var yOff = new Vector2(Offsets.XOff, Offsets.BaseYOff) / (HouseScale * 2f); var yOff2 = yOff; yOff2.Y -= Offsets.AddYOff / (HouseScale); DrawLocalTexture(batch, HouseTex, null, new Vector2(-HouseTex.Width, -HouseTex.Height) / (HouseScale * 2) + yOff, new Vector2(1f / HouseScale, 1f / HouseScale)); if (AlphaTime > 0) { DrawLocalTexture(batch, HouseOpenTex, null, new Vector2(-HouseTex.Width, -HouseTex.Height) / (HouseScale * 2) + yOff2, new Vector2(1f / HouseScale, 1f / HouseScale), Color.White * AlphaTime); } }
public override void Draw(UISpriteBatch batch) { if (!UISpriteBatch.Invalidated) { if (!_3DScene.IsInvalidated) { batch.Pause(); Avatar.Draw(GameFacade.GraphicsDevice); batch.Resume(); } } }
public override void Draw(UISpriteBatch batch) { m_TextStyle.Color = UIStyle.Current.DialogText * InterpolatedAnimation; base.Draw(batch); if (m_TextDirty) { ComputeText(); } TextRenderer.DrawText(m_MessageText.DrawingCommands, this, batch); }
public override void Draw(UISpriteBatch batch) { if (!Visible) { return; } if (CurrentLot.Value != null) { UITerrainHighlight.DrawArrow(batch, ((CoreGameScreen)GameFacade.Screens.CurrentUIScreen).CityRenderer, Position + (_Open? Size : BackgroundContractedImage.Size.ToVector2()) / 2, (int)CurrentLot.Value.Id); } base.Draw(batch); }
public override void Draw(UISpriteBatch SBatch) { DrawLocalTexture(SBatch, Texture, null, new Vector2(Texture.Width, Texture.Height) / -2, Vector2.One, new Color(104, 164, 184, 255)); if (Icon != null) { DrawLocalTexture(SBatch, Icon, new Vector2(Icon.Width, Icon.Height) / -2); } if (Outlined) { DrawLocalTexture(SBatch, Outline, null, new Vector2(Outline.Width, Outline.Height) / -2, Vector2.One, UIStyle.Current.ActiveSelection); } }