From ab1e930ba3c4de0a54fc265460281c6d4f6d5fa2 Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 11 Oct 2010 19:42:07 +1300 Subject: [PATCH] pass worldRenderer around as necessary --- OpenRA.FileFormats/Palette.cs | 3 --- OpenRA.Game/Cursor.cs | 4 ++-- OpenRA.Game/Game.cs | 2 +- OpenRA.Game/Graphics/Sprite.cs | 9 ++------ OpenRA.Game/Graphics/SpriteRenderer.cs | 8 +++---- OpenRA.Game/Graphics/TerrainRenderer.cs | 4 ++-- OpenRA.Game/Graphics/Viewport.cs | 7 +++---- OpenRA.Game/Graphics/WorldRenderer.cs | 8 +++---- OpenRA.Game/Orders/GenericSelectTarget.cs | 5 +++-- OpenRA.Game/Orders/IOrderGenerator.cs | 5 +++-- OpenRA.Game/Orders/UnitOrderGenerator.cs | 21 +++++++++---------- OpenRA.Game/ShroudRenderer.cs | 1 - OpenRA.Game/Traits/DrawLineToTarget.cs | 6 +++--- OpenRA.Game/Traits/Selectable.cs | 21 +++++++++---------- OpenRA.Game/Traits/TraitsInterfaces.cs | 8 +++---- OpenRA.Game/Traits/World/BibLayer.cs | 20 +++++++++--------- OpenRA.Game/Traits/World/ResourceLayer.cs | 4 ++-- OpenRA.Game/UiOverlay.cs | 11 +++++----- OpenRA.Game/Widgets/ShpImageWidget.cs | 2 +- OpenRA.Game/Widgets/WidgetUtils.cs | 2 +- OpenRA.Game/World.cs | 2 +- OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs | 6 +++--- OpenRA.Mods.RA/LightPaletteRotator.cs | 3 +-- OpenRA.Mods.RA/Minelayer.cs | 13 ++++++------ .../Orders/PlaceBuildingOrderGenerator.cs | 7 ++++--- .../Orders/PowerDownOrderGenerator.cs | 5 +++-- OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs | 5 +++-- OpenRA.Mods.RA/Orders/SellOrderGenerator.cs | 5 +++-- .../Orders/SetChronoTankDestination.cs | 7 ++++--- OpenRA.Mods.RA/RenderDetectionCircle.cs | 5 +++-- OpenRA.Mods.RA/RenderRangeCircle.cs | 5 +++-- .../SupportPowers/ChronoshiftPower.cs | 11 +++++----- .../SupportPowers/IronCurtainPower.cs | 5 +++-- OpenRA.Mods.RA/World/SmudgeLayer.cs | 4 ++-- 34 files changed, 116 insertions(+), 118 deletions(-) diff --git a/OpenRA.FileFormats/Palette.cs b/OpenRA.FileFormats/Palette.cs index 01fdf89d30..e01ea24bd0 100644 --- a/OpenRA.FileFormats/Palette.cs +++ b/OpenRA.FileFormats/Palette.cs @@ -8,11 +8,8 @@ */ #endregion -using System.Collections.Generic; using System.Drawing; using System.IO; -using System.Linq; -using System; namespace OpenRA.FileFormats { diff --git a/OpenRA.Game/Cursor.cs b/OpenRA.Game/Cursor.cs index 58731da877..b38fdb6aaf 100644 --- a/OpenRA.Game/Cursor.cs +++ b/OpenRA.Game/Cursor.cs @@ -20,9 +20,9 @@ namespace OpenRA sequence = CursorProvider.GetCursorSequence(cursor); } - public void Draw(int frame, float2 pos) + public void Draw(WorldRenderer wr, int frame, float2 pos) { - sequence.GetSprite(frame).DrawAt(pos - sequence.Hotspot, sequence.Palette); + sequence.GetSprite(frame).DrawAt(wr, pos - sequence.Hotspot, sequence.Palette); } } } diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index a312b58150..5b30b379a8 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -141,7 +141,7 @@ namespace OpenRA using (new PerfSample("render")) { ++RenderFrame; - viewport.DrawRegions(world); + viewport.DrawRegions(world.WorldRenderer, world); Sound.SetListenerPosition(viewport.Location + .5f * new float2(viewport.Width, viewport.Height)); } diff --git a/OpenRA.Game/Graphics/Sprite.cs b/OpenRA.Game/Graphics/Sprite.cs index 758c577fd7..0ef880cad7 100644 --- a/OpenRA.Game/Graphics/Sprite.cs +++ b/OpenRA.Game/Graphics/Sprite.cs @@ -50,9 +50,9 @@ namespace OpenRA.Graphics return uvhax[ k ]; } - public void DrawAt( float2 location, string palette ) + public void DrawAt( WorldRenderer wr, float2 location, string palette ) { - Game.Renderer.SpriteRenderer.DrawSprite( this, location, palette, this.size ); + Game.Renderer.SpriteRenderer.DrawSprite( this, location, wr, palette, this.size ); } public void DrawAt( float2 location, int paletteIndex ) @@ -60,11 +60,6 @@ namespace OpenRA.Graphics Game.Renderer.SpriteRenderer.DrawSprite( this, location, paletteIndex, this.size ); } - public void DrawAt(float2 location, string palette, float2 size) - { - Game.Renderer.SpriteRenderer.DrawSprite( this, location, palette, size ); - } - public void DrawAt( float2 location, int paletteIndex, float2 size ) { Game.Renderer.SpriteRenderer.DrawSprite( this, location, paletteIndex, size ); diff --git a/OpenRA.Game/Graphics/SpriteRenderer.cs b/OpenRA.Game/Graphics/SpriteRenderer.cs index c798485c24..88e3135b7a 100644 --- a/OpenRA.Game/Graphics/SpriteRenderer.cs +++ b/OpenRA.Game/Graphics/SpriteRenderer.cs @@ -54,14 +54,14 @@ namespace OpenRA.Graphics } } - public void DrawSprite(Sprite s, float2 location, string palette) + public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette) { - DrawSprite(s, location, Game.world.WorldRenderer.GetPaletteIndex(palette), s.size); + DrawSprite(s, location, wr.GetPaletteIndex(palette), s.size); } - public void DrawSprite(Sprite s, float2 location, string palette, float2 size) + public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette, float2 size) { - DrawSprite(s, location, Game.world.WorldRenderer.GetPaletteIndex(palette), size); + DrawSprite(s, location, wr.GetPaletteIndex(palette), size); } public void DrawSprite(Sprite s, float2 location, int paletteIndex, float2 size) diff --git a/OpenRA.Game/Graphics/TerrainRenderer.cs b/OpenRA.Game/Graphics/TerrainRenderer.cs index 943f795648..f48fcec8ab 100644 --- a/OpenRA.Game/Graphics/TerrainRenderer.cs +++ b/OpenRA.Game/Graphics/TerrainRenderer.cs @@ -62,7 +62,7 @@ namespace OpenRA.Graphics indexBuffer.SetData( indices, ni ); } - public void Draw( Viewport viewport ) + public void Draw( WorldRenderer wr, Viewport viewport ) { int indicesPerRow = map.Width * 6; int verticesPerRow = map.Width * 4; @@ -98,7 +98,7 @@ namespace OpenRA.Graphics PrimitiveType.TriangleList, Game.Renderer.SpriteShader)); foreach (var r in world.WorldActor.TraitsImplementing()) - r.Render(); + r.Render( wr ); } } } diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index b5b2904aac..48aa7efee2 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -11,7 +11,6 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; -using OpenRA.Support; using OpenRA.Traits; using OpenRA.Widgets; @@ -96,16 +95,16 @@ namespace OpenRA.Graphics this.scrollPosition = Game.CellSize* mapStart; } - public void DrawRegions( World world ) + public void DrawRegions( WorldRenderer wr, World world ) { renderer.BeginFrame(scrollPosition); - world.WorldRenderer.Draw(); + wr.Draw(); Widget.DoDraw(world); var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default"; var c = new Cursor(cursorName); - c.Draw((int)cursorFrame, Viewport.LastMousePos + Location); + c.Draw(wr, (int)cursorFrame, Viewport.LastMousePos + Location); renderer.EndFrame(); } diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index d40f259c8f..c610060ba2 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -92,17 +92,17 @@ namespace OpenRA.Graphics var bounds = GetBoundsRect(); Game.Renderer.EnableScissor(bounds.Left, bounds.Top, bounds.Width, bounds.Height); - terrainRenderer.Draw(Game.viewport); + terrainRenderer.Draw(this, Game.viewport); if (world.OrderGenerator != null) - world.OrderGenerator.RenderBeforeWorld(world); + world.OrderGenerator.RenderBeforeWorld(this, world); foreach( var image in worldSprites ) image.Sprite.DrawAt( image.Pos, this.GetPaletteIndex( image.Palette ) ); - uiOverlay.Draw(world); + uiOverlay.Draw(this, world); if (world.OrderGenerator != null) - world.OrderGenerator.RenderAfterWorld(world); + world.OrderGenerator.RenderAfterWorld(this, world); if (world.LocalPlayer != null) world.LocalPlayer.Shroud.Draw(); diff --git a/OpenRA.Game/Orders/GenericSelectTarget.cs b/OpenRA.Game/Orders/GenericSelectTarget.cs index d684a11817..89e8bbb662 100644 --- a/OpenRA.Game/Orders/GenericSelectTarget.cs +++ b/OpenRA.Game/Orders/GenericSelectTarget.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; namespace OpenRA.Orders { @@ -43,8 +44,8 @@ namespace OpenRA.Orders } public virtual void Tick(World world) { } - public void RenderAfterWorld(World world) { } - public void RenderBeforeWorld(World world) { } + public void RenderAfterWorld(WorldRenderer wr, World world) { } + public void RenderBeforeWorld(WorldRenderer wr, World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { return world.Map.IsInMap(xy) ? cursor : "generic-blocked"; } } diff --git a/OpenRA.Game/Orders/IOrderGenerator.cs b/OpenRA.Game/Orders/IOrderGenerator.cs index da47eed1f6..7a3d6165af 100644 --- a/OpenRA.Game/Orders/IOrderGenerator.cs +++ b/OpenRA.Game/Orders/IOrderGenerator.cs @@ -9,6 +9,7 @@ #endregion using System.Collections.Generic; +using OpenRA.Graphics; namespace OpenRA { @@ -16,8 +17,8 @@ namespace OpenRA { IEnumerable Order(World world, int2 xy, MouseInput mi); void Tick(World world); - void RenderBeforeWorld(World world); - void RenderAfterWorld(World world); + void RenderBeforeWorld(WorldRenderer wr, World world); + void RenderAfterWorld(WorldRenderer wr, World world); string GetCursor(World world, int2 xy, MouseInput mi); } } diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index 600b0b3f03..aaba582781 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -6,13 +6,12 @@ * as published by the Free Software Foundation. For more information, * see LICENSE. */ -#endregion - -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using OpenRA.Traits; -using OpenRA.FileFormats; +#endregion + +using System.Collections.Generic; +using System.Linq; +using OpenRA.Graphics; +using OpenRA.Traits; namespace OpenRA.Orders { @@ -41,22 +40,22 @@ namespace OpenRA.Orders public void Tick( World world ) {} - public void RenderBeforeWorld(World world) + public void RenderBeforeWorld( WorldRenderer wr, World world ) { foreach (var a in world.Selection.Actors) if (!a.Destroyed) foreach (var t in a.TraitsImplementing()) - t.RenderBeforeWorld(a); + t.RenderBeforeWorld( wr, a ); Game.Renderer.Flush(); } - public void RenderAfterWorld( World world ) + public void RenderAfterWorld( WorldRenderer wr, World world ) { foreach (var a in world.Selection.Actors) if (!a.Destroyed) foreach (var t in a.TraitsImplementing()) - t.RenderAfterWorld(a); + t.RenderAfterWorld( wr, a ); Game.Renderer.Flush(); } diff --git a/OpenRA.Game/ShroudRenderer.cs b/OpenRA.Game/ShroudRenderer.cs index 6ef85d2c3f..02d6455c61 100644 --- a/OpenRA.Game/ShroudRenderer.cs +++ b/OpenRA.Game/ShroudRenderer.cs @@ -9,7 +9,6 @@ #endregion using System.Drawing; -using OpenRA.FileFormats; using OpenRA.Graphics; namespace OpenRA diff --git a/OpenRA.Game/Traits/DrawLineToTarget.cs b/OpenRA.Game/Traits/DrawLineToTarget.cs index 7b1770be7e..e0fe2b7422 100644 --- a/OpenRA.Game/Traits/DrawLineToTarget.cs +++ b/OpenRA.Game/Traits/DrawLineToTarget.cs @@ -8,8 +8,8 @@ */ #endregion -using System.Drawing; -using OpenRA.Traits.Activities; +using System.Drawing; +using OpenRA.Graphics; namespace OpenRA.Traits { @@ -45,7 +45,7 @@ namespace OpenRA.Traits this.c = c; } - public void RenderAfterWorld(Actor self) + public void RenderAfterWorld(WorldRenderer wr, Actor self) { if (self.IsIdle) return; diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index f7a6d0be87..7fc25e78c2 100644 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -10,7 +10,6 @@ using System.Drawing; using OpenRA.Graphics; -using System.Linq; namespace OpenRA.Traits { @@ -29,7 +28,7 @@ namespace OpenRA.Traits static readonly string[] pipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray" }; static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" }; - public void RenderAfterWorld (Actor self) + public void RenderAfterWorld (WorldRenderer wr, Actor self) { var bounds = self.GetBounds(true); @@ -40,9 +39,9 @@ namespace OpenRA.Traits DrawSelectionBox(self, xy, Xy, xY, XY, Color.White); DrawHealthBar(self, xy, Xy); - DrawControlGroup(self, xy); - DrawPips(self, xY); - DrawTags(self, new float2(.5f * (bounds.Left + bounds.Right), bounds.Top)); + DrawControlGroup(wr, self, xy); + DrawPips(wr, self, xY); + DrawTags(wr, self, new float2(.5f * (bounds.Left + bounds.Right), bounds.Top)); DrawUnitPath(self); } @@ -89,7 +88,7 @@ namespace OpenRA.Traits Game.Renderer.LineRenderer.DrawLine(xy + new float2(0, -4), z + new float2(0, -4), healthColor2, healthColor2); } - void DrawControlGroup(Actor self, float2 basePosition) + void DrawControlGroup(WorldRenderer wr, Actor self, float2 basePosition) { var group = self.World.Selection.GetControlGroupForActor(self); if (group == null) return; @@ -97,10 +96,10 @@ namespace OpenRA.Traits var pipImages = new Animation("pips"); pipImages.PlayFetchIndex("groups", () => (int)group); pipImages.Tick(); - pipImages.Image.DrawAt(basePosition + new float2(-8, 1), "chrome"); + pipImages.Image.DrawAt(wr, basePosition + new float2(-8, 1), "chrome"); } - void DrawPips(Actor self, float2 basePosition) + void DrawPips(WorldRenderer wr, Actor self, float2 basePosition) { if (self.Owner != self.World.LocalPlayer) return; @@ -123,7 +122,7 @@ namespace OpenRA.Traits } var pipImages = new Animation("pips"); pipImages.PlayRepeating(pipStrings[(int)pip]); - pipImages.Image.DrawAt(pipxyBase + pipxyOffset, "chrome"); + pipImages.Image.DrawAt(wr, pipxyBase + pipxyOffset, "chrome"); pipxyOffset += new float2(4, 0); } // Increment row @@ -132,7 +131,7 @@ namespace OpenRA.Traits } } - void DrawTags(Actor self, float2 basePosition) + void DrawTags(WorldRenderer wr, Actor self, float2 basePosition) { if (self.Owner != self.World.LocalPlayer) return; @@ -149,7 +148,7 @@ namespace OpenRA.Traits var tagImages = new Animation("pips"); tagImages.PlayRepeating(tagStrings[(int)tag]); - tagImages.Image.DrawAt(tagxyBase + tagxyOffset, "chrome"); + tagImages.Image.DrawAt(wr, tagxyBase + tagxyOffset, "chrome"); // Increment row tagxyOffset.Y += 8; diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 3ff2c1b729..ec67480ab0 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -10,9 +10,9 @@ using System.Collections.Generic; using System.Drawing; +using OpenRA.FileFormats; using OpenRA.GameRules; using OpenRA.Graphics; -using OpenRA.FileFormats; namespace OpenRA.Traits { @@ -211,13 +211,13 @@ namespace OpenRA.Traits } } - public interface IRenderOverlay { void Render(); } + public interface IRenderOverlay { void Render( WorldRenderer wr ); } public interface INotifyIdle { void Idle(Actor self); } public interface IBlocksBullets { } - public interface IPostRenderSelection { void RenderAfterWorld(Actor self); } - public interface IPreRenderSelection { void RenderBeforeWorld(Actor self); } + public interface IPostRenderSelection { void RenderAfterWorld(WorldRenderer wr, Actor self); } + public interface IPreRenderSelection { void RenderBeforeWorld(WorldRenderer wr, Actor self); } public struct Target // a target: either an actor, or a fixed location. { diff --git a/OpenRA.Game/Traits/World/BibLayer.cs b/OpenRA.Game/Traits/World/BibLayer.cs index 6888555497..755f8b0e88 100755 --- a/OpenRA.Game/Traits/World/BibLayer.cs +++ b/OpenRA.Game/Traits/World/BibLayer.cs @@ -6,14 +6,14 @@ * as published by the Free Software Foundation. For more information, * see LICENSE. */ -#endregion - -using System; -using System.Drawing; -using System.Linq; -using OpenRA.FileFormats; -using OpenRA.Graphics; -using System.Collections.Generic; +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using OpenRA.FileFormats; +using OpenRA.Graphics; namespace OpenRA.Traits { @@ -71,7 +71,7 @@ namespace OpenRA.Traits } } - public void Render() + public void Render( WorldRenderer wr ) { var cliprect = Game.viewport.ShroudBounds().HasValue ? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds; @@ -84,7 +84,7 @@ namespace OpenRA.Traits if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(kv.Key)) continue; - bibSprites[kv.Value.type - 1][kv.Value.image].DrawAt( + bibSprites[kv.Value.type - 1][kv.Value.image].DrawAt( wr, Game.CellSize * kv.Key, "terrain"); } } diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index 3e38780a15..d1f0d0d95a 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.cs @@ -24,7 +24,7 @@ namespace OpenRA.Traits public ResourceType[] resourceTypes; CellContents[,] content; - public void Render() + public void Render( WorldRenderer wr ) { var cliprect = Game.viewport.ShroudBounds().HasValue ? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds; @@ -38,7 +38,7 @@ namespace OpenRA.Traits var maxy = cliprect.Bottom; foreach( var rt in world.WorldActor.TraitsImplementing() ) - rt.info.PaletteIndex = world.WorldRenderer.GetPaletteIndex(rt.info.Palette); + rt.info.PaletteIndex = wr.GetPaletteIndex(rt.info.Palette); for (int x = minx; x < maxx; x++) for (int y = miny; y < maxy; y++) diff --git a/OpenRA.Game/UiOverlay.cs b/OpenRA.Game/UiOverlay.cs index 2524d20162..b92f846cf8 100644 --- a/OpenRA.Game/UiOverlay.cs +++ b/OpenRA.Game/UiOverlay.cs @@ -14,7 +14,6 @@ using System.Linq; using OpenRA.GameRules; using OpenRA.Graphics; using OpenRA.Traits; -using OpenRA.Widgets; namespace OpenRA { @@ -40,7 +39,7 @@ namespace OpenRA return Game.modData.SheetBuilder.Add(data, new Size(Game.CellSize, Game.CellSize)); } - public void Draw( World world ) + public void Draw( WorldRenderer wr, World world ) { if (Game.Settings.Debug.ShowCollisions) { @@ -49,11 +48,11 @@ namespace OpenRA for (var i = world.Map.Bounds.Left; i < world.Map.Bounds.Right; i++) for (var j = world.Map.Bounds.Top; j < world.Map.Bounds.Bottom; j++) if (uim.GetUnitsAt(new int2(i, j)).Any()) - unitDebug.DrawAt(Game.CellSize * new float2(i, j), "terrain"); + unitDebug.DrawAt(wr, Game.CellSize * new float2(i, j), "terrain"); } } - public void DrawBuildingGrid( World world, string name, BuildingInfo bi ) + public void DrawBuildingGrid( WorldRenderer wr, World world, string name, BuildingInfo bi ) { var position = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2(); var topLeft = position - Footprint.AdjustForBuildingSize( bi ); @@ -64,7 +63,7 @@ namespace OpenRA { foreach (var t in LineBuildUtils.GetLineBuildCells(world, topLeft, name, bi)) (world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, t) ? buildOk : buildBlocked) - .DrawAt(Game.CellSize * t, "terrain"); + .DrawAt(wr, Game.CellSize * t, "terrain"); } else { @@ -72,7 +71,7 @@ namespace OpenRA var isCloseEnough = world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, topLeft); foreach (var t in Footprint.Tiles(name, bi, topLeft)) ((isCloseEnough && world.IsCellBuildable(t, bi.WaterBound) && res.GetResource(t) == null) ? buildOk : buildBlocked) - .DrawAt(Game.CellSize * t, "terrain"); + .DrawAt( wr, Game.CellSize * t, "terrain"); } } } diff --git a/OpenRA.Game/Widgets/ShpImageWidget.cs b/OpenRA.Game/Widgets/ShpImageWidget.cs index b1c09ccbcd..06fb9afeb9 100644 --- a/OpenRA.Game/Widgets/ShpImageWidget.cs +++ b/OpenRA.Game/Widgets/ShpImageWidget.cs @@ -61,7 +61,7 @@ namespace OpenRA.Widgets cachedFrame = frame; } - Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite,RenderOrigin, palette); + Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite,RenderOrigin, Game.world.WorldRenderer, palette); } } } diff --git a/OpenRA.Game/Widgets/WidgetUtils.cs b/OpenRA.Game/Widgets/WidgetUtils.cs index 1a4d10a3f5..212916a6ca 100644 --- a/OpenRA.Game/Widgets/WidgetUtils.cs +++ b/OpenRA.Game/Widgets/WidgetUtils.cs @@ -29,7 +29,7 @@ namespace OpenRA.Widgets public static void DrawSHP(Sprite s, float2 pos) { - Game.Renderer.WorldSpriteRenderer.DrawSprite(s,pos, "chrome"); + Game.Renderer.WorldSpriteRenderer.DrawSprite(s,pos, Game.world.WorldRenderer, "chrome"); } public static void DrawPanel(string collection, Rectangle Bounds) diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 7ce1d6c322..3e30abfb7f 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -14,11 +14,11 @@ using OpenRA.Collections; using OpenRA.Effects; using OpenRA.FileFormats; using OpenRA.Graphics; +using OpenRA.Network; using OpenRA.Orders; using OpenRA.Traits; using XRandom = OpenRA.Thirdparty.Random; -using OpenRA.Network; namespace OpenRA { diff --git a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs index 993983f2b1..d3cb0dfc67 100644 --- a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs +++ b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs @@ -8,10 +8,10 @@ */ #endregion -using System.Drawing; -using OpenRA.Traits; -using OpenRA.FileFormats; using System.Collections.Generic; +using System.Drawing; +using OpenRA.FileFormats; +using OpenRA.Traits; namespace OpenRA.Mods.RA { diff --git a/OpenRA.Mods.RA/LightPaletteRotator.cs b/OpenRA.Mods.RA/LightPaletteRotator.cs index af272ea8ba..891098be2a 100644 --- a/OpenRA.Mods.RA/LightPaletteRotator.cs +++ b/OpenRA.Mods.RA/LightPaletteRotator.cs @@ -8,10 +8,9 @@ */ #endregion -using System.Drawing; -using OpenRA.Traits; using System.Collections.Generic; using OpenRA.FileFormats; +using OpenRA.Traits; namespace OpenRA.Mods.RA { diff --git a/OpenRA.Mods.RA/Minelayer.cs b/OpenRA.Mods.RA/Minelayer.cs index 4d0694efe0..e06bdc8835 100644 --- a/OpenRA.Mods.RA/Minelayer.cs +++ b/OpenRA.Mods.RA/Minelayer.cs @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Linq; +using OpenRA.Graphics; using OpenRA.Mods.RA.Activities; using OpenRA.Traits; @@ -41,7 +42,7 @@ namespace OpenRA.Mods.RA { if( order is BeginMinefieldOrderTargeter ) { - var start = Util.CellContaining( target.CenterLocation ); + var start = Traits.Util.CellContaining( target.CenterLocation ); self.World.OrderGenerator = new MinefieldOrderGenerator( self, start ); return new Order( "BeginMinefield", self, start ); } @@ -120,7 +121,7 @@ namespace OpenRA.Mods.RA } int2 lastMousePos; - public void RenderAfterWorld(World world) + public void RenderAfterWorld(WorldRenderer wr, World world) { if (!minelayer.IsInWorld) return; @@ -129,21 +130,21 @@ namespace OpenRA.Mods.RA var minefield = GetMinefieldCells(minefieldStart, lastMousePos, minelayer.Info.Traits.Get().MinefieldDepth) .Where(p => movement.CanEnterCell(p)).ToArray(); - world.WorldRenderer.DrawLocus(Color.Cyan, minefield); + wr.DrawLocus(Color.Cyan, minefield); } - public void RenderBeforeWorld(World world) { } + public void RenderBeforeWorld(WorldRenderer wr, World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { lastMousePos = xy; return "ability"; } /* todo */ } - public void RenderAfterWorld(Actor self) + public void RenderAfterWorld(WorldRenderer wr, Actor self) { if (self.Owner != self.World.LocalPlayer) return; if (minefield != null) - self.World.WorldRenderer.DrawLocus(Color.Cyan, minefield); + wr.DrawLocus(Color.Cyan, minefield); } class BeginMinefieldOrderTargeter : IOrderTargeter diff --git a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs index 6e8300047d..346dcc3295 100755 --- a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.GameRules; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Orders @@ -71,11 +72,11 @@ namespace OpenRA.Mods.RA.Orders // .FirstOrDefault(); } - public void RenderAfterWorld( World world ) {} + public void RenderAfterWorld( WorldRenderer wr, World world ) { } - public void RenderBeforeWorld(World world) + public void RenderBeforeWorld( WorldRenderer wr, World world ) { - world.WorldRenderer.uiOverlay.DrawBuildingGrid(world, Building, BuildingInfo); + wr.uiOverlay.DrawBuildingGrid( wr, world, Building, BuildingInfo ); } public string GetCursor(World world, int2 xy, MouseInput mi) { return "default"; } diff --git a/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs index a747a12986..4a292f41ca 100755 --- a/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; namespace OpenRA.Mods.RA.Orders { @@ -38,8 +39,8 @@ namespace OpenRA.Mods.RA.Orders } public void Tick(World world) { } - public void RenderAfterWorld(World world) { } - public void RenderBeforeWorld(World world) { } + public void RenderAfterWorld(WorldRenderer wr, World world) { } + public void RenderBeforeWorld(WorldRenderer wr, World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { diff --git a/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs b/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs index 0bd4c0fe87..8237e2222a 100644 --- a/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Orders @@ -51,8 +52,8 @@ namespace OpenRA.Mods.RA.Orders return world.Queries.OwnedBy[ world.LocalPlayer ].WithTrait().Any(); } - public void RenderAfterWorld( World world ) {} - public void RenderBeforeWorld(World world) { } + public void RenderAfterWorld( WorldRenderer wr, World world ) { } + public void RenderBeforeWorld( WorldRenderer wr, World world ) { } public string GetCursor(World world, int2 xy, MouseInput mi) { diff --git a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs index ec0c167da8..ed6aef20ef 100755 --- a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Orders @@ -41,8 +42,8 @@ namespace OpenRA.Mods.RA.Orders } public void Tick( World world ) {} - public void RenderAfterWorld( World world ) {} - public void RenderBeforeWorld(World world) { } + public void RenderAfterWorld( WorldRenderer wr, World world ) { } + public void RenderBeforeWorld( WorldRenderer wr, World world ) { } public string GetCursor(World world, int2 xy, MouseInput mi) { diff --git a/OpenRA.Mods.RA/Orders/SetChronoTankDestination.cs b/OpenRA.Mods.RA/Orders/SetChronoTankDestination.cs index 66c0346d99..ddd7c6a400 100644 --- a/OpenRA.Mods.RA/Orders/SetChronoTankDestination.cs +++ b/OpenRA.Mods.RA/Orders/SetChronoTankDestination.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Drawing; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Orders @@ -36,12 +37,12 @@ namespace OpenRA.Mods.RA.Orders } public void Tick( World world ) { } - public void RenderAfterWorld( World world ) + public void RenderAfterWorld( WorldRenderer wr, World world ) { - world.WorldRenderer.DrawSelectionBox(self, Color.White); + wr.DrawSelectionBox(self, Color.White); } - public void RenderBeforeWorld(World world) { } + public void RenderBeforeWorld( WorldRenderer wr, World world ) { } public string GetCursor(World world, int2 xy, MouseInput mi) { diff --git a/OpenRA.Mods.RA/RenderDetectionCircle.cs b/OpenRA.Mods.RA/RenderDetectionCircle.cs index 636aa2e95d..ce9d8f5a81 100644 --- a/OpenRA.Mods.RA/RenderDetectionCircle.cs +++ b/OpenRA.Mods.RA/RenderDetectionCircle.cs @@ -9,6 +9,7 @@ #endregion using System.Drawing; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -16,12 +17,12 @@ namespace OpenRA.Mods.RA class RenderDetectionCircleInfo : TraitInfo { } class RenderDetectionCircle : IPreRenderSelection { - public void RenderBeforeWorld(Actor self) + public void RenderBeforeWorld(WorldRenderer wr, Actor self) { if (self.Owner != self.World.LocalPlayer) return; - self.World.WorldRenderer.DrawRangeCircle( + wr.DrawRangeCircle( Color.FromArgb(128, Color.LimeGreen), self.CenterLocation, self.Info.Traits.Get().Range); } diff --git a/OpenRA.Mods.RA/RenderRangeCircle.cs b/OpenRA.Mods.RA/RenderRangeCircle.cs index fd70672da5..561cfc6b43 100644 --- a/OpenRA.Mods.RA/RenderRangeCircle.cs +++ b/OpenRA.Mods.RA/RenderRangeCircle.cs @@ -9,6 +9,7 @@ #endregion using System.Drawing; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -16,12 +17,12 @@ namespace OpenRA.Mods.RA class RenderRangeCircleInfo : TraitInfo { } class RenderRangeCircle : IPreRenderSelection { - public void RenderBeforeWorld(Actor self) + public void RenderBeforeWorld(WorldRenderer wr, Actor self) { if (self.Owner != self.World.LocalPlayer) return; - self.World.WorldRenderer.DrawRangeCircle( + wr.DrawRangeCircle( Color.FromArgb(128, Color.Yellow), self.CenterLocation, (int)self.Trait().GetMaximumRange()); } diff --git a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs index e2150557a8..82f65157cf 100755 --- a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; +using OpenRA.Graphics; using OpenRA.Mods.RA.Render; using OpenRA.Traits; @@ -96,8 +97,8 @@ namespace OpenRA.Mods.RA // TODO: Check if the selected unit is still alive } - public void RenderAfterWorld( World world ) { } - public void RenderBeforeWorld(World world) { } + public void RenderAfterWorld( WorldRenderer wr, World world ) { } + public void RenderBeforeWorld( WorldRenderer wr, World world ) { } public string GetCursor(World world, int2 xy, MouseInput mi) { @@ -145,12 +146,12 @@ namespace OpenRA.Mods.RA // TODO: Check if the selected unit is still alive } - public void RenderAfterWorld(World world) + public void RenderAfterWorld(WorldRenderer wr, World world) { - world.WorldRenderer.DrawSelectionBox(self, Color.Red); + wr.DrawSelectionBox(self, Color.Red); } - public void RenderBeforeWorld(World world) { } + public void RenderBeforeWorld(WorldRenderer wr, World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { diff --git a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs index babbe7beac..56e40983c7 100755 --- a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Mods.RA.Render; using OpenRA.Traits; @@ -95,8 +96,8 @@ namespace OpenRA.Mods.RA world.CancelInputMode(); } - public void RenderAfterWorld(World world) { } - public void RenderBeforeWorld(World world) { } + public void RenderAfterWorld(WorldRenderer wr, World world) { } + public void RenderBeforeWorld(WorldRenderer wr, World world) { } public string GetCursor(World world, int2 xy, MouseInput mi) { diff --git a/OpenRA.Mods.RA/World/SmudgeLayer.cs b/OpenRA.Mods.RA/World/SmudgeLayer.cs index 82eecf28d0..8a05cae5b4 100755 --- a/OpenRA.Mods.RA/World/SmudgeLayer.cs +++ b/OpenRA.Mods.RA/World/SmudgeLayer.cs @@ -73,7 +73,7 @@ namespace OpenRA.Mods.RA } } - public void Render() + public void Render( WorldRenderer wr ) { var cliprect = Game.viewport.ShroudBounds().HasValue ? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds; @@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(kv.Key)) continue; - smudgeSprites[kv.Value.type- 1][kv.Value.image].DrawAt( + smudgeSprites[kv.Value.type- 1][kv.Value.image].DrawAt( wr, Game.CellSize * kv.Key, "terrain"); } }