diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 0141466a19..c1479e0dd0 100644 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -5,6 +5,7 @@ using System.Drawing; using OpenRa.FileFormats; using System.Windows.Forms; +using OpenRa.Game.Graphics; namespace OpenRa.Game { diff --git a/OpenRa.Game/ConstructionYard.cs b/OpenRa.Game/ConstructionYard.cs deleted file mode 100644 index dd1e5f4078..0000000000 --- a/OpenRa.Game/ConstructionYard.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - - -namespace OpenRa.Game -{ - class ConstructionYard : Building - { - public ConstructionYard( int2 location, Player owner, Game game ) - : base( "fact", location, owner, game ) - { - animation.PlayThen("make", () => animation.PlayRepeating("build")); - } - } -} diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 2926879fbd..e23b35d36f 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -1,9 +1,8 @@ using System; using System.Collections.Generic; -using System.Text; using OpenRa.FileFormats; -using System.Drawing; +using OpenRa.Game.Graphics; namespace OpenRa.Game { @@ -45,10 +44,9 @@ namespace OpenRa.Game network = new Network(); - buildingCreation.Add("fact", (location, owner) => new ConstructionYard(location, owner, this)); buildingCreation.Add("proc", (location, owner) => new Refinery(location, owner, this)); - string[] buildings = { "powr", "apwr", "weap", "barr", "atek", "stek", "dome" }; + string[] buildings = { "fact", "powr", "apwr", "weap", "barr", "atek", "stek", "dome" }; foreach (string s in buildings) AddBuilding(s); } diff --git a/OpenRa.Game/Animation.cs b/OpenRa.Game/Graphics/Animation.cs similarity index 78% rename from OpenRa.Game/Animation.cs rename to OpenRa.Game/Graphics/Animation.cs index ee2a505b5d..d1debfef51 100644 --- a/OpenRa.Game/Animation.cs +++ b/OpenRa.Game/Graphics/Animation.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class Animation { @@ -19,6 +16,7 @@ namespace OpenRa.Game } public Sprite[] Images { get { return new Sprite[] { currentSequence.GetSprite( frame ) }; } } + public float2 Center { get { return 0.25f * new float2(currentSequence.GetSprite(0).bounds.Size); } } public void Play( string sequenceName ) { @@ -35,13 +33,13 @@ namespace OpenRa.Game tickAlways = false; currentSequence = SequenceProvider.GetSequence( name, sequenceName ); frame = 0; - tickFunc = _ => + tickFunc = () => { ++frame; if( frame >= currentSequence.Length ) { frame = currentSequence.Length - 1; - tickFunc = t => { }; + tickFunc = () => { }; after(); } }; @@ -52,22 +50,22 @@ namespace OpenRa.Game tickAlways = true; currentSequence = SequenceProvider.GetSequence( name, sequenceName ); frame = func(); - tickFunc = t => frame = func(); + tickFunc = () => frame = func(); } int timeUntilNextFrame; + Action tickFunc; - Action tickFunc; public void Tick( int t ) { if( tickAlways ) - tickFunc( t ); + tickFunc(); else { timeUntilNextFrame -= t; while( timeUntilNextFrame <= 0 ) { - tickFunc( 40 ); + tickFunc(); timeUntilNextFrame += 40; // 25 fps == 40 ms } } diff --git a/OpenRa.Game/Graphics/Graphics.cd b/OpenRa.Game/Graphics/Graphics.cd new file mode 100644 index 0000000000..54372aa050 --- /dev/null +++ b/OpenRa.Game/Graphics/Graphics.cd @@ -0,0 +1,131 @@ + + + + + + AAQCgACAAAAAAAAAAAAAAAAAAAAEABAEgAAAAQQIQAA= + Graphics\Animation.cs + + + + + + + + + AAAAAQAABAAAgAAAAIYAAEAAAABCAAAAAABgAAAAgAE= + Graphics\Viewport.cs + + + + + + + + + AAQAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAQAAAAA= + Graphics\HardwarePalette.cs + + + + + + AIQAAAAAAAAAggAABAIAIAQCAAAAAGAAAAAAAAAQAAA= + Graphics\Region.cs + + + + + + QACAEAAGAAAAAgMAAAAAAAAAAAAAAAAAAAAAAEAAAAA= + Graphics\Renderer.cs + + + + + + AAAAAAAAAACAgAAACAgAAAAIAAAAAgAAAAIAAAAggAA= + Graphics\Sheet.cs + + + + + + + + + AQIACAAAAAAAIQAAAAAAAAAAgAAAAIAAAEAAAAACgAA= + Graphics\SheetBuilder.cs + + + + + + + + + AAAAAAAAAQAAIAAAAIAAAAAAAAAAAAABAAACAAAEAgA= + Graphics\Sprite.cs + + + + + + + + + AAAQQAAAAECAAAAAAAAAAAAAABAQABAAAAAAAACIwAQ= + Graphics\SpriteRenderer.cs + + + + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAACAAAA= + Graphics\SpriteSheetBuilder.cs + + + + + + + + + AACQEAAAAAAAAgAAAAAACAAAABgAAAAAAAAAAAAAgAA= + Graphics\TerrainRenderer.cs + + + + + + + + + + AAAAAAAAgAAAAAAAAAAAAAAAAQAAAAAAAQAAAACAAAA= + Graphics\UnitSheetBuilder.cs + + + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAgAAACAAFJgAQAAAAA= + Graphics\Vertex.cs + + + + + + AAACAAAAAAAAAgAAAAAAAAAAAAAAABAAAAAAABAAAAA= + Graphics\Sprite.cs + + + + \ No newline at end of file diff --git a/OpenRa.Game/HardwarePalette.cs b/OpenRa.Game/Graphics/HardwarePalette.cs similarity index 92% rename from OpenRa.Game/HardwarePalette.cs rename to OpenRa.Game/Graphics/HardwarePalette.cs index a0c7e256bd..f1a6a2c4bd 100644 --- a/OpenRa.Game/HardwarePalette.cs +++ b/OpenRa.Game/Graphics/HardwarePalette.cs @@ -6,7 +6,7 @@ using System.Drawing; using System.IO; using OpenRa.FileFormats; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class HardwarePalette : Sheet { diff --git a/OpenRa.Game/Region.cs b/OpenRa.Game/Graphics/Region.cs similarity index 83% rename from OpenRa.Game/Region.cs rename to OpenRa.Game/Graphics/Region.cs index 9f787b8ff7..6a35060fc0 100644 --- a/OpenRa.Game/Region.cs +++ b/OpenRa.Game/Graphics/Region.cs @@ -1,10 +1,8 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; using System.Windows.Forms; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class Region { @@ -13,15 +11,10 @@ namespace OpenRa.Game public float2 Location { - get { return location + viewport.Location; } + get { return location + viewport.Location; } // WTF HACK HACK HACK } - float2 size; - - public float2 Size - { - get { return size; } - } + public readonly float2 Size; Action drawFunction; MouseEventHandler mouseHandler; @@ -71,7 +64,7 @@ namespace OpenRa.Game Region(int2 location, int2 size, Viewport viewport, Action drawFunction, MouseEventHandler mouseHandler) { this.location = location; - this.size = size; + this.Size = size; this.drawFunction = drawFunction; this.viewport = viewport; this.mouseHandler = mouseHandler; @@ -82,7 +75,7 @@ namespace OpenRa.Game public void Draw(Renderer renderer) { - renderer.Device.EnableScissor((int)location.X, (int)location.Y, (int)size.X, (int)size.Y); + renderer.Device.EnableScissor((int)location.X, (int)location.Y, (int)Size.X, (int)Size.Y); drawFunction(); renderer.Device.DisableScissor(); } diff --git a/OpenRa.Game/Renderer.cs b/OpenRa.Game/Graphics/Renderer.cs similarity index 90% rename from OpenRa.Game/Renderer.cs rename to OpenRa.Game/Graphics/Renderer.cs index 6715cad2dd..b6d40272ee 100644 --- a/OpenRa.Game/Renderer.cs +++ b/OpenRa.Game/Graphics/Renderer.cs @@ -1,13 +1,10 @@ using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; using System.Drawing; +using System.Windows.Forms; using Ijw.DirectX; -using System.IO; using OpenRa.FileFormats; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class Renderer { diff --git a/OpenRa.Game/Sequence.cs b/OpenRa.Game/Graphics/Sequence.cs similarity index 87% rename from OpenRa.Game/Sequence.cs rename to OpenRa.Game/Graphics/Sequence.cs index ab16c512ed..c9fe749d10 100644 --- a/OpenRa.Game/Sequence.cs +++ b/OpenRa.Game/Graphics/Sequence.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Ijw.DirectX; using System.Xml; +using Ijw.DirectX; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class Sequence { diff --git a/OpenRa.Game/SequenceProvider.cs b/OpenRa.Game/Graphics/SequenceProvider.cs similarity index 91% rename from OpenRa.Game/SequenceProvider.cs rename to OpenRa.Game/Graphics/SequenceProvider.cs index f0dab18c30..c233ff2780 100644 --- a/OpenRa.Game/SequenceProvider.cs +++ b/OpenRa.Game/Graphics/SequenceProvider.cs @@ -1,10 +1,8 @@ -using System; using System.Collections.Generic; -using System.Text; using System.Xml; using OpenRa.FileFormats; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { static class SequenceProvider { diff --git a/OpenRa.Game/Sheet.cs b/OpenRa.Game/Graphics/Sheet.cs similarity index 86% rename from OpenRa.Game/Sheet.cs rename to OpenRa.Game/Graphics/Sheet.cs index 15ca490893..57fcda9fea 100644 --- a/OpenRa.Game/Sheet.cs +++ b/OpenRa.Game/Graphics/Sheet.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; using System.IO; using Ijw.DirectX; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class Sheet { diff --git a/OpenRa.Game/SheetBuilder.cs b/OpenRa.Game/Graphics/SheetBuilder.cs similarity index 88% rename from OpenRa.Game/SheetBuilder.cs rename to OpenRa.Game/Graphics/SheetBuilder.cs index 65885109e9..480288e2c0 100644 --- a/OpenRa.Game/SheetBuilder.cs +++ b/OpenRa.Game/Graphics/SheetBuilder.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; -using OpenRa.FileFormats; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { static class SheetBuilder { @@ -16,7 +12,6 @@ namespace OpenRa.Game public static Sprite Add(byte[] src, Size size) { Sprite rect = AddImage(size); - //Util.CopyIntoChannel(rect, src); Util.FastCopyIntoChannel(rect, src); return rect; } diff --git a/OpenRa.Game/Sprite.cs b/OpenRa.Game/Graphics/Sprite.cs similarity index 93% rename from OpenRa.Game/Sprite.cs rename to OpenRa.Game/Graphics/Sprite.cs index 7c978c3314..054bed7647 100644 --- a/OpenRa.Game/Sprite.cs +++ b/OpenRa.Game/Graphics/Sprite.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Text; using System.Drawing; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class Sprite { diff --git a/OpenRa.Game/SpriteRenderer.cs b/OpenRa.Game/Graphics/SpriteRenderer.cs similarity index 94% rename from OpenRa.Game/SpriteRenderer.cs rename to OpenRa.Game/Graphics/SpriteRenderer.cs index 5534121f4f..8b3d3433c5 100644 --- a/OpenRa.Game/SpriteRenderer.cs +++ b/OpenRa.Game/Graphics/SpriteRenderer.cs @@ -5,7 +5,7 @@ using OpenRa.FileFormats; using System.Drawing; using Ijw.DirectX; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class SpriteRenderer { diff --git a/OpenRa.Game/SpriteSheetBuilder.cs b/OpenRa.Game/Graphics/SpriteSheetBuilder.cs similarity index 85% rename from OpenRa.Game/SpriteSheetBuilder.cs rename to OpenRa.Game/Graphics/SpriteSheetBuilder.cs index 784f917bc6..5813c74e4e 100644 --- a/OpenRa.Game/SpriteSheetBuilder.cs +++ b/OpenRa.Game/Graphics/SpriteSheetBuilder.cs @@ -1,9 +1,7 @@ -using System; using System.Collections.Generic; -using System.Text; using OpenRa.FileFormats; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { static class SpriteSheetBuilder { diff --git a/OpenRa.Game/TerrainRenderer.cs b/OpenRa.Game/Graphics/TerrainRenderer.cs similarity index 92% rename from OpenRa.Game/TerrainRenderer.cs rename to OpenRa.Game/Graphics/TerrainRenderer.cs index 8681d2476c..cb6dca3f60 100644 --- a/OpenRa.Game/TerrainRenderer.cs +++ b/OpenRa.Game/Graphics/TerrainRenderer.cs @@ -1,15 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenRa.FileFormats; - using System.Drawing; -using System.IO; using System.Windows.Forms; using Ijw.DirectX; using IjwFramework.Collections; +using OpenRa.FileFormats; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class TerrainRenderer { diff --git a/OpenRa.Game/TreeCache.cs b/OpenRa.Game/Graphics/TreeCache.cs similarity index 84% rename from OpenRa.Game/TreeCache.cs rename to OpenRa.Game/Graphics/TreeCache.cs index 86dcf7fe70..f6c95890fb 100644 --- a/OpenRa.Game/TreeCache.cs +++ b/OpenRa.Game/Graphics/TreeCache.cs @@ -1,10 +1,7 @@ -using System; using System.Collections.Generic; -using System.Text; using OpenRa.FileFormats; -using System.Drawing; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class TreeCache { diff --git a/OpenRa.Game/UnitSheetBuilder.cs b/OpenRa.Game/Graphics/UnitSheetBuilder.cs similarity index 88% rename from OpenRa.Game/UnitSheetBuilder.cs rename to OpenRa.Game/Graphics/UnitSheetBuilder.cs index df46fd16bd..96b0b23860 100644 --- a/OpenRa.Game/UnitSheetBuilder.cs +++ b/OpenRa.Game/Graphics/UnitSheetBuilder.cs @@ -1,12 +1,8 @@ -using System; using System.Collections.Generic; -using System.Text; -using OpenRa.FileFormats; -using System.Drawing; using Ijw.DirectX; +using OpenRa.FileFormats; - -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { static class UnitSheetBuilder { diff --git a/OpenRa.Game/Util.cs b/OpenRa.Game/Graphics/Util.cs similarity index 93% rename from OpenRa.Game/Util.cs rename to OpenRa.Game/Graphics/Util.cs index 346127eb96..2d76597447 100644 --- a/OpenRa.Game/Util.cs +++ b/OpenRa.Game/Graphics/Util.cs @@ -1,12 +1,9 @@ using System; using System.Collections.Generic; -using System.Text; -using OpenRa.FileFormats; -using System.Drawing; -using System.IO; using System.Drawing.Imaging; +using System.IO; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { static class Util { diff --git a/OpenRa.Game/Vertex.cs b/OpenRa.Game/Graphics/Vertex.cs similarity index 75% rename from OpenRa.Game/Vertex.cs rename to OpenRa.Game/Graphics/Vertex.cs index e32a5a9ef8..e9d0a054f0 100644 --- a/OpenRa.Game/Vertex.cs +++ b/OpenRa.Game/Graphics/Vertex.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Runtime.InteropServices; -using System.Drawing; using Ijw.DirectX; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { [StructLayout(LayoutKind.Sequential)] struct Vertex diff --git a/OpenRa.Game/Viewport.cs b/OpenRa.Game/Graphics/Viewport.cs similarity index 87% rename from OpenRa.Game/Viewport.cs rename to OpenRa.Game/Graphics/Viewport.cs index 062a487c0a..9ba0db84db 100644 --- a/OpenRa.Game/Viewport.cs +++ b/OpenRa.Game/Graphics/Viewport.cs @@ -1,10 +1,6 @@ -using System; using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Windows.Forms; -namespace OpenRa.Game +namespace OpenRa.Game.Graphics { class Viewport { diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index a9ee92a1ec..d541db0fae 100644 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -1,15 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; using System.Drawing; - +using System.Windows.Forms; using OpenRa.FileFormats; -using System.IO; +using OpenRa.Game.Graphics; using OpenRa.TechTree; namespace OpenRa.Game { + using GRegion = OpenRa.Game.Graphics.Region; + class MainWindow : Form { readonly Renderer renderer; @@ -74,7 +72,7 @@ namespace OpenRa.Game lastPos = new int2(e.Location); if (e.Button == MouseButtons.Left) - foreach (Region region in game.viewport.Regions) + foreach (GRegion region in game.viewport.Regions) if (region.Contains(lastPos)) region.Clicked(e); } diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 14368f039b..4fb47ae327 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -71,53 +71,53 @@ - + - + - - + + - - + - - - - + + + + Form - + - - + + - - - - + + + + - + - + + - - - - + + + + @@ -148,7 +148,7 @@ - +