refactor: removed dash from project name and underscore from namespaces. Began working on pipeline project.

This commit is contained in:
Harrison Deng 2018-12-04 19:19:31 -06:00
parent 52fa550ced
commit 151480eaee
40 changed files with 316 additions and 114 deletions

View File

@ -1,57 +0,0 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Recrowned_Athenaeum.DataTypes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace RecrownedAthenaeum.DataTypes
{
public class TextureAtlas
{
string assetName;
private TextureAtlasRegion[] textureRegions;
[XmlIgnore]
private Texture2D texture;
[XmlIgnore]
private Dictionary<string, TextureAtlasRegion> dictionaryOfRegions = new Dictionary<string, TextureAtlasRegion>();
/// <summary>
/// Should be called after serialization to prepare the data.
/// More specifically, loads the texture map, as well as load the regions into a dictionary.
/// <param name="texture">the texture for the atlas.</param>
/// </summary>
public void Initialize(Texture2D texture)
{
SetTextureRegions(texture, textureRegions);
}
public void SetTextureRegions(Texture2D texture, TextureAtlasRegion[] regions)
{
this.texture = texture;
Array.Sort(regions);
this.textureRegions = regions;
dictionaryOfRegions.Clear();
foreach (TextureAtlasRegion region in textureRegions)
{
dictionaryOfRegions.Add(region.name, region);
}
}
public void Draw(SpriteBatch batch, Rectangle destinationRectangle, string textureRegionName)
{
dictionaryOfRegions[textureRegionName].Draw(batch, destinationRectangle, );
}
public Texture2D TextureOfRegion(string name, GraphicsDevice graphicsDevice)
{
return dictionaryOfRegions[name].AsTexture2D(graphicsDevice, texture);
}
}
}

View File

