diff --git a/Build/Module.xml b/Build/Module.xml
index 2d79393ba50..57035b845f1 100644
--- a/Build/Module.xml
+++ b/Build/Module.xml
@@ -4,8 +4,8 @@
Generate
Angle,Linux,WindowsGL
Angle,MacOS,iOS,WindowsGL,Android,tvOS,Linux
- Android,Angle,Linux,Ouya,Windows8,Windows,WindowsGL,WindowsPhone,WindowsPhone81,WindowsUniversal,iOS,tvOS
- Android,Angle,Linux,Ouya,Windows8,Windows,WindowsGL,WindowsPhone,WindowsPhone81,WindowsUniversal,iOS,MacOS,Web,tvOS,PSVita,XBoxOne
+ Android,Angle,Linux,Windows8,Windows,WindowsGL,WindowsPhone81,WindowsUniversal,iOS,tvOS
+ Android,Angle,Linux,Windows8,Windows,WindowsGL,WindowsPhone81,WindowsUniversal,iOS,MacOS,Web,tvOS,PSVita,XBoxOne
true
false
diff --git a/Build/Projects/FrameworkReferences.Net.definition b/Build/Projects/FrameworkReferences.Net.definition
index 8061512184e..1ca6964a989 100644
--- a/Build/Projects/FrameworkReferences.Net.definition
+++ b/Build/Projects/FrameworkReferences.Net.definition
@@ -36,17 +36,6 @@
-
-
-
-
-
-
-
-
-
@@ -66,17 +55,6 @@
-
-
-
-
- MicrosoftXnaGamerServices
-
-
- MicrosoftXnaFramework
-
-
-
diff --git a/Build/Projects/FrameworkReferences.definition b/Build/Projects/FrameworkReferences.definition
index 5bcd00c8e18..065351d5f95 100644
--- a/Build/Projects/FrameworkReferences.definition
+++ b/Build/Projects/FrameworkReferences.definition
@@ -45,17 +45,6 @@
-
-
-
-
-
-
-
-
-
@@ -144,33 +133,6 @@
-
-
-
-
-
-
-
-
-
-
- MicrosoftXnaFramework
-
-
- MicrosoftXnaGamerServices
-
-
-
diff --git a/Build/Projects/Lidgren.Network.References.definition b/Build/Projects/Lidgren.Network.References.definition
index 8f617d6b307..a006e8d0835 100644
--- a/Build/Projects/Lidgren.Network.References.definition
+++ b/Build/Projects/Lidgren.Network.References.definition
@@ -25,12 +25,6 @@
-
-
-
-
-
-
diff --git a/Build/Projects/Lidgren.Network.definition b/Build/Projects/Lidgren.Network.definition
index 9da3fa8efe7..e46c2372200 100644
--- a/Build/Projects/Lidgren.Network.definition
+++ b/Build/Projects/Lidgren.Network.definition
@@ -3,7 +3,7 @@
Name="Lidgren.Network"
Path="ThirdParty/Lidgren.Network"
Type="Library"
- Platforms="Android,Linux,MacOS,Ouya,Windows,WindowsGL,iOS">
+ Platforms="Android,Linux,MacOS,Windows,WindowsGL,iOS">
-
- MonoGameXnaFramework
-
-
+
@@ -47,11 +42,9 @@
IOS;GLES;OPENGL;OPENAL;NET
TRACE;LINUX;OPENGL;OPENAL;NET;DESKTOPGL
MONOMAC;OPENGL;OPENAL;NET
- TRACE;ANDROID;GLES;OPENGL;OUYA;NET
TRACE;WINDOWS;DIRECTX;WINDOWS_MEDIA_SESSION;NET
TRACE;NETFX_CORE;WINRT;WINDOWS_STOREAPP;DIRECTX;DIRECTX11_1;WINDOWS_MEDIA_ENGINE;NET
TRACE;WINDOWS;OPENGL;OPENAL;NET;DESKTOPGL
- TRACE;SILVERLIGHT;WINDOWS_PHONE;WINRT;DIRECTX;NET
TRACE;WINRT;WINDOWS_PHONE81;DIRECTX;WINDOWS_STOREAPP
TRACE;NETFX_CORE;WINDOWS_UAP;WINRT;DIRECTX;DIRECTX11_1;WINDOWS_MEDIA_ENGINE
@@ -69,45 +62,19 @@
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -115,122 +82,120 @@
-
- WindowsPhone
-
+
- Android,MacOS,Ouya,Windows,WindowsGL,Linux
+ Android,MacOS,Windows,WindowsGL,Linux
MacOS,Windows,WindowsGL,Linux
- Android,iOS,Linux,MacOS,Ouya,Windows,WindowsGL
+ Android,iOS,Linux,MacOS,Windows,WindowsGL
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
- WindowsPhone,WindowsPhone81,Windows8,WindowsUniversal
+ WindowsPhone81,Windows8,WindowsUniversal
-
+
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
@@ -296,7 +261,7 @@
- Windows8,Windows,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Windows8,Windows,WindowsPhone81,WindowsUniversal
Windows
diff --git a/Build/Projects/MonoGame.Framework.definition b/Build/Projects/MonoGame.Framework.definition
index d5defb5409a..acc1de9e681 100644
--- a/Build/Projects/MonoGame.Framework.definition
+++ b/Build/Projects/MonoGame.Framework.definition
@@ -1,5 +1,5 @@
-
+
- Angle,iOS,Linux,Windows,WindowsGL,MacOS,Android,Ouya,tvOS
+ Angle,iOS,Linux,Windows,WindowsGL,MacOS,Android,tvOS
XAudioAudio,WebAudio
- Windows,Windows8,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Windows,Windows8,WindowsPhone81,WindowsUniversal
OpenALAudio,WebAudio
@@ -168,9 +164,6 @@
MacOS
-
- Ouya
-
Angle
@@ -181,7 +174,7 @@
Windows
- WindowsPhone,WindowsPhone81
+ WindowsPhone81
Windows8
@@ -261,19 +254,19 @@
- Android,Ouya
+ Android
libs\armeabi-v7a\libopenal32.so
- Android,Ouya
+ Android
libs\arm64-v8a\libopenal32.so
- Android,Ouya
+ Android
libs\x86\libopenal32.so
- Android,Ouya
+ Android
libs\x86_64\libopenal32.so
@@ -304,7 +297,7 @@
Angle,Linux,MacOS,Windows,Windows8,WindowsGL,WindowsUniversal
- Android,iOS,Ouya,WindowsPhone,WindowsPhone81,Web,tvOS
+ Android,iOS,WindowsPhone81,Web,tvOS
@@ -313,7 +306,7 @@
Windows8,WindowsPhone81
- Windows8,WindowsPhone,WindowsPhone81
+ Windows8,WindowsPhone81
@@ -333,7 +326,7 @@
- Android,MacOS,Ouya
+ Android,MacOS
@@ -346,11 +339,11 @@
Angle,Linux,MacOS,Windows,WindowsGL,WindowsUniversal
- Android,Angle,iOS,Linux,MacOS,Ouya,WindowsGL,WindowsPhone,tvOS
+ Android,Angle,iOS,Linux,MacOS,WindowsGL,tvOS
- Android,Ouya
+ Android
Angle,Linux,Windows,WindowsGL,Web
@@ -361,9 +354,6 @@
Windows8,WindowsPhone81,WindowsUniversal
-
- WindowsPhone
-
@@ -376,7 +366,7 @@
- Linux,WindowsGL,Angle,Android,Ouya
+ Linux,WindowsGL,Angle,Android
@@ -391,7 +381,7 @@
- Android,Angle,iOS,Linux,MacOS,Ouya,WindowsGL,Web,tvOS
+ Android,Angle,iOS,Linux,MacOS,WindowsGL,Web,tvOS
@@ -514,13 +504,13 @@
- Angle,Linux,MacOS,Windows8,Windows,WindowsGL,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Angle,Linux,MacOS,Windows8,Windows,WindowsGL,WindowsPhone81,WindowsUniversal
- Android,Angle,iOS,Linux,MacOS,Ouya,Windows8,Windows,WindowsGL,WindowsPhone,WindowsPhone81,WindowsUniversal,tvOS
+ Android,Angle,iOS,Linux,MacOS,Windows8,Windows,WindowsGL,WindowsPhone81,WindowsUniversal,tvOS
- Android,Angle,iOS,Linux,MacOS,Ouya,Windows8,Windows,WindowsGL,WindowsPhone,WindowsPhone81,WindowsUniversal,tvOS
+ Android,Angle,iOS,Linux,MacOS,Windows8,Windows,WindowsGL,WindowsPhone81,WindowsUniversal,tvOS
@@ -532,7 +522,7 @@
- Angle,Linux,WindowsGL,WindowsPhone,Web,tvOS
+ Angle,Linux,WindowsGL,Web,tvOS
@@ -543,7 +533,7 @@
- Angle,Android,iOS,Linux,Ouya,Windows,WindowsGL,tvOS
+ Angle,Android,iOS,Linux,Windows,WindowsGL,tvOS
@@ -555,13 +545,13 @@
- Windows,Windows8,WindowsPhone,WindowsPhone81,WindowsUniversal,Web
+ Windows,Windows8,WindowsPhone81,WindowsUniversal,Web
- Windows8,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Windows8,WindowsPhone81,WindowsUniversal
- Android,Angle,iOS,Linux,MacOS,Ouya,WindowsGL,tvOS
+ Android,Angle,iOS,Linux,MacOS,WindowsGL,tvOS
@@ -604,15 +594,24 @@
- Android,Angle,iOS,Linux,MacOS,Ouya,WindowsGL,tvOS,Web
+ Android,Angle,iOS,Linux,MacOS,WindowsGL,tvOS,Web
DirectXGraphics
- Android,Angle,iOS,Linux,MacOS,Ouya,WindowsGL,tvOS,Web
+ Android,Angle,iOS,Linux,MacOS,WindowsGL,tvOS,Web
+
+ DirectXGraphics
+
+
+ OpenGLGraphics,ANGLEGraphics
+
+
+ WebGraphics
+
WindowsGL,Linux
@@ -636,7 +635,7 @@
- Angle,Linux,Windows8,Windows,WindowsGL,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Angle,Linux,Windows8,Windows,WindowsGL,WindowsPhone81,WindowsUniversal
@@ -650,14 +649,14 @@
- iOS,Android,Ouya
+ iOS,Android
DirectXGraphics
ANGLEGraphics,OpenGLGraphics
- iOS,Android,Ouya
+ iOS,Android
WebGraphics
@@ -755,7 +754,7 @@
WebGraphics
- Android,Angle,iOS,Linux,MacOS,Ouya,WindowsGL,tvOS
+ Android,Angle,iOS,Linux,MacOS,WindowsGL,tvOS
@@ -939,7 +938,7 @@
- WindowsPhone,WindowsPhone81
+ WindowsPhone81
Android
@@ -950,9 +949,6 @@
tvOS
-
- Ouya
-
Linux,WindowsGL
@@ -981,7 +977,7 @@
- Angle,Android,MacOS,Ouya,Windows8,Windows,WindowsPhone,WindowsPhone81,WindowsUniversal,iOS,tvOS
+ Angle,Android,MacOS,Windows8,Windows,WindowsPhone81,WindowsUniversal,iOS,tvOS
Linux,WindowsGL
@@ -990,10 +986,10 @@
Web
- Android,Ouya
+ Android
- Android,Ouya,Windows,WindowsGL,Linux
+ Android,Windows,WindowsGL,Linux
WindowsGL,Linux
@@ -1002,7 +998,7 @@
Windows
- Android,iOS,Windows8,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Android,iOS,Windows8,WindowsPhone81,WindowsUniversal
Android
@@ -1010,9 +1006,6 @@
iOS
-
- WindowsPhone
-
Windows8,WindowsPhone81,WindowsUniversal
@@ -1020,7 +1013,7 @@
- Android,iOS,Windows8,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Android,iOS,Windows8,WindowsPhone81,WindowsUniversal
Android
@@ -1028,9 +1021,6 @@
iOS
-
- WindowsPhone
-
Windows8,WindowsPhone81,WindowsUniversal
@@ -1064,7 +1054,7 @@
- Windows8,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Windows8,WindowsPhone81,WindowsUniversal
@@ -1080,10 +1070,10 @@
- iOS,Windows8,WindowsPhone,Android,Ouya,WindowsPhone81,WindowsUniversal
+ iOS,Windows8,Android,WindowsPhone81,WindowsUniversal
- Android,Ouya
+ Android
iOS
@@ -1091,9 +1081,6 @@
Windows8,WindowsPhone81,WindowsUniversal
-
- WindowsPhone
-
Windows
@@ -1104,11 +1091,8 @@
Windows
-
- WindowsPhone
-
- Angle,WindowsGL,Linux,MacOS,iOS,Android,Ouya,Web,tvOS
+ Angle,WindowsGL,Linux,MacOS,iOS,Android,Web,tvOS
@@ -1125,7 +1109,7 @@
Angle,MacOS,Web
- Android,Ouya
+ Android
iOS,tvOS
@@ -1136,15 +1120,12 @@
Windows
-
- WindowsPhone
-
Windows8,WindowsPhone81,WindowsUniversal
- Angle,Linux,WindowsGL,WindowsPhone,Web,tvOS
+ Angle,Linux,WindowsGL,Web,tvOS
iOS
@@ -1153,13 +1134,13 @@
MacOS
- Android,Ouya
+ Android
Windows
- Angle,Linux,WindowsGL,WindowsPhone,Web,tvOS
+ Angle,Linux,WindowsGL,Web,tvOS
iOS
@@ -1171,7 +1152,7 @@
MacOS
- Android,Ouya
+ Android
Windows
@@ -1179,31 +1160,31 @@
- Android,iOS,Ouya
+ Android,iOS
- Android,iOS,Ouya
+ Android,iOS
- Android,iOS,Ouya
+ Android,iOS
- Android,iOS,Ouya
+ Android,iOS
- Android,iOS,Ouya
+ Android,iOS
- Android,iOS,Ouya
+ Android,iOS
- Android,iOS,Ouya
+ Android,iOS
- Android,iOS,Ouya
+ Android,iOS
- Android,iOS,Ouya
+ Android,iOS
@@ -1217,6 +1198,12 @@
+
+ Android,iOS,MacOS,Windows8,WindowsPhone81,WindowsUniversal,tvOS
+
+
+ Angle,Linux,Windows,WindowsGL,WindowsPhone,Web
+
@@ -1226,45 +1213,45 @@
-
+
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
- Android,Ouya
+ Android
@@ -1375,10 +1362,10 @@
Windows8,WindowsPhone81
- Windows8,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Windows8,WindowsPhone81,WindowsUniversal
- Windows8,Windows,WindowsPhone,WindowsPhone81,WindowsUniversal
+ Windows8,Windows,WindowsPhone81,WindowsUniversal
Windows8,WindowsPhone81
@@ -1412,26 +1399,6 @@
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
- WindowsPhone
-
-
Web
diff --git a/Build/Projects/MonoGame.Tests.definition b/Build/Projects/MonoGame.Tests.definition
index d0b3ce48c9d..6d147c3f954 100644
--- a/Build/Projects/MonoGame.Tests.definition
+++ b/Build/Projects/MonoGame.Tests.definition
@@ -12,7 +12,7 @@
-
+
Default
1591,0436
Build/MonoDevelopPolicies.xml
@@ -95,7 +95,7 @@
-
+
@@ -121,7 +121,7 @@
-
+
@@ -139,7 +139,9 @@
-
+
+ Windows
+
@@ -152,7 +154,9 @@
-
+
+ Windows
+
@@ -239,7 +243,7 @@
PreserveNewest
-
+
PreserveNewest
@@ -473,6 +477,15 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
@@ -640,6 +653,12 @@
PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
PreserveNewest
diff --git a/Build/Projects/Pipeline.definition b/Build/Projects/Pipeline.definition
index c8c7d97e9a9..007a4b1756d 100644
--- a/Build/Projects/Pipeline.definition
+++ b/Build/Projects/Pipeline.definition
@@ -122,6 +122,8 @@
+
+
Pad.cs
@@ -231,6 +233,9 @@
Build.Succeed.png
+
+ Build.SucceedWithWarnings.png
+
diff --git a/Documentation/Styles/MonoGame/css/sharpdoc.css b/Documentation/Styles/MonoGame/css/sharpdoc.css
index 0df6f1e0b62..a8ca4c3e676 100644
--- a/Documentation/Styles/MonoGame/css/sharpdoc.css
+++ b/Documentation/Styles/MonoGame/css/sharpdoc.css
@@ -378,17 +378,6 @@
background-image:url("../images/android.png");
}
-.sharpdoc div.icon.ouya
-{
- background-image:url("../images/ouya.png");
-}
-
-.sharpdoc div.icon.psm
-{
- background-image:url("../images/psm.png");
-}
-
-
.sharpdoc .content .section .members table {
table-layout:fixed;
width:100%;
diff --git a/Documentation/config.xml b/Documentation/config.xml
index 9ff5dbddb50..319231d96a7 100644
--- a/Documentation/config.xml
+++ b/Documentation/config.xml
@@ -90,11 +90,6 @@
..\MonoGame.Framework\bin\Windows8\AnyCPU\Release\MonoGame.Framework.dll
-
-
- ..\MonoGame.Framework\bin\WindowsPhone\x86\Release\MonoGame.Framework.dll
-
-
..\MonoGame.Framework\bin\Web\AnyCPU\Release\MonoGame.Framework.dll
@@ -114,11 +109,4 @@
-->
-
-
-
diff --git a/Documentation/content_intro.md b/Documentation/content_intro.md
index e1a862a8b23..dce6e337783 100644
--- a/Documentation/content_intro.md
+++ b/Documentation/content_intro.md
@@ -6,7 +6,7 @@ This section will cover the following topics:
- What is Game Content
- [Using The Pipeline Tool](using_pipeline_tool.md)
- - [Using TrueType Fonts](adding_fonts.md)
+ - [Using TrueType Fonts](adding_ttf_fonts.md)
- [Custom Effects](custom_effects.md)
- Custom Content Types
diff --git a/Documentation/mgcb.md b/Documentation/mgcb.md
index 888755d965c..947d0d64002 100644
--- a/Documentation/mgcb.md
+++ b/Documentation/mgcb.md
@@ -48,15 +48,12 @@ An optional parameter which adds an assembly reference which contains importers,
Set the target platform for this build. It must be a member of the TargetPlatform enum:
* Windows
* Xbox360
-* WindowsPhone
* iOS
* Android
* Linux
* MacOSX
* WindowsStoreApp
* NativeClient
-* Ouya
-* PlayStationMobile
* PlayStation4
* WindowsPhone8
* RaspberryPi
diff --git a/Documentation/pipeline.md b/Documentation/pipeline.md
index 9c545da97d0..b8daab6855a 100644
--- a/Documentation/pipeline.md
+++ b/Documentation/pipeline.md
@@ -4,10 +4,10 @@ The MonoGame Pipeline Tool (Pipeline.exe) is the front-end GUI editor for MonoGa
-The Pipeline Tool is still relatively new to MonoGame, but it already has the following features:
+The Pipeline Tool has the following features:
* Create, open, and save MGCB projects.
- * Import existing .contentproj.
+ * Import existing XNA .contentproj.
* Tree view showing content of project.
* Property grid for editing content settings.
* Full undo/redo support.
@@ -17,7 +17,7 @@ The Pipeline Tool is still relatively new to MonoGame, but it already has the fo
* Support for custom importers/processors/writers.
* Template format for adding new custom content types.
-Currently the Pipeline Tool is only available on Windows and is part of the SDK installation. The Mac and Linux versions are in development and should be available soon.
+The Pipeline Tool is included in the SDK installation.
[Read detailed documentation](using_pipeline_tool.md)
diff --git a/Documentation/setting_up_monogame_source.md b/Documentation/setting_up_monogame_source.md
index c3e49a55d8a..ae1148aab22 100644
--- a/Documentation/setting_up_monogame_source.md
+++ b/Documentation/setting_up_monogame_source.md
@@ -4,22 +4,23 @@ This section will help you setup MonoGame by building it from source code.
Install the tools for the system you are building from:
* Windows:
- * [GitHub for Windows](https://windows.github.com/)
- * [Visual Studio](https://www.visualstudio.com/) or [Xamarin Studio](http://www.monodevelop.com/download/)
- * Optional download Xamarin.Android and Windows Phone 8 SDK
+ * [Git for Windows](https://git-scm.com/download/win)
+ * [Visual Studio](https://www.visualstudio.com/)
+ * [Xamarin.Android](https://www.xamarin.com/download) (Optional)
+ * [Windows Phone 8 SDK](https://www.microsoft.com/en-us/download/details.aspx?id=35471) (Optional)
* Mac:
- * [GitHub for Mac](https://mac.github.com/)
- * [Xamarin Studio](http://www.monodevelop.com/download/)
- * Optional download Xamarin.Android and Xamarin.iOS
+ * [Git](https://git-scm.com/download/mac)
+ * [Xamarin Studio](https://store.xamarin.com/)
+ * Xamarin.Android and Xamarin.iOS can be installed with the Xamarin Studio installer (Optional)
* Linux:
- * Install package called "git"
+ * [Git](https://git-scm.com/download/linux)
* [Monodevelop](http://www.monodevelop.com/download/linux/)
### Getting the source code
-If on Windows, start up Git Shell, if on Unix, start the terminal and type in the following:
+Start up a Terminal (Mac/Linux) or Git Bash (Windows) and clone the MonoGame repository:
```
-git clone https://github.com/mono/MonoGame.git
+git clone https://github.com/MonoGame/MonoGame.git
cd MonoGame
git submodule init
git submodule update
@@ -27,12 +28,13 @@ git submodule update
### Building from source
-If on Windows just start Protobuild.exe.
+MonoGame uses [Protobuild](https://protobuild.org/) to generate project and solution files. Protobuild.exe will be in your MonoGame folder. To run Protobuild:
-if on Unix open terminal and type in:
-```
-cd MonoGame
-mono Protobuild.exe
-```
+- On Windows run Protobuild.exe either by double-clicking or by executing it from the command line.
+- On Mac/Linux open a terminal and run `mono Protobuild.exe` in the MonoGame folder.
+
+Once the project and solution files are generated you can build them with the IDE you installed.
+
+### Referencing the projects
-Now the sln files are generated and you can build them with either Monodevelop or Visual Studio.
+First get the MonoGame SDK from the [downloads page](http://www.monogame.net/downloads/) and install it to get the IDE templates. Start up the IDE you have installed and create a new project from one of the templates. Click Add > Existing Project... on your solution and select the MonoGame.Framework project that matches the template (i.e. MonoGame.Framework.Windows.csproj for a MonoGame Windows project template). The project files are located in MonoGame/MonoGame.Framework. Delete the existing MonoGame.Framework reference and add a reference to the added project by clicking Add Reference... > Projects and selecting the project. You can run your game now. If you make changes to the MonoGame.Framework project it will automatically rebuild when running your game.
diff --git a/Documentation/using_pipeline_tool.md b/Documentation/using_pipeline_tool.md
index 3fca7416b60..20da1827815 100644
--- a/Documentation/using_pipeline_tool.md
+++ b/Documentation/using_pipeline_tool.md
@@ -1,4 +1,4 @@
-The [Pipeline Tool](pipeline.md) is used to organize and define content for use with MonoGame. It is installed as part of the MonoGame SDK Installer or can be build [directly from source](https://github.com/mono/MonoGame/tree/develop/Tools/Pipeline) if needed.
+The [Pipeline Tool](pipeline.md) is used to organize and build content for use with MonoGame. It is installed as part of the MonoGame SDK Installer or can be built [directly from source](https://github.com/mono/MonoGame/tree/develop/Tools/Pipeline) if needed.
## Create A Project
@@ -27,7 +27,7 @@ Note that currently the Pipeline tool is not setup to support multiple target pl
## Adding Content Items
-Once you have a project setup you can then add content to it for building. You can do this from the "Edit" menu:
+Once you have a project setup you can add content to it for building. You can do this from the "Edit" menu:
@@ -39,12 +39,12 @@ Selecting "New Item..." will bring up the New Item dialog which displays a list
-When you select "Add Item..." you get to select an existing item from disk to add to the content project.
+When you select "Existing Item..." you get to select an existing item from disk to add to the content project.
## Custom Content Processors
-Justl ike XNA, the MonoGame content pipeline supports custom content processors. To use them you need to rebuild them correctly to work against MonoGame.
+Just like XNA, the MonoGame content pipeline supports custom content processors. To use them you need to rebuild them correctly to work against MonoGame.
The first step is removing all `Microsoft.Xna.Framework.XXX` references and replacing them with references to `MonoGame.Framework` and `MonoGame.Framework.Content.Pipeline`. This is required as you will no longer be building against Microsoft XNA.
@@ -52,19 +52,26 @@ Once you references are working you then need to change your assembly target pla
After you have done these fixes you should be able to add these new processors to the content project "References".
+## Building Content
+
+The Pipeline Tool has 3 actions related to building content: Build, Rebuild and Clean. Build will build all content that needs to be built and put the xnb's in the output directory (bin by default). Content will be skipped if it hasn't changed since the last build. The time source content was last edited is saved in the intermediate directory (obj by default) to determine if content changed since the last build. Clean will empty the output and intermediate directories. Rebuild will first Clean and then Build.
## Linking Content To Your Game
-Once you have built your content you have a few different ways to add the XNBs to your game project.
+Once you have built your content you have a few different ways to add the xnb's to your game project. They all have the same goal, to get the built xnb's in your project output folder so a ContentManager can easily find and load them.
+
+### MonoGameContentReference
+
+The simplest method is to setup your game project from one of the templates that come with the SDK. When you create a new project it will include a Content.mgcb file with its Build Action set to MonoGameContentReference. This build action is defined in the .targets file [here](https://github.com/MonoGame/MonoGame/blob/develop/MonoGame.Framework.Content.Pipeline/MonoGame.Content.Builder.targets). MonoGameContentReference is set up so that when the project is built, the mgcb will build any new/modified content and copy the resulting xnb's to the project output directory so they can be used in the project. Note that this way you don't even have to manually build the content with the Pipeline Tool. Just add your content to the .mgcb with the Pipeline Tool and the rest will happen when you build your project. The content files do not need to be added to your project.
### Manual Copy
-The simplest and method is to simply copy the content into a Content folder under the output folder where you game executable is. This should work for most desktop builds.
+If you don't want to use the automated process, you can build the content project with the Pipeline Tool and copy the xnb's to the output folder of your project manually.
### Add As Content
-If you are using Visual Studio you can simply add the content files into your C# game project. Create a folder in the project called Content then right click on the folder and select Add -> Existing Item.
+If you are using Visual Studio you can simply add the xnb files to your C# game project. Create a folder in the project called Content then right click on the folder and select Add -> Existing Item.
@@ -85,7 +92,7 @@ Once the files are added you need to select them all and change their build acti
### Add With Wildcard
-The more automatic option is to hand edit your game .csproj and have it include you content using wildcards. To do this just open the .csproj with any text editor then add the following after any other ``:
+The more automatic option is to hand edit your game .csproj and have it include you content using wildcards. To do this just open the .csproj with any text editor then add the following after any other ``:
```
@@ -100,4 +107,4 @@ Then any files you put in a Content folder within your game project will automat
## Reporting Bugs
-The MonoGame content pipeline, MGCB, and the Pipeline tool are all very new in MonoGame. If you run into any problems with them please ask for help on the [community site](http://community.monogame.net/) or submit a [bug report on GitHub](https://github.com/mono/MonoGame/issues).
+If you run into any problems with MGCB or the Pipeline Tool, please ask for help on the [community site](http://community.monogame.net/) or submit a [bug report on GitHub](https://github.com/MonoGame/MonoGame/issues).
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/MonoDevelop.MonoGame.Android.csproj b/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/MonoDevelop.MonoGame.Android.csproj
index b8cb33f833b..b6209ad111b 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/MonoDevelop.MonoGame.Android.csproj
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/MonoDevelop.MonoGame.Android.csproj
@@ -62,7 +62,6 @@
-
@@ -104,8 +103,8 @@
PreserveNewest
-
- PreserveNewest
-
+
+
+
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/templates/Android/Activity1.cs b/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/templates/Android/Activity1.cs
index db79b7ad21e..560095ba1ab 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/templates/Android/Activity1.cs
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/templates/Android/Activity1.cs
@@ -8,10 +8,6 @@
using Android.Widget;
using Android.OS;
-#if OUYA
-using Ouya.Console.Api;
-#endif
-
using Microsoft.Xna.Framework;
namespace ${Namespace}
@@ -26,10 +22,6 @@ namespace ${Namespace}
ConfigChanges.KeyboardHidden |
ConfigChanges.Keyboard |
ConfigChanges.ScreenSize)]
- #if OUYA
- [IntentFilter(new[] { Intent.ActionMain }
- , Categories = new[] { Intent.CategoryLauncher, OuyaIntent.CategoryGame })]
- #endif
public class Activity1 : AndroidGameActivity
{
protected override void OnCreate (Bundle bundle)
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/templates/MonoGameOUYAProject.xpt.xml b/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/templates/MonoGameOUYAProject.xpt.xml
deleted file mode 100644
index dac32e754c3..00000000000
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame.Android/templates/MonoGameOUYAProject.xpt.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
- <_Name>MonoGame for OUYA Application
- monogame/app/games
- monogame-project
- C#
- <_Description>Creates an MonoGame for OUYA Project
-
-
-
-
-
-
-
-
- ${ProjectName}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/MonoDevelop.MonoGame.Mac.csproj b/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/MonoDevelop.MonoGame.Mac.csproj
index c8153acaaec..888733b7cfa 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/MonoDevelop.MonoGame.Mac.csproj
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/MonoDevelop.MonoGame.Mac.csproj
@@ -39,18 +39,10 @@
/Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/bin/MonoDevelop.Core.dll
False
-
- /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.MonoMac/MonoDevelop.MonoMac.dll
- False
-
/Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll
False
-
- /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.MacDev/MonoDevelop.MacDev.dll
- False
-
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/templates/MonoGameOSXProject.xpt.xml b/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/templates/MonoGameOSXProject.xpt.xml
index 39676ae2f16..0ab9c08f043 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/templates/MonoGameOSXProject.xpt.xml
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/templates/MonoGameOSXProject.xpt.xml
@@ -27,8 +27,6 @@
-
-
@@ -41,6 +39,11 @@
+
+
+
+
+
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/templates/MonoGameXamMacProject.xpt.xml b/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/templates/MonoGameXamMacProject.xpt.xml
index 712488048eb..d49598230c7 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/templates/MonoGameXamMacProject.xpt.xml
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame.Mac/templates/MonoGameXamMacProject.xpt.xml
@@ -27,8 +27,6 @@
-
-
@@ -42,6 +40,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame/ContentItemTemplate.cs b/IDE/MonoDevelop/MonoDevelop.MonoGame/ContentItemTemplate.cs
index 1ab59e10dac..27564325e14 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame/ContentItemTemplate.cs
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame/ContentItemTemplate.cs
@@ -31,10 +31,11 @@ public override void Load (XmlElement filenode, FilePath baseDirectory)
}
}
- public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name)
+ public override bool AddToProject(SolutionFolderItem policyParent, Project project, string language, string directory, string name)
{
- ProjectFile file = template.AddFileToProject (policyParent, project, language, directory, name);
- if (file != null) {
+ ProjectFile file = template.AddFileToProject(policyParent, project, language, directory, name);
+ if (file != null)
+ {
file.BuildAction = BuildAction.Content;
file.CopyToOutputDirectory = mode;
return true;
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoDevelop.MonoGame.addin.xml b/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoDevelop.MonoGame.addin.xml
index 92516dd78b8..122f3c62e53 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoDevelop.MonoGame.addin.xml
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoDevelop.MonoGame.addin.xml
@@ -27,7 +27,6 @@
-
@@ -78,10 +77,8 @@
-
-
@@ -90,8 +87,8 @@
-
-
+
+
@@ -100,14 +97,15 @@
-
+
+
+ -->
@@ -122,9 +120,11 @@
+
@@ -164,9 +164,11 @@
+
@@ -176,7 +178,6 @@
-
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoDevelop.MonoGame.csproj b/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoDevelop.MonoGame.csproj
index 40b517cdff8..dc254792e2c 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoDevelop.MonoGame.csproj
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoDevelop.MonoGame.csproj
@@ -71,10 +71,8 @@
-
-
@@ -154,9 +152,6 @@
PreserveNewest
-
- PreserveNewest
-
PreserveNewest
@@ -244,4 +239,8 @@
+
+
+
+
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoGameMSBuildImports.cs b/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoGameMSBuildImports.cs
index 6cc88f9b6dc..fa33621e7fe 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoGameMSBuildImports.cs
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoGameMSBuildImports.cs
@@ -2,56 +2,60 @@
using System.Xml;
using System.Xml.XPath;
using System.Linq;
-using MonoDevelop.Projects.Formats.MSBuild;
using System.Collections.Generic;
+using MonoDevelop.Projects.MSBuild;
using MonoDevelop.Projects;
namespace MonoDevelop.MonoGame
{
- public class MonoGameMSBuildImports : MSBuildExtension
+ public class MonoGameMSBuildImports : DotNetProjectExtension
{
const string MonoGameContentBuildTargets = "$(MSBuildExtensionsPath)\\MonoGame\\v3.0\\MonoGame.Content.Builder.targets";
const string MonoGameCommonProps = "$(MSBuildExtensionsPath)\\MonoGame\\v3.0\\MonoGame.Common.props";
const string MonoGameExtensionsPath = @"$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\{0}\{1}";
const string MonoGameExtensionsAbsolutePath = @"/Library/Frameworks/MonoGame.framework/v3.0/Assemblies/{0}/{1}";
- static bool UpgradeMonoGameProject (MonoDevelop.Core.IProgressMonitor monitor, MonoDevelop.Projects.SolutionEntityItem item, MSBuildProject project)
+ static bool UpgradeMonoGameProject (MonoDevelop.Core.ProgressMonitor monitor, DotNetProjectExtension extension, MSBuildProject project)
{
bool needsSave = false;
bool containsMGCB = project.ItemGroups.Any (x => x.Items.Any (i => System.IO.Path.GetExtension (i.Include) == ".mgcb"));
- bool isMonoGame = project.PropertyGroups.Any (x => x.Properties.Any (p => p.Name == "MonoGamePlatform")) ||
+ bool isMonoGame = project.PropertyGroups.Any (x => x.GetProperties().Any (p => p.Name == "MonoGamePlatform")) ||
project.ItemGroups.Any (x => x.Items.Any (i => i.Name == "Reference" && i.Include == "MonoGame.Framework")) ||
containsMGCB;
- bool isApplication = project.PropertyGroups.Any (x => x.Properties.Any (p => p.Name == "OutputType" && p.GetValue () == "Exe")) ||
- project.PropertyGroups.Any (x => x.Properties.Any (p => p.Name == "AndroidApplication" && string.Compare (p.GetValue (), bool.TrueString, true)==0));
- bool isShared = project.PropertyGroups.Any (x => x.Properties.Any (p => p.Name == "HasSharedItems" && p.GetValue () == "true"));
- var type = item.GetType ().Name;
+ bool isDesktopGL = project.ItemGroups.Any (x => x.Items.Any (i => i.Include.EndsWith ("SDL2.dll")));
+ bool isApplication = project.PropertyGroups.Any (x => x.GetProperties().Any (p => p.Name == "OutputType" && p.Value == "Exe"))
+ | project.PropertyGroups.Any (x => x.GetProperties().Any (p => p.Name == "AndroidApplication" && string.Compare (p.Value, bool.TrueString, true)==0));
+ bool isShared = project.PropertyGroups.Any (x => x.GetProperties().Any (p => p.Name == "HasSharedItems" && p.Value == "true"));
+ bool absoluteReferenes = false;
+ var type = extension.Project.GetType ().Name;
+
monitor.Log.WriteLine ("Found {0}", type);
- var platform = Environment.OSVersion.Platform == PlatformID.Win32NT ? "Windows" : "DesktopGL";
+ monitor.Log.WriteLine ("Found {0}", project.GetType ().Name);
+ var platform = isDesktopGL ? "DesktopGL" : "Windows";
var path = MonoGameExtensionsPath;
- switch (type) {
- case "XamarinIOSProject":
+ if (extension.Project.FlavorGuids.Contains ("{FEACFBD2-3405-455C-9665-78FE426C6842}")) {
platform = "iOS";
- break;
- case "MonoDroidProject":
+ }
+ if (extension.Project.FlavorGuids.Contains ("{06FA79CB-D6CD-4721-BB4B-1BD202089C55}")) {
+ platform = "tvOS";
+ }
+ if (extension.Project.FlavorGuids.Contains ("{EFBA0AD7-5A72-4C68-AF49-83D382785DCF}")) {
platform = "Android";
- break;
- case "XamMac2Project":
- case "MonoGameProject":
- platform = "DesktopGL";
- break;
- case "XamMac":
- case "XamMacProject":
- platform = "DesktopGL";
- // Xamarin.Mac Classic does not use MSBuild so we need to absolute path.
- path = MonoGameExtensionsAbsolutePath;
- break;
- case "MonoMac":
- case "MonoMacProject":
+ }
+ if (extension.Project.FlavorGuids.Contains ("{948B3504-5B70-4649-8FE4-BDE1FB46EC69}")) {
platform = "MacOSX";
+ // MonoMac Classic does not use MSBuild so we need to absolute path.
+ path = MonoGameExtensionsAbsolutePath;
+ absoluteReferenes = true;
+ }
+ if (extension.Project.FlavorGuids.Contains ("{42C0BBD9-55CE-4FC1-8D90-A7348ABAFB23}")) {
+ platform = "DesktopGL";
// Xamarin.Mac Classic does not use MSBuild so we need to absolute path.
path = MonoGameExtensionsAbsolutePath;
- break;
+ absoluteReferenes = true;
+ }
+ if (extension.Project.FlavorGuids.Contains ("{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1}")) {
+ platform = "DesktopGL";
}
monitor.Log.WriteLine ("Platform = {0}", platform);
monitor.Log.WriteLine ("Path = {0}", path);
@@ -60,31 +64,28 @@ static bool UpgradeMonoGameProject (MonoDevelop.Core.IProgressMonitor monitor, M
var ritems = new List ();
foreach (var ig in project.ItemGroups) {
foreach (var i in ig.Items.Where (x => x.Name == "Reference" && x.Include == "MonoGame.Framework")) {
- if (!i.HasMetadata ("HintPath")) {
+ var metaData = i.Metadata;
+ if (!metaData.HasProperty("HintPath")) {
monitor.Log.WriteLine ("Fixing {0} to be MonoGameContentReference", i.Include);
- var a = ig.AddNewItem ("Reference", i.Include);
- a.SetMetadata ("HintPath", string.Format (path, platform, "MonoGame.Framework.dll"));
- ritems.Add (i);
+ metaData.SetValue ("HintPath", string.Format (path, platform, "MonoGame.Framework.dll"));
needsSave = true;
}
}
foreach (var i in ig.Items.Where (x => x.Name == "Reference" && x.Include == "Tao.Sdl")) {
- if (!i.HasMetadata ("HintPath")) {
+ var metaData = i.Metadata;
+ if (!metaData.HasProperty("HintPath")) {
monitor.Log.WriteLine ("Fixing {0} to be Tao.Sdl", i.Include);
- var a = ig.AddNewItem ("Reference", i.Include);
- a.SetMetadata ("HintPath", string.Format (path, platform, "Tao.Sdl.dll"));
- ritems.Add (i);
+ metaData.SetValue ("HintPath", string.Format (path, platform, "Tao.Sdl.dll"));
needsSave = true;
}
}
foreach (var i in ig.Items.Where (x => x.Name == "Reference" && x.Include.StartsWith ("OpenTK") &&
(platform != "iOS" && platform != "Android"))) {
- if (!i.HasMetadata ("HintPath")) {
- monitor.Log.WriteLine ("Fixing {0} to be OpenTK", i.Include);
- var a = ig.AddNewItem ("Reference", i.Include);
- a.SetMetadata ("HintPath", string.Format (path, platform, "OpenTK.dll"));
- a.SetMetadata ("SpecificVersion", "true");
- ritems.Add (i);
+ var metaData = i.Metadata;
+ if (!metaData.HasProperty ("HintPath")) {
+ monitor.Log.WriteLine("Fixing {0} to be OpenTK", i.Include);
+ metaData.SetValue ("HintPath", string.Format (path, platform, "OpenTK.dll"));
+ metaData.SetValue ("SpecificVersion", "true");
needsSave = true;
}
}
@@ -92,22 +93,22 @@ static bool UpgradeMonoGameProject (MonoDevelop.Core.IProgressMonitor monitor, M
foreach (var a in ritems) {
project.RemoveItem (a);
}
- var dotNetProject = item as DotNetProject;
- if (dotNetProject != null && (type == "MonoMacProject" || type == "XamMacProject" )) {
+ var dotNetProject = extension.Project;
+ if (dotNetProject != null && absoluteReferenes) {
var items = new List ();
var newitems = new List ();
foreach (var reference in dotNetProject.References) {
if (reference.Reference == "MonoGame.Framework" && string.IsNullOrEmpty (reference.HintPath)) {
items.Add (reference);
- newitems.Add (new ProjectReference (ReferenceType.Assembly, reference.Reference, string.Format (path, platform, "MonoGame.Framework.dll")));
+ newitems.Add (ProjectReference.CreateCustomReference (ReferenceType.Assembly, reference.Reference, string.Format(path, platform, "MonoGame.Framework.dll")));
}
- if (reference.Reference.StartsWith ("OpenTK") && string.IsNullOrEmpty (reference.HintPath)) {
+ if (reference.Reference.StartsWith ("OpenTK", StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty (reference.HintPath)) {
items.Add (reference);
- newitems.Add (new ProjectReference (ReferenceType.Assembly, reference.Reference, string.Format (path, platform, "OpenTK.dll")));
+ newitems.Add (ProjectReference.CreateCustomReference (ReferenceType.Assembly, reference.Reference, string.Format (path, platform, "OpenTK.dll")));
}
if (reference.Reference == "Tao.Sdl" && string.IsNullOrEmpty (reference.HintPath)) {
items.Add (reference);
- newitems.Add (new ProjectReference (ReferenceType.Assembly, reference.Reference, string.Format (path, platform, "Tao.Sdl.dll")));
+ newitems.Add (ProjectReference.CreateCustomReference (ReferenceType.Assembly, reference.Reference, string.Format (path, platform, "Tao.Sdl.dll")));
}
}
dotNetProject.References.RemoveRange (items);
@@ -115,21 +116,14 @@ static bool UpgradeMonoGameProject (MonoDevelop.Core.IProgressMonitor monitor, M
}
}
if (isMonoGame && containsMGCB && (isApplication || isShared)) {
- if (!project.PropertyGroups.Any (x => x.Properties.Any (p => p.Name == "MonoGamePlatform")) && !isShared) {
- monitor.Log.WriteLine ("Adding MonoGamePlatform", platform);
- project.PropertyGroups.First ().SetPropertyValue ("MonoGamePlatform", platform, true);
+ if (!project.PropertyGroups.Any (x => x.GetProperties().Any (p => p.Name == "MonoGamePlatform")) && !isShared) {
+ monitor.Log.WriteLine ("Adding MonoGamePlatform {0}", platform == "tvOS" ? "iOS" : platform);
+ project.PropertyGroups.First ().SetValue ("MonoGamePlatform", platform == "tvOS" ? "iOS" : platform, true);
needsSave = true;
}
if (!project.Imports.Any (x => x.Project.StartsWith (MonoGameCommonProps, StringComparison.OrdinalIgnoreCase))&& !isShared) {
monitor.Log.WriteLine ("Adding MonoGame.Common.props Import");
- var e = project.Document.DocumentElement;
- var manager = new XmlNamespaceManager (new NameTable ());
- var schema = "http://schemas.microsoft.com/developer/msbuild/2003";
- manager.AddNamespace ("tns", schema);
- var import = project.Document.CreateElement ("Import", schema);
- import.SetAttribute ("Project", MonoGameCommonProps);
- import.SetAttribute ("Condition", string.Format ("Exists('{0}')", MonoGameCommonProps));
- project.Document.DocumentElement.InsertBefore (import, project.Document.DocumentElement.FirstChild);
+ project.AddNewImport(MonoGameCommonProps, string.Format ("Exists('{0}')", MonoGameCommonProps), project.PropertyGroups.First());
needsSave = true;
}
if (containsMGCB) {
@@ -157,21 +151,25 @@ static bool UpgradeMonoGameProject (MonoDevelop.Core.IProgressMonitor monitor, M
return needsSave;
}
- public override void LoadProject (MonoDevelop.Core.IProgressMonitor monitor, MonoDevelop.Projects.SolutionEntityItem item, MSBuildProject project)
+ protected override void OnWriteProject(MonoDevelop.Core.ProgressMonitor monitor, MSBuildProject msproject)
{
- var changed = (UpgradeMonoGameProject (monitor, item, project));
- base.LoadProject (monitor, item, project);
- if (changed) {
- project.Save (project.FileName);
+ base.OnWriteProject(monitor, msproject);
+ var changed = UpgradeMonoGameProject (monitor, this, msproject);
+ if (changed)
+ {
+ msproject.Save(msproject.FileName);
+ this.Project.NeedsReload = true;
}
}
- public override void SaveProject (MonoDevelop.Core.IProgressMonitor monitor, MonoDevelop.Projects.SolutionEntityItem item, MSBuildProject project)
+ protected override void OnReadProject(MonoDevelop.Core.ProgressMonitor monitor, MSBuildProject msproject)
{
- var changed = UpgradeMonoGameProject (monitor, item, project);
- base.SaveProject (monitor, item, project);
- if (changed) {
- this.LoadProject (monitor, item, project);
+ base.OnReadProject (monitor, msproject);
+ var changed = (UpgradeMonoGameProject(monitor, this, msproject));
+ if (changed)
+ {
+ msproject.Save (msproject.FileName);
+ this.Project.NeedsReload = true;
}
}
}
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoGameProject.cs b/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoGameProject.cs
index f76d41fdc48..cbbe891525e 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoGameProject.cs
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame/MonoGameProject.cs
@@ -1,7 +1,8 @@
using System;
-using MonoDevelop.Projects;
+using MonoDevelop.Projects.MSBuild;
using MonoDevelop.Core.Assemblies;
using System.Xml;
+using MonoDevelop.Projects;
namespace MonoDevelop.MonoGame
{
diff --git a/IDE/MonoDevelop/MonoDevelop.MonoGame/templates/MonoGamePipelineProject.xpt.xml b/IDE/MonoDevelop/MonoDevelop.MonoGame/templates/MonoGamePipelineProject.xpt.xml
index e58c278b12c..6e329adc742 100644
--- a/IDE/MonoDevelop/MonoDevelop.MonoGame/templates/MonoGamePipelineProject.xpt.xml
+++ b/IDE/MonoDevelop/MonoDevelop.MonoGame/templates/MonoGamePipelineProject.xpt.xml
@@ -13,7 +13,7 @@
-
+
diff --git a/IDE/MonoDevelop/default.build b/IDE/MonoDevelop/default.build
index 1facd50a2f1..75af7fb1681 100644
--- a/IDE/MonoDevelop/default.build
+++ b/IDE/MonoDevelop/default.build
@@ -42,12 +42,10 @@
-
-
diff --git a/Installers/Linux/RUN/postinstall.sh b/Installers/Linux/RUN/postinstall.sh
index 6c6225f668b..939b37431d1 100755
--- a/Installers/Linux/RUN/postinstall.sh
+++ b/Installers/Linux/RUN/postinstall.sh
@@ -9,15 +9,15 @@ echodep()
do
line="$line."
done
+
+ echo -ne "$line"
if eval "$2"
then
- line="$line\e[32m[Found]\e[0m"
+ echo -e "\e[32m[Found]\e[0m"
else
- line="$line\e[31m[Not Found]\e[0m"
+ echo -e "\e[31m[Not Found]\e[0m"
fi
-
- echo -e "$line"
}
# Check installation priviledge
@@ -26,36 +26,36 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
-# Check previous versions
-if type "mgcb" > /dev/null 2>&1
+DIR=$(pwd)
+IDIR="/usr/lib/mono/xbuild/MonoGame/v3.0"
+
+# Find MonoDevelop
+MDTOOL="?????"
+
+if type "monodevelop" > /dev/null 2>&1
then
- echo "Previous version detected, trying to uninstall..."
-
- # Try and uninstall previus versions
- if [ -f /opt/monogame/uninstall.sh ]
- then
- sudo sh /opt/monogame/uninstall.sh
- elif [ -f /opt/MonoGameSDK/uninstall.sh ]
+ if eval "monodevelop --help | grep 'MonoDevelop 6' > /dev/null 2>&1"
then
- sudo sh /opt/MonoGameSDK/uninstall.sh
- else
- echo "Could not uninstall, please uninstall any previous version of MonoGame SDK manually." 1>&2
- exit 1
+ MDTOOL="mdtool"
fi
fi
-DIR=$(pwd)
-IDIR="/usr/lib/mono/xbuild/MonoGame/v3.0"
+if type "monodevelop-stable" > /dev/null 2>&1
+then
+ if eval "monodevelop-stable --help | grep 'MonoDevelop 6' > /dev/null 2>&1"
+ then
+ MDTOOL="mdtool-stable"
+ fi
+fi
# Show dependency list
echo "Dependencies:"
echodep "mono-runtime" "type 'mono' > /dev/null 2>&1"
-echodep "libopenal" "ldconfig -p | grep -q libopenal"
echodep "gtk-sharp3" "type 'gacutil' > /dev/null 2>&1 && gacutil /l gtk-sharp | grep -q 3.0.0.0"
echo ""
echo "Optional Dependencies:"
-echodep "monodevelop" "type 'mdtool' > /dev/null 2>&1"
-echodep "rider" "type 'rider' > /dev/null 2>&1"
+echodep "MonoDevelop 6" "$MDTOOL > /dev/null 2>&1"
+echodep "Rider" "type 'rider' > /dev/null 2>&1"
echodep "referenceassemblies-pcl / mono-pcl" "test -d /usr/lib/mono/xbuild/Microsoft/Portable"
echodep "ttf-mscorefonts-installer / mscore-fonts" "fc-list | grep -q Arial"
echo ""
@@ -65,6 +65,24 @@ case "$choice2" in
*) ;;
esac
+# Check previous versions
+if type "mgcb" > /dev/null 2>&1
+then
+ echo "Previous version detected, trying to uninstall..."
+
+ # Try and uninstall previus versions
+ if [ -f /opt/monogame/uninstall.sh ]
+ then
+ sudo sh /opt/monogame/uninstall.sh
+ elif [ -f /opt/MonoGameSDK/uninstall.sh ]
+ then
+ sudo sh /opt/MonoGameSDK/uninstall.sh
+ else
+ echo "Could not uninstall, please uninstall any previous version of MonoGame SDK manually." 1>&2
+ exit 1
+ fi
+fi
+
# MonoGame SDK installation
echo "Installing MonoGame SDK..."
@@ -97,10 +115,10 @@ then
fi
# MonoDevelop addin
-if type "mdtool" > /dev/null 2>&1
+if [ "$MONODEVELOP" != "?????" ]
then
echo "Installing MonoDevelop Addin..."
- sudo -H -u $SUDO_USER bash -c "mdtool setup install -y $DIR/Main/MonoDevelop.MonoGame.mpack > /dev/null"
+ sudo -H -u $SUDO_USER bash -c "$MDTOOL setup install -y $DIR/Main/MonoDevelop.MonoGame.mpack > /dev/null"
fi
# Monogame Pipeline terminal commands
diff --git a/Installers/Windows/MonoGame.nsi b/Installers/Windows/MonoGame.nsi
index 1892edbda94..4df678f2991 100644
--- a/Installers/Windows/MonoGame.nsi
+++ b/Installers/Windows/MonoGame.nsi
@@ -106,11 +106,6 @@ Section "MonoGame Core Components" CoreComponents ;No components page, name is n
File '..\..\MonoGame.Framework\bin\Android\AnyCPU\Release\*.dll'
File '..\..\MonoGame.Framework\bin\Android\AnyCPU\Release\*.xml'
- ; Install OUYA Assemblies
- SetOutPath '$INSTDIR\Assemblies\OUYA'
- File '..\..\MonoGame.Framework\bin\Ouya\AnyCPU\Release\*.dll'
- File '..\..\MonoGame.Framework\bin\Ouya\AnyCPU\Release\*.xml'
-
; Install DesktopGL Assemblies
SetOutPath '$INSTDIR\Assemblies\DesktopGL'
File /nonfatal '..\..\MonoGame.Framework\bin\WindowsGL\AnyCPU\Release\*.dll'
@@ -148,18 +143,6 @@ Section "MonoGame Core Components" CoreComponents ;No components page, name is n
File '..\..\MonoGame.Framework\bin\WindowsPhone81\AnyCPU\Release\*.dll'
File '..\..\MonoGame.Framework\bin\WindowsPhone81\AnyCPU\Release\*.xml'
- ; Install Windows Phone ARM Assemblies
- SetOutPath '$INSTDIR\Assemblies\WindowsPhone\ARM'
- File '..\..\MonoGame.Framework\bin\WindowsPhone\ARM\Release\*.dll'
- File '..\..\MonoGame.Framework\bin\WindowsPhone\ARM\Release\*.xml'
- File '..\..\MonoGame.Framework\bin\WindowsPhone\ARM\Release\*.winmd'
-
- ; Install Windows Phone x86 Assemblies
- SetOutPath '$INSTDIR\Assemblies\WindowsPhone\x86'
- File '..\..\MonoGame.Framework\bin\WindowsPhone\x86\Release\*.dll'
- File '..\..\MonoGame.Framework\bin\WindowsPhone\x86\Release\*.xml'
- File '..\..\MonoGame.Framework\bin\WindowsPhone\x86\Release\*.winmd'
-
; Install Windows 10 UAP Assemblies
SetOutPath '$INSTDIR\Assemblies\WindowsUniversal'
File '..\..\MonoGame.Framework\bin\WindowsUniversal\AnyCPU\Release\*.dll'
@@ -177,11 +160,8 @@ Section "MonoGame Core Components" CoreComponents ;No components page, name is n
WriteRegStr HKLM 'SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows' '' '$INSTDIR\Assemblies\Windows'
WriteRegStr HKLM 'SOFTWARE\Microsoft\.NETFramework\v4.5.50709\AssemblyFoldersEx\${APPNAME} for Windows Store' '' '$INSTDIR\Assemblies\Windows8'
WriteRegStr HKLM 'SOFTWARE\Microsoft\.NETFramework\v4.5.50709\AssemblyFoldersEx\${APPNAME} for Windows Phone 8.1' '' '$INSTDIR\Assemblies\WindowsPhone81'
- WriteRegStr HKLM 'SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows Phone ARM' '' '$INSTDIR\Assemblies\WindowsPhone\ARM'
- WriteRegStr HKLM 'SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows Phone x86' '' '$INSTDIR\Assemblies\WindowsPhone\x86'
WriteRegStr HKLM 'SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows 10 Universal' '' '$INSTDIR\Assemblies\WindowsUniversal'
WriteRegStr HKLM 'SOFTWARE\Microsoft\MonoAndroid\v2.3\AssemblyFoldersEx\${APPNAME} for Android' '' '$INSTDIR\Assemblies\Android'
- WriteRegStr HKLM 'SOFTWARE\Microsoft\MonoAndroid\v2.3\AssemblyFoldersEx\${APPNAME} for OUYA' '' '$INSTDIR\Assemblies\OUYA'
WriteRegStr HKLM 'SOFTWARE\Microsoft\MonoTouch\v1.0\AssemblyFoldersEx\${APPNAME} for iOS' '' '$INSTDIR\Assemblies\iOS'
IfFileExists $WINDIR\SYSWOW64\*.* Is64bit Is32bit
@@ -193,10 +173,7 @@ Section "MonoGame Core Components" CoreComponents ;No components page, name is n
WriteRegStr HKLM 'SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.5.50709\AssemblyFoldersEx\${APPNAME} for Windows Store' '' '$INSTDIR\Assemblies\Windows8'
WriteRegStr HKLM 'SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.5.50709\AssemblyFoldersEx\${APPNAME} for Windows Phone 8.1' '' '$INSTDIR\Assemblies\WindowsPhone81'
WriteRegStr HKLM 'SOFTWARE\Wow6432Node\Microsoft\MonoAndroid\v2.3\AssemblyFoldersEx\${APPNAME} for Android' '' '$INSTDIR\Assemblies\Android'
- WriteRegStr HKLM 'SOFTWARE\Wow6432Node\Microsoft\MonoAndroid\v2.3\AssemblyFoldersEx\${APPNAME} for OUYA' '' '$INSTDIR\Assemblies\OUYA'
WriteRegStr HKLM 'SOFTWARE\Wow6432Node\Microsoft\MonoTouch\v1.0\AssemblyFoldersEx\${APPNAME} for iOS' '' '$INSTDIR\Assemblies\iOS'
- WriteRegStr HKLM 'SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows Phone ARM' '' '$INSTDIR\Assemblies\WindowsPhone\ARM'
- WriteRegStr HKLM 'SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows Phone x86' '' '$INSTDIR\Assemblies\WindowsPhone\x86'
WriteRegStr HKLM 'SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows 10 Universal' '' '$INSTDIR\Assemblies\WindowsUniversal'
End32Bitvs64BitCheck:
@@ -273,6 +250,7 @@ Section "Visual Studio 2015 Templates" VS2015
InstallTemplates:
SetOutPath "$1\Visual C#\MonoGame"
File /r '..\..\ProjectTemplates\VisualStudio2010\*.zip'
+ File /r '..\..\ProjectTemplates\VisualStudio2013\WindowsPhone8.1.zip'
File /r '..\..\ProjectTemplates\VisualStudio2015\*.zip'
GOTO EndTemplates
CannotInstallTemplates:
@@ -382,7 +360,6 @@ Section "Uninstall"
DeleteRegKey HKLM 'SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows Phone x86'
DeleteRegKey HKLM 'SOFTWARE\Microsoft\.NETFramework\v4.5.50709\AssemblyFoldersEx\${APPNAME} for Windows 10 UAP'
DeleteRegKey HKLM 'SOFTWARE\Microsoft\MonoAndroid\v2.3\AssemblyFoldersEx\${APPNAME} for Android'
- DeleteRegKey HKLM 'SOFTWARE\Microsoft\MonoAndroid\v2.3\AssemblyFoldersEx\${APPNAME} for OUYA'
DeleteRegKey HKLM 'SOFTWARE\Microsoft\MonoTouch\v1.0\AssemblyFoldersEx\${APPNAME} for iOS'
DeleteRegKey HKCU 'Software\Microsoft\VisualStudio\10.0\Default Editors\mgcb'
@@ -404,7 +381,6 @@ Section "Uninstall"
DeleteRegKey HKLM 'SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows Phone x86'
DeleteRegKey HKLM 'SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\${APPNAME} for Windows 10 UAP'
DeleteRegKey HKLM 'SOFTWARE\Wow6432Node\Microsoft\MonoAndroid\v2.3\AssemblyFoldersEx\${APPNAME} for Android'
- DeleteRegKey HKLM 'SOFTWARE\Wow6432Node\Microsoft\MonoAndroid\v2.3\AssemblyFoldersEx\${APPNAME} for OUYA'
DeleteRegKey HKLM 'SOFTWARE\Wow6432Node\Microsoft\MonoTouch\v1.0\AssemblyFoldersEx\${APPNAME} for iOS'
diff --git a/Installers/default.build b/Installers/default.build
index 1444e9dc342..cdb250d9aee 100644
--- a/Installers/default.build
+++ b/Installers/default.build
@@ -63,7 +63,6 @@
-
@@ -89,11 +88,6 @@
-
-
-
-
-
diff --git a/MonoGame.Framework.Content.Pipeline/Audio/AudioContent.cs b/MonoGame.Framework.Content.Pipeline/Audio/AudioContent.cs
index d5f2f2a433f..3fb343ea400 100644
--- a/MonoGame.Framework.Content.Pipeline/Audio/AudioContent.cs
+++ b/MonoGame.Framework.Content.Pipeline/Audio/AudioContent.cs
@@ -137,7 +137,18 @@ public AudioContent(string audioFileName, AudioFileType audioFileType)
fs.Read(rawData, 0, rawData.Length);
}
- var stripped = DefaultAudioProfile.StripRiffWaveHeader(rawData);
+ AudioFormat riffAudioFormat;
+ var stripped = DefaultAudioProfile.StripRiffWaveHeader(rawData, out riffAudioFormat);
+
+ if (riffAudioFormat != null)
+ {
+ if (_format.BlockAlign != riffAudioFormat.BlockAlign)
+ throw new InvalidOperationException("Calcualted block align does not match RIFF " + _format.BlockAlign + " : " + riffAudioFormat.BlockAlign);
+ if (_format.ChannelCount != riffAudioFormat.ChannelCount || _format.Format != riffAudioFormat.Format
+ || _format.SampleRate != riffAudioFormat.SampleRate || _format.AverageBytesPerSecond != riffAudioFormat.AverageBytesPerSecond)
+ throw new InvalidOperationException("Probed audio format does not match RIFF");
+ }
+
_data = Array.AsReadOnly(stripped);
}
}
diff --git a/MonoGame.Framework.Content.Pipeline/Audio/DefaultAudioProfile.cs b/MonoGame.Framework.Content.Pipeline/Audio/DefaultAudioProfile.cs
index 1d967fa3580..6974c88b21c 100644
--- a/MonoGame.Framework.Content.Pipeline/Audio/DefaultAudioProfile.cs
+++ b/MonoGame.Framework.Content.Pipeline/Audio/DefaultAudioProfile.cs
@@ -20,7 +20,6 @@ public override bool Supports(TargetPlatform platform)
platform == TargetPlatform.NativeClient ||
platform == TargetPlatform.RaspberryPi ||
platform == TargetPlatform.Windows ||
- platform == TargetPlatform.WindowsPhone ||
platform == TargetPlatform.WindowsPhone8 ||
platform == TargetPlatform.WindowsStoreApp ||
platform == TargetPlatform.iOS;
@@ -228,8 +227,10 @@ public static void ProbeFormat(string sourceFile, out AudioFileType audioFileTyp
loopLength = (int)Math.Floor(sampleRate * durationInSeconds);
}
- internal static byte[] StripRiffWaveHeader(byte[] data)
+ internal static byte[] StripRiffWaveHeader(byte[] data, out AudioFormat audioFormat)
{
+ audioFormat = null;
+
using (var reader = new BinaryReader(new MemoryStream(data)))
{
var signature = new string(reader.ReadChars(4));
@@ -248,7 +249,26 @@ internal static byte[] StripRiffWaveHeader(byte[] data)
var chunkSignature = new string(reader.ReadChars(4));
if (chunkSignature.ToLowerInvariant() == "data")
break;
- reader.BaseStream.Seek(reader.ReadInt32(), SeekOrigin.Current);
+ if (chunkSignature.ToLowerInvariant() == "fmt ")
+ {
+ int fmtLength = reader.ReadInt32();
+ short formatTag = reader.ReadInt16();
+ short channels = reader.ReadInt16();
+ int sampleRate = reader.ReadInt32();
+ int avgBytesPerSec = reader.ReadInt32();
+ short blockAlign = reader.ReadInt16();
+ short bitsPerSample = reader.ReadInt16();
+ audioFormat = new AudioFormat(avgBytesPerSec, bitsPerSample, blockAlign, channels, formatTag, sampleRate);
+
+ fmtLength -= 2 + 2 + 4 + 4 + 2 + 2;
+ if (fmtLength < 0)
+ throw new InvalidOperationException("riff wave header has unexpected format");
+ reader.BaseStream.Seek(fmtLength, SeekOrigin.Current);
+ }
+ else
+ {
+ reader.BaseStream.Seek(reader.ReadInt32(), SeekOrigin.Current);
+ }
}
var dataSize = reader.ReadInt32();
@@ -279,14 +299,14 @@ public static ConversionQuality ConvertToFormat(AudioContent content, Conversion
try
{
string ffmpegCodecName, ffmpegMuxerName;
- int format;
+ //int format;
switch (formatType)
{
case ConversionFormat.Adpcm:
// ADPCM Microsoft
ffmpegCodecName = "adpcm_ms";
ffmpegMuxerName = "wav";
- format = 0x0002; /* WAVE_FORMAT_ADPCM */
+ //format = 0x0002; /* WAVE_FORMAT_ADPCM */
break;
case ConversionFormat.Pcm:
// XNA seems to preserve the bit size of the input
@@ -298,13 +318,13 @@ public static ConversionQuality ConvertToFormat(AudioContent content, Conversion
else
ffmpegCodecName = "pcm_s16le";
ffmpegMuxerName = "wav";
- format = 0x0001; /* WAVE_FORMAT_PCM */
+ //format = 0x0001; /* WAVE_FORMAT_PCM */
break;
case ConversionFormat.WindowsMedia:
// Windows Media Audio 2
ffmpegCodecName = "wmav2";
ffmpegMuxerName = "asf";
- format = 0x0161; /* WAVE_FORMAT_WMAUDIO2 */
+ //format = 0x0161; /* WAVE_FORMAT_WMAUDIO2 */
break;
case ConversionFormat.Xma:
throw new NotSupportedException(
@@ -313,20 +333,20 @@ public static ConversionQuality ConvertToFormat(AudioContent content, Conversion
// ADPCM IMA WAV
ffmpegCodecName = "adpcm_ima_wav";
ffmpegMuxerName = "wav";
- format = 0x0011; /* WAVE_FORMAT_IMA_ADPCM */
+ //format = 0x0011; /* WAVE_FORMAT_IMA_ADPCM */
break;
case ConversionFormat.Aac:
// AAC (Advanced Audio Coding)
// Requires -strict experimental
ffmpegCodecName = "aac";
ffmpegMuxerName = "ipod";
- format = 0x0000; /* WAVE_FORMAT_UNKNOWN */
+ //format = 0x0000; /* WAVE_FORMAT_UNKNOWN */
break;
case ConversionFormat.Vorbis:
// Vorbis
ffmpegCodecName = "libvorbis";
ffmpegMuxerName = "ogg";
- format = 0x0000; /* WAVE_FORMAT_UNKNOWN */
+ //format = 0x0000; /* WAVE_FORMAT_UNKNOWN */
break;
default:
// Unknown format
@@ -378,7 +398,24 @@ public static ConversionQuality ConvertToFormat(AudioContent content, Conversion
int loopStart, loopLength;
ProbeFormat(temporaryOutput, out audioFileType, out audioFormat, out duration, out loopStart, out loopLength);
- content.SetData(StripRiffWaveHeader(rawData), audioFormat, duration, loopStart, loopLength);
+ AudioFormat riffAudioFormat;
+ byte[] data = StripRiffWaveHeader(rawData, out riffAudioFormat);
+
+ // deal with adpcm
+ if (audioFormat.Format == 2)
+ {
+ // riff contains correct blockAlign
+ audioFormat = riffAudioFormat;
+
+ // fix loopLength -> has to be multiple of sample per block
+ // see https://msdn.microsoft.com/de-de/library/windows/desktop/ee415711(v=vs.85).aspx
+ ushort samplesPerBlock = (ushort)(audioFormat.BlockAlign * 2 / audioFormat.ChannelCount - 12); // from https://github.com/sharpdx/SharpDX/blob/master/Source/SharpDX/Multimedia/WaveFormatAdpcm.cs
+ loopLength = (int)(audioFormat.SampleRate * duration.TotalSeconds);
+ int remainder = loopLength % samplesPerBlock;
+ loopLength += samplesPerBlock - remainder;
+ }
+
+ content.SetData(data, audioFormat, duration, loopStart, loopLength);
}
finally
{
diff --git a/MonoGame.Framework.Content.Pipeline/Builder/PipelineManager.cs b/MonoGame.Framework.Content.Pipeline/Builder/PipelineManager.cs
index d781bad942b..d3a7da064de 100644
--- a/MonoGame.Framework.Content.Pipeline/Builder/PipelineManager.cs
+++ b/MonoGame.Framework.Content.Pipeline/Builder/PipelineManager.cs
@@ -59,7 +59,6 @@ private struct ProcessorInfo
public string IntermediateDirectory { get; private set; }
private ContentCompiler _compiler;
- private MethodInfo _compileMethod;
public ContentBuildLogger Logger { get; set; }
diff --git a/MonoGame.Framework.Content.Pipeline/Graphics/DefaultTextureProfile.cs b/MonoGame.Framework.Content.Pipeline/Graphics/DefaultTextureProfile.cs
index 70abd7e8f07..c7d9743a82f 100644
--- a/MonoGame.Framework.Content.Pipeline/Graphics/DefaultTextureProfile.cs
+++ b/MonoGame.Framework.Content.Pipeline/Graphics/DefaultTextureProfile.cs
@@ -19,7 +19,6 @@ public override bool Supports(TargetPlatform platform)
platform == TargetPlatform.NativeClient ||
platform == TargetPlatform.RaspberryPi ||
platform == TargetPlatform.Windows ||
- platform == TargetPlatform.WindowsPhone ||
platform == TargetPlatform.WindowsPhone8 ||
platform == TargetPlatform.WindowsStoreApp ||
platform == TargetPlatform.iOS;
@@ -109,7 +108,7 @@ public override void Requirements(ContentProcessorContext context, TextureProces
}
}
- protected override void PlatformCompressTexture(ContentProcessorContext context, TextureContent content, TextureProcessorOutputFormat format, bool generateMipmaps, bool sharpAlpha)
+ protected override void PlatformCompressTexture(ContentProcessorContext context, TextureContent content, TextureProcessorOutputFormat format, bool generateMipmaps, bool isSpriteFont)
{
format = GetTextureFormatForPlatform(format, context.TargetPlatform);
@@ -127,7 +126,7 @@ protected override void PlatformCompressTexture(ContentProcessorContext context,
break;
case TextureProcessorOutputFormat.DxtCompressed:
- GraphicsUtil.CompressDxt(context.TargetProfile, content, generateMipmaps, sharpAlpha);
+ GraphicsUtil.CompressDxt(context.TargetProfile, content, generateMipmaps, isSpriteFont);
break;
case TextureProcessorOutputFormat.Etc1Compressed:
@@ -135,7 +134,7 @@ protected override void PlatformCompressTexture(ContentProcessorContext context,
break;
case TextureProcessorOutputFormat.PvrCompressed:
- GraphicsUtil.CompressPvrtc(content, generateMipmaps);
+ GraphicsUtil.CompressPvrtc(content, generateMipmaps, isSpriteFont);
break;
}
}
diff --git a/MonoGame.Framework.Content.Pipeline/Graphics/Font/GlyphPacker.cs b/MonoGame.Framework.Content.Pipeline/Graphics/Font/GlyphPacker.cs
index 309de263eb6..278a31d71ce 100644
--- a/MonoGame.Framework.Content.Pipeline/Graphics/Font/GlyphPacker.cs
+++ b/MonoGame.Framework.Content.Pipeline/Graphics/Font/GlyphPacker.cs
@@ -59,6 +59,8 @@ public static BitmapContent ArrangeGlyphs(Glyph[] sourceGlyphs, bool requirePOT,
static BitmapContent CopyGlyphsToOutput(List glyphs, int width, int height)
{
var output = new PixelBitmapContent(width, height);
+ // Fill the output with non-premultiplied black
+ output.ReplaceColor(Color.Transparent, Color.Black);
foreach (var glyph in glyphs)
{
diff --git a/MonoGame.Framework.Content.Pipeline/Graphics/FontHelper.cs b/MonoGame.Framework.Content.Pipeline/Graphics/FontHelper.cs
deleted file mode 100644
index f4c230a3ea3..00000000000
--- a/MonoGame.Framework.Content.Pipeline/Graphics/FontHelper.cs
+++ /dev/null
@@ -1,228 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Runtime.InteropServices;
-using System.Drawing;
-
-#if MACOS
-using MonoMac.CoreGraphics;
-using MonoMac.AppKit;
-using MonoMac.Foundation;
-using MonoMac.CoreText;
-using MonoMac.ImageIO;
-#endif
-
-namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
-{
-
- static class FontHelper
- {
- [StructLayout(LayoutKind.Sequential)]
- public struct ABC
- {
- public int abcA;
- public uint abcB;
- public int abcC;
- }
-
-#if WINDOWS
- [DllImport("gdi32.dll", ExactSpelling = true)]
- public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObj);
-
- [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
- public static extern int DeleteObject(IntPtr hObj);
-
- [DllImport("gdi32.dll", ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
- public static extern bool GetCharABCWidthsW(IntPtr hdc, uint uFirstChar, uint uLastChar, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStruct, SizeConst = 1)] ABC[] lpabc);
-
- public static ABC GetCharWidthABC(char ch, Font font, System.Drawing.Graphics gr)
- {
- ABC[] _temp = new ABC[1];
- IntPtr hDC = gr.GetHdc();
- Font ft = (Font)font.Clone();
- IntPtr hFt = ft.ToHfont();
- SelectObject(hDC, hFt);
- GetCharABCWidthsW(hDC, ch, ch, _temp);
- DeleteObject(hFt);
- gr.ReleaseHdc();
-
- return _temp[0];
- }
-
-#elif MACOS
-
- static CTFont nativeFont;
-
- public static ABC GetCharWidthABC(char ch, Font font, System.Drawing.Graphics gr)
- {
- ABC[] _temp = new ABC[1];
- var nativFont = CreateFont (font.Name, font.Size, font.Style, font.GdiCharSet, font.GdiVerticalFont);
- var atts = buildAttributedString(ch.ToString(), nativFont);
- // for now just a line not sure if this is going to work
- CTLine line = new CTLine(atts);
-
- float ascent;
- float descent;
- float leading;
- _temp[0].abcB = (uint)line.GetTypographicBounds(out ascent, out descent, out leading);
-
-
- return _temp[0];
- }
-
- const byte DefaultCharSet = 1;
- static bool underLine = false;
- static bool strikeThrough = false;
-
- static float dpiScale = 96f / 72f;
-
-
- static internal CTFont CreateFont (string familyName, float emSize)
- {
- return CreateFont (familyName, emSize, FontStyle.Regular, DefaultCharSet, false);
- }
-
- static internal CTFont CreateFont (string familyName, float emSize, FontStyle style)
- {
- return CreateFont (familyName, emSize, style, DefaultCharSet, false);
- }
-
- static internal CTFont CreateFont (string familyName, float emSize, FontStyle style, byte gdiCharSet)
- {
- return CreateFont (familyName, emSize, style, gdiCharSet, false);
- }
-
- static internal CTFont CreateFont (string familyName, float emSize, FontStyle style,
- byte gdiCharSet, bool gdiVerticalFont )
- {
- if (emSize <= 0)
- throw new ArgumentException("emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.","emSize");
-
- CTFont nativeFont;
-
- // convert to 96 Dpi to be consistent with Windows
- var dpiSize = emSize * dpiScale;
-
- try {
- nativeFont = new CTFont(familyName,dpiSize);
- }
- catch
- {
- nativeFont = new CTFont("Helvetica",dpiSize);
- }
-
- CTFontSymbolicTraits tMask = CTFontSymbolicTraits.None;
-
- if ((style & FontStyle.Bold) == FontStyle.Bold)
- tMask |= CTFontSymbolicTraits.Bold;
- if ((style & FontStyle.Italic) == FontStyle.Italic)
- tMask |= CTFontSymbolicTraits.Italic;
- strikeThrough = (style & FontStyle.Strikeout) == FontStyle.Strikeout;
- underLine = (style & FontStyle.Underline) == FontStyle.Underline;
-
- var nativeFont2 = nativeFont.WithSymbolicTraits(dpiSize,tMask,tMask);
-
- if (nativeFont2 != null)
- nativeFont = nativeFont2;
-
- return nativeFont;
- }
-
- static NSString FontAttributedName = (NSString)"NSFont";
- static NSString ForegroundColorAttributedName = (NSString)"NSColor";
- static NSString UnderlineStyleAttributeName = (NSString)"NSUnderline";
- static NSString ParagraphStyleAttributeName = (NSString)"NSParagraphStyle";
- //NSAttributedString.ParagraphStyleAttributeName
- static NSString StrikethroughStyleAttributeName = (NSString)"NSStrikethrough";
-
- private static NSMutableAttributedString buildAttributedString(string text, CTFont font,
- Color? fontColor=null)
- {
-
-
- // Create a new attributed string from text
- NSMutableAttributedString atts =
- new NSMutableAttributedString(text);
-
- var attRange = new NSRange(0, atts.Length);
- var attsDic = new NSMutableDictionary();
-
- // Font attribute
- NSObject fontObject = new NSObject(font.Handle);
- attsDic.Add(FontAttributedName, fontObject);
- // -- end font
-
- if (fontColor.HasValue) {
-
- // Font color
- var fc = fontColor.Value;
- NSColor color = NSColor.FromDeviceRgba(fc.R / 255f,
- fc.G / 255f,
- fc.B / 255f,
- fc.A / 255f);
- NSObject colorObject = new NSObject(color.Handle);
- attsDic.Add(ForegroundColorAttributedName, colorObject);
- // -- end font Color
- }
-
- if (underLine) {
- // Underline
- int single = (int)MonoMac.AppKit.NSUnderlineStyle.Single;
- int solid = (int)MonoMac.AppKit.NSUnderlinePattern.Solid;
- var attss = single | solid;
- var underlineObject = NSNumber.FromInt32(attss);
- //var under = NSAttributedString.UnderlineStyleAttributeName.ToString();
- attsDic.Add(UnderlineStyleAttributeName, underlineObject);
- // --- end underline
- }
-
-
- if (strikeThrough) {
- // StrikeThrough
- // NSColor bcolor = NSColor.Blue;
- // NSObject bcolorObject = new NSObject(bcolor.Handle);
- // attsDic.Add(NSAttributedString.StrikethroughColorAttributeName, bcolorObject);
- int stsingle = (int)MonoMac.AppKit.NSUnderlineStyle.Single;
- int stsolid = (int)MonoMac.AppKit.NSUnderlinePattern.Solid;
- var stattss = stsingle | stsolid;
- var stunderlineObject = NSNumber.FromInt32(stattss);
-
- attsDic.Add(StrikethroughStyleAttributeName, stunderlineObject);
- // --- end underline
- }
-
-
- // Text alignment
- var alignment = CTTextAlignment.Left;
- var alignmentSettings = new CTParagraphStyleSettings();
- alignmentSettings.Alignment = alignment;
- var paragraphStyle = new CTParagraphStyle(alignmentSettings);
- NSObject psObject = new NSObject(paragraphStyle.Handle);
-
- // end text alignment
-
- attsDic.Add(ParagraphStyleAttributeName, psObject);
-
- atts.SetAttributes(attsDic, attRange);
-
- return atts;
-
- }
-
-#elif LINUX
- public static ABC GetCharWidthABC(char ch, Font font, System.Drawing.Graphics gr)
- {
- var sf = StringFormat.GenericTypographic;
- sf.Trimming = StringTrimming.None;
- sf.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;
- return new ABC
- {
- abcA = 0,
- abcB = (uint)gr.MeasureString(ch.ToString(), font, new PointF(0, 0), sf).Width,
- abcC = 0
- };
- }
-#endif
- }
-}
diff --git a/MonoGame.Framework.Content.Pipeline/Graphics/GraphicsUtil.cs b/MonoGame.Framework.Content.Pipeline/Graphics/GraphicsUtil.cs
index 88246537143..0d3a2c66f10 100644
--- a/MonoGame.Framework.Content.Pipeline/Graphics/GraphicsUtil.cs
+++ b/MonoGame.Framework.Content.Pipeline/Graphics/GraphicsUtil.cs
@@ -3,6 +3,7 @@
// file 'LICENSE.txt', which is part of this source code package.
using System;
+using System.IO;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Graphics.PackedVector;
using FreeImageAPI;
@@ -122,8 +123,15 @@ static AlphaRange CalculateAlphaRange(BitmapContent bitmap)
return result;
}
- public static void CompressPvrtc(TextureContent content, bool generateMipMaps)
+ public static void CompressPvrtc(TextureContent content, bool generateMipMaps, bool isSpriteFont)
{
+ // If sharp alpha is required (for a font texture page), use 16-bit color instead of PVR
+ if (isSpriteFont)
+ {
+ CompressColor16Bit(content, generateMipMaps);
+ return;
+ }
+
// Calculate number of mip levels
var width = content.Faces[0][0].Height;
var height = content.Faces[0][0].Width;
@@ -144,7 +152,7 @@ public static void CompressPvrtc(TextureContent content, bool generateMipMaps)
Compress(typeof(PvrtcRgba4BitmapContent), content, generateMipMaps);
}
- public static void CompressDxt(GraphicsProfile profile, TextureContent content, bool generateMipMaps, bool sharpAlpha)
+ public static void CompressDxt(GraphicsProfile profile, TextureContent content, bool generateMipMaps, bool isSpriteFont)
{
var face = content.Faces[0][0];
@@ -157,9 +165,11 @@ public static void CompressDxt(GraphicsProfile profile, TextureContent content,
// Test the alpha channel to figure out if we have alpha.
var alphaRange = CalculateAlphaRange(face);
- if (alphaRange == AlphaRange.Opaque)
+ if (isSpriteFont)
+ CompressFontDXT3(content, generateMipMaps);
+ else if (alphaRange == AlphaRange.Opaque)
Compress(typeof(Dxt1BitmapContent), content, generateMipMaps);
- else if (alphaRange == AlphaRange.Cutout || sharpAlpha)
+ else if (alphaRange == AlphaRange.Cutout)
Compress(typeof(Dxt3BitmapContent), content, generateMipMaps);
else
Compress(typeof(Dxt5BitmapContent), content, generateMipMaps);
@@ -263,5 +273,241 @@ static void Compress(Type targetType, TextureContent content, bool generateMipMa
content.ConvertBitmapType(targetType);
}
}
+
+ // Compress the greyscale font texture page using a specially-formulated DXT3 mode
+ static public unsafe void CompressFontDXT3(TextureContent content, bool generateMipmaps)
+ {
+ if (content.Faces.Count > 1)
+ throw new PipelineException("Font textures should only have one face");
+
+ var block = new Vector4[16];
+ for (int i = 0; i < content.Faces[0].Count; ++i)
+ {
+ var face = content.Faces[0][i];
+ var xBlocks = (face.Width + 3) / 4;
+ var yBlocks = (face.Height + 3) / 4;
+ var dxt3Size = xBlocks * yBlocks * 16;
+ var buffer = new byte[dxt3Size];
+
+ var bytes = face.GetPixelData();
+ fixed (byte* b = bytes)
+ {
+ Vector4* colors = (Vector4*)b;
+
+ int w = 0;
+ int h = 0;
+ int x = 0;
+ int y = 0;
+ while (h < (face.Height & ~3))
+ {
+ w = 0;
+ x = 0;
+
+ var h0 = h * face.Width;
+ var h1 = h0 + face.Width;
+ var h2 = h1 + face.Width;
+ var h3 = h2 + face.Width;
+
+ while (w < (face.Width & ~3))
+ {
+ block[0] = colors[w + h0];
+ block[1] = colors[w + h0 + 1];
+ block[2] = colors[w + h0 + 2];
+ block[3] = colors[w + h0 + 3];
+ block[4] = colors[w + h1];
+ block[5] = colors[w + h1 + 1];
+ block[6] = colors[w + h1 + 2];
+ block[7] = colors[w + h1 + 3];
+ block[8] = colors[w + h2];
+ block[9] = colors[w + h2 + 1];
+ block[10] = colors[w + h2 + 2];
+ block[11] = colors[w + h2 + 3];
+ block[12] = colors[w + h3];
+ block[13] = colors[w + h3 + 1];
+ block[14] = colors[w + h3 + 2];
+ block[15] = colors[w + h3 + 3];
+
+ int offset = (x + y * xBlocks) * 16;
+ CompressFontDXT3Block(block, buffer, offset);
+
+ w += 4;
+ ++x;
+ }
+
+ // Do partial block at end of row
+ if (w < face.Width)
+ {
+ var cols = face.Width - w;
+ Array.Clear(block, 0, 16);
+ for (int r = 0; r < 4; ++r)
+ {
+ h0 = (h + r) * face.Width;
+ for (int c = 0; c < cols; ++c)
+ block[(r * 4) + c] = colors[w + h0 + c];
+ }
+
+ int offset = (x + y * xBlocks) * 16;
+ CompressFontDXT3Block(block, buffer, offset);
+ }
+
+ h += 4;
+ ++y;
+ }
+
+ // Do last partial row
+ if (h < face.Height)
+ {
+ var rows = face.Height - h;
+ w = 0;
+ x = 0;
+ while (w < (face.Width & ~3))
+ {
+ Array.Clear(block, 0, 16);
+ for (int r = 0; r < rows; ++r)
+ {
+ var h0 = (h + r) * face.Width;
+ block[(r * 4) + 0] = colors[w + h0 + 0];
+ block[(r * 4) + 1] = colors[w + h0 + 1];
+ block[(r * 4) + 2] = colors[w + h0 + 2];
+ block[(r * 4) + 3] = colors[w + h0 + 3];
+ }
+
+ int offset = (x + y * xBlocks) * 16;
+ CompressFontDXT3Block(block, buffer, offset);
+
+ w += 4;
+ ++x;
+ }
+
+ // Do last partial block
+ if (w < face.Width)
+ {
+ var cols = face.Width - w;
+ Array.Clear(block, 0, 16);
+ for (int r = 0; r < rows; ++r)
+ {
+ var h0 = (h + r) * face.Width;
+ for (int c = 0; c < cols; ++c)
+ block[(r * 4) + c] = colors[w + h0 + c];
+ }
+
+ int offset = (x + y * xBlocks) * 16;
+ CompressFontDXT3Block(block, buffer, offset);
+ }
+ }
+ }
+
+ var dxt3 = new Dxt3BitmapContent(face.Width, face.Height);
+ dxt3.SetPixelData(buffer);
+ content.Faces[0][i] = dxt3;
+ }
+ }
+
+ // Maps a 2-bit greyscale to the index required for DXT3
+ // 00 = color0
+ // 01 = color1
+ // 10 = 2/3 * color0 + 1/3 * color1
+ // 11 = 1/3 * color0 + 2/3 * color1
+ static byte[] dxt3Map = new byte[] { 0, 2, 3, 1 };
+
+ // Compress a single 4x4 block from colors into buffer at the given offset
+ static void CompressFontDXT3Block(Vector4[] colors, byte[] buffer, int offset)
+ {
+ // Get the alpha into a 0-15 range
+ int a0 = (int)(colors[0].W * 15.0);
+ int a1 = (int)(colors[1].W * 15.0);
+ int a2 = (int)(colors[2].W * 15.0);
+ int a3 = (int)(colors[3].W * 15.0);
+ int a4 = (int)(colors[4].W * 15.0);
+ int a5 = (int)(colors[5].W * 15.0);
+ int a6 = (int)(colors[6].W * 15.0);
+ int a7 = (int)(colors[7].W * 15.0);
+ int a8 = (int)(colors[8].W * 15.0);
+ int a9 = (int)(colors[9].W * 15.0);
+ int a10 = (int)(colors[10].W * 15.0);
+ int a11 = (int)(colors[11].W * 15.0);
+ int a12 = (int)(colors[12].W * 15.0);
+ int a13 = (int)(colors[13].W * 15.0);
+ int a14 = (int)(colors[14].W * 15.0);
+ int a15 = (int)(colors[15].W * 15.0);
+
+ // Duplicate the top two bits into the bottom two bits so we get one of four values: b0000, b0101, b1010, b1111
+ a0 = (a0 & 0xC) | (a0 >> 2);
+ a1 = (a1 & 0xC) | (a1 >> 2);
+ a2 = (a2 & 0xC) | (a2 >> 2);
+ a3 = (a3 & 0xC) | (a3 >> 2);
+ a4 = (a4 & 0xC) | (a4 >> 2);
+ a5 = (a5 & 0xC) | (a5 >> 2);
+ a6 = (a6 & 0xC) | (a6 >> 2);
+ a7 = (a7 & 0xC) | (a7 >> 2);
+ a8 = (a8 & 0xC) | (a8 >> 2);
+ a9 = (a9 & 0xC) | (a9 >> 2);
+ a10 = (a10 & 0xC) | (a10 >> 2);
+ a11 = (a11 & 0xC) | (a11 >> 2);
+ a12 = (a12 & 0xC) | (a12 >> 2);
+ a13 = (a13 & 0xC) | (a13 >> 2);
+ a14 = (a14 & 0xC) | (a14 >> 2);
+ a15 = (a15 & 0xC) | (a15 >> 2);
+
+ // 4-bit alpha
+ buffer[offset + 0] = (byte)((a1 << 4) | a0);
+ buffer[offset + 1] = (byte)((a3 << 4) | a2);
+ buffer[offset + 2] = (byte)((a5 << 4) | a4);
+ buffer[offset + 3] = (byte)((a7 << 4) | a6);
+ buffer[offset + 4] = (byte)((a9 << 4) | a8);
+ buffer[offset + 5] = (byte)((a11 << 4) | a10);
+ buffer[offset + 6] = (byte)((a13 << 4) | a12);
+ buffer[offset + 7] = (byte)((a15 << 4) | a14);
+
+ // color0 (transparent)
+ buffer[offset + 8] = 0;
+ buffer[offset + 9] = 0;
+
+ // color1 (white)
+ buffer[offset + 10] = 255;
+ buffer[offset + 11] = 255;
+
+ // Get the red (to be used for green and blue channels as well) into a 0-15 range
+ a0 = (int)(colors[0].X * 15.0);
+ a1 = (int)(colors[1].X * 15.0);
+ a2 = (int)(colors[2].X * 15.0);
+ a3 = (int)(colors[3].X * 15.0);
+ a4 = (int)(colors[4].X * 15.0);
+ a5 = (int)(colors[5].X * 15.0);
+ a6 = (int)(colors[6].X * 15.0);
+ a7 = (int)(colors[7].X * 15.0);
+ a8 = (int)(colors[8].X * 15.0);
+ a9 = (int)(colors[9].X * 15.0);
+ a10 = (int)(colors[10].X * 15.0);
+ a11 = (int)(colors[11].X * 15.0);
+ a12 = (int)(colors[12].X * 15.0);
+ a13 = (int)(colors[13].X * 15.0);
+ a14 = (int)(colors[14].X * 15.0);
+ a15 = (int)(colors[15].X * 15.0);
+
+ // Duplicate the top two bits into the bottom two bits so we get one of four values: b0000, b0101, b1010, b1111
+ a0 = (a0 & 0xC) | (a0 >> 2);
+ a1 = (a1 & 0xC) | (a1 >> 2);
+ a2 = (a2 & 0xC) | (a2 >> 2);
+ a3 = (a3 & 0xC) | (a3 >> 2);
+ a4 = (a4 & 0xC) | (a4 >> 2);
+ a5 = (a5 & 0xC) | (a5 >> 2);
+ a6 = (a6 & 0xC) | (a6 >> 2);
+ a7 = (a7 & 0xC) | (a7 >> 2);
+ a8 = (a8 & 0xC) | (a8 >> 2);
+ a9 = (a9 & 0xC) | (a9 >> 2);
+ a10 = (a10 & 0xC) | (a10 >> 2);
+ a11 = (a11 & 0xC) | (a11 >> 2);
+ a12 = (a12 & 0xC) | (a12 >> 2);
+ a13 = (a13 & 0xC) | (a13 >> 2);
+ a14 = (a14 & 0xC) | (a14 >> 2);
+ a15 = (a15 & 0xC) | (a15 >> 2);
+
+ // Color indices (00 = color0, 01 = color1, 10 = 2/3 * color0 + 1/3 * color1, 11 = 1/3 * color0 + 2/3 * color1)
+ buffer[offset + 12] = (byte)((dxt3Map[a3 >> 2] << 6) | (dxt3Map[a2 >> 2] << 4) | (dxt3Map[a1 >> 2] << 2) | dxt3Map[a0 >> 2]);
+ buffer[offset + 13] = (byte)((dxt3Map[a7 >> 2] << 6) | (dxt3Map[a6 >> 2] << 4) | (dxt3Map[a5 >> 2] << 2) | dxt3Map[a4 >> 2]);
+ buffer[offset + 14] = (byte)((dxt3Map[a11 >> 2] << 6) | (dxt3Map[a10 >> 2] << 4) | (dxt3Map[a9 >> 2] << 2) | dxt3Map[a8 >> 2]);
+ buffer[offset + 15] = (byte)((dxt3Map[a15 >> 2] << 6) | (dxt3Map[a14 >> 2] << 4) | (dxt3Map[a13 >> 2] << 2) | dxt3Map[a12 >> 2]);
+ }
}
}
diff --git a/MonoGame.Framework.Content.Pipeline/Graphics/TextureProfile.cs b/MonoGame.Framework.Content.Pipeline/Graphics/TextureProfile.cs
index 1f884e4d397..1b67fb65f3c 100644
--- a/MonoGame.Framework.Content.Pipeline/Graphics/TextureProfile.cs
+++ b/MonoGame.Framework.Content.Pipeline/Graphics/TextureProfile.cs
@@ -49,8 +49,8 @@ public static TextureProfile ForPlatform(TargetPlatform platform)
/// The content to be compressed.
/// The user requested format for compression.
/// If mipmap generation is required.
- /// If the texture has sharp alpha cutouts.
- public void ConvertTexture(ContentProcessorContext context, TextureContent content, TextureProcessorOutputFormat format, bool generateMipmaps, bool sharpAlpha)
+ /// If the texture has represents a sprite font, i.e. is greyscale and has sharp black/white contrast.
+ public void ConvertTexture(ContentProcessorContext context, TextureContent content, TextureProcessorOutputFormat format, bool generateMipmaps, bool isSpriteFont)
{
// We do nothing in this case.
if (format == TextureProcessorOutputFormat.NoChange)
@@ -75,7 +75,7 @@ public void ConvertTexture(ContentProcessorContext context, TextureContent conte
try
{
// All other formats require platform specific choices.
- PlatformCompressTexture(context, content, format, generateMipmaps, false);
+ PlatformCompressTexture(context, content, format, generateMipmaps, isSpriteFont);
}
catch (EntryPointNotFoundException ex)
{
@@ -94,6 +94,6 @@ public void ConvertTexture(ContentProcessorContext context, TextureContent conte
}
}
- protected abstract void PlatformCompressTexture(ContentProcessorContext context, TextureContent content, TextureProcessorOutputFormat format, bool generateMipmaps, bool sharpAlpha);
+ protected abstract void PlatformCompressTexture(ContentProcessorContext context, TextureContent content, TextureProcessorOutputFormat format, bool generateMipmaps, bool isSpriteFont);
}
}
diff --git a/MonoGame.Framework.Content.Pipeline/MonoGame.Content.Builder.targets b/MonoGame.Framework.Content.Pipeline/MonoGame.Content.Builder.targets
index 93bb2f040d5..e342b783e8d 100644
--- a/MonoGame.Framework.Content.Pipeline/MonoGame.Content.Builder.targets
+++ b/MonoGame.Framework.Content.Pipeline/MonoGame.Content.Builder.targets
@@ -47,7 +47,7 @@
-
{
+ [DefaultValue(true)]
+ public virtual bool PremultiplyAlpha { get; set; }
+
[DefaultValue(typeof(TextureProcessorOutputFormat), "Compressed")]
public virtual TextureProcessorOutputFormat TextureFormat { get; set; }
public FontDescriptionProcessor()
{
- this.TextureFormat = TextureProcessorOutputFormat.Compressed;
+ PremultiplyAlpha = true;
+ TextureFormat = TextureProcessorOutputFormat.Compressed;
}
public override SpriteFontContent Process(FontDescription input,
@@ -86,7 +90,7 @@ public override SpriteFontContent Process(FontDescription input,
// Get the platform specific texture profile.
var texProfile = TextureProfile.ForPlatform(context.TargetPlatform);
- try {
+ {
if (!File.Exists(fontName)) {
throw new Exception(string.Format("Could not load {0}", fontName));
}
@@ -129,9 +133,47 @@ public override SpriteFontContent Process(FontDescription input,
output.Texture.Faces[0].Add(face);
}
- catch(Exception ex) {
- context.Logger.LogImportantMessage("{0}", ex.ToString());
- }
+
+ if (PremultiplyAlpha)
+ {
+ var bmp = output.Texture.Faces[0][0];
+ var data = bmp.GetPixelData();
+ var idx = 0;
+ for (; idx < data.Length; )
+ {
+ var r = data[idx];
+
+ // Special case of simply copying the R component into the A, since R is the value of white alpha we want
+ data[idx + 0] = r;
+ data[idx + 1] = r;
+ data[idx + 2] = r;
+ data[idx + 3] = r;
+
+ idx += 4;
+ }
+
+ bmp.SetPixelData(data);
+ }
+ else
+ {
+ var bmp = output.Texture.Faces[0][0];
+ var data = bmp.GetPixelData();
+ var idx = 0;
+ for (; idx < data.Length; )
+ {
+ var r = data[idx];
+
+ // Special case of simply moving the R component into the A and setting RGB to solid white, since R is the value of white alpha we want
+ data[idx + 0] = 255;
+ data[idx + 1] = 255;
+ data[idx + 2] = 255;
+ data[idx + 3] = r;
+
+ idx += 4;
+ }
+
+ bmp.SetPixelData(data);
+ }
// Perform the final texture conversion.
texProfile.ConvertTexture(context, output.Texture, TextureFormat, false, true);
@@ -222,6 +264,9 @@ string FindFontFileFromFontName(string fontname, string style)
s = s.Trim();
var split = s.Split (':');
+ if (split.Length < 2)
+ return String.Empty;
+
//check font family, fontconfig might return a fallback
if (split [1].Contains (",")) { //this file defines multiple family names
var families = split [1].Split (',');
diff --git a/MonoGame.Framework.Content.Pipeline/Serialization/Compiler/ContentWriter.cs b/MonoGame.Framework.Content.Pipeline/Serialization/Compiler/ContentWriter.cs
index c69cd1d6472..8d431fba41e 100644
--- a/MonoGame.Framework.Content.Pipeline/Serialization/Compiler/ContentWriter.cs
+++ b/MonoGame.Framework.Content.Pipeline/Serialization/Compiler/ContentWriter.cs
@@ -43,7 +43,6 @@ public sealed class ContentWriter : BinaryWriter
{
'w', // Windows (DirectX)
'x', // Xbox360
- 'm', // WindowsPhone
'i', // iOS
'a', // Android
'd', // DesktopGL
diff --git a/MonoGame.Framework.Content.Pipeline/Serialization/Compiler/IndexBufferWriter.cs b/MonoGame.Framework.Content.Pipeline/Serialization/Compiler/IndexBufferWriter.cs
index 47ff00d499b..cf09f372060 100644
--- a/MonoGame.Framework.Content.Pipeline/Serialization/Compiler/IndexBufferWriter.cs
+++ b/MonoGame.Framework.Content.Pipeline/Serialization/Compiler/IndexBufferWriter.cs
@@ -11,7 +11,17 @@ class IndexBufferWriter : BuiltInContentWriter
{
protected internal override void Write(ContentWriter output, IndexCollection value)
{
- var shortIndices = value.Count < ushort.MaxValue;
+ // Check if the buffer and can be saved as Int16.
+ var shortIndices = true;
+ foreach(var index in value)
+ {
+ if(index > ushort.MaxValue)
+ {
+ shortIndices = false;
+ break;
+ }
+ }
+
output.Write(shortIndices);
var byteCount = shortIndices
diff --git a/MonoGame.Framework.Content.Pipeline/Serialization/Intermediate/NamespaceAliasHelper.cs b/MonoGame.Framework.Content.Pipeline/Serialization/Intermediate/NamespaceAliasHelper.cs
index fc7dae29ce6..2d7b3e65c30 100644
--- a/MonoGame.Framework.Content.Pipeline/Serialization/Intermediate/NamespaceAliasHelper.cs
+++ b/MonoGame.Framework.Content.Pipeline/Serialization/Intermediate/NamespaceAliasHelper.cs
@@ -136,7 +136,7 @@ private static AliasedNamespace FindAlias(Dictionary a
}
///
- /// Returns just the portion relative to .
+ /// Returns just the portion relative to .
/// For example, given namespaceParent=Foo.Bar and @namespace=Foo.Bar.Baz, will return Baz.
///
private static string GetRelativeNamespace(string namespaceParent, string @namespace)
diff --git a/MonoGame.Framework.Content.Pipeline/TargetPlatform.cs b/MonoGame.Framework.Content.Pipeline/TargetPlatform.cs
index 36ab710b273..df5f061c7e6 100644
--- a/MonoGame.Framework.Content.Pipeline/TargetPlatform.cs
+++ b/MonoGame.Framework.Content.Pipeline/TargetPlatform.cs
@@ -24,11 +24,6 @@ public enum TargetPlatform
///
Xbox360,
- ///
- /// Windows Phone
- ///
- WindowsPhone,
-
// MonoGame-specific platforms listed below
///
diff --git a/MonoGame.Framework.Content.Pipeline/Utilities/Vector4Converter.cs b/MonoGame.Framework.Content.Pipeline/Utilities/Vector4Converter.cs
index ffc24b534b4..40651188115 100644
--- a/MonoGame.Framework.Content.Pipeline/Utilities/Vector4Converter.cs
+++ b/MonoGame.Framework.Content.Pipeline/Utilities/Vector4Converter.cs
@@ -24,24 +24,24 @@ class Vector4Converter :
Vector4 IVector4Converter.ToVector4(byte value)
{
var f = (float)value / (float)byte.MaxValue;
- return new Vector4(f, f, f, f);
+ return new Vector4(f, 0f, 0f, 1f);
}
Vector4 IVector4Converter.ToVector4(short value)
{
var f = (float)value / (float)short.MaxValue;
- return new Vector4(f, f, f, f);
+ return new Vector4(f, 0f, 0f, 1f);
}
Vector4 IVector4Converter.ToVector4(int value)
{
var f = (float)value / (float)int.MaxValue;
- return new Vector4(f, f, f, f);
+ return new Vector4(f, 0f, 0f, 1f);
}
Vector4 IVector4Converter.ToVector4(float value)
{
- return new Vector4(value, value, value, value);
+ return new Vector4(value, 0f, 0f, 1f);
}
Vector4 IVector4Converter.ToVector4(Color value)
diff --git a/MonoGame.Framework/Android/AndroidGameActivity.cs b/MonoGame.Framework/Android/AndroidGameActivity.cs
index 4892e73e270..23efe410542 100644
--- a/MonoGame.Framework/Android/AndroidGameActivity.cs
+++ b/MonoGame.Framework/Android/AndroidGameActivity.cs
@@ -11,11 +11,7 @@
namespace Microsoft.Xna.Framework
{
[CLSCompliant(false)]
-#if OUYA
- public class AndroidGameActivity : Ouya.Console.Api.OuyaActivity
-#else
public class AndroidGameActivity : Activity
-#endif
{
internal Game Game { private get; set; }
diff --git a/MonoGame.Framework/Android/AndroidGameWindow.cs b/MonoGame.Framework/Android/AndroidGameWindow.cs
index 9a737bdccab..8131a8bdbd5 100644
--- a/MonoGame.Framework/Android/AndroidGameWindow.cs
+++ b/MonoGame.Framework/Android/AndroidGameWindow.cs
@@ -9,10 +9,6 @@
using Microsoft.Xna.Framework.Input.Touch;
using OpenTK;
-#if OUYA
-using Microsoft.Xna.Framework.Input;
-#endif
-
namespace Microsoft.Xna.Framework
{
[CLSCompliant(false)]
@@ -53,10 +49,6 @@ private void Initialize(Context context)
GameView.RequestFocus();
GameView.FocusableInTouchMode = true;
-
-#if OUYA
- GamePad.Initialize();
-#endif
}
#region AndroidGameView Methods
diff --git a/MonoGame.Framework/Android/MonoGameAndroidGameView.cs b/MonoGame.Framework/Android/MonoGameAndroidGameView.cs
index aaabcc91a10..4b7b8093b70 100644
--- a/MonoGame.Framework/Android/MonoGameAndroidGameView.cs
+++ b/MonoGame.Framework/Android/MonoGameAndroidGameView.cs
@@ -27,9 +27,7 @@ internal class MonoGameAndroidGameView : AndroidGameView, View.IOnTouchListener,
public bool IsResuming { get; private set; }
private bool _lostContext;
-#if !OUYA
private bool backPressed;
-#endif
public MonoGameAndroidGameView(Context context, AndroidGameWindow androidGameWindow, Game game)
: base(context)
@@ -294,12 +292,11 @@ protected override void CreateFrameBuffer()
public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
{
- // Handle gamepad inputs in Android/OUYA
+ // Handle gamepad inputs in Android
if ((e.Source & InputSourceType.Gamepad) == InputSourceType.Gamepad)
return GamePad.OnKeyDown(keyCode, e);
Keyboard.KeyDown(keyCode);
-#if !OUYA
// we need to handle the Back key here because it doesnt work any other way
if (keyCode == Keycode.Back && !this.backPressed)
{
@@ -307,7 +304,6 @@ public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
GamePad.Back = true;
return true;
}
-#endif
if (keyCode == Keycode.VolumeUp)
{
@@ -333,11 +329,9 @@ public override bool OnKeyUp(Keycode keyCode, KeyEvent e)
Keyboard.KeyUp(keyCode);
-#if !OUYA
// we need to handle the Back key here because it doesnt work any other way
if (keyCode == Keycode.Back)
this.backPressed = false;
-#endif
return true;
}
diff --git a/MonoGame.Framework/Audio/OpenAL.cs b/MonoGame.Framework/Audio/OpenAL.cs
index 8e486b86374..b72ec2440d6 100644
--- a/MonoGame.Framework/Audio/OpenAL.cs
+++ b/MonoGame.Framework/Audio/OpenAL.cs
@@ -325,7 +325,6 @@ public static void DeleteSource(int source)
[DllImport (NativeLibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourceStop")]
public static extern void SourceStop (int sourceId);
- [CLSCompliant (false)]
[DllImport (NativeLibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourcei")]
internal static extern void Source (int sourceId, int i, int a);
diff --git a/MonoGame.Framework/Audio/OpenALSoundController.cs b/MonoGame.Framework/Audio/OpenALSoundController.cs
index 02f3ce79308..2d487567063 100644
--- a/MonoGame.Framework/Audio/OpenALSoundController.cs
+++ b/MonoGame.Framework/Audio/OpenALSoundController.cs
@@ -406,12 +406,11 @@ void Dispose(bool disposing)
}
///
- /// Reserves the given sound buffer. If there are no available sources then false is
- /// returned, otherwise true will be returned and the sound buffer can be played. If
- /// the controller was not able to setup the hardware, then false will be returned.
+ /// Reserves a sound buffer and return its identifier. If there are no available sources
+ /// or the controller was not able to setup the hardware then an
+ /// is thrown.
///
- /// The sound buffer you want to play
- /// True if the buffer can be played, and false if not.
+ /// The source number of the reserved sound buffer.
public int ReserveSource()
{
if (!CheckInitState())
diff --git a/MonoGame.Framework/Audio/Xact/ReverbSettings.cs b/MonoGame.Framework/Audio/Xact/ReverbSettings.cs
index 26add3ad246..6c414f5f596 100644
--- a/MonoGame.Framework/Audio/Xact/ReverbSettings.cs
+++ b/MonoGame.Framework/Audio/Xact/ReverbSettings.cs
@@ -11,8 +11,6 @@ class ReverbSettings
{
private readonly DspParameter[] _parameters = new DspParameter[22];
- private bool _dirty;
-
public ReverbSettings(BinaryReader reader)
{
_parameters[0] = new DspParameter(reader); // ReflectionsDelayMs
diff --git a/MonoGame.Framework/BoundingBox.cs b/MonoGame.Framework/BoundingBox.cs
index 077a01da9fc..c51d7e40b36 100644
--- a/MonoGame.Framework/BoundingBox.cs
+++ b/MonoGame.Framework/BoundingBox.cs
@@ -214,16 +214,11 @@ public void Contains(ref Vector3 point, out ContainmentType result)
|| point.Z > this.Max.Z)
{
result = ContainmentType.Disjoint;
- }//or if point is on box because coordonate of point is lesser or equal
- else if (point.X == this.Min.X
- || point.X == this.Max.X
- || point.Y == this.Min.Y
- || point.Y == this.Max.Y
- || point.Z == this.Min.Z
- || point.Z == this.Max.Z)
- result = ContainmentType.Intersects;
+ }
else
+ {
result = ContainmentType.Contains;
+ }
}
private static readonly Vector3 MaxVector3 = new Vector3(float.MaxValue);
diff --git a/MonoGame.Framework/Color.cs b/MonoGame.Framework/Color.cs
index 75afbbaf28a..bbfc61b9ec4 100644
--- a/MonoGame.Framework/Color.cs
+++ b/MonoGame.Framework/Color.cs
@@ -1788,7 +1788,7 @@ public Vector4 ToVector4()
return new Vector4(R / 255.0f, G / 255.0f, B / 255.0f, A / 255.0f);
}
- ///
+ ///
/// Gets or sets packed value of this .
///
[CLSCompliant(false)]
diff --git a/MonoGame.Framework/Content/ContentManager.cs b/MonoGame.Framework/Content/ContentManager.cs
index 541f88bc9d1..38bf5eea6a8 100644
--- a/MonoGame.Framework/Content/ContentManager.cs
+++ b/MonoGame.Framework/Content/ContentManager.cs
@@ -37,7 +37,6 @@ public partial class ContentManager : IDisposable
{
'w', // Windows (DirectX)
'x', // Xbox360
- 'm', // WindowsPhone
'i', // iOS
'a', // Android
'd', // DesktopGL
@@ -61,7 +60,6 @@ public partial class ContentManager : IDisposable
'p', // PlayStationMobile
'g', // Windows (OpenGL)
'l', // Linux
- 'u', // Ouya
};
diff --git a/MonoGame.Framework/Game.cs b/MonoGame.Framework/Game.cs
index 6cf99b2b563..88b7ec7a77f 100644
--- a/MonoGame.Framework/Game.cs
+++ b/MonoGame.Framework/Game.cs
@@ -53,7 +53,7 @@ public class Game : IDisposable
private TimeSpan _maxElapsedTime = TimeSpan.FromMilliseconds(500);
-
+ private bool _shouldExit;
private bool _suppressDraw;
public Game()
@@ -323,7 +323,7 @@ internal bool Initialized
#endif
public void Exit()
{
- Platform.Exit();
+ _shouldExit = true;
_suppressDraw = true;
}
@@ -350,7 +350,8 @@ public void RunOneFrame()
if (!Platform.BeforeRun())
return;
- if (!_initialized) {
+ if (!_initialized)
+ {
DoInitialize ();
_gameTimer = Stopwatch.StartNew();
_initialized = true;
@@ -452,7 +453,7 @@ public void Tick()
var stepCount = 0;
// Perform as many full fixed length time steps as we can.
- while (_accumulatedElapsedTime >= TargetElapsedTime)
+ while (_accumulatedElapsedTime >= TargetElapsedTime && !_shouldExit)
{
_gameTime.TotalGameTime += TargetElapsedTime;
_accumulatedElapsedTime -= TargetElapsedTime;
@@ -501,6 +502,9 @@ public void Tick()
{
DoDraw(_gameTime);
}
+
+ if (_shouldExit)
+ Platform.Exit();
}
#endregion
@@ -521,7 +525,7 @@ protected virtual void UnloadContent() { }
protected virtual void Initialize()
{
- // TODO: We shouldn't need to do this here.
+ // TODO: This should be removed once all platforms use the new GraphicsDeviceManager
applyChanges(graphicsDeviceManager);
// According to the information given on MSDN (see link below), all
@@ -534,9 +538,6 @@ protected virtual void Initialize()
_graphicsDeviceService = (IGraphicsDeviceService)
Services.GetService(typeof(IGraphicsDeviceService));
- // FIXME: If this test fails, is LoadContent ever called? This
- // seems like a condition that warrants an exception more
- // than a silent failure.
if (_graphicsDeviceService != null &&
_graphicsDeviceService.GraphicsDevice != null)
{
@@ -677,6 +678,9 @@ internal void DoDraw(GameTime gameTime)
internal void DoInitialize()
{
AssertNotDisposed();
+ if (GraphicsDevice == null && graphicsDeviceManager != null)
+ _graphicsDeviceManager.CreateDevice();
+
Platform.BeforeInitialize();
Initialize();
@@ -706,9 +710,6 @@ internal GraphicsDeviceManager graphicsDeviceManager
{
_graphicsDeviceManager = (IGraphicsDeviceManager)
Services.GetService(typeof(IGraphicsDeviceManager));
-
- if (_graphicsDeviceManager == null)
- throw new InvalidOperationException ("No Graphics Device Manager");
}
return (GraphicsDeviceManager)_graphicsDeviceManager;
}
diff --git a/MonoGame.Framework/GamePlatform.Mobile.cs b/MonoGame.Framework/GamePlatform.Mobile.cs
index da033c5bb7e..64de849f8ea 100644
--- a/MonoGame.Framework/GamePlatform.Mobile.cs
+++ b/MonoGame.Framework/GamePlatform.Mobile.cs
@@ -16,8 +16,6 @@ internal static GamePlatform PlatformCreate(Game game)
return new AndroidGamePlatform(game);
#elif WINDOWS_PHONE81
return new MetroGamePlatform(game);
-#elif WINDOWS_PHONE
- return new MonoGame.Framework.WindowsPhone.WindowsPhoneGamePlatform(game);
#elif WEB
return new WebGamePlatform(game);
#endif
diff --git a/MonoGame.Framework/GamePlatform.cs b/MonoGame.Framework/GamePlatform.cs
index 300abbe22d8..da8b4102d06 100644
--- a/MonoGame.Framework/GamePlatform.cs
+++ b/MonoGame.Framework/GamePlatform.cs
@@ -16,8 +16,7 @@ abstract partial class GamePlatform : IDisposable
protected TimeSpan _inactiveSleepTime = TimeSpan.FromMilliseconds(20.0);
protected bool _needsToResetElapsedTime = false;
bool disposed;
- protected bool _alreadyInFullScreenMode = false;
- protected bool _alreadyInWindowedMode = false;
+ protected bool InFullScreenMode = false;
protected bool IsDisposed { get { return disposed; } }
#endregion
@@ -138,11 +137,6 @@ protected void RaiseAsyncRunLoopEnded()
public virtual void BeforeInitialize()
{
IsActive = true;
- if (this.Game.GraphicsDevice == null)
- {
- var graphicsDeviceManager = Game.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager;
- graphicsDeviceManager.CreateDevice();
- }
}
///
diff --git a/MonoGame.Framework/GameWindow.cs b/MonoGame.Framework/GameWindow.cs
index 749488690d9..1243580f117 100644
--- a/MonoGame.Framework/GameWindow.cs
+++ b/MonoGame.Framework/GameWindow.cs
@@ -120,7 +120,7 @@ protected void OnActivated ()
{
}
- protected void OnClientSizeChanged ()
+ internal void OnClientSizeChanged ()
{
if (ClientSizeChanged != null)
ClientSizeChanged (this, EventArgs.Empty);
diff --git a/MonoGame.Framework/Graphics/ClearOptions.cs b/MonoGame.Framework/Graphics/ClearOptions.cs
index 10a24ffe0d1..f580572446a 100644
--- a/MonoGame.Framework/Graphics/ClearOptions.cs
+++ b/MonoGame.Framework/Graphics/ClearOptions.cs
@@ -7,7 +7,7 @@
namespace Microsoft.Xna.Framework.Graphics
{
///
- /// Defines the buffers for clearing when calling operation.
+ /// Defines the buffers for clearing when calling operation.
///
[Flags]
public enum ClearOptions
diff --git a/MonoGame.Framework/Graphics/GraphicsAdapter.DirectX.cs b/MonoGame.Framework/Graphics/GraphicsAdapter.DirectX.cs
index 07644a690cb..60fad0d84ae 100644
--- a/MonoGame.Framework/Graphics/GraphicsAdapter.DirectX.cs
+++ b/MonoGame.Framework/Graphics/GraphicsAdapter.DirectX.cs
@@ -5,11 +5,15 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using SharpDX.Direct3D;
+using SharpDX.DXGI;
namespace Microsoft.Xna.Framework.Graphics
{
partial class GraphicsAdapter
{
+ SharpDX.DXGI.Adapter1 _adapter;
+
private static void PlatformInitializeAdapters(out ReadOnlyCollection adapters)
{
var factory = new SharpDX.DXGI.Factory1();
@@ -31,8 +35,6 @@ private static void PlatformInitializeAdapters(out ReadOnlyCollection 0)
+ {
+ qualityLevels = device._d3dDevice.CheckMultisampleQualityLevels(format, maxLevel);
+ if (qualityLevels > 0)
+ break;
+ maxLevel /= 2;
+ }
+ return maxLevel;
+ }
+ }
+}
\ No newline at end of file
diff --git a/MonoGame.Framework/Graphics/GraphicsCapabilities.OpenGL.cs b/MonoGame.Framework/Graphics/GraphicsCapabilities.OpenGL.cs
new file mode 100644
index 00000000000..52d5834af42
--- /dev/null
+++ b/MonoGame.Framework/Graphics/GraphicsCapabilities.OpenGL.cs
@@ -0,0 +1,130 @@
+// MonoGame - Copyright (C) The MonoGame Team
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE.txt', which is part of this source code package.
+
+#if OPENGL
+#if MONOMAC
+#if PLATFORM_MACOS_LEGACY
+using MonoMac.OpenGL;
+using GetParamName = MonoMac.OpenGL.All;
+using GetPName = MonoMac.OpenGL.GetPName;
+#else
+using OpenTK.Graphics.OpenGL;
+using GetParamName = OpenTK.Graphics.OpenGL.All;
+using GetPName = OpenTK.Graphics.OpenGL.GetPName;
+#endif
+#elif GLES
+using OpenTK.Graphics.ES20;
+using GetParamName = OpenTK.Graphics.ES20.All;
+using GetPName = OpenTK.Graphics.ES20.GetPName;
+#else
+using OpenGL;
+using GetParamName = OpenGL.GetPName;
+#endif
+#endif
+
+namespace Microsoft.Xna.Framework.Graphics
+{
+
+ internal partial class GraphicsCapabilities
+ {
+ ///
+ /// True, if GL_ARB_framebuffer_object is supported; false otherwise.
+ ///
+ internal bool SupportsFramebufferObjectARB { get; private set; }
+
+ ///
+ /// True, if GL_EXT_framebuffer_object is supported; false otherwise.
+ ///
+ internal bool SupportsFramebufferObjectEXT { get; private set; }
+
+ ///
+ /// Gets the max texture anisotropy. This value typically lies
+ /// between 0 and 16, where 0 means anisotropic filtering is not
+ /// supported.
+ ///
+ internal int MaxTextureAnisotropy { get; private set; }
+
+ private void PlatformInitialize(GraphicsDevice device)
+ {
+#if GLES
+ SupportsNonPowerOfTwo = device._extensions.Contains("GL_OES_texture_npot") ||
+ device._extensions.Contains("GL_ARB_texture_non_power_of_two") ||
+ device._extensions.Contains("GL_IMG_texture_npot") ||
+ device._extensions.Contains("GL_NV_texture_npot_2D_mipmap");
+#else
+ // Unfortunately non PoT texture support is patchy even on desktop systems and we can't
+ // rely on the fact that GL2.0+ supposedly supports npot in the core.
+ // Reference: http://aras-p.info/blog/2012/10/17/non-power-of-two-textures/
+ SupportsNonPowerOfTwo = device._maxTextureSize >= 8192;
+#endif
+
+ SupportsTextureFilterAnisotropic = device._extensions.Contains("GL_EXT_texture_filter_anisotropic");
+
+#if GLES
+ SupportsDepth24 = device._extensions.Contains("GL_OES_depth24");
+ SupportsPackedDepthStencil = device._extensions.Contains("GL_OES_packed_depth_stencil");
+ SupportsDepthNonLinear = device._extensions.Contains("GL_NV_depth_nonlinear");
+ SupportsTextureMaxLevel = device._extensions.Contains("GL_APPLE_texture_max_level");
+#else
+ SupportsDepth24 = true;
+ SupportsPackedDepthStencil = true;
+ SupportsDepthNonLinear = false;
+ SupportsTextureMaxLevel = true;
+#endif
+ // Texture compression
+ SupportsS3tc = device._extensions.Contains("GL_EXT_texture_compression_s3tc") ||
+ device._extensions.Contains("GL_OES_texture_compression_S3TC") ||
+ device._extensions.Contains("GL_EXT_texture_compression_dxt3") ||
+ device._extensions.Contains("GL_EXT_texture_compression_dxt5");
+ SupportsDxt1 = SupportsS3tc || device._extensions.Contains("GL_EXT_texture_compression_dxt1");
+ SupportsPvrtc = device._extensions.Contains("GL_IMG_texture_compression_pvrtc");
+ SupportsEtc1 = device._extensions.Contains("GL_OES_compressed_ETC1_RGB8_texture");
+ SupportsAtitc = device._extensions.Contains("GL_ATI_texture_compression_atitc") ||
+ device._extensions.Contains("GL_AMD_compressed_ATC_texture");
+
+ // Framebuffer objects
+#if GLES
+ SupportsFramebufferObjectARB = true; // always supported on GLES 2.0+
+ SupportsFramebufferObjectEXT = false;
+#else
+ // if we're on GL 3.0+, frame buffer extensions are guaranteed to be present, but extensions may be missing
+ // it is then safe to assume that GL_ARB_framebuffer_object is present so that the standard function are loaded
+ SupportsFramebufferObjectARB = device.glMajorVersion >= 3 || device._extensions.Contains("GL_ARB_framebuffer_object");
+ SupportsFramebufferObjectEXT = device._extensions.Contains("GL_EXT_framebuffer_object");
+#endif
+ // Anisotropic filtering
+ int anisotropy = 0;
+ if (SupportsTextureFilterAnisotropic)
+ {
+#if __IOS__
+ GL.GetInteger ((GetPName)All.MaxTextureMaxAnisotropyExt, out anisotropy);
+#else
+ GL.GetInteger((GetPName)GetParamName.MaxTextureMaxAnisotropyExt, out anisotropy);
+#endif
+ GraphicsExtensions.CheckGLError();
+ }
+ MaxTextureAnisotropy = anisotropy;
+
+ // sRGB
+#if GLES
+ SupportsSRgb = device._extensions.Contains("GL_EXT_sRGB");
+#else
+ SupportsSRgb = device._extensions.Contains("GL_EXT_texture_sRGB") && device._extensions.Contains("GL_EXT_framebuffer_sRGB");
+#endif
+
+ // TODO: Implement OpenGL support for texture arrays
+ // once we can author shaders that use texture arrays.
+ SupportsTextureArrays = false;
+
+ SupportsDepthClamp = device._extensions.Contains("GL_ARB_depth_clamp");
+
+ SupportsVertexTextures = false; // For now, until we implement vertex textures in OpenGL.
+ }
+
+ private void PlatformInitializeAfterResources(GraphicsDevice device)
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/MonoGame.Framework/Graphics/GraphicsCapabilities.Web.cs b/MonoGame.Framework/Graphics/GraphicsCapabilities.Web.cs
new file mode 100644
index 00000000000..866dbc2f05c
--- /dev/null
+++ b/MonoGame.Framework/Graphics/GraphicsCapabilities.Web.cs
@@ -0,0 +1,21 @@
+// MonoGame - Copyright (C) The MonoGame Team
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE.txt', which is part of this source code package.
+
+using System;
+
+namespace Microsoft.Xna.Framework.Graphics
+{
+ internal partial class GraphicsCapabilities
+ {
+ private void PlatformInitialize(GraphicsDevice device)
+ {
+ throw new NotImplementedException();
+ }
+
+ private void PlatformInitializeAfterResources(GraphicsDevice device)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/MonoGame.Framework/Graphics/GraphicsCapabilities.cs b/MonoGame.Framework/Graphics/GraphicsCapabilities.cs
index 192edeca184..d40e6e37547 100644
--- a/MonoGame.Framework/Graphics/GraphicsCapabilities.cs
+++ b/MonoGame.Framework/Graphics/GraphicsCapabilities.cs
@@ -4,26 +4,6 @@
using System;
using System.Collections.Generic;
-#if OPENGL
-#if MONOMAC
-#if PLATFORM_MACOS_LEGACY
-using MonoMac.OpenGL;
-using GetParamName = MonoMac.OpenGL.All;
-using GetPName = MonoMac.OpenGL.GetPName;
-#else
-using OpenTK.Graphics.OpenGL;
-using GetParamName = OpenTK.Graphics.OpenGL.All;
-using GetPName = OpenTK.Graphics.OpenGL.GetPName;
-#endif
-#elif GLES
-using OpenTK.Graphics.ES20;
-using GetParamName = OpenTK.Graphics.ES20.All;
-using GetPName = OpenTK.Graphics.ES20.GetPName;
-#else
-using OpenGL;
-using GetParamName = OpenGL.GetPName;
-#endif
-#endif
namespace Microsoft.Xna.Framework.Graphics
{
@@ -32,12 +12,19 @@ namespace Microsoft.Xna.Framework.Graphics
/// current graphics device. A very useful thread for investigating GL extenion names
/// http://stackoverflow.com/questions/3881197/opengl-es-2-0-extensions-on-android-devices
///
- internal class GraphicsCapabilities
+ internal partial class GraphicsCapabilities
{
- public GraphicsCapabilities(GraphicsDevice graphicsDevice)
+ internal void Initialize(GraphicsDevice device)
{
- Initialize(graphicsDevice);
+ PlatformInitialize(device);
}
+
+ // For figuring out some capabilities we need native resources for querying
+ internal void InitializeAfterResources(GraphicsDevice device)
+ {
+ PlatformInitializeAfterResources(device);
+ }
+
///
/// Whether the device fully supports non power-of-two textures, including
/// mip maps and wrap modes other than CLAMP_TO_EDGE
@@ -80,25 +67,6 @@ public GraphicsCapabilities(GraphicsDevice graphicsDevice)
///
internal bool SupportsAtitc { get; private set; }
-#if OPENGL
- ///
- /// True, if GL_ARB_framebuffer_object is supported; false otherwise.
- ///
- internal bool SupportsFramebufferObjectARB { get; private set; }
-
- ///
- /// True, if GL_EXT_framebuffer_object is supported; false otherwise.
- ///
- internal bool SupportsFramebufferObjectEXT { get; private set; }
-
- ///
- /// Gets the max texture anisotropy. This value typically lies
- /// between 0 and 16, where 0 means anisotropic filtering is not
- /// supported.
- ///
- internal int MaxTextureAnisotropy { get; private set; }
-#endif
-
internal bool SupportsTextureMaxLevel { get; private set; }
///
@@ -114,121 +82,8 @@ public GraphicsCapabilities(GraphicsDevice graphicsDevice)
internal bool SupportsVertexTextures { get; private set; }
- internal void Initialize(GraphicsDevice device)
- {
- SupportsNonPowerOfTwo = GetNonPowerOfTwo(device);
-
-#if OPENGL
- SupportsTextureFilterAnisotropic = device._extensions.Contains("GL_EXT_texture_filter_anisotropic");
-#else
- SupportsTextureFilterAnisotropic = true;
-#endif
-#if GLES
- SupportsDepth24 = device._extensions.Contains("GL_OES_depth24");
- SupportsPackedDepthStencil = device._extensions.Contains("GL_OES_packed_depth_stencil");
- SupportsDepthNonLinear = device._extensions.Contains("GL_NV_depth_nonlinear");
- SupportsTextureMaxLevel = device._extensions.Contains("GL_APPLE_texture_max_level");
-#else
- SupportsDepth24 = true;
- SupportsPackedDepthStencil = true;
- SupportsDepthNonLinear = false;
- SupportsTextureMaxLevel = true;
-#endif
-
- // Texture compression
-#if DIRECTX
- SupportsDxt1 = true;
- SupportsS3tc = true;
-#elif OPENGL
- SupportsS3tc = device._extensions.Contains("GL_EXT_texture_compression_s3tc") ||
- device._extensions.Contains("GL_OES_texture_compression_S3TC") ||
- device._extensions.Contains("GL_EXT_texture_compression_dxt3") ||
- device._extensions.Contains("GL_EXT_texture_compression_dxt5");
- SupportsDxt1 = SupportsS3tc || device._extensions.Contains("GL_EXT_texture_compression_dxt1");
- SupportsPvrtc = device._extensions.Contains("GL_IMG_texture_compression_pvrtc");
- SupportsEtc1 = device._extensions.Contains("GL_OES_compressed_ETC1_RGB8_texture");
- SupportsAtitc = device._extensions.Contains("GL_ATI_texture_compression_atitc") ||
- device._extensions.Contains("GL_AMD_compressed_ATC_texture");
-#endif
-
- // OpenGL framebuffer objects
-#if OPENGL
-#if GLES
- SupportsFramebufferObjectARB = true; // always supported on GLES 2.0+
- SupportsFramebufferObjectEXT = false;
-#else
- // if we're on GL 3.0+, frame buffer extensions are guaranteed to be present, but extensions may be missing
- // it is then safe to assume that GL_ARB_framebuffer_object is present so that the standard function are loaded
- SupportsFramebufferObjectARB = device.glMajorVersion >= 3 || device._extensions.Contains("GL_ARB_framebuffer_object");
- SupportsFramebufferObjectEXT = device._extensions.Contains("GL_EXT_framebuffer_object");
-#endif
-#endif
-
- // Anisotropic filtering
-#if OPENGL
- int anisotropy = 0;
- if (SupportsTextureFilterAnisotropic)
- {
-#if __IOS__
- GL.GetInteger ((GetPName)All.MaxTextureMaxAnisotropyExt, out anisotropy);
-#else
- GL.GetInteger((GetPName)GetParamName.MaxTextureMaxAnisotropyExt, out anisotropy);
-#endif
- GraphicsExtensions.CheckGLError();
- }
- MaxTextureAnisotropy = anisotropy;
-#endif
-
- // sRGB
-#if DIRECTX
- SupportsSRgb = true;
-#elif OPENGL
-#if GLES
- SupportsSRgb = device._extensions.Contains("GL_EXT_sRGB");
-#else
- SupportsSRgb = device._extensions.Contains("GL_EXT_texture_sRGB") && device._extensions.Contains("GL_EXT_framebuffer_sRGB");
-#endif
-#endif
-
-#if DIRECTX
- SupportsTextureArrays = device.GraphicsProfile == GraphicsProfile.HiDef;
-#elif OPENGL
- // TODO: Implement OpenGL support for texture arrays
- // once we can author shaders that use texture arrays.
- SupportsTextureArrays = false;
-#endif
-
-#if DIRECTX
- SupportsDepthClamp = device.GraphicsProfile == GraphicsProfile.HiDef;
-#elif OPENGL
- SupportsDepthClamp = device._extensions.Contains("GL_ARB_depth_clamp");
-#endif
-
-#if DIRECTX
- SupportsVertexTextures = device.GraphicsProfile == GraphicsProfile.HiDef;
-#elif OPENGL
- SupportsVertexTextures = false; // For now, until we implement vertex textures in OpenGL.
-#endif
- }
-
- bool GetNonPowerOfTwo(GraphicsDevice device)
- {
-#if OPENGL
-#if GLES
- return device._extensions.Contains("GL_OES_texture_npot") ||
- device._extensions.Contains("GL_ARB_texture_non_power_of_two") ||
- device._extensions.Contains("GL_IMG_texture_npot") ||
- device._extensions.Contains("GL_NV_texture_npot_2D_mipmap");
-#else
- // Unfortunately non PoT texture support is patchy even on desktop systems and we can't
- // rely on the fact that GL2.0+ supposedly supports npot in the core.
- // Reference: http://aras-p.info/blog/2012/10/17/non-power-of-two-textures/
- return device._maxTextureSize >= 8192;
-#endif
-
-#else
- return device.GraphicsProfile == GraphicsProfile.HiDef;
-#endif
- }
+ // The highest possible MSCount
+ private const int MultiSampleCountLimit = 32;
+ internal int MaxMultiSampleCount;
}
}
\ No newline at end of file
diff --git a/MonoGame.Framework/Graphics/GraphicsDevice.DirectX.cs b/MonoGame.Framework/Graphics/GraphicsDevice.DirectX.cs
index c311f3bfdf9..2b704334a98 100644
--- a/MonoGame.Framework/Graphics/GraphicsDevice.DirectX.cs
+++ b/MonoGame.Framework/Graphics/GraphicsDevice.DirectX.cs
@@ -11,9 +11,6 @@
using SharpDX;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
-#if WINDOWS_PHONE
-using MonoGame.Framework.WindowsPhone;
-#endif
#if WINDOWS_STOREAPP || WINDOWS_UAP
using Windows.UI.Xaml.Controls;
@@ -568,7 +565,7 @@ internal void OnPresentationChanged()
#if WINDOWS_STOREAPP || WINDOWS_UAP || WINDOWS_PHONE
- internal void PlatformSetMultiSamplingToMaximum(PresentationParameters presentationParameters, out int quality)
+ private void SetMultiSamplingToMaximum(PresentationParameters presentationParameters, out int quality)
{
quality = (int)SharpDX.Direct3D11.StandardMultisampleQualityLevels.StandardMultisamplePattern;
}
@@ -655,39 +652,10 @@ protected virtual void CreateDeviceResources()
// Get Direct3D 11.1 context
_d3dContext = _d3dDevice.ImmediateContext.QueryInterface();
}
-
- internal void PlatformSetMultiSamplingToMaximum(PresentationParameters presentationParameters, out int quality)
- {
- var format = presentationParameters.BackBufferFormat == SurfaceFormat.Color ?
- SharpDX.DXGI.Format.B8G8R8A8_UNorm :
- SharpDXHelper.ToFormat(presentationParameters.BackBufferFormat);
-
- // Check that the multisample count specified by the game is valid.
- var msc = PresentationParameters.MultiSampleCount;
- if (!((msc != 0) && ((msc & (msc - 1)) == 0)))
- {
- throw new ApplicationException(
- "The specified multisample count is not a power of 2 (it must be " +
- "a value such as 0, 1, 2, 4, 8, 16, 32, etc.).");
- }
- // Find the maximum supported level starting with the game's requested multisampling level
- // and halving each time until reaching 0 (meaning no multisample support).
- var qualityLevels = 0;
- var maxLevel = msc;
- while (maxLevel > 0)
- {
- qualityLevels = _d3dDevice.CheckMultisampleQualityLevels(format, maxLevel);
- if (qualityLevels > 0)
- break;
- maxLevel /= 2;
- }
-
- // Correct the MSAA level if it is too high.
- if (presentationParameters.MultiSampleCount > maxLevel)
- presentationParameters.MultiSampleCount = maxLevel;
-
- quality = qualityLevels - 1;
+ private int GetMultiSamplingQuality(Format format, int multiSampleCount)
+ {
+ return _d3dDevice.CheckMultisampleQualityLevels(format, multiSampleCount) - 1;
}
internal void SetHardwareFullscreen()
@@ -741,15 +709,12 @@ internal void CreateSizeDependentResources()
var multisampleDesc = new SharpDX.DXGI.SampleDescription(1, 0);
if (PresentationParameters.MultiSampleCount > 1)
{
- int quality;
- PlatformSetMultiSamplingToMaximum(PresentationParameters, out quality);
+ var quality = GetMultiSamplingQuality(format, PresentationParameters.MultiSampleCount);
multisampleDesc.Count = PresentationParameters.MultiSampleCount;
multisampleDesc.Quality = quality;
}
- int vSyncFrameLatency = PresentationParameters.PresentationInterval.GetFrameLatency();
-
// If the swap chain already exists... update it.
if (_swapChain != null)
{
@@ -757,18 +722,7 @@ internal void CreateSizeDependentResources()
PresentationParameters.BackBufferWidth,
PresentationParameters.BackBufferHeight,
format,
- SwapChainFlags.None);
-
- // Update Vsync setting.
- using (var dxgiDevice = _d3dDevice.QueryInterface())
- {
- // If VSync is disabled, Ensure that DXGI does not queue more than one frame at a time. This
- // both reduces latency and ensures that the application will only render
- // after each VSync, minimizing power consumption.
- // Setting latency to 0 (PresentInterval.Immediate) will result in the hardware default.
- // (normally 3)
- dxgiDevice.MaximumFrameLatency = vSyncFrameLatency;
- }
+ SwapChainFlags.AllowModeSwitch);
}
// Otherwise, create a new swap chain.
@@ -807,12 +761,9 @@ internal void CreateSizeDependentResources()
{
_swapChain = new SwapChain(dxgiFactory, dxgiDevice, desc);
dxgiFactory.MakeWindowAssociation(PresentationParameters.DeviceWindowHandle, WindowAssociationFlags.IgnoreAll);
- // If VSync is disabled, Ensure that DXGI does not queue more than one frame at a time. This
- // both reduces latency and ensures that the application will only render
- // after each VSync, minimizing power consumption.
- // Setting latency to 0 (PresentInterval.Immediate) will result in the hardware default.
- // (normally 3)
- dxgiDevice.MaximumFrameLatency = vSyncFrameLatency;
+ // To reduce latency, ensure that DXGI does not queue more than one frame at a time.
+ // Docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ff471334(v=vs.85).aspx
+ dxgiDevice.MaximumFrameLatency = 1;
}
}
@@ -1005,7 +956,7 @@ public void PlatformPresent()
try
{
- var syncInterval = PresentationParameters.PresentationInterval.GetFrameLatency();
+ var syncInterval = PresentationParameters.PresentationInterval.GetSyncInterval();
// The first argument instructs DXGI to block n VSyncs before presenting.
lock (_d3dContext)
@@ -1182,19 +1133,34 @@ internal void PlatformBeginApplyState()
Debug.Assert(_d3dContext != null, "The d3d context is null!");
}
- private void PlatformApplyBlendFactor()
+ private void PlatformApplyBlend()
{
+ if (_blendFactorDirty || _blendStateDirty)
+ {
+ var state = _actualBlendState.GetDxState(this);
+ var factor = GetBlendFactor();
+ _d3dContext.OutputMerger.SetBlendState(state, factor);
+
+ _blendFactorDirty = false;
+ _blendStateDirty = false;
+ }
+ }
+
#if WINDOWS_UAP
- _d3dContext.OutputMerger.BlendFactor =
- new SharpDX.Mathematics.Interop.RawColor4(
+ private SharpDX.Mathematics.Interop.RawColor4 GetBlendFactor()
+ {
+ return new SharpDX.Mathematics.Interop.RawColor4(
BlendFactor.R / 255.0f,
BlendFactor.G / 255.0f,
BlendFactor.B / 255.0f,
BlendFactor.A / 255.0f);
+ }
#else
- _d3dContext.OutputMerger.BlendFactor = BlendFactor.ToColor4();
-#endif
+ private Color4 GetBlendFactor()
+ {
+ return BlendFactor.ToColor4();
}
+#endif
internal void PlatformApplyState(bool applyShaders)
{
@@ -1332,8 +1298,7 @@ private int SetUserIndexBuffer(T[] indexData, int indexOffset, int indexCount
{
DynamicIndexBuffer buffer;
- var indexType = typeof(T);
- var indexSize = Marshal.SizeOf(indexType);
+ var indexSize = Utilities.ReflectionHelpers.SizeOf.Get();
var indexElementSize = indexSize == 2 ? IndexElementSize.SixteenBits : IndexElementSize.ThirtyTwoBits;
var requiredIndexCount = Math.Max(indexCount, 6000);
diff --git a/MonoGame.Framework/Graphics/GraphicsDevice.OpenGL.cs b/MonoGame.Framework/Graphics/GraphicsDevice.OpenGL.cs
index 54e51966441..7ec4ed2054f 100644
--- a/MonoGame.Framework/Graphics/GraphicsDevice.OpenGL.cs
+++ b/MonoGame.Framework/Graphics/GraphicsDevice.OpenGL.cs
@@ -296,9 +296,8 @@ private void PlatformInitialize()
"Try updating your graphics drivers.");
}
- // Force reseting states
- this.BlendState.PlatformApplyState(this, true);
- this.PlatformApplyBlendFactor(true);
+ // Force resetting states
+ this.PlatformApplyBlend(true);
this.DepthStencilState.PlatformApplyState(this, true);
this.RasterizerState.PlatformApplyState(this, true);
@@ -843,15 +842,21 @@ internal void PlatformBeginApplyState()
Threading.EnsureUIThread();
}
- private void PlatformApplyBlendFactor(bool force = false)
+ private void PlatformApplyBlend(bool force = false)
+ {
+ _actualBlendState.PlatformApplyState(this, force);
+ ApplyBlendFactor(force);
+ }
+
+ private void ApplyBlendFactor(bool force)
{
if (force || BlendFactor != _lastBlendState.BlendFactor)
{
GL.BlendColor(
- this.BlendFactor.R / 255.0f,
- this.BlendFactor.G / 255.0f,
- this.BlendFactor.B / 255.0f,
- this.BlendFactor.A / 255.0f);
+ this.BlendFactor.R/255.0f,
+ this.BlendFactor.G/255.0f,
+ this.BlendFactor.B/255.0f,
+ this.BlendFactor.A/255.0f);
GraphicsExtensions.CheckGLError();
_lastBlendState.BlendFactor = this.BlendFactor;
}
@@ -942,7 +947,8 @@ private void PlatformDrawIndexedPrimitives(PrimitiveType primitiveType, int base
var vertexDeclaration = _vertexBuffers.Get(0).VertexBuffer.VertexDeclaration;
var vertexOffset = (IntPtr)(vertexDeclaration.VertexStride * baseVertex);
- vertexDeclaration.Apply(_vertexShader, vertexOffset);
+ var programHash = _vertexShader.HashKey | _pixelShader.HashKey;
+ vertexDeclaration.Apply(_vertexShader, vertexOffset, programHash);
GL.DrawElements(target,
indexElementCount,
@@ -967,7 +973,8 @@ private void PlatformDrawUserPrimitives(PrimitiveType primitiveType, T[] vert
// Setup the vertex declaration to point at the VB data.
vertexDeclaration.GraphicsDevice = this;
- vertexDeclaration.Apply(_vertexShader, vbHandle.AddrOfPinnedObject());
+ var programHash = _vertexShader.HashKey | _pixelShader.HashKey;
+ vertexDeclaration.Apply(_vertexShader, vbHandle.AddrOfPinnedObject(), programHash);
//Draw
GL.DrawArrays(PrimitiveTypeGL(primitiveType),
@@ -983,7 +990,8 @@ private void PlatformDrawPrimitives(PrimitiveType primitiveType, int vertexStart
{
ApplyState(true);
- _vertexBuffers.Get(0).VertexBuffer.VertexDeclaration.Apply(_vertexShader, IntPtr.Zero);
+ var programHash = _vertexShader.HashKey | _pixelShader.HashKey;
+ _vertexBuffers.Get(0).VertexBuffer.VertexDeclaration.Apply(_vertexShader, IntPtr.Zero, programHash);
GL.DrawArrays(PrimitiveTypeGL(primitiveType),
vertexStart,
@@ -1010,7 +1018,8 @@ private void PlatformDrawUserIndexedPrimitives(PrimitiveType primitiveType, T
// Setup the vertex declaration to point at the VB data.
vertexDeclaration.GraphicsDevice = this;
- vertexDeclaration.Apply(_vertexShader, vertexAddr);
+ var programHash = _vertexShader.HashKey | _pixelShader.HashKey;
+ vertexDeclaration.Apply(_vertexShader, vertexAddr, programHash);
//Draw
GL.DrawElements( PrimitiveTypeGL(primitiveType),
@@ -1043,7 +1052,8 @@ private void PlatformDrawUserIndexedPrimitives(PrimitiveType primitiveType, T
// Setup the vertex declaration to point at the VB data.
vertexDeclaration.GraphicsDevice = this;
- vertexDeclaration.Apply(_vertexShader, vertexAddr);
+ var programHash = _vertexShader.HashKey | _pixelShader.HashKey;
+ vertexDeclaration.Apply(_vertexShader, vertexAddr, programHash);
//Draw
GL.DrawElements( PrimitiveTypeGL(primitiveType),
diff --git a/MonoGame.Framework/Graphics/GraphicsDevice.Web.cs b/MonoGame.Framework/Graphics/GraphicsDevice.Web.cs
index 3e3cb7212bb..776d73af19d 100644
--- a/MonoGame.Framework/Graphics/GraphicsDevice.Web.cs
+++ b/MonoGame.Framework/Graphics/GraphicsDevice.Web.cs
@@ -67,7 +67,7 @@ internal void PlatformBeginApplyState()
{
}
- private void PlatformApplyBlendFactor()
+ private void PlatformApplyBlend()
{
}
diff --git a/MonoGame.Framework/Graphics/GraphicsDevice.cs b/MonoGame.Framework/Graphics/GraphicsDevice.cs
index 375503dc9d5..f26d86277e1 100644
--- a/MonoGame.Framework/Graphics/GraphicsDevice.cs
+++ b/MonoGame.Framework/Graphics/GraphicsDevice.cs
@@ -13,7 +13,6 @@ namespace Microsoft.Xna.Framework.Graphics
public partial class GraphicsDevice : IDisposable
{
private Viewport _viewport;
- private GraphicsProfile _graphicsProfile;
private bool _isDisposed;
@@ -122,15 +121,6 @@ private bool PixelShaderDirty
public event EventHandler ResourceDestroyed;
public event EventHandler Disposing;
- private bool SuppressEventHandlerWarningsUntilEventsAreProperlyImplemented()
- {
- return
- DeviceLost != null &&
- ResourceCreated != null &&
- ResourceDestroyed != null &&
- Disposing != null;
- }
-
private int _maxVertexBufferSlots;
internal int MaxTextureSlots;
internal int MaxVertexTextureSlots;
@@ -159,6 +149,16 @@ internal bool IsRenderTargetBound
}
}
+ internal DepthFormat ActiveDepthFormat
+ {
+ get
+ {
+ return IsRenderTargetBound
+ ? _currentRenderTargetBindings[0].DepthFormat
+ : PresentationParameters.DepthStencilFormat;
+ }
+ }
+
public GraphicsAdapter Adapter
{
get;
@@ -174,14 +174,8 @@ public GraphicsAdapter Adapter
public GraphicsMetrics Metrics { get { return _graphicsMetrics; } set { _graphicsMetrics = value; } }
internal GraphicsDevice(GraphicsDeviceInformation gdi)
+ : this(gdi.Adapter, gdi.GraphicsProfile, gdi.PresentationParameters)
{
- if (gdi.PresentationParameters == null)
- throw new ArgumentNullException("presentationParameters");
- PresentationParameters = gdi.PresentationParameters;
- Setup();
- GraphicsCapabilities = new GraphicsCapabilities(this);
- GraphicsProfile = gdi.GraphicsProfile;
- Initialize();
}
internal GraphicsDevice ()
@@ -189,7 +183,8 @@ internal GraphicsDevice ()
PresentationParameters = new PresentationParameters();
PresentationParameters.DepthStencilFormat = DepthFormat.Depth24;
Setup();
- GraphicsCapabilities = new GraphicsCapabilities(this);
+ GraphicsCapabilities = new GraphicsCapabilities();
+ GraphicsCapabilities.Initialize(this);
Initialize();
}
@@ -204,13 +199,23 @@ internal GraphicsDevice ()
///
public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)
{
- Adapter = adapter;
+ if (adapter == null)
+ throw new ArgumentNullException("adapter");
+#if DIRECTX
+ if (!adapter.IsProfileSupported(graphicsProfile))
+ throw new NoSuitableGraphicsDeviceException(String.Format("Adapter '{0}' does not support the {1} profile.", adapter.Description, graphicsProfile));
+#else
+ if (!adapter.IsProfileSupported(graphicsProfile))
+ throw new NoSuitableGraphicsDeviceException(String.Format("Adapter does not support the {1} profile.", graphicsProfile));
+#endif
if (presentationParameters == null)
throw new ArgumentNullException("presentationParameters");
+ Adapter = adapter;
PresentationParameters = presentationParameters;
+ _graphicsProfile = graphicsProfile;
Setup();
- GraphicsCapabilities = new GraphicsCapabilities(this);
- GraphicsProfile = graphicsProfile;
+ GraphicsCapabilities = new GraphicsCapabilities();
+ GraphicsCapabilities.Initialize(this);
Initialize();
}
@@ -269,6 +274,7 @@ private void Setup()
internal void Initialize()
{
PlatformInitialize();
+ GraphicsCapabilities.InitializeAfterResources(this);
// Force set the default render states.
_blendStateDirty = _depthStencilStateDirty = _rasterizerStateDirty = true;
@@ -434,17 +440,7 @@ internal void ApplyState(bool applyShaders)
{
PlatformBeginApplyState();
- if (_blendStateDirty)
- {
- _actualBlendState.PlatformApplyState(this);
- _blendStateDirty = false;
- }
-
- if (_blendFactorDirty)
- {
- PlatformApplyBlendFactor();
- _blendFactorDirty = false;
- }
+ PlatformApplyBlend();
if (_depthStencilStateDirty)
{
@@ -525,6 +521,9 @@ protected virtual void Dispose(bool disposing)
}
_isDisposed = true;
+
+ if (Disposing != null)
+ Disposing(this, EventArgs.Empty);
}
}
@@ -546,6 +545,10 @@ internal void RemoveResourceReference(WeakReference resourceReference)
public void Present()
{
+ // We cannot present with a RT set on the device.
+ if (_currentRenderTargetCount != 0)
+ throw new InvalidOperationException("Cannot call Present when a render target is active.");
+
_graphicsMetrics = new GraphicsMetrics();
PlatformPresent();
}
@@ -555,22 +558,44 @@ public void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle,
{
throw new NotImplementedException();
}
+ */
+#if WINDOWS && DIRECTX
public void Reset()
{
- // Manually resetting the device is not currently supported.
- throw new NotImplementedException();
+ if (DeviceResetting != null)
+ DeviceResetting(this, EventArgs.Empty);
+
+ // Update the back buffer.
+ OnPresentationChanged();
+
+ if (DeviceReset != null)
+ DeviceReset(this, EventArgs.Empty);
+
+ if (DeviceLost != null)
+ DeviceLost(this, EventArgs.Empty);
}
- */
-#if WINDOWS && DIRECTX
public void Reset(PresentationParameters presentationParameters)
{
+ if (presentationParameters == null)
+ throw new ArgumentNullException("presentationParameters");
+ if (presentationParameters.DeviceWindowHandle == IntPtr.Zero)
+ throw new ArgumentException("PresentationParameters.DeviceWindowHandle must not be null.");
+
PresentationParameters = presentationParameters;
+ Reset();
+ }
+#else
+ // TODO: implement these
+ public void Reset()
+ {
+
+ }
+
+ public void Reset(PresentationParameters presentationParameters)
+ {
- // Update the back buffer.
- CreateSizeDependentResources();
- ApplyRenderTargets(null);
}
#endif
@@ -650,22 +675,10 @@ public Viewport Viewport
}
}
+ private readonly GraphicsProfile _graphicsProfile;
public GraphicsProfile GraphicsProfile
{
- get
- {
- return _graphicsProfile;
- }
- internal set
- {
- //Check if Profile is supported.
- //TODO: [DirectX] Recreate the Device using the new
- // feature level each time the Profile changes.
- if(value > GetHighestSupportedGraphicsProfile(this))
- throw new NotSupportedException(String.Format("Could not find a graphics device that supports the {0} profile", value.ToString()));
- _graphicsProfile = value;
- GraphicsCapabilities.Initialize(this);
- }
+ get { return _graphicsProfile; }
}
public Rectangle ScissorRectangle
@@ -763,7 +776,7 @@ public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
{
unchecked
{
- _graphicsMetrics._targetCount += (ulong)renderTargetCount;
+ _graphicsMetrics._targetCount += renderTargetCount;
}
}
}
@@ -938,6 +951,13 @@ public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, i
DrawIndexedPrimitives(primitiveType, baseVertex, startIndex, primitiveCount);
}
+ ///
+ /// Draw geometry by indexing into the vertex buffer.
+ ///
+ /// The type of primitives in the index buffer.
+ /// Used to offset the vertex range indexed from the vertex buffer.
+ /// The index within the index buffer to start drawing from.
+ /// The number of primitives to render from the index buffer.
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int startIndex, int primitiveCount)
{
if (_vertexShader == null)
@@ -957,15 +977,34 @@ public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, i
unchecked
{
_graphicsMetrics._drawCount++;
- _graphicsMetrics._primitiveCount += (ulong)primitiveCount;
+ _graphicsMetrics._primitiveCount += primitiveCount;
}
}
+ ///
+ /// Draw primitives of the specified type from the data in an array of vertices without indexing.
+ ///
+ /// The type of the vertices.
+ /// The type of primitives to draw with the vertices.
+ /// An array of vertices to draw.
+ /// The index in the array of the first vertex that should be rendered.
+ /// The number of primitives to draw.
+ /// The will be found by getting
+ /// from an instance of and cached for subsequent calls.
public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount) where T : struct, IVertexType
{
DrawUserPrimitives(primitiveType, vertexData, vertexOffset, primitiveCount, VertexDeclarationCache.VertexDeclaration);
}
+ ///
+ /// Draw primitives of the specified type from the data in the given array of vertices without indexing.
+ ///
+ /// The type of the vertices.
+ /// The type of primitives to draw with the vertices.
+ /// An array of vertices to draw.
+ /// The index in the array of the first vertex that should be rendered.
+ /// The number of primitives to draw.
+ /// The layout of the vertices.
public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct
{
if (vertexData == null)
@@ -993,10 +1032,16 @@ public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, i
unchecked
{
_graphicsMetrics._drawCount++;
- _graphicsMetrics._primitiveCount += (ulong) primitiveCount;
+ _graphicsMetrics._primitiveCount += primitiveCount;
}
}
+ ///
+ /// Draw primitives of the specified type from the currently bound vertexbuffers without indexing.
+ ///
+ /// The type of primitives to draw.
+ /// Index of the vertex to start at.
+ /// The number of primitives to draw.
public void DrawPrimitives(PrimitiveType primitiveType, int vertexStart, int primitiveCount)
{
if (_vertexShader == null)
@@ -1015,15 +1060,46 @@ public void DrawPrimitives(PrimitiveType primitiveType, int vertexStart, int pri
unchecked
{
_graphicsMetrics._drawCount++;
- _graphicsMetrics._primitiveCount += (ulong) primitiveCount;
+ _graphicsMetrics._primitiveCount += primitiveCount;
}
}
+ ///
+ /// Draw primitives of the specified type by indexing into the given array of vertices with 16-bit indices.
+ ///
+ /// The type of the vertices.
+ /// The type of primitives to draw with the vertices.
+ /// An array of vertices to draw.
+ /// The index in the array of the first vertex to draw.
+ /// The index in the array of indices of the first index to use
+ /// The number of primitives to draw.
+ /// The number of vertices to draw.
+ /// The index data.
+ /// The will be found by getting
+ /// from an instance of and cached for subsequent calls.
+ /// All indices in the vertex buffer are interpreted relative to the specified .
+ /// For example a value of zero in the array of indices points to the vertex at index
+ /// in the array of vertices.
public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, short[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
{
DrawUserIndexedPrimitives(primitiveType, vertexData, vertexOffset, numVertices, indexData, indexOffset, primitiveCount, VertexDeclarationCache.VertexDeclaration);
}
+ ///
+ /// Draw primitives of the specified type by indexing into the given array of vertices with 16-bit indices.
+ ///
+ /// The type of the vertices.
+ /// The type of primitives to draw with the vertices.
+ /// An array of vertices to draw.
+ /// The index in the array of the first vertex to draw.
+ /// The index in the array of indices of the first index to use
+ /// The number of primitives to draw.
+ /// The number of vertices to draw.
+ /// The index data.
+ /// The layout of the vertices.
+ /// All indices in the vertex buffer are interpreted relative to the specified .
+ /// For example a value of zero in the array of indices points to the vertex at index
+ /// in the array of vertices.
public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, short[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct
{
// These parameter checks are a duplicate of the checks in the int[] overload of DrawUserIndexedPrimitives.
@@ -1061,15 +1137,46 @@ public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, T[] vertex
unchecked
{
_graphicsMetrics._drawCount++;
- _graphicsMetrics._primitiveCount += (ulong) primitiveCount;
+ _graphicsMetrics._primitiveCount += primitiveCount;
}
}
+ ///
+ /// Draw primitives of the specified type by indexing into the given array of vertices with 32-bit indices.
+ ///
+ /// The type of the vertices.
+ /// The type of primitives to draw with the vertices.
+ /// An array of vertices to draw.
+ /// The index in the array of the first vertex to draw.
+ /// The index in the array of indices of the first index to use
+ /// The number of primitives to draw.
+ /// The number of vertices to draw.
+ /// The index data.
+ /// The will be found by getting
+ /// from an instance of and cached for subsequent calls.
+ /// All indices in the vertex buffer are interpreted relative to the specified .
+ /// For example a value of zero in the array of indices points to the vertex at index
+ /// in the array of vertices.
public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, int[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
{
DrawUserIndexedPrimitives(primitiveType, vertexData, vertexOffset, numVertices, indexData, indexOffset, primitiveCount, VertexDeclarationCache.VertexDeclaration);
}
+ ///
+ /// Draw primitives of the specified type by indexing into the given array of vertices with 32-bit indices.
+ ///
+ /// The type of the vertices.
+ /// The type of primitives to draw with the vertices.
+ /// An array of vertices to draw.
+ /// The index in the array of the first vertex to draw.
+ /// The index in the array of indices of the first index to use
+ /// The number of primitives to draw.
+ /// The number of vertices to draw.
+ /// The index data.
+ /// The layout of the vertices.
+ /// All indices in the vertex buffer are interpreted relative to the specified .
+ /// For example value of zero in the array of indices points to the vertex at index
+ /// in the array of vertices.
public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, int[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct
{
// These parameter checks are a duplicate of the checks in the short[] overload of DrawUserIndexedPrimitives.
@@ -1107,12 +1214,38 @@ public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, T[] vertex
unchecked
{
_graphicsMetrics._drawCount++;
- _graphicsMetrics._primitiveCount += (ulong) primitiveCount;
+ _graphicsMetrics._primitiveCount += primitiveCount;
}
}
+ ///
+ /// Draw instanced geometry from the bound vertex buffers and index buffer.
+ ///
+ /// The type of primitives in the index buffer.
+ /// Used to offset the vertex range indexed from the vertex buffer.
+ /// This is unused and remains here only for XNA API compatibility.
+ /// This is unused and remains here only for XNA API compatibility.
+ /// The index within the index buffer to start drawing from.
+ /// The number of primitives in a single instance.
+ /// The number of instances to render.
+ /// Note that minVertexIndex and numVertices are unused in MonoGame and will be ignored.
+ [Obsolete("Use DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int startIndex, int primitiveCount, int instanceCount) instead. In future versions this method can be removed.")]
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex,
int numVertices, int startIndex, int primitiveCount, int instanceCount)
+ {
+ DrawInstancedPrimitives(primitiveType, baseVertex, startIndex, primitiveCount, instanceCount);
+ }
+
+ ///
+ /// Draw instanced geometry from the bound vertex buffers and index buffer.
+ ///
+ /// The type of primitives in the index buffer.
+ /// Used to offset the vertex range indexed from the vertex buffer.
+ /// The index within the index buffer to start drawing from.
+ /// The number of primitives in a single instance.
+ /// The number of instances to render.
+ /// Draw geometry with data from multiple bound vertex streams at different frequencies.
+ public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int startIndex, int primitiveCount, int instanceCount)
{
if (_vertexShader == null)
throw new InvalidOperationException("Vertex shader must be set before calling DrawInstancedPrimitives.");
@@ -1131,7 +1264,7 @@ public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex,
unchecked
{
_graphicsMetrics._drawCount++;
- _graphicsMetrics._primitiveCount += (ulong)(primitiveCount * instanceCount);
+ _graphicsMetrics._primitiveCount += (primitiveCount * instanceCount);
}
}
diff --git a/MonoGame.Framework/Graphics/GraphicsExtensions.cs b/MonoGame.Framework/Graphics/GraphicsExtensions.cs
index 26a76932ba1..93e3af223af 100644
--- a/MonoGame.Framework/Graphics/GraphicsExtensions.cs
+++ b/MonoGame.Framework/Graphics/GraphicsExtensions.cs
@@ -747,7 +747,7 @@ internal static void GetGLFormat (this SurfaceFormat format,
#endif // OPENGL
- public static int GetFrameLatency(this PresentInterval interval)
+ public static int GetSyncInterval(this PresentInterval interval)
{
switch (interval)
{
diff --git a/MonoGame.Framework/Graphics/GraphicsMetrics.cs b/MonoGame.Framework/Graphics/GraphicsMetrics.cs
index 44820c3df9a..feb30f34ef3 100644
--- a/MonoGame.Framework/Graphics/GraphicsMetrics.cs
+++ b/MonoGame.Framework/Graphics/GraphicsMetrics.cs
@@ -9,54 +9,54 @@ namespace Microsoft.Xna.Framework.Graphics
///
public struct GraphicsMetrics
{
- internal ulong _clearCount;
- internal ulong _drawCount;
- internal ulong _pixelShaderCount;
- internal ulong _primitiveCount;
- internal ulong _spriteCount;
- internal ulong _targetCount;
- internal ulong _textureCount;
- internal ulong _vertexShaderCount;
+ internal long _clearCount;
+ internal long _drawCount;
+ internal long _pixelShaderCount;
+ internal long _primitiveCount;
+ internal long _spriteCount;
+ internal long _targetCount;
+ internal long _textureCount;
+ internal long _vertexShaderCount;
///
/// Number of times Clear was called.
///
- public ulong ClearCount { get { return _clearCount; } }
+ public long ClearCount { get { return _clearCount; } }
///
/// Number of times Draw was called.
///
- public ulong DrawCount { get { return _drawCount; } }
+ public long DrawCount { get { return _drawCount; } }
///
/// Number of times the pixel shader was changed on the GPU.
///
- public ulong PixelShaderCount { get { return _pixelShaderCount; } }
+ public long PixelShaderCount { get { return _pixelShaderCount; } }
///
/// Number of rendered primitives.
///
- public ulong PrimitiveCount { get { return _primitiveCount; } }
+ public long PrimitiveCount { get { return _primitiveCount; } }
///
/// Number of sprites and text characters rendered via .
///
- public ulong SpriteCount { get { return _spriteCount; } }
+ public long SpriteCount { get { return _spriteCount; } }
///
/// Number of times a target was changed on the GPU.
///
- public ulong TargetCount {get { return _targetCount; } }
+ public long TargetCount {get { return _targetCount; } }
///
/// Number of times a texture was changed on the GPU.
///
- public ulong TextureCount { get { return _textureCount; } }
+ public long TextureCount { get { return _textureCount; } }
///
/// Number of times the vertex shader was changed on the GPU.
///
- public ulong VertexShaderCount { get { return _vertexShaderCount; } }
+ public long VertexShaderCount { get { return _vertexShaderCount; } }
///
/// Returns the difference between two sets of metrics.
diff --git a/MonoGame.Framework/Graphics/ModelMesh.cs b/MonoGame.Framework/Graphics/ModelMesh.cs
index 3673f9f2fa1..dfec491709f 100644
--- a/MonoGame.Framework/Graphics/ModelMesh.cs
+++ b/MonoGame.Framework/Graphics/ModelMesh.cs
@@ -84,7 +84,7 @@ public void Draw()
for (int j = 0; j < effect.CurrentTechnique.Passes.Count; j++)
{
effect.CurrentTechnique.Passes[j].Apply ();
- this.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, part.VertexOffset, 0, part.NumVertices, part.StartIndex, part.PrimitiveCount);
+ graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, part.VertexOffset, part.StartIndex, part.PrimitiveCount);
}
}
}
diff --git a/MonoGame.Framework/Graphics/ModelMeshPart.cs b/MonoGame.Framework/Graphics/ModelMeshPart.cs
index 7cf1fb2f42e..337c253021a 100644
--- a/MonoGame.Framework/Graphics/ModelMeshPart.cs
+++ b/MonoGame.Framework/Graphics/ModelMeshPart.cs
@@ -38,7 +38,9 @@ public Effect Effect
// Set the new effect.
_effect = value;
- parent.Effects.Add(value);
+
+ if (_effect != null && !parent.Effects.Contains(_effect))
+ parent.Effects.Add(_effect);
}
}
diff --git a/MonoGame.Framework/Graphics/RenderTargetBinding.cs b/MonoGame.Framework/Graphics/RenderTargetBinding.cs
index 8c6e292c415..f1ec91dfbaa 100644
--- a/MonoGame.Framework/Graphics/RenderTargetBinding.cs
+++ b/MonoGame.Framework/Graphics/RenderTargetBinding.cs
@@ -49,6 +49,7 @@ public struct RenderTargetBinding
{
private readonly Texture _renderTarget;
private readonly int _arraySlice;
+ private DepthFormat _depthFormat;
public Texture RenderTarget
{
@@ -60,6 +61,11 @@ public int ArraySlice
get { return _arraySlice; }
}
+ internal DepthFormat DepthFormat
+ {
+ get { return _depthFormat; }
+ }
+
public RenderTargetBinding(RenderTarget2D renderTarget)
{
if (renderTarget == null)
@@ -67,6 +73,7 @@ public RenderTargetBinding(RenderTarget2D renderTarget)
_renderTarget = renderTarget;
_arraySlice = (int)CubeMapFace.PositiveX;
+ _depthFormat = renderTarget.DepthStencilFormat;
}
public RenderTargetBinding(RenderTargetCube renderTarget, CubeMapFace cubeMapFace)
@@ -78,6 +85,7 @@ public RenderTargetBinding(RenderTargetCube renderTarget, CubeMapFace cubeMapFac
_renderTarget = renderTarget;
_arraySlice = (int)cubeMapFace;
+ _depthFormat = renderTarget.DepthStencilFormat;
}
#if DIRECTX
@@ -93,6 +101,7 @@ public RenderTargetBinding(RenderTarget2D renderTarget, int arraySlice)
_renderTarget = renderTarget;
_arraySlice = arraySlice;
+ _depthFormat = renderTarget.DepthStencilFormat;
}
public RenderTargetBinding(RenderTarget3D renderTarget)
@@ -102,6 +111,7 @@ public RenderTargetBinding(RenderTarget3D renderTarget)
_renderTarget = renderTarget;
_arraySlice = 0;
+ _depthFormat = renderTarget.DepthStencilFormat;
}
public RenderTargetBinding(RenderTarget3D renderTarget, int arraySlice)
@@ -113,6 +123,7 @@ public RenderTargetBinding(RenderTarget3D renderTarget, int arraySlice)
_renderTarget = renderTarget;
_arraySlice = arraySlice;
+ _depthFormat = renderTarget.DepthStencilFormat;
}
#endif
diff --git a/MonoGame.Framework/Graphics/RenderTargetCube.cs b/MonoGame.Framework/Graphics/RenderTargetCube.cs
index 5f2e34c511c..e10fab5c499 100644
--- a/MonoGame.Framework/Graphics/RenderTargetCube.cs
+++ b/MonoGame.Framework/Graphics/RenderTargetCube.cs
@@ -2,6 +2,8 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
+using System;
+
namespace Microsoft.Xna.Framework.Graphics
{
///
@@ -39,6 +41,9 @@ int IRenderTarget.Height
get { return size; }
}
+ public bool IsContentLost { get { return false; } }
+ public event EventHandler ContentLost;
+
///
/// Initializes a new instance of the class.
///
diff --git a/MonoGame.Framework/Graphics/SpriteBatcher.cs b/MonoGame.Framework/Graphics/SpriteBatcher.cs
index fb6eb5ffab3..0ad0333ec77 100644
--- a/MonoGame.Framework/Graphics/SpriteBatcher.cs
+++ b/MonoGame.Framework/Graphics/SpriteBatcher.cs
@@ -170,7 +170,7 @@ public unsafe void DrawBatch(SpriteSortMode sortMode, Effect effect)
unchecked
{
- _device._graphicsMetrics._spriteCount += (ulong)batchCount;
+ _device._graphicsMetrics._spriteCount += batchCount;
}
// Iterate through the batches, doing short.MaxValue sets of vertices only.
diff --git a/MonoGame.Framework/Graphics/SpriteFont.cs b/MonoGame.Framework/Graphics/SpriteFont.cs
index 4dc7d924e26..d10025fdc88 100644
--- a/MonoGame.Framework/Graphics/SpriteFont.cs
+++ b/MonoGame.Framework/Graphics/SpriteFont.cs
@@ -1,70 +1,6 @@
-#region License
-/*
-Microsoft Public License (Ms-PL)
-MonoGame - Copyright © 2009-2012 The MonoGame Team
-
-All rights reserved.
-
-This license governs use of the accompanying software. If you use the software,
-you accept this license. If you do not accept the license, do not use the
-software.
-
-1. Definitions
-
-The terms "reproduce," "reproduction," "derivative works," and "distribution"
-have the same meaning here as under U.S. copyright law.
-
-A "contribution" is the original software, or any additions or changes to the
-software.
-
-A "contributor" is any person that distributes its contribution under this
-license.
-
-"Licensed patents" are a contributor's patent claims that read directly on its
-contribution.
-
-2. Grant of Rights
-
-(A) Copyright Grant- Subject to the terms of this license, including the
-license conditions and limitations in section 3, each contributor grants you a
-non-exclusive, worldwide, royalty-free copyright license to reproduce its
-contribution, prepare derivative works of its contribution, and distribute its
-contribution or any derivative works that you create.
-
-(B) Patent Grant- Subject to the terms of this license, including the license
-conditions and limitations in section 3, each contributor grants you a
-non-exclusive, worldwide, royalty-free license under its licensed patents to
-make, have made, use, sell, offer for sale, import, and/or otherwise dispose of
-its contribution in the software or derivative works of the contribution in the
-software.
-
-3. Conditions and Limitations
-
-(A) No Trademark License- This license does not grant you rights to use any
-contributors' name, logo, or trademarks.
-
-(B) If you bring a patent claim against any contributor over patents that you
-claim are infringed by the software, your patent license from such contributor
-to the software ends automatically.
-
-(C) If you distribute any portion of the software, you must retain all
-copyright, patent, trademark, and attribution notices that are present in the
-software.
-
-(D) If you distribute any portion of the software in source code form, you may
-do so only under this license by including a complete copy of this license with
-your distribution. If you distribute any portion of the software in compiled or
-object code form, you may only do so under a license that complies with this
-license.
-
-(E) The software is licensed "as-is." You bear the risk of using it. The
-contributors give no express warranties, guarantees or conditions. You may have
-additional consumer rights under your local laws which this license cannot
-change. To the extent permitted under your local laws, the contributors exclude
-the implied warranties of merchantability, fitness for a particular purpose and
-non-infringement.
-*/
-#endregion License
+// MonoGame - Copyright (C) The MonoGame Team
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE.txt', which is part of this source code package.
// Original code from SilverSprite Project
using System;
@@ -297,19 +233,37 @@ internal void DrawInto( SpriteBatch spriteBatch, ref CharacterSource text, Vecto
}
}
- // TODO: This looks excessive... i suspect we could do most
- // of this with simple vector math and avoid this much matrix work.
-
- Matrix transformation, temp;
- Matrix.CreateTranslation(-origin.X, -origin.Y, 0f, out transformation);
- Matrix.CreateScale((flippedHorz ? -scale.X : scale.X), (flippedVert ? -scale.Y : scale.Y), 1f, out temp);
- Matrix.Multiply(ref transformation, ref temp, out transformation);
- Matrix.CreateTranslation(flipAdjustment.X, flipAdjustment.Y, 0, out temp);
- Matrix.Multiply(ref temp, ref transformation, out transformation);
- Matrix.CreateRotationZ(rotation, out temp);
- Matrix.Multiply(ref transformation, ref temp, out transformation);
- Matrix.CreateTranslation(position.X, position.Y, 0f, out temp);
- Matrix.Multiply(ref transformation, ref temp, out transformation);
+ // OPTIMIZED
+ //Matrix transformation, temp;
+ //Matrix.CreateTranslation(-origin.X, -origin.Y, 0f, out transformation);
+ //Matrix.CreateScale((flippedHorz ? -scale.X : scale.X), (flippedVert ? -scale.Y : scale.Y), 1f, out temp);
+ //Matrix.Multiply(ref transformation, ref temp, out transformation);
+ //Matrix.CreateTranslation(flipAdjustment.X, flipAdjustment.Y, 0, out temp);
+ //Matrix.Multiply(ref temp, ref transformation, out transformation);
+ //Matrix.CreateRotationZ(rotation, out temp);
+ //Matrix.Multiply(ref transformation, ref temp, out transformation);
+ //Matrix.CreateTranslation(position.X, position.Y, 0f, out temp);
+ //Matrix.Multiply(ref transformation, ref temp, out transformation);
+
+ Matrix transformation = Matrix.Identity;
+ if (rotation == 0)
+ {
+ transformation.M11 = (flippedHorz ? -scale.X : scale.X);
+ transformation.M22 = (flippedVert ? -scale.Y : scale.Y);
+ transformation.M41 = ((flipAdjustment.X - origin.X) * transformation.M11) + position.X;
+ transformation.M42 = ((flipAdjustment.Y - origin.Y) * transformation.M22) + position.Y;
+ }
+ else
+ {
+ var cos = (float)Math.Cos(rotation);
+ var sin = (float)Math.Sin(rotation);
+ transformation.M11 = (flippedHorz ? -scale.X : scale.X) * cos;
+ transformation.M12 = (flippedHorz ? -scale.X : scale.X) * sin;
+ transformation.M21 = (flippedVert ? -scale.Y : scale.Y) * (-sin);
+ transformation.M22 = (flippedVert ? -scale.Y : scale.Y) * cos;
+ transformation.M41 = (((flipAdjustment.X - origin.X) * transformation.M11) + (flipAdjustment.Y - origin.Y) * transformation.M21) + position.X;
+ transformation.M42 = (((flipAdjustment.X - origin.X) * transformation.M12) + (flipAdjustment.Y - origin.Y) * transformation.M22) + position.Y;
+ }
// Get the default glyph here once.
Glyph? defaultGlyph = null;
diff --git a/MonoGame.Framework/Graphics/States/Blend.cs b/MonoGame.Framework/Graphics/States/Blend.cs
index afa58a65933..dd1e02bac85 100644
--- a/MonoGame.Framework/Graphics/States/Blend.cs
+++ b/MonoGame.Framework/Graphics/States/Blend.cs
@@ -58,11 +58,11 @@ public enum Blend
///
InverseDestinationAlpha,
///
- /// Each component of the color is multiplied by a constant in the .
+ /// Each component of the color is multiplied by a constant in the .
///
BlendFactor,
///
- /// Each component of the color is multiplied by a inversed constant in the .
+ /// Each component of the color is multiplied by a inversed constant in the .
///
InverseBlendFactor,
///
diff --git a/MonoGame.Framework/Graphics/States/BlendState.DirectX.cs b/MonoGame.Framework/Graphics/States/BlendState.DirectX.cs
index 10c60a95cfa..4bb95386d8b 100644
--- a/MonoGame.Framework/Graphics/States/BlendState.DirectX.cs
+++ b/MonoGame.Framework/Graphics/States/BlendState.DirectX.cs
@@ -8,7 +8,7 @@ namespace Microsoft.Xna.Framework.Graphics
{
public partial class BlendState
{
- SharpDX.Direct3D11.BlendState _state;
+ private SharpDX.Direct3D11.BlendState _state;
protected internal override void GraphicsDeviceResetting()
{
@@ -16,7 +16,7 @@ protected internal override void GraphicsDeviceResetting()
base.GraphicsDeviceResetting();
}
- internal void PlatformApplyState(GraphicsDevice device)
+ internal SharpDX.Direct3D11.BlendState GetDxState(GraphicsDevice device)
{
if (_state == null)
{
@@ -38,11 +38,8 @@ internal void PlatformApplyState(GraphicsDevice device)
Debug.Assert(GraphicsDevice == device, "The state was created for a different device!");
- // NOTE: We make the assumption here that the caller has
- // locked the d3dContext for us to use.
-
// Apply the state!
- device._d3dContext.OutputMerger.BlendState = _state;
+ return _state;
}
protected override void Dispose(bool disposing)
diff --git a/MonoGame.Framework/Graphics/States/BlendState.cs b/MonoGame.Framework/Graphics/States/BlendState.cs
index 7e4cd950509..401af5c49aa 100644
--- a/MonoGame.Framework/Graphics/States/BlendState.cs
+++ b/MonoGame.Framework/Graphics/States/BlendState.cs
@@ -149,7 +149,7 @@ public ColorWriteChannels ColorWriteChannels3
/// The color used as blend factor when alpha blending.
///
///
- /// is set to this value when this
+ /// is set to this value when this
/// is bound to a GraphicsDevice.
///
public Color BlendFactor
diff --git a/MonoGame.Framework/Graphics/States/RasterizerState.DirectX.cs b/MonoGame.Framework/Graphics/States/RasterizerState.DirectX.cs
index daeb41c4d02..bf4313a7e2e 100644
--- a/MonoGame.Framework/Graphics/States/RasterizerState.DirectX.cs
+++ b/MonoGame.Framework/Graphics/States/RasterizerState.DirectX.cs
@@ -2,6 +2,7 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
+using System;
using System.Diagnostics;
namespace Microsoft.Xna.Framework.Graphics
@@ -40,7 +41,26 @@ internal void PlatformApplyState(GraphicsDevice device)
desc.IsScissorEnabled = ScissorTestEnable;
desc.IsMultisampleEnabled = MultiSampleAntiAlias;
- desc.DepthBias = (int)DepthBias;
+
+ // discussion and explanation in https://github.com/MonoGame/MonoGame/issues/4826
+ int depthMul;
+ switch (device.ActiveDepthFormat)
+ {
+ case DepthFormat.None:
+ depthMul = 0;
+ break;
+ case DepthFormat.Depth16:
+ depthMul = 1 << 16 - 1;
+ break;
+ case DepthFormat.Depth24:
+ case DepthFormat.Depth24Stencil8:
+ depthMul = 1 << 24 - 1;
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ desc.DepthBias = (int) (DepthBias * depthMul);
desc.SlopeScaledDepthBias = SlopeScaleDepthBias;
if (FillMode == Graphics.FillMode.WireFrame)
diff --git a/MonoGame.Framework/Graphics/SwapChainRenderTarget.cs b/MonoGame.Framework/Graphics/SwapChainRenderTarget.cs
index b7d3c5bcfe3..15afd0e1ad3 100644
--- a/MonoGame.Framework/Graphics/SwapChainRenderTarget.cs
+++ b/MonoGame.Framework/Graphics/SwapChainRenderTarget.cs
@@ -156,7 +156,7 @@ public void Present()
{
try
{
- _swapChain.Present(PresentInterval.GetFrameLatency(), PresentFlags.None);
+ _swapChain.Present(PresentInterval.GetSyncInterval(), PresentFlags.None);
}
catch (SharpDX.SharpDXException)
{
diff --git a/MonoGame.Framework/Graphics/Texture2D.DirectX.cs b/MonoGame.Framework/Graphics/Texture2D.DirectX.cs
index 4e229550718..87ce9c7378a 100644
--- a/MonoGame.Framework/Graphics/Texture2D.DirectX.cs
+++ b/MonoGame.Framework/Graphics/Texture2D.DirectX.cs
@@ -41,7 +41,7 @@ private void PlatformConstruct(int width, int height, bool mipmap, SurfaceFormat
private void PlatformSetData(int level, int arraySlice, Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
{
- var elementSizeInByte = Marshal.SizeOf(typeof(T));
+ var elementSizeInByte = Utilities.ReflectionHelpers.SizeOf.Get();
var dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
// Use try..finally to make sure dataHandle is freed in case of an error
try
@@ -167,7 +167,7 @@ private void PlatformGetData(int level, int arraySlice, Rectangle? rect, T[]
// We need to copy each row separatly and skip trailing zeros.
stream.Seek(0, SeekOrigin.Begin);
- int elementSizeInByte = Marshal.SizeOf(typeof(T));
+ int elementSizeInByte = Utilities.ReflectionHelpers.SizeOf.Get();
for (var row = 0; row < rows; row++)
{
int i;
@@ -322,7 +322,6 @@ private void SaveAsImage(Guid encoderId, Stream stream, int width, int height)
#endif
#if !WINDOWS_PHONE
- [CLSCompliant(false)]
static SharpDX.Direct3D11.Texture2D CreateTex2DFromBitmap(SharpDX.WIC.BitmapSource bsource, GraphicsDevice device)
{
diff --git a/MonoGame.Framework/Graphics/Texture2D.cs b/MonoGame.Framework/Graphics/Texture2D.cs
index 805f21616dc..a0a00bb31d4 100644
--- a/MonoGame.Framework/Graphics/Texture2D.cs
+++ b/MonoGame.Framework/Graphics/Texture2D.cs
@@ -84,9 +84,11 @@ internal Texture2D(GraphicsDevice graphicsDevice, int width, int height, bool mi
protected Texture2D(GraphicsDevice graphicsDevice, int width, int height, bool mipmap, SurfaceFormat format, SurfaceType type, bool shared, int arraySize)
{
if (graphicsDevice == null)
- {
throw new ArgumentNullException("graphicsDevice", FrameworkResources.ResourceCreationWhenDeviceIsNull);
- }
+ if (width <= 0)
+ throw new ArgumentOutOfRangeException("width","Texture width must be greater than zero");
+ if (height <= 0)
+ throw new ArgumentOutOfRangeException("height","Texture height must be greater than zero");
if (arraySize > 1 && !graphicsDevice.GraphicsCapabilities.SupportsTextureArrays)
throw new ArgumentException("Texture arrays are not supported on this graphics device", "arraySize");
diff --git a/MonoGame.Framework/Graphics/Texture3D.DirectX.cs b/MonoGame.Framework/Graphics/Texture3D.DirectX.cs
index 37f46d559de..def4187d44b 100644
--- a/MonoGame.Framework/Graphics/Texture3D.DirectX.cs
+++ b/MonoGame.Framework/Graphics/Texture3D.DirectX.cs
@@ -7,7 +7,6 @@
using System.Runtime.InteropServices;
using SharpDX;
using SharpDX.Direct3D11;
-using SharpDX.DXGI;
using MapFlags = SharpDX.Direct3D11.MapFlags;
namespace Microsoft.Xna.Framework.Graphics
@@ -16,7 +15,6 @@ public partial class Texture3D : Texture
{
private bool renderTarget;
private bool mipMap;
- private SampleDescription _sampleDescription;
private void PlatformConstruct(GraphicsDevice graphicsDevice, int width, int height, int depth, bool mipMap, SurfaceFormat format, bool renderTarget)
{
@@ -65,7 +63,7 @@ private void PlatformSetData(int level,
int left, int top, int right, int bottom, int front, int back,
T[] data, int startIndex, int elementCount, int width, int height, int depth)
{
- var elementSizeInByte = Marshal.SizeOf(typeof(T));
+ var elementSizeInByte = Utilities.ReflectionHelpers.SizeOf.Get();
var dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
diff --git a/MonoGame.Framework/Graphics/Texture3D.cs b/MonoGame.Framework/Graphics/Texture3D.cs
index 0f29f8f1ec0..f5fb9d39ff5 100644
--- a/MonoGame.Framework/Graphics/Texture3D.cs
+++ b/MonoGame.Framework/Graphics/Texture3D.cs
@@ -37,9 +37,14 @@ public Texture3D(GraphicsDevice graphicsDevice, int width, int height, int depth
protected Texture3D (GraphicsDevice graphicsDevice, int width, int height, int depth, bool mipMap, SurfaceFormat format, bool renderTarget)
{
if (graphicsDevice == null)
- {
throw new ArgumentNullException("graphicsDevice", FrameworkResources.ResourceCreationWhenDeviceIsNull);
- }
+ if (width <= 0)
+ throw new ArgumentOutOfRangeException("width","Texture width must be greater than zero");
+ if (height <= 0)
+ throw new ArgumentOutOfRangeException("height","Texture height must be greater than zero");
+ if (depth <= 0)
+ throw new ArgumentOutOfRangeException("depth","Texture depth must be greater than zero");
+
this.GraphicsDevice = graphicsDevice;
this._width = width;
this._height = height;
diff --git a/MonoGame.Framework/Graphics/TextureCube.DirectX.cs b/MonoGame.Framework/Graphics/TextureCube.DirectX.cs
index 40594edcf2b..1c260fab631 100644
--- a/MonoGame.Framework/Graphics/TextureCube.DirectX.cs
+++ b/MonoGame.Framework/Graphics/TextureCube.DirectX.cs
@@ -102,7 +102,7 @@ private void PlatformGetData(CubeMapFace cubeMapFace, T[] data) where T : str
// We need to copy each row separatly and skip trailing zeros.
stream.Seek(startIndex, SeekOrigin.Begin);
- int elementSizeInByte = Marshal.SizeOf(typeof(T));
+ int elementSizeInByte = Utilities.ReflectionHelpers.SizeOf.Get();
for (var row = 0; row < rows; row++)
{
int i;
diff --git a/MonoGame.Framework/Graphics/TextureCube.cs b/MonoGame.Framework/Graphics/TextureCube.cs
index e3852824a44..f2af5814e1b 100644
--- a/MonoGame.Framework/Graphics/TextureCube.cs
+++ b/MonoGame.Framework/Graphics/TextureCube.cs
@@ -31,9 +31,10 @@ public TextureCube (GraphicsDevice graphicsDevice, int size, bool mipMap, Surfac
internal TextureCube(GraphicsDevice graphicsDevice, int size, bool mipMap, SurfaceFormat format, bool renderTarget)
{
if (graphicsDevice == null)
- {
throw new ArgumentNullException("graphicsDevice", FrameworkResources.ResourceCreationWhenDeviceIsNull);
- }
+ if (size <= 0)
+ throw new ArgumentOutOfRangeException("size","Cube size must be greater than zero");
+
this.GraphicsDevice = graphicsDevice;
this.size = size;
this._format = format;
@@ -68,8 +69,8 @@ public void SetData(CubeMapFace face, int level, Rectangle? rect, T[] data, i
if (data == null)
throw new ArgumentNullException("data");
- var elementSizeInByte = Marshal.SizeOf(typeof(T));
- var dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
+ var elementSizeInByte = Utilities.ReflectionHelpers.SizeOf.Get();
+ var dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
// Use try..finally to make sure dataHandle is freed in case of an error
try
{
diff --git a/MonoGame.Framework/Graphics/Vertices/DynamicVertexBuffer.cs b/MonoGame.Framework/Graphics/Vertices/DynamicVertexBuffer.cs
index 4005391a15f..9f7c9f7726e 100644
--- a/MonoGame.Framework/Graphics/Vertices/DynamicVertexBuffer.cs
+++ b/MonoGame.Framework/Graphics/Vertices/DynamicVertexBuffer.cs
@@ -33,7 +33,7 @@ public void SetData(int offsetInBytes, T[] data, int startIndex, int elementC
public void SetData(T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
{
- var elementSizeInBytes = Marshal.SizeOf(typeof(T));
+ var elementSizeInBytes = Utilities.ReflectionHelpers.SizeOf.Get();
base.SetDataInternal(0, data, startIndex, elementCount, elementSizeInBytes, options);
}
}
diff --git a/MonoGame.Framework/Graphics/Vertices/IndexBuffer.DirectX.cs b/MonoGame.Framework/Graphics/Vertices/IndexBuffer.DirectX.cs
index 72da3e920b6..0be24a59750 100644
--- a/MonoGame.Framework/Graphics/Vertices/IndexBuffer.DirectX.cs
+++ b/MonoGame.Framework/Graphics/Vertices/IndexBuffer.DirectX.cs
@@ -131,7 +131,7 @@ private void PlatformSetDataInternal(int offsetInBytes, T[] data, int startIn
}
else
{
- var elementSizeInBytes = Marshal.SizeOf(typeof(T));
+ var elementSizeInBytes = Utilities.ReflectionHelpers.SizeOf.Get();
var dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
diff --git a/MonoGame.Framework/Graphics/Vertices/IndexBuffer.cs b/MonoGame.Framework/Graphics/Vertices/IndexBuffer.cs
index cadd1a397cf..ee23fd304c9 100644
--- a/MonoGame.Framework/Graphics/Vertices/IndexBuffer.cs
+++ b/MonoGame.Framework/Graphics/Vertices/IndexBuffer.cs
@@ -54,7 +54,7 @@ public IndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount
/// The IndexElementSize enum value that matches the type
static IndexElementSize SizeForType(GraphicsDevice graphicsDevice, Type type)
{
- switch (Marshal.SizeOf(type))
+ switch (Utilities.ReflectionHelpers.ManagedSizeOf(type))
{
case 2:
return IndexElementSize.SixteenBits;
diff --git a/MonoGame.Framework/Graphics/Vertices/VertexBuffer.cs b/MonoGame.Framework/Graphics/Vertices/VertexBuffer.cs
index 87f0bffaf9d..f3f7bb86270 100644
--- a/MonoGame.Framework/Graphics/Vertices/VertexBuffer.cs
+++ b/MonoGame.Framework/Graphics/Vertices/VertexBuffer.cs
@@ -55,7 +55,7 @@ internal protected override void GraphicsDeviceResetting()
public void GetData (int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride) where T : struct
{
- var elementSizeInBytes = Marshal.SizeOf(typeof(T));
+ var elementSizeInBytes = Utilities.ReflectionHelpers.SizeOf.Get();
if (vertexStride == 0)
vertexStride = elementSizeInBytes;
@@ -74,13 +74,13 @@ public void GetData (int offsetInBytes, T[] data, int startIndex, int element
public void GetData(T[] data, int startIndex, int elementCount) where T : struct
{
- var elementSizeInByte = Marshal.SizeOf(typeof(T));
+ var elementSizeInByte = Utilities.ReflectionHelpers.SizeOf.Get();
this.GetData(0, data, startIndex, elementCount, elementSizeInByte);
}
public void GetData(T[] data) where T : struct
{
- var elementSizeInByte = Marshal.SizeOf(typeof(T));
+ var elementSizeInByte = Utilities.ReflectionHelpers.SizeOf.Get();
this.GetData(0, data, 0, data.Length, elementSizeInByte);
}
@@ -146,7 +146,7 @@ public void SetData(int offsetInBytes, T[] data, int startIndex, int elementC
/// must be within the array bounds.
public void SetData(T[] data, int startIndex, int elementCount) where T : struct
{
- var elementSizeInBytes = Marshal.SizeOf(typeof(T));
+ var elementSizeInBytes = Utilities.ReflectionHelpers.SizeOf.Get();
SetDataInternal(0, data, startIndex, elementCount, elementSizeInBytes, SetDataOptions.None);
}
@@ -159,7 +159,7 @@ public void SetData(T[] data, int startIndex, int elementCount) where T : str
/// Data array.
public void SetData(T[] data) where T : struct
{
- var elementSizeInBytes = Marshal.SizeOf(typeof(T));
+ var elementSizeInBytes = Utilities.ReflectionHelpers.SizeOf.Get();
SetDataInternal(0, data, 0, data.Length, elementSizeInBytes, SetDataOptions.None);
}
@@ -168,7 +168,7 @@ protected void SetDataInternal(int offsetInBytes, T[] data, int startIndex, i
if (data == null)
throw new ArgumentNullException("data");
- var elementSizeInBytes = Marshal.SizeOf(typeof(T));
+ var elementSizeInBytes = Utilities.ReflectionHelpers.SizeOf.Get();
var bufferSize = VertexCount * VertexDeclaration.VertexStride;
if (vertexStride == 0)
diff --git a/MonoGame.Framework/Graphics/Vertices/VertexDeclaration.OpenGL.cs b/MonoGame.Framework/Graphics/Vertices/VertexDeclaration.OpenGL.cs
index bc89bf9d813..f16f4ed77d4 100644
--- a/MonoGame.Framework/Graphics/Vertices/VertexDeclaration.OpenGL.cs
+++ b/MonoGame.Framework/Graphics/Vertices/VertexDeclaration.OpenGL.cs
@@ -24,11 +24,10 @@ public partial class VertexDeclaration
{
Dictionary shaderAttributeInfo = new Dictionary();
- internal void Apply(Shader shader, IntPtr offset)
+ internal void Apply(Shader shader, IntPtr offset, int programHash)
{
VertexDeclarationAttributeInfo attrInfo;
- int shaderHash = shader.GetHashCode();
- if (!shaderAttributeInfo.TryGetValue(shaderHash, out attrInfo))
+ if (!shaderAttributeInfo.TryGetValue(programHash, out attrInfo))
{
// Get the vertex attribute info and cache it
attrInfo = new VertexDeclarationAttributeInfo(GraphicsDevice.MaxVertexAttributes);
@@ -51,7 +50,7 @@ internal void Apply(Shader shader, IntPtr offset)
}
}
- shaderAttributeInfo.Add(shaderHash, attrInfo);
+ shaderAttributeInfo.Add(programHash, attrInfo);
}
// Apply the vertex attribute info
diff --git a/MonoGame.Framework/GraphicsDeviceManager.cs b/MonoGame.Framework/GraphicsDeviceManager.cs
index 354430d69bd..c294d1abbff 100644
--- a/MonoGame.Framework/GraphicsDeviceManager.cs
+++ b/MonoGame.Framework/GraphicsDeviceManager.cs
@@ -15,6 +15,8 @@ public partial class GraphicsDeviceManager : IGraphicsDeviceService, IDisposable
{
private readonly Game _game;
private GraphicsDevice _graphicsDevice;
+ private bool _initialized = false;
+
private int _preferredBackBufferHeight;
private int _preferredBackBufferWidth;
private SurfaceFormat _preferredBackBufferFormat;
@@ -26,6 +28,9 @@ public partial class GraphicsDeviceManager : IGraphicsDeviceService, IDisposable
private bool _disposed;
private bool _hardwareModeSwitch = true;
private bool _wantFullScreen;
+ private GraphicsProfile _graphicsProfile;
+ // dirty flag for ApplyChanges
+ private bool _shouldApplyChanges;
///
/// The default back buffer width.
@@ -94,14 +99,18 @@ public GraphicsDeviceManager(Game game)
Dispose(false);
}
- public void CreateDevice()
+ private void CreateDevice()
{
if (_graphicsDevice != null)
return;
try
{
- Initialize();
+ if (!_initialized)
+ Initialize();
+
+ var gdi = DoPreparingDeviceSettings();
+ CreateDevice(gdi);
}
catch (NoSuitableGraphicsDeviceException)
{
@@ -111,10 +120,31 @@ public void CreateDevice()
{
throw new NoSuitableGraphicsDeviceException("Failed to create graphics device!", ex);
}
+ }
+
+ private void CreateDevice(GraphicsDeviceInformation gdi)
+ {
+ if (_graphicsDevice != null)
+ return;
+
+ _graphicsDevice = new GraphicsDevice(gdi);
+ _shouldApplyChanges = false;
+
+ // hook up reset events
+ GraphicsDevice.DeviceReset += (sender, args) => OnDeviceReset(args);
+ GraphicsDevice.DeviceResetting += (sender, args) => OnDeviceResetting(args);
+
+ // update the touchpanel display size when the graphicsdevice is reset
+ _graphicsDevice.DeviceReset += UpdateTouchPanel;
OnDeviceCreated(EventArgs.Empty);
}
+ void IGraphicsDeviceManager.CreateDevice()
+ {
+ CreateDevice();
+ }
+
public bool BeginDraw()
{
if (_graphicsDevice == null)
@@ -140,35 +170,70 @@ public void EndDraw()
public event EventHandler DeviceReset;
public event EventHandler DeviceResetting;
public event EventHandler PreparingDeviceSettings;
+ public event EventHandler Disposed;
- // FIXME: Why does the GraphicsDeviceManager not know enough about the
- // GraphicsDevice to raise these events without help?
- internal void OnDeviceDisposing(EventArgs e)
+ protected void OnDeviceDisposing(EventArgs e)
{
Raise(DeviceDisposing, e);
}
- // FIXME: Why does the GraphicsDeviceManager not know enough about the
- // GraphicsDevice to raise these events without help?
- internal void OnDeviceResetting(EventArgs e)
+ protected void OnDeviceResetting(EventArgs e)
{
Raise(DeviceResetting, e);
}
- // FIXME: Why does the GraphicsDeviceManager not know enough about the
- // GraphicsDevice to raise these events without help?
internal void OnDeviceReset(EventArgs e)
{
Raise(DeviceReset, e);
}
- // FIXME: Why does the GraphicsDeviceManager not know enough about the
- // GraphicsDevice to raise these events without help?
internal void OnDeviceCreated(EventArgs e)
{
Raise(DeviceCreated, e);
}
+ ///
+ /// This populates a GraphicsDeviceInformation instance and invokes PreparingDeviceSettings to
+ /// allow users to change the settings. Then returns that GraphicsDeviceInformation.
+ /// Throws NullReferenceException if users set GraphicsDeviceInformation.PresentationParameters to null.
+ ///
+ private GraphicsDeviceInformation DoPreparingDeviceSettings()
+ {
+ var gdi = new GraphicsDeviceInformation();
+ PrepareGraphicsDeviceInformation(gdi);
+
+ if (PreparingDeviceSettings != null)
+ {
+ // this allows users to overwrite settings through the argument
+ var args = new PreparingDeviceSettingsEventArgs(gdi);
+ PreparingDeviceSettings(this, args);
+
+ if (gdi.PresentationParameters == null || gdi.Adapter == null)
+ throw new NullReferenceException("Members should not be set to null in PreparingDeviceSettingsEventArgs");
+
+ if (gdi.PresentationParameters.MultiSampleCount > 0)
+ {
+ // Round down MultiSampleCount to the nearest power of two
+ // hack from http://stackoverflow.com/a/2681094
+ var msc = gdi.PresentationParameters.MultiSampleCount;
+ msc = msc | (msc >> 1);
+ msc = msc | (msc >> 2);
+ msc = msc | (msc >> 4);
+
+ if (GraphicsDevice != null)
+ {
+ // and clamp it to what the device can handle
+ if (msc > GraphicsDevice.GraphicsCapabilities.MaxMultiSampleCount)
+ msc = GraphicsDevice.GraphicsCapabilities.MaxMultiSampleCount;
+ }
+
+ gdi.PresentationParameters.MultiSampleCount = msc - (msc >> 1);
+ }
+ }
+
+ return gdi;
+ }
+
private void Raise(EventHandler handler, TEventArgs e)
where TEventArgs : EventArgs
{
@@ -199,6 +264,8 @@ protected virtual void Dispose(bool disposing)
}
}
_disposed = true;
+ if (Disposed != null)
+ Disposed(this, EventArgs.Empty);
}
}
@@ -219,18 +286,12 @@ private void PreparePresentationParameters(PresentationParameters presentationPa
if (_preferMultiSampling)
{
- if (_graphicsDevice == null)
- {
- // We can't determine the multisampling level by calling PlatformSetMultiSamplingToMaximum yet.
- // Once the device initializes, it will call CreateSizeDependentResources which will perform
- // a call to PlatformSetMultiSamplingToMaximum.
- presentationParameters.MultiSampleCount = 32;
- }
- else
- {
- int quality;
- _graphicsDevice.PlatformSetMultiSamplingToMaximum(presentationParameters, out quality);
- }
+ // always initialize MultiSampleCount to the maximum, if users want to overwrite
+ // this they have to respond to the PreparingDeviceSettingsEvent and modify
+ // args.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount
+ presentationParameters.MultiSampleCount = GraphicsDevice != null
+ ? GraphicsDevice.GraphicsCapabilities.MaxMultiSampleCount
+ : 32;
}
else
{
@@ -238,6 +299,15 @@ private void PreparePresentationParameters(PresentationParameters presentationPa
}
}
+ private void PrepareGraphicsDeviceInformation(GraphicsDeviceInformation gdi)
+ {
+ gdi.Adapter = GraphicsAdapter.DefaultAdapter;
+ gdi.GraphicsProfile = GraphicsProfile;
+ var pp = new PresentationParameters();
+ PreparePresentationParameters(pp);
+ gdi.PresentationParameters = pp;
+ }
+
///
/// Applies any pending property changes to the graphics device.
///
@@ -247,28 +317,42 @@ public void ApplyChanges()
if (_graphicsDevice == null)
CreateDevice();
- _game.Window.SetSupportedOrientations(_supportedOrientations);
-
- PreparePresentationParameters(_graphicsDevice.PresentationParameters);
+ if (!_shouldApplyChanges)
+ return;
- // TODO: Should this trigger some sort of device reset?
- _graphicsDevice.GraphicsProfile = GraphicsProfile;
+ _game.Window.SetSupportedOrientations(_supportedOrientations);
// Allow for optional platform specific behavior.
PlatformApplyChanges();
- // Update the graphics device and then the platform window.
- _graphicsDevice.OnPresentationChanged();
+ // populates a gdi with settings in this gdm and allows users to override them with
+ // PrepareDeviceSettings event this information should be applied to the GraphicsDevice
+ var gdi = DoPreparingDeviceSettings();
+
+ if (gdi.GraphicsProfile != GraphicsDevice.GraphicsProfile)
+ {
+ // if the GraphicsProfile changed we need to create a new GraphicsDevice
+ DisposeGraphicsDevice();
+ CreateDevice(gdi);
+ return;
+ }
+
+ GraphicsDevice.Reset(gdi.PresentationParameters);
+
+ // Update the platform window.
_game.Platform.OnPresentationChanged();
- // Set the new display size on the touch panel.
- //
- // TODO: In XNA this seems to be done as part of the
- // GraphicsDevice.DeviceReset event... we need to get
- // those working.
- //
- TouchPanel.DisplayWidth = _graphicsDevice.PresentationParameters.BackBufferWidth;
- TouchPanel.DisplayHeight = _graphicsDevice.PresentationParameters.BackBufferHeight;
+ _shouldApplyChanges = false;
+ }
+
+ private void DisposeGraphicsDevice()
+ {
+ _graphicsDevice.Dispose();
+
+ if (DeviceDisposing != null)
+ DeviceDisposing(this, EventArgs.Empty);
+
+ _graphicsDevice = null;
}
partial void PlatformInitialize(PresentationParameters presentationParameters);
@@ -283,28 +367,11 @@ private void Initialize()
// Allow for any per-platform changes to the presentation.
PlatformInitialize(presentationParameters);
- // TODO: Implement multisampling (aka anti-alising) for all platforms!
- if (PreparingDeviceSettings != null)
- {
- var gdi = new GraphicsDeviceInformation();
- gdi.GraphicsProfile = GraphicsProfile; // Microsoft defaults this to Reach.
- gdi.Adapter = GraphicsAdapter.DefaultAdapter;
- gdi.PresentationParameters = presentationParameters;
- var pe = new PreparingDeviceSettingsEventArgs(gdi);
- PreparingDeviceSettings(this, pe);
- presentationParameters = pe.GraphicsDeviceInformation.PresentationParameters;
- GraphicsProfile = pe.GraphicsDeviceInformation.GraphicsProfile;
- }
-
- // Create and initialize the graphics device.
- _graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile, presentationParameters);
+ _initialized = true;
+ }
- // Set the new display size on the touch panel.
- //
- // TODO: In XNA this seems to be done as part of the
- // GraphicsDevice.DeviceReset event... we need to get
- // those working.
- //
+ private void UpdateTouchPanel(object sender, EventArgs eventArgs)
+ {
TouchPanel.DisplayWidth = _graphicsDevice.PresentationParameters.BackBufferWidth;
TouchPanel.DisplayHeight = _graphicsDevice.PresentationParameters.BackBufferHeight;
TouchPanel.DisplayOrientation = _graphicsDevice.PresentationParameters.DisplayOrientation;
@@ -325,7 +392,18 @@ public void ToggleFullScreen()
///
/// The profile which determines the graphics feature level.
///
- public GraphicsProfile GraphicsProfile { get; set; }
+ public GraphicsProfile GraphicsProfile
+ {
+ get
+ {
+ return _graphicsProfile;
+ }
+ set
+ {
+ _shouldApplyChanges = true;
+ _graphicsProfile = value;
+ }
+ }
///
/// Returns the graphics device for this manager.
@@ -351,6 +429,7 @@ public bool IsFullScreen
get { return _wantFullScreen; }
set
{
+ _shouldApplyChanges = true;
_wantFullScreen = value;
}
}
@@ -365,6 +444,7 @@ public bool HardwareModeSwitch
get { return _hardwareModeSwitch;}
set
{
+ _shouldApplyChanges = true;
_hardwareModeSwitch = value;
}
}
@@ -384,6 +464,7 @@ public bool PreferMultiSampling
}
set
{
+ _shouldApplyChanges = true;
_preferMultiSampling = value;
}
}
@@ -403,6 +484,7 @@ public SurfaceFormat PreferredBackBufferFormat
}
set
{
+ _shouldApplyChanges = true;
_preferredBackBufferFormat = value;
}
}
@@ -422,6 +504,7 @@ public int PreferredBackBufferHeight
}
set
{
+ _shouldApplyChanges = true;
_preferredBackBufferHeight = value;
}
}
@@ -441,6 +524,7 @@ public int PreferredBackBufferWidth
}
set
{
+ _shouldApplyChanges = true;
_preferredBackBufferWidth = value;
}
}
@@ -461,6 +545,7 @@ public DepthFormat PreferredDepthStencilFormat
}
set
{
+ _shouldApplyChanges = true;
_preferredDepthStencilFormat = value;
}
}
@@ -481,6 +566,7 @@ public bool SynchronizeWithVerticalRetrace
}
set
{
+ _shouldApplyChanges = true;
_synchronizedWithVerticalRetrace = value;
}
}
@@ -501,6 +587,7 @@ public DisplayOrientation SupportedOrientations
}
set
{
+ _shouldApplyChanges = true;
_supportedOrientations = value;
}
}
diff --git a/MonoGame.Framework/Input/GamePad.Ouya.cs b/MonoGame.Framework/Input/GamePad.Ouya.cs
deleted file mode 100644
index 7ca7f90064d..00000000000
--- a/MonoGame.Framework/Input/GamePad.Ouya.cs
+++ /dev/null
@@ -1,377 +0,0 @@
-#region License
-/*
-Microsoft Public License (Ms-PL)
-MonoGame - Copyright � 2009 The MonoGame Team
-
-All rights reserved.
-
-This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
-accept the license, do not use the software.
-
-1. Definitions
-The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
-U.S. copyright law.
-
-A "contribution" is the original software, or any additions or changes to the software.
-A "contributor" is any person that distributes its contribution under this license.
-"Licensed patents" are a contributor's patent claims that read directly on its contribution.
-
-2. Grant of Rights
-(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
-each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
-(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
-each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
-
-3. Conditions and Limitations
-(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
-(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
-your patent license from such contributor to the software ends automatically.
-(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
-notices that are present in the software.
-(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
-a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
-code form, you may only do so under a license that complies with this license.
-(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
-or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
-permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
-purpose and non-infringement.
-*/
-#endregion License
-
-using Android.Views;
-using System;
-using System.Diagnostics;
-using Ouya.Console.Api;
-
-namespace Microsoft.Xna.Framework.Input
-{
- internal class OuyaGamePad
- {
- public InputDevice _device;
- public int _deviceId;
- public string _descriptor;
- public bool _isConnected;
-
- public Buttons _buttons;
- public float _leftTrigger, _rightTrigger;
- public Vector2 _leftStick, _rightStick;
-
- // Workaround for the OnKeyUp and OnKeyDown events for KeyCode.Menu
- // both being sent in a single frame. This can be removed if the
- // OUYA firmware is updated to send these events in different frames.
- public bool _startButtonPressed;
-
- public readonly GamePadCapabilities _capabilities;
-
- public OuyaGamePad(InputDevice device)
- {
- _device = device;
- _deviceId = device.Id;
- _descriptor = device.Descriptor;
- _isConnected = true;
-
- _capabilities = CapabilitiesOfDevice(device);
- }
-
- private static GamePadCapabilities CapabilitiesOfDevice(InputDevice device)
- {
- //TODO: There is probably a better way to do this. Maybe device.GetMotionRange and device.GetKeyCharacterMap?
- //Or not http://stackoverflow.com/questions/11686703/android-enumerating-the-buttons-on-a-gamepad
-
- var capabilities = new GamePadCapabilities();
- capabilities.IsConnected = true;
- capabilities.GamePadType = GamePadType.GamePad;
- capabilities.HasLeftVibrationMotor = capabilities.HasRightVibrationMotor = device.Vibrator.HasVibrator;
-
- switch (device.Name)
- {
- case "OUYA Game Controller":
-
- capabilities.HasAButton = true;
- capabilities.HasBButton = true;
- capabilities.HasXButton = true;
- capabilities.HasYButton = true;
-
- capabilities.HasLeftXThumbStick = true;
- capabilities.HasLeftYThumbStick = true;
- capabilities.HasRightXThumbStick = true;
- capabilities.HasRightYThumbStick = true;
-
- capabilities.HasLeftShoulderButton = true;
- capabilities.HasRightShoulderButton = true;
- capabilities.HasLeftTrigger = true;
- capabilities.HasRightTrigger = true;
-
- capabilities.HasDPadDownButton = true;
- capabilities.HasDPadLeftButton = true;
- capabilities.HasDPadRightButton = true;
- capabilities.HasDPadUpButton = true;
- break;
-
- case "Microsoft X-Box 360 pad":
- capabilities.HasAButton = true;
- capabilities.HasBButton = true;
- capabilities.HasXButton = true;
- capabilities.HasYButton = true;
-
- capabilities.HasLeftXThumbStick = true;
- capabilities.HasLeftYThumbStick = true;
- capabilities.HasRightXThumbStick = true;
- capabilities.HasRightYThumbStick = true;
-
- capabilities.HasLeftShoulderButton = true;
- capabilities.HasRightShoulderButton = true;
- capabilities.HasLeftTrigger = true;
- capabilities.HasRightTrigger = true;
-
- capabilities.HasDPadDownButton = true;
- capabilities.HasDPadLeftButton = true;
- capabilities.HasDPadRightButton = true;
- capabilities.HasDPadUpButton = true;
-
- capabilities.HasStartButton = true;
- capabilities.HasBackButton = true;
- break;
- }
- return capabilities;
- }
- }
-
-
- static partial class GamePad
- {
- private static readonly OuyaGamePad[] GamePads = new OuyaGamePad[OuyaController.MaxControllers];
-
- private static int PlatformGetMaxNumberOfGamePads()
- {
- return 4;
- }
-
- private static GamePadCapabilities PlatformGetCapabilities(int index)
- {
- var gamePad = GamePads[index];
- if (gamePad != null)
- return gamePad._capabilities;
-
- GamePadCapabilities capabilities = new GamePadCapabilities();
- capabilities.IsConnected = false;
- capabilities.HasAButton = true;
- capabilities.HasBButton = true;
- capabilities.HasXButton = true;
- capabilities.HasYButton = true;
- capabilities.HasBackButton = true;
- capabilities.HasLeftXThumbStick = true;
- capabilities.HasLeftYThumbStick = true;
- capabilities.HasRightXThumbStick = true;
- capabilities.HasRightYThumbStick = true;
-
- return capabilities;
- }
-
- private static GamePadState PlatformGetState(int index, GamePadDeadZone deadZoneMode)
- {
- var gamePad = GamePads[index];
- GamePadState state = GamePadState.Default;
- if (gamePad != null && gamePad._isConnected)
- {
- // Check if the device was disconnected
- var dvc = InputDevice.GetDevice(gamePad._deviceId);
- if (dvc == null)
- {
- Debug.WriteLine("Detected controller disconnect [" + index + "] ");
- gamePad._isConnected = false;
- return state;
- }
-
- GamePadThumbSticks thumbSticks = new GamePadThumbSticks(gamePad._leftStick, gamePad._rightStick, deadZoneMode);
-
- if (gamePad._startButtonPressed)
- {
- gamePad._buttons |= Buttons.Start;
- gamePad._startButtonPressed = false;
- }
- else
- {
- gamePad._buttons &= ~Buttons.Start;
- }
-
- state = new GamePadState(
- thumbSticks,
- new GamePadTriggers(gamePad._leftTrigger, gamePad._rightTrigger),
- new GamePadButtons(gamePad._buttons),
- new GamePadDPad(gamePad._buttons));
- }
-
- return state;
- }
-
- private static bool PlatformSetVibration(int index, float leftMotor, float rightMotor)
- {
- var gamePad = GamePads[index];
- if (gamePad == null)
- return false;
-
- var vibrator = gamePad._device.Vibrator;
- if (!vibrator.HasVibrator)
- return false;
- vibrator.Vibrate(500);
- return true;
- }
-
- internal static OuyaGamePad GetGamePad(InputDevice device)
- {
- if (device == null || (device.Sources & InputSourceType.Gamepad) != InputSourceType.Gamepad)
- return null;
-
- // The recommended way to map devices to players numbers is to use OuyaController.GetPlayerNumByDeviceId(),
- // however as of ODK 0.0.6 there is a bug where disconnected and reconnected controllers get mapped
- // to new player numbers. Also, the player number returned does not match the LED on the controller.
- // Once this is fixed, we could consider using OuyaController.GetPlayerNumByDeviceId()
- // http://forums.ouya.tv/discussion/819/getplayernumbydeviceid-can-return-1-after-controllers-disconnect-and-reconnect
-
- int firstDisconnectedPadId = -1;
- for (int i = 0; i < GamePads.Length; i++)
- {
- var pad = GamePads[i];
- if (pad != null && pad._isConnected && pad._deviceId == device.Id)
- {
- return pad;
- }
- else if (pad != null && !pad._isConnected && pad._descriptor == device.Descriptor)
- {
- Debug.WriteLine("Found previous controller [" + i + "] " + device.Name);
- pad._deviceId = device.Id;
- pad._isConnected = true;
- return pad;
- }
- else if (pad == null)
- {
- Debug.WriteLine("Found new controller [" + i + "] " + device.Name);
- pad = new OuyaGamePad(device);
- GamePads[i] = pad;
- return pad;
- }
- else if (!pad._isConnected && firstDisconnectedPadId < 0)
- {
- firstDisconnectedPadId = i;
- }
- }
-
- // If we get here, we failed to find a game pad or an empty slot to create one.
- // If we're holding onto a disconnected pad, overwrite it with this one
- if (firstDisconnectedPadId >= 0)
- {
- Debug.WriteLine("Found new controller in place of disconnected controller [" + firstDisconnectedPadId + "] " + device.Name);
- var pad = new OuyaGamePad(device);
- GamePads[firstDisconnectedPadId] = pad;
- return pad;
- }
-
- // All pad slots are taken so ignore further devices.
- return null;
- }
-
- internal static bool OnKeyDown(Keycode keyCode, KeyEvent e)
- {
- var gamePad = GetGamePad(e.Device);
- if (gamePad == null)
- return false;
-
- gamePad._buttons |= ButtonForKeyCode(keyCode);
-
- if (keyCode == Keycode.Menu)
- {
- gamePad._startButtonPressed = true;
- }
- return true;
- }
-
- internal static bool OnKeyUp(Keycode keyCode, KeyEvent e)
- {
- var gamePad = GetGamePad(e.Device);
- if (gamePad == null)
- return false;
-
- gamePad._buttons &= ~ButtonForKeyCode(keyCode);
- return true;
- }
-
- internal static bool OnGenericMotionEvent(MotionEvent e)
- {
- var gamePad = GetGamePad(e.Device);
- if (gamePad == null)
- return false;
-
- if (e.Action != MotionEventActions.Move)
- return false;
-
- gamePad._leftStick = new Vector2(e.GetAxisValue(Axis.X), -e.GetAxisValue(Axis.Y));
- gamePad._rightStick = new Vector2(e.GetAxisValue(Axis.Z), -e.GetAxisValue(Axis.Rz));
- gamePad._leftTrigger = e.GetAxisValue(Axis.Ltrigger);
- gamePad._rightTrigger = e.GetAxisValue(Axis.Rtrigger);
-
- return true;
- }
-
- private static Buttons ButtonForKeyCode(Keycode keyCode)
- {
- switch (keyCode)
- {
- case Keycode.ButtonA: //O
- return Buttons.A;
- case Keycode.ButtonX: //U
- return Buttons.X;
- case Keycode.ButtonY: //Y
- return Buttons.Y;
- case Keycode.ButtonB: //A
- return Buttons.B;
-
- case Keycode.ButtonL1:
- return Buttons.LeftShoulder;
- case Keycode.ButtonL2:
- return Buttons.LeftTrigger;
- case Keycode.ButtonR1:
- return Buttons.RightShoulder;
- case Keycode.ButtonR2:
- return Buttons.RightTrigger;
-
- case Keycode.ButtonThumbl:
- return Buttons.LeftStick;
- case Keycode.ButtonThumbr:
- return Buttons.RightStick;
-
- case Keycode.DpadUp:
- return Buttons.DPadUp;
- case Keycode.DpadDown:
- return Buttons.DPadDown;
- case Keycode.DpadLeft:
- return Buttons.DPadLeft;
- case Keycode.DpadRight:
- return Buttons.DPadRight;
-
- // Ouya system button sends Keycode.Menu after a delay if no
- // double tap or hold is detected. It also sends Keycode.Home just
- // before the system menu is opened (but not on dev kit controllers)
- // http://forums.ouya.tv/discussion/comment/6076/#Comment_6076
- case Keycode.Menu:
- case Keycode.ButtonStart:
- return Buttons.Start;
- case Keycode.Home:
- return Buttons.BigButton;
- case Keycode.Back:
- return Buttons.Back;
- }
-
- return 0;
- }
-
- internal static void Initialize()
- {
- //Iterate and 'connect' any detected gamepads
- foreach (var deviceId in InputDevice.GetDeviceIds())
- {
- GetGamePad(InputDevice.GetDevice(deviceId));
- }
- }
- }
-}
diff --git a/MonoGame.Framework/Input/GamePad.XInput.cs b/MonoGame.Framework/Input/GamePad.XInput.cs
index f178520054d..ac41fd26a4a 100644
--- a/MonoGame.Framework/Input/GamePad.XInput.cs
+++ b/MonoGame.Framework/Input/GamePad.XInput.cs
@@ -169,7 +169,7 @@ private static GamePadState PlatformGetState(int index, GamePadDeadZone deadZone
packetNumber = xistate.PacketNumber;
gamepad = xistate.Gamepad;
}
- catch (Exception ex)
+ catch (Exception)
{
}
diff --git a/MonoGame.Framework/Input/GamePadThumbSticks.cs b/MonoGame.Framework/Input/GamePadThumbSticks.cs
index b6adcda5246..50190603ad6 100644
--- a/MonoGame.Framework/Input/GamePadThumbSticks.cs
+++ b/MonoGame.Framework/Input/GamePadThumbSticks.cs
@@ -31,11 +31,6 @@ public Vector2 Right
// Dead zones are slighty different between left and right sticks, this may come from Microsoft usability tests
private const float leftThumbDeadZone = SharpDX.XInput.Gamepad.LeftThumbDeadZone / (float)short.MaxValue;
private const float rightThumbDeadZone = SharpDX.XInput.Gamepad.RightThumbDeadZone / (float)short.MaxValue;
-#elif OUYA
- // OUYA dead zones should
- // They are a bit larger to accomodate OUYA Gamepad (but will also affect Xbox 360 controllers plugged to an OUYA)
- private const float leftThumbDeadZone = 0.3f;
- private const float rightThumbDeadZone = 0.3f;
#else
// Default & SDL Xbox 360 Controller dead zones
// Based on the XInput constants
diff --git a/MonoGame.Framework/Input/Mouse.SDL.cs b/MonoGame.Framework/Input/Mouse.SDL.cs
index 77470d25546..098b7f1efbd 100644
--- a/MonoGame.Framework/Input/Mouse.SDL.cs
+++ b/MonoGame.Framework/Input/Mouse.SDL.cs
@@ -24,19 +24,27 @@ private static MouseState PlatformGetState(GameWindow window)
Sdl.Mouse.GetGlobalState(out x, out y) :
Sdl.Mouse.GetState(out x, out y);
- if (winFlags.HasFlag(Sdl.Window.State.MouseFocus))
+ if ((winFlags & Sdl.Window.State.MouseFocus) != 0)
{
- window.MouseState.LeftButton = (state.HasFlag(Sdl.Mouse.Button.Left)) ? ButtonState.Pressed : ButtonState.Released;
- window.MouseState.MiddleButton = (state.HasFlag(Sdl.Mouse.Button.Middle)) ? ButtonState.Pressed : ButtonState.Released;
- window.MouseState.RightButton = (state.HasFlag(Sdl.Mouse.Button.Right)) ? ButtonState.Pressed : ButtonState.Released;
- window.MouseState.XButton1 = (state.HasFlag(Sdl.Mouse.Button.X1Mask)) ? ButtonState.Pressed : ButtonState.Released;
- window.MouseState.XButton2 = (state.HasFlag(Sdl.Mouse.Button.X2Mask)) ? ButtonState.Pressed : ButtonState.Released;
+ window.MouseState.LeftButton = (state & Sdl.Mouse.Button.Left) != 0 ? ButtonState.Pressed : ButtonState.Released;
+ window.MouseState.MiddleButton = (state & Sdl.Mouse.Button.Middle) != 0 ? ButtonState.Pressed : ButtonState.Released;
+ window.MouseState.RightButton = (state & Sdl.Mouse.Button.Right) != 0 ? ButtonState.Pressed : ButtonState.Released;
+ window.MouseState.XButton1 = (state & Sdl.Mouse.Button.X1Mask) != 0 ? ButtonState.Pressed : ButtonState.Released;
+ window.MouseState.XButton2 = (state & Sdl.Mouse.Button.X2Mask) != 0 ? ButtonState.Pressed : ButtonState.Released;
window.MouseState.ScrollWheelValue = ScrollY;
+ }
+ if (Sdl.Patch > 4)
+ {
var clientBounds = window.ClientBounds;
- window.MouseState.X = x - ((Sdl.Patch > 4) ? clientBounds.X : 0);
- window.MouseState.Y = y - ((Sdl.Patch > 4) ? clientBounds.Y : 0);
+ window.MouseState.X = x - clientBounds.X;
+ window.MouseState.Y = y - clientBounds.Y;
+ }
+ else
+ {
+ window.MouseState.X = x;
+ window.MouseState.Y = y;
}
return window.MouseState;
diff --git a/MonoGame.Framework/Input/Mouse.cs b/MonoGame.Framework/Input/Mouse.cs
index 7635e09b3ee..7254dcea54b 100644
--- a/MonoGame.Framework/Input/Mouse.cs
+++ b/MonoGame.Framework/Input/Mouse.cs
@@ -24,11 +24,10 @@ public static IntPtr WindowHandle
{
return PlatformGetHandle();
}
-#pragma warning disable RECS0029 // Warns about property or indexer setters and event adders or removers that do not use the value parameter
set
-#pragma warning restore RECS0029 // Warns about property or indexer setters and event adders or removers that do not use the value parameter
{
// only for XNA compatibility, yet
+ IntPtr temp = value;
}
}
diff --git a/MonoGame.Framework/Input/MouseState.cs b/MonoGame.Framework/Input/MouseState.cs
index f35a65682a9..0e0b38f5a98 100644
--- a/MonoGame.Framework/Input/MouseState.cs
+++ b/MonoGame.Framework/Input/MouseState.cs
@@ -139,9 +139,8 @@ internal set {
///
public Point Position
{
- get{return new Point(_x,_y);}
+ get { return new Point(_x, _y); }
}
-
///
/// Gets state of the left mouse button.
///
@@ -189,7 +188,7 @@ public ButtonState XButton1 {
get {
return _xButton1;
}
- set {
+ internal set {
_xButton1 = value;
}
}
@@ -201,7 +200,7 @@ public ButtonState XButton2 {
get {
return _xButton2;
}
- set {
+ internal set {
_xButton2 = value;
}
}
diff --git a/MonoGame.Framework/Media/MediaPlayer.WMS.cs b/MonoGame.Framework/Media/MediaPlayer.WMS.cs
index aa23c528d4c..000162ea870 100644
--- a/MonoGame.Framework/Media/MediaPlayer.WMS.cs
+++ b/MonoGame.Framework/Media/MediaPlayer.WMS.cs
@@ -14,6 +14,7 @@ public static partial class MediaPlayer
{
private static MediaSession _session;
private static AudioStreamVolume _volumeController;
+ private static readonly object _volumeLock = new object();
private static PresentationClock _clock;
private static Song _nextSong;
@@ -147,12 +148,15 @@ private static float PlatformGetVolume()
private static void SetChannelVolumes()
{
- if (_volumeController == null)
- return;
+ lock (_volumeLock)
+ {
+ if (_volumeController == null)
+ return;
- float volume = _isMuted ? 0f : _volume;
- for (int i = 0; i < _volumeController.ChannelCount; i++)
- _volumeController.SetChannelVolume(i, volume);
+ float volume = _isMuted ? 0f : _volume;
+ for (int i = 0; i < _volumeController.ChannelCount; i++)
+ _volumeController.SetChannelVolume(i, volume);
+ }
}
private static void PlatformSetVolume(float volume)
@@ -209,10 +213,13 @@ private static void PlayNewSong(Song song, TimeSpan? startPosition)
private static void StartNewSong(Song song, TimeSpan? startPosition)
{
- if (_volumeController != null)
+ lock (_volumeLock)
{
- _volumeController.Dispose();
- _volumeController = null;
+ if (_volumeController != null)
+ {
+ _volumeController.Dispose();
+ _volumeController = null;
+ }
}
_currentSong = song;
@@ -236,9 +243,12 @@ private static void StartSession(Variant startPosition)
private static void OnTopologyReady()
{
- IntPtr volumeObjectPtr;
- MediaFactory.GetService(_session, MediaServiceKeys.StreamVolume, AudioStreamVolumeGuid, out volumeObjectPtr);
- _volumeController = CppObject.FromPointer(volumeObjectPtr);
+ lock (_volumeLock)
+ {
+ IntPtr volumeObjectPtr;
+ MediaFactory.GetService(_session, MediaServiceKeys.StreamVolume, AudioStreamVolumeGuid, out volumeObjectPtr);
+ _volumeController = CppObject.FromPointer(volumeObjectPtr);
+ }
SetChannelVolumes();
diff --git a/MonoGame.Framework/Properties/AssemblyInfo.OUYA.cs b/MonoGame.Framework/Properties/AssemblyInfo.OUYA.cs
deleted file mode 100644
index 2b610d18542..00000000000
--- a/MonoGame.Framework/Properties/AssemblyInfo.OUYA.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-using System.Reflection;
-
-// Specific platform 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("MonoGame for OUYA")]
diff --git a/MonoGame.Framework/SDL/SDL2.cs b/MonoGame.Framework/SDL/SDL2.cs
index d806019aea5..3c1a8fe04bb 100644
--- a/MonoGame.Framework/SDL/SDL2.cs
+++ b/MonoGame.Framework/SDL/SDL2.cs
@@ -252,24 +252,23 @@ public enum EventId : byte
Close,
}
- [Flags]
- public enum State
- {
- Fullscreen = 0x00000001,
- OpenGL = 0x00000002,
- Shown = 0x00000004,
- Hidden = 0x00000008,
- Borderless = 0x00000010,
- Resizable = 0x00000020,
- Minimized = 0x00000040,
- Maximized = 0x00000080,
- Grabbed = 0x00000100,
- InputFocus = 0x00000200,
- MouseFocus = 0x00000400,
- FullscreenDesktop = 0x00001001,
- Foreign = 0x00000800,
- AllowHighDPI = 0x00002000,
- MouseCapture = 0x00004000,
+ public static class State
+ {
+ public const int Fullscreen = 0x00000001;
+ public const int OpenGL = 0x00000002;
+ public const int Shown = 0x00000004;
+ public const int Hidden = 0x00000008;
+ public const int Borderless = 0x00000010;
+ public const int Resizable = 0x00000020;
+ public const int Minimized = 0x00000040;
+ public const int Maximized = 0x00000080;
+ public const int Grabbed = 0x00000100;
+ public const int InputFocus = 0x00000200;
+ public const int MouseFocus = 0x00000400;
+ public const int FullscreenDesktop = 0x00001001;
+ public const int Foreign = 0x00000800;
+ public const int AllowHighDPI = 0x00002000;
+ public const int MouseCapture = 0x00004000;
}
[StructLayout(LayoutKind.Sequential)]
@@ -287,9 +286,9 @@ public struct Event
}
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_CreateWindow")]
- private static extern IntPtr SDL_CreateWindow(string title, int x, int y, int w, int h, State flags);
+ private static extern IntPtr SDL_CreateWindow(string title, int x, int y, int w, int h, int flags);
- public static IntPtr Create(string title, int x, int y, int w, int h, State flags)
+ public static IntPtr Create(string title, int x, int y, int w, int h, int flags)
{
return GetError(SDL_CreateWindow(title, x, y, w, h, flags));
}
@@ -307,7 +306,7 @@ public static int GetDisplayIndex(IntPtr window)
}
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetWindowFlags")]
- public static extern State GetWindowFlags(IntPtr window);
+ public static extern int GetWindowFlags(IntPtr window);
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_SetWindowIcon")]
public static extern void SetIcon(IntPtr window, IntPtr icon);
@@ -322,9 +321,9 @@ public static int GetDisplayIndex(IntPtr window)
public static extern void SetBordered(IntPtr window, int bordered);
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_SetWindowFullscreen")]
- private static extern int SDL_SetWindowFullscreen(IntPtr window, State flags);
+ private static extern int SDL_SetWindowFullscreen(IntPtr window, int flags);
- public static void SetFullscreen(IntPtr window, State flags)
+ public static void SetFullscreen(IntPtr window, int flags)
{
GetError(SDL_SetWindowFullscreen(window, flags));
}
diff --git a/MonoGame.Framework/SDL/SDLGamePlatform.cs b/MonoGame.Framework/SDL/SDLGamePlatform.cs
index 51a62c0110e..3df61041ef9 100644
--- a/MonoGame.Framework/SDL/SDLGamePlatform.cs
+++ b/MonoGame.Framework/SDL/SDLGamePlatform.cs
@@ -46,22 +46,15 @@ public SdlGamePlatform(Game game)
Sdl.Minor = sversion.Minor;
Sdl.Patch = sversion.Patch;
- try
- {
- // HACK: The current development version of SDL
- // returns 2.0.4, to check SDL version we simply
- // need to try and execute a function that's only
- // available in the newer version of it.
- Sdl.Window.SetResizable(IntPtr.Zero, false);
- Sdl.Patch = 5;
- }
- catch { }
-
var version = 100 * Sdl.Major + 10 * Sdl.Minor + Sdl.Patch;
if (version <= 204)
Debug.WriteLine ("Please use SDL 2.0.5 or higher.");
+ // Needed so VS can debug the project on Windows
+ if (version >= 205 && CurrentPlatform.OS == OS.Windows && Debugger.IsAttached)
+ Sdl.SetHint("SDL_WINDOWS_DISABLE_THREAD_NAMING", "1");
+
Sdl.Init((int)(
Sdl.InitFlags.Video |
Sdl.InitFlags.Joystick |
@@ -71,6 +64,7 @@ public SdlGamePlatform(Game game)
Sdl.DisableScreenSaver();
+ GamePad.InitDatabase();
Window = _view = new SdlGameWindow(_game);
try
@@ -85,8 +79,7 @@ public SdlGamePlatform(Game game)
public override void BeforeInitialize ()
{
- GamePad.InitDatabase();
- _view.CreateWindow();
+ _view.InitGraphics();
SdlRunLoop();
base.BeforeInitialize ();
diff --git a/MonoGame.Framework/SDL/SDLGameWindow.cs b/MonoGame.Framework/SDL/SDLGameWindow.cs
index 5b87e2dc443..1aa6aad9ae0 100644
--- a/MonoGame.Framework/SDL/SDLGameWindow.cs
+++ b/MonoGame.Framework/SDL/SDLGameWindow.cs
@@ -17,13 +17,10 @@ public override bool AllowUserResizing
get { return !IsBorderless && _resizable; }
set
{
- if (_init)
- {
- if (Sdl.Patch > 4)
- Sdl.Window.SetResizable(_handle, value);
- else
- throw new Exception("SDL does not support changing resizable parameter of the window after it's already been created.");
- }
+ if (Sdl.Patch > 4)
+ Sdl.Window.SetResizable(_handle, value);
+ else
+ throw new Exception("SDL 2.0.4 does not support changing resizable parameter of the window after it's already been created, please use a newer version of it.");
_resizable = value;
}
@@ -73,7 +70,7 @@ public override bool IsBorderless
get { return _borderless; }
set
{
- Sdl.Window.SetBordered(_handle, value ? 1 : 0);
+ Sdl.Window.SetBordered(_handle, value ? 0 : 1);
_borderless = value;
}
}
@@ -83,7 +80,7 @@ public override bool IsBorderless
internal readonly Game _game;
private IntPtr _handle;
- private bool _init, _disposed;
+ private bool _disposed;
private bool _resizable, _borderless, _willBeFullScreen, _mouseVisible, _hardwareSwitch;
private string _screenDeviceName;
private int _winx, _winy, _width, _height;
@@ -97,6 +94,8 @@ public SdlGameWindow(Game game)
_winx = Sdl.Window.PosUndefined;
_winy = Sdl.Window.PosUndefined;
+ _width = GraphicsDeviceManager.DefaultBackBufferWidth;
+ _height = GraphicsDeviceManager.DefaultBackBufferHeight;
if (Sdl.Patch >= 4)
{
@@ -105,71 +104,19 @@ public SdlGameWindow(Game game)
_winy = display.Y + display.Height / 2;
}
- // We need a dummy handle for GraphicDevice until our window gets created
- _handle = Sdl.Window.Create("", _winx, _winy,
- GraphicsDeviceManager.DefaultBackBufferWidth, GraphicsDeviceManager.DefaultBackBufferHeight,
- Sdl.Window.State.Hidden);
- }
-
- internal void CreateWindow()
- {
- _width = GraphicsDeviceManager.DefaultBackBufferWidth;
- _height = GraphicsDeviceManager.DefaultBackBufferHeight;
- var title = MonoGame.Utilities.AssemblyHelper.GetDefaultWindowTitle();
-
var initflags =
Sdl.Window.State.OpenGL |
Sdl.Window.State.Hidden |
Sdl.Window.State.InputFocus |
Sdl.Window.State.MouseFocus;
- if (_resizable)
- initflags |= Sdl.Window.State.Resizable;
-
- if (_borderless)
- initflags |= Sdl.Window.State.Borderless;
-
- Sdl.Window.Destroy(_handle);
-
- var surfaceFormat = _game.graphicsDeviceManager.PreferredBackBufferFormat.GetColorFormat ();
- var depthStencilFormat = _game.graphicsDeviceManager.PreferredDepthStencilFormat;
- // TODO Need to get this data from the Presentation Parameters
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.RedSize, surfaceFormat.R);
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.GreenSize, surfaceFormat.G);
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.BlueSize, surfaceFormat.B);
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.AlphaSize, surfaceFormat.A);
- switch (depthStencilFormat)
- {
- case DepthFormat.None:
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.DepthSize, 0);
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.StencilSize, 0);
- break;
- case DepthFormat.Depth16:
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.DepthSize, 16);
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.StencilSize, 0);
- break;
- case DepthFormat.Depth24:
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.DepthSize, 24);
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.StencilSize, 0);
- break;
- case DepthFormat.Depth24Stencil8:
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.DepthSize, 24);
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.StencilSize, 8);
- break;
- }
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.DoubleBuffer, 1);
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.ContextMajorVersion, 2);
- Sdl.GL.SetAttribute (Sdl.GL.Attribute.ContextMinorVersion, 1);
-
- _handle = Sdl.Window.Create (title,
+ _handle = Sdl.Window.Create(MonoGame.Utilities.AssemblyHelper.GetDefaultWindowTitle(),
_winx - _width / 2, _winy - _height / 2,
_width, _height, initflags);
Sdl.SetHint("SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS", "0");
Sdl.SetHint("SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS", "1");
- Sdl.Window.SetTitle(Handle, title);
-
using (
var stream =
Assembly.GetEntryAssembly().GetManifestResourceStream(Assembly.GetEntryAssembly().EntryPoint.DeclaringType.Namespace + ".Icon.bmp") ??
@@ -191,8 +138,43 @@ internal void CreateWindow()
}
SetCursorVisible(_mouseVisible);
+ }
+
+ // TODO Move this to GraphicsDeviceManager
+ internal void InitGraphics()
+ {
+ var surfaceFormat = _game.graphicsDeviceManager.PreferredBackBufferFormat.GetColorFormat();
+ var depthStencilFormat = _game.graphicsDeviceManager.PreferredDepthStencilFormat;
+
+ // TODO Need to get this data from the Presentation Parameters
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.RedSize, surfaceFormat.R);
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.GreenSize, surfaceFormat.G);
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.BlueSize, surfaceFormat.B);
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.AlphaSize, surfaceFormat.A);
+
+ switch (depthStencilFormat)
+ {
+ case DepthFormat.None:
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 0);
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 0);
+ break;
+ case DepthFormat.Depth16:
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 16);
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 0);
+ break;
+ case DepthFormat.Depth24:
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 24);
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 0);
+ break;
+ case DepthFormat.Depth24Stencil8:
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 24);
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 8);
+ break;
+ }
- _init = true;
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.DoubleBuffer, 1);
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.ContextMajorVersion, 2);
+ Sdl.GL.SetAttribute(Sdl.GL.Attribute.ContextMinorVersion, 1);
}
~SdlGameWindow()
diff --git a/MonoGame.Framework/Utilities/ByteBufferPool.cs b/MonoGame.Framework/Utilities/ByteBufferPool.cs
index 56a46da005b..614e1fc5a0c 100644
--- a/MonoGame.Framework/Utilities/ByteBufferPool.cs
+++ b/MonoGame.Framework/Utilities/ByteBufferPool.cs
@@ -51,7 +51,7 @@ public void Return(byte[] buffer)
if (index == -1)
_freeBuffers.Add(buffer);
else
- _freeBuffers.Insert(index + 1, buffer);
+ _freeBuffers.Insert(index, buffer);
}
}
diff --git a/MonoGame.Framework/Utilities/ReflectionHelpers.Default.cs b/MonoGame.Framework/Utilities/ReflectionHelpers.Default.cs
new file mode 100644
index 00000000000..b08447cedbc
--- /dev/null
+++ b/MonoGame.Framework/Utilities/ReflectionHelpers.Default.cs
@@ -0,0 +1,36 @@
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace Microsoft.Xna.Framework.Utilities
+{
+ internal static partial class ReflectionHelpers
+ {
+ ///
+ /// Generics handler for Marshal.SizeOf
+ ///
+ internal static class SizeOf
+ {
+ static int _sizeOf;
+
+ static SizeOf()
+ {
+ _sizeOf = Marshal.SizeOf();
+ }
+
+ static public int Get()
+ {
+ return _sizeOf;
+ }
+ }
+
+ ///
+ /// Fallback handler for Marshal.SizeOf(type)
+ ///
+ internal static int ManagedSizeOf(Type type)
+ {
+ return Marshal.SizeOf(type);
+ }
+ }
+}
\ No newline at end of file
diff --git a/MonoGame.Framework/Utilities/ReflectionHelpers.Legacy.cs b/MonoGame.Framework/Utilities/ReflectionHelpers.Legacy.cs
new file mode 100644
index 00000000000..9a3ec5e2a4c
--- /dev/null
+++ b/MonoGame.Framework/Utilities/ReflectionHelpers.Legacy.cs
@@ -0,0 +1,37 @@
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace Microsoft.Xna.Framework.Utilities
+{
+ internal static partial class ReflectionHelpers
+ {
+ ///
+ /// Generics handler for Marshal.SizeOf
+ ///
+ internal static class SizeOf
+ {
+ static int _sizeOf;
+
+ static SizeOf()
+ {
+ var type = typeof(T);
+ _sizeOf = Marshal.SizeOf(type);
+ }
+
+ static public int Get()
+ {
+ return _sizeOf;
+ }
+ }
+
+ ///
+ /// Fallback handler for Marshal.SizeOf(type)
+ ///
+ internal static int ManagedSizeOf(Type type)
+ {
+ return Marshal.SizeOf(type);
+ }
+ }
+}
\ No newline at end of file
diff --git a/MonoGame.Framework/Utilities/ReflectionHelpers.cs b/MonoGame.Framework/Utilities/ReflectionHelpers.cs
index cd1f51d1fc0..c3894c520fa 100644
--- a/MonoGame.Framework/Utilities/ReflectionHelpers.cs
+++ b/MonoGame.Framework/Utilities/ReflectionHelpers.cs
@@ -1,61 +1,61 @@
-
-using System;
+using System;
using System.IO;
using System.Reflection;
+using System.Runtime.InteropServices;
namespace Microsoft.Xna.Framework.Utilities
{
- internal static class ReflectionHelpers
- {
- public static bool IsValueType(Type targetType)
- {
- if (targetType == null)
- {
- throw new NullReferenceException("Must supply the targetType parameter");
- }
+ internal static partial class ReflectionHelpers
+ {
+ public static bool IsValueType(Type targetType)
+ {
+ if (targetType == null)
+ {
+ throw new NullReferenceException("Must supply the targetType parameter");
+ }
#if WINRT
- return targetType.GetTypeInfo().IsValueType;
+ return targetType.GetTypeInfo().IsValueType;
#else
- return targetType.IsValueType;
+ return targetType.IsValueType;
#endif
- }
-
- public static Type GetBaseType(Type targetType)
- {
- if (targetType == null)
- {
- throw new NullReferenceException("Must supply the targetType parameter");
- }
+ }
+
+ public static Type GetBaseType(Type targetType)
+ {
+ if (targetType == null)
+ {
+ throw new NullReferenceException("Must supply the targetType parameter");
+ }
#if WINRT
- var type = targetType.GetTypeInfo().BaseType;
+ var type = targetType.GetTypeInfo().BaseType;
#else
- var type = targetType.BaseType;
+ var type = targetType.BaseType;
#endif
- return type;
- }
+ return type;
+ }
///
/// Returns true if the given type represents a non-object type that is not abstract.
///
- public static bool IsConcreteClass(Type t)
- {
- if (t == null)
- {
- throw new NullReferenceException("Must supply the t (type) parameter");
- }
+ public static bool IsConcreteClass(Type t)
+ {
+ if (t == null)
+ {
+ throw new NullReferenceException("Must supply the t (type) parameter");
+ }
if (t == typeof(object))
return false;
#if WINRT
- var ti = t.GetTypeInfo();
- if (ti.IsClass && !ti.IsAbstract)
- return true;
+ var ti = t.GetTypeInfo();
+ if (ti.IsClass && !ti.IsAbstract)
+ return true;
#else
- if (t.IsClass && !t.IsAbstract)
- return true;
+ if (t.IsClass && !t.IsAbstract)
+ return true;
#endif
- return false;
- }
+ return false;
+ }
public static MethodInfo GetPropertyGetMethod(PropertyInfo property)
{
@@ -85,17 +85,17 @@ public static MethodInfo GetPropertySetMethod(PropertyInfo property)
#endif
}
- public static T GetCustomAttribute(MemberInfo member) where T : Attribute
- {
- if (member == null)
- throw new NullReferenceException("Must supply the member parameter");
+ public static T GetCustomAttribute(MemberInfo member) where T : Attribute
+ {
+ if (member == null)
+ throw new NullReferenceException("Must supply the member parameter");
#if WINRT
- return member.GetCustomAttribute(typeof(T)) as T;
+ return member.GetCustomAttribute(typeof(T)) as T;
#else
return Attribute.GetCustomAttribute(member, typeof(T)) as T;
#endif
- }
+ }
///
/// Returns true if the get method of the given property exist and are public.
@@ -110,6 +110,7 @@ public static bool PropertyIsPublic(PropertyInfo property)
}
var getMethod = GetPropertyGetMethod(property);
+
if (getMethod == null || !getMethod.IsPublic)
return false;
@@ -119,15 +120,15 @@ public static bool PropertyIsPublic(PropertyInfo property)
///
/// Returns true if the given type can be assigned the given value
///
- public static bool IsAssignableFrom(Type type, object value)
- {
- if (type == null)
- throw new ArgumentNullException("type");
- if (value == null)
- throw new ArgumentNullException("value");
+ public static bool IsAssignableFrom(Type type, object value)
+ {
+ if (type == null)
+ throw new ArgumentNullException("type");
+ if (value == null)
+ throw new ArgumentNullException("value");
return IsAssignableFromType(type, value.GetType());
- }
+ }
///
/// Returns true if the given type can be assigned a value with the given object type
@@ -147,6 +148,5 @@ public static bool IsAssignableFromType(Type type, Type objectType)
#endif
return false;
}
-
- }
-}
+ }
+}
\ No newline at end of file
diff --git a/MonoGame.Framework/Utilities/ZLibStream/ZlibStream.cs b/MonoGame.Framework/Utilities/ZLibStream/ZlibStream.cs
index b2252e331c6..a544c3bd578 100644
--- a/MonoGame.Framework/Utilities/ZLibStream/ZlibStream.cs
+++ b/MonoGame.Framework/Utilities/ZLibStream/ZlibStream.cs
@@ -8378,7 +8378,7 @@ internal Int32 Crc
///
///
///
- /// Set this at any point before calling .
+ /// Set this at any point before calling .
///
///
internal bool LeaveOpen
diff --git a/MonoGame.Framework/Windows/WinFormsGameForm.cs b/MonoGame.Framework/Windows/WinFormsGameForm.cs
index 4b6315606ee..23807d5a843 100644
--- a/MonoGame.Framework/Windows/WinFormsGameForm.cs
+++ b/MonoGame.Framework/Windows/WinFormsGameForm.cs
@@ -47,6 +47,13 @@ public WinFormsGameForm(GameWindow window)
_window = window;
}
+ public void CenterOnPrimaryMonitor()
+ {
+ Location = new System.Drawing.Point(
+ (Screen.PrimaryScreen.WorkingArea.Width - Width ) / 2,
+ (Screen.PrimaryScreen.WorkingArea.Height - Height) / 2);
+ }
+
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
diff --git a/MonoGame.Framework/Windows/WinFormsGamePlatform.cs b/MonoGame.Framework/Windows/WinFormsGamePlatform.cs
index 09e22bae6fd..c1c55b2847e 100644
--- a/MonoGame.Framework/Windows/WinFormsGamePlatform.cs
+++ b/MonoGame.Framework/Windows/WinFormsGamePlatform.cs
@@ -16,13 +16,14 @@ class WinFormsGamePlatform : GamePlatform
//internal static string LaunchParameters;
private WinFormsGameWindow _window;
+ private System.Drawing.Point _locationBeforeFullscreen;
public WinFormsGamePlatform(Game game)
: base(game)
{
_window = new WinFormsGameWindow(this);
- Mouse.Window = _window._form;
+ Mouse.Window = _window.Form;
Window = _window;
}
@@ -45,16 +46,21 @@ public override bool BeforeRun()
public override void BeforeInitialize()
{
- var gdm = Game.graphicsDeviceManager;
-
- _window.Initialize(gdm.PreferredBackBufferWidth, gdm.PreferredBackBufferHeight);
-
base.BeforeInitialize();
- if (gdm.IsFullScreen)
- EnterFullScreen();
+ var gdm = Game.graphicsDeviceManager;
+ if (gdm == null)
+ {
+ _window.Initialize(GraphicsDeviceManager.DefaultBackBufferWidth, GraphicsDeviceManager.DefaultBackBufferHeight);
+ }
else
- ExitFullScreen();
+ {
+ var pp = Game.GraphicsDevice.PresentationParameters;
+ _window.Initialize(pp.BackBufferWidth, pp.BackBufferHeight);
+
+ if (gdm.IsFullScreen)
+ EnterFullScreen();
+ }
}
public override void RunLoop()
@@ -87,66 +93,51 @@ public override bool BeforeDraw(GameTime gameTime)
public override void EnterFullScreen()
{
- if (_alreadyInFullScreenMode)
- return;
-
+ // store the location of the window so we can restore it later
+ _locationBeforeFullscreen = _window.Form.Location;
if (Game.graphicsDeviceManager.HardwareModeSwitch)
- {
- Game.GraphicsDevice.PresentationParameters.IsFullScreen = true;
Game.GraphicsDevice.SetHardwareFullscreen();
-
- _window._form.WindowState = FormWindowState.Maximized;
- }
else
- {
_window.IsBorderless = true;
- _window._form.WindowState = FormWindowState.Maximized;
- }
- _alreadyInWindowedMode = false;
- _alreadyInFullScreenMode = true;
+ _window.Form.WindowState = FormWindowState.Maximized;
+
+ InFullScreenMode = true;
}
public override void ExitFullScreen()
{
- if (_alreadyInWindowedMode)
- return;
-
if (Game.graphicsDeviceManager.HardwareModeSwitch)
- {
-
- Game.GraphicsDevice.PresentationParameters.IsFullScreen = false;
Game.GraphicsDevice.SetHardwareFullscreen();
-
- _window._form.WindowState = FormWindowState.Normal;
-
- Game.GraphicsDevice.PresentationParameters.BackBufferWidth = Game.graphicsDeviceManager.PreferredBackBufferWidth;
- Game.GraphicsDevice.PresentationParameters.BackBufferHeight = Game.graphicsDeviceManager.PreferredBackBufferHeight;
-
- Game.GraphicsDevice.OnPresentationChanged();
- }
else
- {
- _window._form.WindowState = FormWindowState.Normal;
_window.IsBorderless = false;
- }
- _alreadyInWindowedMode = true;
- _alreadyInFullScreenMode = false;
+ _window.Form.WindowState = FormWindowState.Normal;
+ _window.Form.Location = _locationBeforeFullscreen;
+
+ InFullScreenMode = false;
}
internal override void OnPresentationChanged()
{
- var presentationParameters = Game.GraphicsDevice.PresentationParameters;
-
- if (presentationParameters.IsFullScreen)
+ var pp = Game.GraphicsDevice.PresentationParameters;
+ _window.ChangeClientSize(new Size(pp.BackBufferWidth, pp.BackBufferHeight));
+
+ if (Game.GraphicsDevice.PresentationParameters.IsFullScreen && !InFullScreenMode)
+ {
EnterFullScreen();
- else
- ExitFullScreen();
-
- _window.ChangeClientSize(new Size(presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight));
+ _window.OnClientSizeChanged();
+ }
+ else if (!Game.GraphicsDevice.PresentationParameters.IsFullScreen && InFullScreenMode)
+ {
+ ExitFullScreen();
+ _window.OnClientSizeChanged();
+ }
+
+ if (!_window.UserResized)
+ _window.CenterForm();
}
-
+
public override void EndScreenDeviceChange(string screenDeviceName, int clientWidth, int clientHeight)
{
}
diff --git a/MonoGame.Framework/Windows/WinFormsGameWindow.cs b/MonoGame.Framework/Windows/WinFormsGameWindow.cs
index 62270f8ef25..ba4b7ed12dc 100644
--- a/MonoGame.Framework/Windows/WinFormsGameWindow.cs
+++ b/MonoGame.Framework/Windows/WinFormsGameWindow.cs
@@ -22,7 +22,7 @@ namespace MonoGame.Framework
{
class WinFormsGameWindow : GameWindow, IDisposable
{
- internal WinFormsGameForm _form;
+ internal WinFormsGameForm Form;
static private ReaderWriterLockSlim _allWindowsReaderWriterLockSlim = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
static private List _allWindows = new List();
@@ -40,12 +40,13 @@ class WinFormsGameWindow : GameWindow, IDisposable
#region Internal Properties
internal Game Game { get; private set; }
+ internal bool UserResized { get; private set; }
#endregion
#region Public Properties
- public override IntPtr Handle { get { return _form.Handle; } }
+ public override IntPtr Handle { get { return Form.Handle; } }
public override string ScreenDeviceName { get { return String.Empty; } }
@@ -53,8 +54,8 @@ public override Rectangle ClientBounds
{
get
{
- var position = _form.PointToScreen(Point.Empty);
- var size = _form.ClientSize;
+ var position = Form.PointToScreen(Point.Empty);
+ var size = Form.ClientSize;
return new Rectangle(position.X, position.Y, size.Width, size.Height);
}
}
@@ -67,13 +68,13 @@ public override bool AllowUserResizing
if (_isResizable != value)
{
_isResizable = value;
- _form.MaximizeBox = _isResizable;
+ Form.MaximizeBox = _isResizable;
}
else
return;
if (_isBorderless)
return;
- _form.FormBorderStyle = _isResizable ? FormBorderStyle.Sizable : FormBorderStyle.FixedSingle;
+ Form.FormBorderStyle = _isResizable ? FormBorderStyle.Sizable : FormBorderStyle.FixedSingle;
}
}
@@ -82,7 +83,7 @@ public override bool AllowAltF4
get { return base.AllowAltF4; }
set
{
- _form.AllowAltF4 = value;
+ Form.AllowAltF4 = value;
base.AllowAltF4 = value;
}
}
@@ -94,8 +95,8 @@ public override DisplayOrientation CurrentOrientation
public override XnaPoint Position
{
- get { return new XnaPoint(_form.DesktopLocation.X, _form.DesktopLocation.Y); }
- set { _form.DesktopLocation = new Point(value.X, value.Y); }
+ get { return new XnaPoint(Form.Location.X, Form.Location.Y); }
+ set { Form.Location = new Point(value.X, value.Y); }
}
protected internal override void SetSupportedOrientations(DisplayOrientation orientations)
@@ -112,9 +113,9 @@ public override bool IsBorderless
else
return;
if (_isBorderless)
- _form.FormBorderStyle = FormBorderStyle.None;
+ Form.FormBorderStyle = FormBorderStyle.None;
else
- _form.FormBorderStyle = _isResizable ? FormBorderStyle.Sizable : FormBorderStyle.FixedSingle;
+ Form.FormBorderStyle = _isResizable ? FormBorderStyle.Sizable : FormBorderStyle.FixedSingle;
}
}
@@ -125,26 +126,26 @@ internal WinFormsGameWindow(WinFormsGamePlatform platform)
_platform = platform;
Game = platform.Game;
- _form = new WinFormsGameForm(this);
- _form.ClientSize = new Size(GraphicsDeviceManager.DefaultBackBufferWidth, GraphicsDeviceManager.DefaultBackBufferHeight);
+ Form = new WinFormsGameForm(this);
+ Form.ClientSize = new Size(GraphicsDeviceManager.DefaultBackBufferWidth, GraphicsDeviceManager.DefaultBackBufferHeight);
SetIcon();
Title = Utilities.AssemblyHelper.GetDefaultWindowTitle();
- _form.MaximizeBox = false;
- _form.FormBorderStyle = FormBorderStyle.FixedSingle;
- _form.StartPosition = FormStartPosition.CenterScreen;
+ Form.MaximizeBox = false;
+ Form.FormBorderStyle = FormBorderStyle.FixedSingle;
+ Form.StartPosition = FormStartPosition.Manual;
// Capture mouse events.
- _form.MouseWheel += OnMouseScroll;
- _form.MouseEnter += OnMouseEnter;
- _form.MouseLeave += OnMouseLeave;
+ Form.MouseWheel += OnMouseScroll;
+ Form.MouseEnter += OnMouseEnter;
+ Form.MouseLeave += OnMouseLeave;
- _form.Activated += OnActivated;
- _form.Deactivate += OnDeactivate;
- _form.ClientSizeChanged += OnClientSizeChanged;
+ Form.Activated += OnActivated;
+ Form.Deactivate += OnDeactivate;
+ Form.ResizeEnd += OnResizeEnd;
- _form.KeyPress += OnKeyPress;
+ Form.KeyPress += OnKeyPress;
RegisterToAllWindows();
}
@@ -160,7 +161,7 @@ private void SetIcon()
return;
var handle = ExtractIcon(IntPtr.Zero, assembly.Location, 0);
if (handle != IntPtr.Zero)
- _form.Icon = Icon.FromHandle(handle);
+ Form.Icon = Icon.FromHandle(handle);
}
~WinFormsGameWindow()
@@ -198,20 +199,6 @@ private void UnregisterFromAllWindows()
private void OnActivated(object sender, EventArgs eventArgs)
{
-#if (WINDOWS && DIRECTX)
- if (Game.GraphicsDevice != null)
- {
- if (Game.graphicsDeviceManager.HardwareModeSwitch)
- {
- if (!_platform.IsActive && Game.GraphicsDevice.PresentationParameters.IsFullScreen)
- {
- Game.GraphicsDevice.PresentationParameters.IsFullScreen = true;
- Game.GraphicsDevice.CreateSizeDependentResources();
- Game.GraphicsDevice.ApplyRenderTargets(null);
- }
- }
- }
-#endif
_platform.IsActive = true;
Keyboard.SetActive(true);
}
@@ -232,11 +219,11 @@ private void UpdateMouseState()
// If we call the form client functions before the form has
// been made visible it will cause the wrong window size to
// be applied at startup.
- if (!_form.Visible)
+ if (!Form.Visible)
return;
- var clientPos = _form.PointToClient(Control.MousePosition);
- var withinClient = _form.ClientRectangle.Contains(clientPos);
+ var clientPos = Form.PointToClient(Control.MousePosition);
+ var withinClient = Form.ClientRectangle.Contains(clientPos);
var buttons = Control.MouseButtons;
var previousState = MouseState.LeftButton;
@@ -291,29 +278,30 @@ private void OnKeyPress(object sender, KeyPressEventArgs e)
}
internal void Initialize(int width, int height)
- {
- _form.ClientSize = new Size(width, height);
- _form.Show();
+ {
+ Form.ClientSize = new Size(width, height);
+ CenterForm();
}
- private void OnClientSizeChanged(object sender, EventArgs eventArgs)
+ private void OnResizeEnd(object sender, EventArgs eventArgs)
{
+ UserResized = true;
if (Game.Window == this)
{
var manager = Game.graphicsDeviceManager;
-
- // Set the default new back buffer size and viewport, but this
- // can be overloaded by the two events below.
-
- var newWidth = _form.ClientRectangle.Width;
- var newHeight = _form.ClientRectangle.Height;
-
if (manager.GraphicsDevice == null)
return;
- manager.GraphicsDevice.PresentationParameters.BackBufferWidth = newWidth;
- manager.GraphicsDevice.PresentationParameters.BackBufferHeight = newHeight;
- manager.GraphicsDevice.OnPresentationChanged();
+ var newSize = Form.ClientSize;
+ if (newSize.Width == manager.PreferredBackBufferWidth
+ && newSize.Height == manager.PreferredBackBufferHeight)
+ return;
+
+ // Set the default new back buffer size and viewport, but this
+ // can be overloaded by the two events below.
+ manager.PreferredBackBufferWidth = newSize.Width;
+ manager.PreferredBackBufferHeight = newSize.Height;
+ manager.ApplyChanges();
}
// Set the new view state which will trigger the
@@ -324,19 +312,26 @@ private void OnClientSizeChanged(object sender, EventArgs eventArgs)
protected override void SetTitle(string title)
{
- _form.Text = title;
+ Form.Text = title;
}
internal void RunLoop()
{
+ // XNA runs one Update even before showing the window
+ Game.DoUpdate(new GameTime());
+
+ // center now in case the user changed the window size
+ // in the first update call
+ Form.CenterOnPrimaryMonitor();
+
// https://bugzilla.novell.com/show_bug.cgi?id=487896
// Since there's existing bug from implementation with mono WinForms since 09'
// Application.Idle is not working as intended
// So we're just going to emulate Application.Run just like Microsoft implementation
- _form.Show();
+ Form.Show();
var nativeMsg = new NativeMessage();
- while (_form != null && _form.IsDisposed == false)
+ while (Form != null && Form.IsDisposed == false)
{
if (PeekMessage(out nativeMsg, IntPtr.Zero, 0, 0, 0))
{
@@ -359,7 +354,7 @@ internal void RunLoop()
// This is critical for some NUnit runners which
// typically will run all the tests on the same
// process/thread.
-
+#if DEBUG
var msg = new NativeMessage();
do
{
@@ -368,7 +363,13 @@ internal void RunLoop()
Thread.Sleep(100);
}
- while (PeekMessage(out msg, IntPtr.Zero, 0, 0, 1));
+ while (PeekMessage(out msg, IntPtr.Zero, 0, 1 << 5, 1));
+#endif
+ }
+
+ public void CenterForm()
+ {
+ Form.CenterOnPrimaryMonitor();
}
internal void UpdateWindows()
@@ -403,8 +404,8 @@ public struct NativeMessage
internal void ChangeClientSize(Size clientBounds)
{
- if(this._form.ClientSize != clientBounds)
- this._form.ClientSize = clientBounds;
+ if(this.Form.ClientSize != clientBounds)
+ this.Form.ClientSize = clientBounds;
}
[System.Security.SuppressUnmanagedCodeSecurity] // We won't use this maliciously
@@ -423,11 +424,11 @@ void Dispose(bool disposing)
{
if (disposing)
{
- if (_form != null)
+ if (Form != null)
{
UnregisterFromAllWindows();
- _form.Dispose();
- _form = null;
+ Form.Dispose();
+ Form = null;
}
}
_platform = null;
diff --git a/NuGetPackages/MonoGame.Framework.Android.nuspec b/NuGetPackages/MonoGame.Framework.Android.nuspec
index 1737c8e2625..cfa7f1a3f41 100644
--- a/NuGetPackages/MonoGame.Framework.Android.nuspec
+++ b/NuGetPackages/MonoGame.Framework.Android.nuspec
@@ -11,7 +11,7 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Copyright 2016
diff --git a/NuGetPackages/MonoGame.Framework.DesktopGL.nuspec b/NuGetPackages/MonoGame.Framework.DesktopGL.nuspec
index 361a5db159a..7fa4a436774 100644
--- a/NuGetPackages/MonoGame.Framework.DesktopGL.nuspec
+++ b/NuGetPackages/MonoGame.Framework.DesktopGL.nuspec
@@ -11,7 +11,7 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Copyright 2016
diff --git a/NuGetPackages/MonoGame.Framework.Linux.nuspec b/NuGetPackages/MonoGame.Framework.Linux.nuspec
index 7a80f8cbaff..a6e9778da61 100644
--- a/NuGetPackages/MonoGame.Framework.Linux.nuspec
+++ b/NuGetPackages/MonoGame.Framework.Linux.nuspec
@@ -11,7 +11,7 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Copyright 2016
diff --git a/NuGetPackages/MonoGame.Framework.MacOS.nuspec b/NuGetPackages/MonoGame.Framework.MacOS.nuspec
index b9baaa28318..dc8f31ecd15 100644
--- a/NuGetPackages/MonoGame.Framework.MacOS.nuspec
+++ b/NuGetPackages/MonoGame.Framework.MacOS.nuspec
@@ -11,7 +11,7 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Updated dev release - 10th December 2014
Added support for Windows Phone 8.1 and Universal projects
diff --git a/NuGetPackages/MonoGame.Framework.Ouya.nuspec b/NuGetPackages/MonoGame.Framework.Ouya.nuspec
deleted file mode 100644
index d8335d37e1f..00000000000
--- a/NuGetPackages/MonoGame.Framework.Ouya.nuspec
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- MonoGame.Framework.Ouya
- 0.0.0.0
- MonoGame.Framework.Ouya
- MonoGameTeam
- MonoGameTeam
- https://github.com/mono/MonoGame/blob/develop/LICENSE.txt#L2
- http://monogame.net/
- https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
- false
- MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
- MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
-
- Copyright 2016
- en-US
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/NuGetPackages/MonoGame.Framework.Windows8.nuspec b/NuGetPackages/MonoGame.Framework.Windows8.nuspec
index 8cf309fb697..55fa0e0842d 100644
--- a/NuGetPackages/MonoGame.Framework.Windows8.nuspec
+++ b/NuGetPackages/MonoGame.Framework.Windows8.nuspec
@@ -11,7 +11,7 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Copyright 2016
diff --git a/NuGetPackages/MonoGame.Framework.WindowsDX.nuspec b/NuGetPackages/MonoGame.Framework.WindowsDX.nuspec
index 3356e0a6ee5..17a88172b82 100644
--- a/NuGetPackages/MonoGame.Framework.WindowsDX.nuspec
+++ b/NuGetPackages/MonoGame.Framework.WindowsDX.nuspec
@@ -11,7 +11,7 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Copyright 2016
diff --git a/NuGetPackages/MonoGame.Framework.WindowsGL.nuspec b/NuGetPackages/MonoGame.Framework.WindowsGL.nuspec
index c0254b7c39c..bd7b6896260 100644
--- a/NuGetPackages/MonoGame.Framework.WindowsGL.nuspec
+++ b/NuGetPackages/MonoGame.Framework.WindowsGL.nuspec
@@ -11,7 +11,7 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Copyright 2016
diff --git a/NuGetPackages/MonoGame.Framework.WindowsPhone8.nuspec b/NuGetPackages/MonoGame.Framework.WindowsPhone8.nuspec
deleted file mode 100644
index f48afc77e06..00000000000
--- a/NuGetPackages/MonoGame.Framework.WindowsPhone8.nuspec
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
- MonoGame.Framework.WindowsPhone8
- 0.0.0.0
- MonoGame.Framework.WindowsPhone8
- MonoGameTeam
- MonoGameTeam
- https://github.com/mono/MonoGame/blob/develop/LICENSE.txt#L2
- http://monogame.net/
- https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
- false
- MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
- MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
-
- Copyright 2016
- en-US
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/NuGetPackages/MonoGame.Framework.WindowsPhone81.nuspec b/NuGetPackages/MonoGame.Framework.WindowsPhone81.nuspec
index 5c340782b25..9bfdfb06b1c 100644
--- a/NuGetPackages/MonoGame.Framework.WindowsPhone81.nuspec
+++ b/NuGetPackages/MonoGame.Framework.WindowsPhone81.nuspec
@@ -11,7 +11,7 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Copyright 2016
diff --git a/NuGetPackages/MonoGame.Framework.WindowsUniversal.nuspec b/NuGetPackages/MonoGame.Framework.WindowsUniversal.nuspec
index 829a38c8f53..b0bb3c08987 100644
--- a/NuGetPackages/MonoGame.Framework.WindowsUniversal.nuspec
+++ b/NuGetPackages/MonoGame.Framework.WindowsUniversal.nuspec
@@ -1,5 +1,5 @@

-
+
MonoGame.Framework.WindowsUniversal
0.0.0.0
@@ -11,14 +11,11 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Copyright 2016
en-US
-
-
-
@@ -34,4 +31,4 @@
-
+
\ No newline at end of file
diff --git a/NuGetPackages/MonoGame.Framework.iOS.nuspec b/NuGetPackages/MonoGame.Framework.iOS.nuspec
index 7b941d3887e..1d276de3a46 100644
--- a/NuGetPackages/MonoGame.Framework.iOS.nuspec
+++ b/NuGetPackages/MonoGame.Framework.iOS.nuspec
@@ -11,7 +11,7 @@
https://pbs.twimg.com/profile_images/487954549441691649/O3KsHAsb_400x400.png
false
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
- The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+ The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
MonoGame is an open source cross platform implementation of Microsoft's XNA 4.x Framework
Copyright 2016
diff --git a/NuGetPackages/Readme-Build.txt b/NuGetPackages/Readme-Build.txt
index cf4e3fd08bc..0ac907f6a04 100644
--- a/NuGetPackages/Readme-Build.txt
+++ b/NuGetPackages/Readme-Build.txt
@@ -7,7 +7,6 @@ NuGet pack MonoGame.Framework.iOS.nuspec -BasePath ..\MonoGame.Framework\bin -Ou
NuGet pack MonoGame.Framework.Linux.nuspec -BasePath ..\MonoGame.Framework\bin -OutputDirectory packages
NuGet pack MonoGame.Framework.MacOS.nuspec -BasePath ..\MonoGame.Framework\bin -OutputDirectory packages
NuGet pack MonoGame.Framework.MonoMac.nuspec -BasePath ..\MonoGame.Framework\bin -OutputDirectory packages
-NuGet pack MonoGame.Framework.Ouya.nuspec -BasePath ..\MonoGame.Framework\bin -OutputDirectory packages
NuGet pack MonoGame.Framework.Windows8.nuspec -BasePath ..\MonoGame.Framework\bin -OutputDirectory packages
NuGet pack MonoGame.Framework.WindowsDX.nuspec -BasePath ..\MonoGame.Framework\bin -OutputDirectory packages
NuGet pack MonoGame.Framework.WindowsGL.nuspec -BasePath ..\MonoGame.Framework\bin -OutputDirectory packages
diff --git a/NuGetPackages/readme/MonoGame.Framework/readme.txt b/NuGetPackages/readme/MonoGame.Framework/readme.txt
index f4eaf84a599..a7dc875b79d 100644
--- a/NuGetPackages/readme/MonoGame.Framework/readme.txt
+++ b/NuGetPackages/readme/MonoGame.Framework/readme.txt
@@ -2,7 +2,7 @@ Welcome to MonoGame on NuGet
_Description
MonoGame is an open source implementation of the Microsoft XNA 4.x Framework.
-The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8, PlayStation Mobile, and the OUYA console.
+The goal is to make it easy for XNA developers to create cross-platform games with extremely high code reuse. We currently support iOS, Android, Windows (both OpenGL and DirectX), Mac OS X, Linux, Windows 8 Store, Windows Phone 8 and Windows UWP.
This package contains only the Binaries for the MonoGame framework, to enable easier platform dll updates.
@@ -19,7 +19,6 @@ The currently available packages are:
* iOS (Xamarin.iOS only)
* MacOS (net4 / net45 / MonoMac and Xamarin.Mac)
* Android
- * Ouya
* Linux
_Contents
@@ -48,7 +47,7 @@ This will install all the project templates for Visual Studio including the new
To upgrade your project you will need to edit your .CSPROJ file for your solution (either from windows explorer or using the VS power tools to edit the project file) and add the following entries:
* WindowsGL <- Placed just before the 1st line with (in the initial project definition section)
-**Note, the platform name should be one of the following: Android, iOS, Linux, MacOSX, NativeClient, Ouya, Playstation4, PlaystationMobile, RaspberryPi, Windows, WindowsGL, WindowsPhone, WindowsPhone8, WindowsStoreApp, XBOX360 (depending on your project platform)
+**Note, the platform name should be one of the following: Android, iOS, Linux, MacOSX, NativeClient, Playstation4, RaspberryPi, Windows, WindowsGL, WindowsPhone8, WindowsStoreApp (depending on your project platform)
* <- Placed with the other IMPORT references at the end of the CSPROJ file
This will enable the new Content Builder to function an run.
diff --git a/ProjectTemplates/VisualStudio2010/ContentPipelineExtension/MonoGameContentPipelineExtension.csproj b/ProjectTemplates/VisualStudio2010/ContentPipelineExtension/MonoGameContentPipelineExtension.csproj
index 078fa98f2f9..872ed6adfe7 100644
--- a/ProjectTemplates/VisualStudio2010/ContentPipelineExtension/MonoGameContentPipelineExtension.csproj
+++ b/ProjectTemplates/VisualStudio2010/ContentPipelineExtension/MonoGameContentPipelineExtension.csproj
@@ -10,7 +10,7 @@
Properties
$safeprojectname$
$safeprojectname$
- v4.0
+ v4.5
512
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Activity1.cs b/ProjectTemplates/VisualStudio2010/OUYA/Activity1.cs
deleted file mode 100644
index aa1debd8118..00000000000
--- a/ProjectTemplates/VisualStudio2010/OUYA/Activity1.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Android.App;
-using Android.Content.PM;
-using Android.OS;
-using Android.Content;
-using Android.Views;
-using Ouya.Console.Api;
-
-namespace $safeprojectname$
-{
- [Activity(Label = "$projectname$"
- , MainLauncher = true
- , Icon = "@drawable/icon"
- , Theme = "@style/Theme.Splash"
- , AlwaysRetainTaskState=true
- , LaunchMode=Android.Content.PM.LaunchMode.SingleInstance
- , ScreenOrientation = ScreenOrientation.SensorLandscape
- , ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden)]
- [IntentFilter(new[] { Intent.ActionMain }
- , Categories = new[] { Intent.CategoryLauncher, OuyaIntent.CategoryGame })]
- public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
- {
- protected override void OnCreate(Bundle bundle)
- {
- base.OnCreate(bundle);
- var g = new Game1();
- SetContentView((View)g.Services.GetService(typeof(View)));
- g.Run();
- }
- }
-}
-
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Assets/AboutAssets.txt b/ProjectTemplates/VisualStudio2010/OUYA/Assets/AboutAssets.txt
deleted file mode 100644
index ee398862952..00000000000
--- a/ProjectTemplates/VisualStudio2010/OUYA/Assets/AboutAssets.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-Any raw assets you want to be deployed with your application can be placed in
-this directory (and child directories) and given a Build Action of "AndroidAsset".
-
-These files will be deployed with you package and will be accessible using Android's
-AssetManager, like this:
-
-public class ReadAsset : Activity
-{
- protected override void OnCreate (Bundle bundle)
- {
- base.OnCreate (bundle);
-
- InputStream input = Assets.Open ("my_asset.txt");
- }
-}
-
-Additionally, some Android functions will automatically load asset files:
-
-Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/MonoGameOUYA.vstemplate b/ProjectTemplates/VisualStudio2010/OUYA/MonoGameOUYA.vstemplate
deleted file mode 100644
index 6ee1fb496d2..00000000000
--- a/ProjectTemplates/VisualStudio2010/OUYA/MonoGameOUYA.vstemplate
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
- MonoGame OUYA Project
- A MonoGame game project for OUYA using Xamarin.Android 4.8.2 or greater.
- CSharp
- 1
-
-
- 43210
- true
- Game
- true
- Enabled
- true
- __TemplateIcon.png
- __PreviewImage.png
-
-
-
- Activity1.cs
-
- AboutAssets.txt
-
- Game1.cs
-
- AssemblyInfo.cs
-
-
- AboutResources.txt
-
- Icon.png
- Splash.png
-
-
- ouya_icon.png
-
-
-
- key.der
-
- Resource.Designer.cs
-
- Strings.xml
- Styles.xml
-
-
-
- Content.mgcb
-
-
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/OuyaGame1.csproj b/ProjectTemplates/VisualStudio2010/OUYA/OuyaGame1.csproj
deleted file mode 100644
index 30637558659..00000000000
--- a/ProjectTemplates/VisualStudio2010/OUYA/OuyaGame1.csproj
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- 8.0.30703
- 2.0
- $guid1$
- {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- Library
- Properties
- $safeprojectname$
- $safeprojectname$
- 512
- true
- Resources\Resource.Designer.cs
- Off
- armeabi-v7a%3bx86
-
-
- v4.2
- Android
-
-
- true
- full
- false
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;ANDROID;OUYA
- prompt
- 4
- True
- None
-
-
- pdbonly
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;ANDROID;OUYA
- prompt
- 4
- False
- SdkOnly
-
-
-
-
-
-
-
-
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\OUYA\MonoGame.Framework.dll
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\OUYA\Ouya.Console.Api.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Resources/AboutResources.txt b/ProjectTemplates/VisualStudio2010/OUYA/Resources/AboutResources.txt
deleted file mode 100644
index b0fc999bdb7..00000000000
--- a/ProjectTemplates/VisualStudio2010/OUYA/Resources/AboutResources.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-Images, layout descriptions, binary blobs and string dictionaries can be included
-in your application as resource files. Various Android APIs are designed to
-operate on the resource IDs instead of dealing with images, strings or binary blobs
-directly.
-
-For example, a sample Android app that contains a user interface layout (Main.xml),
-an internationalization string table (Strings.xml) and some icons (drawable/Icon.png)
-would keep its resources in the "Resources" directory of the application:
-
-Resources/
- Drawable/
- Icon.png
-
- Layout/
- Main.axml
-
- Values/
- Strings.xml
-
-In order to get the build system to recognize Android resources, the build action should be set
-to "AndroidResource". The native Android APIs do not operate directly with filenames, but
-instead operate on resource IDs. When you compile an Android application that uses resources,
-the build system will package the resources for distribution and generate a class called
-"Resource" that contains the tokens for each one of the resources included. For example,
-for the above Resources layout, this is what the Resource class would expose:
-
-public class Resource {
- public class Drawable {
- public const int Icon = 0x123;
- }
-
- public class Layout {
- public const int Main = 0x456;
- }
-
- public class String {
- public const int FirstString = 0xabc;
- public const int SecondString = 0xbcd;
- }
-}
-
-You would then use Resource.Drawable.Icon to reference the Drawable/Icon.png file, or
-Resource.Layout.Main to reference the Layout/Main.axml file, or Resource.String.FirstString
-to reference the first string in the dictionary file Values/Strings.xml.
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Drawable-xhdpi/ouya_icon.png b/ProjectTemplates/VisualStudio2010/OUYA/Resources/Drawable-xhdpi/ouya_icon.png
deleted file mode 100644
index efee0e392d4..00000000000
Binary files a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Drawable-xhdpi/ouya_icon.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Drawable/Icon.png b/ProjectTemplates/VisualStudio2010/OUYA/Resources/Drawable/Icon.png
deleted file mode 100644
index f6f4f411136..00000000000
Binary files a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Drawable/Icon.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Drawable/Splash.png b/ProjectTemplates/VisualStudio2010/OUYA/Resources/Drawable/Splash.png
deleted file mode 100644
index 8cb2ef7cb1e..00000000000
Binary files a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Drawable/Splash.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Raw/key.der b/ProjectTemplates/VisualStudio2010/OUYA/Resources/Raw/key.der
deleted file mode 100644
index 92304755a9e..00000000000
Binary files a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Raw/key.der and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Resource.Designer.cs b/ProjectTemplates/VisualStudio2010/OUYA/Resources/Resource.Designer.cs
deleted file mode 100644
index 4eb07fe304b..00000000000
--- a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Resource.Designer.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.269
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace $safeprojectname$
-{
-
-
- public partial class Resource
- {
-
- public partial class Attribute
- {
-
- private Attribute()
- {
- }
- }
-
- public partial class Drawable
- {
-
- // aapt resource value: 0x7f020000
- public const int Icon = 2130837504;
-
- // aapt resource value: 0x7f020001
- public const int Splash = 2130837505;
-
- private Drawable()
- {
- }
- }
-
- public partial class String
- {
-
- // aapt resource value: 0x7f030001
- public const int ApplicationName = 2130903041;
-
- // aapt resource value: 0x7f030000
- public const int Hello = 2130903040;
-
- private String()
- {
- }
- }
-
- public partial class Style
- {
-
- // aapt resource value: 0x7f040000
- public const int Theme_Splash = 2130968576;
-
- private Style()
- {
- }
- }
- }
-}
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Values/Strings.xml b/ProjectTemplates/VisualStudio2010/OUYA/Resources/Values/Strings.xml
deleted file mode 100644
index 70ed0979094..00000000000
--- a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Values/Strings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- Hello World, Click Me!
- $safeprojectname$
-
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Values/Styles.xml b/ProjectTemplates/VisualStudio2010/OUYA/Resources/Values/Styles.xml
deleted file mode 100644
index 51021340133..00000000000
--- a/ProjectTemplates/VisualStudio2010/OUYA/Resources/Values/Styles.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/AlignmentGrid.png b/ProjectTemplates/VisualStudio2012/WindowsPhone/AlignmentGrid.png
deleted file mode 100644
index f7d2e97804e..00000000000
Binary files a/ProjectTemplates/VisualStudio2012/WindowsPhone/AlignmentGrid.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/App.xaml b/ProjectTemplates/VisualStudio2012/WindowsPhone/App.xaml
deleted file mode 100644
index 69d106beebf..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/App.xaml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/App.xaml.cs b/ProjectTemplates/VisualStudio2012/WindowsPhone/App.xaml.cs
deleted file mode 100644
index 511774308ee..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/App.xaml.cs
+++ /dev/null
@@ -1,223 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Resources;
-using System.Windows;
-using System.Windows.Markup;
-using System.Windows.Navigation;
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Shell;
-using $safeprojectname$.Resources;
-
-namespace $safeprojectname$
-{
- public partial class App : Application
- {
- ///
- /// Provides easy access to the root frame of the Phone Application.
- ///
- /// The root frame of the Phone Application.
- public static PhoneApplicationFrame RootFrame { get; private set; }
-
- ///
- /// Constructor for the Application object.
- ///
- public App()
- {
- // Global handler for uncaught exceptions.
- UnhandledException += Application_UnhandledException;
-
- // Standard XAML initialization
- InitializeComponent();
-
- // Phone-specific initialization
- InitializePhoneApplication();
-
- // Language display initialization
- InitializeLanguage();
-
- // Show graphics profiling information while debugging.
- if (Debugger.IsAttached)
- {
- // Display the current frame rate counters.
- Application.Current.Host.Settings.EnableFrameRateCounter = true;
-
- // Show the areas of the app that are being redrawn in each frame.
- //Application.Current.Host.Settings.EnableRedrawRegions = true;
-
- // Enable non-production analysis visualization mode,
- // which shows areas of a page that are handed off to GPU with a colored overlay.
- //Application.Current.Host.Settings.EnableCacheVisualization = true;
-
- // Prevent the screen from turning off while under the debugger by disabling
- // the application's idle detection.
- // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
- // and consume battery power when the user is not using the phone.
- PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
- }
-
- }
-
- // Code to execute when the application is launching (eg, from Start)
- // This code will not execute when the application is reactivated
- private void Application_Launching(object sender, LaunchingEventArgs e)
- {
- }
-
- // Code to execute when the application is activated (brought to foreground)
- // This code will not execute when the application is first launched
- private void Application_Activated(object sender, ActivatedEventArgs e)
- {
- }
-
- // Code to execute when the application is deactivated (sent to background)
- // This code will not execute when the application is closing
- private void Application_Deactivated(object sender, DeactivatedEventArgs e)
- {
- }
-
- // Code to execute when the application is closing (eg, user hit Back)
- // This code will not execute when the application is deactivated
- private void Application_Closing(object sender, ClosingEventArgs e)
- {
- }
-
- // Code to execute if a navigation fails
- private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
- {
- if (Debugger.IsAttached)
- {
- // A navigation has failed; break into the debugger
- Debugger.Break();
- }
- }
-
- // Code to execute on Unhandled Exceptions
- private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
- {
- if (Debugger.IsAttached)
- {
- // An unhandled exception has occurred; break into the debugger
- Debugger.Break();
- }
- }
-
- #region Phone application initialization
-
- // Avoid double-initialization
- private bool phoneApplicationInitialized = false;
-
- // Do not add any additional code to this method
- private void InitializePhoneApplication()
- {
- if (phoneApplicationInitialized)
- return;
-
- // Create the frame but don't set it as RootVisual yet; this allows the splash
- // screen to remain active until the application is ready to render.
- RootFrame = new PhoneApplicationFrame();
- RootFrame.Navigated += CompleteInitializePhoneApplication;
-
- // Handle navigation failures
- RootFrame.NavigationFailed += RootFrame_NavigationFailed;
-
- // Handle reset requests for clearing the backstack
- RootFrame.Navigated += CheckForResetNavigation;
-
- // Ensure we don't initialize again
- phoneApplicationInitialized = true;
- }
-
- // Do not add any additional code to this method
- private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
- {
- // Set the root visual to allow the application to render
- if (RootVisual != RootFrame)
- RootVisual = RootFrame;
-
- // Remove this handler since it is no longer needed
- RootFrame.Navigated -= CompleteInitializePhoneApplication;
- }
-
- private void CheckForResetNavigation(object sender, NavigationEventArgs e)
- {
- // If the app has received a 'reset' navigation, then we need to check
- // on the next navigation to see if the page stack should be reset
- if (e.NavigationMode == NavigationMode.Reset)
- RootFrame.Navigated += ClearBackStackAfterReset;
- }
-
- private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
- {
- // Unregister the event so it doesn't get called again
- RootFrame.Navigated -= ClearBackStackAfterReset;
-
- // Only clear the stack for 'new' (forward) and 'refresh' navigations
- if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh)
- return;
-
- // For UI consistency, clear the entire page stack
- while (RootFrame.RemoveBackEntry() != null)
- {
- ; // do nothing
- }
- }
-
- #endregion
-
- // Initialize the app's font and flow direction as defined in its localized resource strings.
- //
- // To ensure that the font of your application is aligned with its supported languages and that the
- // FlowDirection for each of those languages follows its traditional direction, ResourceLanguage
- // and ResourceFlowDirection should be initialized in each resx file to match these values with that
- // file's culture. For example:
- //
- // AppResources.es-ES.resx
- // ResourceLanguage's value should be "es-ES"
- // ResourceFlowDirection's value should be "LeftToRight"
- //
- // AppResources.ar-SA.resx
- // ResourceLanguage's value should be "ar-SA"
- // ResourceFlowDirection's value should be "RightToLeft"
- //
- // For more info on localizing Windows Phone apps see http://go.microsoft.com/fwlink/?LinkId=262072.
- //
- private void InitializeLanguage()
- {
- try
- {
- // Set the font to match the display language defined by the
- // ResourceLanguage resource string for each supported language.
- //
- // Fall back to the font of the neutral language if the Display
- // language of the phone is not supported.
- //
- // If a compiler error is hit then ResourceLanguage is missing from
- // the resource file.
- RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage);
-
- // Set the FlowDirection of all elements under the root frame based
- // on the ResourceFlowDirection resource string for each
- // supported language.
- //
- // If a compiler error is hit then ResourceFlowDirection is missing from
- // the resource file.
- FlowDirection flow = (FlowDirection)Enum.Parse(typeof(FlowDirection), AppResources.ResourceFlowDirection);
- RootFrame.FlowDirection = flow;
- }
- catch
- {
- // If an exception is caught here it is most likely due to either
- // ResourceLangauge not being correctly set to a supported language
- // code or ResourceFlowDirection is set to a value other than LeftToRight
- // or RightToLeft.
-
- if (Debugger.IsAttached)
- {
- Debugger.Break();
- }
-
- throw;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/AppManifest.xml b/ProjectTemplates/VisualStudio2012/WindowsPhone/AppManifest.xml
deleted file mode 100644
index 6712a117839..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/AppManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/AppResources.Designer.cs b/ProjectTemplates/VisualStudio2012/WindowsPhone/AppResources.Designer.cs
deleted file mode 100644
index 164af5264f4..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/AppResources.Designer.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.17626
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace $safeprojectname$.Resources
-{
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- public class AppResources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal AppResources()
- {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if (object.ReferenceEquals(resourceMan, null))
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("$safeprojectname$.Resources.AppResources", typeof(AppResources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to LeftToRight.
- ///
- public static string ResourceFlowDirection
- {
- get
- {
- return ResourceManager.GetString("ResourceFlowDirection", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to us-EN.
- ///
- public static string ResourceLanguage
- {
- get
- {
- return ResourceManager.GetString("ResourceLanguage", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to MY APPLICATION.
- ///
- public static string ApplicationTitle
- {
- get
- {
- return ResourceManager.GetString("ApplicationTitle", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to button.
- ///
- public static string AppBarButtonText
- {
- get
- {
- return ResourceManager.GetString("AppBarButtonText", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to menu item.
- ///
- public static string AppBarMenuItemText
- {
- get
- {
- return ResourceManager.GetString("AppBarMenuItemText", resourceCulture);
- }
- }
- }
-}
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/AppResources.resx b/ProjectTemplates/VisualStudio2012/WindowsPhone/AppResources.resx
deleted file mode 100644
index 529a19431a7..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/AppResources.resx
+++ /dev/null
@@ -1,137 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- LeftToRight
- Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language
-
-
- en-US
- Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.
-
-
- MY APPLICATION
-
-
- add
-
-
- Menu Item
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/Application.csproj b/ProjectTemplates/VisualStudio2012/WindowsPhone/Application.csproj
deleted file mode 100644
index 3da75db702c..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/Application.csproj
+++ /dev/null
@@ -1,173 +0,0 @@
-
-
-
-
- Debug
- ARM
- 10.0.20506
- 2.0
- $guid1$
- {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
- Library
- Properties
- $safeprojectname$
- $safeprojectname$
- WindowsPhone
- v8.0
- $(TargetFrameworkVersion)
- true
-
-
- true
- true
- $safeprojectname$_$(Configuration)_$(Platform).xap
- Properties\AppManifest.xml
- $safeprojectname$.App
- true
- 11.0
- true
- WindowsPhone8
-
-
- true
- full
- false
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
- true
- true
- prompt
- 4
-
-
- pdbonly
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;SILVERLIGHT;WINDOWS_PHONE
- true
- true
- prompt
- 4
-
-
- true
- full
- false
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
- true
- true
- prompt
- 4
-
-
- pdbonly
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;SILVERLIGHT;WINDOWS_PHONE
- true
- true
- prompt
- 4
-
-
-
- App.xaml
-
-
-
- GamePage.xaml
-
-
-
-
- True
- True
- AppResources.resx
-
-
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
-
-
-
- Designer
-
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
-
-
-
-
- PublicResXFileCodeGenerator
- AppResources.Designer.cs
-
-
-
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\WindowsPhone\ARM\MonoGame.Framework.dll
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\WindowsPhone\x86\MonoGame.Framework.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/ApplicationIcon.png b/ProjectTemplates/VisualStudio2012/WindowsPhone/ApplicationIcon.png
deleted file mode 100644
index 7d95d4e0810..00000000000
Binary files a/ProjectTemplates/VisualStudio2012/WindowsPhone/ApplicationIcon.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/FlipCycleTileLarge.png b/ProjectTemplates/VisualStudio2012/WindowsPhone/FlipCycleTileLarge.png
deleted file mode 100644
index e0c59ac0146..00000000000
Binary files a/ProjectTemplates/VisualStudio2012/WindowsPhone/FlipCycleTileLarge.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/FlipCycleTileMedium.png b/ProjectTemplates/VisualStudio2012/WindowsPhone/FlipCycleTileMedium.png
deleted file mode 100644
index e93b89d6006..00000000000
Binary files a/ProjectTemplates/VisualStudio2012/WindowsPhone/FlipCycleTileMedium.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/FlipCycleTileSmall.png b/ProjectTemplates/VisualStudio2012/WindowsPhone/FlipCycleTileSmall.png
deleted file mode 100644
index 550b1b5e8d0..00000000000
Binary files a/ProjectTemplates/VisualStudio2012/WindowsPhone/FlipCycleTileSmall.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/GamePage.xaml b/ProjectTemplates/VisualStudio2012/WindowsPhone/GamePage.xaml
deleted file mode 100644
index b364f3e424e..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/GamePage.xaml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/GamePage.xaml.cs b/ProjectTemplates/VisualStudio2012/WindowsPhone/GamePage.xaml.cs
deleted file mode 100644
index 3ec6a4a0067..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/GamePage.xaml.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Navigation;
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Shell;
-using Microsoft.Xna.Framework;
-using MonoGame.Framework.WindowsPhone;
-using $safeprojectname$.Resources;
-
-namespace $safeprojectname$
-{
- public partial class GamePage : PhoneApplicationPage
- {
- private Game1 _game;
-
- // Constructor
- public GamePage()
- {
- InitializeComponent();
-
- _game = XamlGame.Create("", this);
-
- // Sample code to localize the ApplicationBar
- //BuildLocalizedApplicationBar();
- }
-
- // Sample code for building a localized ApplicationBar
- //private void BuildLocalizedApplicationBar()
- //{
- // // Set the page's ApplicationBar to a new instance of ApplicationBar.
- // ApplicationBar = new ApplicationBar();
-
- // // Create a new button and set the text value to the localized string from AppResources.
- // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
- // appBarButton.Text = AppResources.AppBarButtonText;
- // ApplicationBar.Buttons.Add(appBarButton);
-
- // // Create a new menu item with the localized string from AppResources.
- // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
- // ApplicationBar.MenuItems.Add(appBarMenuItem);
- //}
- }
-}
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/IconicTileMediumLarge.png b/ProjectTemplates/VisualStudio2012/WindowsPhone/IconicTileMediumLarge.png
deleted file mode 100644
index 686e6b53f03..00000000000
Binary files a/ProjectTemplates/VisualStudio2012/WindowsPhone/IconicTileMediumLarge.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/IconicTileSmall.png b/ProjectTemplates/VisualStudio2012/WindowsPhone/IconicTileSmall.png
deleted file mode 100644
index d4b5ede1b56..00000000000
Binary files a/ProjectTemplates/VisualStudio2012/WindowsPhone/IconicTileSmall.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/LocalizedStrings.cs b/ProjectTemplates/VisualStudio2012/WindowsPhone/LocalizedStrings.cs
deleted file mode 100644
index e8746165111..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/LocalizedStrings.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using $safeprojectname$.Resources;
-
-namespace $safeprojectname$
-{
- ///
- /// Provides access to string resources.
- ///
- public class LocalizedStrings
- {
- private static AppResources _localizedResources = new AppResources();
-
- public AppResources LocalizedResources { get { return _localizedResources; } }
- }
-}
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/MonoGameWindowsPhone.vstemplate b/ProjectTemplates/VisualStudio2012/WindowsPhone/MonoGameWindowsPhone.vstemplate
deleted file mode 100644
index bd855aed128..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/MonoGameWindowsPhone.vstemplate
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
- MonoGame Windows Phone 8 Project
- A MonoGame game project for Windows Phone 8.
- __TemplateIcon.png
- __PreviewImage.png
- MonoGame.CS.WinRT.Game
- WinRT-Managed
- CSharp
- 43140
- true
- Game
- true
- Enabled
- true
- 1
- Windows
- 8
- true
-
-
-
- App.xaml
- App.xaml.cs
- GamePage.xaml
- GamePage.xaml.cs
- Game1.cs
- LocalizedStrings.cs
- AppResources.resx
- AppResources.Designer.cs
- AssemblyInfo.cs
- WMAppManifest.xml
- AppManifest.xml
- AlignmentGrid.png
- ApplicationIcon.png
- FlipCycleTileLarge.png
- FlipCycleTileMedium.png
- FlipCycleTileSmall.png
- IconicTileMediumLarge.png
- IconicTileSmall.png
-
- Content.mgcb
-
-
-
-
- Microsoft.VisualStudio.SmartDevice.ProjectSystem.Base, Version=11.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a
- Microsoft.VisualStudio.SmartDevice.ProjectSystem.Wizards.ProjectTemplateWizard
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/WMAppManifest.xml b/ProjectTemplates/VisualStudio2012/WindowsPhone/WMAppManifest.xml
deleted file mode 100644
index 6d7bb2db800..00000000000
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/WMAppManifest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
- Assets\ApplicationIcon.png
-
-
-
-
-
-
-
-
-
-
-
-
-
- Assets\Tiles\FlipCycleTileSmall.png
- 0
- Assets\Tiles\FlipCycleTileMedium.png
- $safeprojectname$
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/AlignmentGrid.png b/ProjectTemplates/VisualStudio2013/WindowsPhone/AlignmentGrid.png
deleted file mode 100644
index f7d2e97804e..00000000000
Binary files a/ProjectTemplates/VisualStudio2013/WindowsPhone/AlignmentGrid.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/App.xaml b/ProjectTemplates/VisualStudio2013/WindowsPhone/App.xaml
deleted file mode 100644
index 69d106beebf..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/App.xaml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/App.xaml.cs b/ProjectTemplates/VisualStudio2013/WindowsPhone/App.xaml.cs
deleted file mode 100644
index 511774308ee..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/App.xaml.cs
+++ /dev/null
@@ -1,223 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Resources;
-using System.Windows;
-using System.Windows.Markup;
-using System.Windows.Navigation;
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Shell;
-using $safeprojectname$.Resources;
-
-namespace $safeprojectname$
-{
- public partial class App : Application
- {
- ///
- /// Provides easy access to the root frame of the Phone Application.
- ///
- /// The root frame of the Phone Application.
- public static PhoneApplicationFrame RootFrame { get; private set; }
-
- ///
- /// Constructor for the Application object.
- ///
- public App()
- {
- // Global handler for uncaught exceptions.
- UnhandledException += Application_UnhandledException;
-
- // Standard XAML initialization
- InitializeComponent();
-
- // Phone-specific initialization
- InitializePhoneApplication();
-
- // Language display initialization
- InitializeLanguage();
-
- // Show graphics profiling information while debugging.
- if (Debugger.IsAttached)
- {
- // Display the current frame rate counters.
- Application.Current.Host.Settings.EnableFrameRateCounter = true;
-
- // Show the areas of the app that are being redrawn in each frame.
- //Application.Current.Host.Settings.EnableRedrawRegions = true;
-
- // Enable non-production analysis visualization mode,
- // which shows areas of a page that are handed off to GPU with a colored overlay.
- //Application.Current.Host.Settings.EnableCacheVisualization = true;
-
- // Prevent the screen from turning off while under the debugger by disabling
- // the application's idle detection.
- // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
- // and consume battery power when the user is not using the phone.
- PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
- }
-
- }
-
- // Code to execute when the application is launching (eg, from Start)
- // This code will not execute when the application is reactivated
- private void Application_Launching(object sender, LaunchingEventArgs e)
- {
- }
-
- // Code to execute when the application is activated (brought to foreground)
- // This code will not execute when the application is first launched
- private void Application_Activated(object sender, ActivatedEventArgs e)
- {
- }
-
- // Code to execute when the application is deactivated (sent to background)
- // This code will not execute when the application is closing
- private void Application_Deactivated(object sender, DeactivatedEventArgs e)
- {
- }
-
- // Code to execute when the application is closing (eg, user hit Back)
- // This code will not execute when the application is deactivated
- private void Application_Closing(object sender, ClosingEventArgs e)
- {
- }
-
- // Code to execute if a navigation fails
- private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
- {
- if (Debugger.IsAttached)
- {
- // A navigation has failed; break into the debugger
- Debugger.Break();
- }
- }
-
- // Code to execute on Unhandled Exceptions
- private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
- {
- if (Debugger.IsAttached)
- {
- // An unhandled exception has occurred; break into the debugger
- Debugger.Break();
- }
- }
-
- #region Phone application initialization
-
- // Avoid double-initialization
- private bool phoneApplicationInitialized = false;
-
- // Do not add any additional code to this method
- private void InitializePhoneApplication()
- {
- if (phoneApplicationInitialized)
- return;
-
- // Create the frame but don't set it as RootVisual yet; this allows the splash
- // screen to remain active until the application is ready to render.
- RootFrame = new PhoneApplicationFrame();
- RootFrame.Navigated += CompleteInitializePhoneApplication;
-
- // Handle navigation failures
- RootFrame.NavigationFailed += RootFrame_NavigationFailed;
-
- // Handle reset requests for clearing the backstack
- RootFrame.Navigated += CheckForResetNavigation;
-
- // Ensure we don't initialize again
- phoneApplicationInitialized = true;
- }
-
- // Do not add any additional code to this method
- private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
- {
- // Set the root visual to allow the application to render
- if (RootVisual != RootFrame)
- RootVisual = RootFrame;
-
- // Remove this handler since it is no longer needed
- RootFrame.Navigated -= CompleteInitializePhoneApplication;
- }
-
- private void CheckForResetNavigation(object sender, NavigationEventArgs e)
- {
- // If the app has received a 'reset' navigation, then we need to check
- // on the next navigation to see if the page stack should be reset
- if (e.NavigationMode == NavigationMode.Reset)
- RootFrame.Navigated += ClearBackStackAfterReset;
- }
-
- private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
- {
- // Unregister the event so it doesn't get called again
- RootFrame.Navigated -= ClearBackStackAfterReset;
-
- // Only clear the stack for 'new' (forward) and 'refresh' navigations
- if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh)
- return;
-
- // For UI consistency, clear the entire page stack
- while (RootFrame.RemoveBackEntry() != null)
- {
- ; // do nothing
- }
- }
-
- #endregion
-
- // Initialize the app's font and flow direction as defined in its localized resource strings.
- //
- // To ensure that the font of your application is aligned with its supported languages and that the
- // FlowDirection for each of those languages follows its traditional direction, ResourceLanguage
- // and ResourceFlowDirection should be initialized in each resx file to match these values with that
- // file's culture. For example:
- //
- // AppResources.es-ES.resx
- // ResourceLanguage's value should be "es-ES"
- // ResourceFlowDirection's value should be "LeftToRight"
- //
- // AppResources.ar-SA.resx
- // ResourceLanguage's value should be "ar-SA"
- // ResourceFlowDirection's value should be "RightToLeft"
- //
- // For more info on localizing Windows Phone apps see http://go.microsoft.com/fwlink/?LinkId=262072.
- //
- private void InitializeLanguage()
- {
- try
- {
- // Set the font to match the display language defined by the
- // ResourceLanguage resource string for each supported language.
- //
- // Fall back to the font of the neutral language if the Display
- // language of the phone is not supported.
- //
- // If a compiler error is hit then ResourceLanguage is missing from
- // the resource file.
- RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage);
-
- // Set the FlowDirection of all elements under the root frame based
- // on the ResourceFlowDirection resource string for each
- // supported language.
- //
- // If a compiler error is hit then ResourceFlowDirection is missing from
- // the resource file.
- FlowDirection flow = (FlowDirection)Enum.Parse(typeof(FlowDirection), AppResources.ResourceFlowDirection);
- RootFrame.FlowDirection = flow;
- }
- catch
- {
- // If an exception is caught here it is most likely due to either
- // ResourceLangauge not being correctly set to a supported language
- // code or ResourceFlowDirection is set to a value other than LeftToRight
- // or RightToLeft.
-
- if (Debugger.IsAttached)
- {
- Debugger.Break();
- }
-
- throw;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/AppManifest.xml b/ProjectTemplates/VisualStudio2013/WindowsPhone/AppManifest.xml
deleted file mode 100644
index 6712a117839..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/AppManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/AppResources.Designer.cs b/ProjectTemplates/VisualStudio2013/WindowsPhone/AppResources.Designer.cs
deleted file mode 100644
index 164af5264f4..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/AppResources.Designer.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.17626
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace $safeprojectname$.Resources
-{
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- public class AppResources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal AppResources()
- {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if (object.ReferenceEquals(resourceMan, null))
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("$safeprojectname$.Resources.AppResources", typeof(AppResources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to LeftToRight.
- ///
- public static string ResourceFlowDirection
- {
- get
- {
- return ResourceManager.GetString("ResourceFlowDirection", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to us-EN.
- ///
- public static string ResourceLanguage
- {
- get
- {
- return ResourceManager.GetString("ResourceLanguage", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to MY APPLICATION.
- ///
- public static string ApplicationTitle
- {
- get
- {
- return ResourceManager.GetString("ApplicationTitle", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to button.
- ///
- public static string AppBarButtonText
- {
- get
- {
- return ResourceManager.GetString("AppBarButtonText", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to menu item.
- ///
- public static string AppBarMenuItemText
- {
- get
- {
- return ResourceManager.GetString("AppBarMenuItemText", resourceCulture);
- }
- }
- }
-}
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/AppResources.resx b/ProjectTemplates/VisualStudio2013/WindowsPhone/AppResources.resx
deleted file mode 100644
index 529a19431a7..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/AppResources.resx
+++ /dev/null
@@ -1,137 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- LeftToRight
- Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language
-
-
- en-US
- Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.
-
-
- MY APPLICATION
-
-
- add
-
-
- Menu Item
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/Application.csproj b/ProjectTemplates/VisualStudio2013/WindowsPhone/Application.csproj
deleted file mode 100644
index fadd81f089e..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/Application.csproj
+++ /dev/null
@@ -1,167 +0,0 @@
-
-
-
-
- Debug
- ARM
- 10.0.20506
- 2.0
- $guid1$
- {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
- Library
- Properties
- $safeprojectname$
- $safeprojectname$
- WindowsPhone
- v8.0
- $(TargetFrameworkVersion)
- true
-
-
- true
- true
- $safeprojectname$_$(Configuration)_$(Platform).xap
- Properties\AppManifest.xml
- $safeprojectname$.App
- true
- 11.0
- true
- WindowsPhone8
-
-
- true
- full
- false
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
- true
- true
- prompt
- 4
-
-
- pdbonly
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;SILVERLIGHT;WINDOWS_PHONE
- true
- true
- prompt
- 4
-
-
- true
- full
- false
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
- true
- true
- prompt
- 4
-
-
- pdbonly
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;SILVERLIGHT;WINDOWS_PHONE
- true
- true
- prompt
- 4
-
-
-
- App.xaml
-
-
-
- GamePage.xaml
-
-
-
-
- True
- True
- AppResources.resx
-
-
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
-
-
-
- Designer
-
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
-
-
-
-
- PublicResXFileCodeGenerator
- AppResources.Designer.cs
-
-
-
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\WindowsPhone\ARM\MonoGame.Framework.dll
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\WindowsPhone\x86\MonoGame.Framework.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/ApplicationIcon.png b/ProjectTemplates/VisualStudio2013/WindowsPhone/ApplicationIcon.png
deleted file mode 100644
index 7d95d4e0810..00000000000
Binary files a/ProjectTemplates/VisualStudio2013/WindowsPhone/ApplicationIcon.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/FlipCycleTileLarge.png b/ProjectTemplates/VisualStudio2013/WindowsPhone/FlipCycleTileLarge.png
deleted file mode 100644
index e0c59ac0146..00000000000
Binary files a/ProjectTemplates/VisualStudio2013/WindowsPhone/FlipCycleTileLarge.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/FlipCycleTileMedium.png b/ProjectTemplates/VisualStudio2013/WindowsPhone/FlipCycleTileMedium.png
deleted file mode 100644
index e93b89d6006..00000000000
Binary files a/ProjectTemplates/VisualStudio2013/WindowsPhone/FlipCycleTileMedium.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/FlipCycleTileSmall.png b/ProjectTemplates/VisualStudio2013/WindowsPhone/FlipCycleTileSmall.png
deleted file mode 100644
index 550b1b5e8d0..00000000000
Binary files a/ProjectTemplates/VisualStudio2013/WindowsPhone/FlipCycleTileSmall.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/GamePage.xaml b/ProjectTemplates/VisualStudio2013/WindowsPhone/GamePage.xaml
deleted file mode 100644
index b364f3e424e..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/GamePage.xaml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/GamePage.xaml.cs b/ProjectTemplates/VisualStudio2013/WindowsPhone/GamePage.xaml.cs
deleted file mode 100644
index 3ec6a4a0067..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/GamePage.xaml.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Navigation;
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Shell;
-using Microsoft.Xna.Framework;
-using MonoGame.Framework.WindowsPhone;
-using $safeprojectname$.Resources;
-
-namespace $safeprojectname$
-{
- public partial class GamePage : PhoneApplicationPage
- {
- private Game1 _game;
-
- // Constructor
- public GamePage()
- {
- InitializeComponent();
-
- _game = XamlGame.Create("", this);
-
- // Sample code to localize the ApplicationBar
- //BuildLocalizedApplicationBar();
- }
-
- // Sample code for building a localized ApplicationBar
- //private void BuildLocalizedApplicationBar()
- //{
- // // Set the page's ApplicationBar to a new instance of ApplicationBar.
- // ApplicationBar = new ApplicationBar();
-
- // // Create a new button and set the text value to the localized string from AppResources.
- // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
- // appBarButton.Text = AppResources.AppBarButtonText;
- // ApplicationBar.Buttons.Add(appBarButton);
-
- // // Create a new menu item with the localized string from AppResources.
- // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
- // ApplicationBar.MenuItems.Add(appBarMenuItem);
- //}
- }
-}
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/IconicTileMediumLarge.png b/ProjectTemplates/VisualStudio2013/WindowsPhone/IconicTileMediumLarge.png
deleted file mode 100644
index 686e6b53f03..00000000000
Binary files a/ProjectTemplates/VisualStudio2013/WindowsPhone/IconicTileMediumLarge.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/IconicTileSmall.png b/ProjectTemplates/VisualStudio2013/WindowsPhone/IconicTileSmall.png
deleted file mode 100644
index d4b5ede1b56..00000000000
Binary files a/ProjectTemplates/VisualStudio2013/WindowsPhone/IconicTileSmall.png and /dev/null differ
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/LocalizedStrings.cs b/ProjectTemplates/VisualStudio2013/WindowsPhone/LocalizedStrings.cs
deleted file mode 100644
index e8746165111..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/LocalizedStrings.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using $safeprojectname$.Resources;
-
-namespace $safeprojectname$
-{
- ///
- /// Provides access to string resources.
- ///
- public class LocalizedStrings
- {
- private static AppResources _localizedResources = new AppResources();
-
- public AppResources LocalizedResources { get { return _localizedResources; } }
- }
-}
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/MonoGameWindowsPhone.vstemplate b/ProjectTemplates/VisualStudio2013/WindowsPhone/MonoGameWindowsPhone.vstemplate
deleted file mode 100644
index d2c38e99aa8..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/MonoGameWindowsPhone.vstemplate
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
- MonoGame Windows Phone 8 Project
- A MonoGame game project for Windows Phone 8.
- __TemplateIcon.png
- __PreviewImage.png
- MonoGame.CS.WinRT.Game
- WinRT-Managed
- CSharp
- 43140
- true
- Game
- true
- Enabled
- true
- 1
- Windows
- 8
- true
-
-
-
- App.xaml
- App.xaml.cs
- GamePage.xaml
- GamePage.xaml.cs
- Game1.cs
- LocalizedStrings.cs
- AppResources.resx
- AppResources.Designer.cs
- AssemblyInfo.cs
- WMAppManifest.xml
- AppManifest.xml
- AlignmentGrid.png
- ApplicationIcon.png
- FlipCycleTileLarge.png
- FlipCycleTileMedium.png
- FlipCycleTileSmall.png
- IconicTileMediumLarge.png
- IconicTileSmall.png
-
- Content.mgcb
-
-
-
-
- Microsoft.VisualStudio.SmartDevice.ProjectSystem.Base, Version=12.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a
- Microsoft.VisualStudio.SmartDevice.ProjectSystem.Wizards.ProjectTemplateWizard
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/WMAppManifest.xml b/ProjectTemplates/VisualStudio2013/WindowsPhone/WMAppManifest.xml
deleted file mode 100644
index 6d7bb2db800..00000000000
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/WMAppManifest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
- Assets\ApplicationIcon.png
-
-
-
-
-
-
-
-
-
-
-
-
-
- Assets\Tiles\FlipCycleTileSmall.png
- 0
- Assets\Tiles\FlipCycleTileMedium.png
- $safeprojectname$
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2013/WindowsStore/Application.csproj b/ProjectTemplates/VisualStudio2013/WindowsStore/Application.csproj
index acc5cf6b945..f1d16934dba 100644
--- a/ProjectTemplates/VisualStudio2013/WindowsStore/Application.csproj
+++ b/ProjectTemplates/VisualStudio2013/WindowsStore/Application.csproj
@@ -17,7 +17,8 @@
$projectname$_TemporaryKey.pfx
$endif$
WindowsStoreApp
- v4.5.1
+ 8.1
+ 12
AnyCPU
diff --git a/ProjectTemplates/VisualStudio2013/WindowsStore/MonoGameWindowsStore.vstemplate b/ProjectTemplates/VisualStudio2013/WindowsStore/MonoGameWindowsStore.vstemplate
index 3fa9a47f345..29d47f7f8d7 100644
--- a/ProjectTemplates/VisualStudio2013/WindowsStore/MonoGameWindowsStore.vstemplate
+++ b/ProjectTemplates/VisualStudio2013/WindowsStore/MonoGameWindowsStore.vstemplate
@@ -16,7 +16,7 @@
true
1
Windows
- 8
+ 8.1
true
diff --git a/ProjectTemplates/VisualStudio2013/WindowsStore/Package-managed.appxmanifest b/ProjectTemplates/VisualStudio2013/WindowsStore/Package-managed.appxmanifest
index 19a105899a3..2eea6942d5c 100644
--- a/ProjectTemplates/VisualStudio2013/WindowsStore/Package-managed.appxmanifest
+++ b/ProjectTemplates/VisualStudio2013/WindowsStore/Package-managed.appxmanifest
@@ -1,5 +1,5 @@

-
+
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/Application.csproj b/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/Application.csproj
index eb3a41cdfba..3d42706100f 100644
--- a/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/Application.csproj
+++ b/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/Application.csproj
@@ -17,7 +17,8 @@
$projectname$_TemporaryKey.pfx
$endif$
WindowsStoreApp
- v4.5.1
+ 8.1
+ 12
AnyCPU
diff --git a/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/MonoGameWindowsStoreXaml.vstemplate b/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/MonoGameWindowsStoreXaml.vstemplate
index 11b242547d4..957a5942ad6 100644
--- a/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/MonoGameWindowsStoreXaml.vstemplate
+++ b/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/MonoGameWindowsStoreXaml.vstemplate
@@ -16,7 +16,7 @@
true
1
Windows
- 8
+ 8.1
true
diff --git a/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/Package-managed.appxmanifest b/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/Package-managed.appxmanifest
index 19a105899a3..2eea6942d5c 100644
--- a/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/Package-managed.appxmanifest
+++ b/ProjectTemplates/VisualStudio2013/WindowsStoreXaml/Package-managed.appxmanifest
@@ -1,5 +1,5 @@

-
+
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStore/Application.csproj b/ProjectTemplates/VisualStudio2015/WindowsStore/Application.csproj
new file mode 100644
index 00000000000..35d16ad29ad
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStore/Application.csproj
@@ -0,0 +1,169 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ $guid1$
+ AppContainerExe
+ Properties
+ $safeprojectname$
+ $projectname$
+ $currentuiculturename$
+ 512
+ {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ $if$($includeKeyFile$==true)
+ $projectname$_TemporaryKey.pfx
+ $endif$
+ WindowsStoreApp
+ 8.1
+ 12
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE
+ prompt
+ 4
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+
+
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\MonoGame.Framework.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.XInput.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.Direct2D1.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.Direct3D11.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.DXGI.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.MediaFoundation.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.XAudio2.dll
+
+
+
+
+
+
+
+
+
+ Designer
+
+ $if$($includeKeyFile$==true)
+
+ $endif$
+
+
+
+
+
+
+
+
+
+
+
+ 12.0
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Application_TemporaryKey.pfx b/ProjectTemplates/VisualStudio2015/WindowsStore/Application_TemporaryKey.pfx
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Application_TemporaryKey.pfx
rename to ProjectTemplates/VisualStudio2015/WindowsStore/Application_TemporaryKey.pfx
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/AssemblyInfo.cs b/ProjectTemplates/VisualStudio2015/WindowsStore/AssemblyInfo.cs
similarity index 87%
rename from ProjectTemplates/VisualStudio2013/WindowsPhone/AssemblyInfo.cs
rename to ProjectTemplates/VisualStudio2015/WindowsStore/AssemblyInfo.cs
index 10f05e1a3dd..34324b374f1 100644
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/AssemblyInfo.cs
+++ b/ProjectTemplates/VisualStudio2015/WindowsStore/AssemblyInfo.cs
@@ -1,7 +1,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Resources;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
@@ -20,9 +19,6 @@
// 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("$guid2$")]
-
// Version information for an assembly consists of the following four values:
//
// Major Version
@@ -35,4 +31,3 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
-[assembly: NeutralResourcesLanguageAttribute("en-US")]
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Content/Content.mgcb b/ProjectTemplates/VisualStudio2015/WindowsStore/Content/Content.mgcb
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Content/Content.mgcb
rename to ProjectTemplates/VisualStudio2015/WindowsStore/Content/Content.mgcb
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/Game1.cs b/ProjectTemplates/VisualStudio2015/WindowsStore/Game1.cs
similarity index 100%
rename from ProjectTemplates/VisualStudio2012/WindowsPhone/Game1.cs
rename to ProjectTemplates/VisualStudio2015/WindowsStore/Game1.cs
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStore/Logo.png b/ProjectTemplates/VisualStudio2015/WindowsStore/Logo.png
new file mode 100644
index 00000000000..e26771cb33a
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsStore/Logo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStore/MonoGameWindowsStore.vstemplate b/ProjectTemplates/VisualStudio2015/WindowsStore/MonoGameWindowsStore.vstemplate
new file mode 100644
index 00000000000..10b2b719156
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStore/MonoGameWindowsStore.vstemplate
@@ -0,0 +1,42 @@
+
+
+
+ MonoGame Windows Store Project
+ A MonoGame game project for the Windows Store.
+ __TemplateIcon.png
+ __PreviewImage.png
+ MonoGame.CS.WinRT.Game
+ WinRT-Managed
+ CSharp
+ 43120
+ true
+ Game
+ true
+ Enabled
+ true
+ 1
+ Windows
+ 8.1
+ true
+
+
+
+ Program.cs
+ Game1.cs
+ AssemblyInfo.cs
+ Package-managed.appxmanifest
+ Logo.png
+ SmallLogo.png
+ SplashScreen.png
+ StoreLogo.png
+ Application_TemporaryKey.pfx
+
+ Content.mgcb
+
+
+
+
+ Microsoft.VisualStudio.WinRT.TemplateWizards, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard
+
+
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStore/Package-managed.appxmanifest b/ProjectTemplates/VisualStudio2015/WindowsStore/Package-managed.appxmanifest
new file mode 100644
index 00000000000..2eea6942d5c
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStore/Package-managed.appxmanifest
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+ $projectname$
+ $XmlEscapedPublisher$
+ Assets\StoreLogo.png
+
+
+
+ 6.2.1
+ 6.2.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStore/Program.cs b/ProjectTemplates/VisualStudio2015/WindowsStore/Program.cs
new file mode 100644
index 00000000000..43da881a911
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStore/Program.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace $safeprojectname$
+{
+ ///
+ /// The main class.
+ ///
+ public static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ static void Main()
+ {
+ var factory = new MonoGame.Framework.GameFrameworkViewSource();
+ Windows.ApplicationModel.Core.CoreApplication.Run(factory);
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStore/SmallLogo.png b/ProjectTemplates/VisualStudio2015/WindowsStore/SmallLogo.png
new file mode 100644
index 00000000000..1eb0d9d528c
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsStore/SmallLogo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStore/SplashScreen.png b/ProjectTemplates/VisualStudio2015/WindowsStore/SplashScreen.png
new file mode 100644
index 00000000000..c951e031bdf
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsStore/SplashScreen.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStore/StoreLogo.png b/ProjectTemplates/VisualStudio2015/WindowsStore/StoreLogo.png
new file mode 100644
index 00000000000..dcb672712c6
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsStore/StoreLogo.png differ
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/__PreviewImage.png b/ProjectTemplates/VisualStudio2015/WindowsStore/__PreviewImage.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2010/OUYA/__PreviewImage.png
rename to ProjectTemplates/VisualStudio2015/WindowsStore/__PreviewImage.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/__TemplateIcon.png b/ProjectTemplates/VisualStudio2015/WindowsStore/__TemplateIcon.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/__TemplateIcon.png
rename to ProjectTemplates/VisualStudio2015/WindowsStore/__TemplateIcon.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/App.xaml b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/App.xaml
new file mode 100644
index 00000000000..5f935d64d2c
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/App.xaml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/App.xaml.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/App.xaml.cs
new file mode 100644
index 00000000000..53759c0bed0
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/App.xaml.cs
@@ -0,0 +1,70 @@
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.UI.Xaml;
+
+// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227
+
+namespace $safeprojectname$
+{
+ ///
+ /// Provides application-specific behavior to supplement the default Application class.
+ ///
+ sealed partial class App : Application
+ {
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ public App()
+ {
+ InitializeComponent();
+ Suspending += OnSuspending;
+ }
+
+ ///
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used when the application is launched to open a specific file, to display
+ /// search results, and so forth.
+ ///
+ /// Details about the launch request and process.
+ protected override void OnLaunched(LaunchActivatedEventArgs args)
+ {
+ var gamePage = Window.Current.Content as GamePage;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (gamePage == null)
+ {
+ // Create a main GamePage
+ gamePage = new GamePage(args);
+
+ if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
+ {
+ // TODO: Load state from previously suspended application
+ }
+
+ // Place the GamePage in the current Window
+ Window.Current.Content = gamePage;
+ }
+
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+
+ ///
+ /// Invoked when application execution is being suspended. Application state is saved
+ /// without knowing whether the application will be terminated or resumed with the contents
+ /// of memory still intact.
+ ///
+ /// The source of the suspend request.
+ /// Details about the suspend request.
+ private void OnSuspending(object sender, SuspendingEventArgs e)
+ {
+ var deferral = e.SuspendingOperation.GetDeferral();
+
+ // TODO: Save application state and stop any background activity
+
+ deferral.Complete();
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Application.csproj b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Application.csproj
new file mode 100644
index 00000000000..b53e5626ade
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Application.csproj
@@ -0,0 +1,188 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ $guid1$
+ AppContainerExe
+ Properties
+ $safeprojectname$
+ $projectname$
+ $currentuiculturename$
+ 512
+ {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ $if$($includeKeyFile$==true)
+ $projectname$_TemporaryKey.pfx
+ $endif$
+ WindowsStoreApp
+ 8.1
+ 12
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE
+ prompt
+ 4
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+
+
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\MonoGame.Framework.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.XInput.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.Direct2D1.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.Direct3D11.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.DXGI.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.MediaFoundation.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\SharpDX.XAudio2.dll
+
+
+
+
+ App.xaml
+
+
+ GamePage.xaml
+
+
+
+
+
+
+ Designer
+
+ $if$($includeKeyFile$==true)
+
+ $endif$
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+ 12.0
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Application_TemporaryKey.pfx b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Application_TemporaryKey.pfx
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/AssemblyInfo.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/AssemblyInfo.cs
similarity index 87%
rename from ProjectTemplates/VisualStudio2012/WindowsPhone/AssemblyInfo.cs
rename to ProjectTemplates/VisualStudio2015/WindowsStoreXaml/AssemblyInfo.cs
index 10f05e1a3dd..34324b374f1 100644
--- a/ProjectTemplates/VisualStudio2012/WindowsPhone/AssemblyInfo.cs
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/AssemblyInfo.cs
@@ -1,7 +1,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Resources;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
@@ -20,9 +19,6 @@
// 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("$guid2$")]
-
// Version information for an assembly consists of the following four values:
//
// Major Version
@@ -35,4 +31,3 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
-[assembly: NeutralResourcesLanguageAttribute("en-US")]
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/BindableBase.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/BindableBase.cs
new file mode 100644
index 00000000000..358d71b6dbb
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/BindableBase.cs
@@ -0,0 +1,55 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using Windows.UI.Xaml.Data;
+
+namespace $safeprojectname$.Common
+{
+ ///
+ /// Implementation of to simplify models.
+ ///
+ [Windows.Foundation.Metadata.WebHostHidden]
+ public abstract class BindableBase : INotifyPropertyChanged
+ {
+ ///
+ /// Multicast event for property change notifications.
+ ///
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ ///
+ /// Checks if a property already matches a desired value. Sets the property and
+ /// notifies listeners only when necessary.
+ ///
+ /// Type of the property.
+ /// Reference to a property with both getter and setter.
+ /// Desired value for the property.
+ /// Name of the property used to notify listeners. This
+ /// value is optional and can be provided automatically when invoked from compilers that
+ /// support CallerMemberName.
+ /// True if the value was changed, false if the existing value matched the
+ /// desired value.
+ protected bool SetProperty(ref T storage, T value, [CallerMemberName] String propertyName = null)
+ {
+ if (object.Equals(storage, value)) return false;
+
+ storage = value;
+ this.OnPropertyChanged(propertyName);
+ return true;
+ }
+
+ ///
+ /// Notifies listeners that a property value has changed.
+ ///
+ /// Name of the property used to notify listeners. This
+ /// value is optional and can be provided automatically when invoked from compilers
+ /// that support .
+ protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ var eventHandler = this.PropertyChanged;
+ if (eventHandler != null)
+ {
+ eventHandler(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/BooleanNegationConverter.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/BooleanNegationConverter.cs
new file mode 100644
index 00000000000..e415a1a8a9a
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/BooleanNegationConverter.cs
@@ -0,0 +1,21 @@
+using System;
+using Windows.UI.Xaml.Data;
+
+namespace $safeprojectname$.Common
+{
+ ///
+ /// Value converter that translates true to false and vice versa.
+ ///
+ public sealed class BooleanNegationConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, string language)
+ {
+ return !(value is bool && (bool)value);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language)
+ {
+ return !(value is bool && (bool)value);
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/BooleanToVisibilityConverter.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/BooleanToVisibilityConverter.cs
new file mode 100644
index 00000000000..b770942f746
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/BooleanToVisibilityConverter.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.Graphics.Display;
+using Windows.UI.ViewManagement;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Data;
+
+namespace $safeprojectname$.Common
+{
+ ///
+ /// Value converter that translates true to and false to
+ /// .
+ ///
+ public sealed class BooleanToVisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, string language)
+ {
+ return (value is bool && (bool)value) ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language)
+ {
+ return value is Visibility && (Visibility)value == Visibility.Visible;
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/Content/Content.mgcb b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Content/Content.mgcb
similarity index 92%
rename from ProjectTemplates/VisualStudio2013/WindowsPhone/Content/Content.mgcb
rename to ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Content/Content.mgcb
index 73054a959b7..a7026da36bd 100644
--- a/ProjectTemplates/VisualStudio2013/WindowsPhone/Content/Content.mgcb
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Content/Content.mgcb
@@ -3,7 +3,7 @@
/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
-/platform:WindowsPhone8
+/platform:WindowsStoreApp
/config:
/profile:Reach
/compress:False
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/Game1.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Game1.cs
similarity index 100%
rename from ProjectTemplates/VisualStudio2013/WindowsPhone/Game1.cs
rename to ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Game1.cs
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/GamePage.xaml b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/GamePage.xaml
new file mode 100644
index 00000000000..43f039d5b83
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/GamePage.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/GamePage.xaml.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/GamePage.xaml.cs
new file mode 100644
index 00000000000..b76477aafd2
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/GamePage.xaml.cs
@@ -0,0 +1,24 @@
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using MonoGame.Framework;
+using Windows.ApplicationModel.Activation;
+
+
+namespace $safeprojectname$
+{
+ ///
+ /// The root page used to display the game.
+ ///
+ public sealed partial class GamePage : SwapChainBackgroundPanel
+ {
+ readonly Game1 _game;
+
+ public GamePage(LaunchActivatedEventArgs args)
+ {
+ this.InitializeComponent();
+
+ // Create the game.
+ _game = XamlGame.Create(args, Window.Current.CoreWindow, this);
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/LayoutAwarePage.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/LayoutAwarePage.cs
new file mode 100644
index 00000000000..157fae2c350
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/LayoutAwarePage.cs
@@ -0,0 +1,543 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.System;
+using Windows.UI.Core;
+using Windows.UI.ViewManagement;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Navigation;
+
+namespace $safeprojectname$.Common
+{
+ ///
+ /// Typical implementation of Page that provides several important conveniences:
+ ///
+ /// -
+ ///
Application view state to visual state mapping
+ ///
+ /// -
+ ///
GoBack, GoForward, and GoHome event handlers
+ ///
+ /// -
+ ///
Mouse and keyboard shortcuts for navigation
+ ///
+ /// -
+ ///
State management for navigation and process lifetime management
+ ///
+ /// -
+ ///
A default view model
+ ///
+ ///
+ ///
+ [Windows.Foundation.Metadata.WebHostHidden]
+ public class LayoutAwarePage : Page
+ {
+ ///
+ /// Identifies the dependency property.
+ ///
+ public static readonly DependencyProperty DefaultViewModelProperty =
+ DependencyProperty.Register("DefaultViewModel", typeof(IObservableMap),
+ typeof(LayoutAwarePage), null);
+
+ private List _layoutAwareControls;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public LayoutAwarePage()
+ {
+ if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) return;
+
+ // Create an empty default view model
+ this.DefaultViewModel = new ObservableDictionary();
+
+ // When this page is part of the visual tree make two changes:
+ // 1) Map application view state to visual state for the page
+ // 2) Handle keyboard and mouse navigation requests
+ this.Loaded += (sender, e) =>
+ {
+ this.StartLayoutUpdates(sender, e);
+
+ // Keyboard and mouse navigation only apply when occupying the entire window
+ if (this.ActualHeight == Window.Current.Bounds.Height &&
+ this.ActualWidth == Window.Current.Bounds.Width)
+ {
+ // Listen to the window directly so focus isn't required
+ Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
+ CoreDispatcher_AcceleratorKeyActivated;
+ Window.Current.CoreWindow.PointerPressed +=
+ this.CoreWindow_PointerPressed;
+ }
+ };
+
+ // Undo the same changes when the page is no longer visible
+ this.Unloaded += (sender, e) =>
+ {
+ this.StopLayoutUpdates(sender, e);
+ Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
+ CoreDispatcher_AcceleratorKeyActivated;
+ Window.Current.CoreWindow.PointerPressed -=
+ this.CoreWindow_PointerPressed;
+ };
+ }
+
+ ///
+ /// An implementation of designed to be
+ /// used as a trivial view model.
+ ///
+ protected IObservableMap DefaultViewModel
+ {
+ get
+ {
+ return this.GetValue(DefaultViewModelProperty) as IObservableMap;
+ }
+
+ set
+ {
+ this.SetValue(DefaultViewModelProperty, value);
+ }
+ }
+
+ #region Navigation support
+
+ ///
+ /// Invoked as an event handler to navigate backward in the page's associated
+ /// until it reaches the top of the navigation stack.
+ ///
+ /// Instance that triggered the event.
+ /// Event data describing the conditions that led to the event.
+ protected virtual void GoHome(object sender, RoutedEventArgs e)
+ {
+ // Use the navigation frame to return to the topmost page
+ if (this.Frame != null)
+ {
+ while (this.Frame.CanGoBack) this.Frame.GoBack();
+ }
+ }
+
+ ///
+ /// Invoked as an event handler to navigate backward in the navigation stack
+ /// associated with this page's .
+ ///
+ /// Instance that triggered the event.
+ /// Event data describing the conditions that led to the
+ /// event.
+ protected virtual void GoBack(object sender, RoutedEventArgs e)
+ {
+ // Use the navigation frame to return to the previous page
+ if (this.Frame != null && this.Frame.CanGoBack) this.Frame.GoBack();
+ }
+
+ ///
+ /// Invoked as an event handler to navigate forward in the navigation stack
+ /// associated with this page's .
+ ///
+ /// Instance that triggered the event.
+ /// Event data describing the conditions that led to the
+ /// event.
+ protected virtual void GoForward(object sender, RoutedEventArgs e)
+ {
+ // Use the navigation frame to move to the next page
+ if (this.Frame != null && this.Frame.CanGoForward) this.Frame.GoForward();
+ }
+
+ ///
+ /// Invoked on every keystroke, including system keys such as Alt key combinations, when
+ /// this page is active and occupies the entire window. Used to detect keyboard navigation
+ /// between pages even when the page itself doesn't have focus.
+ ///
+ /// Instance that triggered the event.
+ /// Event data describing the conditions that led to the event.
+ private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender,
+ AcceleratorKeyEventArgs args)
+ {
+ var virtualKey = args.VirtualKey;
+
+ // Only investigate further when Left, Right, or the dedicated Previous or Next keys
+ // are pressed
+ if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
+ args.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
+ (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right ||
+ (int)virtualKey == 166 || (int)virtualKey == 167))
+ {
+ var coreWindow = Window.Current.CoreWindow;
+ var downState = CoreVirtualKeyStates.Down;
+ bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
+ bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
+ bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
+ bool noModifiers = !menuKey && !controlKey && !shiftKey;
+ bool onlyAlt = menuKey && !controlKey && !shiftKey;
+
+ if (((int)virtualKey == 166 && noModifiers) ||
+ (virtualKey == VirtualKey.Left && onlyAlt))
+ {
+ // When the previous key or Alt+Left are pressed navigate back
+ args.Handled = true;
+ this.GoBack(this, new RoutedEventArgs());
+ }
+ else if (((int)virtualKey == 167 && noModifiers) ||
+ (virtualKey == VirtualKey.Right && onlyAlt))
+ {
+ // When the next key or Alt+Right are pressed navigate forward
+ args.Handled = true;
+ this.GoForward(this, new RoutedEventArgs());
+ }
+ }
+ }
+
+ ///
+ /// Invoked on every mouse click, touch screen tap, or equivalent interaction when this
+ /// page is active and occupies the entire window. Used to detect browser-style next and
+ /// previous mouse button clicks to navigate between pages.
+ ///
+ /// Instance that triggered the event.
+ /// Event data describing the conditions that led to the event.
+ private void CoreWindow_PointerPressed(CoreWindow sender,
+ PointerEventArgs args)
+ {
+ var properties = args.CurrentPoint.Properties;
+
+ // Ignore button chords with the left, right, and middle buttons
+ if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed ||
+ properties.IsMiddleButtonPressed) return;
+
+ // If back or foward are pressed (but not both) navigate appropriately
+ bool backPressed = properties.IsXButton1Pressed;
+ bool forwardPressed = properties.IsXButton2Pressed;
+ if (backPressed ^ forwardPressed)
+ {
+ args.Handled = true;
+ if (backPressed) this.GoBack(this, new RoutedEventArgs());
+ if (forwardPressed) this.GoForward(this, new RoutedEventArgs());
+ }
+ }
+
+ #endregion
+
+ #region Visual state switching
+
+ ///
+ /// Invoked as an event handler, typically on the
+ /// event of a within the page, to indicate that the sender should
+ /// start receiving visual state management changes that correspond to application view
+ /// state changes.
+ ///
+ /// Instance of that supports visual state
+ /// management corresponding to view states.
+ /// Event data that describes how the request was made.
+ /// The current view state will immediately be used to set the corresponding
+ /// visual state when layout updates are requested. A corresponding
+ /// event handler connected to
+ /// is strongly encouraged. Instances of
+ /// automatically invoke these handlers in their Loaded and
+ /// Unloaded events.
+ ///
+ ///
+ public void StartLayoutUpdates(object sender, RoutedEventArgs e)
+ {
+ var control = sender as Control;
+ if (control == null) return;
+ if (this._layoutAwareControls == null)
+ {
+ // Start listening to view state changes when there are controls interested in updates
+ Window.Current.SizeChanged += this.WindowSizeChanged;
+ this._layoutAwareControls = new List();
+ }
+ this._layoutAwareControls.Add(control);
+
+ // Set the initial visual state of the control
+ VisualStateManager.GoToState(control, DetermineVisualState(ApplicationView.Value), false);
+ }
+
+ private void WindowSizeChanged(object sender, WindowSizeChangedEventArgs e)
+ {
+ this.InvalidateVisualState();
+ }
+
+ ///
+ /// Invoked as an event handler, typically on the
+ /// event of a , to indicate that the sender should start receiving
+ /// visual state management changes that correspond to application view state changes.
+ ///
+ /// Instance of that supports visual state
+ /// management corresponding to view states.
+ /// Event data that describes how the request was made.
+ /// The current view state will immediately be used to set the corresponding
+ /// visual state when layout updates are requested.
+ ///
+ public void StopLayoutUpdates(object sender, RoutedEventArgs e)
+ {
+ var control = sender as Control;
+ if (control == null || this._layoutAwareControls == null) return;
+ this._layoutAwareControls.Remove(control);
+ if (this._layoutAwareControls.Count == 0)
+ {
+ // Stop listening to view state changes when no controls are interested in updates
+ this._layoutAwareControls = null;
+ Window.Current.SizeChanged -= this.WindowSizeChanged;
+ }
+ }
+
+ ///
+ /// Translates values into strings for visual state
+ /// management within the page. The default implementation uses the names of enum values.
+ /// Subclasses may override this method to control the mapping scheme used.
+ ///
+ /// View state for which a visual state is desired.
+ /// Visual state name used to drive the
+ ///
+ ///
+ protected virtual string DetermineVisualState(ApplicationViewState viewState)
+ {
+ return viewState.ToString();
+ }
+
+ ///
+ /// Updates all controls that are listening for visual state changes with the correct
+ /// visual state.
+ ///
+ ///
+ /// Typically used in conjunction with overriding to
+ /// signal that a different value may be returned even though the view state has not
+ /// changed.
+ ///
+ public void InvalidateVisualState()
+ {
+ if (this._layoutAwareControls != null)
+ {
+ string visualState = DetermineVisualState(ApplicationView.Value);
+ foreach (var layoutAwareControl in this._layoutAwareControls)
+ {
+ VisualStateManager.GoToState(layoutAwareControl, visualState, false);
+ }
+ }
+ }
+
+ #endregion
+
+ #region Process lifetime management
+
+ private String _pageKey;
+
+ ///
+ /// Invoked when this page is about to be displayed in a Frame.
+ ///
+ /// Event data that describes how this page was reached. The Parameter
+ /// property provides the group to be displayed.
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ // Returning to a cached page through navigation shouldn't trigger state loading
+ if (this._pageKey != null) return;
+
+ var frameState = SuspensionManager.SessionStateForFrame(this.Frame);
+ this._pageKey = "Page-" + this.Frame.BackStackDepth;
+
+ if (e.NavigationMode == NavigationMode.New)
+ {
+ // Clear existing state for forward navigation when adding a new page to the
+ // navigation stack
+ var nextPageKey = this._pageKey;
+ int nextPageIndex = this.Frame.BackStackDepth;
+ while (frameState.Remove(nextPageKey))
+ {
+ nextPageIndex++;
+ nextPageKey = "Page-" + nextPageIndex;
+ }
+
+ // Pass the navigation parameter to the new page
+ this.LoadState(e.Parameter, null);
+ }
+ else
+ {
+ // Pass the navigation parameter and preserved page state to the page, using
+ // the same strategy for loading suspended state and recreating pages discarded
+ // from cache
+ this.LoadState(e.Parameter, (Dictionary)frameState[this._pageKey]);
+ }
+ }
+
+ ///
+ /// Invoked when this page will no longer be displayed in a Frame.
+ ///
+ /// Event data that describes how this page was reached. The Parameter
+ /// property provides the group to be displayed.
+ protected override void OnNavigatedFrom(NavigationEventArgs e)
+ {
+ var frameState = SuspensionManager.SessionStateForFrame(this.Frame);
+ var pageState = new Dictionary();
+ this.SaveState(pageState);
+ frameState[_pageKey] = pageState;
+ }
+
+ ///
+ /// Populates the page with content passed during navigation. Any saved state is also
+ /// provided when recreating a page from a prior session.
+ ///
+ /// The parameter value passed to
+ /// when this page was initially requested.
+ ///
+ /// A dictionary of state preserved by this page during an earlier
+ /// session. This will be null the first time a page is visited.
+ protected virtual void LoadState(Object navigationParameter, Dictionary pageState)
+ {
+ }
+
+ ///
+ /// Preserves state associated with this page in case the application is suspended or the
+ /// page is discarded from the navigation cache. Values must conform to the serialization
+ /// requirements of .
+ ///
+ /// An empty dictionary to be populated with serializable state.
+ protected virtual void SaveState(Dictionary pageState)
+ {
+ }
+
+ #endregion
+
+ ///
+ /// Implementation of IObservableMap that supports reentrancy for use as a default view
+ /// model.
+ ///
+ private class ObservableDictionary : IObservableMap
+ {
+ private class ObservableDictionaryChangedEventArgs : IMapChangedEventArgs
+ {
+ public ObservableDictionaryChangedEventArgs(CollectionChange change, K key)
+ {
+ this.CollectionChange = change;
+ this.Key = key;
+ }
+
+ public CollectionChange CollectionChange { get; private set; }
+ public K Key { get; private set; }
+ }
+
+ private Dictionary _dictionary = new Dictionary();
+ public event MapChangedEventHandler MapChanged;
+
+ private void InvokeMapChanged(CollectionChange change, K key)
+ {
+ var eventHandler = MapChanged;
+ if (eventHandler != null)
+ {
+ eventHandler(this, new ObservableDictionaryChangedEventArgs(change, key));
+ }
+ }
+
+ public void Add(K key, V value)
+ {
+ this._dictionary.Add(key, value);
+ this.InvokeMapChanged(CollectionChange.ItemInserted, key);
+ }
+
+ public void Add(KeyValuePair item)
+ {
+ this.Add(item.Key, item.Value);
+ }
+
+ public bool Remove(K key)
+ {
+ if (this._dictionary.Remove(key))
+ {
+ this.InvokeMapChanged(CollectionChange.ItemRemoved, key);
+ return true;
+ }
+ return false;
+ }
+
+ public bool Remove(KeyValuePair item)
+ {
+ V currentValue;
+ if (this._dictionary.TryGetValue(item.Key, out currentValue) &&
+ Object.Equals(item.Value, currentValue) && this._dictionary.Remove(item.Key))
+ {
+ this.InvokeMapChanged(CollectionChange.ItemRemoved, item.Key);
+ return true;
+ }
+ return false;
+ }
+
+ public V this[K key]
+ {
+ get
+ {
+ return this._dictionary[key];
+ }
+ set
+ {
+ this._dictionary[key] = value;
+ this.InvokeMapChanged(CollectionChange.ItemChanged, key);
+ }
+ }
+
+ public void Clear()
+ {
+ var priorKeys = this._dictionary.Keys.ToArray();
+ this._dictionary.Clear();
+ foreach (var key in priorKeys)
+ {
+ this.InvokeMapChanged(CollectionChange.ItemRemoved, key);
+ }
+ }
+
+ public ICollection Keys
+ {
+ get { return this._dictionary.Keys; }
+ }
+
+ public bool ContainsKey(K key)
+ {
+ return this._dictionary.ContainsKey(key);
+ }
+
+ public bool TryGetValue(K key, out V value)
+ {
+ return this._dictionary.TryGetValue(key, out value);
+ }
+
+ public ICollection Values
+ {
+ get { return this._dictionary.Values; }
+ }
+
+ public bool Contains(KeyValuePair item)
+ {
+ return this._dictionary.Contains(item);
+ }
+
+ public int Count
+ {
+ get { return this._dictionary.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public IEnumerator> GetEnumerator()
+ {
+ return this._dictionary.GetEnumerator();
+ }
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return this._dictionary.GetEnumerator();
+ }
+
+ public void CopyTo(KeyValuePair[] array, int arrayIndex)
+ {
+ int arraySize = array.Length;
+ foreach (var pair in this._dictionary)
+ {
+ if (arrayIndex >= arraySize) break;
+ array[arrayIndex++] = pair;
+ }
+ }
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Logo.png b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Logo.png
new file mode 100644
index 00000000000..e26771cb33a
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Logo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/MonoGameWindowsStoreXaml.vstemplate b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/MonoGameWindowsStoreXaml.vstemplate
new file mode 100644
index 00000000000..5ac939a90eb
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/MonoGameWindowsStoreXaml.vstemplate
@@ -0,0 +1,46 @@
+
+
+
+ MonoGame Windows Store (XAML) Project
+ A MonoGame game project for the Windows Store using XAML controls.
+ __TemplateIcon.png
+ __PreviewImage.png
+ MonoGame.CS.WinRT.XamlGame
+ WinRT-Managed
+ CSharp
+ 43130
+ true
+ Game
+ true
+ Enabled
+ true
+ 1
+ Windows
+ 8.1
+ true
+
+
+
+ App.xaml
+ App.xaml.cs
+ GamePage.xaml
+ Game1.cs
+ GamePage.xaml.cs
+ AssemblyInfo.cs
+ Package-managed.appxmanifest
+ Logo.png
+ SmallLogo.png
+ SplashScreen.png
+ StoreLogo.png
+ StandardStyles.xaml
+ Application_TemporaryKey.pfx
+
+ Content.mgcb
+
+
+
+
+ Microsoft.VisualStudio.WinRT.TemplateWizards, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Package-managed.appxmanifest b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Package-managed.appxmanifest
new file mode 100644
index 00000000000..2eea6942d5c
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/Package-managed.appxmanifest
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+ $projectname$
+ $XmlEscapedPublisher$
+ Assets\StoreLogo.png
+
+
+
+ 6.2.1
+ 6.2.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/ReadMe.txt b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/ReadMe.txt
new file mode 100644
index 00000000000..028505af67c
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/ReadMe.txt
@@ -0,0 +1,12 @@
+The Common directory contains classes and XAML styles that simplify application development.
+
+These are not merely convenient, but are required by most Visual Studio project and item templates.
+If you need a variation on one of the styles in StandardStyles it is recommended that you make a
+copy in your own resource dictionary. When right-clicking on a styled control in the design
+surface the context menu includes an option to Edit a Copy to simplify this process.
+
+Classes in the Common directory form part of your project and may be further enhanced to meet your
+needs. Care should be taken when altering existing methods and properties as incompatible changes
+will require corresponding changes to code included in a variety of Visual Studio templates. For
+example, additional pages added to your project are written assuming that the original methods and
+properties in Common classes are still present and that the names of the types have not changed.
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/RichTextColumns.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/RichTextColumns.cs
new file mode 100644
index 00000000000..20a02de1d78
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/RichTextColumns.cs
@@ -0,0 +1,210 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Windows.Foundation;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Documents;
+
+namespace $safeprojectname$.Common
+{
+ ///
+ /// Wrapper for that creates as many additional overflow
+ /// columns as needed to fit the available content.
+ ///
+ ///
+ /// The following creates a collection of 400-pixel wide columns spaced 50 pixels apart
+ /// to contain arbitrary data-bound content:
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Typically used in a horizontally scrolling region where an unbounded amount of
+ /// space allows for all needed columns to be created. When used in a vertically scrolling
+ /// space there will never be any additional columns.
+ [Windows.UI.Xaml.Markup.ContentProperty(Name = "RichTextContent")]
+ public sealed class RichTextColumns : Panel
+ {
+ ///
+ /// Identifies the dependency property.
+ ///
+ public static readonly DependencyProperty RichTextContentProperty =
+ DependencyProperty.Register("RichTextContent", typeof(RichTextBlock),
+ typeof(RichTextColumns), new PropertyMetadata(null, ResetOverflowLayout));
+
+ ///
+ /// Identifies the dependency property.
+ ///
+ public static readonly DependencyProperty ColumnTemplateProperty =
+ DependencyProperty.Register("ColumnTemplate", typeof(DataTemplate),
+ typeof(RichTextColumns), new PropertyMetadata(null, ResetOverflowLayout));
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RichTextColumns()
+ {
+ this.HorizontalAlignment = HorizontalAlignment.Left;
+ }
+
+ ///
+ /// Gets or sets the initial rich text content to be used as the first column.
+ ///
+ public RichTextBlock RichTextContent
+ {
+ get { return (RichTextBlock)GetValue(RichTextContentProperty); }
+ set { SetValue(RichTextContentProperty, value); }
+ }
+
+ ///
+ /// Gets or sets the template used to create additional
+ /// instances.
+ ///
+ public DataTemplate ColumnTemplate
+ {
+ get { return (DataTemplate)GetValue(ColumnTemplateProperty); }
+ set { SetValue(ColumnTemplateProperty, value); }
+ }
+
+ ///
+ /// Invoked when the content or overflow template is changed to recreate the column layout.
+ ///
+ /// Instance of where the change
+ /// occurred.
+ /// Event data describing the specific change.
+ private static void ResetOverflowLayout(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ // When dramatic changes occur, rebuild the column layout from scratch
+ var target = d as RichTextColumns;
+ if (target != null)
+ {
+ target._overflowColumns = null;
+ target.Children.Clear();
+ target.InvalidateMeasure();
+ }
+ }
+
+ ///
+ /// Lists overflow columns already created. Must maintain a 1:1 relationship with
+ /// instances in the collection following the initial
+ /// RichTextBlock child.
+ ///
+ private List _overflowColumns = null;
+
+ ///
+ /// Determines whether additional overflow columns are needed and if existing columns can
+ /// be removed.
+ ///
+ /// The size of the space available, used to constrain the
+ /// number of additional columns that can be created.
+ /// The resulting size of the original content plus any extra columns.
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ if (this.RichTextContent == null) return new Size(0, 0);
+
+ // Make sure the RichTextBlock is a child, using the lack of
+ // a list of additional columns as a sign that this hasn't been
+ // done yet
+ if (this._overflowColumns == null)
+ {
+ Children.Add(this.RichTextContent);
+ this._overflowColumns = new List();
+ }
+
+ // Start by measuring the original RichTextBlock content
+ this.RichTextContent.Measure(availableSize);
+ var maxWidth = this.RichTextContent.DesiredSize.Width;
+ var maxHeight = this.RichTextContent.DesiredSize.Height;
+ var hasOverflow = this.RichTextContent.HasOverflowContent;
+
+ // Make sure there are enough overflow columns
+ int overflowIndex = 0;
+ while (hasOverflow && maxWidth < availableSize.Width && this.ColumnTemplate != null)
+ {
+ // Use existing overflow columns until we run out, then create
+ // more from the supplied template
+ RichTextBlockOverflow overflow;
+ if (this._overflowColumns.Count > overflowIndex)
+ {
+ overflow = this._overflowColumns[overflowIndex];
+ }
+ else
+ {
+ overflow = (RichTextBlockOverflow)this.ColumnTemplate.LoadContent();
+ this._overflowColumns.Add(overflow);
+ this.Children.Add(overflow);
+ if (overflowIndex == 0)
+ {
+ this.RichTextContent.OverflowContentTarget = overflow;
+ }
+ else
+ {
+ this._overflowColumns[overflowIndex - 1].OverflowContentTarget = overflow;
+ }
+ }
+
+ // Measure the new column and prepare to repeat as necessary
+ overflow.Measure(new Size(availableSize.Width - maxWidth, availableSize.Height));
+ maxWidth += overflow.DesiredSize.Width;
+ maxHeight = Math.Max(maxHeight, overflow.DesiredSize.Height);
+ hasOverflow = overflow.HasOverflowContent;
+ overflowIndex++;
+ }
+
+ // Disconnect extra columns from the overflow chain, remove them from our private list
+ // of columns, and remove them as children
+ if (this._overflowColumns.Count > overflowIndex)
+ {
+ if (overflowIndex == 0)
+ {
+ this.RichTextContent.OverflowContentTarget = null;
+ }
+ else
+ {
+ this._overflowColumns[overflowIndex - 1].OverflowContentTarget = null;
+ }
+ while (this._overflowColumns.Count > overflowIndex)
+ {
+ this._overflowColumns.RemoveAt(overflowIndex);
+ this.Children.RemoveAt(overflowIndex + 1);
+ }
+ }
+
+ // Report final determined size
+ return new Size(maxWidth, maxHeight);
+ }
+
+ ///
+ /// Arranges the original content and all extra columns.
+ ///
+ /// Defines the size of the area the children must be arranged
+ /// within.
+ /// The size of the area the children actually required.
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ double maxWidth = 0;
+ double maxHeight = 0;
+ foreach (var child in Children)
+ {
+ child.Arrange(new Rect(maxWidth, 0, child.DesiredSize.Width, finalSize.Height));
+ maxWidth += child.DesiredSize.Width;
+ maxHeight = Math.Max(maxHeight, child.DesiredSize.Height);
+ }
+ return new Size(maxWidth, maxHeight);
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/SmallLogo.png b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/SmallLogo.png
new file mode 100644
index 00000000000..1eb0d9d528c
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/SmallLogo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/SplashScreen.png b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/SplashScreen.png
new file mode 100644
index 00000000000..c951e031bdf
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/SplashScreen.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/StandardStyles.xaml b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/StandardStyles.xaml
new file mode 100644
index 00000000000..85f4ed640e1
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/StandardStyles.xaml
@@ -0,0 +1,1829 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Mouse
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/StoreLogo.png b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/StoreLogo.png
new file mode 100644
index 00000000000..dcb672712c6
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/StoreLogo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/SuspensionManager.cs b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/SuspensionManager.cs
new file mode 100644
index 00000000000..4387bb7b893
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/SuspensionManager.cs
@@ -0,0 +1,257 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+using Windows.ApplicationModel;
+using Windows.Storage;
+using Windows.Storage.Streams;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+
+namespace $safeprojectname$.Common
+{
+ ///
+ /// SuspensionManager captures global session state to simplify process lifetime management
+ /// for an application. Note that session state will be automatically cleared under a variety
+ /// of conditions and should only be used to store information that would be convenient to
+ /// carry across sessions, but that should be discarded when an application crashes or is
+ /// upgraded.
+ ///
+ internal sealed class SuspensionManager
+ {
+ private static Dictionary _sessionState = new Dictionary();
+ private static List _knownTypes = new List();
+ private const string sessionStateFilename = "_sessionState.xml";
+
+ ///
+ /// Provides access to global session state for the current session. This state is
+ /// serialized by and restored by
+ /// , so values must be serializable by
+ /// and should be as compact as possible. Strings
+ /// and other self-contained data types are strongly recommended.
+ ///
+ public static Dictionary SessionState
+ {
+ get { return _sessionState; }
+ }
+
+ ///
+ /// List of custom types provided to the when
+ /// reading and writing session state. Initially empty, additional types may be
+ /// added to customize the serialization process.
+ ///
+ public static List KnownTypes
+ {
+ get { return _knownTypes; }
+ }
+
+ ///
+ /// Save the current . Any instances
+ /// registered with will also preserve their current
+ /// navigation stack, which in turn gives their active an opportunity
+ /// to save its state.
+ ///
+ /// An asynchronous task that reflects when session state has been saved.
+ public static async Task SaveAsync()
+ {
+ try
+ {
+ // Save the navigation state for all registered frames
+ foreach (var weakFrameReference in _registeredFrames)
+ {
+ Frame frame;
+ if (weakFrameReference.TryGetTarget(out frame))
+ {
+ SaveFrameNavigationState(frame);
+ }
+ }
+
+ // Serialize the session state synchronously to avoid asynchronous access to shared
+ // state
+ MemoryStream sessionData = new MemoryStream();
+ DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary), _knownTypes);
+ serializer.WriteObject(sessionData, _sessionState);
+
+ // Get an output stream for the SessionState file and write the state asynchronously
+ StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(sessionStateFilename, CreationCollisionOption.ReplaceExisting);
+ using (Stream fileStream = await file.OpenStreamForWriteAsync())
+ {
+ sessionData.Seek(0, SeekOrigin.Begin);
+ await sessionData.CopyToAsync(fileStream);
+ await fileStream.FlushAsync();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new SuspensionManagerException(e);
+ }
+ }
+
+ ///
+ /// Restores previously saved . Any instances
+ /// registered with will also restore their prior navigation
+ /// state, which in turn gives their active an opportunity restore its
+ /// state.
+ ///
+ /// An asynchronous task that reflects when session state has been read. The
+ /// content of should not be relied upon until this task
+ /// completes.
+ public static async Task RestoreAsync()
+ {
+ _sessionState = new Dictionary();
+
+ try
+ {
+ // Get the input stream for the SessionState file
+ StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(sessionStateFilename);
+ using (IInputStream inStream = await file.OpenSequentialReadAsync())
+ {
+ // Deserialize the Session State
+ DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary), _knownTypes);
+ _sessionState = (Dictionary)serializer.ReadObject(inStream.AsStreamForRead());
+ }
+
+ // Restore any registered frames to their saved state
+ foreach (var weakFrameReference in _registeredFrames)
+ {
+ Frame frame;
+ if (weakFrameReference.TryGetTarget(out frame))
+ {
+ frame.ClearValue(FrameSessionStateProperty);
+ RestoreFrameNavigationState(frame);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new SuspensionManagerException(e);
+ }
+ }
+
+ private static DependencyProperty FrameSessionStateKeyProperty =
+ DependencyProperty.RegisterAttached("_FrameSessionStateKey", typeof(String), typeof(SuspensionManager), null);
+ private static DependencyProperty FrameSessionStateProperty =
+ DependencyProperty.RegisterAttached("_FrameSessionState", typeof(Dictionary), typeof(SuspensionManager), null);
+ private static List> _registeredFrames = new List>();
+
+ ///
+ /// Registers a instance to allow its navigation history to be saved to
+ /// and restored from . Frames should be registered once
+ /// immediately after creation if they will participate in session state management. Upon
+ /// registration if state has already been restored for the specified key
+ /// the navigation history will immediately be restored. Subsequent invocations of
+ /// will also restore navigation history.
+ ///
+ /// An instance whose navigation history should be managed by
+ ///
+ /// A unique key into used to
+ /// store navigation-related information.
+ public static void RegisterFrame(Frame frame, String sessionStateKey)
+ {
+ if (frame.GetValue(FrameSessionStateKeyProperty) != null)
+ {
+ throw new InvalidOperationException("Frames can only be registered to one session state key");
+ }
+
+ if (frame.GetValue(FrameSessionStateProperty) != null)
+ {
+ throw new InvalidOperationException("Frames must be either be registered before accessing frame session state, or not registered at all");
+ }
+
+ // Use a dependency property to associate the session key with a frame, and keep a list of frames whose
+ // navigation state should be managed
+ frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey);
+ _registeredFrames.Add(new WeakReference (frame));
+
+ // Check to see if navigation state can be restored
+ RestoreFrameNavigationState(frame);
+ }
+
+ ///
+ /// Disassociates a previously registered by
+ /// from . Any navigation state previously captured will be
+ /// removed.
+ ///
+ /// An instance whose navigation history should no longer be
+ /// managed.
+ public static void UnregisterFrame(Frame frame)
+ {
+ // Remove session state and remove the frame from the list of frames whose navigation
+ // state will be saved (along with any weak references that are no longer reachable)
+ SessionState.Remove((String)frame.GetValue(FrameSessionStateKeyProperty));
+ _registeredFrames.RemoveAll((weakFrameReference) =>
+ {
+ Frame testFrame;
+ return !weakFrameReference.TryGetTarget(out testFrame) || testFrame == frame;
+ });
+ }
+
+ ///
+ /// Provides storage for session state associated with the specified .
+ /// Frames that have been previously registered with have
+ /// their session state saved and restored automatically as a part of the global
+ /// . Frames that are not registered have transient state
+ /// that can still be useful when restoring pages that have been discarded from the
+ /// navigation cache.
+ ///
+ /// Apps may choose to rely on to manage
+ /// page-specific state instead of working with frame session state directly.
+ /// The instance for which session state is desired.
+ /// A collection of state subject to the same serialization mechanism as
+ /// .
+ public static Dictionary SessionStateForFrame(Frame frame)
+ {
+ var frameState = (Dictionary)frame.GetValue(FrameSessionStateProperty);
+
+ if (frameState == null)
+ {
+ var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty);
+ if (frameSessionKey != null)
+ {
+ // Registered frames reflect the corresponding session state
+ if (!_sessionState.ContainsKey(frameSessionKey))
+ {
+ _sessionState[frameSessionKey] = new Dictionary();
+ }
+ frameState = (Dictionary)_sessionState[frameSessionKey];
+ }
+ else
+ {
+ // Frames that aren't registered have transient state
+ frameState = new Dictionary();
+ }
+ frame.SetValue(FrameSessionStateProperty, frameState);
+ }
+ return frameState;
+ }
+
+ private static void RestoreFrameNavigationState(Frame frame)
+ {
+ var frameState = SessionStateForFrame(frame);
+ if (frameState.ContainsKey("Navigation"))
+ {
+ frame.SetNavigationState((String)frameState["Navigation"]);
+ }
+ }
+
+ private static void SaveFrameNavigationState(Frame frame)
+ {
+ var frameState = SessionStateForFrame(frame);
+ frameState["Navigation"] = frame.GetNavigationState();
+ }
+ }
+ public class SuspensionManagerException : Exception
+ {
+ public SuspensionManagerException()
+ {
+ }
+
+ public SuspensionManagerException(Exception e) : base("SuspensionManager failed", e)
+ {
+
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/__PreviewImage.png b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/__PreviewImage.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2012/WindowsPhone/__PreviewImage.png
rename to ProjectTemplates/VisualStudio2015/WindowsStoreXaml/__PreviewImage.png
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/__TemplateIcon.png b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/__TemplateIcon.png
similarity index 83%
rename from ProjectTemplates/VisualStudio2013/WindowsPhone/__TemplateIcon.png
rename to ProjectTemplates/VisualStudio2015/WindowsStoreXaml/__TemplateIcon.png
index 09f72fd2628..62f7641be97 100644
Binary files a/ProjectTemplates/VisualStudio2013/WindowsPhone/__TemplateIcon.png and b/ProjectTemplates/VisualStudio2015/WindowsStoreXaml/__TemplateIcon.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/App.xaml.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal/App.xaml.cs
deleted file mode 100644
index 2045acc1d4d..00000000000
--- a/ProjectTemplates/VisualStudio2015/WindowsUniversal/App.xaml.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices.WindowsRuntime;
-using Windows.ApplicationModel;
-using Windows.ApplicationModel.Activation;
-using Windows.Foundation;
-using Windows.Foundation.Collections;
-using Windows.UI.ViewManagement;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-using Windows.UI.Xaml.Data;
-using Windows.UI.Xaml.Input;
-using Windows.UI.Xaml.Media;
-using Windows.UI.Xaml.Navigation;
-
-// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=402347&clcid=0x409
-
-namespace $safeprojectname$
-{
- ///
- /// Provides application-specific behavior to supplement the default Application class.
- ///
- sealed partial class App : Application
- {
- ///
- /// Initializes the singleton application object. This is the first line of authored code
- /// executed, and as such is the logical equivalent of main() or WinMain().
- ///
- public App()
- {
- this.InitializeComponent();
- this.Suspending += OnSuspending;
- }
-
- ///
- /// Invoked when the application is launched normally by the end user. Other entry points
- /// will be used such as when the application is launched to open a specific file.
- ///
- /// Details about the launch request and process.
- protected override void OnLaunched(LaunchActivatedEventArgs e)
- {
- // By default we want to fill the entire core window.
- ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
-
-#if DEBUG
- if (System.Diagnostics.Debugger.IsAttached)
- {
- this.DebugSettings.EnableFrameRateCounter = true;
- }
-#endif
-
- Frame rootFrame = Window.Current.Content as Frame;
-
- // Do not repeat app initialization when the Window already has content,
- // just ensure that the window is active
- if (rootFrame == null)
- {
- // Create a Frame to act as the navigation context and navigate to the first page
- rootFrame = new Frame();
-
- rootFrame.NavigationFailed += OnNavigationFailed;
-
- if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
- {
- //TODO: Load state from previously suspended application
- }
-
- // Place the frame in the current Window
- Window.Current.Content = rootFrame;
- }
-
- if (rootFrame.Content == null)
- {
- // When the navigation stack isn't restored navigate to the first page,
- // configuring the new page by passing required information as a navigation
- // parameter
- rootFrame.Navigate(typeof(GamePage), e.Arguments);
- }
- // Ensure the current window is active
- Window.Current.Activate();
- }
-
- ///
- /// Invoked when Navigation to a certain page fails
- ///
- /// The Frame which failed navigation
- /// Details about the navigation failure
- void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
- {
- throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
- }
-
- ///
- /// Invoked when application execution is being suspended. Application state is saved
- /// without knowing whether the application will be terminated or resumed with the contents
- /// of memory still intact.
- ///
- /// The source of the suspend request.
- /// Details about the suspend request.
- private void OnSuspending(object sender, SuspendingEventArgs e)
- {
- var deferral = e.SuspendingOperation.GetDeferral();
- //TODO: Save application state and stop any background activity
- deferral.Complete();
- }
- }
-}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/MonoGameWindowsUniversal.vstemplate b/ProjectTemplates/VisualStudio2015/WindowsUniversal/MonoGameWindowsUniversal.vstemplate
new file mode 100644
index 00000000000..81742697866
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/MonoGameWindowsUniversal.vstemplate
@@ -0,0 +1,35 @@
+
+
+
+ MonoGame Windows 8.1 Universal Project
+ A MonoGame universal game project for the Windows Store and Windows Phone 8.1.
+ MonoGame.WindowsUniversal.CS.WinRT.Game
+ WinRT-Managed
+ CSharp
+ 43150
+ true
+ Game
+ __TemplateIcon.png
+ __PreviewImage.png
+ true
+ Enabled
+ true
+ 2
+ true
+
+
+
+
+
+ Shared\Shared.vstemplate
+
+
+ Windows\Windows.vstemplate
+
+
+ WindowsPhone\WindowsPhone.vstemplate
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/Content/Content.mgcb b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Content/Content.mgcb
similarity index 100%
rename from ProjectTemplates/VisualStudio2012/WindowsPhone/Content/Content.mgcb
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Content/Content.mgcb
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Game1.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Game1.cs
similarity index 56%
rename from ProjectTemplates/VisualStudio2010/OUYA/Game1.cs
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Game1.cs
index 0c870d9f35f..622e64a8bd3 100644
--- a/ProjectTemplates/VisualStudio2010/OUYA/Game1.cs
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Game1.cs
@@ -1,14 +1,7 @@
-using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Framework.Input;
-using Ouya.Console.Api;
-// There are three things that need to be done for each new OUYA project:
-// 1. Insert your OUYA developer key in the Initialize method below.
-// 2. Replace Resources\Raw\key.der with your application key downloaded from the OUYA dev portal.
-// 3. Replace the product IDs in the call to RequestProductListAsync with your product IDs.
-
-namespace $safeprojectname$
+namespace $ext_safeprojectname$
{
///
/// This is the main type for your game.
@@ -17,17 +10,13 @@ public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
- OuyaFacade facade;
- public Game1()
+ public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
-
- graphics.IsFullScreen = true;
- graphics.PreferredBackBufferWidth = 1280;
- graphics.PreferredBackBufferHeight = 720;
- graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;
+
+ graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
}
///
@@ -39,13 +28,8 @@ public Game1()
protected override void Initialize()
{
// TODO: Add your initialization logic here
- facade = OuyaFacade.Instance;
- facade.Init(Activity, "insert your developer key here");
base.Initialize();
-
- // Start the IAP test as an async task so it runs in the background.
- DoIapTest();
}
///
@@ -56,7 +40,7 @@ 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
}
@@ -76,9 +60,6 @@ protected override void UnloadContent()
/// Provides a snapshot of timing values.
protected override void Update(GameTime gameTime)
{
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- Exit();
-
// TODO: Add your update logic here
base.Update(gameTime);
@@ -96,23 +77,5 @@ protected override void Draw(GameTime gameTime)
base.Draw(gameTime);
}
-
- async void DoIapTest()
- {
- // Retrieve the receipts to see what items the user has previously purchased.
- var receipts = await facade.RequestReceiptsAsync();
- // Retrieve the known products from the OUYA Store.
- var products = await facade.RequestProductListAsync("__TEST__01", "__TEST__02");
- // Make a purchase of the first product in the list.
- // NOTE: This would usually be initiated by a user action such as a button press.
- var purchaseResult = await facade.RequestPurchaseAsync(products[0]);
- // If the purchase was successful...
- if (purchaseResult)
- {
- // ...retrieve the receipts again from the OUYA Store.
- // This will include the new purchase.
- receipts = await facade.RequestReceiptsAsync();
- }
- }
}
}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/GamePage.xaml b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/GamePage.xaml
new file mode 100644
index 00000000000..f94fadad7dc
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/GamePage.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/GamePage.xaml.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/GamePage.xaml.cs
new file mode 100644
index 00000000000..fe7896aaa24
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/GamePage.xaml.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+using MonoGame.Framework;
+// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace $ext_safeprojectname$
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class GamePage : SwapChainBackgroundPanel
+ {
+ readonly Game1 _game;
+
+ public GamePage(string launchArguments)
+ {
+ this.InitializeComponent();
+
+ // Create the game.
+
+ _game = XamlGame.Create(launchArguments, Window.Current.CoreWindow, this);
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.App.xaml b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.App.xaml
new file mode 100644
index 00000000000..a2f0d3938e2
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.App.xaml
@@ -0,0 +1,7 @@
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.App.xaml.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.App.xaml.cs
new file mode 100644
index 00000000000..c96e0976ab4
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.App.xaml.cs
@@ -0,0 +1,70 @@
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.UI.Xaml;
+
+// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227
+
+namespace $ext_safeprojectname$
+{
+ ///
+ /// Provides application-specific behavior to supplement the default Application class.
+ ///
+ sealed partial class App : Application
+ {
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ public App()
+ {
+ InitializeComponent();
+ Suspending += OnSuspending;
+ }
+
+ ///
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used when the application is launched to open a specific file, to display
+ /// search results, and so forth.
+ ///
+ /// Details about the launch request and process.
+ protected override void OnLaunched(LaunchActivatedEventArgs args)
+ {
+ var gamePage = Window.Current.Content as GamePage;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (gamePage == null)
+ {
+ // Create a main GamePage
+ gamePage = new GamePage(args.Arguments);
+
+ if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
+ {
+ // TODO: Load state from previously suspended application
+ }
+
+ // Place the GamePage in the current Window
+ Window.Current.Content = gamePage;
+ }
+
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+
+ ///
+ /// Invoked when application execution is being suspended. Application state is saved
+ /// without knowing whether the application will be terminated or resumed with the contents
+ /// of memory still intact.
+ ///
+ /// The source of the suspend request.
+ /// Details about the suspend request.
+ private void OnSuspending(object sender, SuspendingEventArgs e)
+ {
+ var deferral = e.SuspendingOperation.GetDeferral();
+
+ // TODO: Save application state and stop any background activity
+
+ deferral.Complete();
+ }
+ }
+}
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.Application.Shared.projitems b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.Application.Shared.projitems
new file mode 100644
index 00000000000..ae157ce24b3
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.Application.Shared.projitems
@@ -0,0 +1,29 @@
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+ true
+ $guid1$
+
+
+ $ext_safeprojectname$
+
+
+
+ Designer
+
+
+ App.xaml
+
+
+
+ GamePage.xaml
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.Application.shproj b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.Application.shproj
new file mode 100644
index 00000000000..9130a21dd38
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.Application.shproj
@@ -0,0 +1,12 @@
+
+
+
+ $guid1$
+
+
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.vstemplate b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.vstemplate
new file mode 100644
index 00000000000..dc1bb9abc3e
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Shared/Shared.vstemplate
@@ -0,0 +1,26 @@
+
+
+
+ $ext_safeprojectname$.Shared
+ CSharp
+ Windows
+ true
+ true
+ Enabled
+ App
+ true
+
+
+
+ Shared.Application.Shared.projitems
+ Shared.App.xaml
+ Shared.App.xaml.cs
+ GamePage.xaml
+ GamePage.xaml.cs
+ Game1.cs
+
+ Content.mgcb
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Logo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Logo.png
new file mode 100644
index 00000000000..e26771cb33a
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Logo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Package-managed.appxmanifest b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Package-managed.appxmanifest
new file mode 100644
index 00000000000..ee6bcf7961c
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Package-managed.appxmanifest
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+ $ext_safeprojectname$
+ $XmlEscapedPublisher$
+ Assets\StoreLogo.png
+
+
+
+ 6.3.0
+ 6.3.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/SmallLogo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/SmallLogo.png
new file mode 100644
index 00000000000..1eb0d9d528c
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/SmallLogo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/SplashScreen.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/SplashScreen.png
new file mode 100644
index 00000000000..c951e031bdf
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/SplashScreen.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/StoreLogo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/StoreLogo.png
new file mode 100644
index 00000000000..dcb672712c6
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/StoreLogo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.Application.Windows.csproj b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.Application.Windows.csproj
new file mode 100644
index 00000000000..8abccf5c918
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.Application.Windows.csproj
@@ -0,0 +1,154 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ $guid1$
+ AppContainerExe
+ Properties
+ $ext_safeprojectname$
+ $ext_safeprojectname$.Windows
+ $currentuiculturename$
+ 8.1
+ 12
+ 512
+ true
+ {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ $if$($includeKeyFile$==true)
+ $ext_safeprojectname$.Windows_TemporaryKey.pfx
+ $endif$
+ WindowsStoreApp
+ 8.1
+ 12
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_APP
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE;WINDOWS_APP
+ prompt
+ 4
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_APP
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE;WINDOWS_APP
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_APP
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE;WINDOWS_APP
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_APP
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE;WINDOWS_APP
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+
+
+
+
+
+
+
+
+
+ Designer
+
+ $if$($includeKeyFile$==true)
+
+ $endif$
+
+
+
+
+
+
+
+
+
+ Content\Content.mgcb
+
+
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows8\MonoGame.Framework.dll
+
+
+
+ 12.0
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Properties/AssemblyInfo.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.AssemblyInfo.cs
similarity index 57%
rename from ProjectTemplates/VisualStudio2010/OUYA/Properties/AssemblyInfo.cs
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.AssemblyInfo.cs
index 94466eb84ce..6ce6072ccf3 100644
--- a/ProjectTemplates/VisualStudio2010/OUYA/Properties/AssemblyInfo.cs
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.AssemblyInfo.cs
@@ -1,41 +1,29 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using Android.App;
-// General Information about an assembly is controlled through the following
+// 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("$projectname$")]
-[assembly: AssemblyProduct("$projectname$")]
-[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyTitle("$ext_projectname$")]
[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("$registeredorganization$")]
+[assembly: AssemblyProduct("$ext_projectname$")]
[assembly: AssemblyCopyright("Copyright © $registeredorganization$ $year$")]
[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("$guid2$")]
-
// Version information for an assembly consists of the following four values:
//
// Major Version
-// Minor Version
+// Minor Version
// Build Number
// Revision
//
-// You can specify all the values or you can default the Build and Revision Numbers
+// 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")]
-
-// Add some common permissions, these can be removed if not needed
-[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
-[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
+[assembly: ComVisible(false)]
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.TemporaryKey.pfx b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.TemporaryKey.pfx
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.vstemplate b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.vstemplate
new file mode 100644
index 00000000000..0c54ce5a6fb
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/Windows/Windows.vstemplate
@@ -0,0 +1,32 @@
+
+
+
+ $ext_safeprojectname$.Windows
+ App
+ CSharp
+ Windows
+ true
+ true
+ Enabled
+ true
+
+
+
+
+ Logo.png
+ SmallLogo.png
+ SplashScreen.png
+ StoreLogo.png
+
+
+ Windows.AssemblyInfo.cs
+
+ Package-managed.appxmanifest
+ Windows.TemporaryKey.pfx
+
+
+
+ Microsoft.VisualStudio.WinRT.TemplateWizards, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Package-PhoneAppx.appxmanifest b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Package-PhoneAppx.appxmanifest
new file mode 100644
index 00000000000..8478067912f
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Package-PhoneAppx.appxmanifest
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+ $ext_safeprojectname$
+ $XmlEscapedPublisher$
+ Assets\StoreLogo.png
+
+
+
+ 6.3.1
+ 6.3.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.Logo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.Logo.png
new file mode 100644
index 00000000000..76921ca9971
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.Logo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.SmallLogo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.SmallLogo.png
new file mode 100644
index 00000000000..316630124fd
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.SmallLogo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.SplashScreen.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.SplashScreen.png
new file mode 100644
index 00000000000..33f26b33107
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.SplashScreen.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.Square71x71Logo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.Square71x71Logo.png
new file mode 100644
index 00000000000..cfa54bee034
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.Square71x71Logo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.StoreLogo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.StoreLogo.png
new file mode 100644
index 00000000000..47e084b5932
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.StoreLogo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.WideLogo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.WideLogo.png
new file mode 100644
index 00000000000..6249d29db05
Binary files /dev/null and b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/Phone.WideLogo.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/WindowsPhone.Application.WindowsPhone.csproj b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/WindowsPhone.Application.WindowsPhone.csproj
new file mode 100644
index 00000000000..3dca926c9f9
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/WindowsPhone.Application.WindowsPhone.csproj
@@ -0,0 +1,129 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ $guid1$
+ AppContainerExe
+ Properties
+ $ext_safeprojectname$
+ $ext_safeprojectname$.WindowsPhone
+ $currentuiculturename$
+ 8.1
+ 12
+ 512
+ {76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ true
+ WindowsPhone8
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE;WINDOWS_PHONE_APP
+ prompt
+ 4
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE;WINDOWS_PHONE_APP
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+
+
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;NETFX_CORE;WINDOWS_PHONE_APP
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+
+
+
+
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+ Content\Content.mgcb
+
+
+
+ 12.0
+
+
+ WindowsPhoneApp
+
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\WindowsPhone81\MonoGame.Framework.dll
+
+
+
+
+
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/WindowsPhone.AssemblyInfo.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/WindowsPhone.AssemblyInfo.cs
new file mode 100644
index 00000000000..3102defff29
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/WindowsPhone.AssemblyInfo.cs
@@ -0,0 +1,29 @@
+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("$ext_safeprojectname$")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("$registeredorganization$")]
+[assembly: AssemblyProduct("$ext_safeprojectname$")]
+[assembly: AssemblyCopyright("Copyright © $registeredorganization$ $year$")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 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")]
+[assembly: ComVisible(false)]
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/WindowsPhone.vstemplate b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/WindowsPhone.vstemplate
new file mode 100644
index 00000000000..13f92421773
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsPhone/WindowsPhone.vstemplate
@@ -0,0 +1,34 @@
+
+
+
+ $ext_safeprojectname$.WindowsPhone
+ App
+ CSharp
+ Windows
+ 6.3.0
+ true
+ true
+ Enabled
+ true
+
+
+
+
+ Phone.Logo.png
+ Phone.SmallLogo.png
+ Phone.SplashScreen.png
+ Phone.Square71x71Logo.png
+ Phone.StoreLogo.png
+ Phone.WideLogo.png
+
+
+ WindowsPhone.AssemblyInfo.cs
+
+ Package-PhoneAppx.appxmanifest
+
+
+
+ Microsoft.VisualStudio.WinRT.TemplateWizards, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard
+
+
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/App.xaml b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/App.xaml
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/App.xaml
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/App.xaml
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/App.xaml.vb b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/App.xaml.vb
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/App.xaml.vb
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/App.xaml.vb
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/ApplicationInsights.config b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/ApplicationInsights.config
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/ApplicationInsights.config
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/ApplicationInsights.config
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/LockScreenLogo.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/LockScreenLogo.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/LockScreenLogo.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/LockScreenLogo.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/SplashScreen.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/SplashScreen.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/SplashScreen.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/SplashScreen.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/Square150x150Logo.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/Square150x150Logo.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/Square150x150Logo.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/Square150x150Logo.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/Square44x44Logo.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/Square44x44Logo.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/Square44x44Logo.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/Square44x44Logo.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/StoreLogo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/StoreLogo.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/StoreLogo.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/StoreLogo.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/Wide310x150Logo.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/Wide310x150Logo.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Assets/Wide310x150Logo.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Assets/Wide310x150Logo.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Content/Content.mgcb b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Content/Content.mgcb
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Content/Content.mgcb
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Content/Content.mgcb
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Game1.vb b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Game1.vb
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Game1.vb
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Game1.vb
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/GamePage.xaml b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/GamePage.xaml
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/GamePage.xaml
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/GamePage.xaml
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/GamePage.xaml.vb b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/GamePage.xaml.vb
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/GamePage.xaml.vb
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/GamePage.xaml.vb
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/My Project/AssemblyInfo.vb b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/My Project/AssemblyInfo.vb
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/My Project/AssemblyInfo.vb
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/My Project/AssemblyInfo.vb
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/My Project/Default.rd.xml b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/My Project/Default.rd.xml
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/My Project/Default.rd.xml
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/My Project/Default.rd.xml
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/MyTemplate.vstemplate b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/MyTemplate.vstemplate
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/MyTemplate.vstemplate
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/MyTemplate.vstemplate
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Package.appxmanifest b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Package.appxmanifest
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/Package.appxmanifest
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/Package.appxmanifest
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/WindowsUniversal.VB.vbproj b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/WindowsUniversal.VB.vbproj
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/WindowsUniversal.VB.vbproj
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/WindowsUniversal.VB.vbproj
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/WindowsUniversal.VB_TemporaryKey.pfx b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/WindowsUniversal.VB_TemporaryKey.pfx
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/WindowsUniversal.VB_TemporaryKey.pfx
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/WindowsUniversal.VB_TemporaryKey.pfx
diff --git a/ProjectTemplates/VisualStudio2013/WindowsPhone/__PreviewImage.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/__PreviewImage.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2013/WindowsPhone/__PreviewImage.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/__PreviewImage.png
diff --git a/ProjectTemplates/VisualStudio2012/WindowsPhone/__TemplateIcon.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/__TemplateIcon.png
similarity index 83%
rename from ProjectTemplates/VisualStudio2012/WindowsPhone/__TemplateIcon.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/__TemplateIcon.png
index 09f72fd2628..62f7641be97 100644
Binary files a/ProjectTemplates/VisualStudio2012/WindowsPhone/__TemplateIcon.png and b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/__TemplateIcon.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/project.json b/ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/project.json
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/project.json
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10.VB/project.json
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/App.xaml b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/App.xaml
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/App.xaml
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/App.xaml
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal10/App.xaml.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/App.xaml.cs
new file mode 100644
index 00000000000..84b8ea584d4
--- /dev/null
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/App.xaml.cs
@@ -0,0 +1,134 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.ViewManagement;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=402347&clcid=0x409
+
+namespace $safeprojectname$
+{
+ ///
+ /// Provides application-specific behavior to supplement the default Application class.
+ ///
+ sealed partial class App : Application
+{
+ static string deviceFamily;
+
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ public App()
+ {
+ this.InitializeComponent();
+ this.Suspending += OnSuspending;
+
+ //API check to ensure the "RequiresPointerMode" property exists, ensuring project is running on build 14393 or later
+ if (Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Application", "RequiresPointerMode"))
+ {
+ //If running on the Xbox, disable the default on screen pointer
+ if (IsXbox())
+ {
+ Application.Current.RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested;
+ }
+ }
+ }
+
+ ///
+ /// Detection code in Windows 10 to identify the platform it is being run on
+ /// This function returns true if the project is running on an XboxOne
+ ///
+ public static bool IsXbox()
+ {
+ if (deviceFamily == null)
+ deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
+
+ return deviceFamily == "Windows.Xbox";
+ }
+
+ ///
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used such as when the application is launched to open a specific file.
+ ///
+ /// Details about the launch request and process.
+ protected override void OnLaunched(LaunchActivatedEventArgs e)
+ {
+ // By default we want to fill the entire core window.
+ ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
+
+#if DEBUG
+ if (System.Diagnostics.Debugger.IsAttached)
+ {
+ this.DebugSettings.EnableFrameRateCounter = true;
+ }
+#endif
+
+ Frame rootFrame = Window.Current.Content as Frame;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (rootFrame == null)
+ {
+ // Create a Frame to act as the navigation context and navigate to the first page
+ rootFrame = new Frame();
+
+ rootFrame.NavigationFailed += OnNavigationFailed;
+
+ if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
+ {
+ //TODO: Load state from previously suspended application
+ }
+
+ // Place the frame in the current Window
+ Window.Current.Content = rootFrame;
+ }
+
+ if (rootFrame.Content == null)
+ {
+ // When the navigation stack isn't restored navigate to the first page,
+ // configuring the new page by passing required information as a navigation
+ // parameter
+ rootFrame.Navigate(typeof(GamePage), e.Arguments);
+ }
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+
+ ///
+ /// Invoked when Navigation to a certain page fails
+ ///
+ /// The Frame which failed navigation
+ /// Details about the navigation failure
+ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
+ {
+ throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
+ }
+
+ ///
+ /// Invoked when application execution is being suspended. Application state is saved
+ /// without knowing whether the application will be terminated or resumed with the contents
+ /// of memory still intact.
+ ///
+ /// The source of the suspend request.
+ /// Details about the suspend request.
+ private void OnSuspending(object sender, SuspendingEventArgs e)
+ {
+ var deferral = e.SuspendingOperation.GetDeferral();
+ //TODO: Save application state and stop any background activity
+ deferral.Complete();
+ }
+}
+}
\ No newline at end of file
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Application.csproj b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Application.csproj
similarity index 98%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Application.csproj
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/Application.csproj
index 7b0fdf8691a..ad4e329e0ce 100644
--- a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Application.csproj
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Application.csproj
@@ -12,8 +12,8 @@
$projectname$
$currentuiculturename$
UAP
- 10.0.10586.0
- 10.0.10240.0
+ 10.0.14393.0
+ 10.0.10240.0
14
true
512
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Application_TemporaryKey.pfx b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Application_TemporaryKey.pfx
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/AssemblyInfo.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/AssemblyInfo.cs
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/AssemblyInfo.cs
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/AssemblyInfo.cs
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/Content/Content.mgcb b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Content/Content.mgcb
similarity index 76%
rename from ProjectTemplates/VisualStudio2010/OUYA/Content/Content.mgcb
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/Content/Content.mgcb
index bdf99b83fbd..a7026da36bd 100644
--- a/ProjectTemplates/VisualStudio2010/OUYA/Content/Content.mgcb
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Content/Content.mgcb
@@ -1,9 +1,9 @@
#----------------------------- Global Properties ----------------------------#
-/outputDir:bin/Ouya
-/intermediateDir:obj/Ouya
-/platform:Android
+/outputDir:bin/$(Platform)
+/intermediateDir:obj/$(Platform)
+/platform:WindowsStoreApp
/config:
/profile:Reach
/compress:False
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Default.rd.xml b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Default.rd.xml
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Default.rd.xml
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/Default.rd.xml
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Game1.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Game1.cs
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Game1.cs
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/Game1.cs
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/GamePage.xaml b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/GamePage.xaml
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/GamePage.xaml
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/GamePage.xaml
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/GamePage.xaml.cs b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/GamePage.xaml.cs
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/GamePage.xaml.cs
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/GamePage.xaml.cs
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/LockScreenLogo.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/LockScreenLogo.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/LockScreenLogo.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/LockScreenLogo.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Package-managed.appxmanifest b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Package-managed.appxmanifest
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Package-managed.appxmanifest
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/Package-managed.appxmanifest
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/SplashScreen.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/SplashScreen.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/SplashScreen.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/SplashScreen.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Square150x150Logo.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Square150x150Logo.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Square150x150Logo.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/Square150x150Logo.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Square44x44Logo.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Square44x44Logo.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Square44x44Logo.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/Square44x44Logo.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Square44x44Logo.targetsize-24_altform-unplated.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Square44x44Logo.targetsize-24_altform-unplated.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Square44x44Logo.targetsize-24_altform-unplated.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/Square44x44Logo.targetsize-24_altform-unplated.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/StoreLogo.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/StoreLogo.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/StoreLogo.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/StoreLogo.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/Wide310x150Logo.scale-200.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/Wide310x150Logo.scale-200.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/Wide310x150Logo.scale-200.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/Wide310x150Logo.scale-200.png
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsUniversal.vstemplate b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/WindowsUniversal10.vstemplate
similarity index 98%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsUniversal.vstemplate
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/WindowsUniversal10.vstemplate
index 1172a609033..c381015374b 100644
--- a/ProjectTemplates/VisualStudio2015/WindowsUniversal/WindowsUniversal.vstemplate
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/WindowsUniversal10.vstemplate
@@ -6,7 +6,7 @@
__TemplateIcon.png
__PreviewImage.png
MonoGame.CS.WinRT.UAPGame
- WinRT-Managed
+ WinRT-Native-UAP
CSharp
43160
true
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/__PreviewImage.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/__PreviewImage.png
similarity index 100%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal.VB/__PreviewImage.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/__PreviewImage.png
diff --git a/ProjectTemplates/VisualStudio2010/OUYA/__TemplateIcon.png b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/__TemplateIcon.png
similarity index 78%
rename from ProjectTemplates/VisualStudio2010/OUYA/__TemplateIcon.png
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/__TemplateIcon.png
index cefee0fcbe4..62f7641be97 100644
Binary files a/ProjectTemplates/VisualStudio2010/OUYA/__TemplateIcon.png and b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/__TemplateIcon.png differ
diff --git a/ProjectTemplates/VisualStudio2015/WindowsUniversal/project.json b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/project.json
similarity index 79%
rename from ProjectTemplates/VisualStudio2015/WindowsUniversal/project.json
rename to ProjectTemplates/VisualStudio2015/WindowsUniversal10/project.json
index c5949392705..32d927479d9 100644
--- a/ProjectTemplates/VisualStudio2015/WindowsUniversal/project.json
+++ b/ProjectTemplates/VisualStudio2015/WindowsUniversal10/project.json
@@ -1,6 +1,6 @@
{
"dependencies": {
- "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
+ "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2"
},
"frameworks": {
"uap10.0": {}
diff --git a/README.md b/README.md
index 5f0d758f820..6fefb03312b 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ Our [build server](http://teamcity.monogame.net/?guest=1) builds, tests, and pac
| Name | Status |
|:---|--------|
-| Build Windows, Web, Android, and OUYA | [](http://teamcity.monogame.net/viewType.html?buildTypeId=MonoGame_DevelopWin&guest=1) |
+| Build Windows, Web, and Android | [](http://teamcity.monogame.net/viewType.html?buildTypeId=MonoGame_DevelopWin&guest=1) |
| Build Mac, iOS, and Linux | [](http://teamcity.monogame.net/viewType.html?buildTypeId=MonoGame_DevelopMac&guest=1) |
| Generate Documentation | [](http://teamcity.monogame.net/viewType.html?buildTypeId=MonoGame_GenerateDocumentation&guest=1) |
| Windows Tests | [](http://teamcity.monogame.net/viewType.html?buildTypeId=MonoGame_TestWindows&guest=1) |
@@ -44,7 +44,6 @@ We support a growing list of platforms across the desktop, mobile, and console s
* PlayStation 4
* PlayStation Vita
* Xbox One (both UWP and XDK)
- * OUYA
## Support and Contributions
diff --git a/Test/Assets/ReferenceImages/RasterizerState/DepthBiasVisualTest_-0.0004f_.png b/Test/Assets/ReferenceImages/RasterizerState/DepthBiasVisualTest_-0.0004f_.png
new file mode 100644
index 00000000000..3949105b2ce
Binary files /dev/null and b/Test/Assets/ReferenceImages/RasterizerState/DepthBiasVisualTest_-0.0004f_.png differ
diff --git a/Test/Assets/ReferenceImages/RasterizerState/DepthBiasVisualTest_-1.0f_.png b/Test/Assets/ReferenceImages/RasterizerState/DepthBiasVisualTest_-1.0f_.png
new file mode 100644
index 00000000000..3949105b2ce
Binary files /dev/null and b/Test/Assets/ReferenceImages/RasterizerState/DepthBiasVisualTest_-1.0f_.png differ
diff --git a/Test/Assets/ReferenceImages/RasterizerState/DepthBiasVisualTest_1.0f_.png b/Test/Assets/ReferenceImages/RasterizerState/DepthBiasVisualTest_1.0f_.png
new file mode 100644
index 00000000000..82497828b8a
Binary files /dev/null and b/Test/Assets/ReferenceImages/RasterizerState/DepthBiasVisualTest_1.0f_.png differ
diff --git a/Test/Assets/ReferenceImages/SpriteBatch/Draw_with_viewport_changing_Deferred_.png b/Test/Assets/ReferenceImages/SpriteBatch/Draw_with_viewport_changing_Deferred_.png
new file mode 100644
index 00000000000..63a6e0a3f81
Binary files /dev/null and b/Test/Assets/ReferenceImages/SpriteBatch/Draw_with_viewport_changing_Deferred_.png differ
diff --git a/Test/Assets/ReferenceImages/SpriteBatch/Draw_with_viewport_changing_Immediate_.png b/Test/Assets/ReferenceImages/SpriteBatch/Draw_with_viewport_changing_Immediate_.png
new file mode 100644
index 00000000000..aae4b95a8fc
Binary files /dev/null and b/Test/Assets/ReferenceImages/SpriteBatch/Draw_with_viewport_changing_Immediate_.png differ
diff --git a/Test/ContentPipeline/AudioContentTests.cs b/Test/ContentPipeline/AudioContentTests.cs
index 9f5ba7569e0..5ef9d993a8e 100644
--- a/Test/ContentPipeline/AudioContentTests.cs
+++ b/Test/ContentPipeline/AudioContentTests.cs
@@ -192,10 +192,8 @@ private static int ToWavFormat(ConversionFormat format, int bitsPerSample)
if (bitsPerSample == 32)
return -2;
return 1;
- break;
case ConversionFormat.Adpcm:
return 2;
- break;
case ConversionFormat.WindowsMedia:
case ConversionFormat.Xma:
default:
diff --git a/Test/ContentPipeline/BitmapContentTests.cs b/Test/ContentPipeline/BitmapContentTests.cs
index 10342809c71..4622602541c 100644
--- a/Test/ContentPipeline/BitmapContentTests.cs
+++ b/Test/ContentPipeline/BitmapContentTests.cs
@@ -51,7 +51,7 @@ void BitmapCopyFullNoResize(T color1)
Assert.AreEqual(color1, b2.GetPixel(x, y));
}
- void BitmapCopyFullResize(T color1)
+ void BitmapCopyFullResize(T color1, IEqualityComparer comparer)
where T : struct, IEquatable
{
var b1 = new PixelBitmapContent(8, 8);
@@ -61,7 +61,7 @@ void BitmapCopyFullResize(T color1)
for (var y = 0; y < b2.Height; y++)
for (var x = 0; x < b2.Width; x++)
- Assert.AreEqual(color1, b2.GetPixel(x, y));
+ Assert.That(color1, Is.EqualTo(b2.GetPixel(x, y)).Using(comparer));
}
void BitmapConvertFullNoResize(T color1, U color2)
@@ -126,7 +126,7 @@ void BitmapCopyMoveRegionNoResize(T color1, T color2)
Assert.AreEqual(x >= 4 && y >= 4 ? color1 : color2, b2.GetPixel(x, y));
}
- void BitmapCopyRegionResize(T color1, T color2)
+ void BitmapCopyRegionResize(T color1, T color2, IEqualityComparer comparer)
where T : struct, IEquatable
{
var b1 = new PixelBitmapContent(8, 8);
@@ -137,13 +137,15 @@ void BitmapCopyRegionResize(T color1, T color2)
for (var y = 0; y < b2.Height; y++)
for (var x = 0; x < b2.Width; x++)
- Assert.AreEqual(x < 3 && y < 6 ? color1 : color2, b2.GetPixel(x, y));
+ Assert.That(x < 3 && y < 6 ? color1 : color2, Is.EqualTo(b2.GetPixel(x, y)).Using(comparer));
}
[Test]
public void BitmapCopyFullNoResize()
{
+#if !XNA
BitmapCopyFullNoResize(56);
+#endif
BitmapCopyFullNoResize(0.56f);
BitmapCopyFullNoResize(Color.Red);
BitmapCopyFullNoResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f));
@@ -152,17 +154,21 @@ public void BitmapCopyFullNoResize()
[Test]
public void BitmapCopyFullResize()
{
- BitmapCopyFullResize(56);
- BitmapCopyFullResize(0.56f);
- BitmapCopyFullResize(Color.Red);
- BitmapCopyFullResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+#if !XNA
+ BitmapCopyFullResize(56, ByteComparer.Equal);
+#endif
+ BitmapCopyFullResize(0.56f, FloatComparer.Epsilon);
+ BitmapCopyFullResize(Color.Red, ColorComparer.Equal);
+ BitmapCopyFullResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), Vector4Comparer.Epsilon);
}
[Test]
public void BitmapConvertFullNoResize()
{
- BitmapConvertFullNoResize(byte.MaxValue, Color.White);
- BitmapConvertFullNoResize(1.0f, Color.White);
+#if !XNA
+ BitmapConvertFullNoResize(byte.MaxValue, Color.Red);
+#endif
+ BitmapConvertFullNoResize(1.0f, Color.Red);
BitmapConvertFullNoResize(Color.Red, new Vector4(1.0f, 0.0f, 0.0f, 1.0f));
BitmapConvertFullNoResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), Color.Red);
}
@@ -170,7 +176,9 @@ public void BitmapConvertFullNoResize()
[Test]
public void BitmapCompressFullNoResize()
{
+#if !XNA
BitmapCompressFullNoResize(56);
+#endif
BitmapCompressFullNoResize(0.56f);
BitmapCompressFullNoResize(Color.Red);
BitmapCompressFullNoResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f));
@@ -179,7 +187,9 @@ public void BitmapCompressFullNoResize()
[Test]
public void BitmapCompressFullResize()
{
+#if !XNA
BitmapCompressFullResize(56);
+#endif
BitmapCompressFullResize(0.56f);
BitmapCompressFullResize(Color.Red);
BitmapCompressFullResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f));
@@ -188,7 +198,9 @@ public void BitmapCompressFullResize()
[Test]
public void BitmapCopySameRegionNoResize()
{
+#if !XNA
BitmapCopySameRegionNoResize(56, 48);
+#endif
BitmapCopySameRegionNoResize(0.56f, 0.48f);
BitmapCopySameRegionNoResize(Color.Red, Color.Blue);
BitmapCopySameRegionNoResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f));
@@ -197,7 +209,9 @@ public void BitmapCopySameRegionNoResize()
[Test]
public void BitmapCopyMoveRegionNoResize()
{
+#if !XNA
BitmapCopyMoveRegionNoResize(56, 48);
+#endif
BitmapCopyMoveRegionNoResize(0.56f, 0.48f);
BitmapCopyMoveRegionNoResize(Color.Red, Color.Blue);
BitmapCopyMoveRegionNoResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f));
@@ -206,10 +220,12 @@ public void BitmapCopyMoveRegionNoResize()
[Test]
public void BitmapCopyRegionResize()
{
- BitmapCopyRegionResize(56, 48);
- BitmapCopyRegionResize(0.56f, 0.48f);
- BitmapCopyRegionResize(Color.Red, Color.Blue);
- BitmapCopyRegionResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f));
+#if !XNA
+ BitmapCopyRegionResize(56, 48, ByteComparer.Equal);
+#endif
+ BitmapCopyRegionResize(0.56f, 0.48f, FloatComparer.Epsilon);
+ BitmapCopyRegionResize(Color.Red, Color.Blue, ColorComparer.Equal);
+ BitmapCopyRegionResize(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), Vector4Comparer.Epsilon);
}
}
}
diff --git a/Test/Framework/Audio/SoundEffectTest.cs b/Test/Framework/Audio/SoundEffectTest.cs
index 7f52c1bf4b3..15649c1de1c 100644
--- a/Test/Framework/Audio/SoundEffectTest.cs
+++ b/Test/Framework/Audio/SoundEffectTest.cs
@@ -269,10 +269,14 @@ public void Ctor2()
Assert.Throws(() => new SoundEffect(new byte[2], 0, 2, 8000, AudioChannels.Mono, 0, int.MaxValue));
}
+ // TODO creating/disposing a Game should not create/dispose the master voice
+ [Test, Ignore]
public void InstanceNotDisposedWhenGameDisposed()
{
var game = new Game();
- var s = new SoundEffectInstance();
+
+ var se = new SoundEffect(new byte[16000], 8000, AudioChannels.Mono);
+ var s = se.CreateInstance();
var d = new DynamicSoundEffectInstance(44100, AudioChannels.Stereo);
game.Dispose();
@@ -417,4 +421,4 @@ public void FromStream_Unsupported_Formats(string filename)
Assert.Throws(() => SoundEffect.FromStream(stream));
}
}
-}
\ No newline at end of file
+}
diff --git a/Test/Framework/Bounding.cs b/Test/Framework/Bounding.cs
index 4459e6b05ef..cb38c0c9458 100644
--- a/Test/Framework/Bounding.cs
+++ b/Test/Framework/Bounding.cs
@@ -11,6 +11,31 @@ namespace MonoGame.Tests.Framework
[TestFixture]
class Bounding
{
+ [Test]
+ public void BoxContainsVector3Test()
+ {
+ var box = new BoundingBox(Vector3.Zero, Vector3.One);
+
+ Assert.AreEqual(ContainmentType.Disjoint, box.Contains(-Vector3.One));
+ Assert.AreEqual(ContainmentType.Disjoint, box.Contains(new Vector3(0.5f, 0.5f, -1f)));
+ Assert.AreEqual(ContainmentType.Contains, box.Contains(Vector3.Zero));
+ Assert.AreEqual(ContainmentType.Contains, box.Contains(new Vector3(0f, 0, 0.5f)));
+ Assert.AreEqual(ContainmentType.Contains, box.Contains(new Vector3(0f, 0.5f, 0.5f)));
+ Assert.AreEqual(ContainmentType.Contains, box.Contains(Vector3.One));
+ Assert.AreEqual(ContainmentType.Contains, box.Contains(new Vector3(1f, 1, 0.5f)));
+ Assert.AreEqual(ContainmentType.Contains, box.Contains(new Vector3(1f, 0.5f, 0.5f)));
+ Assert.AreEqual(ContainmentType.Contains, box.Contains(new Vector3(0.5f, 0.5f, 0.5f)));
+ }
+
+ [Test]
+ public void BoxContainsIdenticalBox()
+ {
+ var b1 = new BoundingBox(Vector3.Zero, Vector3.One);
+ var b2 = new BoundingBox(Vector3.Zero, Vector3.One);
+
+ Assert.AreEqual(ContainmentType.Contains, b1.Contains(b2));
+ }
+
[Test]
public void BoundingSphereTests()
{
diff --git a/Test/Framework/GameTest.cs b/Test/Framework/GameTest.cs
index dccb3104a6a..5a9720fdc74 100644
--- a/Test/Framework/GameTest.cs
+++ b/Test/Framework/GameTest.cs
@@ -1,86 +1,15 @@
-#region License
-/*
-Microsoft Public License (Ms-PL)
-MonoGame - Copyright © 2009-2012 The MonoGame Team
-
-All rights reserved.
-
-This license governs use of the accompanying software. If you use the software,
-you accept this license. If you do not accept the license, do not use the
-software.
-
-1. Definitions
-
-The terms "reproduce," "reproduction," "derivative works," and "distribution"
-have the same meaning here as under U.S. copyright law.
-
-A "contribution" is the original software, or any additions or changes to the
-software.
-
-A "contributor" is any person that distributes its contribution under this
-license.
-
-"Licensed patents" are a contributor's patent claims that read directly on its
-contribution.
-
-2. Grant of Rights
-
-(A) Copyright Grant- Subject to the terms of this license, including the
-license conditions and limitations in section 3, each contributor grants you a
-non-exclusive, worldwide, royalty-free copyright license to reproduce its
-contribution, prepare derivative works of its contribution, and distribute its
-contribution or any derivative works that you create.
-
-(B) Patent Grant- Subject to the terms of this license, including the license
-conditions and limitations in section 3, each contributor grants you a
-non-exclusive, worldwide, royalty-free license under its licensed patents to
-make, have made, use, sell, offer for sale, import, and/or otherwise dispose of
-its contribution in the software or derivative works of the contribution in the
-software.
-
-3. Conditions and Limitations
-
-(A) No Trademark License- This license does not grant you rights to use any
-contributors' name, logo, or trademarks.
-
-(B) If you bring a patent claim against any contributor over patents that you
-claim are infringed by the software, your patent license from such contributor
-to the software ends automatically.
-
-(C) If you distribute any portion of the software, you must retain all
-copyright, patent, trademark, and attribution notices that are present in the
-software.
-
-(D) If you distribute any portion of the software in source code form, you may
-do so only under this license by including a complete copy of this license with
-your distribution. If you distribute any portion of the software in compiled or
-object code form, you may only do so under a license that complies with this
-license.
-
-(E) The software is licensed "as-is." You bear the risk of using it. The
-contributors give no express warranties, guarantees or conditions. You may have
-additional consumer rights under your local laws which this license cannot
-change. To the extent permitted under your local laws, the contributors exclude
-the implied warranties of merchantability, fitness for a particular purpose and
-non-infringement.
-*/
-#endregion License
+// MonoGame - Copyright (C) The MonoGame Team
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE.txt', which is part of this source code package.
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
-using System.Linq.Expressions;
using System.Reflection;
-using System.Text;
-using System.Threading;
using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
-
using NUnit.Framework;
-using NUnit.Framework.Constraints;
namespace MonoGame.Tests {
static partial class GameTest {
@@ -239,6 +168,113 @@ public void Fixed_time_step_skips_draw_when_update_is_slow ()
}
}
+ [TestFixture]
+ public class Misc
+ {
+ [Test]
+ // TODO MG crashes when no graphicsDeviceManager is set and Run is called
+ [Ignore]
+ public void LoadContentNotCalledWithoutGdm()
+ {
+ var g = new CountCallsGame();
+ g.PublicInitialize();
+
+ Assert.AreEqual(0, g.LoadContentCount);
+
+ g.Dispose();
+ }
+
+ [Test]
+ // TODO MG crashes when no GraphicsDevice is set and Run is called
+ [Ignore]
+ public void LoadContentNotCalledWithoutGd()
+ {
+ var g = new CountCallsGame();
+ var gdm = new GraphicsDeviceManager(g);
+
+ g.PublicInitialize();
+
+ Assert.AreEqual(0, g.LoadContentCount);
+
+ g.Dispose();
+ }
+
+ [Test]
+ public void ExitHappensAtEndOfTick()
+ {
+ // Exit called in Run
+ var g = new ExitTestGame();
+
+ // TODO this is not necessary for XNA, but MG crashes when no GDM is set and Run is called
+ new GraphicsDeviceManager(g);
+ g.Run();
+ Assert.AreEqual(2, g.UpdateCount);
+ Assert.AreEqual(0, g.DrawCount); // Draw should be suppressed
+ Assert.AreEqual(1, g.ExitingCount);
+
+ g.Dispose();
+ }
+
+ private class ExitTestGame : CountCallsGame
+ {
+ private int count = 0;
+
+ protected override void Update(GameTime gameTime)
+ {
+ if (count > 0)
+ Exit();
+
+ base.Update(gameTime);
+ Assert.IsNotNull(Window);
+ Assert.AreEqual(0, ExitingCount);
+
+ count++;
+ }
+ }
+
+ private class CountCallsGame : Game
+ {
+ public int BeginRunCount { get; set; }
+ public int InitializeCount { get; set; }
+ public int LoadContentCount { get; set; }
+ public int UnloadContentCount { get; set; }
+ public int UpdateCount { get; set; }
+ public int BeginDrawCount { get; set; }
+ public int DrawCount { get; set; }
+ public int EndDrawCount { get; set; }
+ public int EndRunCount { get; set; }
+ public int DeactivatedCount { get; set; }
+ public int ActivatedCount { get; set; }
+ public int ExitingCount { get; set; }
+ public int DisposeCount { get; set; }
+
+ public void PublicBeginRun() { BeginRun(); }
+ protected override void BeginRun() { BeginRunCount++; base.BeginRun(); }
+ public void PublicInitialize() { Initialize(); }
+ protected override void Initialize() { InitializeCount++; base.Initialize(); }
+ public void PublicLoadContent() { LoadContent(); }
+ protected override void LoadContent() { LoadContentCount++; base.LoadContent(); }
+ public void PublicUnloadContent() { UnloadContent(); }
+ protected override void UnloadContent() { UnloadContentCount++; base.UnloadContent(); }
+ public void PublicUpdate(GameTime gt = null) { Update(gt ?? new GameTime()); }
+ protected override void Update(GameTime gameTime) { UpdateCount++; base.Update(gameTime); }
+ public bool PublicBeginDraw() { return BeginDraw(); }
+ protected override bool BeginDraw() { BeginDrawCount++; return base.BeginDraw(); }
+ public void PublicDraw(GameTime gt) { Draw(gt ?? new GameTime()); }
+ protected override void Draw(GameTime gameTime) { DrawCount++; base.Draw(gameTime); }
+ public bool PublicEndDraw() { return BeginDraw(); }
+ protected override void EndDraw() { EndDrawCount++; base.EndDraw(); }
+ public void PublicEndRun() { EndRun(); }
+ protected override void EndRun() { EndRunCount++; base.EndRun(); }
+
+ protected override void OnActivated(object sender, EventArgs args) { ActivatedCount++; base.OnActivated(sender, args); }
+ protected override void OnDeactivated(object sender, EventArgs args) { DeactivatedCount++; base.OnDeactivated(sender, args); }
+ protected override void OnExiting(object sender, EventArgs args) { ExitingCount++; base.OnExiting(sender, args); }
+ protected override void Dispose(bool disposing) { DisposeCount++; base.Dispose(disposing); }
+ }
+
+ }
+
public class MockGame : TestGameBase {
public MockGame ()
{
diff --git a/Test/Framework/Graphics/GraphicsAdapterTest.cs b/Test/Framework/Graphics/GraphicsAdapterTest.cs
index baa5745597a..520cc73e6c7 100644
--- a/Test/Framework/Graphics/GraphicsAdapterTest.cs
+++ b/Test/Framework/Graphics/GraphicsAdapterTest.cs
@@ -55,9 +55,14 @@ public static void Adapters()
Assert.GreaterOrEqual(adapter.SupportedDisplayModes.Count(), 1);
Assert.AreEqual(1, adapter.SupportedDisplayModes.Count(m => Equals(m, adapter.CurrentDisplayMode)));
- // Seems like XNA treats aspect ratios above 16:10 as wide screen.
+ // Seems like XNA treats aspect ratios above 16:10 as wide screen. A 1680x1050 display (exactly 16:10) was considered not to be wide screen.
+ // MonoGame considers ratios equal or greater than 16:10 to be wide screen.
const float minWideScreenAspect = 16.0f / 10.0f;
+#if XNA
+ var isWidescreen = adapter.CurrentDisplayMode.AspectRatio > minWideScreenAspect;
+#else
var isWidescreen = adapter.CurrentDisplayMode.AspectRatio >= minWideScreenAspect;
+#endif
Assert.AreEqual(isWidescreen, adapter.IsWideScreen);
foreach (var mode in adapter.SupportedDisplayModes)
diff --git a/Test/Framework/Graphics/GraphicsDeviceManagerTest.cs b/Test/Framework/Graphics/GraphicsDeviceManagerTest.cs
index 06481187f26..d9f0135bb1b 100644
--- a/Test/Framework/Graphics/GraphicsDeviceManagerTest.cs
+++ b/Test/Framework/Graphics/GraphicsDeviceManagerTest.cs
@@ -36,12 +36,70 @@ public void DefaultParameterValidation()
game.Dispose();
}
+ [Test]
+ public void InitializeEventCount()
+ {
+ var game = new TestGameBase();
+ var gdm = new GraphicsDeviceManager(game);
+
+ var resettingCount = 0;
+ var resetCount = 0;
+ var preparingCount = 0;
+ var createdCount = 0;
+ var devDispCount = 0;
+ var dispCount = 0;
+
+ gdm.DeviceResetting += (s, a) => resettingCount++;
+ gdm.DeviceReset += (s, a) => resetCount++;
+ gdm.PreparingDeviceSettings += (s, a) => preparingCount++;
+ gdm.DeviceCreated += (s, a) => createdCount++;
+ gdm.DeviceDisposing += (s, a) => devDispCount++;
+ // TODO: re-add this when DesktopGL platfrom uses the new GDM
+#if !DESKTOPGL
+ gdm.Disposed += (s, a) => dispCount++;
+#endif
+
+ game.InitializeOnly();
+
+ Assert.AreEqual(0, resettingCount);
+ Assert.AreEqual(0, resetCount);
+ Assert.AreEqual(1, preparingCount);
+ Assert.AreEqual(1, createdCount);
+ Assert.AreEqual(0, devDispCount);
+ Assert.AreEqual(0, dispCount);
+
+ game.Dispose();
+ }
+
+ [Test]
+ public void DoNotModifyPresentationParametersDirectly()
+ {
+ var game = new TestGameBase();
+ var gdm = new GraphicsDeviceManager(game);
+
+ game.InitializeWith += (sender, args) =>
+ {
+ var gd = game.GraphicsDevice;
+
+ var oldpp = gd.PresentationParameters;
+ gdm.PreferredBackBufferWidth = 100;
+ gdm.ApplyChanges();
+ var newpp = gd.PresentationParameters;
+ Assert.AreNotSame(oldpp, newpp);
+ };
+
+ game.InitializeOnly();
+ game.Dispose();
+ }
+
[Test]
public void PreparingDeviceSettings()
{
var game = new TestGameBase();
var gdm = new GraphicsDeviceManager(game);
+ var count = 0;
+
gdm.PreparingDeviceSettings += (sender, args) =>
{
Assert.NotNull(args.GraphicsDeviceInformation);
@@ -63,22 +121,279 @@ public void PreparingDeviceSettings()
Assert.AreEqual(DisplayOrientation.Default, pp.DisplayOrientation);
Assert.AreEqual(RenderTargetUsage.DiscardContents, pp.RenderTargetUsage);
Assert.AreEqual(0, pp.MultiSampleCount);
+
+ count++;
+ };
+
+ game.InitializeOnly();
+ Assert.AreEqual(1, count);
+ game.Dispose();
+ }
+
+ [Test]
+ public void PreparingDeviceSettingsEventChangeGraphicsProfile()
+ {
+ var game = new TestGameBase();
+ var gdm = new GraphicsDeviceManager(game);
+
+ Assert.AreEqual(GraphicsProfile.Reach, gdm.GraphicsProfile);
+
+ game.InitializeOnly();
+
+ var invoked = false;
+ gdm.PreparingDeviceSettings += (s, a) =>
+ {
+ a.GraphicsDeviceInformation.GraphicsProfile = GraphicsProfile.HiDef;
+ invoked = true;
+ };
+
+ // make sure that changing the graphics profile creates a new device and does not reset
+ var creationCount = 0;
+ gdm.DeviceCreated += (sender, args) => creationCount++;
+ var resetCount = 0;
+ gdm.DeviceReset += (sender, args) => resetCount++;
+
+ // make a change so ApplyChanges actually does something
+ gdm.PreferredBackBufferWidth = 100;
+ gdm.ApplyChanges();
+
+ // assert that PreparingDeviceSettings is invoked, but the GraphicsProfile of the gdm did not change
+ Assert.That(invoked);
+ Assert.AreEqual(GraphicsProfile.Reach, gdm.GraphicsProfile);
+ Assert.AreEqual(GraphicsProfile.HiDef, gdm.GraphicsDevice.GraphicsProfile);
+
+ Assert.AreEqual(creationCount, 1);
+ Assert.AreEqual(resetCount, 0);
+
+ game.Dispose();
+ }
+
+ [Test]
+ public void PreparingDeviceSettingsArgsPresentationParametersAreApplied()
+ {
+ var game = new TestGameBase();
+ var gdm = new GraphicsDeviceManager(game);
+
+ var invoked = false;
+
+ game.PreInitializeWith += (sender, args) =>
+ {
+ Assert.AreEqual(RenderTargetUsage.DiscardContents,
+ gdm.GraphicsDevice.PresentationParameters.RenderTargetUsage);
+
+ gdm.PreparingDeviceSettings += (s, a) =>
+ {
+ a.GraphicsDeviceInformation.GraphicsProfile = GraphicsProfile.HiDef;
+ a.GraphicsDeviceInformation.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
+ invoked = true;
+ };
+ };
+
+ game.InitializeOnly();
+
+ // make a change so ApplyChanges actually does something
+ gdm.PreferredBackBufferWidth = 100;
+ gdm.ApplyChanges();
+
+ Assert.That(invoked);
+ Assert.AreEqual(RenderTargetUsage.PreserveContents, gdm.GraphicsDevice.PresentationParameters.RenderTargetUsage);
+
+ game.Dispose();
+ }
+
+ [Test]
+ public void PreparingDeviceSettingsArgsThrowsWhenPPSetToNull()
+ {
+ var game = new TestGameBase();
+ var gdm = new GraphicsDeviceManager(game);
+
+ var invoked = false;
+
+ gdm.PreparingDeviceSettings += (s, a) =>
+ {
+ a.GraphicsDeviceInformation.PresentationParameters = null;
+ invoked = true;
+ };
+
+ Assert.Throws(Is.InstanceOf(typeof(Exception)), () => game.InitializeOnly());
+ Assert.That(invoked);
+
+ game.Dispose();
+ }
+
+ [Test]
+ public void ApplyChangesReturnsWhenNoSetterCalled()
+ {
+ var game = new TestGameBase();
+ var gdm = new GraphicsDeviceManager(game);
+
+ var invoked = false;
+
+ game.PreInitializeWith += (sender, args) =>
+ {
+ gdm.PreparingDeviceSettings += (s, a) =>
+ {
+ invoked = true;
+ };
+ };
+
+ game.InitializeOnly();
+
+ gdm.ApplyChanges();
+ Assert.IsFalse(invoked);
+
+ // this proves that XNA does not check for equality, but just registers that setters are used
+ gdm.PreferredBackBufferWidth = gdm.PreferredBackBufferWidth;
+
+ gdm.ApplyChanges();
+ Assert.That(invoked);
+
+ game.Dispose();
+ }
+
+ [Test]
+ public void ApplyChangesInvokesPreparingDeviceSettings()
+ {
+ var game = new TestGameBase();
+ var gdm = new GraphicsDeviceManager(game);
+
+ var invoked = false;
+
+ game.InitializeWith += (sender, args) =>
+ {
+ gdm.PreparingDeviceSettings += (s, a) =>
+ {
+ invoked = true;
+ };
};
- game.ExitCondition = x => x.DrawNumber > 1;
- game.Run();
+ game.InitializeOnly();
+
+ gdm.PreferredBackBufferWidth = gdm.PreferredBackBufferWidth;
+ gdm.ApplyChanges();
+ Assert.That(invoked);
+
game.Dispose();
}
+ [Test]
+ public void ApplyChangesResetsDevice()
+ {
+ var game = new TestGameBase();
+ var gdm = new GraphicsDeviceManager(game);
+
+ var count = 0;
+
+ gdm.DeviceReset += (sender, args) => count++;
+
+ game.InitializeOnly();
+
+ gdm.PreferredBackBufferWidth = gdm.PreferredBackBufferWidth;
+ gdm.ApplyChanges();
+ Assert.AreEqual(1, count);
+
+ game.Dispose();
+ }
+
+ [Test]
+ public void DeviceDisposingInvokedAfterDeviceDisposed()
+ {
+ var game = new TestGameBase();
+ var gdm = new GraphicsDeviceManager(game);
+
+ var invoked = false;
+
+ gdm.DeviceDisposing += (sender, args) =>
+ {
+ invoked = true;
+ Assert.IsTrue(gdm.GraphicsDevice.IsDisposed);
+ };
+
+ game.InitializeOnly();
+
+ Assert.IsFalse(gdm.GraphicsDevice.IsDisposed);
+ Assert.IsFalse(invoked);
+ // change the graphics profile so the current device needs to be disposed
+ gdm.GraphicsProfile = GraphicsProfile.HiDef;
+ gdm.ApplyChanges();
+ Assert.IsTrue(invoked);
+
+ game.Dispose();
+
+ }
+ }
+
+ internal class GraphicsDeviceManagerFixtureTest : GraphicsDeviceTestFixtureBase
+ {
+ [Test]
+ public void ResettingDeviceTriggersGdmEvents()
+ {
+ var resetCount = 0;
+ var resettingCount = 0;
+ gdm.DeviceReset += (sender, args) =>
+ {
+ resetCount++;
+ };
+
+ gdm.DeviceResetting += (sender, args) =>
+ {
+ resettingCount++;
+ };
+
+ gd.Reset();
+
+ Assert.AreEqual(1, resetCount);
+ Assert.AreEqual(1, resettingCount);
+ }
+
+ [Test]
+ public void ClientSizeChangedOnDeviceReset()
+ {
+ var count = 0;
+ game.Window.ClientSizeChanged += (sender, args) =>
+ {
+ count++;
+ };
+ gdm.GraphicsProfile = GraphicsProfile.HiDef;
+ gdm.ApplyChanges();
+ Assert.AreEqual(0, count);
+
+ gdm.PreferredBackBufferWidth = 100;
+ gdm.ApplyChanges();
+ Assert.AreEqual(0, count);
+
+ // changing the profile will trigger a device reset
+ gdm.GraphicsProfile = GraphicsProfile.Reach;
+ gdm.ApplyChanges();
+ // not even that will trigger the event
+ Assert.AreEqual(0, count);
+ }
+
+ [Test]
+ public void MultiSampleCountRoundsDown()
+ {
+ gdm.PreferMultiSampling = true;
+
+ gdm.PreparingDeviceSettings += (sender, args) =>
+ {
+ var pp = args.GraphicsDeviceInformation.PresentationParameters;
+ pp.MultiSampleCount = 3;
+ };
+
+ gdm.ApplyChanges();
+
+ Assert.AreEqual(2, gd.PresentationParameters.MultiSampleCount);
+
+ }
+
[TestCase(false)]
[TestCase(true)]
public void MSAAEnabled(bool enabled)
{
- var game = new TestGameBase();
- var gdm = new GraphicsDeviceManager(game);
gdm.PreferMultiSampling = enabled;
gdm.GraphicsProfile = GraphicsProfile.HiDef;
+ // first hook an event to do some checks
gdm.PreparingDeviceSettings += (sender, args) =>
{
var pp = args.GraphicsDeviceInformation.PresentationParameters;
@@ -91,43 +406,31 @@ public void MSAAEnabled(bool enabled)
}
};
- Texture2D tex = null;
- SpriteBatch spriteBatch = null;
+ // then create a GraphicsDevice
+ gdm.ApplyChanges();
- game.PreInitializeWith += (sender, args) =>
- {
- tex = new Texture2D(game.GraphicsDevice, 1, 1);
- tex.SetData(new[] { Color.White.PackedValue });
- spriteBatch = new SpriteBatch(game.GraphicsDevice);
- };
+ var tex = new Texture2D(gd, 1, 1);
+ tex.SetData(new[] { Color.White.PackedValue });
+ var spriteBatch = new SpriteBatch(gd);
- game.PreDrawWith += (sender, args) =>
+ if (enabled)
{
- if (enabled)
- {
- var pp = game.GraphicsDevice.PresentationParameters;
- Assert.Less(0, pp.MultiSampleCount);
- Assert.AreNotEqual(1024, pp.MultiSampleCount);
- }
+ var pp = gd.PresentationParameters;
+ Assert.Less(0, pp.MultiSampleCount);
+ Assert.AreNotEqual(1024, pp.MultiSampleCount);
+ }
- game.GraphicsDevice.Clear(Color.Black);
+ gd.Clear(Color.Black);
- spriteBatch.Begin();
- spriteBatch.Draw(tex, new Vector2(800 / 2, 480 / 2), null, Color.White, MathHelper.ToRadians(45), new Vector2(0.5f), 200, SpriteEffects.None, 0);
- spriteBatch.End();
- };
+ spriteBatch.Begin();
+ spriteBatch.Draw(tex, new Vector2(800 / 2, 480 / 2), null, Color.White, MathHelper.ToRadians(45), new Vector2(0.5f), 200, SpriteEffects.None, 0);
+ spriteBatch.End();
#if XNA
var data = new Color[800 * 480];
- game.DrawWith += (sender, args) =>
- {
- game.GraphicsDevice.GetBackBufferData(data);
- };
+ gd.GetBackBufferData(data);
#endif
- game.ExitCondition = x => x.DrawNumber > 1;
- game.Run();
-
#if XNA
float black = 0;
float white = 0;
@@ -164,7 +467,6 @@ public void MSAAEnabled(bool enabled)
tex.Dispose();
spriteBatch.Dispose();
- game.Dispose();
}
}
}
\ No newline at end of file
diff --git a/Test/Framework/Graphics/GraphicsDeviceTest.cs b/Test/Framework/Graphics/GraphicsDeviceTest.cs
index d6908df2a1c..253361e072d 100644
--- a/Test/Framework/Graphics/GraphicsDeviceTest.cs
+++ b/Test/Framework/Graphics/GraphicsDeviceTest.cs
@@ -34,6 +34,100 @@ public void BlendFactor()
blend.Dispose();
}
+ [Test]
+ public void CtorAdapterNull()
+ {
+ Assert.Throws(
+ () => new GraphicsDevice(null, GraphicsProfile.Reach, new PresentationParameters()));
+ }
+
+ [Test]
+ public void CtorPresentationParametersNull()
+ {
+ Assert.Throws(
+ () => new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, null));
+ }
+
+ [Test]
+ public void DisposedWhenDisposingInvoked()
+ {
+ var count = 0;
+
+ gd.Disposing += (sender, args) =>
+ {
+ Assert.IsTrue(gd.IsDisposed);
+ count++;
+ };
+
+ gd.Dispose();
+ Assert.AreEqual(1, count);
+
+ // Disposing should not be invoked more than once
+ gd.Dispose();
+ Assert.AreEqual(1, count);
+ }
+
+ [Test]
+ public void ResetInvokedBeforeDeviceLost()
+ {
+ var resetCount = 0;
+ var devLostCount = 0;
+
+ gd.DeviceReset += (sender, args) =>
+ {
+ resetCount++;
+ Assert.AreEqual(0, devLostCount);
+ };
+
+ gd.DeviceLost += (sender, args) =>
+ {
+ devLostCount++;
+ Assert.AreEqual(1, resetCount);
+ };
+
+ gd.Reset();
+
+ Assert.AreEqual(1, resetCount);
+ Assert.AreEqual(1, devLostCount);
+ }
+
+ // TODO Make sure dynamic graphics resources are notified when graphics device is lost
+ [Test, Ignore]
+ public void ContentLostResources()
+ {
+ // https://blogs.msdn.microsoft.com/shawnhar/2007/12/12/virtualizing-the-graphicsdevice-in-xna-game-studio-2-0/
+
+ var rt = new RenderTarget2D(gdm.GraphicsDevice, 5, 5);
+ var vb = new DynamicVertexBuffer(gd, VertexPositionColor.VertexDeclaration, 1, BufferUsage.None);
+ var ib = new DynamicIndexBuffer(gd, IndexElementSize.SixteenBits, 1, BufferUsage.None);
+ var rtc = new RenderTargetCube(gd, 1, false, SurfaceFormat.Color, DepthFormat.Depth16);
+
+ gd.Reset();
+
+ Assert.IsTrue(rt.IsContentLost);
+ Assert.IsFalse(rt.IsDisposed);
+
+ Assert.IsTrue(vb.IsContentLost);
+ Assert.IsFalse(vb.IsDisposed);
+
+ Assert.IsTrue(ib.IsContentLost);
+ Assert.IsFalse(ib.IsDisposed);
+
+ Assert.IsTrue(rtc.IsContentLost);
+ Assert.IsFalse(rtc.IsDisposed);
+
+ rt.Dispose();
+ vb.Dispose();
+ ib.Dispose();
+ rtc.Dispose();
+ }
+
+ [Test]
+ public void ResetWindowHandleNullThrowsException()
+ {
+ Assert.Throws(() => gd.Reset(new PresentationParameters()));
+ }
+
[Test]
public void Clear()
{
@@ -599,5 +693,26 @@ public void VertexSamplerStatesGetSet()
samplerState.Dispose();
}
+
+ [Test]
+ public void PresentInvalidOperationException()
+ {
+ // This should work else it means we had
+ // some bad state to start this test!
+ gd.Present();
+
+ // You can't call present with a RT set.
+ var rt = new RenderTarget2D(gd, 100, 100);
+ gd.SetRenderTarget(rt);
+ Assert.Throws(() => gd.Present());
+
+ // Set the default RT and present works again.
+ gd.SetRenderTarget(null);
+ gd.Present();
+
+ // Cleanup.
+ rt.Dispose();
+ }
+
}
-}
\ No newline at end of file
+}
diff --git a/Test/Framework/Graphics/RasterizerStateTest.cs b/Test/Framework/Graphics/RasterizerStateTest.cs
index d1d90638564..afad2745bbc 100644
--- a/Test/Framework/Graphics/RasterizerStateTest.cs
+++ b/Test/Framework/Graphics/RasterizerStateTest.cs
@@ -13,6 +13,53 @@ namespace MonoGame.Tests.Graphics
[TestFixture]
internal class RasterizerStateTest : GraphicsDeviceTestFixtureBase
{
+ [TestCase(-1f)]
+ [TestCase(1f)]
+ [TestCase(-0.0004f)]
+ public void DepthBiasVisualTest(float depthBias)
+ {
+ var effect = new BasicEffect(gd)
+ {
+ VertexColorEnabled = true,
+ World = Matrix.Identity,
+ View = Matrix.Identity,
+ Projection = Matrix.Identity,
+ };
+ RasterizerState rs;
+ var data = new VertexPositionColor[3];
+ var step = depthBias / 4;
+
+ PrepareFrameCapture();
+ for (var i = 0; i < 4; i++)
+ {
+ var r = i * MathHelper.PiOver2;
+ var bias = i * step;
+ var c = new Color(new Vector3(i / 4f));
+
+ rs = new RasterizerState();
+ rs.DepthBias = bias;
+
+ var rot = Matrix.CreateRotationZ(-r);
+ var v1 = Vector3.Transform(new Vector3(-0.5f, 0f, 0f), rot);
+ var v2 = Vector3.Transform(new Vector3(0.2f, 0.9f, 0f), rot);
+ var v3 = Vector3.Transform(new Vector3(0.2f, -0.9f, 0f), rot);
+
+ data[0] = new VertexPositionColor(v1, c);
+ data[1] = new VertexPositionColor(v2, c);
+ data[2] = new VertexPositionColor(v3, c);
+
+ effect.CurrentTechnique.Passes[0].Apply();
+ gd.RasterizerState = rs;
+ gd.DrawUserPrimitives(PrimitiveType.TriangleList, data, 0, 1, VertexPositionColor.VertexDeclaration);
+
+ rs.Dispose();
+ }
+
+ CheckFrames();
+
+ effect.Dispose();
+ }
+
[Test]
public void ShouldNotBeAbleToSetNullRasterizerState()
{
diff --git a/Test/Framework/Graphics/RenderTarget2DTest.cs b/Test/Framework/Graphics/RenderTarget2DTest.cs
index 5cf7d478f6e..e54e6f03867 100644
--- a/Test/Framework/Graphics/RenderTarget2DTest.cs
+++ b/Test/Framework/Graphics/RenderTarget2DTest.cs
@@ -2,6 +2,7 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
+using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using NUnit.Framework;
@@ -12,6 +13,15 @@ namespace MonoGame.Tests.Graphics
class RenderTarget2DTest : GraphicsDeviceTestFixtureBase
{
[Test]
+ public void ZeroSizeShouldFailTest()
+ {
+ RenderTarget2D renderTarget;
+ Assert.Throws(() => renderTarget = new RenderTarget2D(gd, 0, 1));
+ Assert.Throws(() => renderTarget = new RenderTarget2D(gd, 1, 0));
+ Assert.Throws(() => renderTarget = new RenderTarget2D(gd, 0, 0));
+ }
+
+ [Test]
#if XNA
[Ignore]
#endif
diff --git a/Test/Framework/Graphics/RenderTargetCubeTest.cs b/Test/Framework/Graphics/RenderTargetCubeTest.cs
index 11ac39686a2..31a2c0a975c 100644
--- a/Test/Framework/Graphics/RenderTargetCubeTest.cs
+++ b/Test/Framework/Graphics/RenderTargetCubeTest.cs
@@ -2,6 +2,7 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
+using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using NUnit.Framework;
@@ -11,6 +12,13 @@ namespace MonoGame.Tests.Graphics
[TestFixture]
class RenderTargetCubeTest : GraphicsDeviceTestFixtureBase
{
+ [Test]
+ public void ZeroSizeShouldFailTest()
+ {
+ RenderTargetCube renderTarget;
+ Assert.Throws(() => renderTarget = new RenderTargetCube(gd, 0, false, SurfaceFormat.Color, DepthFormat.None));
+ }
+
[TestCase(1)]
[TestCase(8)]
[TestCase(31)]
diff --git a/Test/Framework/Graphics/SpriteBatchTest.cs b/Test/Framework/Graphics/SpriteBatchTest.cs
index 5714b7fa81a..45a778c4b52 100644
--- a/Test/Framework/Graphics/SpriteBatchTest.cs
+++ b/Test/Framework/Graphics/SpriteBatchTest.cs
@@ -11,6 +11,8 @@ class SpriteBatchTest : GraphicsDeviceTestFixtureBase {
private Texture2D _texture;
private Texture2D _texture2;
private Texture2D _texture3;
+ private BasicEffect _effect;
+ private Effect _effect2;
[SetUp]
public override void SetUp ()
@@ -21,6 +23,20 @@ public override void SetUp ()
_texture = content.Load (Paths.Texture ("MonoGameIcon"));
_texture2 = content.Load(Paths.Texture("Surge"));
_texture3 = content.Load (Paths.Texture ("Lines-64"));
+ _effect = new BasicEffect(gd)
+ {
+ VertexColorEnabled = true,
+ TextureEnabled = true,
+ View = Matrix.Identity,
+ World = Matrix.Identity
+ };
+ var effect2Name = "Grayscale";
+#if XNA
+ effect2Name = System.IO.Path.Combine("XNA", effect2Name);
+#elif WINDOWS
+ effect2Name = System.IO.Path.Combine("DirectX", effect2Name);
+#endif
+ _effect2 = content.Load(Paths.Effect(effect2Name));
}
[TearDown]
@@ -30,6 +46,8 @@ public override void TearDown()
_texture.Dispose();
_texture2.Dispose();
_texture3.Dispose();
+ _effect.Dispose();
+ _effect2.Dispose();
}
[Test]
@@ -380,5 +398,80 @@ public void Draw_many()
CheckFrames();
}
+
+ [TestCase(SpriteSortMode.Deferred)]
+ [TestCase(SpriteSortMode.Immediate)]
+ public void Draw_with_viewport_changing(SpriteSortMode sortMode)
+ {
+ Similarity = 0.975f;
+ PrepareFrameCapture();
+
+ // Test SpriteEffect
+ var vp = gd.Viewport;
+ var lvp = new Viewport (vp.X, vp.Y, vp.Width/3, vp.Height); //Left
+ var mvp = new Viewport(vp.X + vp.Width / 3, vp.Y, vp.Width / 3, vp.Height); //middle
+ var rvp = new Viewport(vp.X+(vp.Width /3)*2, vp.Y, vp.Width / 3, vp.Height); //Right
+
+ // Test viewport change
+ gd.Viewport = rvp;
+ _spriteBatch.Begin(sortMode, BlendState.AlphaBlend);
+ _spriteBatch.Draw(_texture, new Vector2(10, 10), null, Color.White);
+ gd.Viewport = mvp;
+ _spriteBatch.Draw(_texture2, new Vector2(70, 10), null, Color.White);
+ gd.Viewport = lvp;
+ _spriteBatch.Draw(_texture3, new Vector2(130, 10), null, Color.White);
+ gd.Viewport = vp;
+ _spriteBatch.Draw(_texture2, new Vector2(190, 10), null, Color.White);
+ _spriteBatch.End();
+
+ // Test viewport/effect BasicEffect (Vertex & Pixel shader)
+#if DIRECTX
+ Matrix halfPixelOffset = Matrix.Identity;
+#else
+ Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
+#endif
+
+ _effect.Projection = halfPixelOffset * Matrix.CreateOrthographicOffCenter(0, gd.Viewport.Width, gd.Viewport.Height, 0, 0, 1);
+
+ gd.Viewport = rvp;
+ _spriteBatch.Begin(sortMode, BlendState.AlphaBlend, null, null, null, _effect);
+ _spriteBatch.Draw(_texture, new Vector2(10, 110), null, Color.White);
+ gd.Viewport = mvp;
+ _spriteBatch.Draw(_texture2, new Vector2(70, 110), null, Color.White);
+ gd.Viewport = lvp;
+ _spriteBatch.Draw(_texture3, new Vector2(130, 110), null, Color.White);
+ gd.Viewport = vp;
+ _spriteBatch.Draw(_texture2, new Vector2(190, 110), null, Color.White);
+ _spriteBatch.End();
+
+ // Test BasicEffect (Vertex & Pixel shader)
+ // re-apply projection when viewport dimensions change
+ gd.Viewport = rvp;
+ _effect.Projection = halfPixelOffset * Matrix.CreateOrthographicOffCenter(0, gd.Viewport.Width, gd.Viewport.Height, 0, 0, 1);
+ _spriteBatch.Begin(sortMode, BlendState.AlphaBlend, null, null, null, _effect);
+ _spriteBatch.Draw(_texture, new Vector2(10, 210), null, Color.White);
+ gd.Viewport = mvp;
+ _spriteBatch.Draw(_texture2, new Vector2(70, 210), null, Color.White);
+ gd.Viewport = lvp;
+ _spriteBatch.Draw(_texture3, new Vector2(130, 210), null, Color.White);
+ gd.Viewport = vp;
+ _effect.Projection = halfPixelOffset * Matrix.CreateOrthographicOffCenter(0, gd.Viewport.Width, gd.Viewport.Height, 0, 0, 1);
+ _spriteBatch.Draw(_texture2, new Vector2(190, 210), null, Color.White);
+ _spriteBatch.End();
+
+ // TODO: test custom Effect with no Vertex shader
+ gd.Viewport = rvp;
+ _spriteBatch.Begin(sortMode, BlendState.AlphaBlend, null, null, null, _effect2);
+ _spriteBatch.Draw(_texture, new Vector2(10, 310), null, Color.White);
+ gd.Viewport = mvp;
+ _spriteBatch.Draw(_texture2, new Vector2(70, 310), null, Color.White);
+ gd.Viewport = lvp;
+ _spriteBatch.Draw(_texture3, new Vector2(130, 310), null, Color.White);
+ gd.Viewport = vp;
+ _spriteBatch.Draw(_texture2, new Vector2(190, 310), null, Color.White);
+ _spriteBatch.End();
+
+ CheckFrames();
+ }
}
}
diff --git a/Test/Framework/Graphics/Texture2DNonVisualTest.cs b/Test/Framework/Graphics/Texture2DNonVisualTest.cs
index 39eb1809e41..611ed81aef3 100644
--- a/Test/Framework/Graphics/Texture2DNonVisualTest.cs
+++ b/Test/Framework/Graphics/Texture2DNonVisualTest.cs
@@ -73,6 +73,15 @@ public void FromStreamArgumentNullTest()
#endif
}
+ [Test]
+ public void ZeroSizeShouldFailTest()
+ {
+ Texture2D texture;
+ Assert.Throws(() => texture = new Texture2D(gd, 0, 1));
+ Assert.Throws(() => texture = new Texture2D(gd, 1, 0));
+ Assert.Throws(() => texture = new Texture2D(gd, 0, 0));
+ }
+
[TestCase(25, 23, 1, 1, 0, 1)]
[TestCase(25, 23, 1, 1, 1, 1)]
[TestCase(25, 23, 2, 1, 0, 2)]
diff --git a/Test/Framework/Graphics/Texture3DNonVisualTest.cs b/Test/Framework/Graphics/Texture3DNonVisualTest.cs
index cea9f4f2e49..6723791ca41 100644
--- a/Test/Framework/Graphics/Texture3DNonVisualTest.cs
+++ b/Test/Framework/Graphics/Texture3DNonVisualTest.cs
@@ -24,11 +24,7 @@ public void TestFixtureSetUp()
_game = new Game();
var graphicsDeviceManager = new GraphicsDeviceManager(_game);
graphicsDeviceManager.GraphicsProfile = GraphicsProfile.HiDef;
-#if XNA
graphicsDeviceManager.ApplyChanges();
-#else
- graphicsDeviceManager.CreateDevice();
-#endif
t = new Texture3D(_game.GraphicsDevice, w, h, d, false, SurfaceFormat.Color);
for (int layer = 0; layer < d; layer++)
@@ -52,6 +48,21 @@ public void TestSetUp()
{
t.SetData(reference);
}
+
+ [Test]
+ public void ZeroSizeShouldFailTest()
+ {
+ Texture3D texture;
+ var gd = _game.GraphicsDevice;
+ Assert.Throws(() => texture = new Texture3D(gd, 0, 1, 1, false, SurfaceFormat.Color));
+ Assert.Throws(() => texture = new Texture3D(gd, 1, 0, 1, false, SurfaceFormat.Color));
+ Assert.Throws(() => texture = new Texture3D(gd, 1, 1, 0, false, SurfaceFormat.Color));
+ Assert.Throws(() => texture = new Texture3D(gd, 0, 0, 1, false, SurfaceFormat.Color));
+ Assert.Throws(() => texture = new Texture3D(gd, 1, 0, 0, false, SurfaceFormat.Color));
+ Assert.Throws(() => texture = new Texture3D(gd, 0, 1, 0, false, SurfaceFormat.Color));
+ Assert.Throws(() => texture = new Texture3D(gd, 0, 0, 0, false, SurfaceFormat.Color));
+ }
+
[Test]
public void SetData1ParameterTest()
{
diff --git a/Test/Framework/Graphics/TextureCubeTest.cs b/Test/Framework/Graphics/TextureCubeTest.cs
index e7997ff3a5e..0bb9069264b 100644
--- a/Test/Framework/Graphics/TextureCubeTest.cs
+++ b/Test/Framework/Graphics/TextureCubeTest.cs
@@ -2,6 +2,7 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
+using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using NUnit.Framework;
@@ -11,6 +12,13 @@ namespace MonoGame.Tests.Graphics
[TestFixture]
class TextureCubeTest : GraphicsDeviceTestFixtureBase
{
+ [Test]
+ public void ZeroSizeShouldFailTest()
+ {
+ TextureCube texture;
+ Assert.Throws(() => texture = new TextureCube(gd, 0, false, SurfaceFormat.Color));
+ }
+
[TestCase(1)]
[TestCase(8)]
[TestCase(31)]
diff --git a/Test/Framework/TestGameBase.cs b/Test/Framework/TestGameBase.cs
index 3ade9bc8577..6c88a322b60 100644
--- a/Test/Framework/TestGameBase.cs
+++ b/Test/Framework/TestGameBase.cs
@@ -145,6 +145,16 @@ private void SafeRaise (EventHandler handler)
handler (this, new FrameInfoEventArgs(FrameInfo));
}
+ public void InitializeOnly()
+ {
+ if (GraphicsDevice == null)
+ {
+ var graphicsDeviceManager = Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager;
+ graphicsDeviceManager.CreateDevice();
+ }
+ Initialize();
+ }
+
protected override void Initialize ()
{
SafeRaise (PreInitializeWith);
@@ -166,7 +176,7 @@ protected override void UnloadContent ()
SafeRaise (UnloadContentWith);
}
- public new void Run (Predicate until = null)
+ public void Run (Predicate until = null)
{
if (until != null)
ExitCondition = until;
diff --git a/Test/Framework/Visual/MiscellaneousTests.cs b/Test/Framework/Visual/MiscellaneousTests.cs
index b5d470d6c9d..1d028e57781 100644
--- a/Test/Framework/Visual/MiscellaneousTests.cs
+++ b/Test/Framework/Visual/MiscellaneousTests.cs
@@ -82,6 +82,9 @@ namespace MonoGame.Tests.Visual {
class MiscellaneousTests : VisualTestFixtureBase
{
[Test]
+#if XNA
+ [Ignore]
+#endif
public void DrawOrder_falls_back_to_order_of_addition_to_Game ()
{
Game.PreDrawWith += (sender, e) => {
diff --git a/Test/MonoGame.Tests.XNA.csproj b/Test/MonoGame.Tests.XNA.csproj
index efe61db4ddf..3c5fd9652c3 100644
--- a/Test/MonoGame.Tests.XNA.csproj
+++ b/Test/MonoGame.Tests.XNA.csproj
@@ -399,6 +399,15 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
@@ -555,6 +564,12 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
diff --git a/Test/Runner/Interface/CommandLineInterface.cs b/Test/Runner/Interface/CommandLineInterface.cs
index 676dfdc3188..f2ddfe24401 100644
--- a/Test/Runner/Interface/CommandLineInterface.cs
+++ b/Test/Runner/Interface/CommandLineInterface.cs
@@ -121,7 +121,7 @@ public override void RunFinished(TestResult result)
resultWriter.SaveTestResult (result);
if (_runOptions.PerformXslTransform) {
- var transform = new XslTransform ();
+ var transform = new XslCompiledTransform();
transform.Load (_runOptions.XslTransformPath);
transform.Transform (_runOptions.XmlResultsPath, _runOptions.TransformedResultsPath);
}
diff --git a/Test/Runner/Utility.cs b/Test/Runner/Utility.cs
index 8654dea93e2..50667768028 100644
--- a/Test/Runner/Utility.cs
+++ b/Test/Runner/Utility.cs
@@ -47,6 +47,44 @@ public int GetHashCode(Matrix obj)
}
}
+ public class ByteComparer : IEqualityComparer
+ {
+ static public ByteComparer Equal = new ByteComparer();
+
+ private ByteComparer()
+ {
+ }
+
+ public bool Equals(byte x, byte y)
+ {
+ return x == y;
+ }
+
+ public int GetHashCode(byte obj)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class ColorComparer : IEqualityComparer
+ {
+ static public ColorComparer Equal = new ColorComparer();
+
+ private ColorComparer()
+ {
+ }
+
+ public bool Equals(Color x, Color y)
+ {
+ return x == y;
+ }
+
+ public int GetHashCode(Color obj)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
public class FloatComparer : IEqualityComparer
{
static public FloatComparer Epsilon = new FloatComparer(0.000001f);
diff --git a/ThirdParty/Dependencies b/ThirdParty/Dependencies
index c053985a0d7..2344ab54b5a 160000
--- a/ThirdParty/Dependencies
+++ b/ThirdParty/Dependencies
@@ -1 +1 @@
-Subproject commit c053985a0d716d5f525c7f8dd2d403e1182d88ba
+Subproject commit 2344ab54b5a09e256e5e29d3bd116edfc485f740
diff --git a/ThirdParty/Kickstart b/ThirdParty/Kickstart
index 5e03d0127e5..290303cd5be 160000
--- a/ThirdParty/Kickstart
+++ b/ThirdParty/Kickstart
@@ -1 +1 @@
-Subproject commit 5e03d0127e514dcf8a63ae9ebd385cd392dcde52
+Subproject commit 290303cd5bedfdc802582a7cb324de1f0619ab08
diff --git a/ThirdParty/NVorbis b/ThirdParty/NVorbis
index 9091a9ca312..0d40b48a48c 160000
--- a/ThirdParty/NVorbis
+++ b/ThirdParty/NVorbis
@@ -1 +1 @@
-Subproject commit 9091a9ca31299ed925480442f23932bec3f31907
+Subproject commit 0d40b48a48c4f87bb18b3593e7db0dab74dbb829
diff --git a/Tools/2MGFX/ConstantBufferData.cs b/Tools/2MGFX/ConstantBufferData.cs
index 7248eaf7665..f98b040ed16 100644
--- a/Tools/2MGFX/ConstantBufferData.cs
+++ b/Tools/2MGFX/ConstantBufferData.cs
@@ -14,6 +14,15 @@ internal partial class ConstantBufferData
public List Parameters { get; private set; }
+ public ConstantBufferData(string name)
+ {
+ Name = name;
+
+ ParameterIndex = new List();
+ ParameterOffset = new List();
+ Parameters = new List();
+ Size = 0;
+ }
public bool SameAs(ConstantBufferData other)
{
diff --git a/Tools/2MGFX/MGFX.tpg b/Tools/2MGFX/MGFX.tpg
index ad0baa758c9..ebac649e914 100644
--- a/Tools/2MGFX/MGFX.tpg
+++ b/Tools/2MGFX/MGFX.tpg
@@ -410,10 +410,13 @@ Sampler_Register_Expression -> Colon Register OpenParenthesis Identifier (Comma
Sampler_Declaration_States -> (Equals SamplerState)? OpenBracket Sampler_State_Expression* CloseBracket;
-Sampler_Declaration -> Sampler Identifier Sampler_Register_Expression* Sampler_Declaration_States? Semicolon
+Sampler_Declaration -> Sampler Identifier Sampler_Register_Expression* Sampler_Declaration_States? (Semicolon | Comma | CloseParenthesis)
{
+ // if there is a comma or closing paren at the end this is a sampler as a parameter of a function
+ if ($Semicolon == null) return null;
+
var sampler = new SamplerStateInfo();
- sampler.Name = $Identifier as string;
+ sampler.Name = $Identifier[0] as string;
foreach (ParseNode node in Nodes)
node.Eval(tree, sampler);
diff --git a/Tools/2MGFX/ParseTree.cs b/Tools/2MGFX/ParseTree.cs
index 456b2421346..353247c8fb6 100644
--- a/Tools/2MGFX/ParseTree.cs
+++ b/Tools/2MGFX/ParseTree.cs
@@ -1098,7 +1098,10 @@ protected virtual object EvalSampler_Declaration_States(ParseTree tree, params o
protected virtual object EvalSampler_Declaration(ParseTree tree, params object[] paramlist)
{
- var sampler = new SamplerStateInfo();
+ // if there is a comma or closing paren at the end this is a sampler as a parameter of a function
+ if (this.GetValue(tree, TokenType.Semicolon, 0) == null) return null;
+
+ var sampler = new SamplerStateInfo();
sampler.Name = this.GetValue(tree, TokenType.Identifier, 0) as string;
foreach (ParseNode node in Nodes)
diff --git a/Tools/2MGFX/Parser.cs b/Tools/2MGFX/Parser.cs
index e957d1c4f77..7fe163335c7 100644
--- a/Tools/2MGFX/Parser.cs
+++ b/Tools/2MGFX/Parser.cs
@@ -3929,14 +3929,43 @@ private void ParseSampler_Declaration(ParseNode parent) // NonTerminalSymbol: Sa
}
// Concat Rule
- tok = scanner.Scan(TokenType.Semicolon); // Terminal Rule: Semicolon
- n = node.CreateNode(tok, tok.ToString() );
- node.Token.UpdateRange(tok);
- node.Nodes.Add(n);
- if (tok.Type != TokenType.Semicolon) {
- tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.Semicolon.ToString(), 0x1001, tok));
- return;
- }
+ tok = scanner.LookAhead(TokenType.Semicolon, TokenType.Comma, TokenType.CloseParenthesis); // Choice Rule
+ switch (tok.Type)
+ { // Choice Rule
+ case TokenType.Semicolon:
+ tok = scanner.Scan(TokenType.Semicolon); // Terminal Rule: Semicolon
+ n = node.CreateNode(tok, tok.ToString() );
+ node.Token.UpdateRange(tok);
+ node.Nodes.Add(n);
+ if (tok.Type != TokenType.Semicolon) {
+ tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.Semicolon.ToString(), 0x1001, tok));
+ return;
+ }
+ break;
+ case TokenType.Comma:
+ tok = scanner.Scan(TokenType.Comma); // Terminal Rule: Comma
+ n = node.CreateNode(tok, tok.ToString() );
+ node.Token.UpdateRange(tok);
+ node.Nodes.Add(n);
+ if (tok.Type != TokenType.Comma) {
+ tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.Comma.ToString(), 0x1001, tok));
+ return;
+ }
+ break;
+ case TokenType.CloseParenthesis:
+ tok = scanner.Scan(TokenType.CloseParenthesis); // Terminal Rule: CloseParenthesis
+ n = node.CreateNode(tok, tok.ToString() );
+ node.Token.UpdateRange(tok);
+ node.Nodes.Add(n);
+ if (tok.Type != TokenType.CloseParenthesis) {
+ tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.CloseParenthesis.ToString(), 0x1001, tok));
+ return;
+ }
+ break;
+ default:
+ tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected Semicolon, Comma, or CloseParenthesis.", 0x0002, tok));
+ break;
+ } // Choice Rule
parent.Token.UpdateRange(node.Token);
} // NonTerminalSymbol: Sampler_Declaration
diff --git a/Tools/2MGFX/Properties/AssemblyInfo.cs b/Tools/2MGFX/Properties/AssemblyInfo.cs
index a6712f3ffe7..33571bcfcb4 100644
--- a/Tools/2MGFX/Properties/AssemblyInfo.cs
+++ b/Tools/2MGFX/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
-using System.Reflection;
+using System;
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -14,6 +15,9 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
+// Mark the assembly as CLS compliant so it can be safely used in other .NET languages
+[assembly: CLSCompliant(true)]
+
// 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.
diff --git a/Tools/2MGFX/ShaderData.cs b/Tools/2MGFX/ShaderData.cs
index ae778f4cf64..d784de5152b 100644
--- a/Tools/2MGFX/ShaderData.cs
+++ b/Tools/2MGFX/ShaderData.cs
@@ -29,7 +29,9 @@ public struct Attribute
public string name;
public VertexElementUsage usage;
public int index;
+#pragma warning disable 649
public int location;
+#pragma warning restore 649
}
///
diff --git a/Tools/MGCB/ConsoleLogger.cs b/Tools/MGCB/ConsoleLogger.cs
index 1ec97ee8801..de632543375 100644
--- a/Tools/MGCB/ConsoleLogger.cs
+++ b/Tools/MGCB/ConsoleLogger.cs
@@ -30,7 +30,12 @@ public override void LogWarning(string helpLink, ContentIdentity contentIdentity
warning += "(" + contentIdentity.FragmentIdentifier + ")";
warning += ": ";
}
- warning += string.Format(message, messageArgs);
+
+ if (messageArgs != null && messageArgs.Length != 0)
+ warning += string.Format(message, messageArgs);
+ else if (!string.IsNullOrEmpty(message))
+ warning += message;
+
Console.WriteLine(warning);
}
}
diff --git a/Tools/Pipeline/Common/IController.cs b/Tools/Pipeline/Common/IController.cs
index 755d6c6d298..6785b389c81 100644
--- a/Tools/Pipeline/Common/IController.cs
+++ b/Tools/Pipeline/Common/IController.cs
@@ -118,6 +118,8 @@ public interface IController : IContentItemObserver
IProjectItem GetItem(string originalPath);
+ void CopyAssetPath();
+
#endregion
#region Undo, Redo
diff --git a/Tools/Pipeline/Common/IView.cs b/Tools/Pipeline/Common/IView.cs
index 48d2c795a6c..c2d7a9522b2 100644
--- a/Tools/Pipeline/Common/IView.cs
+++ b/Tools/Pipeline/Common/IView.cs
@@ -77,5 +77,7 @@ public interface IView
void UpdateCommands(MenuInfo info);
void UpdateRecentList(List recentList);
+
+ void SetClipboard(string text);
}
}
diff --git a/Tools/Pipeline/Common/MenuInfo.cs b/Tools/Pipeline/Common/MenuInfo.cs
index cea0df61da1..f9b2e39009e 100644
--- a/Tools/Pipeline/Common/MenuInfo.cs
+++ b/Tools/Pipeline/Common/MenuInfo.cs
@@ -50,6 +50,8 @@ public class MenuInfo
public bool OpenItemLocation { get; set; }
+ public bool CopyAssetPath { get; set; }
+
public bool RebuildItem { get; set; }
}
}
diff --git a/Tools/Pipeline/Common/PipelineController.ExcludeAction.cs b/Tools/Pipeline/Common/PipelineController.ExcludeAction.cs
index 953a278acb3..e882bab676c 100644
--- a/Tools/Pipeline/Common/PipelineController.ExcludeAction.cs
+++ b/Tools/Pipeline/Common/PipelineController.ExcludeAction.cs
@@ -53,7 +53,7 @@ public bool Do()
else
File.Delete(_con.GetFullPath(item.OriginalPath));
}
- catch (FileNotFoundException ex)
+ catch (FileNotFoundException)
{
// No error needed in case file is not found
}
diff --git a/Tools/Pipeline/Common/PipelineController.cs b/Tools/Pipeline/Common/PipelineController.cs
index 96e7018f352..8db6d4cd587 100644
--- a/Tools/Pipeline/Common/PipelineController.cs
+++ b/Tools/Pipeline/Common/PipelineController.cs
@@ -271,7 +271,7 @@ public void OpenProject(string projectFilePath)
PipelineSettings.Default.Save();
View.UpdateRecentList(PipelineSettings.Default.ProjectHistory);
}
- catch (Exception e)
+ catch (Exception)
{
View.ShowError("Open Project", "Failed to open project!");
return;
@@ -959,6 +959,19 @@ public IProjectItem GetItem(string originalPath)
return null;
}
+ public void CopyAssetPath()
+ {
+ var item = SelectedItem as ContentItem;
+ if (item != null)
+ {
+ var path = item.OriginalPath;
+ path = path.Remove(path.Length - Path.GetExtension(path).Length);
+ path = path.Replace('\\', '/');
+
+ View.SetClipboard(path);
+ }
+ }
+
#region Undo, Redo
private readonly ActionStack _actionStack;
@@ -1114,6 +1127,7 @@ private void UpdateContextMenu()
info.OpenItem = exists && oneselected && SelectedItem is ContentItem;
info.OpenItemWith = exists && oneselected && !(SelectedItem is DirectoryItem);
info.OpenItemLocation = exists && oneselected;
+ info.CopyAssetPath = exists && oneselected && SelectedItem is ContentItem;
info.Add = (exists && oneselected && !(SelectedItem is ContentItem)) || !somethingselected && ProjectOpen;
info.Exclude = somethingselected && !SelectedItems.Contains(_project);
info.Rename = exists && oneselected;
diff --git a/Tools/Pipeline/Common/PipelineSettings.cs b/Tools/Pipeline/Common/PipelineSettings.cs
index 59a3f0c33c5..7d6b68ac92f 100644
--- a/Tools/Pipeline/Common/PipelineSettings.cs
+++ b/Tools/Pipeline/Common/PipelineSettings.cs
@@ -21,7 +21,8 @@ public class PipelineSettings
public string StartupProject;
public Microsoft.Xna.Framework.Point Size;
public int HSeparator, VSeparator;
- public bool Maximized, FilterOutput, AutoScrollBuildOutput, DebugMode, PropertyGroupSort;
+ public bool Maximized, DebugMode, PropertyGroupSort;
+ public bool FilterOutput, FilterShowSkipped, FilterShowSuccessful, FilterShowCleaned, AutoScrollBuildOutput;
static PipelineSettings()
{
@@ -34,6 +35,9 @@ public PipelineSettings()
PropertyGroupSort = true;
FilterOutput = true;
+ FilterShowSkipped = true;
+ FilterShowSuccessful = true;
+ FilterShowCleaned = true;
AutoScrollBuildOutput = true;
try
diff --git a/Tools/Pipeline/Common/PipelineTypes.cs b/Tools/Pipeline/Common/PipelineTypes.cs
index 602c0148254..2acccb51f51 100644
--- a/Tools/Pipeline/Common/PipelineTypes.cs
+++ b/Tools/Pipeline/Common/PipelineTypes.cs
@@ -300,8 +300,6 @@ public static void Load(PipelineProject project)
browsable = (a as BrowsableAttribute).Browsable;
else if (a is DisplayNameAttribute)
name = (a as DisplayNameAttribute).DisplayName;
- else if (a is DefaultValueAttribute)
- defvalue = (a as DefaultValueAttribute).Value;
}
var p = new ProcessorTypeDescription.Property()
diff --git a/Tools/Pipeline/Controls/BuildItem.cs b/Tools/Pipeline/Controls/BuildItem.cs
new file mode 100644
index 00000000000..d8307c01df0
--- /dev/null
+++ b/Tools/Pipeline/Controls/BuildItem.cs
@@ -0,0 +1,115 @@
+using System;
+using System.Collections.Generic;
+using Eto.Drawing;
+
+namespace MonoGame.Tools.Pipeline
+{
+ class BuildItem
+ {
+ private const int CellHeight = 32;
+ private const int Spacing = 10;
+ private const int Margin = 10;
+ private const string ArrowCollapse = "â–²";
+ private const string ArrowExpand = "â–¼";
+ private const int ButtonSpacing = 3;
+
+ public string Text { get; set; }
+ public Image Icon { get; set; }
+ public int Height { get; set; }
+ public int RequestedWidth { get; set; }
+
+ public string Description
+ {
+ set
+ {
+ _description.Clear();
+ _description.Add(value);
+ }
+ }
+
+ private readonly float _arrowWidth;
+ private readonly float _textOffset;
+ private readonly float _imageOffset;
+ private readonly float _descSize;
+
+ private List _description;
+ private float _descriptionOffset;
+ private bool _expanded;
+ private bool _selected;
+
+ public BuildItem()
+ {
+ _arrowWidth = SystemFonts.Default().MeasureString(ArrowExpand).Width;
+ _textOffset = (CellHeight - DrawInfo.TextHeight) / 2;
+ _imageOffset = (CellHeight - 16) / 2;
+ _descSize = SystemFonts.Default().LineHeight + 4;
+
+ _description = new List();
+
+ Height = CellHeight;
+ RequestedWidth = 0;
+ }
+
+ public void AddDescription(string text)
+ {
+ _description.Add(text);
+ }
+
+ public void OnClick()
+ {
+ if (_selected && _description.Count != 0)
+ {
+ _expanded = !_expanded;
+
+ if (_expanded)
+ {
+ _descriptionOffset = (_descSize - DrawInfo.TextHeight) / 2;
+ Height = (int)(CellHeight + _descSize * _description.Count);
+
+ foreach (var des in _description)
+ {
+ var width = SystemFonts.Default().MeasureString(des).Width + 4 * Spacing + 16;
+ if (width > RequestedWidth)
+ RequestedWidth = (int)width;
+ }
+ }
+ else
+ {
+ Height = CellHeight;
+ RequestedWidth = 0;
+ }
+ }
+ }
+
+ public void Draw(Graphics g, int y, int width)
+ {
+ var x = Margin;
+ _selected = BuildOutput.MouseLocation.Y > y && BuildOutput.MouseLocation.Y < y + CellHeight;
+
+ // Draw Background
+ g.FillRectangle(DrawInfo.BorderColor, 0, y, width, Height);
+ g.FillRectangle(_selected ? DrawInfo.HoverBackColor : DrawInfo.BorderColor, 0, y, width, CellHeight);
+
+ // Draw Icon
+ g.DrawImage(Icon, x, y + _imageOffset);
+ x += 16 + Spacing;
+
+ // Draw Text
+ g.DrawText(SystemFonts.Default(), DrawInfo.GetTextColor(_selected, false), x, y + _textOffset, Text);
+
+ // Draw Expander
+ if (_description.Count != 0)
+ {
+ //g.FillRectangle(_expandSelected ? DrawInfo.HoverBackColor : DrawInfo.BorderColor, rectangle);
+ g.DrawText(SystemFonts.Default(), DrawInfo.GetTextColor(_selected, false), width - Margin - _arrowWidth, y + _textOffset, _expanded ? ArrowCollapse : ArrowExpand);
+ }
+
+ // Draw Description
+ if (_expanded)
+ {
+ for (int i = 0; i < _description.Count; i++)
+ g.DrawText(SystemFonts.Default(), DrawInfo.DisabledTextColor, x + Spacing, y + CellHeight + _descriptionOffset + _descSize * i, _description[i]);
+ }
+ }
+ }
+}
diff --git a/Tools/Pipeline/Controls/BuildOutput.cs b/Tools/Pipeline/Controls/BuildOutput.cs
index b99433350bb..4516e14faa0 100644
--- a/Tools/Pipeline/Controls/BuildOutput.cs
+++ b/Tools/Pipeline/Controls/BuildOutput.cs
@@ -3,65 +3,116 @@
// file 'LICENSE.txt', which is part of this source code package.
using System;
-using Xwt;
-using Xwt.Drawing;
+using System.Collections.Generic;
+using Eto.Drawing;
+using Eto.Forms;
namespace MonoGame.Tools.Pipeline
{
public partial class BuildOutput
{
+ public static Point MouseLocation;
+ public static int Count;
+ public static int ReqWidth;
+
private OutputParser _output;
- private TreeStore _treeStore;
- private readonly DataField _dataImage;
- private readonly DataField _dataText;
- private TreePosition _last;
- private Image _iconInformation, _iconFail, _iconProcessing, _iconSkip, _iconSucceed, _iconStart, _iconEndSucceed, _iconEndFailed;
- private Eto.Forms.CheckCommand _cmdFilterOutput, _cmdAutoScroll;
+ private List _items;
+ private CheckCommand _cmdFilterOutput, _cmdAutoScroll, _cmdShowSkipped, _cmdShowSuccessful, _cmdShowCleaned;
+ private Image _iconInformation, _iconFail, _iconProcessing, _iconSkip, _iconSucceed, _iconSucceedWithWarnings, _iconStart, _iconEndSucceed, _iconEndFailed;
+ private BuildItem _selectedItem;
public BuildOutput()
{
InitializeComponent();
-
+ scrollable1.Style = "BuildOutput";
+
_output = new OutputParser();
- _iconInformation = Global.GetXwtIcon("Build.Information.png");
- _iconFail = Global.GetXwtIcon("Build.Fail.png");
- _iconProcessing = Global.GetXwtIcon("Build.Processing.png");
- _iconSkip = Global.GetXwtIcon("Build.Skip.png");
- _iconStart = Global.GetXwtIcon("Build.Start.png");
- _iconEndSucceed = Global.GetXwtIcon("Build.EndSucceed.png");
- _iconEndFailed = Global.GetXwtIcon("Build.EndFailed.png");
- _iconSucceed = Global.GetXwtIcon("Build.Succeed.png");
+ _iconInformation = Global.GetEtoIcon("Build.Information.png");
+ _iconFail = Global.GetEtoIcon("Build.Fail.png");
+ _iconProcessing = Global.GetEtoIcon("Build.Processing.png");
+ _iconSkip = Global.GetEtoIcon("Build.Skip.png");
+ _iconStart = Global.GetEtoIcon("Build.Start.png");
+ _iconEndSucceed = Global.GetEtoIcon("Build.EndSucceed.png");
+ _iconEndFailed = Global.GetEtoIcon("Build.EndFailed.png");
+ _iconSucceed = Global.GetEtoIcon("Build.Succeed.png");
+ _iconSucceedWithWarnings = Global.GetEtoIcon("Build.SucceedWithWarnings.png");
- _dataImage = new DataField();
- _dataText = new DataField();
+ _items = new List();
- _treeStore = new TreeStore(_dataImage, _dataText);
-
- _cmdFilterOutput = new Eto.Forms.CheckCommand();
+ _cmdFilterOutput = new CheckCommand();
_cmdFilterOutput.MenuText = "Filter Output";
_cmdFilterOutput.CheckedChanged += CmdFilterOutput_CheckedChanged;
AddCommand(_cmdFilterOutput);
- _cmdAutoScroll = new Eto.Forms.CheckCommand();
+ _cmdShowSkipped = new CheckCommand();
+ _cmdShowSkipped.MenuText = "Show Skipped Files";
+ _cmdShowSkipped.CheckedChanged += CmdShowSkipped_CheckedChanged;
+ AddCommand(_cmdShowSkipped);
+
+ _cmdShowSuccessful = new CheckCommand();
+ _cmdShowSuccessful.MenuText = "Show Successfully Built Files";
+ _cmdShowSuccessful.CheckedChanged += CmdShowSuccessful_CheckedChanged;
+ AddCommand(_cmdShowSuccessful);
+
+ _cmdShowCleaned = new CheckCommand();
+ _cmdShowCleaned.MenuText = "Show Cleaned Files";
+ _cmdShowCleaned.CheckedChanged += CmdShowCleaned_CheckedChanged;
+ AddCommand(_cmdShowCleaned);
+
+ _cmdAutoScroll = new CheckCommand();
_cmdAutoScroll.MenuText = "Auto Scroll";
_cmdAutoScroll.CheckedChanged += CmdAutoScroll_CheckedChanged;
AddCommand(_cmdAutoScroll);
- treeView.DataSource = _treeStore;
- treeView.Columns.Add("", _dataImage, _dataText);
+ MouseLocation = new Point(-1, -1);
+
+#if LINUX
+ var scrollView = scrollable1.ControlObject as Gtk.ScrolledWindow;
+ scrollView.Vadjustment.ValueChanged += Scrollable1_Scroll;
+ scrollView.Hadjustment.ValueChanged += Scrollable1_Scroll;
+#endif
}
public override void LoadSettings()
{
_cmdFilterOutput.Checked = PipelineSettings.Default.FilterOutput;
+ _cmdShowSkipped.Checked = PipelineSettings.Default.FilterShowSkipped;
+ _cmdShowSuccessful.Checked = PipelineSettings.Default.FilterShowSuccessful;
+ _cmdShowCleaned.Checked = PipelineSettings.Default.FilterShowCleaned;
_cmdAutoScroll.Checked = PipelineSettings.Default.AutoScrollBuildOutput;
}
private void CmdFilterOutput_CheckedChanged(object sender, EventArgs e)
{
- panel.Content = _cmdFilterOutput.Checked ? treeView.ToEto() : textArea;
+ if (_cmdFilterOutput.Checked)
+ drawable.Paint -= Drawable_Paint;
+
+ panel.Content = _cmdFilterOutput.Checked ? (Control)scrollable1 : textArea;
PipelineSettings.Default.FilterOutput = _cmdFilterOutput.Checked;
+
+ if (_cmdFilterOutput.Checked)
+ drawable.Paint += Drawable_Paint;
+
+ drawable.Invalidate();
+ }
+
+ private void CmdShowSkipped_CheckedChanged(object sender, EventArgs e)
+ {
+ PipelineSettings.Default.FilterShowSkipped = _cmdShowSkipped.Checked;
+ drawable.Invalidate();
+ }
+
+ private void CmdShowSuccessful_CheckedChanged(object sender, EventArgs e)
+ {
+ PipelineSettings.Default.FilterShowSuccessful = _cmdShowSuccessful.Checked;
+ drawable.Invalidate();
+ }
+
+ private void CmdShowCleaned_CheckedChanged(object sender, EventArgs e)
+ {
+ PipelineSettings.Default.FilterShowCleaned = _cmdShowCleaned.Checked;
+ drawable.Invalidate();
}
private void CmdAutoScroll_CheckedChanged(object sender, EventArgs e)
@@ -71,8 +122,10 @@ private void CmdAutoScroll_CheckedChanged(object sender, EventArgs e)
public void ClearOutput()
{
+ scrollable1.ScrollPosition = new Point(0, 0);
textArea.Text = "";
- _treeStore.Clear();
+ _items.Clear();
+ drawable.Invalidate();
}
public void WriteLine(string line)
@@ -88,65 +141,171 @@ public void WriteLine(string line)
switch (_output.State)
{
case OutputState.BuildBegin:
- AddItem(_iconStart, line);
+ _items.Add(new BuildItem { Text = line, Icon = _iconStart });
+ Count = -1;
+ ReqWidth = 0;
break;
case OutputState.Cleaning:
- AddItem(_iconInformation, "Cleaning " + PipelineController.Instance.GetRelativePath(_output.Filename));
- AddItem(line);
+ _items.Add(new BuildItem
+ {
+ Text = "Cleaning " + PipelineController.Instance.GetRelativePath(_output.Filename),
+ Icon = _iconInformation,
+ Description = line
+ });
break;
case OutputState.Skipping:
- AddItem(_iconSkip, "Skipping " + PipelineController.Instance.GetRelativePath(_output.Filename));
- AddItem(line);
+ if (_items[_items.Count - 1].Icon == _iconProcessing)
+ _items[_items.Count - 1].Icon = _iconSucceed;
+
+ _items.Add(new BuildItem
+ {
+ Text = "Skipping " + PipelineController.Instance.GetRelativePath(_output.Filename),
+ Icon = _iconSkip,
+ Description = _output.Filename
+ });
break;
case OutputState.BuildAsset:
- AddItem(_iconProcessing, "Building " + PipelineController.Instance.GetRelativePath(_output.Filename));
- AddItem(line);
+ if (_items[_items.Count - 1].Icon == _iconProcessing)
+ _items[_items.Count - 1].Icon = _iconSucceed;
+
+ _items.Add(new BuildItem
+ {
+ Text = "Building " + PipelineController.Instance.GetRelativePath(_output.Filename),
+ Icon = _iconProcessing,
+ Description = _output.Filename
+ });
break;
case OutputState.BuildError:
- _treeStore.GetNavigatorAt(_last).SetValue(_dataImage, _iconFail);
- AddItem(_output.ErrorMessage);
+ _items[_items.Count - 1].Icon = _iconFail;
+ _items[_items.Count - 1].AddDescription(_output.ErrorMessage);
break;
case OutputState.BuildErrorContinue:
- AddItem(_output.ErrorMessage);
+ _items[_items.Count - 1].AddDescription(_output.ErrorMessage);
break;
case OutputState.BuildWarning:
- AddItem(_output.ErrorMessage);
+ if (_items[_items.Count - 1].Icon == _iconProcessing)
+ _items[_items.Count - 1].Icon = _iconSucceedWithWarnings;
+ _items[_items.Count - 1].AddDescription(_output.ErrorMessage);
break;
case OutputState.BuildEnd:
- if (line.Contains("0 failed"))
- AddItem(_iconEndSucceed, line);
- else
- AddItem(_iconEndFailed, line);
+ if (_items[_items.Count - 1].Icon == _iconProcessing)
+ _items[_items.Count - 1].Icon = _iconSucceed;
+
+ _items.Add(new BuildItem
+ {
+ Text = line,
+ Icon = line.Contains("0 failed") ? _iconEndSucceed : _iconEndFailed
+ });
break;
case OutputState.BuildTime:
- var node = _treeStore.GetNavigatorAt(_last);
- var text = node.GetValue(_dataText);
-
- AddItem(node.GetValue(_dataImage), text.TrimEnd(new[] { '.', ' ' }) + ", " + line);
- node.Remove();
+ var text = _items[_items.Count - 1].Text.TrimEnd(new[] { '.', ' ' }) + ", " + line;
+ _items[_items.Count - 1].Text = text;
+ Count = _items.Count * 35 - 3;
break;
}
+
+ drawable.Invalidate();
+ }
+
+ private void Drawable_MouseMove(object sender, MouseEventArgs e)
+ {
+ MouseLocation = new Point((int)e.Location.X, (int)e.Location.Y);
+ drawable.Invalidate();
}
- private void AddItem(Image image, string text)
+ private void Drawable_MouseLeave(object sender, MouseEventArgs e)
{
- var item = _treeStore.AddNode();
- item.SetValue(_dataImage, image);
- item.SetValue(_dataText, text);
+ _selectedItem = null;
+ MouseLocation = new Point(-1, -1);
+ drawable.Invalidate();
+ }
+
+ private void Drawable_MouseDown(object sender, MouseEventArgs e)
+ {
+ if (_selectedItem != null)
+ _selectedItem.OnClick();
+
+ ReqWidth = 0;
+ foreach (var item in _items)
+ if (item.RequestedWidth > ReqWidth)
+ ReqWidth = item.RequestedWidth;
+
+ SetWidth();
+ drawable.Invalidate();
+ }
+
+ private void Scrollable1_SizeChanged(object sender, EventArgs e)
+ {
+ SetWidth();
+ drawable.Invalidate();
+ }
+
+
+ private void Scrollable1_Scroll(object sender, EventArgs e)
+ {
+ drawable.Invalidate();
+ }
- if (_last != null && _treeStore.GetNavigatorAt(_last).GetValue(_dataImage) == _iconProcessing)
- _treeStore.GetNavigatorAt(_last).SetValue(_dataImage, _iconSucceed);
+ private void SetWidth()
+ {
+#if WINDOWS
+ var scrollsize = (drawable.Height >= scrollable1.Height) ? System.Windows.SystemParameters.VerticalScrollBarWidth : 0.0;
+ var width = (int)(Width - scrollsize - System.Windows.SystemParameters.BorderWidth * 2);
- if (_cmdAutoScroll.Checked)
- treeView.ScrollToRow(item.CurrentPosition);
+ if (ReqWidth > width)
+ width = ReqWidth;
- _last = item.CurrentPosition;
+ if (drawable.Width != width)
+ drawable.Width = width;
+#endif
}
- private void AddItem(string text)
+ private void Drawable_Paint(object sender, PaintEventArgs e)
{
- _treeStore.GetNavigatorAt(_last).AddChild().SetValue(_dataText, text);
+ var g = e.Graphics;
+ var count = _items.Count;
+ var y = 0;
+
+ g.Clear(DrawInfo.BackColor);
+
+ for (int i = 0; i < _items.Count; i++)
+ {
+ var item = _items[i];
+
+ // Skip Skipped items
+ if (!PipelineSettings.Default.FilterShowSkipped && item.Icon == _iconSkip)
+ continue;
+
+ // Skip Successful items
+ if (!PipelineSettings.Default.FilterShowSuccessful && item.Icon == _iconSucceed)
+ continue;
+
+ // Skip Cleaned items
+ if (!PipelineSettings.Default.FilterShowCleaned && item.Icon == _iconInformation)
+ continue;
+
+ // Check if the item is in the visible rectangle
+ if (y + item.Height >= scrollable1.ScrollPosition.Y && y < scrollable1.ScrollPosition.Y + scrollable1.Height)
+ {
+ // Check if the item is selected
+ if (MouseLocation.Y > y && MouseLocation.Y < y + item.Height)
+ _selectedItem = item;
+
+ // Draw item
+ item.Draw(g, y, drawable.Width);
+ }
+
+ // Add border
+ y += item.Height + 3;
+ }
+
+ drawable.Height = Math.Max(y - 3, 1);
+ SetWidth();
+
+#if WINDOWS
+ if (Count == -1 && PipelineSettings.Default.AutoScrollBuildOutput)
+ scrollable1.ScrollPosition = new Point(0, y - scrollable1.Height);
+#endif
}
}
}
-
diff --git a/Tools/Pipeline/Controls/BuildOutput.eto.cs b/Tools/Pipeline/Controls/BuildOutput.eto.cs
index 3751feea7d6..d5230dec24f 100644
--- a/Tools/Pipeline/Controls/BuildOutput.eto.cs
+++ b/Tools/Pipeline/Controls/BuildOutput.eto.cs
@@ -2,6 +2,7 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
+using System;
using Eto.Forms;
namespace MonoGame.Tools.Pipeline
@@ -10,8 +11,8 @@ public partial class BuildOutput : Pad
{
Panel panel;
TextArea textArea;
-
- Xwt.TreeView treeView;
+ Scrollable scrollable1;
+ Drawable drawable;
private void InitializeComponent()
{
@@ -23,11 +24,20 @@ private void InitializeComponent()
textArea.Wrap = false;
textArea.ReadOnly = true;
- treeView = new Xwt.TreeView();
- treeView.HeadersVisible = false;
+ scrollable1 = new Scrollable();
+ scrollable1.BackgroundColor = DrawInfo.BackColor;
+ drawable = new Drawable();
+ scrollable1.Content = drawable;
panel.Content = textArea;
CreateContent(panel);
+
+ drawable.MouseDown += Drawable_MouseDown;
+ drawable.MouseMove += Drawable_MouseMove;
+ drawable.MouseLeave += Drawable_MouseLeave;
+ drawable.Paint += Drawable_Paint;
+ scrollable1.SizeChanged += Scrollable1_SizeChanged;
+ scrollable1.Scroll += Scrollable1_Scroll;
}
}
}
diff --git a/Tools/Pipeline/Controls/DrawInfo.cs b/Tools/Pipeline/Controls/DrawInfo.cs
new file mode 100644
index 00000000000..75ddc12f3d9
--- /dev/null
+++ b/Tools/Pipeline/Controls/DrawInfo.cs
@@ -0,0 +1,36 @@
+using System;
+using Eto.Drawing;
+
+namespace MonoGame.Tools.Pipeline
+{
+ static class DrawInfo
+ {
+ public static int TextHeight;
+ public static Color TextColor, BackColor, HoverTextColor, HoverBackColor, DisabledTextColor, BorderColor;
+
+ static DrawInfo()
+ {
+ TextHeight = (int)SystemFonts.Default().LineHeight;
+ TextColor = SystemColors.ControlText;
+ BackColor = SystemColors.ControlBackground;
+ HoverTextColor = SystemColors.HighlightText;
+ HoverBackColor = SystemColors.Highlight;
+ DisabledTextColor = SystemColors.ControlText;
+ DisabledTextColor.A = 0.4f;
+ BorderColor = Global.Unix ? SystemColors.WindowBackground : SystemColors.Control;
+ }
+
+ public static Color GetTextColor(bool selected, bool disabled)
+ {
+ if (disabled)
+ return DisabledTextColor;
+
+ return selected ? HoverTextColor : TextColor;
+ }
+
+ public static Color GetBackgroundColor(bool selected)
+ {
+ return selected ? HoverBackColor : BackColor;
+ }
+ }
+}
diff --git a/Tools/Pipeline/Controls/ProjectControl.cs b/Tools/Pipeline/Controls/ProjectControl.cs
index 72863be446f..9dcf384a328 100644
--- a/Tools/Pipeline/Controls/ProjectControl.cs
+++ b/Tools/Pipeline/Controls/ProjectControl.cs
@@ -2,6 +2,7 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -45,27 +46,81 @@ public ProjectControl()
TreeView.ButtonReleased += Handle_ButtonReleased;
TreeView.SelectionChanged += ProjectControl_SelectionChanged;
+
+ TreeView.SetDragDropTarget(TransferDataType.Text, TransferDataType.Uri);
+ TreeView.DragOver += TreeView_DragOver;
+ TreeView.DragDrop += TreeView_DragDrop;
+ }
+
+ private void TreeView_DragOver(object sender, DragOverEventArgs e)
+ {
+ if (!PipelineController.Instance.ProjectOpen)
+ return;
+
+ e.AllowedAction = DragDropAction.Copy;
+
+ RowDropPosition rowpos;
+ TreePosition pos;
+
+ if (TreeView.GetDropTargetRow(e.Position.X, e.Position.Y, out rowpos, out pos))
+ if (rowpos == RowDropPosition.Into && _treeStore.GetNavigatorAt(pos).GetValue(_dataTag) is ContentItem)
+ e.AllowedAction = DragDropAction.None;
+ }
+
+ private void TreeView_DragDrop(object sender, DragEventArgs e)
+ {
+ var initialDirectory = PipelineController.Instance.ProjectLocation;
+ var folders = new List();
+ var files = new List();
+ RowDropPosition rowpos;
+ TreePosition pos;
+
+ foreach (var u in e.Data.Uris)
+ {
+ if (Directory.Exists(u.LocalPath))
+ folders.Add(u.LocalPath);
+ else
+ files.Add(u.LocalPath);
+ }
+
+ if (TreeView.GetDropTargetRow(e.Position.X, e.Position.Y, out rowpos, out pos))
+ {
+ var item = _treeStore.GetNavigatorAt(pos).GetValue(_dataTag);
+
+ if (!(item is DirectoryItem && rowpos == RowDropPosition.Into))
+ {
+ var nav = _treeStore.GetNavigatorAt(pos);
+ if (nav.MoveToParent())
+ item = nav.GetValue(_dataTag);
+ }
+
+ if (!(item is PipelineProject))
+ initialDirectory = Path.Combine(initialDirectory, item.OriginalPath);
+ }
+
+ PipelineController.Instance.DragDrop(initialDirectory, folders.ToArray(), files.ToArray());
+ e.Success = true;
}
private void Handle_ButtonReleased(object sender, ButtonEventArgs e)
{
if (e.Button == PointerButton.Right)
{
-#if WINDOWS
+#if WINDOWS
var crow = TreeView.GetRowAtPosition(e.X, e.Y);
if (crow == null)
return;
-
- if (!TreeView.SelectedRows.ToList().Contains(crow))
- {
- TreeView.UnselectAll();
+
+ if (!TreeView.SelectedRows.ToList().Contains(crow))
+ {
+ TreeView.UnselectAll();
TreeView.SelectRow(crow);
- TreeView.FocusedRow = crow;
+ TreeView.FocusedRow = crow;
}
-#endif
-
- if (_showContextMenu && _contextMenu.Items.Count > 0)
+#endif
+
+ if (_showContextMenu && _contextMenu.Items.Count > 0)
_contextMenu.Show(TreeView.ToEto());
}
}
@@ -98,7 +153,7 @@ public void SetRoot(IProjectItem item)
_treeStore.Clear();
_rootExists = false;
- _showContextMenu = false;
+ _showContextMenu = false;
PipelineController.Instance.SelectionChanged(new List());
return;
diff --git a/Tools/Pipeline/Controls/PropertyCells/CellBase.cs b/Tools/Pipeline/Controls/PropertyCells/CellBase.cs
index 0cb992484d7..8496995ff45 100644
--- a/Tools/Pipeline/Controls/PropertyCells/CellBase.cs
+++ b/Tools/Pipeline/Controls/PropertyCells/CellBase.cs
@@ -27,6 +27,7 @@ public class CellBase
public string DisplayValue { get; set; }
public string Text { get; set; }
public bool Editable { get; set; }
+ public int Height { get; set; }
public Action OnKill;
protected EventHandler _eventHandler;
@@ -40,6 +41,7 @@ public void Create(string category, string name, object value, Type type, EventH
DisplayValue = (value == null) ? "" : value.ToString();
Text = name;
Editable = true;
+ Height = DrawInfo.TextHeight;
_eventHandler = eventHandler;
_type = type;
@@ -62,8 +64,8 @@ public virtual void Draw(Graphics g, Rectangle rec, int separatorPos, bool selec
if (selected)
g.FillRectangle(SystemColors.Highlight, rec);
- g.DrawText(SystemFonts.Default(), PropInfo.GetTextColor(selected, false), rec.X + 5, rec.Y + (rec.Height - PropInfo.TextHeight) / 2, Text);
- g.FillRectangle(PropInfo.GetBackgroundColor(selected), separatorPos - 6, rec.Y, rec.Width, rec.Height);
+ g.DrawText(SystemFonts.Default(), DrawInfo.GetTextColor(selected, false), rec.X + 5, rec.Y + (rec.Height - Height) / 2, Text);
+ g.FillRectangle(DrawInfo.GetBackgroundColor(selected), separatorPos - 6, rec.Y, rec.Width, rec.Height);
DrawCell(g, rec, separatorPos, selected);
}
@@ -73,7 +75,7 @@ public virtual void DrawCell(Graphics g, Rectangle rec, int separatorPos, bool s
_lastRec.X += separatorPos;
_lastRec.Width -= separatorPos - 1;
- g.DrawText(SystemFonts.Default(), PropInfo.GetTextColor(selected, !Editable), separatorPos + 5, rec.Y + (rec.Height - PropInfo.TextHeight) / 2, DisplayValue);
+ g.DrawText(SystemFonts.Default(), DrawInfo.GetTextColor(selected, !Editable), separatorPos + 5, rec.Y + (rec.Height - Height) / 2, DisplayValue);
}
}
}
diff --git a/Tools/Pipeline/Controls/PropertyCells/CellRefs.cs b/Tools/Pipeline/Controls/PropertyCells/CellRefs.cs
index 701fd5fa5f7..21150b71d5b 100644
--- a/Tools/Pipeline/Controls/PropertyCells/CellRefs.cs
+++ b/Tools/Pipeline/Controls/PropertyCells/CellRefs.cs
@@ -3,8 +3,10 @@
// file 'LICENSE.txt', which is part of this source code package.
using System;
+using System.IO;
using System.Collections.Generic;
using Eto.Forms;
+using Eto.Drawing;
namespace MonoGame.Tools.Pipeline
{
@@ -16,7 +18,14 @@ public override void OnCreate()
if (Value == null)
Value = new List();
- DisplayValue = (Value as List).Count > 0 ? "Collection" : "None";
+ var list = Value as List;
+ var displayValue = "";
+
+ foreach (var value in list)
+ displayValue += Environment.NewLine + Path.GetFileNameWithoutExtension (value);
+
+ DisplayValue = (Value as List).Count > 0 ? displayValue.Trim(Environment.NewLine.ToCharArray()) : "None";
+ Height = Height * Math.Max(list.Count, 1);
}
public override void Edit(PixelLayout control)
diff --git a/Tools/Pipeline/Controls/PropertyCells/CellText.cs b/Tools/Pipeline/Controls/PropertyCells/CellText.cs
index e53eaee1092..7c64893b49b 100644
--- a/Tools/Pipeline/Controls/PropertyCells/CellText.cs
+++ b/Tools/Pipeline/Controls/PropertyCells/CellText.cs
@@ -17,7 +17,7 @@ public override void Edit(PixelLayout control)
editText.Style = "OverrideSize";
editText.Width = _lastRec.Width;
editText.Height = _lastRec.Height;
- editText.Text = Value.ToString();
+ editText.Text = (Value == null) ? "" : Value.ToString();
control.Add(editText, _lastRec.X, _lastRec.Y);
diff --git a/Tools/Pipeline/Controls/PropertyGridTable.cs b/Tools/Pipeline/Controls/PropertyGridTable.cs
index 988eb20e76d..70210cefdb0 100755
--- a/Tools/Pipeline/Controls/PropertyGridTable.cs
+++ b/Tools/Pipeline/Controls/PropertyGridTable.cs
@@ -3,7 +3,6 @@
// file 'LICENSE.txt', which is part of this source code package.
using System;
-using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -12,42 +11,6 @@
namespace MonoGame.Tools.Pipeline
{
- static class PropInfo
- {
- public static int TextHeight;
- public static Color TextColor;
- public static Color BackColor;
- public static Color HoverTextColor;
- public static Color HoverBackColor;
- public static Color DisabledTextColor;
- public static Color BorderColor;
-
- static PropInfo()
- {
- TextHeight = (int)SystemFonts.Default().LineHeight;
- TextColor = SystemColors.ControlText;
- BackColor = SystemColors.ControlBackground;
- HoverTextColor = SystemColors.HighlightText;
- HoverBackColor = SystemColors.Highlight;
- DisabledTextColor = SystemColors.ControlText;
- DisabledTextColor.A = 0.4f;
- BorderColor = Global.Unix ? SystemColors.WindowBackground : SystemColors.Control;
- }
-
- public static Color GetTextColor(bool selected, bool disabled)
- {
- if (disabled)
- return DisabledTextColor;
-
- return selected ? HoverTextColor : TextColor;
- }
-
- public static Color GetBackgroundColor(bool selected)
- {
- return selected ? HoverBackColor : BackColor;
- }
- }
-
public partial class PropertyGridTable
{
private const int _spacing = 12;
@@ -167,33 +130,35 @@ private void DrawGroup(Graphics g, Rectangle rec, string text)
var font = SystemFonts.Default();
font = new Font(font.Family, font.Size, FontStyle.Bold);
- g.FillRectangle(PropInfo.BorderColor, rec);
- g.DrawText(SystemFonts.Default(), PropInfo.TextColor, rec.X + 1, rec.Y + (rec.Height - font.LineHeight) / 2, text);
+ g.FillRectangle(DrawInfo.BorderColor, rec);
+ g.DrawText(SystemFonts.Default(), DrawInfo.TextColor, rec.X + 1, rec.Y + (rec.Height - font.LineHeight) / 2, text);
}
private void Drawable_Paint(object sender, PaintEventArgs e)
{
var g = e.Graphics;
- var rec = new Rectangle(0, 0, drawable.Width - 1, PropInfo.TextHeight + _spacing);
+ var rec = new Rectangle(0, 0, drawable.Width - 1, DrawInfo.TextHeight + _spacing);
var overGroup = false;
string prevCategory = null;
_separatorPos = Math.Min(Width - _separatorSafeDistance, Math.Max(_separatorSafeDistance, _separatorPos));
_selectedCell = null;
- g.Clear(PropInfo.BackColor);
+ g.Clear(DrawInfo.BackColor);
if (_cells.Count == 0)
{
- drawable.Height = _height = 1;
+ drawable.Height = _height = 10;
return;
}
// Draw separator for not filled rows
- g.FillRectangle(PropInfo.BorderColor, _separatorPos - 1, 0, 1, Height);
+ g.FillRectangle(DrawInfo.BorderColor, _separatorPos - 1, 0, 1, Height);
foreach (var c in _cells)
{
+ rec.Height = c.Height + _spacing;
+
// Draw group
if (prevCategory != c.Category)
{
@@ -202,7 +167,7 @@ private void Drawable_Paint(object sender, PaintEventArgs e)
DrawGroup(g, rec, c.Category);
prevCategory = c.Category;
overGroup |= rec.Contains(_mouseLocation);
- rec.Y += PropInfo.TextHeight + _spacing;
+ rec.Y += DrawInfo.TextHeight + _spacing;
}
}
@@ -213,9 +178,9 @@ private void Drawable_Paint(object sender, PaintEventArgs e)
c.Draw(g, rec, _separatorPos, selected);
// Draw separator for the current row
- g.FillRectangle(PropInfo.BorderColor, _separatorPos - 1, rec.Y, 1, rec.Height);
+ g.FillRectangle(DrawInfo.BorderColor, _separatorPos - 1, rec.Y, 1, rec.Height);
- rec.Y += PropInfo.TextHeight + _spacing;
+ rec.Y += c.Height + _spacing;
}
if (_height != rec.Y + 1)
@@ -298,8 +263,8 @@ private void SetWidth()
var scrollsize = (_height >= Height) ? System.Windows.SystemParameters.VerticalScrollBarWidth : 0.0;
drawable.Width = (int)(Width - scrollsize - System.Windows.SystemParameters.BorderWidth * 2);
- foreach (var child in pixel1.Children)
- if (child != drawable)
+ foreach (var child in pixel1.Children)
+ if (child != drawable)
child.Width = drawable.Width - _separatorPos;
});
diff --git a/Tools/Pipeline/Controls/PropertyGridTable.eto.cs b/Tools/Pipeline/Controls/PropertyGridTable.eto.cs
index 3cecede1171..4f9fe8cfd01 100644
--- a/Tools/Pipeline/Controls/PropertyGridTable.eto.cs
+++ b/Tools/Pipeline/Controls/PropertyGridTable.eto.cs
@@ -14,10 +14,10 @@ public partial class PropertyGridTable : Scrollable
private void InitializeComponent()
{
- BackgroundColor = PropInfo.BackColor;
+ BackgroundColor = DrawInfo.BackColor;
pixel1 = new PixelLayout();
- pixel1.BackgroundColor = PropInfo.BackColor;
+ pixel1.BackgroundColor = DrawInfo.BackColor;
drawable = new Drawable();
drawable.Height = 100;
diff --git a/Tools/Pipeline/Dialogs/PathDialog.eto.cs b/Tools/Pipeline/Dialogs/PathDialog.eto.cs
index 5ddfd56a21f..21f9477c722 100644
--- a/Tools/Pipeline/Dialogs/PathDialog.eto.cs
+++ b/Tools/Pipeline/Dialogs/PathDialog.eto.cs
@@ -11,7 +11,7 @@ partial class PathDialog : DialogBase
{
DynamicLayout layout1;
StackLayout stack1, stack2;
- Label label1;
+ Label label1, label2;
TextBox textBox1;
Button buttonBrowse;
@@ -35,15 +35,19 @@ private void InitializeComponent()
stack1.Orientation = Orientation.Horizontal;
textBox1 = new TextBox();
- stack1.Items.Add(new StackLayoutItem(textBox1, true));
+ stack1.Items.Add(new StackLayoutItem(textBox1, VerticalAlignment.Center, true));
buttonBrowse = new Button();
buttonBrowse.Text = "...";
buttonBrowse.MinimumSize = new Size(1, 1);
- stack1.Items.Add(new StackLayoutItem(buttonBrowse, false));
+ stack1.Items.Add(new StackLayoutItem(buttonBrowse, VerticalAlignment.Center, false));
layout1.Add(stack1);
+ label2 = new Label();
+ label2.Text = "Macros:";
+ layout1.Add(label2);
+
stack2 = new StackLayout();
stack2.Spacing = 4;
stack2.Orientation = Orientation.Horizontal;
diff --git a/Tools/Pipeline/Global.Linux.cs b/Tools/Pipeline/Global.Linux.cs
index be3209d822e..21da4bc56b7 100644
--- a/Tools/Pipeline/Global.Linux.cs
+++ b/Tools/Pipeline/Global.Linux.cs
@@ -3,12 +3,10 @@
// file 'LICENSE.txt', which is part of this source code package.
using System;
-using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using Eto.Drawing;
-using Eto.Forms;
using Eto.GtkSharp.Drawing;
using Gtk;
@@ -34,26 +32,34 @@ static partial class Gtk3Wrapper
static partial class Global
{
private static IconTheme _theme;
- private static Gdk.Pixbuf _iconMissing;
- private static Gtk.Application _app;
+ private static Application _app;
private static void PlatformInit()
{
Linux = true;
_theme = IconTheme.Default;
- try
- {
- _iconMissing = _theme.LoadIcon("error", 16, 0);
- }
- catch
- {
- _iconMissing = new Gdk.Pixbuf(null, "TreeView.Missing.png");
- }
+ var iconMissing = _theme.LoadIcon("dialog-error", 16, 0);
+ var file = _theme.LoadIcon("text-x-generic", 16, 0);
+ var fileMissing = file.Copy();
+ iconMissing.Composite(fileMissing, 8, 8, 8, 8, 8, 8, 0.5, 0.5, Gdk.InterpType.Tiles, 255);
+ var folder = _theme.LoadIcon("folder", 16, 0);
+ var folderMissing = folder.Copy();
+ iconMissing.Composite(folderMissing, 8, 8, 8, 8, 8, 8, 0.5, 0.5, Gdk.InterpType.Tiles, 255);
+
+ _files["."] = ToEtoImage(file);
+ _fileMissing = ToEtoImage(fileMissing);
+ _folder = ToEtoImage(folder);
+ _folderMissing = ToEtoImage(folderMissing);
+
+ _xwtFiles["."] = ToXwtImage(file);
+ _xwtFileMissing = ToXwtImage(fileMissing);
+ _xwtFolder = ToXwtImage(folder);
+ _xwtFolderMissing = ToXwtImage(folderMissing);
if (Gtk.Global.MajorVersion >= 3 && Gtk.Global.MinorVersion >= 16)
{
- _app = new Gtk.Application(null, GLib.ApplicationFlags.None);
+ _app = new Application(null, GLib.ApplicationFlags.None);
_app.Register(GLib.Cancellable.Current);
UseHeaderBar = Gtk3Wrapper.gtk_application_prefers_app_menu(_app.Handle);
@@ -62,7 +68,7 @@ private static void PlatformInit()
private static void PlatformShowOpenWithDialog(string filePath)
{
- var adialoghandle = Gtk3Wrapper.gtk_app_chooser_dialog_new(((Gtk.Window)MainWindow.Instance.ControlObject).Handle,
+ var adialoghandle = Gtk3Wrapper.gtk_app_chooser_dialog_new(((Window)MainWindow.Instance.ControlObject).Handle,
4 + (int)DialogFlags.Modal,
Gtk3Wrapper.g_file_new_for_path(filePath));
var adialog = new AppChooserDialog(adialoghandle);
@@ -73,50 +79,26 @@ private static void PlatformShowOpenWithDialog(string filePath)
adialog.Destroy();
}
- private static Gdk.Pixbuf PlatformGetDirectoryIcon(bool exists)
- {
- var icon = _theme.LoadIcon("folder", 16, 0);
-
- if (!exists)
- {
- icon = icon.Copy();
- _iconMissing.Composite(icon, 8, 8, 8, 8, 8, 8, 0.5, 0.5, Gdk.InterpType.Tiles, 255);
- }
-
- return icon;
- }
-
- private static Gdk.Pixbuf PlatformGetFileIcon(string path, bool exists)
+ private static Gdk.Pixbuf PlatformGetFileIcon(string path)
{
Gdk.Pixbuf icon = null;
- try
- {
- var info = new GLib.FileInfo(Gtk3Wrapper.g_file_query_info(Gtk3Wrapper.g_file_new_for_path(path), "standard::*", 0, new IntPtr(), new IntPtr()));
- var sicon = info.Icon.ToString().Split(' ');
+ var info = new GLib.FileInfo(Gtk3Wrapper.g_file_query_info(Gtk3Wrapper.g_file_new_for_path(path), "standard::*", 0, new IntPtr(), new IntPtr()));
+ var sicon = info.Icon.ToString().Split(' ');
- for (int i = sicon.Length - 1; i >= 1; i--)
+ for (int i = sicon.Length - 1; i >= 1; i--)
+ {
+ try
{
- try
- {
- icon = _theme.LoadIcon(sicon[i], 16, 0);
- if (icon != null)
- break;
- }
- catch { }
+ icon = _theme.LoadIcon(sicon[i], 16, 0);
+ if (icon != null)
+ break;
}
+ catch { }
}
- catch { }
if (icon == null)
- icon = _theme.LoadIcon("text-x-generic", 16, 0);
-
-
- if (!exists)
- {
- icon = icon.Copy();
- _iconMissing.Composite(icon, 8, 8, 8, 8, 8, 8, 0.5, 0.5, Gdk.InterpType.Tiles, 255);
- }
+ throw new Exception();
return icon;
}
@@ -196,37 +178,39 @@ private static Gdk.Pixbuf PlatformGetIcon(string resource)
break;
case "Commands.Clean.png":
iconInfo = _theme.LookupIcon("edit-clear-all", 16, 0);
+ if (iconInfo == null)
+ iconInfo = _theme.LookupIcon("edit-clear", 16, 0);
break;
case "Commands.CancelBuild.png":
- iconInfo = _theme.LookupIcon("stop", 16, 0);
+ iconInfo = _theme.LookupIcon("process-stop", 16, 0);
break;
case "Commands.Help.png":
- iconInfo = _theme.LookupIcon("help", 16, 0);
+ iconInfo = _theme.LookupIcon("system-help", 16, 0);
break;
-
+
case "Build.Information.png":
- iconInfo = _theme.LookupIcon("info", 16, 0);
+ iconInfo = _theme.LookupIcon("dialog-information", 16, 0);
break;
case "Build.Fail.png":
- iconInfo = _theme.LookupIcon("error", 16, 0);
+ iconInfo = _theme.LookupIcon("dialog-error", 16, 0);
break;
case "Build.Processing.png":
iconInfo = _theme.LookupIcon("preferences-system-time", 16, 0);
break;
case "Build.Skip.png":
- iconInfo = _theme.LookupIcon("gtk-yes", 16, 0);
+ iconInfo = _theme.LookupIcon("emblem-default", 16, 0);
break;
case "Build.Start.png":
- iconInfo = _theme.LookupIcon("info", 16, 0);
+ iconInfo = _theme.LookupIcon("system-run", 16, 0);
break;
case "Build.EndSucceed.png":
- iconInfo = _theme.LookupIcon("info", 16, 0);
+ iconInfo = _theme.LookupIcon("system-run", 16, 0);
break;
case "Build.EndFailed.png":
- iconInfo = _theme.LookupIcon("info", 16, 0);
+ iconInfo = _theme.LookupIcon("system-run", 16, 0);
break;
case "Build.Succeed.png":
- iconInfo = _theme.LookupIcon("gtk-yes", 16, 0);
+ iconInfo = _theme.LookupIcon("emblem-default", 16, 0);
break;
}
diff --git a/Tools/Pipeline/Global.Mac.cs b/Tools/Pipeline/Global.Mac.cs
index 7ff1548c097..fd9e9c3146f 100644
--- a/Tools/Pipeline/Global.Mac.cs
+++ b/Tools/Pipeline/Global.Mac.cs
@@ -14,13 +14,18 @@ private static void PlatformInit()
{
}
-
- private static Image PlatformGetDirectoryIcon(bool exists)
+
+ private static Image PlatformGetFileIcon(string path)
+ {
+ throw new NotImplementedException();
+ }
+
+ private static Bitmap ToEtoImage(Image image)
{
throw new NotImplementedException();
}
- private static Image PlatformGetFileIcon(string path, bool exists)
+ private static Xwt.Drawing.Image ToXwtImage(Image image)
{
throw new NotImplementedException();
}
diff --git a/Tools/Pipeline/Global.Windows.cs b/Tools/Pipeline/Global.Windows.cs
index c5789e4f34a..13295a0b425 100755
--- a/Tools/Pipeline/Global.Windows.cs
+++ b/Tools/Pipeline/Global.Windows.cs
@@ -26,6 +26,21 @@ private static void PlatformInit()
{
var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
IsWindows10 = (reg.GetValue("ProductName") as string).StartsWith("Windows 10");
+
+ var file = ExtractIcon(0).ToBitmap();
+ var fileMissing = ExtractIcon(271).ToBitmap();
+ var folder = ExtractIcon(4).ToBitmap();
+ var folderMissing = ExtractIcon(234).ToBitmap();
+
+ _files["."] = ToEtoImage(file);
+ _fileMissing = ToEtoImage(fileMissing);
+ _folder = ToEtoImage(folder);
+ _folderMissing = ToEtoImage(folderMissing);
+
+ _xwtFiles["."] = ToXwtImage(file);
+ _xwtFileMissing = ToXwtImage(fileMissing);
+ _xwtFolder = ToXwtImage(folder);
+ _xwtFolderMissing = ToXwtImage(folderMissing);
}
public static System.Drawing.Icon ExtractIcon(int number)
@@ -37,37 +52,9 @@ public static System.Drawing.Icon ExtractIcon(int number)
return System.Drawing.Icon.FromHandle(large);
}
- private static System.Drawing.Bitmap PlatformGetDirectoryIcon(bool exists)
- {
- System.Drawing.Bitmap icon;
-
- if (exists)
- icon = ExtractIcon(4).ToBitmap();
- else
- icon = ExtractIcon(234).ToBitmap();
-
- return icon;
- }
-
- private static System.Drawing.Bitmap PlatformGetFileIcon(string path, bool exists)
+ private static System.Drawing.Bitmap PlatformGetFileIcon(string path)
{
- System.Drawing.Bitmap icon;
-
- if (exists)
- {
- try
- {
- icon = System.Drawing.Icon.ExtractAssociatedIcon(path).ToBitmap();
- }
- catch
- {
- icon = ExtractIcon(0).ToBitmap();
- }
- }
- else
- icon = ExtractIcon(271).ToBitmap();
-
- return icon;
+ return System.Drawing.Icon.ExtractAssociatedIcon(path).ToBitmap();
}
private static Bitmap ToEtoImage(System.Drawing.Bitmap bitmap)
diff --git a/Tools/Pipeline/Global.cs b/Tools/Pipeline/Global.cs
index 73cef196580..02e8b6f0574 100644
--- a/Tools/Pipeline/Global.cs
+++ b/Tools/Pipeline/Global.cs
@@ -3,34 +3,52 @@
// file 'LICENSE.txt', which is part of this source code package.
using System;
+using System.Collections.Generic;
using System.IO;
using Eto.Drawing;
-using Eto.Forms;
namespace MonoGame.Tools.Pipeline
{
static partial class Global
{
+ public static string NotAllowedCharacters
+ {
+ get
+ {
+ if (Unix)
+ return Linux ? "/" : ":";
+
+ return "/?<>\\:*|\"";
+ }
+ }
+
public static bool Linux { get; private set; }
public static bool UseHeaderBar { get; private set; }
public static bool Unix { get; private set; }
+ private static Dictionary _files;
+ private static Image _fileMissing, _folder, _folderMissing;
+
+ private static Dictionary _xwtFiles;
+ private static Xwt.Drawing.Image _xwtFileMissing, _xwtFolder, _xwtFolderMissing;
+
static Global()
{
Unix = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX;
- PlatformInit();
- }
+ _files = new Dictionary();
+ _files.Add(".", Bitmap.FromResource("TreeView.File.png"));
+ _fileMissing = Bitmap.FromResource("TreeView.FileMissing.png");
+ _folder = Bitmap.FromResource("TreeView.Folder.png");
+ _folderMissing = Bitmap.FromResource("TreeView.FolderMissing.png");
- public static string NotAllowedCharacters
- {
- get
- {
- if (Global.Unix)
- return Global.Linux ? "/" : ":";
+ _xwtFiles = new Dictionary();
+ _xwtFiles.Add(".", Xwt.Drawing.Image.FromResource("TreeView.File.png"));
+ _xwtFileMissing = Xwt.Drawing.Image.FromResource("TreeView.FileMissing.png");
+ _xwtFolder = Xwt.Drawing.Image.FromResource("TreeView.Folder.png");
+ _xwtFolderMissing = Xwt.Drawing.Image.FromResource("TreeView.FolderMissing.png");
- return "/?<>\\:*|\"";
- }
+ PlatformInit();
}
public static bool CheckString(string s)
@@ -58,54 +76,60 @@ public static void ShowOpenWithDialog(string filePath)
public static Image GetEtoDirectoryIcon(bool exists)
{
-#if WINDOWS || LINUX
- try
- {
- return ToEtoImage(PlatformGetDirectoryIcon(exists));
- }
- catch { }
-#endif
-
- return exists ? Bitmap.FromResource("TreeView.Folder.png") : Bitmap.FromResource("TreeView.FolderMissing.png");
+ return exists ? _folder : _folderMissing;
}
public static Image GetEtoFileIcon(string path, bool exists)
{
-#if WINDOWS || LINUX
+ if (!exists)
+ return _fileMissing;
+
+ var ext = Path.GetExtension(path);
+ if (_files.ContainsKey(ext))
+ return _files[ext];
+
+ Image icon;
+
try
{
- return ToEtoImage(PlatformGetFileIcon(path, exists));
+ icon = ToEtoImage(PlatformGetFileIcon(path));
+ }
+ catch
+ {
+ icon = _files["."];
}
- catch { }
-#endif
- return exists ? Bitmap.FromResource("TreeView.File.png") : Bitmap.FromResource("TreeView.FileMissing.png");
+ _files.Add(ext, icon);
+ return icon;
}
public static Xwt.Drawing.Image GetXwtDirectoryIcon(bool exists)
{
-#if WINDOWS || LINUX
- try
- {
- return ToXwtImage(PlatformGetDirectoryIcon(exists));
- }
- catch { }
-#endif
-
- return exists ? Xwt.Drawing.Image.FromResource("TreeView.Folder.png") : Xwt.Drawing.Image.FromResource("TreeView.FolderMissing.png");
+ return exists ? _xwtFolder : _xwtFolderMissing;
}
public static Xwt.Drawing.Image GetXwtFileIcon(string path, bool exists)
{
-#if WINDOWS || LINUX
+ if (!exists)
+ return _xwtFileMissing;
+
+ var ext = Path.GetExtension(path);
+ if (_xwtFiles.ContainsKey(ext))
+ return _xwtFiles[ext];
+
+ Xwt.Drawing.Image icon;
+
try
{
- return ToXwtImage(PlatformGetFileIcon(path, exists));
+ icon = ToXwtImage(PlatformGetFileIcon(path));
+ }
+ catch
+ {
+ icon = _xwtFiles["."];
}
- catch { }
-#endif
- return exists ? Xwt.Drawing.Image.FromResource("TreeView.File.png") : Xwt.Drawing.Image.FromResource("TreeView.FileMissing.png");
+ _xwtFiles.Add(ext, icon);
+ return icon;
}
public static Image GetEtoIcon(string resource)
diff --git a/Tools/Pipeline/Icons/Build/SucceedWithWarnings.png b/Tools/Pipeline/Icons/Build/SucceedWithWarnings.png
new file mode 100644
index 00000000000..ecd0633ee6f
Binary files /dev/null and b/Tools/Pipeline/Icons/Build/SucceedWithWarnings.png differ
diff --git a/Tools/Pipeline/MainWindow.cs b/Tools/Pipeline/MainWindow.cs
index 9f0430639c5..c9032d3b910 100644
--- a/Tools/Pipeline/MainWindow.cs
+++ b/Tools/Pipeline/MainWindow.cs
@@ -12,12 +12,15 @@ namespace MonoGame.Tools.Pipeline
{
partial class MainWindow : Form, IView
{
+#pragma warning disable 649
public EventHandler RecentChanged;
public EventHandler TitleChanged;
+#pragma warning restore 649
public const string TitleBase = "MonoGame Pipeline Tool";
public static MainWindow Instance;
private List _pads;
+ private Clipboard _clipboard;
private ContextMenu _contextMenu;
private FileDialogFilter _mgcbFileFilter, _allFileFilter, _xnaFileFilter;
private string[] monoLocations = {
@@ -29,6 +32,7 @@ partial class MainWindow : Form, IView
public MainWindow()
{
_pads = new List();
+ _clipboard = new Clipboard();
InitializeComponent();
@@ -45,7 +49,7 @@ public MainWindow()
foreach (var com in pad.Commands)
menu.Items.Add(com.CreateMenuItem());
- menuPads.Items.Add(menu);
+ menuView.Items.Add(menu);
}
}
@@ -60,13 +64,11 @@ public MainWindow()
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = !PipelineController.Instance.Exit();
- base.OnClosing(e);
- }
- public override void Close()
- {
- Application.Instance.Quit();
- base.Close();
+ if (!e.Cancel)
+ Xwt.Application.Exit();
+
+ base.OnClosing(e);
}
public void ShowContextMenu()
@@ -197,7 +199,7 @@ public void UpdateProperties()
public void OutputAppend(string text)
{
- Application.Instance.Invoke(() => buildOutput.WriteLine(text));
+ Application.Instance.AsyncInvoke(() => buildOutput.WriteLine(text));
}
public void OutputClear()
@@ -383,6 +385,7 @@ public void UpdateCommands(MenuInfo info)
cmdOpenItem.Enabled = info.OpenItem;
cmdOpenItemWith.Enabled = info.OpenItemWith;
cmdOpenItemLocation.Enabled = info.OpenItemLocation;
+ cmdCopyAssetPath.Enabled = info.CopyAssetPath;
cmdRebuildItem.Enabled = info.RebuildItem;
// Visibility of menu items can't be changed so
@@ -398,6 +401,7 @@ public void UpdateCommands(MenuInfo info)
AddContextMenu(cmAdd, ref sep);
AddSeparator(ref sep);
AddContextMenu(cmOpenItemLocation, ref sep);
+ AddContextMenu(cmCopyAssetPath, ref sep);
AddContextMenu(cmRebuildItem, ref sep);
AddSeparator(ref sep);
AddContextMenu(cmExclude, ref sep);
@@ -463,6 +467,12 @@ public void UpdateRecentList(List recentList)
}
}
+ public void SetClipboard(string text)
+ {
+ _clipboard.Clear();
+ _clipboard.Text = text;
+ }
+
#endregion
#region Commands
@@ -602,6 +612,11 @@ private void CmdOpenItemLocation_Executed(object sender, EventArgs e)
Process.Start(PipelineController.Instance.GetFullPath(PipelineController.Instance.SelectedItem.Location));
}
+ private void CmdCopyAssetPath_Executed(object sender, EventArgs e)
+ {
+ PipelineController.Instance.CopyAssetPath();
+ }
+
private void CmdRebuildItem_Executed(object sender, EventArgs e)
{
PipelineController.Instance.RebuildItems();
diff --git a/Tools/Pipeline/MainWindow.eto.cs b/Tools/Pipeline/MainWindow.eto.cs
index 6be27619e20..9ad53fa3048 100644
--- a/Tools/Pipeline/MainWindow.eto.cs
+++ b/Tools/Pipeline/MainWindow.eto.cs
@@ -17,13 +17,13 @@ partial class MainWindow
public Command cmdBuild, cmdRebuild, cmdClean, cmdCancelBuild;
public CheckCommand cmdDebugMode;
public Command cmdHelp, cmdAbout;
- public Command cmdOpenItem, cmdOpenItemWith, cmdOpenItemLocation, cmdRebuildItem;
+ public Command cmdOpenItem, cmdOpenItemWith, cmdOpenItemLocation, cmdCopyAssetPath, cmdRebuildItem;
MenuBar menubar;
ToolBar toolbar;
- ButtonMenuItem menuFile, menuRecent, menuEdit, menuAdd, menuPads, menuBuild, menuHelp;
+ ButtonMenuItem menuFile, menuRecent, menuEdit, menuAdd, menuView, menuBuild, menuHelp;
ToolItem toolBuild, toolRebuild, toolClean, toolCancelBuild;
- MenuItem cmOpenItem, cmOpenItemWith, cmOpenItemLocation, cmRebuildItem, cmExclude, cmRename, cmDelete;
+ MenuItem cmOpenItem, cmOpenItemWith, cmOpenItemLocation, cmCopyAssetPath, cmRebuildItem, cmExclude, cmRename, cmDelete;
ButtonMenuItem cmAdd;
ProjectControl projectControl;
@@ -102,6 +102,7 @@ private void InitializeComponent()
cmdOpenItem.Executed += CmdOpenItem_Executed;
cmdOpenItemWith.Executed += CmdOpenItemWith_Executed;
cmdOpenItemLocation.Executed += CmdOpenItemLocation_Executed;
+ cmdCopyAssetPath.Executed += CmdCopyAssetPath_Executed;
cmdRebuildItem.Executed += CmdRebuildItem_Executed;
}
@@ -241,6 +242,9 @@ private void InitalizeCommands()
cmdOpenItemLocation = new Command();
cmdOpenItemLocation.MenuText = "Open Containing Directory";
+ cmdCopyAssetPath = new Command();
+ cmdCopyAssetPath.MenuText = "Copy Asset Path";
+
cmdRebuildItem = new Command();
cmdRebuildItem.Image = Global.GetEtoIcon("Commands.Rebuild.png");
cmdRebuildItem.MenuText = "Rebuild";
@@ -248,8 +252,7 @@ private void InitalizeCommands()
private void InitalizeMenu()
{
- Menu = menubar = new MenuBar();
- Menu.Style = "MenuBar";
+ menubar = new MenuBar();
menuFile = new ButtonMenuItem();
menuFile.Text = "File";
@@ -266,7 +269,7 @@ private void InitalizeMenu()
menuFile.Items.Add(new SeparatorMenuItem());
menuFile.Items.Add(cmdSave);
menuFile.Items.Add(cmdSaveAs);
- Menu.Items.Add(menuFile);
+ menubar.Items.Add(menuFile);
menuEdit = new ButtonMenuItem();
menuEdit.Text = "Edit";
@@ -287,13 +290,13 @@ private void InitalizeMenu()
menuEdit.Items.Add(new SeparatorMenuItem());
menuEdit.Items.Add(cmdRename);
menuEdit.Items.Add(cmdDelete);
- Menu.Items.Add(menuEdit);
+ menubar.Items.Add(menuEdit);
- //Pads Commands
+ // View Commands
- menuPads = new ButtonMenuItem();
- menuPads.Text = "Pads";
- Menu.Items.Add(menuPads);
+ menuView = new ButtonMenuItem();
+ menuView.Text = "View";
+ menubar.Items.Add(menuView);
menuBuild = new ButtonMenuItem();
menuBuild.Text = "Build";
@@ -303,15 +306,18 @@ private void InitalizeMenu()
menuBuild.Items.Add(cmdCancelBuild);
menuBuild.Items.Add(new SeparatorMenuItem());
menuBuild.Items.Add(cmdDebugMode);
- Menu.Items.Add(menuBuild);
+ menubar.Items.Add(menuBuild);
menuHelp = new ButtonMenuItem();
menuHelp.Text = "Help";
menuHelp.Items.Add(cmdHelp);
- Menu.Items.Add(menuHelp);
+ menubar.Items.Add(menuHelp);
- Menu.QuitItem = cmdExit;
- Menu.AboutItem = cmdAbout;
+ menubar.QuitItem = cmdExit;
+ menubar.AboutItem = cmdAbout;
+
+ Menu = menubar;
+ Menu.Style = "MenuBar";
}
private void InitalizeContextMenu()
@@ -327,6 +333,7 @@ private void InitalizeContextMenu()
cmAdd.Items.Add(cmdExistingFolder.CreateMenuItem());
cmOpenItemLocation = cmdOpenItemLocation.CreateMenuItem();
+ cmCopyAssetPath = cmdCopyAssetPath.CreateMenuItem();
cmRebuildItem = cmdRebuildItem.CreateMenuItem();
cmExclude = cmdExclude.CreateMenuItem();
cmRename = cmdRename.CreateMenuItem();
diff --git a/Tools/Pipeline/MainWindow.glade b/Tools/Pipeline/MainWindow.glade
index 4d5f2c8f4e2..36142cdcbc5 100644
--- a/Tools/Pipeline/MainWindow.glade
+++ b/Tools/Pipeline/MainWindow.glade
@@ -18,7 +18,7 @@
True
False
- emblem-system-symbolic
+ applications-system-symbolic
True
@@ -28,7 +28,7 @@
True
False
- media-playback-stop-symbolic
+ process-stop-symbolic
True
diff --git a/Tools/Pipeline/Styles.Linux.cs b/Tools/Pipeline/Styles.Linux.cs
index 392635a28c5..8bd7c198d41 100644
--- a/Tools/Pipeline/Styles.Linux.cs
+++ b/Tools/Pipeline/Styles.Linux.cs
@@ -282,6 +282,38 @@ public static void Load()
{
h.Control.WidthChars = 0;
});
+
+ Style.Add("BuildOutput", h =>
+ {
+ var child = ((((h.Control.Child as Gtk.Viewport).Child as Gtk.VBox).Children[0] as Gtk.HBox).Children[0] as Gtk.Alignment).Child;
+ var ok = false;
+
+ h.Control.SizeAllocated += delegate
+ {
+ // Set Width of the Drawable
+ var al = child.Allocation;
+ al.Width = h.Control.AllocatedWidth - 2;
+ if (BuildOutput.ReqWidth > al.Width)
+ al.Width = BuildOutput.ReqWidth;
+ child.SetAllocation(al);
+
+ if (PipelineSettings.Default.AutoScrollBuildOutput)
+ {
+ // Scroll to bottom
+ if (BuildOutput.Count == -1)
+ ok = false;
+
+ if (!ok)
+ {
+ var adj = h.Control.Vadjustment;
+ adj.Value = adj.Upper - adj.PageSize;
+
+ if (adj.Upper >= BuildOutput.Count && BuildOutput.Count != -1)
+ ok = true;
+ }
+ }
+ };
+ });
}
}
}
diff --git a/default.build b/default.build
index 7f5c8868e0c..a9879b67983 100644
--- a/default.build
+++ b/default.build
@@ -156,19 +156,13 @@
-
-
-
-
-
-
-
-
+
+
@@ -182,15 +176,7 @@
-
-
-
-
-
-
-
-
-
+