Skip to content

Commit

Permalink
Merge pull request #1367 from tomspilman/master
Browse files Browse the repository at this point in the history
[Branch Migration] Master
  • Loading branch information
dellis1972 committed Feb 14, 2013
2 parents 56afa04 + 078aee4 commit 5952e64
Show file tree
Hide file tree
Showing 889 changed files with 73,991 additions and 41,187 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "StarterKits"]
path = StarterKits
url = https://github.com/kungfubanana/MonoGame-StarterKits.git
[submodule "ThirdParty/Kickstart"]
path = ThirdParty/Kickstart
url = https://github.com/OutOfOrder/MonoKickstart.git
485 changes: 485 additions & 0 deletions Graphics/Logos/MonoGame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Graphics/Logos/MonogameBig.psd
Binary file not shown.
Binary file added Graphics/Logos/MonogameLogo1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Graphics/Logos/MonogameLogo128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Graphics/Logos/MonogameLogo1920x1920.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Graphics/Logos/MonogameLogo1920x1920ForDark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Graphics/Logos/MonogameLogo256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added Graphics/Logos/MonogameLogo512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Graphics/Logos/MonogameLogo64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Installers/Windows/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Its Free
252 changes: 214 additions & 38 deletions Installers/Windows/MonoGame.nsi

Large diffs are not rendered by default.

Binary file added Installers/Windows/mono.bmp
Binary file not shown.
Binary file added Installers/Windows/xamarin.bmp
Binary file not shown.
41 changes: 41 additions & 0 deletions Installers/Windows/xamarin.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=4
Title=Xamarin
CancelEnabled=0
CancelShow=0
BackEnabled=0

[Field 1]
Type=Bitmap
Text=Bitmap
Left=3
Right=115
Top=46
Bottom=100

[Field 2]
Type=Bitmap
Text=Bitmap
Left=3
Right=115
Top=4
Bottom=40

[Field 3]
Type=Link
Text=www.xamarin.com
State=http://www.xamarin.com
Left=220
Right=288
Top=94
Bottom=102

[Field 4]
Type=Label
Text=This installer includes a project template and the MonoGame runtime for Android.\r\n\r\nIn order to use this template you will need to have Mono for Android from Xamarin installed. You can use the Trial version however this will only allow you to deploy to emulators. \r\n\r\nIf you wish to develop for real devices you will need to purchace a developer licence from Xamarin.
Left=123
Right=284
Top=2
Bottom=92

Binary file added Installers/panel.bmp
Binary file not shown.
166 changes: 166 additions & 0 deletions MonoGame.ContentPipeline/ContentProcessors/AudioConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Yeti.WMFSdk;
using System.IO;
//using Yeti.MMedia;
//using WaveLib;
//using Yeti.MMedia.Mp3;

using NAudio;
using NAudio.Wave;
using NAudio.WindowsMediaFormat;
using Microsoft.Xna.Framework.Content.Pipeline.Audio;

