Fixed the StorageDevice and StorageContainer and native implementations

This commit is contained in:
SND\AstrorEnales_cp 2012-10-13 14:55:06 +00:00 committed by Konstantin Koch
parent 0b9acc40ee
commit 4fdad340d3
40 changed files with 339 additions and 288 deletions

View File

@ -116,7 +116,6 @@
<Folder Include="Strukturen\Content\MediaTypeReaders\" />
<Folder Include="Strukturen\Content\PrimitiveTypeReaders\" />
<Folder Include="Strukturen\Content\SystemTypeReaders\" />
<Folder Include="Strukturen\Design\GamerServices\" />
<Folder Include="Strukturen\Input\MotionSensing\" />
<Folder Include="Strukturen\Input\Touch\" />
<Folder Include="Strukturen\Net\" />

View File

@ -116,7 +116,6 @@
<Folder Include="Strukturen\Content\MediaTypeReaders\" />
<Folder Include="Strukturen\Content\PrimitiveTypeReaders\" />
<Folder Include="Strukturen\Content\SystemTypeReaders\" />
<Folder Include="Strukturen\Design\GamerServices\" />
<Folder Include="Strukturen\Input\MotionSensing\" />
<Folder Include="Strukturen\Input\Touch\" />
<Folder Include="Strukturen\Net\" />

View File

@ -117,7 +117,6 @@
<Folder Include="Strukturen\Content\MediaTypeReaders\" />
<Folder Include="Strukturen\Content\PrimitiveTypeReaders\" />
<Folder Include="Strukturen\Content\SystemTypeReaders\" />
<Folder Include="Strukturen\Design\GamerServices\" />
<Folder Include="Strukturen\Input\MotionSensing\" />
<Folder Include="Strukturen\Input\Touch\" />
<Folder Include="Strukturen\Net\" />

View File

@ -118,7 +118,6 @@
<Folder Include="Strukturen\Content\MediaTypeReaders\" />
<Folder Include="Strukturen\Content\PrimitiveTypeReaders\" />
<Folder Include="Strukturen\Content\SystemTypeReaders\" />
<Folder Include="Strukturen\Design\GamerServices\" />
<Folder Include="Strukturen\Input\MotionSensing\" />
<Folder Include="Strukturen\Input\Touch\" />
<Folder Include="Strukturen\Net\" />

View File