@ -1,51 +0,0 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RecrownedAthenaeum.DataTypes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace Recrowned_Athenaeum.DataTypes
{
public struct TextureAtlasRegion : IComparable<TextureAtlasRegion>, IDisposable
{
public string name;
Rectangle sourceRectangle;
Vector2 origin;
Color color;
float rotation;
NinePatch ninepatch;
[XmlIgnore]
Texture2D regionTexture;
public void Draw(SpriteBatch batch, Rectangle destination, Texture2D regionOfTexture)
{
batch.Draw(regionOfTexture, destination, sourceRectangle, color);
}
public Texture2D AsTexture2D(GraphicsDevice graphicsDevice, Texture2D textureAtlas)
{
if (regionTexture == null)
{
Color[] data = new Color[sourceRectangle.Width * sourceRectangle.Height];
regionTexture = new Texture2D(graphicsDevice, sourceRectangle.Width, sourceRectangle.Height);
textureAtlas.GetData(0, sourceRectangle, data, 0, sourceRectangle.Width * sourceRectangle.Height);
regionTexture.SetData(data);
}
return regionTexture;
}
public int CompareTo(TextureAtlasRegion other)
{
return name.CompareTo(other);
}
public void Dispose()
{
regionTexture?.Dispose();
}
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RecrownedAthenaeum.Pipeline.NinePatch
{
class NinePatchTemplate
{
public string name;
public string bounds;
public int a, b, c, d;
}
}

View File

@ -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("RecrownedAthenaeum.Pipeline")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RecrownedAthenaeum.Pipeline")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[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("b38f9812-b1d1-4bfe-89ee-fc4dd4ebaa3f")]
// 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")]

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B38F9812-B1D1-4BFE-89EE-FC4DD4EBAA3F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RecrownedAthenaeum.Pipeline</RootNamespace>
<AssemblyName>RecrownedAthenaeum.Pipeline</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MonoGame.Framework, Version=3.7.0.1708, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.Framework.Portable.3.7.0.1708\lib\portable-net45+win8+wpa81\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="MonoGame.Framework.Content.Pipeline, Version=3.7.0.1708, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.Framework.Content.Pipeline.Portable.3.7.0.1708\lib\portable-net45+win8+wpa81\MonoGame.Framework.Content.Pipeline.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="NinePatch\NinePatchTemplate.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TextureAtlas\TextureAtlasWriter.cs" />
<Compile Include="TextureAtlas\TextureAtlasImporter.cs" />
<Compile Include="TextureAtlas\TextureAtlasProcessor.cs" />
<Compile Include="TextureAtlas\TextureAtlasTemplate.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RecrownedAthenaeum\RecrownedAthenaeum.csproj">
<Project>{95a926dc-1482-4368-91da-8d30ac04740a}</Project>
<Name>RecrownedAthenaeum</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,26 @@
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Graphics;
using RecrownedAthenaeum.DataTypes;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
{
internal class TextureAtlasImporter : ContentImporter<TextureAtlasTemplate>
{
public override TextureAtlasTemplate Import(string filename, ContentImporterContext context)
{
StreamReader stream = new StreamReader(filename);
XmlSerializer serializer = new XmlSerializer(typeof(TextureAtlasTemplate));
TextureAtlasTemplate atlas = (TextureAtlasTemplate)serializer.Deserialize(stream);
context.AddDependency(atlas.textureName);
stream.Dispose();
return atlas;
}
}
}

View File

@ -0,0 +1,21 @@
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Graphics;
using RecrownedAthenaeum.DataTypes;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
{
class TextureAtlasProcessor : ContentProcessor<TextureAtlasTemplate, TextureAtlasTemplate>
{
public override TextureAtlasTemplate Process(TextureAtlasTemplate input, ContentProcessorContext context)
{
return input;
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
{
public class TextureAtlasTemplate
{
public string textureName;
public TextureAtlasRegion[] regions;
public class TextureAtlasRegion
{
public string name;
public Rectangle location;
}
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
{
class TextureAtlasWriter : ContentTypeWriter<TextureAtlasTemplate>
{
public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
throw new NotImplementedException();
}
protected override void Write(ContentWriter output, TextureAtlasTemplate value)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MonoGame.Framework.Content.Pipeline.Portable" version="3.7.0.1708" targetFramework="net45" />
<package id="MonoGame.Framework.Portable" version="3.7.0.1708" targetFramework="net45" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net45" />
</packages>

View File

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Recrowned-Athenaeum", "Recrowned-Athenaeum\Recrowned-Athenaeum.csproj", "{95A926DC-1482-4368-91DA-8D30AC04740A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecrownedAthenaeum", "RecrownedAthenaeum\RecrownedAthenaeum.csproj", "{95A926DC-1482-4368-91DA-8D30AC04740A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecrownedAthenaeum.Pipeline", "RecrownedAthenaeum.Pipeline\RecrownedAthenaeum.Pipeline.csproj", "{B38F9812-B1D1-4BFE-89EE-FC4DD4EBAA3F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +17,10 @@ Global
{95A926DC-1482-4368-91DA-8D30AC04740A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95A926DC-1482-4368-91DA-8D30AC04740A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95A926DC-1482-4368-91DA-8D30AC04740A}.Release|Any CPU.Build.0 = Release|Any CPU
{B38F9812-B1D1-4BFE-89EE-FC4DD4EBAA3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B38F9812-B1D1-4BFE-89EE-FC4DD4EBAA3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B38F9812-B1D1-4BFE-89EE-FC4DD4EBAA3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B38F9812-B1D1-4BFE-89EE-FC4DD4EBAA3F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,73 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RecrownedAthenaeum.DataTypes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace RecrownedAthenaeum.DataTypes
{
public class TextureAtlas
{
private Texture2D texture;
private Dictionary<string, TextureAtlasRegion> dictionaryOfRegions = new Dictionary<string, TextureAtlasRegion>();
public TextureAtlas(Texture2D texture, TextureAtlasRegion[] regions)
{
this.texture = texture;
foreach (TextureAtlasRegion region in regions)
{
dictionaryOfRegions.Add(region.name, region);
}
}
public void Draw(string name, SpriteBatch batch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = new Vector2())
{
dictionaryOfRegions[name].Draw(batch, destination, texture, color, rotation, origin);
}
public Texture2D TextureOfRegion(string name, GraphicsDevice graphicsDevice)
{
return dictionaryOfRegions[name].AsTexture2D(graphicsDevice, texture);
}
public struct TextureAtlasRegion : IComparable<TextureAtlasRegion>, IDisposable
{
public string name;
Rectangle sourceRectangle;
NinePatch ninepatch;
Texture2D regionTexture;
public void Draw(SpriteBatch batch, Rectangle destination, Texture2D fromTexture, Color color, float rotation, Vector2 origin)
{
batch.Draw(fromTexture, destination, sourceRectangle, color, rotation, origin, SpriteEffects.None, 0f);
}
public Texture2D AsTexture2D(GraphicsDevice graphicsDevice, Texture2D textureAtlas)
{
if (regionTexture == null)
{
Color[] data = new Color[sourceRectangle.Width * sourceRectangle.Height];
regionTexture = new Texture2D(graphicsDevice, sourceRectangle.Width, sourceRectangle.Height);
textureAtlas.GetData(0, sourceRectangle, data, 0, sourceRectangle.Width * sourceRectangle.Height);
regionTexture.SetData(data);
}
return regionTexture;
}
public int CompareTo(TextureAtlasRegion other)
{
return name.CompareTo(other);
}
public void Dispose()
{
regionTexture?.Dispose();
}
}
}
}

View File

@ -7,7 +7,7 @@ using System.Xml.Serialization;
namespace RecrownedAthenaeum.Persistence
{
public class Preferences
public interface Preferences
{
}
}

View File

@ -7,11 +7,13 @@
<ProjectGuid>{95A926DC-1482-4368-91DA-8D30AC04740A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Recrowned_Athenaeum</RootNamespace>
<AssemblyName>Recrowned-Athenaeum</AssemblyName>
<RootNamespace>RecrownedAthenaeum</RootNamespace>
<AssemblyName>RecrownedAthenaeum</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -31,7 +33,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MonoGame.Framework, Version=3.6.0.1625, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="MonoGame.Framework, Version=3.7.0.1708, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.Framework.Portable.3.7.0.1708\lib\portable-net45+win8+wpa81\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@ -50,7 +57,6 @@
<Compile Include="DataTypes\NinePatch.cs" />
<Compile Include="DataTypes\Resolution.cs" />
<Compile Include="DataTypes\TextureAtlas.cs" />
<Compile Include="DataTypes\TextureAtlasRegion.cs" />
<Compile Include="Input\IInputListener.cs" />
<Compile Include="Input\InputListener.cs" />
<Compile Include="Input\InputUtilities.cs" />
@ -79,6 +85,7 @@
<None Include="obj\Debug\Recrowned-Athenaeum.csproj.CoreCompileInputs.cache" />
<None Include="obj\Debug\Recrowned-Athenaeum.csprojAssemblyReference.cache" />
<None Include="obj\Release\Recrowned-Athenaeum.csproj.CoreCompileInputs.cache" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="bin\Debug\" />

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MonoGame.Framework.Portable" version="3.7.0.1708" targetFramework="net45" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net45" />
</packages>