public override void Draw() { WidgetUtils.DrawPanel(Background, RenderBounds); }
public override void DrawOuter() { if (!IsVisible()) { return; } var rb = RenderBounds; var ScrollbarHeight = rb.Height - 2 * ScrollbarWidth; var thumbHeight = ContentHeight == 0 ? 0 : Math.Max(MinimumThumbSize, (int)(ScrollbarHeight * Math.Min(rb.Height * 1f / ContentHeight, 1f))); var thumbOrigin = rb.Y + ScrollbarWidth + (int)((ScrollbarHeight - thumbHeight) * (-1f * currentListOffset / (ContentHeight - rb.Height))); if (thumbHeight == ScrollbarHeight) { thumbHeight = 0; } backgroundRect = new Rectangle(rb.X, rb.Y, rb.Width - ScrollbarWidth + 1, rb.Height); upButtonRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Y, ScrollbarWidth, ScrollbarWidth); downButtonRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Bottom - ScrollbarWidth, ScrollbarWidth, ScrollbarWidth); scrollbarRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Y + ScrollbarWidth - 1, ScrollbarWidth, ScrollbarHeight + 2); thumbRect = new Rectangle(rb.Right - ScrollbarWidth, thumbOrigin, ScrollbarWidth, thumbHeight); var upHover = Ui.MouseOverWidget == this && upButtonRect.Contains(Viewport.LastMousePos); UpDisabled = thumbHeight == 0 || currentListOffset >= 0; var downHover = Ui.MouseOverWidget == this && downButtonRect.Contains(Viewport.LastMousePos); DownDisabled = thumbHeight == 0 || currentListOffset <= Bounds.Height - ContentHeight; var thumbHover = Ui.MouseOverWidget == this && thumbRect.Contains(Viewport.LastMousePos); WidgetUtils.DrawPanel(Background, backgroundRect); WidgetUtils.DrawPanel(Background, scrollbarRect); ButtonWidget.DrawBackground(Button, upButtonRect, UpDisabled, UpPressed, upHover, false); ButtonWidget.DrawBackground(Button, downButtonRect, DownDisabled, DownPressed, downHover, false); if (thumbHeight > 0) { ButtonWidget.DrawBackground(Button, thumbRect, false, HasMouseFocus && thumbHover, thumbHover, false); } var upOffset = !UpPressed || UpDisabled ? 4 : 4 + ButtonDepth; var downOffset = !DownPressed || DownDisabled ? 4 : 4 + ButtonDepth; WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", UpPressed || UpDisabled ? "up_pressed" : "up_arrow"), new float2(upButtonRect.Left + upOffset, upButtonRect.Top + upOffset)); WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", DownPressed || DownDisabled ? "down_pressed" : "down_arrow"), new float2(downButtonRect.Left + downOffset, downButtonRect.Top + downOffset)); Game.Renderer.EnableScissor(backgroundRect.InflateBy(-1, -1, -1, -1)); foreach (var child in Children) { child.DrawOuter(); } Game.Renderer.DisableScissor(); }
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; } } } }