@ -11,6 +11,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public class ANXFieldDescriptor : PropertyDescriptor
{
private FieldInfo field;

View File

@ -11,6 +11,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public class ANXPropertyDescriptor : PropertyDescriptor
{
private PropertyInfo property;

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class BoundingBoxConverter : MathTypeConverter
{
public BoundingBoxConverter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class BoundingSphereConverter : MathTypeConverter
{
public BoundingSphereConverter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class ColorConverter : MathTypeConverter
{
public ColorConverter()

View File

@ -19,6 +19,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Untested)]
public class MathTypeConverter : ExpandableObjectConverter
{
protected PropertyDescriptorCollection propertyDescriptions;

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class MatrixConverter : MathTypeConverter
{
public MatrixConverter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class PlaneConverter : MathTypeConverter
{
public PlaneConverter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class PointConverter : MathTypeConverter
{
public PointConverter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class QuaternionConverter : MathTypeConverter
{
public QuaternionConverter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class RayConverter : MathTypeConverter
{
public RayConverter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class RectangleConverter : MathTypeConverter
{
public RectangleConverter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class Vector2Converter : MathTypeConverter
{
public Vector2Converter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class Vector3Converter : MathTypeConverter
{
public Vector3Converter()

View File

@ -12,6 +12,7 @@ namespace ANX.Framework.Design
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[Developer("GinieDP")]
[TestState(TestStateAttribute.TestState.Tested)]
public class Vector4Converter : MathTypeConverter
{
public Vector4Converter()

View File

@ -600,14 +600,8 @@ namespace ANX.Framework.Graphics
public Rectangle ScissorRectangle
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
get { return NativeDevice.ScissorRectangle; }
set { NativeDevice.ScissorRectangle = value; }
}
public GraphicsDeviceStatus GraphicsDeviceStatus

View File

@ -31,8 +31,8 @@ namespace ANX.Framework.Graphics
OneOverWidth = 1f / width;
OneOverHeight = 1f / height;
base.levelCount = 1;
base.format = SurfaceFormat.Color;
base.LevelCount = 1;
base.Format = SurfaceFormat.Color;
this.DepthStencilFormat = DepthFormat.None;
this.MultiSampleCount = 0;
@ -53,8 +53,8 @@ namespace ANX.Framework.Graphics
OneOverWidth = 1f / width;
OneOverHeight = 1f / height;
base.levelCount = 1;
base.format = preferredFormat;
base.LevelCount = 1;
base.Format = preferredFormat;
this.DepthStencilFormat = preferredDepthFormat;
this.MultiSampleCount = 0;
@ -76,8 +76,8 @@ namespace ANX.Framework.Graphics
OneOverWidth = 1f / width;
OneOverHeight = 1f / height;
base.levelCount = 1;
base.format = preferredFormat;
base.LevelCount = 1;
base.Format = preferredFormat;
this.DepthStencilFormat = preferredDepthFormat;
this.MultiSampleCount = preferredMultiSampleCount;

View File

@ -11,27 +11,12 @@ namespace ANX.Framework.Graphics
[TestState(TestStateAttribute.TestState.Untested)]
public abstract class Texture : GraphicsResource
{
protected internal int levelCount;
protected internal SurfaceFormat format;
protected internal INativeTexture nativeTexture;
internal INativeTexture nativeTexture;
public int LevelCount
{
get
{
return this.levelCount;
}
}
public int LevelCount { get; internal set; }
public SurfaceFormat Format { get; internal set; }
public SurfaceFormat Format
{
get
{
return this.format;
}
}
internal INativeTexture NativeTexture
internal INativeTexture NativeTexture
{
get
{
@ -44,7 +29,7 @@ namespace ANX.Framework.Graphics
}
}
public Texture(GraphicsDevice graphicsDevice)
internal Texture(GraphicsDevice graphicsDevice)
: base(graphicsDevice)
{
base.GraphicsDevice.ResourceCreated += GraphicsDevice_ResourceCreated;

View File

@ -75,8 +75,8 @@ namespace ANX.Framework.Graphics
OneOverWidth = 1f / width;
OneOverHeight = 1f / height;
base.levelCount = 1;
base.format = SurfaceFormat.Color;
base.LevelCount = 1;
base.Format = SurfaceFormat.Color;
CreateNativeTextureSurface();
}
@ -91,8 +91,8 @@ namespace ANX.Framework.Graphics
OneOverHeight = 1f / height;
// TODO: pass the mipmap parameter to the creation of the texture to let the graphics card generate mipmaps!
base.levelCount = 1;
base.format = format;
base.LevelCount = 1;
base.Format = format;
CreateNativeTextureSurface();
}
@ -105,8 +105,8 @@ namespace ANX.Framework.Graphics
OneOverWidth = 1f / width;
OneOverHeight = 1f / height;
base.levelCount = mipCount;
base.format = format;
base.LevelCount = mipCount;
base.Format = format;
CreateNativeTextureSurface();
}
@ -196,7 +196,7 @@ namespace ANX.Framework.Graphics
private void CreateNativeTextureSurface()
{
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
nativeTexture2D = creator.CreateTexture(GraphicsDevice, format, width, height, levelCount);
nativeTexture2D = creator.CreateTexture(GraphicsDevice, Format, width, height, LevelCount);
base.nativeTexture = nativeTexture2D;
}
#endregion

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
public struct VertexBufferBinding
{
#region Private

View File

@ -1,5 +1,4 @@
using System;
using ANX.Framework.Storage;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,21 +8,11 @@ namespace ANX.Framework.NonXNA.PlatformSystem
{
public interface INativeStorageDevice
{
long FreeSpace
{
get;
}
long FreeSpace { get; }
long TotalSpace { get; }
bool IsConnected { get; }
string StoragePath { get; }
long TotalSpace
{
get;
}
bool IsConnected
{
get;
}
void DeleteContainer(string titleName);
void DeleteContainer(string titleName);
}
}

View File

@ -47,5 +47,6 @@ namespace ANX.Framework.NonXNA
void ResizeBuffers(PresentationParameters presentationParameters);
bool VSync { get; set; }
Rectangle ScissorRectangle { get; set; }
}
}

View File

@ -9,6 +9,7 @@ using ANX.Framework.NonXNA.PlatformSystem;
namespace ANX.Framework.Storage
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public class StorageContainer : IDisposable
@ -18,17 +19,17 @@ namespace ANX.Framework.Storage
#region Public
public event EventHandler<EventArgs> Disposing;
public string DisplayName { get; protected set; }
public StorageDevice StorageDevice { get; protected set; }
public bool IsDisposed { get; protected set; }
public string DisplayName { get; private set; }
public StorageDevice StorageDevice { get; private set; }
public bool IsDisposed { get; private set; }
internal PlayerIndex PlayerIndex { get; private set; }
#endregion
internal StorageContainer(StorageDevice device, PlayerIndex player, string displayName)
{
StorageDevice = device;
DisplayName = displayName;
// TODO: player!
PlayerIndex = player;
nativeImplementation = PlatformSystem.Instance.CreateStorageContainer(this);
}
@ -98,8 +99,7 @@ namespace ANX.Framework.Storage
return OpenFile(file, fileMode, fileAccess, FileShare.None);
}
public Stream OpenFile(string file, FileMode fileMode, FileAccess fileAccess,
FileShare fileShare)
public Stream OpenFile(string file, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
{
return nativeImplementation.OpenFile(file, fileMode, fileAccess, fileShare);
}

View File

@ -9,15 +9,17 @@ using ANX.Framework.NonXNA.PlatformSystem;
namespace ANX.Framework.Storage
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class StorageDevice
{
#region Private
private INativeStorageDevice nativeImplementation;
#region Private
private readonly PlayerIndex playerIndex;
private readonly INativeStorageDevice nativeImplementation;
private static Func<PlayerIndex, int, int, StorageDevice> openDeviceDelegate = null;
private Func<string, StorageContainer> openContainerDelegate = null;
private static Func<PlayerIndex, int, int, StorageDevice> openDeviceDelegate;
private Func<string, StorageContainer> openContainerDelegate;
#endregion
#region Public
@ -25,57 +27,40 @@ namespace ANX.Framework.Storage
public static event EventHandler<EventArgs> DeviceChanged;
#pragma warning restore 0067
public long FreeSpace
{
get
{
return nativeImplementation.FreeSpace;
}
}
public long FreeSpace
{
get { return nativeImplementation.FreeSpace; }
}
public bool IsConnected
{
get
{
return nativeImplementation.IsConnected;
}
}
public bool IsConnected
{
get { return nativeImplementation.IsConnected; }
}
public long TotalSpace
{
get
{
return nativeImplementation.TotalSpace;
}
}
public long TotalSpace
{
get { return nativeImplementation.TotalSpace; }
}
internal string StoragePath
{
get;
private set;
}
internal PlayerIndex PlayerIndex
{
get;
private set;
}
#endregion
internal string StoragePath
{
get { return nativeImplementation.StoragePath; }
}
#endregion
#region Constructor
internal StorageDevice(PlayerIndex player, int sizeInBytes, int directoryCount)
{
playerIndex = player;
nativeImplementation = PlatformSystem.Instance.CreateStorageDevice(this, player, sizeInBytes, directoryCount);
}
#endregion
#region BeginOpenContainer
public IAsyncResult BeginOpenContainer(string displayName,
AsyncCallback callback, Object state)
public IAsyncResult BeginOpenContainer(string displayName, AsyncCallback callback, Object state)
{
if (openContainerDelegate != null)
throw new InvalidOperationException(
"There is currently a StorageContainer request pending. " +
throw new InvalidOperationException("There is currently a StorageContainer request pending. " +
"Please let this request finish.");
openContainerDelegate = OpenStorageContainer;
@ -88,35 +73,26 @@ namespace ANX.Framework.Storage
{
return BeginShowSelector(PlayerIndex.One, 0, 0, callback, state);
}
#endregion
#region BeginShowSelector
public static IAsyncResult BeginShowSelector(int sizeInBytes, int directoryCount,
AsyncCallback callback, Object state)
public static IAsyncResult BeginShowSelector(int sizeInBytes, int directoryCount, AsyncCallback callback, Object state)
{
return BeginShowSelector(PlayerIndex.One, sizeInBytes, directoryCount,
callback, state);
return BeginShowSelector(PlayerIndex.One, sizeInBytes, directoryCount, callback, state);
}
#endregion
#region BeginShowSelector
public static IAsyncResult BeginShowSelector(PlayerIndex player,
AsyncCallback callback, Object state)
public static IAsyncResult BeginShowSelector(PlayerIndex player, AsyncCallback callback, Object state)
{
return BeginShowSelector(player, 0, 0, callback, state);
}
#endregion
#region BeginShowSelector
public static IAsyncResult BeginShowSelector(PlayerIndex player,
int sizeInBytes, int directoryCount, AsyncCallback callback, Object state)
public static IAsyncResult BeginShowSelector(PlayerIndex player, int sizeInBytes, int directoryCount,
AsyncCallback callback, Object state)
{
if (openDeviceDelegate != null)
throw new InvalidOperationException("There is currently a StorageDevice request pending. Please let this request finish.");
throw new InvalidOperationException(
"There is currently a StorageDevice request pending. Please let this request finish.");
openDeviceDelegate = OpenStorageDevice;
return openDeviceDelegate.BeginInvoke(player, sizeInBytes, directoryCount,
callback, state);
return openDeviceDelegate.BeginInvoke(player, sizeInBytes, directoryCount, callback, state);
}
#endregion
@ -162,8 +138,7 @@ namespace ANX.Framework.Storage
#endregion
#region OpenStorageDevice
private static StorageDevice OpenStorageDevice(PlayerIndex player,
int sizeInBytes, int directoryCount)
private static StorageDevice OpenStorageDevice(PlayerIndex player, int sizeInBytes, int directoryCount)
{
return new StorageDevice(player, sizeInBytes, directoryCount);
}
@ -172,7 +147,7 @@ namespace ANX.Framework.Storage
#region OpenStorageContainer
private StorageContainer OpenStorageContainer(string displayName)
{
return new StorageContainer(this, PlayerIndex, displayName);
return new StorageContainer(this, playerIndex, displayName);
}
#endregion
}

View File

@ -12,6 +12,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Storage
{
[PercentageComplete(95)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public class StorageDeviceNotConnectedException : ExternalException

View File

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using ANX.Framework;
using ANX.Framework.NonXNA.PlatformSystem;
using ANX.Framework.Storage;
@ -12,21 +14,56 @@ namespace ANX.PlatformSystem.Linux
{
public class LinuxStorageContainer : INativeStorageContainer
{
private StorageContainer parent;
private DirectoryInfo baseDirectory;
private readonly StorageContainer parent;
private readonly DirectoryInfo baseDirectory;
public LinuxStorageContainer(StorageContainer setParent)
{
parent = setParent;
string fullPath = Path.Combine(parent.StorageDevice.StoragePath,
parent.DisplayName);
baseDirectory = new DirectoryInfo(fullPath);
baseDirectory = new DirectoryInfo(GetDirectoryForContainer());
// fails silently if directory exists
baseDirectory.Create();
}
#region CreateDirectory
private string GetDirectoryForContainer()
{
// TODO: check if Environment.GetFolderPath returns something useful under linux!
string result = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "SavedGames");
result = Path.Combine(result, GetGameTitle());
result = Path.Combine(result, parent.DisplayName);
string playerSubDir;
switch (parent.PlayerIndex)
{
case PlayerIndex.One:
playerSubDir = "Player1";
break;
case PlayerIndex.Two:
playerSubDir = "Player2";
break;
case PlayerIndex.Three:
playerSubDir = "Player3";
break;
case PlayerIndex.Four:
playerSubDir = "Player4";
break;
default:
playerSubDir = "AllPlayers";
break;
}
return Path.Combine(result, playerSubDir);
}
private static string GetGameTitle()
{
var entryAssembly = Assembly.GetEntryAssembly();
if (entryAssembly != null)
return Path.GetFileNameWithoutExtension(entryAssembly.Location);
throw new InvalidOperationException();
}
#region CreateDirectory
public void CreateDirectory(string directory)
{
baseDirectory.CreateSubdirectory(directory);

View File

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Reflection;
using ANX.Framework;
using ANX.Framework.NonXNA.PlatformSystem;
using ANX.Framework.Storage;
@ -15,9 +16,8 @@ namespace ANX.PlatformSystem.Linux
/// </summary>
public class LinuxStorageDevice : INativeStorageDevice
{
private string storagePath;
private StorageDevice parent;
private DriveInfo storageDrive;
private readonly StorageDevice parent;
private readonly DriveInfo storageDrive;
#region Public
public long FreeSpace
@ -50,55 +50,62 @@ namespace ANX.PlatformSystem.Linux
}
}
public bool IsConnected
public bool IsConnected
{
get { return storageDrive.IsReady; }
}
public string StoragePath { get; private set; }
#endregion
public LinuxStorageDevice(StorageDevice setParent, PlayerIndex player, int sizeInBytes, int directoryCount)
{
get
{
return storageDrive.IsReady;
}
}
#endregion
parent = setParent;
StoragePath = GetDirectoryForContainer(player);
storageDrive = new DriveInfo(Path.GetPathRoot(StoragePath).Substring(0, 1));
}
#region Constructor
public LinuxStorageDevice(StorageDevice setParent, PlayerIndex player,
int sizeInBytes, int directoryCount)
{
parent = setParent;
private string GetDirectoryForContainer(PlayerIndex player)
{
// TODO: check if Environment.GetFolderPath returns something useful under linux!
string result = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "SavedGames");
result = Path.Combine(result, GetGameTitle());
//result = Path.Combine(result, StorageContainer.DisplayName);
string playerSubDir;
switch (player)
{
case PlayerIndex.One:
playerSubDir = "Player1";
break;
case PlayerIndex.Two:
playerSubDir = "Player2";
break;
case PlayerIndex.Three:
playerSubDir = "Player3";
break;
case PlayerIndex.Four:
playerSubDir = "Player4";
break;
default:
playerSubDir = "AllPlayers";
break;
}
string playerPath;
switch (player)
{
case PlayerIndex.One:
playerPath = "Player1";
break;
case PlayerIndex.Two:
playerPath = "Player2";
break;
case PlayerIndex.Three:
playerPath = "Player3";
break;
case PlayerIndex.Four:
playerPath = "Player4";
break;
default:
playerPath = "AllPlayers";
break;
}
return Path.Combine(result, playerSubDir);
}
// TODO: find the correct linux location for this stuff!
string myDocsPath = Environment.GetFolderPath(
Environment.SpecialFolder.MyDocuments);
storagePath = Path.Combine(myDocsPath, "SavedGames", playerPath);
storagePath = Path.GetFullPath(storagePath);
storageDrive = new DriveInfo(Path.GetPathRoot(myDocsPath).Substring(0, 1));
}
#endregion
private static string GetGameTitle()
{
var entryAssembly = Assembly.GetEntryAssembly();
if (entryAssembly != null)
return Path.GetFileNameWithoutExtension(entryAssembly.Location);
throw new InvalidOperationException();
}
#region DeleteContainer
public void DeleteContainer(string titleName)
{
Directory.Delete(Path.Combine(parent.StoragePath, titleName), true);
}
#endregion
}
}

View File

@ -33,9 +33,14 @@ namespace ANX.PlatformSystem.Metro
}
}
public string StoragePath
{
get { throw new NotImplementedException(); }
}
public void DeleteContainer(string titleName)
{
throw new NotImplementedException();
}
}
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Reflection;
using ANX.Framework;
using ANX.Framework.NonXNA.PlatformSystem;
using ANX.Framework.Storage;
@ -12,9 +13,8 @@ namespace ANX.PlatformSystem.PsVita
{
public class PsVitaStorageDevice : INativeStorageDevice
{
private string storagePath;
private StorageDevice parent;
private DriveInfo storageDrive;
private readonly StorageDevice parent;
private readonly DriveInfo storageDrive;
#region Public
public long FreeSpace
@ -47,55 +47,61 @@ namespace ANX.PlatformSystem.PsVita
}
}
public bool IsConnected
public bool IsConnected
{
get { return storageDrive.IsReady; }
}
public string StoragePath { get; private set; }
#endregion
public PsVitaStorageDevice(StorageDevice setParent, PlayerIndex player, int sizeInBytes, int directoryCount)
{
get
{
return storageDrive.IsReady;
}
}
#endregion
parent = setParent;
StoragePath = GetDirectoryForContainer(player);
storageDrive = new DriveInfo(Path.GetPathRoot(StoragePath).Substring(0, 1));
}
#region Constructor
public PsVitaStorageDevice(StorageDevice setParent, PlayerIndex player,
int sizeInBytes, int directoryCount)
{
parent = setParent;
private string GetDirectoryForContainer(PlayerIndex player)
{
string result = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "SavedGames");
result = Path.Combine(result, GetGameTitle());
//result = Path.Combine(result, StorageContainer.DisplayName);
string playerSubDir;
switch (player)
{
case PlayerIndex.One:
playerSubDir = "Player1";
break;
case PlayerIndex.Two:
playerSubDir = "Player2";
break;
case PlayerIndex.Three:
playerSubDir = "Player3";
break;
case PlayerIndex.Four:
playerSubDir = "Player4";
break;
default:
playerSubDir = "AllPlayers";
break;
}
string playerPath;
switch (player)
{
case PlayerIndex.One:
playerPath = "Player1";
break;
case PlayerIndex.Two:
playerPath = "Player2";
break;
case PlayerIndex.Three:
playerPath = "Player3";
break;
case PlayerIndex.Four:
playerPath = "Player4";
break;
default:
playerPath = "AllPlayers";
break;
}
return Path.Combine(result, playerSubDir);
}
// TODO: find the correct PsVita location for this stuff!
string myDocsPath = Environment.GetFolderPath(
Environment.SpecialFolder.MyDocuments);
storagePath = Path.Combine(myDocsPath, "SavedGames", playerPath);
storagePath = Path.GetFullPath(storagePath);
storageDrive = new DriveInfo(Path.GetPathRoot(myDocsPath).Substring(0, 1));
}
#endregion
private static string GetGameTitle()
{
var entryAssembly = Assembly.GetEntryAssembly();
if (entryAssembly != null)
return Path.GetFileNameWithoutExtension(entryAssembly.Location);
throw new InvalidOperationException();
}
#region DeleteContainer
public void DeleteContainer(string titleName)
{
Directory.Delete(Path.Combine(parent.StoragePath, titleName), true);
}
#endregion
}
}

View File

@ -12,19 +12,16 @@ namespace ANX.PlatformSystem.Windows
{
public class WindowsStorageContainer : INativeStorageContainer
{
private StorageContainer parent;
private DirectoryInfo baseDirectory;
private readonly StorageContainer parent;
private readonly DirectoryInfo baseDirectory;
public WindowsStorageContainer(StorageContainer setParent)
{
parent = setParent;
string fullPath = Path.Combine(parent.StorageDevice.StoragePath,
parent.DisplayName);
baseDirectory = new DirectoryInfo(fullPath);
baseDirectory = new DirectoryInfo(parent.StorageDevice.StoragePath);
// fails silently if directory exists
baseDirectory.Create();
}
}
#region CreateDirectory
public void CreateDirectory(string directory)

View File

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Reflection;
using ANX.Framework;
using ANX.Framework.NonXNA.PlatformSystem;
using ANX.Framework.Storage;
@ -12,9 +13,8 @@ namespace ANX.PlatformSystem.Windows
{
public class WindowsStorageDevice : INativeStorageDevice
{
private string storagePath;
private StorageDevice parent;
private DriveInfo storageDrive;
private readonly StorageDevice parent;
private readonly DriveInfo storageDrive;
#region Public
public long FreeSpace
@ -47,54 +47,61 @@ namespace ANX.PlatformSystem.Windows
}
}
public bool IsConnected
{
get
{
return storageDrive.IsReady;
}
}
#endregion
public bool IsConnected
{
get { return storageDrive.IsReady; }
}
#region Constructor
public WindowsStorageDevice(StorageDevice setParent, PlayerIndex player,
int sizeInBytes, int directoryCount)
public string StoragePath { get; private set; }
#endregion
public WindowsStorageDevice(StorageDevice setParent, PlayerIndex player, int sizeInBytes, int directoryCount)
{
parent = setParent;
string playerPath;
switch (player)
{
case PlayerIndex.One:
playerPath = "Player1";
break;
case PlayerIndex.Two:
playerPath = "Player2";
break;
case PlayerIndex.Three:
playerPath = "Player3";
break;
case PlayerIndex.Four:
playerPath = "Player4";
break;
default:
playerPath = "AllPlayers";
break;
}
string myDocsPath = Environment.GetFolderPath(
Environment.SpecialFolder.MyDocuments);
storagePath = Path.Combine(myDocsPath, "SavedGames", playerPath);
storagePath = Path.GetFullPath(storagePath);
storageDrive = new DriveInfo(Path.GetPathRoot(myDocsPath).Substring(0, 1));
StoragePath = GetDirectoryForContainer(player);
storageDrive = new DriveInfo(Path.GetPathRoot(StoragePath).Substring(0, 1));
}
#endregion
#region DeleteContainer
private string GetDirectoryForContainer(PlayerIndex player)
{
string result = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "SavedGames");
result = Path.Combine(result, GetGameTitle());
//result = Path.Combine(result, StorageContainer.DisplayName);
string playerSubDir;
switch (player)
{
case PlayerIndex.One:
playerSubDir = "Player1";
break;
case PlayerIndex.Two:
playerSubDir = "Player2";
break;
case PlayerIndex.Three:
playerSubDir = "Player3";
break;
case PlayerIndex.Four:
playerSubDir = "Player4";
break;
default:
playerSubDir = "AllPlayers";
break;
}
return Path.Combine(result, playerSubDir);
}
private static string GetGameTitle()
{
var entryAssembly = Assembly.GetEntryAssembly();
if (entryAssembly != null)
return Path.GetFileNameWithoutExtension(entryAssembly.Location);
throw new InvalidOperationException();
}
public void DeleteContainer(string titleName)
{
Directory.Delete(Path.Combine(parent.StoragePath, titleName), true);
}
#endregion
}
}
}

View File

@ -53,6 +53,18 @@ namespace ANX.RenderSystem.GL3
get { return nativeContext.VSync; }
set { nativeContext.VSync = value; }
}
public Rectangle ScissorRectangle
{
get
{
// TODO: test
var boxParams = new int[4];
GL.GetInteger(GetPName.ScissorBox, boxParams);
return new Rectangle(boxParams[0], boxParams[1], boxParams[2], boxParams[3]);
}
set { GL.Scissor(value.X, value.Y, value.Width, value.Height); }
}
#endregion
#region Constructor

View File

@ -29,17 +29,22 @@ namespace ANX.RenderSystem.PsVita
#endregion
#region Public
public bool VSync
{
get
{
return true;
}
set
{
}
}
#endregion
public bool VSync
{
get { return true; }
set { }
}
public Rectangle ScissorRectangle
{
get
{
var rect = NativeContext.GetScissor();
return new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
}
set { NativeContext.SetScissor(value.X, value.Y, value.Width, value.Height); }
}
#endregion
#region Constructor
public PsVitaGraphicsDevice(PresentationParameters presentationParameters)

View File

@ -613,5 +613,11 @@ namespace ANX.RenderSystem.Windows.DX10
return this.nativeDevice;
}
}
}
public Rectangle ScissorRectangle
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
}
}

View File

@ -628,5 +628,11 @@ namespace ANX.RenderSystem.Windows.DX11
return this.nativeDevice;
}
}
public Rectangle ScissorRectangle
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
}
}

View File

@ -44,6 +44,12 @@ namespace ANX.RenderSystem.Windows.Metro
this.vSyncEnabled = value;
}
}
public Rectangle ScissorRectangle
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
#endregion
#region Constructor