public override void Draw(GameTime gameTime) { //draw top left triangle of the button batch.Begin(PrimitiveType.TriangleList); batch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), BackgroundColor); batch.AddVertex(new Vector2(Bounds.Left, Bounds.Top), BackgroundColor); batch.AddVertex(new Vector2(Bounds.Right, Bounds.Top), BackgroundColor); //draw bottom right tri of the button batch.AddVertex(new Vector2(Bounds.Right, Bounds.Bottom), BackgroundColor); batch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), BackgroundColor); batch.AddVertex(new Vector2(Bounds.Right, Bounds.Top), BackgroundColor); batch.End(); //rad dropshadow batch.Begin(PrimitiveType.LineList); batch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), Color.Black); batch.AddVertex(new Vector2(Bounds.Right, Bounds.Bottom), Color.Black); batch.AddVertex(new Vector2(Bounds.Right, Bounds.Top), Color.Black); batch.AddVertex(new Vector2(Bounds.Right, Bounds.Bottom), Color.Black); batch.End(); //draw caption textBatch.Begin(); textBatch.DrawString(font, caption, textPosition, ForegroundColor); textBatch.End(); // batch.AddVertex( base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { primBatch.Begin(PrimitiveType.TriangleList); //black outline primBatch.AddVertex(new Vector2(Bounds.Left - 1, Bounds.Bottom + 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Left - 1, Bounds.Top - 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Right + 1, Bounds.Top - 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Right + 1, Bounds.Top - 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Right + 1, Bounds.Bottom + 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Left - 1, Bounds.Bottom + 1), Color.Black); //white text area primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Top), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Top), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Top), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Bottom), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), BackgroundColor); primBatch.End(); batch.Begin(); batch.DrawString(font, Text + (HasFocus ? "|" : ""), textPosition, ForegroundColor); batch.End(); }
public override void Draw(GameTime gameTime) { //if (!show) // return; if (bounds.Height < consoleHeight && show) { bounds.Inflate(0, 20); } if (bounds.Height > 0 && !show) { bounds.Inflate(0, -20); } Color consoleColor = Color.Gray; consoleColor.A = 200; batch.Begin(PrimitiveType.TriangleList); batch.AddVertex(new Vector2(bounds.Left, bounds.Bottom), consoleColor); batch.AddVertex(new Vector2(bounds.Left, bounds.Top), consoleColor); batch.AddVertex(new Vector2(bounds.Right, bounds.Top), consoleColor); batch.AddVertex(new Vector2(bounds.Right, bounds.Top), consoleColor); batch.AddVertex(new Vector2(bounds.Right, bounds.Bottom), consoleColor); batch.AddVertex(new Vector2(bounds.Left, bounds.Bottom), consoleColor); batch.End(); textBatch.Begin(); int lineLength = 50; if (lines.Count > 0) { DeveloperConsoleMessage[] msgArray = lines.ToArray <DeveloperConsoleMessage>(); for (int i = 0; i < lines.Count; i++) { // Attempt at word wrapping... /*if (strArray[lines.Count - i - 1].Length > lineLength) * { * int lineBreaks = (int)(strArray[lines.Count - i - 1].Length / lineLength); * string TempString; * for (int n = 0; n < lineBreaks; n++) * { * TempString = strArray[lines.Count - i - 1].Substring(lineLength * n, lineLength); * textBatch.DrawString(font, TempString + '\n', new Vector2(bounds.Left + 5, bounds.Bottom - textHeight - ((n + i + 2) * textHeight)), Color.White); * } * } * else * {*/ DeveloperConsoleMessage msg = msgArray[lines.Count - i - 1]; textBatch.DrawString(font, msg.Message, new Vector2(bounds.Left + 5, bounds.Bottom - textHeight - ((i + 1) * textHeight)), MessageColors[msg.MessageType]); //} } } textBatch.DrawString(font, "] " + inputString + "_", new Vector2(bounds.Left + 5, bounds.Bottom - textHeight), Color.White); textBatch.End(); base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { primBatch.Begin(PrimitiveType.TriangleList); if (!minimised) { //black outline primBatch.AddVertex(new Vector2(Bounds.Left - 1, Bounds.Bottom + 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Left - 1, Bounds.Top - 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Right + 1, Bounds.Top - 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Right + 1, Bounds.Top - 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Right + 1, Bounds.Bottom + 1), Color.Black); primBatch.AddVertex(new Vector2(Bounds.Left - 1, Bounds.Bottom + 1), Color.Black); } //title bar primBatch.AddVertex(new Vector2(titleBarBounds.Left, titleBarBounds.Bottom), Color.Gray); primBatch.AddVertex(new Vector2(titleBarBounds.Left, titleBarBounds.Top), Color.Gray); primBatch.AddVertex(new Vector2(titleBarBounds.Right, titleBarBounds.Top), Color.SlateGray); primBatch.AddVertex(new Vector2(titleBarBounds.Right, titleBarBounds.Top), Color.SlateGray); primBatch.AddVertex(new Vector2(titleBarBounds.Right, titleBarBounds.Bottom), Color.SlateGray); primBatch.AddVertex(new Vector2(titleBarBounds.Left, titleBarBounds.Bottom), Color.Gray); if (!minimised) { //panel body primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Top + titleBarBounds.Height), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Top + titleBarBounds.Height), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Top + titleBarBounds.Height), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Bottom), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), BackgroundColor); } primBatch.End(); batch.Begin(); batch.DrawString(font, Caption, captionPosition, Color.White); batch.End(); if (!minimised) { foreach (GUIComponent c in components) { c.Draw(gameTime); } } }
public override void Draw(GameTime gameTime) { base.Draw(gameTime); if (editing) { if (showGrid) { int xbounds = GraphicsDevice.Viewport.Width / gridSize; int ybounds = GraphicsDevice.Viewport.Height / gridSize; Color gridColor = Color.Gray; gridColor.A = 128; gridBatch.Begin(PrimitiveType.LineList); for (int x = 0; x < xbounds; x++) { gridBatch.AddVertex(new Vector2((x * gridSize), 0), gridColor); gridBatch.AddVertex(new Vector2((x * gridSize), GraphicsDevice.Viewport.Height), gridColor); } for (int y = 0; y < ybounds; y++) { gridBatch.AddVertex(new Vector2(0, y * gridSize), gridColor); gridBatch.AddVertex(new Vector2(GraphicsDevice.Viewport.Width, y * gridSize), gridColor); } gridBatch.End(); } } artBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.None); foreach (LevelArt la in Art) { artBatch.Draw(la.Texture, la.GetScreenPosition(), null, la.Tint, la.Rotation, la.Origin, camera.ZoomLevel, SpriteEffects.None, 1 - la.ScreenDepth); if (editing && la.EditorSelected) { la.DrawBoundingBox(); } } foreach (DynamicLevelObject da in DynamicObjects) { if (da.Texture != null) { //artBatch.Draw(da.Texture, new Rectangle((int)da.GetScreenPosition().X, (int)da.GetScreenPosition().Y, da.Texture.Width, da.Texture.Height), null, Color.White, da.Rotation,da.Origin, SpriteEffects.None, 0); artBatch.Draw(da.Texture, da.GetScreenPosition(), null, Color.White, da.Rotation, da.Origin, camera.ZoomLevel, SpriteEffects.None, 0); } } artBatch.End(); }
public override void Draw(GameTime gameTime) { primBatch.Begin(PrimitiveType.TriangleList); //white text area primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), CurrentColour); primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Top), CurrentColour); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Top), CurrentColour); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Top), CurrentColour); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Bottom), CurrentColour); primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), CurrentColour); primBatch.End(); batch.Begin(); batch.DrawString(font, text, textPosition, ForegroundColor); batch.End(); }
public void DrawBoundingBox() { boundingBatch.Begin(PrimitiveType.LineList); //top line boundingBatch.AddVertex(camera.WorldToScreen(new Vector2(BoundingBox.Left - 1, BoundingBox.Top - 1)), Microsoft.Xna.Framework.Graphics.Color.Green); boundingBatch.AddVertex(camera.WorldToScreen(new Vector2(BoundingBox.Right + 1, BoundingBox.Top - 1)), Microsoft.Xna.Framework.Graphics.Color.Green); //left line boundingBatch.AddVertex(camera.WorldToScreen(new Vector2(BoundingBox.Left - 1, BoundingBox.Top)), Microsoft.Xna.Framework.Graphics.Color.Green); boundingBatch.AddVertex(camera.WorldToScreen(new Vector2(BoundingBox.Left - 1, BoundingBox.Bottom + 1)), Microsoft.Xna.Framework.Graphics.Color.Green); //right line boundingBatch.AddVertex(camera.WorldToScreen(new Vector2(BoundingBox.Right, BoundingBox.Top)), Microsoft.Xna.Framework.Graphics.Color.Green); boundingBatch.AddVertex(camera.WorldToScreen(new Vector2(BoundingBox.Right, BoundingBox.Bottom + 1)), Microsoft.Xna.Framework.Graphics.Color.Green); //bottom line boundingBatch.AddVertex(camera.WorldToScreen(new Vector2(BoundingBox.Left, BoundingBox.Bottom)), Microsoft.Xna.Framework.Graphics.Color.Green); boundingBatch.AddVertex(camera.WorldToScreen(new Vector2(BoundingBox.Right, BoundingBox.Bottom)), Microsoft.Xna.Framework.Graphics.Color.Green); boundingBatch.End(); }
public override void Draw(GameTime gameTime) { primBatch.Begin(PrimitiveType.TriangleList); //white text area primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Top), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Top), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Top), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Right, Bounds.Bottom), BackgroundColor); primBatch.AddVertex(new Vector2(Bounds.Left, Bounds.Bottom), BackgroundColor); primBatch.End(); GUIListBoxItem CurrentItem; if (ListOpen) { for (int i = topItem; i < topItem + numItems; i++) { CurrentItem = (GUIListBoxItem)Items[i]; CurrentItem.Draw(gameTime); } foreach (GUIComponent c in components) { c.Draw(gameTime); } } else { // Just draw title and open button currentItem.Draw(gameTime); OpenCloseList.Draw(gameTime); } }