This repository has been archived by the owner on Mar 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Toolkit.Yaml] Add new SharpDX.Toolkit.Yaml project that allows to lo…
…ad Yaml files directly into .NET object using the ContentManager.
- Loading branch information
Showing
16 changed files
with
1,287 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Samples/Toolkit/Common/CustomDataLoading/Content/MyData.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
!MyData | ||
Name: This text was loaded from MyData.yml | ||
SimpleValue: 1.0 | ||
Color: { R: 128, G: 128, B: 128, A: 128} | ||
Vectors: | ||
- {X: 0, Y: 0, Z: 0, W: 1} | ||
- {X: 1, Y: 0, Z: 0, W: 1} | ||
- {X: 2, Y: 0, Z: 0, W: 1} | ||
- {X: 3, Y: 0, Z: 0, W: 1} | ||
- {X: 4, Y: 0, Z: 0, W: 1} | ||
- {X: 5, Y: 0, Z: 0, W: 1} |
111 changes: 111 additions & 0 deletions
111
Samples/Toolkit/Common/CustomDataLoading/CustomDataLoadingGame.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
using System.Collections.Generic; | ||
|
||
using SharpDX; | ||
using SharpDX.Toolkit; | ||
using SharpDX.Toolkit.Yaml; | ||
|
||
namespace CustomLoadingData | ||
{ | ||
// Use this namespace here in case we need to use Direct3D11 namespace as well, as this | ||
// namespace will override the Direct3D11. | ||
using SharpDX.Toolkit.Graphics; | ||
|
||
/// <summary> | ||
/// Simple CustomLoadingData application using SharpDX.Toolkit. | ||
/// The purpose of this application is to demonstrate how to load YAML data into .NET objects | ||
/// using the Content Manager. | ||
/// </summary> | ||
public class CustomLoadingDataGame : Game | ||
{ | ||
private GraphicsDeviceManager graphicsDeviceManager; | ||
private YamlManager yamlManager; | ||
private MyData loadedMyData; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CustomLoadingDataGame" /> class. | ||
/// </summary> | ||
public CustomLoadingDataGame() | ||
{ | ||
// Creates a graphics manager. This is mandatory. | ||
graphicsDeviceManager = new GraphicsDeviceManager(this); | ||
graphicsDeviceManager.PreferredDepthStencilFormat = DepthFormat.None; | ||
|
||
|
||
// In order to support Yaml loading, we need to add the YamlManager | ||
yamlManager = new YamlManager(this); | ||
GameSystems.Add(yamlManager); | ||
|
||
// Register that !MyData will map to our local type. | ||
// We could have used YamlTagAttribute directly on our MyData type from YamlDotNet library. | ||
yamlManager.RegisterTagMapping("MyData",typeof(MyData)); | ||
|
||
// Setup the relative directory to the executable directory | ||
// for loading contents with the ContentManager | ||
Content.RootDirectory = "Content"; | ||
} | ||
|
||
protected override void Initialize() | ||
{ | ||
Window.Title = "Yaml Data Loading"; | ||
|
||
base.Initialize(); | ||
} | ||
|
||
protected override void LoadContent() | ||
{ | ||
loadedMyData = Content.Load<MyData>("MyData.yml"); | ||
Window.Title = string.Format("Yaml Data Loading: [{0}]", loadedMyData.Name); | ||
|
||
base.LoadContent(); | ||
} | ||
|
||
protected override void Draw(GameTime gameTime) | ||
{ | ||
// Clear the color using MyData | ||
GraphicsDevice.Clear(loadedMyData.Color); | ||
|
||
// Handle base.Draw | ||
base.Draw(gameTime); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// A Simple type demonstrating how to load data from YAML to .NET object instance. | ||
/// </summary> | ||
public class MyData | ||
{ | ||
public MyData() | ||
{ | ||
Vectors = new List<Vector4>(); | ||
} | ||
|
||
public string Name { get; set; } | ||
|
||
public Color Color { get; set; } | ||
|
||
public float SimpleValue { get; set; } | ||
|
||
public List<Vector4> Vectors { get; set; } | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
Samples/Toolkit/Desktop/CustomDataLoading/CustomDataLoading.Desktop.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" 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>{72E1AFCD-4E5B-428A-A4C8-0B179F660BA6}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CustomDataLoading</RootNamespace> | ||
<AssemblyName>CustomDataLoading.Desktop</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<UseVSHostingProcess>true</UseVSHostingProcess> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<StartupObject /> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<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.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\..\Common\CustomDataLoading\CustomDataLoadingGame.cs"> | ||
<Link>CustomDataLoadingGame.cs</Link> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="..\..\Common\CustomDataLoading\Content\MyData.yml"> | ||
<Link>Content\MyData.yml</Link> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="..\..\..\..\SharpDX.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
using System; | ||
|
||
namespace CustomLoadingData | ||
{ | ||
/// <summary> | ||
/// Simple SpriteBatchAndFont application using SharpDX.Toolkit. | ||
/// </summary> | ||
class Program | ||
{ | ||
/// <summary> | ||
/// Defines the entry point of the application. | ||
/// </summary> | ||
#if NETFX_CORE | ||
[MTAThread] | ||
#else | ||
[STAThread] | ||
#endif | ||
static void Main() | ||
{ | ||
using (var program = new CustomLoadingDataGame()) | ||
program.Run(); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Samples/Toolkit/Desktop/CustomDataLoading/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("SpriteBatchAndFont")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("SpriteBatchAndFont")] | ||
[assembly: AssemblyCopyright("Copyright © 2012")] | ||
[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("aa8e09eb-19f9-44df-a586-c0b424001031")] | ||
|
||
// 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")] |
Oops, something went wrong.