Skip to content

Commit

Permalink
Merge pull request #531 from CartBlanche/master
Browse files Browse the repository at this point in the history
Merge for 2.5.1 Release, from develop
  • Loading branch information
dellis1972 committed Jun 18, 2012
2 parents 4bf1b0e + 8de7527 commit 56afa04
Show file tree
Hide file tree
Showing 78 changed files with 2,744 additions and 808 deletions.
6 changes: 3 additions & 3 deletions Installers/Windows/MonoGame.nsi
Expand Up @@ -2,7 +2,7 @@ SetCompressor /SOLID /FINAL lzma

!define FrameworkPath "C:\Sandbox\MonoGame\"
!define VERSION "2.5"
!define REVISION "0.0"
!define REVISION "1.0"
!define INSTALLERFILENAME "MonoGame"
!define APPNAME "MonoGame"

Expand All @@ -13,7 +13,7 @@ SetCompressor /SOLID /FINAL lzma
!include "InstallOptions.nsh"

Name '${APPNAME} ${VERSION} for MonoDevelop'
OutFile '${INSTALLERFILENAME}-${VERSION}.exe'
OutFile '${INSTALLERFILENAME}-${VERSION}.${REVISION}.exe'
InstallDir '$PROGRAMFILES64\${APPNAME}'
VIProductVersion "${VERSION}.${REVISION}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APPNAME} for MonoDevelop"
Expand Down Expand Up @@ -124,7 +124,7 @@ Section "Visual Studio 2010 Templates"
SetOutPath "$DOCUMENTS\Visual Studio 2010\Templates\ProjectTemplates\Visual C#\MonoGame"

; install the Templates for MonoDevelop
File /r '..\..\ProjectTemplates\VisualStudio2010.MonoGame.${VERSION}\*.*'
File /r '..\..\ProjectTemplates\VisualStudio2010.MonoGame.${VERSION}\*.zip'
GOTO EndTemplates
CannotInstallTemplates:

Expand Down
2 changes: 1 addition & 1 deletion MonoGame.Framework/Android/AndroidGameActivity.cs
Expand Up @@ -73,7 +73,7 @@ internal class OrientationListener : OrientationEventListener
{
AndroidGameActivity activity;

public OrientationListener(AndroidGameActivity activity) : base(activity, 1)
public OrientationListener(AndroidGameActivity activity) : base(activity, Android.Hardware.SensorDelay.Game)
{
this.activity = activity;
}
Expand Down
18 changes: 9 additions & 9 deletions MonoGame.Framework/Android/AndroidGameWindow.cs
Expand Up @@ -353,8 +353,8 @@ public override bool OnTouchEvent(MotionEvent e)
switch (e.ActionMasked)
{
// DOWN
case 0:
case 5:
case MotionEventActions.Down:
case MotionEventActions.PointerDown:
index = collection.FindIndexById(e.GetPointerId(e.ActionIndex), out tlocation);
if (index < 0)
{
Expand All @@ -368,8 +368,8 @@ public override bool OnTouchEvent(MotionEvent e)
}
break;
// UP
case 1:
case 6:
case MotionEventActions.Up:
case MotionEventActions.PointerUp:
index = collection.FindIndexById(e.GetPointerId(e.ActionIndex), out tlocation);
if (index >= 0)
{
Expand All @@ -378,7 +378,7 @@ public override bool OnTouchEvent(MotionEvent e)
}
break;
// MOVE
case 2:
case MotionEventActions.Move:
for (int i = 0; i < e.PointerCount; i++)
{
id = e.GetPointerId(i);
Expand All @@ -395,8 +395,8 @@ public override bool OnTouchEvent(MotionEvent e)
}
break;
// CANCEL, OUTSIDE
case 3:
case 4:
case MotionEventActions.Cancel:
case MotionEventActions.Outside:
index = collection.FindIndexById(id, out tlocation);
if (index >= 0)
{
Expand Down Expand Up @@ -465,11 +465,11 @@ private set

if (_currentOrientation == DisplayOrientation.Portrait || _currentOrientation == DisplayOrientation.PortraitUpsideDown)
{
Game.Activity.SetRequestedOrientation(ScreenOrientation.Portrait);
//Game.Activity.SetRequestedOrientation(ScreenOrientation.Portrait);
}
else if (_currentOrientation == DisplayOrientation.LandscapeLeft || _currentOrientation == DisplayOrientation.LandscapeRight)
{
Game.Activity.SetRequestedOrientation(ScreenOrientation.Landscape);
//Game.Activity.SetRequestedOrientation(ScreenOrientation.Landscape);
}

if (OrientationChanged != null)
Expand Down
13 changes: 12 additions & 1 deletion MonoGame.Framework/Android/Content/ContentManager.cs
Expand Up @@ -54,7 +54,18 @@ string GetFilename(string assetName)
protected virtual Stream OpenStream(string assetName)
{
Stream stream = Game.Activity.Assets.Open(assetName);
return stream;
try
{
MemoryStream memStream = new MemoryStream();
stream.CopyTo(memStream);
memStream.Seek(0, SeekOrigin.Begin);
return memStream;
}
finally
{
stream.Close();
}

}
}
}
Expand Up @@ -43,7 +43,7 @@
using System.IO;
using System.Linq;

namespace Microsoft.Xna.Framework
namespace Microsoft.Xna.Framework.Content
{
internal class SongReader
{
Expand Down
Expand Up @@ -43,7 +43,7 @@
using System.IO;
using System.Linq;

namespace Microsoft.Xna.Framework
namespace Microsoft.Xna.Framework.Content
{
internal class SoundEffectReader
{
Expand Down
2 changes: 1 addition & 1 deletion MonoGame.Framework/Android/Input/Accelerometer.cs
Expand Up @@ -79,7 +79,7 @@ public static AccelerometerState GetState()

private class SensorListener : Java.Lang.Object, ISensorEventListener
{
public void OnAccuracyChanged(Sensor sensor, int accuracy)
public void OnAccuracyChanged(Sensor sensor, SensorStatus status)
{
//do nothing
}
Expand Down
43 changes: 37 additions & 6 deletions MonoGame.Framework/Android/Input/Keyboard.cs
Expand Up @@ -77,17 +77,48 @@ public static void KeyUp(Keycode keyCode)
maps[Keycode.DpadUp] = Keys.Up;
maps[Keycode.DpadDown] = Keys.Down;
maps[Keycode.DpadCenter] = Keys.Enter;
maps[Keycode.Num0] = Keys.D0;
maps[Keycode.Num1] = Keys.D1;
maps[Keycode.Num2] = Keys.D2;
maps[Keycode.Num3] = Keys.D3;
maps[Keycode.Num4] = Keys.D4;
maps[Keycode.Num5] = Keys.D5;
maps[Keycode.Num6] = Keys.D6;
maps[Keycode.Num7] = Keys.D7;
maps[Keycode.Num8] = Keys.D8;
maps[Keycode.Num9] = Keys.D9;
maps[Keycode.A] = Keys.A;
maps[Keycode.Y] = Keys.Y;
maps[Keycode.X] = Keys.X;
maps[Keycode.B] = Keys.B;
maps[Keycode.S] = Keys.S;
maps[Keycode.B] = Keys.B;
maps[Keycode.C] = Keys.C;
maps[Keycode.D] = Keys.D;
maps[Keycode.E] = Keys.E;
maps[Keycode.F] = Keys.F;
maps[Keycode.G] = Keys.G;
maps[Keycode.H] = Keys.H;
maps[Keycode.I] = Keys.I;
maps[Keycode.J] = Keys.J;
maps[Keycode.K] = Keys.K;
maps[Keycode.L] = Keys.L;
maps[Keycode.M] = Keys.M;
maps[Keycode.N] = Keys.N;
maps[Keycode.O] = Keys.O;
maps[Keycode.P] = Keys.P;
maps[Keycode.Q] = Keys.Q;
maps[Keycode.R] = Keys.R;
maps[Keycode.S] = Keys.S;
maps[Keycode.T] = Keys.T;
maps[Keycode.U] = Keys.U;
maps[Keycode.V] = Keys.V;
maps[Keycode.W] = Keys.W;
maps[Keycode.D] = Keys.D;
maps[Keycode.X] = Keys.X;
maps[Keycode.Y] = Keys.Y;
maps[Keycode.C] = Keys.Z;
maps[Keycode.Back] = Keys.Escape;
maps[Keycode.Back] = Keys.Back;
maps[Keycode.Home] = Keys.Home;
maps[Keycode.Enter] = Keys.Enter;
maps[Keycode.Enter] = Keys.Enter;
maps[Keycode.Period] = Keys.OemPeriod;
maps[Keycode.Comma] = Keys.OemComma;
// TODO: put in all the other mappings
maps[Keycode.Menu] = Keys.Help;
maps[Keycode.Search] = Keys.BrowserSearch;
Expand Down
4 changes: 2 additions & 2 deletions MonoGame.Framework/Android/Input/Touch/GestureListener.cs
Expand Up @@ -112,8 +112,8 @@ internal static void CheckForDrag(MotionEvent e, Vector2 position)

switch (e.ActionMasked)
{
case 1:
case 6:
case MotionEventActions.Up:
case MotionEventActions.PointerUp:
if ((dragging && (TouchPanel.EnabledGestures & GestureType.DragComplete) != 0))
{
var gs = new GestureSample(GestureType.DragComplete, AndroidGameActivity.Game.TargetElapsedTime,
Expand Down
62 changes: 48 additions & 14 deletions MonoGame.Framework/Android/Media/Video.cs
Expand Up @@ -36,6 +36,9 @@
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
// purpose and non-infringement.
// */
using Android.Widget;


#endregion License

using System;
Expand All @@ -46,17 +49,18 @@

namespace Microsoft.Xna.Framework.Media
{
public sealed class Video : IDisposable
public sealed class Video : Java.Lang.Object, IDisposable, Android.Media.MediaPlayer.IOnCompletionListener,
Android.Media.MediaPlayer.IOnVideoSizeChangedListener
{
internal Android.Media.MediaPlayer Player;
internal VideoPlayer Player;
internal Android.Media.MediaPlayer media;
private string _fileName;
private Color _backColor = Color.Black;


internal Video(string FileName)
{
_fileName = FileName;
Prepare();
_fileName = FileName;
}

public Color BackgroundColor
Expand Down Expand Up @@ -116,25 +120,55 @@ private static bool Contains(string search, string[] arr)

internal void Prepare()
{
Player = new Android.Media.MediaPlayer();
if (Player != null )

media = new Android.Media.MediaPlayer();//.Create(Game.Activity,Android.Net.Uri.Parse("file://android_asset/Content/sintel_trailer.mp4"), Game.Instance.Window.Holder);
if (media != null )
{
var afd = Game.Activity.Assets.OpenFd(_fileName);
var afd = Game.Activity.Assets.OpenFd(_fileName);
if (afd != null)
{
Player.SetDataSource(afd.FileDescriptor, afd.StartOffset, afd.Length);
Player.Prepare();
{
media.SetOnCompletionListener(this);
media.SetOnVideoSizeChangedListener(this);
VideoView vv = (VideoView)Game.Activity.FindViewById(MonoGame.Android.Media.VideoViewId);
if (vv == null) throw new InvalidOperationException("you must attach a VideoView in a framelayout with its Id set to MonoGame.Android.Media.VideoViewId");
media.SetDisplay(vv.Holder);
media.SetDataSource(afd.FileDescriptor, afd.StartOffset, afd.Length);
media.Prepare();
}
}
}


public void Dispose()
{
if (Player != null)
{
Player.Dispose();
Player = null;
if (media != null)
{
media.Dispose();
media = null;
}
}

#region IOnCompletionListener implementation
public void OnCompletion (Android.Media.MediaPlayer mp)
{
if (Player != null) Player.Stop();
}
#endregion

#region IOnVideoSizeChangedListener implementation
public void OnVideoSizeChanged (Android.Media.MediaPlayer mp, int width, int height)
{
#if DEBUG
Android.Util.Log.Info("MonoGameInfo", string.Format("Video Size : {0}x{1}", width, height));
#endif
}
#endregion
}
}
namespace MonoGame.Android
{
public class Media
{
public const int VideoViewId = 243252;
}
}
25 changes: 14 additions & 11 deletions MonoGame.Framework/Android/Media/VideoPlayer.cs
Expand Up @@ -65,12 +65,12 @@ public Texture2D GetTexture()

public void Pause()
{
_video.Player.Pause();
_video.media.Pause();
}

public void Resume()
{
_video.Player.Start();
_video.media.Start();
}

public MediaState State
Expand All @@ -83,21 +83,23 @@ public MediaState State

public void Play(Microsoft.Xna.Framework.Media.Video video)
{
_video = video;

_video.Player.SetDisplay(_game.Window.Holder);
_video.Player.Start();

AndroidGamePlatform.IsPlayingVdeo = true;
_video = video;
_video.Player = this;
_video.Prepare();
_video.media.Start();
_state = MediaState.Playing;
AndroidGamePlatform.IsPlayingVdeo = true;
}

public void Stop()
{
_video.Player.Stop();
{
_video.media.Stop();
_state = MediaState.Stopped;
AndroidGamePlatform.IsPlayingVdeo = false;
_video.Player.SetDisplay(null);
_video.media.SetOnCompletionListener(null);
_video.media.SetOnVideoSizeChangedListener(null);
_video.media.SetDisplay(null);
_video.Player = null;
}

public bool IsLooped
Expand All @@ -119,5 +121,6 @@ public Microsoft.Xna.Framework.Media.Video Video
return _video;
}
}

}
}
10 changes: 5 additions & 5 deletions MonoGame.Framework/Android/PowerStatus.cs
Expand Up @@ -48,7 +48,7 @@ namespace Microsoft.Xna.Framework
public static class PowerStatus
{
private static BroadcastReceiver _batteryStatusReceiver;
private static int _batteryStatus = BatteryManager.BatteryStatusUnknown;
private static BatteryStatus _batteryStatus = BatteryStatus.Unknown;
private static int _batteryLevel;
private static int _batteryLevelScale = 100;

Expand All @@ -64,7 +64,7 @@ public override void OnReceive(Context context, Intent intent)
{
_batteryLevel = intent.GetIntExtra("level", 0);
_batteryLevelScale = intent.GetIntExtra("scale", 100);
_batteryStatus = intent.GetIntExtra("status", BatteryManager.BatteryStatusUnknown);
_batteryStatus = (BatteryStatus)intent.GetIntExtra("status", (int)BatteryStatus.Unknown);
}
}

Expand All @@ -76,11 +76,11 @@ public static Microsoft.Xna.Framework.BatteryChargeStatus BatteryChargeStatus
{
switch (_batteryStatus)
{
case BatteryManager.BatteryStatusCharging:
case BatteryStatus.Charging:
return BatteryChargeStatus.Charging;
case BatteryManager.BatteryStatusFull:
case BatteryStatus.Full:
return BatteryChargeStatus.High;
case BatteryManager.BatteryStatusUnknown:
case BatteryStatus.Unknown:
return BatteryChargeStatus.Unknown;
default:
if (BatteryLifePercent >= 60.0f)
Expand Down

0 comments on commit 56afa04

Please sign in to comment.