public override void Draw() { var map = Map(); if (map == null) { return; } if (lastMap != map) { lastMap = map; // Update image data var preview = PreviewCache[map]; if (mapChooserSheet == null || mapChooserSheet.Size.Width != preview.Width || mapChooserSheet.Size.Height != preview.Height) { mapChooserSheet = new Sheet(new Size(preview.Width, preview.Height)); } mapChooserSheet.Texture.SetData(preview); mapChooserSprite = new Sprite(mapChooserSheet, new Rectangle(0, 0, map.Bounds.Width, map.Bounds.Height), TextureChannel.Alpha); } // Update map rect PreviewScale = Math.Min(RenderBounds.Width * 1.0f / map.Bounds.Width, RenderBounds.Height * 1.0f / map.Bounds.Height); var size = Math.Max(map.Bounds.Width, map.Bounds.Height); var dw = (int)(PreviewScale * (size - map.Bounds.Width)) / 2; var dh = (int)(PreviewScale * (size - map.Bounds.Height)) / 2; MapRect = new Rectangle(RenderBounds.X + dw, RenderBounds.Y + dh, (int)(map.Bounds.Width * PreviewScale), (int)(map.Bounds.Height * PreviewScale)); Game.Renderer.RgbaSpriteRenderer.DrawSprite(mapChooserSprite, new float2(MapRect.Location), new float2(MapRect.Size)); if (ShowSpawnPoints) { var colors = SpawnColors(); foreach (var p in map.GetSpawnPoints()) { var owned = colors.ContainsKey(p); var pos = ConvertToPreview(p); var sprite = ChromeProvider.GetImage("spawnpoints", owned ? "owned" : "unowned"); var offset = new int2(-sprite.bounds.Width / 2, -sprite.bounds.Height / 2); if (owned) { WidgetUtils.FillRectWithColor(new Rectangle(pos.X + offset.X + 2, pos.Y + offset.Y + 2, 12, 12), colors[p]); } Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos + offset); } } }
public override void Draw() { base.Draw(); var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0); var image = ChromeProvider.GetImage("scrollbar", IsDisabled() ? "down_pressed" : "down_arrow"); var rb = RenderBounds; WidgetUtils.DrawRGBA(image, stateOffset + new float2(rb.Right - rb.Height + 4, rb.Top + (rb.Height - image.bounds.Height) / 2)); WidgetUtils.FillRectWithColor(new Rectangle(stateOffset.X + rb.Right - rb.Height, stateOffset.Y + rb.Top + 3, 1, rb.Height - 6), Color.White); }
public override void Draw() { WidgetUtils.FillRectWithColor(RenderBounds, GetColor()); }
public override void Draw() { var map = Map(); if (map == null) { return; } // Preview unavailable if (!Loaded) { GeneratePreview(); return; } if (lastMap != map) { lastMap = map; // Update image data Bitmap preview; lock (syncRoot) preview = Previews[map.Uid]; if (mapChooserSheet == null || mapChooserSheet.Size.Width != preview.Width || mapChooserSheet.Size.Height != preview.Height) { mapChooserSheet = new Sheet(new Size(preview.Width, preview.Height)); } mapChooserSheet.Texture.SetData(preview); mapChooserSprite = new Sprite(mapChooserSheet, new Rectangle(0, 0, map.Bounds.Width, map.Bounds.Height), TextureChannel.Alpha); } // Update map rect PreviewScale = Math.Min(RenderBounds.Width * 1.0f / map.Bounds.Width, RenderBounds.Height * 1.0f / map.Bounds.Height); var size = Math.Max(map.Bounds.Width, map.Bounds.Height); var dw = (int)(PreviewScale * (size - map.Bounds.Width)) / 2; var dh = (int)(PreviewScale * (size - map.Bounds.Height)) / 2; MapRect = new Rectangle(RenderBounds.X + dw, RenderBounds.Y + dh, (int)(map.Bounds.Width * PreviewScale), (int)(map.Bounds.Height * PreviewScale)); Game.Renderer.RgbaSpriteRenderer.DrawSprite(mapChooserSprite, new float2(MapRect.Location), new float2(MapRect.Size)); TooltipSpawnIndex = -1; if (ShowSpawnPoints) { var colors = SpawnClients().ToDictionary(c => c.Key, c => c.Value.Color.RGB); var spawnPoints = map.GetSpawnPoints().ToList(); foreach (var p in spawnPoints) { var owned = colors.ContainsKey(p); var pos = ConvertToPreview(p); var sprite = ChromeProvider.GetImage("lobby-bits", owned ? "spawn-claimed" : "spawn-unclaimed"); var offset = new int2(-sprite.bounds.Width / 2, -sprite.bounds.Height / 2); if (owned) { WidgetUtils.FillRectWithColor(new Rectangle(pos.X + offset.X + 2, pos.Y + offset.Y + 2, 12, 12), colors[p]); } Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos + offset); if ((pos - Viewport.LastMousePos).LengthSquared < 64) { TooltipSpawnIndex = spawnPoints.IndexOf(p) + 1; } } } }