public static void DrawSpawn(MapSpawnValues spawn, ISpriteBatch spriteBatch, IDrawableMap map, Font font) { var spawnArea = spawn.SpawnArea; // Only draw if it does not cover the whole map if (!spawnArea.X.HasValue && !spawnArea.Y.HasValue && !spawnArea.Width.HasValue && !spawnArea.Height.HasValue) return; // Draw spawn area Vector2 cameraOffset = map.Camera.Min; Rectangle rect = spawnArea.ToRectangle(map); rect.X -= (int)cameraOffset.X; rect.Y -= (int)cameraOffset.Y; RenderRectangle.Draw(spriteBatch, rect, new Color(0, 255, 0, 75), new Color(0, 0, 0, 125), 2); // Draw name CharacterTemplate charTemp = CharacterTemplateManager.Instance[spawn.CharacterTemplateID]; if (charTemp != null) { string text = string.Format("{0}x {1} [{2}]", spawn.SpawnAmount, charTemp.TemplateTable.Name, spawn.CharacterTemplateID); Vector2 textPos = new Vector2(rect.X, rect.Y); textPos -= new Vector2(0, font.MeasureString(text).Y); textPos = textPos.Round(); spriteBatch.DrawStringShaded(font, text, textPos, Color.White, Color.Black); } }
public static void DrawSpawn(MapSpawnValues spawn, ISpriteBatch spriteBatch, IDrawableMap map, Font font) { var spawnArea = spawn.SpawnArea; // Only draw if it does not cover the whole map if (!spawnArea.X.HasValue && !spawnArea.Y.HasValue && !spawnArea.Width.HasValue && !spawnArea.Height.HasValue) { return; } // Draw spawn area Vector2 cameraOffset = map.Camera.Min; Rectangle rect = spawnArea.ToRectangle(map); rect.X -= (int)cameraOffset.X; rect.Y -= (int)cameraOffset.Y; RenderRectangle.Draw(spriteBatch, rect, new Color(0, 255, 0, 75), new Color(0, 0, 0, 125), 2); // Draw name CharacterTemplate charTemp = CharacterTemplateManager.Instance[spawn.CharacterTemplateID]; if (charTemp != null) { string text = string.Format("{0}x {1} [{2}]", spawn.SpawnAmount, charTemp.TemplateTable.Name, spawn.CharacterTemplateID); Vector2 textPos = new Vector2(rect.X, rect.Y); textPos -= new Vector2(0, font.MeasureString(text).Y); textPos = textPos.Round(); spriteBatch.DrawStringShaded(font, text, textPos, Color.White, Color.Black); } }
/// <summary> /// Draws the text for the control. /// </summary> /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw to.</param> /// <param name="position">Position relative to the Control to draw the text.</param> protected override void DrawText(ISpriteBatch spriteBatch, Vector2 position) { if (string.IsNullOrEmpty(Text) || Font == null) { return; } spriteBatch.DrawStringShaded(Font, Text, ScreenPosition + position, ForeColor, _textBorderColor); }
/// <summary> /// Draws the item amount string for this slot. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param> /// <param name="amount">The amount value to draw.</param> protected virtual void DrawItemAmount(ISpriteBatch spriteBatch, int amount) { if (amount <= 1) { return; } var font = GetItemAmountFont(); var foreColor = GetItemAmountFontForeColor(); var backColor = GetItemAmountFontShadowColor(); spriteBatch.DrawStringShaded(font, amount.ToString(), ScreenPosition, foreColor, backColor); }
/// <summary> /// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param> /// <param name="imap">The <see cref="IDrawableMap"/> being drawn.</param> protected override void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap imap) { base.HandleBeforeDrawMapGUI(spriteBatch, imap); if (!IsEnabled) { return; } var map = imap as EditorMap; if (map == null) { return; } var camera = map.Camera; if (camera == null) { return; } // Only draw for the map under the cursor if (map != _mouseOverMap) { return; } if (IsSelecting) { // Draw the selection area var a = camera.ToScreen(_selectionStart); var b = camera.ToScreen(_selectionEnd); if (a.QuickDistance(b) > _minSelectionAreaDrawSize) { var rect = Rectangle.FromPoints(a, b); RenderRectangle.Draw(spriteBatch, rect, _selectionAreaColorInner, _selectionAreaColorOuter); } } else { // Draw the tooltip var font = ToolTipFont; if (_toolTipObject != null && _toolTip != null && font != null) { spriteBatch.DrawStringShaded(font, _toolTip, _toolTipPos, Color.White, Color.Black); } } }
/// <summary> /// Performs the default menu background drawing. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param> protected virtual void DrawBackground(ISpriteBatch spriteBatch) { // Draw the background if (_background != null) { var bgDest = new Rectangle(0, 0, ScreenManager.ScreenSize.X, ScreenManager.ScreenSize.Y); _background.Draw(spriteBatch, bgDest); } // Draw the title if (!string.IsNullOrEmpty(_title)) { spriteBatch.DrawStringShaded(GameScreenHelper.DefaultMenuTitleFont, Title, _titlePosition, _titleColor, _titleBorderColor); } }
public static bool DrawMapGrhTooltip(ISpriteBatch spriteBatch, IDrawableMap map, MapGrh mapGrh, Vector2 worldPos) { if (mapGrh == null || mapGrh.Grh == null || mapGrh.Grh.GrhData == null) { return(false); } Vector2 drawPos = worldPos - map.Camera.Min; var font = GlobalState.Instance.DefaultRenderFont; string txt = mapGrh.Grh.GrhData.Categorization.ToString(); Vector2 txtSize = font.MeasureString(txt); Vector2 txtPos = drawPos.Max(Vector2.Zero).Min(map.Camera.Size - txtSize); spriteBatch.DrawStringShaded(font, txt, txtPos, Color.White, Color.Black); return(true); }
/// <summary> /// Draws the <see cref="Control"/>. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param> protected override void DrawControl(ISpriteBatch spriteBatch) { base.DrawControl(spriteBatch); // Draw the progress bar float elapsedTime = TickCount.Now - _castStartTime; var percent = elapsedTime / _currentCastTime; var startDrawPos = ScreenPosition + new Vector2(Border.LeftWidth, Border.TopHeight); var drawWidth = ClientSize.X * Math.Min(percent, 1); var r = new Rectangle(startDrawPos.X, startDrawPos.Y, drawWidth, ClientSize.Y); RenderRectangle.Draw(spriteBatch, r, new Color(255, 0, 0, 200)); // Draw the name spriteBatch.DrawStringShaded(Font, Text, Position + _textOffset, ForeColor, Color.Black); // Stop drawing if we hit 100% if (percent >= 1.00f) StopCasting(); }
/// <summary> /// Draws the <see cref="Control"/>. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param> protected override void DrawControl(ISpriteBatch spriteBatch) { base.DrawControl(spriteBatch); // Draw the progress bar float elapsedTime = TickCount.Now - _castStartTime; var percent = elapsedTime / _currentCastTime; var startDrawPos = ScreenPosition + new Vector2(Border.LeftWidth, Border.TopHeight); var drawWidth = ClientSize.X * Math.Min(percent, 1); var r = new Rectangle(startDrawPos.X, startDrawPos.Y, drawWidth, ClientSize.Y); RenderRectangle.Draw(spriteBatch, r, new Color(255, 0, 0, 200)); // Draw the name spriteBatch.DrawStringShaded(Font, Text, Position + _textOffset, ForeColor, Color.Black); // Stop drawing if we hit 100% if (percent >= 1.00f) { StopCasting(); } }
/// <summary> /// Draws the <see cref="Control"/>. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param> protected override void DrawControl(ISpriteBatch spriteBatch) { base.DrawControl(spriteBatch); var item = Item; if (item == null) { return; } // Draw the item in the center of the slot var offset = (_itemSize - item.Grh.Size) / 2f; item.Draw(spriteBatch, ScreenPosition + offset.Round()); // Draw the amount if (item.Amount > 1) { spriteBatch.DrawStringShaded(GUIManager.Font, item.Amount.ToString(), ScreenPosition, ItemAmountForeColor, ItemAmountBackColor); } }
/// <summary> /// Draws the Character's name. /// </summary> /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param> /// <param name="font">The <see cref="Font"/> to use for the name text. May be null.</param> protected virtual void DrawName(ISpriteBatch sb, Font font) { // Ensure we have a valid font and name first if (font == null || string.IsNullOrEmpty(Name)) { return; } // Get the size of the name var nameSize = GetNameSize(); // Get the character's center var namePos = DrawPosition; // Center horizontally namePos.X += Size.X / 2f; // Move the left side of the name to the center of the character namePos.X -= (float)Math.Round(nameSize.X / 2f); // Move the center to the center of the character // Move up above the character's head (height of the text, with a little extra offset) namePos.Y -= nameSize.Y + 4f; // Draw sb.DrawStringShaded(font, Name, namePos, Color.Green, Color.Black); }
/// <summary> /// Draws the Character's name. /// </summary> /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param> /// <param name="font">The <see cref="Font"/> to use for the name text. May be null.</param> protected virtual void DrawName(ISpriteBatch sb, Font font) { // Ensure we have a valid font and name first if (font == null || string.IsNullOrEmpty(Name)) { return; } // Get the size of the name var nameSize = GetNameSize(); // Get the character's center var namePos = DrawPosition; // Center horizontally namePos.X += Size.X / 2f; // Move the left side of the name to the center of the character namePos.X -= (float)Math.Round(nameSize.X / 2f); // Move the center to the center of the character // Move below the character namePos.Y -= 10 + (CharacterSprite.SpriteSize.Y - Size.Y); // Draw sb.DrawStringShaded(font, Name, namePos, Color.White, Color.Black); }
/// <summary> /// Draws the Character's name. /// </summary> /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param> /// <param name="font">The <see cref="Font"/> to use for the name text. May be null.</param> protected virtual void DrawName(ISpriteBatch sb, Font font) { // Ensure we have a valid font and name first if (font == null || string.IsNullOrEmpty(Name)) return; // Get the size of the name var nameSize = GetNameSize(); // Get the character's center var namePos = DrawPosition; // Center horizontally namePos.X += Size.X / 2f; // Move the left side of the name to the center of the character namePos.X -= (float)Math.Round(nameSize.X / 2f); // Move the center to the center of the character // Move up above the character's head (height of the text, with a little extra offset) namePos.Y -= nameSize.Y + 4f; // Draw sb.DrawStringShaded(font, Name, namePos, Color.Green, Color.Black); }
/// <summary> /// Draws the <see cref="Control"/>. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param> protected override void DrawControl(ISpriteBatch spriteBatch) { base.DrawControl(spriteBatch); var item = Item; if (item == null) return; // Draw the item in the center of the slot var offset = (_itemSize - item.Grh.Size) / 2f; item.Draw(spriteBatch, ScreenPosition + offset.Round()); // Draw the amount if (item.Amount > 1) spriteBatch.DrawStringShaded(GUIManager.Font, item.Amount.ToString(), ScreenPosition, ItemAmountForeColor, ItemAmountBackColor); }
/// <summary> /// Draws the Character's name. /// </summary> /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param> /// <param name="font">The <see cref="Font"/> to use for the name text. May be null.</param> protected virtual void DrawName(ISpriteBatch sb, Font font) { // Ensure we have a valid font and name first if (font == null || string.IsNullOrEmpty(Name)) return; // Get the size of the name var nameSize = GetNameSize(); // Get the character's center var namePos = DrawPosition; // Center horizontally namePos.X += Size.X / 2f; // Move the left side of the name to the center of the character namePos.X -= (float)Math.Round(nameSize.X / 2f); // Move the center to the center of the character // Move below the character namePos.Y -= 10 + (CharacterSprite.SpriteSize.Y - Size.Y); // Draw sb.DrawStringShaded(font, Name, namePos, Color.White, Color.Black); }
/// <summary> /// Performs the default menu background drawing. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param> protected virtual void DrawBackground(ISpriteBatch spriteBatch) { // Draw the background if (_background != null) { var bgDest = new Rectangle(0, 0, (int)ScreenManager.ScreenSize.X, (int)ScreenManager.ScreenSize.Y); _background.Draw(spriteBatch, bgDest); } // Draw the title if (!string.IsNullOrEmpty(_title)) spriteBatch.DrawStringShaded(GameScreenHelper.DefaultMenuTitleFont, Title, _titlePosition, _titleColor, _titleBorderColor); }
/// <summary> /// Draws the text for the control. /// </summary> /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw to.</param> /// <param name="position">Position relative to the Control to draw the text.</param> protected override void DrawText(ISpriteBatch spriteBatch, Vector2 position) { if (string.IsNullOrEmpty(Text) || Font == null) return; spriteBatch.DrawStringShaded(Font, Text, ScreenPosition + position, ForeColor, _textBorderColor); }
/// <summary> /// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param> /// <param name="imap">The <see cref="IDrawableMap"/> being drawn.</param> protected override void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap imap) { base.HandleBeforeDrawMapGUI(spriteBatch, imap); var map = imap as EditorMap; if (map == null) return; var camera = map.Camera; if (camera == null) return; // Only draw for the map under the cursor if (map != _mouseOverMap) return; if (IsSelecting) { // Draw the selection area var a = camera.ToScreen(_selectionStart); var b = camera.ToScreen(_selectionEnd); if (a.QuickDistance(b) > _minSelectionAreaDrawSize) { var rect = Rectangle.FromPoints(a, b); RenderRectangle.Draw(spriteBatch, rect, _selectionAreaColorInner, _selectionAreaColorOuter); } } else { // Draw the tooltip var font = ToolTipFont; if (_toolTipObject != null && _toolTip != null && font != null) spriteBatch.DrawStringShaded(font, _toolTip, _toolTipPos, Color.White, Color.Black); } }
public static bool DrawMapGrhTooltip(ISpriteBatch spriteBatch, IDrawableMap map, MapGrh mapGrh, Vector2 worldPos) { if (mapGrh == null || mapGrh.Grh == null || mapGrh.Grh.GrhData == null) return false; Vector2 drawPos = worldPos - map.Camera.Min; var font = GlobalState.Instance.DefaultRenderFont; string txt = mapGrh.Grh.GrhData.Categorization.ToString(); Vector2 txtSize = font.MeasureString(txt); Vector2 txtPos = drawPos.Max(Vector2.Zero).Min(map.Camera.Size - txtSize); spriteBatch.DrawStringShaded(font, txt, txtPos, Color.White, Color.Black); return true; }