pass WorldRenderer to Widget.Draw, DrawInner
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Widgets
|
||||
Rectangle backgroundRect;
|
||||
Rectangle scrollbarRect;
|
||||
|
||||
public ListBoxWidget() : base() {}
|
||||
public ListBoxWidget() : base() {}
|
||||
protected ListBoxWidget(ListBoxWidget other)
|
||||
: base(other)
|
||||
{
|
||||
@@ -44,47 +44,47 @@ namespace OpenRA.Widgets
|
||||
DownPressed = other.DownPressed;
|
||||
}
|
||||
|
||||
public override void DrawInner() {}
|
||||
public override void Draw()
|
||||
{
|
||||
if (!IsVisible())
|
||||
return;
|
||||
|
||||
backgroundRect = new Rectangle(RenderBounds.X, RenderBounds.Y, RenderBounds.Width - ScrollbarWidth, RenderBounds.Height);
|
||||
upButtonRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Y, ScrollbarWidth, ScrollbarWidth);
|
||||
downButtonRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Bottom - ScrollbarWidth, ScrollbarWidth, ScrollbarWidth);
|
||||
scrollbarRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Y + ScrollbarWidth, ScrollbarWidth, RenderBounds.Height - 2 * ScrollbarWidth);
|
||||
|
||||
string upButtonBg = (UpPressed) ? "dialog3" : "dialog2";
|
||||
string downButtonBg = (DownPressed) ? "dialog3" : "dialog2";
|
||||
string scrollbarBg = "dialog3";
|
||||
|
||||
WidgetUtils.DrawPanel(Background, backgroundRect);
|
||||
WidgetUtils.DrawPanel(upButtonBg, upButtonRect);
|
||||
WidgetUtils.DrawPanel(downButtonBg, downButtonRect);
|
||||
WidgetUtils.DrawPanel(scrollbarBg, scrollbarRect);
|
||||
|
||||
var upOffset = UpPressed ? 4 : 3;
|
||||
var downOffset = DownPressed ? 4 : 3;
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", "up_arrow"),
|
||||
new float2(upButtonRect.Left + upOffset, upButtonRect.Top + upOffset));
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", "down_arrow"),
|
||||
new float2(downButtonRect.Left + downOffset, downButtonRect.Top + downOffset));
|
||||
|
||||
Game.Renderer.EnableScissor(backgroundRect.X, backgroundRect.Y + HeaderHeight, backgroundRect.Width, backgroundRect.Height - HeaderHeight);
|
||||
|
||||
foreach (var child in Children)
|
||||
child.Draw();
|
||||
|
||||
Game.Renderer.DisableScissor();
|
||||
public override void DrawInner( WorldRenderer wr ) {}
|
||||
public override void Draw( WorldRenderer wr )
|
||||
{
|
||||
if (!IsVisible())
|
||||
return;
|
||||
|
||||
backgroundRect = new Rectangle(RenderBounds.X, RenderBounds.Y, RenderBounds.Width - ScrollbarWidth, RenderBounds.Height);
|
||||
upButtonRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Y, ScrollbarWidth, ScrollbarWidth);
|
||||
downButtonRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Bottom - ScrollbarWidth, ScrollbarWidth, ScrollbarWidth);
|
||||
scrollbarRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Y + ScrollbarWidth, ScrollbarWidth, RenderBounds.Height - 2 * ScrollbarWidth);
|
||||
|
||||
string upButtonBg = (UpPressed) ? "dialog3" : "dialog2";
|
||||
string downButtonBg = (DownPressed) ? "dialog3" : "dialog2";
|
||||
string scrollbarBg = "dialog3";
|
||||
|
||||
WidgetUtils.DrawPanel(Background, backgroundRect);
|
||||
WidgetUtils.DrawPanel(upButtonBg, upButtonRect);
|
||||
WidgetUtils.DrawPanel(downButtonBg, downButtonRect);
|
||||
WidgetUtils.DrawPanel(scrollbarBg, scrollbarRect);
|
||||
|
||||
var upOffset = UpPressed ? 4 : 3;
|
||||
var downOffset = DownPressed ? 4 : 3;
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", "up_arrow"),
|
||||
new float2(upButtonRect.Left + upOffset, upButtonRect.Top + upOffset));
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", "down_arrow"),
|
||||
new float2(downButtonRect.Left + downOffset, downButtonRect.Top + downOffset));
|
||||
|
||||
Game.Renderer.EnableScissor(backgroundRect.X, backgroundRect.Y + HeaderHeight, backgroundRect.Width, backgroundRect.Height - HeaderHeight);
|
||||
|
||||
foreach (var child in Children)
|
||||
child.Draw( wr );
|
||||
|
||||
Game.Renderer.DisableScissor();
|
||||
}
|
||||
|
||||
public override int2 ChildOrigin { get { return RenderOrigin + new int2(0, (int)ListOffset); } }
|
||||
|
||||
public override Rectangle GetEventBounds()
|
||||
{
|
||||
return EventBounds;
|
||||
}
|
||||
|
||||
public override Rectangle GetEventBounds()
|
||||
{
|
||||
return EventBounds;
|
||||
}
|
||||
|
||||
public override void Tick ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user