diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index 13a93ab190..d47d3fd163 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -68,7 +68,7 @@ namespace OpenRA.Graphics bool gameWasStarted = false; public void DrawRegions( World world ) { -// Timer.Time( "DrawRegions start" ); + Timer.Time( "DrawRegions start" ); world.WorldRenderer.palette.Update( world.WorldActor.traits.WithInterface()); @@ -78,7 +78,7 @@ namespace OpenRA.Graphics renderer.BeginFrame(r1, r2, scrollPosition.ToInt2()); world.WorldRenderer.Draw(); -// Timer.Time( "worldRenderer: {0}" ); + Timer.Time( "worldRenderer: {0}" ); if( Game.orderManager.GameStarted && world.LocalPlayer != null) { if (!gameWasStarted) @@ -88,6 +88,7 @@ namespace OpenRA.Graphics } Game.chrome.Draw( world ); + Timer.Time( "chromedraw: {0}" ); } else { @@ -128,6 +129,7 @@ namespace OpenRA.Graphics lastConnectionState = state; + Timer.Time( "connectionState: {0}" ); } Game.chrome.DrawWidgets(world); if (Chrome.rootWidget.GetWidget("SERVER_LOBBY").Visible) @@ -135,19 +137,19 @@ namespace OpenRA.Graphics else if (Chrome.rootWidget.GetWidget("MAP_CHOOSER").Visible) Game.chrome.DrawMapChooser(); -// Timer.Time( "widgets: {0}" ); + Timer.Time( "widgets: {0}" ); var cursorName = Game.chrome.HitTest(mousePos) ? "default" : Game.controller.ChooseCursor( world ); var c = new Cursor(cursorName); cursorRenderer.DrawSprite(c.GetSprite((int)cursorFrame), mousePos + Location - c.GetHotspot(), "cursor"); -// Timer.Time( "cursors: {0}" ); + Timer.Time( "cursors: {0}" ); renderer.RgbaSpriteRenderer.Flush(); renderer.SpriteRenderer.Flush(); renderer.WorldSpriteRenderer.Flush(); renderer.EndFrame(); -// Timer.Time( "endFrame: {0}" ); + Timer.Time( "endFrame: {0}" ); } public void Tick() diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 51ec67cf28..88f0ead866 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -29,7 +29,7 @@ namespace OpenRA.Traits { public class ShroudInfo : ITraitInfo { - public object Create(Actor self) { return new Shroud(self, this); } + public object Create(Actor self) { return new Shroud(self); } } public class Shroud @@ -41,7 +41,7 @@ namespace OpenRA.Traits public Rectangle? exploredBounds; public event Action Dirty = () => { }; - public Shroud(Actor self, ShroudInfo info) + public Shroud(Actor self) { map = self.World.Map; visibleCells = new int[map.MapSize.X, map.MapSize.Y]; diff --git a/OpenRA.Game/Widgets/BackgroundWidget.cs b/OpenRA.Game/Widgets/BackgroundWidget.cs index 81cdc9990a..3c5f75e82e 100644 --- a/OpenRA.Game/Widgets/BackgroundWidget.cs +++ b/OpenRA.Game/Widgets/BackgroundWidget.cs @@ -25,17 +25,11 @@ namespace OpenRA.Widgets { public readonly string Background = "dialog"; - public override void Draw(World world) + public override void DrawInner(World world) { - if (!IsVisible()) - { - base.Draw(world); - return; - } var pos = DrawPosition(); var rect = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height); WidgetUtils.DrawPanel(Background, rect); - base.Draw(world); } public BackgroundWidget() : base() { } diff --git a/OpenRA.Game/Widgets/BuildPaletteWidget.cs b/OpenRA.Game/Widgets/BuildPaletteWidget.cs index d6600f594f..9d0073077d 100644 --- a/OpenRA.Game/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Game/Widgets/BuildPaletteWidget.cs @@ -171,7 +171,7 @@ namespace OpenRA.Widgets return false; } - public override void Draw (World world) + public override void DrawInner(World world) { int paletteHeight = DrawPalette(world, currentTab); DrawBuildTabs(world, paletteHeight); @@ -181,11 +181,6 @@ namespace OpenRA.Widgets { string paletteCollection = "palette-" + world.LocalPlayer.Country.Race; - if (!Visible) - { - base.Draw(world); - return 0; - } buttons.Clear(); diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index 808282ee49..31ed278ea9 100644 --- a/OpenRA.Game/Widgets/ButtonWidget.cs +++ b/OpenRA.Game/Widgets/ButtonWidget.cs @@ -79,13 +79,8 @@ namespace OpenRA.Widgets return false; } - public override void Draw(World world) + public override void DrawInner(World world) { - if (!IsVisible()) - { - base.Draw(world); - return; - } var pos = DrawPosition(); var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0); @@ -97,8 +92,6 @@ namespace OpenRA.Widgets new int2( pos.X + Bounds.Width / 2, pos.Y + Bounds.Height / 2) - new int2(Game.chrome.renderer.BoldFont.Measure(text).X / 2, Game.chrome.renderer.BoldFont.Measure(text).Y / 2) + stateOffset, Color.White); - - base.Draw(world); } public override Widget Clone() diff --git a/OpenRA.Game/Widgets/CheckboxWidget.cs b/OpenRA.Game/Widgets/CheckboxWidget.cs index 0f893af25e..656cb77174 100644 --- a/OpenRA.Game/Widgets/CheckboxWidget.cs +++ b/OpenRA.Game/Widgets/CheckboxWidget.cs @@ -28,13 +28,8 @@ namespace OpenRA.Widgets public string Text = ""; public Func Checked = () => {return false;}; - public override void Draw(World world) + public override void DrawInner(World world) { - if (!IsVisible()) - { - base.Draw(world); - return; - } var pos = DrawPosition(); var rect = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height); WidgetUtils.DrawPanel("dialog3", new Rectangle(rect.Location, @@ -56,8 +51,6 @@ namespace OpenRA.Widgets Color.White); Game.chrome.lineRenderer.Flush(); } - - base.Draw(world); } public CheckboxWidget() : base() { } diff --git a/OpenRA.Game/Widgets/ColorBlockWidget.cs b/OpenRA.Game/Widgets/ColorBlockWidget.cs index 300ba78545..72f4341425 100644 --- a/OpenRA.Game/Widgets/ColorBlockWidget.cs +++ b/OpenRA.Game/Widgets/ColorBlockWidget.cs @@ -44,18 +44,11 @@ namespace OpenRA.Widgets return new ColorBlockWidget(this); } - public override void Draw(World world) + public override void DrawInner(World world) { - if (!IsVisible()) - { - base.Draw(world); - return; - } - var pos = DrawPosition(); var paletteRect = new RectangleF(pos.X + Game.viewport.Location.X, pos.Y + Game.viewport.Location.Y, Bounds.Width, Bounds.Height); Game.chrome.lineRenderer.FillRect(paletteRect, GetColor()); - base.Draw(world); } } } diff --git a/OpenRA.Game/Widgets/LabelWidget.cs b/OpenRA.Game/Widgets/LabelWidget.cs index 7796aa4be9..35588ac5e9 100644 --- a/OpenRA.Game/Widgets/LabelWidget.cs +++ b/OpenRA.Game/Widgets/LabelWidget.cs @@ -52,14 +52,8 @@ namespace OpenRA.Widgets GetText = (other as LabelWidget).GetText; } - public override void Draw(World world) + public override void DrawInner(World world) { - if (!IsVisible()) - { - base.Draw(world); - return; - } - var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont; var text = GetText(); int2 textSize = font.Measure(text); @@ -69,7 +63,6 @@ namespace OpenRA.Widgets position += new int2((Bounds.Width - textSize.X)/2, 0); font.DrawText(text, position, Color.White); - base.Draw(world); } public override Widget Clone() diff --git a/OpenRA.Game/Widgets/MapPreviewWidget.cs b/OpenRA.Game/Widgets/MapPreviewWidget.cs index d53af2d132..ad4a84b7c3 100755 --- a/OpenRA.Game/Widgets/MapPreviewWidget.cs +++ b/OpenRA.Game/Widgets/MapPreviewWidget.cs @@ -25,7 +25,7 @@ namespace OpenRA.Widgets public override Widget Clone() { return new MapPreviewWidget(this); } - public override void Draw( World world ) + public override void DrawInner( World world ) { var map = Game.chrome.currentMap; if( map == null ) return; @@ -55,7 +55,6 @@ namespace OpenRA.Widgets new float2( mapRect.Size ) ); DrawSpawnPoints( map, new Rectangle(pos.X, pos.Y, Parent.Bounds.Width, Parent.Bounds.Height ), world ); - base.Draw( world ); } void DrawSpawnPoints(MapStub map, Rectangle container, World world) diff --git a/OpenRA.Game/Widgets/MoneyBinWidget.cs b/OpenRA.Game/Widgets/MoneyBinWidget.cs index ecf4d4e892..36cd635e83 100644 --- a/OpenRA.Game/Widgets/MoneyBinWidget.cs +++ b/OpenRA.Game/Widgets/MoneyBinWidget.cs @@ -41,7 +41,7 @@ namespace OpenRA.Widgets public override Widget Clone() { return new MoneyBinWidget(this); } - public override void Draw(World world) + public override void DrawInner(World world) { var playerResources = world.LocalPlayer.PlayerActor.traits.Get(); diff --git a/OpenRA.Game/Widgets/PerfGraphWidget.cs b/OpenRA.Game/Widgets/PerfGraphWidget.cs index 116055148a..e66fc132b3 100644 --- a/OpenRA.Game/Widgets/PerfGraphWidget.cs +++ b/OpenRA.Game/Widgets/PerfGraphWidget.cs @@ -32,13 +32,8 @@ namespace OpenRA.Widgets public override Widget Clone() { return new PerfGraphWidget(this); } - public override void Draw(World world) + public override void DrawInner(World world) { - if (!IsVisible()) - { - base.Draw(world); - return; - } var pos = DrawPosition(); var rect = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height); float2 origin = Game.viewport.Location + new float2(rect.Right,rect.Bottom); @@ -62,8 +57,6 @@ namespace OpenRA.Widgets } Game.chrome.lineRenderer.Flush(); - - base.Draw(world); } } } \ No newline at end of file diff --git a/OpenRA.Game/Widgets/PostGameWidget.cs b/OpenRA.Game/Widgets/PostGameWidget.cs index 5af57b5370..7d49025ca5 100644 --- a/OpenRA.Game/Widgets/PostGameWidget.cs +++ b/OpenRA.Game/Widgets/PostGameWidget.cs @@ -36,10 +36,8 @@ namespace OpenRA.Widgets // todo: all this shit needs to move, probably to Player. - public override void Draw(World world) + public override void DrawInner(World world) { - base.Draw(world); - if (world.LocalPlayer == null) return; if (world.players.Count > 2) /* more than just us + neutral */ diff --git a/OpenRA.Game/Widgets/RadarBinWidget.cs b/OpenRA.Game/Widgets/RadarBinWidget.cs index bf25163f7a..6d227ff5c2 100644 --- a/OpenRA.Game/Widgets/RadarBinWidget.cs +++ b/OpenRA.Game/Widgets/RadarBinWidget.cs @@ -86,7 +86,7 @@ namespace OpenRA.Widgets public override Widget Clone() { throw new NotImplementedException("Why are you Cloning RadarBin?"); } - public override void Draw(World world) + public override void DrawInner(World world) { DrawRadar(world); DrawPower(world); diff --git a/OpenRA.Game/Widgets/SpecialPowerBinWidget.cs b/OpenRA.Game/Widgets/SpecialPowerBinWidget.cs index 88fdfc9c64..5f3c39e682 100644 --- a/OpenRA.Game/Widgets/SpecialPowerBinWidget.cs +++ b/OpenRA.Game/Widgets/SpecialPowerBinWidget.cs @@ -80,13 +80,8 @@ namespace OpenRA.Widgets return false; } - public override void Draw(World world) + public override void DrawInner(World world) { - if (!Visible) - { - base.Draw(world); - return; - } buttons.Clear(); var powers = world.LocalPlayer.PlayerActor.traits.WithInterface(); @@ -170,7 +165,6 @@ namespace OpenRA.Widgets } } Game.chrome.renderer.WorldSpriteRenderer.Flush(); - base.Draw(world); } Action HandleSupportPower(SupportPower sp) diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index e3ac9f4f5d..f7f3124430 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -166,12 +166,17 @@ namespace OpenRA.Widgets throw new InvalidOperationException("Impossible"); } + + public abstract void DrawInner( World world ); - public virtual void Draw(World world) + public void Draw(World world) { if (IsVisible()) + { + DrawInner( world ); foreach (var child in Children) child.Draw(world); + } } public virtual void Tick(World world) @@ -229,6 +234,8 @@ namespace OpenRA.Widgets public ContainerWidget(Widget other) : base(other) { } + public override void DrawInner( World world ) { } + public override Widget Clone() { return new ContainerWidget(this); } } public interface IWidgetDelegate { } diff --git a/OpenRA.Game/Widgets/WorldTooltipWidget.cs b/OpenRA.Game/Widgets/WorldTooltipWidget.cs index 4fd4386f8c..f33675fd99 100644 --- a/OpenRA.Game/Widgets/WorldTooltipWidget.cs +++ b/OpenRA.Game/Widgets/WorldTooltipWidget.cs @@ -36,7 +36,7 @@ namespace OpenRA.Widgets public override Widget Clone() { return new WorldTooltipWidget(this); } - public override void Draw(World world) + public override void DrawInner(World world) { if (Game.chrome.ticksSinceLastMove < worldTooltipDelay || world == null || world.LocalPlayer == null) return;