public override void Draw(GameScreen gameScreen, GameTime gameTime) { base.Draw(gameScreen, gameTime); ScreenManager screenManager = gameScreen.ScreenManager; SpriteBatch spriteBatch = screenManager.SpriteBatch; if (Active) { Texture2D drawingTextue = ActiveTexture ?? screenManager.Game.Content.Load<Texture2D>("Images/GUI/CheckBoxX"); Vector2 textureSize = Size; textureSize.X -= BorderThickness; textureSize.Y -= BorderThickness; Vector2 texturePosition = Position; texturePosition.X += BorderThickness; texturePosition.Y += BorderThickness; Rectangle rectangle = new Rectangle((int) texturePosition.X, (int) texturePosition.Y, (int) textureSize.X - BorderThickness, (int) textureSize.Y - BorderThickness); spriteBatch.Draw(drawingTextue, rectangle, FillColor); } }
private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow, GameScreen[] screensToLoad) { _loadingIsSlow = loadingIsSlow; _screensToLoad = screensToLoad; Message = "Loading..."; TransitionOnTime = TimeSpan.FromSeconds(0.5); }
public void Draw(GameScreen gameScreen, Vector2 position, Vector2 dropdownSize, bool odd = true) { Vector2 labelSize = gameScreen.ScreenManager.SmallFont.MeasureString(Label); labelSize.X = dropdownSize.X; Rectangle rec = new Rectangle((int) position.X, (int) position.Y, (int) labelSize.X, (int) labelSize.Y); //Draw Rectangle gameScreen.ScreenManager.SpriteBatch.Draw(gameScreen.ScreenManager.BlankTexture, rec, Color.Black); //Draw Font gameScreen.ScreenManager.SpriteBatch.DrawString(gameScreen.ScreenManager.SmallFont, Label, position, Color.White); }
public void AddScreen(GameScreen screen) { screen.ScreenManager = this; screen.IsExiting = false; if (_isInitialized) { screen.Activate(false); } _screens.Add(screen); }
public void Draw(GameScreen gameScreen, GameTime gameTime) { SpriteBatch spriteBatch = gameScreen.ScreenManager.SpriteBatch; SpriteFont font = gameScreen.ScreenManager.Font; if (Size.X == 150f) { Size = font.MeasureString(Text); } spriteBatch.DrawString(font, Text, Position, Color); }
public void RemoveScreen(GameScreen screen) { if (_isInitialized) { screen.Unload(); } _screens.Remove(screen); _tempScreenList.Remove(screen); }
public void Update(GameScreen gameScreen, GameTime gameTime) { }
public float GetWidth(GameScreen gameScreen) { return Size.X; }
public float GetHeight(GameScreen gameScreen) { return Size.Y; }
public void Draw(GameScreen gameScreen, GameTime gameTime) { SpriteBatch spriteBatch = gameScreen.ScreenManager.SpriteBatch; SpriteFont font = gameScreen.ScreenManager.Font; _font = _font ?? font; Rectangle rec = new Rectangle((int) Position.X, (int) Position.Y, (int) Size.X, (int) Size.Y); var bgTexture = BackgroundTexture ?? gameScreen.ScreenManager.BlankTexture; var borderColor = (!_hasFocus) ? BorderColor : FocusColor; var borderTexture = BorderTexture ?? gameScreen.ScreenManager.BlankTexture; //Draw Rectangle spriteBatch.Draw(bgTexture, rec, FillColor); if (Text != string.Empty) { //Calculate Textposition Vector2 textSize = _font.MeasureString(Text); Vector2 textPosition = new Vector2(rec.Left + PaddingLeft, rec.Center.Y - textSize.Y/2 + BorderThickness/2); spriteBatch.DrawString(_font, Text, textPosition, TextColor); if (_hasFocus && gameTime.TotalGameTime.Seconds%2 == 0) { //Draw Cursor var cursorX = Position.X + PaddingLeft + CalculateXPositionFromCursor(_cursorPosition); Rectangle cursorRec = new Rectangle((int) cursorX, (int) Position.Y + 13, 2, (int) Size.Y - 20); spriteBatch.Draw(borderTexture, cursorRec, Color.Red); } } //Draw Selection Rectangle if (_selectionInProgress || (_selectionStart != 0 || _selectionEnd != 0)) { CheckedSelectionWrite(); var selectionEnd = _visibleSelectionEnd; var selectionStart = _visibleSelectionStart; Rectangle selectionRec = new Rectangle((int) (Position.X + PaddingLeft + CalculateXPositionFromCursor(selectionStart)), (int) Position.Y + 13, CalculateXPositionFromCursor(Math.Abs(selectionStart - selectionEnd)), (int) Size.Y - 20); spriteBatch.Draw(borderTexture, selectionRec, Color.Black*0.3f); } //Draw Border spriteBatch.Draw(borderTexture, new Rectangle(rec.Left, rec.Top, rec.Width, BorderThickness), borderColor); spriteBatch.Draw(borderTexture, new Rectangle(rec.Left, rec.Top, BorderThickness, rec.Height), borderColor); spriteBatch.Draw(borderTexture, new Rectangle(rec.Right - BorderThickness, rec.Top, BorderThickness, rec.Height), borderColor); spriteBatch.Draw(borderTexture, new Rectangle(rec.Left, rec.Bottom - BorderThickness, rec.Width, BorderThickness), borderColor); }
public void Update(GameScreen gameScreen, GameTime gameTime) { //Nothing to do here }
public void Update(GameScreen gameScreen, GameTime gameTime) { //todo: I don't know yet ^^ }
public virtual void Draw(GameScreen gameScreen, GameTime gameTime) { SpriteBatch spriteBatch = gameScreen.ScreenManager.SpriteBatch; SpriteFont font = gameScreen.ScreenManager.Font; if (_buttonTexture == null) { _buttonTexture = gameScreen.ScreenManager.Game.Content.Load<Texture2D>("Images/Game/Menu/btnBg"); } Rectangle rec = new Rectangle((int) Position.X, (int) Position.Y, (int) Size.X, (int) Size.Y); //Fill Button if (_isHovered) { spriteBatch.Draw(_buttonTexture, rec, HoverColor*Alpha); } else { spriteBatch.Draw(_buttonTexture, rec, FillColor*Alpha); } //Draw Border spriteBatch.Draw(_buttonTexture, new Rectangle(rec.Left, rec.Top, rec.Width, BorderThickness), BorderColor*Alpha); spriteBatch.Draw(_buttonTexture, new Rectangle(rec.Left, rec.Top, BorderThickness, rec.Height), BorderColor*Alpha); spriteBatch.Draw(_buttonTexture, new Rectangle(rec.Right - BorderThickness, rec.Top, BorderThickness, rec.Height), BorderColor*Alpha); spriteBatch.Draw(_buttonTexture, new Rectangle(rec.Left, rec.Bottom - BorderThickness, rec.Width, BorderThickness), BorderColor*Alpha); //Draw the Text centered in the button if (Text != "") { Vector2 textSize = font.MeasureString(Text); Vector2 textPosition = new Vector2(rec.Center.X, rec.Center.Y) - textSize/2f; textPosition.X = (int) textPosition.X; textPosition.Y = (int) textPosition.Y; spriteBatch.DrawString(font, Text, textPosition, TextColor*Alpha); } }
public void Draw(GameScreen gameScreen, GameTime gameTime) { SpriteBatch spriteBatch = gameScreen.ScreenManager.SpriteBatch; SpriteFont font = gameScreen.ScreenManager.Font; SpriteFont smallFont = gameScreen.ScreenManager.SmallFont; if (_dropDownBackground == null) { _dropDownBackground = gameScreen.ScreenManager.Game.Content.Load<Texture2D>("Images/Game/Menu/btnBg"); } //Draw DropDown InnerBox Rectangle rec = new Rectangle((int) Position.X, (int) Position.Y, (int) Size.X, (int) Size.Y); spriteBatch.Draw(_dropDownBackground, rec, Color.Gray); //Draw the Text centered in the DropDown Vector2 textSize = font.MeasureString(SelectedItem.Label); Vector2 textPosition = new Vector2(rec.Center.X, rec.Center.Y) - textSize / 2f; textPosition.X = (int)textPosition.X; textPosition.Y = (int)textPosition.Y; spriteBatch.DrawString(font, SelectedItem.Label, textPosition, Color.White); //Draw DropDown Content if(!_collapsed && Items.Count != 0) { Vector2 position = Position; _dropDownItemSize = smallFont.MeasureString(Items[0].Label); //Initial Position position.Y += Size.Y; for (int i = 0; i < Items.Count; i++) { DropDownItem item = Items[i]; //Enable Zebra Coloring bool even = (i%2 == 0); item.Draw(gameScreen, position, Size, even); position.Y += _dropDownItemSize.Y; } } }