diff --git a/RecrownedAthenaeum.sln b/RecrownedAthenaeum.sln index ae868d0..36dff34 100644 --- a/RecrownedAthenaeum.sln +++ b/RecrownedAthenaeum.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecrownedAthenaeum.Pipeline EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RecrownedAthenaeum.Tools", "RecrownedAthenaeum.Tools\RecrownedAthenaeum.Tools.csproj", "{51E77E29-AD31-449E-9C98-980E5C978EF9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestGame", "TestGame\TestGame.csproj", "{BA487AFA-D973-4FC6-BA6D-D2E639AD3094}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {51E77E29-AD31-449E-9C98-980E5C978EF9}.Debug|Any CPU.Build.0 = Debug|Any CPU {51E77E29-AD31-449E-9C98-980E5C978EF9}.Release|Any CPU.ActiveCfg = Release|Any CPU {51E77E29-AD31-449E-9C98-980E5C978EF9}.Release|Any CPU.Build.0 = Release|Any CPU + {BA487AFA-D973-4FC6-BA6D-D2E639AD3094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BA487AFA-D973-4FC6-BA6D-D2E639AD3094}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BA487AFA-D973-4FC6-BA6D-D2E639AD3094}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BA487AFA-D973-4FC6-BA6D-D2E639AD3094}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RecrownedAthenaeum/Render/RectangleRenderer.cs b/RecrownedAthenaeum/Render/RectangleRenderer.cs index 9e14ea9..5993ac2 100644 --- a/RecrownedAthenaeum/Render/RectangleRenderer.cs +++ b/RecrownedAthenaeum/Render/RectangleRenderer.cs @@ -106,5 +106,15 @@ namespace RecrownedAthenaeum.Render primitiveBatch.Flush(); } + + /// + /// Draws the given rectangle. + /// + /// Uses the x, y and dimensions to draw a rectangle. + /// The color of the rectangle. + public void Draw(Rectangle rectangle, Color color) + { + Draw(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, color); + } } } diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Image.cs b/RecrownedAthenaeum/UI/Modular/Modules/Image.cs index 9e21f03..413ee9f 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Image.cs +++ b/RecrownedAthenaeum/UI/Modular/Modules/Image.cs @@ -18,17 +18,17 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// /// The texture to be rendered. /// - public Texture2D Texture { get; set; } + public Texture2D texture; /// /// Scale of of the X axis. /// - public float ScaleX { get { return (float)bounds.Width / Texture.Width; } set { bounds.Width = (int)(Texture.Width * value); } } + public float ScaleX { get { return (float)bounds.Width / texture.Width; } set { bounds.Width = (int)(texture.Width * value); } } /// /// Scale of the Y axis. /// - public float ScaleY { get { return (float)bounds.Height / Texture.Height; } set { bounds.Height = (int)(Texture.Height * value); } } + public float ScaleY { get { return (float)bounds.Height / texture.Height; } set { bounds.Height = (int)(texture.Height * value); } } /// /// Sets scale of X and Y. @@ -41,7 +41,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// Texture to use. public Image(Texture2D texture) { - Texture = texture ?? throw new ArgumentException("Image requires a texture."); + this.texture = texture ?? throw new ArgumentException("Image requires a texture."); bounds = texture.Bounds; } @@ -51,7 +51,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// The batch to use. public override void Draw(SpriteBatch batch) { - batch.Draw(Texture, bounds, null, color, rotation, origin, SpriteEffects.None, 0f); + batch.Draw(texture, bounds, null, color, rotation, origin, SpriteEffects.None, 0f); base.Draw(batch); } @@ -67,7 +67,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules { this.color = color; this.rotation = rotation; - this.origin = origin; + this.offset = origin; bounds = destination; Draw(spriteBatch); } diff --git a/RecrownedAthenaeum/UI/Modular/UIModule.cs b/RecrownedAthenaeum/UI/Modular/UIModule.cs index b34b108..04ed30e 100644 --- a/RecrownedAthenaeum/UI/Modular/UIModule.cs +++ b/RecrownedAthenaeum/UI/Modular/UIModule.cs @@ -24,11 +24,17 @@ namespace RecrownedAthenaeum.UI.Modular /// Bounds of this module. /// public Rectangle bounds; + + /// + /// The how much of the entire boundary to offset when drawing. + /// + public Vector2 offset; + /// /// Origin of this module. /// public Vector2 origin; - + /// /// The parent of this module. May be null. /// @@ -59,7 +65,12 @@ namespace RecrownedAthenaeum.UI.Modular /// Batch used to draw. public virtual void Draw(SpriteBatch batch) { - if (Debugging) { rectangleRenderer.Draw(bounds.X, bounds.Y, bounds.Width, bounds.Height, Color.Red); } + if (Debugging) + { + rectangleRenderer.Begin(); + rectangleRenderer.Draw(bounds.X, bounds.Y, bounds.Width, bounds.Height, Color.Red); + rectangleRenderer.End(); + } } /// @@ -115,8 +126,8 @@ namespace RecrownedAthenaeum.UI.Modular /// public void CenterOrigin() { - origin.X = bounds.Width / 2f; - origin.Y = bounds.Height / 2f; + offset.X = bounds.Width / 2f; + offset.Y = bounds.Height / 2f; } } } diff --git a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs b/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs index e422dac..03d705e 100644 --- a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs +++ b/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs @@ -61,8 +61,8 @@ namespace RecrownedAthenaeum.UI.Modular { int offsetX = module.bounds.X; int offsetY = module.bounds.Y; - module.bounds.X = bounds.X + offsetX - (int)module.origin.X; - module.bounds.Y = bounds.Y + offsetY - (int)module.origin.Y; + module.bounds.X = bounds.X + offsetX - (int)module.offset.X; + module.bounds.Y = bounds.Y + offsetY - (int)module.offset.Y; module.Draw(batch); module.bounds.X = offsetX; module.bounds.Y = offsetY; diff --git a/TestGame/Content/Content.mgcb b/TestGame/Content/Content.mgcb new file mode 100644 index 0000000..ddc4c36 --- /dev/null +++ b/TestGame/Content/Content.mgcb @@ -0,0 +1,15 @@ + +#----------------------------- Global Properties ----------------------------# + +/outputDir:bin/$(Platform) +/intermediateDir:obj/$(Platform) +/platform:DesktopGL +/config: +/profile:Reach +/compress:False + +#-------------------------------- References --------------------------------# + + +#---------------------------------- Content ---------------------------------# + diff --git a/TestGame/Icon.bmp b/TestGame/Icon.bmp new file mode 100644 index 0000000..2b48165 Binary files /dev/null and b/TestGame/Icon.bmp differ diff --git a/TestGame/Icon.ico b/TestGame/Icon.ico new file mode 100644 index 0000000..7d9dec1 Binary files /dev/null and b/TestGame/Icon.ico differ diff --git a/TestGame/Program.cs b/TestGame/Program.cs new file mode 100644 index 0000000..f78ace2 --- /dev/null +++ b/TestGame/Program.cs @@ -0,0 +1,20 @@ +using System; + +namespace TestGame +{ + /// + /// The main class. + /// + public static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + using (var game = new TestGame()) + game.Run(); + } + } +} diff --git a/TestGame/Properties/AssemblyInfo.cs b/TestGame/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4c4d240 --- /dev/null +++ b/TestGame/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TestGame")] +[assembly: AssemblyProduct("TestGame")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7e819304-4003-4dfd-a017-31ff408f5736")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TestGame/TestGame.cs b/TestGame/TestGame.cs new file mode 100644 index 0000000..e42cd4b --- /dev/null +++ b/TestGame/TestGame.cs @@ -0,0 +1,83 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; + +namespace TestGame +{ + /// + /// This is the main type for your game. + /// + public class TestGame : Game + { + GraphicsDeviceManager graphics; + SpriteBatch spriteBatch; + + public TestGame() + { + graphics = new GraphicsDeviceManager(this); + Content.RootDirectory = "Content"; + } + + /// + /// Allows the game to perform any initialization it needs to before starting to run. + /// This is where it can query for any required services and load any non-graphic + /// related content. Calling base.Initialize will enumerate through any components + /// and initialize them as well. + /// + protected override void Initialize() + { + // TODO: Add your initialization logic here + + base.Initialize(); + } + + /// + /// LoadContent will be called once per game and is the place to load + /// all of your content. + /// + protected override void LoadContent() + { + // Create a new SpriteBatch, which can be used to draw textures. + spriteBatch = new SpriteBatch(GraphicsDevice); + + // TODO: use this.Content to load your game content here + } + + /// + /// UnloadContent will be called once per game and is the place to unload + /// game-specific content. + /// + protected override void UnloadContent() + { + // TODO: Unload any non ContentManager content here + } + + /// + /// Allows the game to run logic such as updating the world, + /// checking for collisions, gathering input, and playing audio. + /// + /// Provides a snapshot of timing values. + protected override void Update(GameTime gameTime) + { + if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) + Exit(); + + // TODO: Add your update logic here + + base.Update(gameTime); + } + + /// + /// This is called when the game should draw itself. + /// + /// Provides a snapshot of timing values. + protected override void Draw(GameTime gameTime) + { + GraphicsDevice.Clear(Color.CornflowerBlue); + + // TODO: Add your drawing code here + + base.Draw(gameTime); + } + } +} diff --git a/TestGame/TestGame.csproj b/TestGame/TestGame.csproj new file mode 100644 index 0000000..a3e3455 --- /dev/null +++ b/TestGame/TestGame.csproj @@ -0,0 +1,117 @@ + + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {BA487AFA-D973-4FC6-BA6D-D2E639AD3094} + WinExe + Properties + TestGame + TestGame + 512 + DesktopGL + v4.5 + + + true + bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ + DEBUG;TRACE;LINUX + full + AnyCPU + prompt + false + 4 + + + bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ + TRACE;LINUX + true + pdbonly + AnyCPU + prompt + false + 4 + + + Icon.ico + + + app.manifest + + + + + + + + + $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll + + + + + + + + + + + + x86\SDL2.dll + PreserveNewest + + + x64\SDL2.dll + PreserveNewest + + + x86\soft_oal.dll + PreserveNewest + + + x64\soft_oal.dll + PreserveNewest + + + x86\libSDL2-2.0.so.0 + PreserveNewest + + + x64\libSDL2-2.0.so.0 + PreserveNewest + + + x86\libopenal.so.1 + PreserveNewest + + + x64\libopenal.so.1 + PreserveNewest + + + libSDL2-2.0.0.dylib + PreserveNewest + + + libopenal.1.dylib + PreserveNewest + + + MonoGame.Framework.dll.config + PreserveNewest + + + + + + + \ No newline at end of file diff --git a/TestGame/app.manifest b/TestGame/app.manifest new file mode 100644 index 0000000..e7b263d --- /dev/null +++ b/TestGame/app.manifest @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true/pm + + + +