namespace MonoGameContentProcessors
{
public static class AudioConverter
{
/// <summary>
/// Converts a WMA file to a WAV stream
/// </summary>
/// <param name="outputStream">Stream to store the converted wav.</param>
/// <param name="filePath">Path to a .wma file to convert</param>
/// <returns>The WaveFormat object of the converted wav</returns>
private static WaveFormat wmaToWav(string pathToWma, Stream outputStream, int sampleRate, int bitDepth, int numChannels)
{
if (!Path.GetExtension(pathToWma).ToLower().Contains("wma"))
throw new ArgumentException("Must be a .wma file!");

using (var reader = new WMAFileReader(pathToWma))
{
var targetFormat = new NAudio.Wave.WaveFormat(sampleRate, bitDepth, numChannels);
var pcmStream = new WaveFormatConversionStream(targetFormat, reader);
var buffer = new byte[pcmStream.Length];
pcmStream.Read(buffer, 0, (int)pcmStream.Length);
outputStream.Write(buffer, 0, buffer.Length);
outputStream.Position = 0;

pcmStream.Close();

return targetFormat;
}
}

/// <summary>
/// Converts one audio format into another.
/// </summary>
/// <param name="pathToFile">Path to the file to be converted</param>
/// <param name="outputStream">Stream where the converted sound will be.</param>
/// /// <param name="bitDepth">The target bit depth.</param>
/// <param name="sampleRate">The target sample rate.</param>
/// <param name="bitDepth">The target bit depth.</param>
/// <param name="numChannels">the number of channels.</param>
public static WaveFormat ConvertFile(string pathToFile, Stream outputStream, AudioFileType targetFileType, int sampleRate, int bitDepth, int numChannels)
{
if (targetFileType == AudioFileType.Wma)
throw new ArgumentException("WMA is not a vaid output type.");

string sourceFileType = pathToFile.Substring(pathToFile.Length - 3).ToLower();
switch (sourceFileType)
{
case "mp3":
if (targetFileType != AudioFileType.Wav)
throw new NotSupportedException("mp3's should only ever be converted to .wav.");

return mp3ToWav(pathToFile, outputStream, sampleRate, bitDepth, numChannels);

case "wma":
if (targetFileType == AudioFileType.Mp3)
{
wmaToMp3(pathToFile, outputStream, sampleRate, bitDepth, numChannels);
return null;
}
else if (targetFileType == AudioFileType.Wav)
{
return wmaToWav(pathToFile, outputStream, sampleRate, bitDepth, numChannels);
}

break;

case "wav":
if (targetFileType == AudioFileType.Mp3)
{
wavToMp3(pathToFile, outputStream, sampleRate, bitDepth, numChannels);
return null;
}
else if (targetFileType == AudioFileType.Wav )
return reencodeWav(pathToFile, outputStream, sampleRate, bitDepth, numChannels);

break;

}

return null;
}

private static void wavToMp3(string pathToFile, Stream outputStream, int sampleRate, int bitDepth, int numChannels)
{
// wavStream gets closed in wavStreamToMP3();
wavToMp3(new WaveLib.WaveStream(pathToFile), outputStream, (uint)(sampleRate / 1000));
}

private static void wavToMp3(Stream streamToWav, Stream outputStream, uint desiredOutputBitRate)
{
var mp3Config = new Yeti.MMedia.Mp3.Mp3WriterConfig((streamToWav as WaveLib.WaveStream).Format, desiredOutputBitRate);

var mp3Writer = new Yeti.MMedia.Mp3.Mp3Writer(outputStream, mp3Config);
byte[] buff = new byte[mp3Writer.OptimalBufferSize];
int read = 0;
long total = streamToWav.Length;
streamToWav.Position = 0;
while ((read = streamToWav.Read(buff, 0, buff.Length)) > 0)
mp3Writer.Write(buff, 0, read);

mp3Writer.Close();
streamToWav.Close();
}

private static void wmaToMp3(string pathToFile, Stream outputStream, int sampleRate, int bitDepth, int numChannels)
{
var streamToWav = new WaveLib.WaveStream();
wmaToWav(pathToFile, streamToWav.BaseStream, sampleRate, bitDepth, numChannels);

streamToWav.ReadHeader();

// wavStream gets closed in wavStreamToMP3();
wavToMp3(streamToWav, outputStream, (uint)(sampleRate / 1000));
}

private static WaveFormat mp3ToWav(string pathToMp3, Stream outputStream, int sampleRate, int bitDepth, int numChannels)
{
using (var reader = new Mp3FileReader(pathToMp3))
{
var targetFormat = new NAudio.Wave.WaveFormat(sampleRate, bitDepth, numChannels);
var pcmStream = new WaveFormatConversionStream(targetFormat, reader);
var buffer = new byte[pcmStream.Length];
pcmStream.Read(buffer, 0, (int)pcmStream.Length);
outputStream.Write(buffer, 0, buffer.Length);
outputStream.Position = 0;

pcmStream.Close();

return targetFormat;
}
}

private static WaveFormat reencodeWav(string pathToWav, Stream outputStream, int sampleRate, int bitDepth, int numChannels)
{
using (var reader = new WaveFileReader(pathToWav))
{
var targetFormat = new NAudio.Wave.WaveFormat(sampleRate, bitDepth, numChannels);
var pcmStream = new WaveFormatConversionStream(targetFormat, reader);
var buffer = new byte[pcmStream.Length];
pcmStream.Read(buffer, 0, (int)pcmStream.Length);

outputStream.Write(buffer, 0, buffer.Length);
outputStream.Position = 0;

pcmStream.Close();

return targetFormat;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;

namespace MonoGameContentProcessors.Content
{
public enum MGCompressionMode
{
PVRTCTwoBitsPerPixel,
PVRTCFourBitsPerPixel,
NoCompression
}

class MGBitmapContent : BitmapContent
{
private MGCompressionMode _bpp;
private byte[] _pixelData;

public MGBitmapContent() { }

public MGBitmapContent(byte[] pData, int width, int height, MGCompressionMode bpp) :
base(width, height)
{
_pixelData = pData;
_bpp = bpp;
}

public override byte[] GetPixelData()
{
return (byte[])this._pixelData.Clone();
}

public override void SetPixelData(byte[] sourceData)
{
this._pixelData = (byte[])sourceData.Clone();
}

protected override bool TryCopyFrom(BitmapContent sourceBitmap, Rectangle sourceRegion, Rectangle destinationRegion)
{
throw new NotImplementedException();
//return BitmapContent.InteropCopy(sourceBitmap, sourceRegion, this, destinationRegion);
}

protected override bool TryCopyTo(BitmapContent destinationBitmap, Rectangle sourceRegion, Rectangle destinationRegion)
{
throw new NotImplementedException();

// return BitmapContent.InteropCopy(this, sourceRegion, destinationBitmap, destinationRegion);

}

// Because of a Validate in Texture2DContent, we cannot simply cast the correct format.
// For IOS, since we'll never be using DXT compression, we'll pass DXT5 for PVRTC4BPP, and DXT3
// for PVRTC2BPP. We'll unpack and properly process this at runtime in the Texture2D Reader.
public override bool TryGetFormat(out SurfaceFormat format)
{
//TODO: Return the correct SurfaceFormat for proper MonoGame processing.
//format = SurfaceFormat.RgbaPvrtc4Bpp;

switch(_bpp)
{
case MGCompressionMode.PVRTCFourBitsPerPixel:
format = SurfaceFormat.Dxt5;
break;
case MGCompressionMode.PVRTCTwoBitsPerPixel:
format = SurfaceFormat.Dxt3;
break;
case MGCompressionMode.NoCompression:
format = SurfaceFormat.Color;
break;

default:
format = SurfaceFormat.Dxt5;
break;
}

return true;
}





}
}
47 changes: 47 additions & 0 deletions MonoGame.ContentPipeline/ContentProcessors/ContentHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using Microsoft.Xna.Framework.Content.Pipeline;

namespace MonoGameContentProcessors
{
static public class ContentHelper
{
static public MonoGamePlatform GetMonoGamePlatform()
{
// Stock XNA uses a hardcoded enum for platforms... this disallows
// us from extending it for MonoGame platforms.
//
// To work around this we currently depend on an environment variable.
//
// In the future when MonoGame has the full content pipeline
// implemented this hack will not be nessasary.

var platform = Environment.GetEnvironmentVariable("MONOGAME_PLATFORM", EnvironmentVariableTarget.User);

// If the platform is unset then this isn't a MonoGame platform we're building for.
if (string.IsNullOrEmpty(platform))
return MonoGamePlatform.None;

// Else return the right platform identifer.
switch (platform.ToUpper())
{
case "WINDOWS":
return MonoGamePlatform.Windows;
case "WINDOWS8":
return MonoGamePlatform.Windows8;
case "IOS":
return MonoGamePlatform.iOS;
case "ANDROID":
return MonoGamePlatform.Android;
case "LINUX":
return MonoGamePlatform.Linux;
case "OSX":
return MonoGamePlatform.OSX;
case "PSM":
return MonoGamePlatform.PSM;

default:
throw new PipelineException("Unexpected MonoGame platform '{0}'!", platform);
}
}
}
}
Loading

0 comments on commit 5952e64

Please sign in to comment.