Skip to content

Commit

Permalink
Merge branch 'NetStandard' of https://github.com/vchelaru/FlatRedBall
Browse files Browse the repository at this point in the history
…into NetStandard
  • Loading branch information
vchelaru committed Mar 20, 2024
2 parents c699ed6 + e208167 commit 9b156ef
Show file tree
Hide file tree
Showing 43 changed files with 2,355 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,36 +97,36 @@ public Anim.AnimationChain ToAnimationChain(string contentManagerName, TimeMeasu
{
if (!string.IsNullOrEmpty(ParentFile))
{
#if !UWP && !DESKTOP_GL && !STANDARD && !IOS
FlatRedBall.Graphics.Animation.AnimationChain animationChain =
FlatRedBall.Graphics.Animation.AnimationChain.FromGif(
ParentFile, contentManagerName);

animationChain.Name = Name;

animationChain.ParentGifFileName = ParentFile;

if (animationChain.Count == this.Frames.Count)
{
for (int i = 0; i < animationChain.Count; i++)
{
animationChain[i].FlipHorizontal = Frames[i].FlipHorizontal;
animationChain[i].FlipVertical = Frames[i].FlipVertical;
animationChain[i].FrameLength = Frames[i].FrameLength;
animationChain[i].RelativeX = Frames[i].RelativeX;
animationChain[i].RelativeY = Frames[i].RelativeY;

animationChain[i].TopCoordinate = Frames[i].TopCoordinate;
animationChain[i].BottomCoordinate = Frames[i].BottomCoordinate;
animationChain[i].LeftCoordinate = Frames[i].LeftCoordinate;
animationChain[i].RightCoordinate = Frames[i].RightCoordinate;
}
}

return animationChain;
#else
// This code was written long ago to support GIF->AnimationChain. It's not used anymore
// but maybe it could be in the future. For now, we'll just throw an exception.

//FlatRedBall.Graphics.Animation.AnimationChain animationChain =
// FlatRedBall.Graphics.Animation.AnimationChain.FromGif(
// ParentFile, contentManagerName);

//animationChain.Name = Name;

//animationChain.ParentGifFileName = ParentFile;

//if (animationChain.Count == this.Frames.Count)
//{
// for (int i = 0; i < animationChain.Count; i++)
// {
// animationChain[i].FlipHorizontal = Frames[i].FlipHorizontal;
// animationChain[i].FlipVertical = Frames[i].FlipVertical;
// animationChain[i].FrameLength = Frames[i].FrameLength;
// animationChain[i].RelativeX = Frames[i].RelativeX;
// animationChain[i].RelativeY = Frames[i].RelativeY;

// animationChain[i].TopCoordinate = Frames[i].TopCoordinate;
// animationChain[i].BottomCoordinate = Frames[i].BottomCoordinate;
// animationChain[i].LeftCoordinate = Frames[i].LeftCoordinate;
// animationChain[i].RightCoordinate = Frames[i].RightCoordinate;
// }
//}

//return animationChain;
throw new NotImplementedException();
#endif
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions Engines/FlatRedBallXNA/FlatRedBall/Content/ContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,14 @@ public T LoadFromFile<T>(string assetName)

if (assetName.EndsWith("gif"))
{
#if UWP || DESKTOP_GL || STANDARD || IOS
throw new NotImplementedException();
#else
AnimationChainList acl = new AnimationChainList();
acl.Add(FlatRedBall.Graphics.Animation.AnimationChain.FromGif(assetName, this.mName));
acl[0].ParentGifFileName = assetName;
loadedAsset = acl;
#endif

// We used to support gif => AnimationChain but this is being
// dropped. It could be added in the future if needed.
//AnimationChainList acl = new AnimationChainList();
//acl.Add(FlatRedBall.Graphics.Animation.AnimationChain.FromGif(assetName, this.mName));
//acl[0].ParentGifFileName = assetName;
//loadedAsset = acl;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;

namespace FlatRedBall.ExtensionMethods
{
public static class EnumerableExtensionMethods
{
public static void AddRange<T>(this HashSet<T> hashSet, IEnumerable<T> enumerable)
{
foreach(var item in enumerable)
{
hashSet.Add(item);
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Entities\IDamageArea.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entities\IEntity.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entities\ITiledTileMetadata.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ExtensionMethods\EnumerableExtensionMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ExtensionMethods\FloatExtensionMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ExtensionMethods\PointExtensionMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ExtensionMethods\Vector2ExtensionMethods.cs" />
Expand Down Expand Up @@ -303,6 +304,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Utilities\SpriteSelectionOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\StringBuilderExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\StringFunctions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\TaskHelper.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Gui\Behaviors\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ public enum RangeType

#endregion

#region XML Docs
/// <summary>
/// An emitter is an invisible object which can create one or more Sprites at a specific
/// rate or on a method call.
/// </summary>
#endregion
[Obsolete("Emitters are no longer being maintained. This class is being kept around for old projects, but new FRB projects should create manual emitters or look for an alternative approach.")]
public class Emitter : PositionedObject, IEquatable<Emitter>, IReadOnlyScalable
{
#region Enums
Expand Down
59 changes: 6 additions & 53 deletions Engines/FlatRedBallXNA/FlatRedBall/IO/FileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define USE_ISOLATED_STORAGE
#endif

#if MONODROID || IOS || UWP
#if MONODROID || IOS || UWP || ANDROID
#define USES_DOT_SLASH_ABOLUTE_FILES
#endif

Expand Down Expand Up @@ -222,14 +222,11 @@ static public string RelativeDirectory
}
}

#if !UWP && !MONODROID && !WINDOWS_8


public static string StartupPath
{
get
{
#if IOS
#if IOS || ANDROID
return "./";
#elif FRB_RAW || DESKTOP_GL || STANDARD
return System.IO.Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location ) + "/";
Expand Down Expand Up @@ -299,7 +296,6 @@ public static string UserApplicationDataForThisApplication
}
}

#endif
#endregion

#region Methods
Expand Down Expand Up @@ -1511,7 +1507,7 @@ private static void SaveText(string stringToSave, string fileName, System.Text.E

fileName = FileManager.GetIsolatedStorageFileName(fileName);

#if WINDOWS_8 || IOS || UWP
#if WINDOWS_8 || IOS || UWP || ANDROID
throw new NotImplementedException();
#else
IsolatedStorageFileStream isfs = null;
Expand Down Expand Up @@ -1852,7 +1848,7 @@ public static Stream GetStreamForFile(string fileName, FileMode mode)
fileName = fileName.Substring(2);
}
Stream stream = null;
#if USES_DOT_SLASH_ABOLUTE_FILES && !IOS
#if USES_DOT_SLASH_ABOLUTE_FILES && !IOS && !ANDROID
// Silverlight and 360 don't like ./ at the start of the file name, but that's what we use to identify an absolute path
if (fileName.Length > 1 && fileName[0] == '.' && fileName[1] == '/')
fileName = fileName.Substring(2);
Expand Down Expand Up @@ -1919,22 +1915,7 @@ public static object BinaryDeserialize(Type type, string fileName)

ThrowExceptionIfFileDoesntExist(fileName);

#if MONODROID
// Cute, the 360 doesn't like ./ at the start of the file name.
if (fileName.Length > 1 && fileName[0] == '.' && fileName[1] == '/')
fileName = fileName.Substring(2);
#endif


#if MONODROID

var store = mIsolatedStorageFile;

using (var stream = GetStreamForFile(fileName))
{
throw new NotImplementedException();
}
#elif WINDOWS_8 || UWP || FNA || IOS
#if WINDOWS_8 || UWP || FNA || IOS || ANDROID
throw new NotImplementedException();
#else
using (FileStream stream = System.IO.File.OpenRead(fileName))
Expand All @@ -1958,14 +1939,6 @@ public static object XmlDeserialize(Type type, string fileName)

ThrowExceptionIfFileDoesntExist(fileName);

#if XBOX360
// Cute, the 360 doesn't like ./ at the start of the file name.
if (fileName.Length > 1 && fileName[0] == '.' && fileName[1] == '/')
fileName = fileName.Substring(2);

#endif


using (Stream stream = GetStreamForFile(fileName))
{
XmlSerializer serializer = GetXmlSerializer(type);
Expand Down Expand Up @@ -1994,38 +1967,18 @@ public static void BinarySerialize(Type type, object objectToSerialize, string f
if (FileManager.IsRelative(fileName))
fileName = FileManager.RelativeDirectory + fileName;

#if SILVERLIGHT || WINDOWS_PHONE || MONODROID
var store = mIsolatedStorageFile;

string directory = FileManager.GetDirectory(fileName);
if (!string.IsNullOrEmpty(directory) && !store.DirectoryExists(directory))
{
if (directory.EndsWith("/"))
{
// the trailing slash causes an exception to be thrown
directory = directory.Substring(0, directory.Length - 1);
}

store.CreateDirectory(directory);
}

fs = GetStreamForFile(fileName, FileMode.OpenOrCreate);

#endif
#if !MONODROID
string directory = FileManager.GetDirectory(fileName);

if (!string.IsNullOrEmpty(directory) && !Directory.Exists(FileManager.GetDirectory(fileName)))
{
Directory.CreateDirectory(FileManager.GetDirectory(fileName));
}

#endif


try
{
#if UWP || FNA || IOS
#if UWP || FNA || IOS || ANDROID
throw new NotImplementedException();
#else

Expand Down
16 changes: 8 additions & 8 deletions Engines/FlatRedBallXNA/FlatRedBall/Input/GenericGamePad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ public bool ButtonPushed(Xbox360GamePad.Button xboxButton)
{
switch(xboxButton)
{
case Button.X:
case Xbox360GamePad.Button.X:
return ButtonPushed(InputDeviceMap.XboxX);
case Button.Y:
case Xbox360GamePad.Button.Y:
return ButtonPushed(InputDeviceMap.XboxY);
case Button.A:
case Xbox360GamePad.Button.A:
return ButtonPushed(InputDeviceMap.XboxA);
case Button.B:
case Xbox360GamePad.Button.B:
return ButtonPushed(InputDeviceMap.XboxB);
}
return false;
Expand All @@ -336,13 +336,13 @@ public bool ButtonReleased(Xbox360GamePad.Button xboxButton)
{
switch (xboxButton)
{
case Button.X:
case Xbox360GamePad.Button.X:
return ButtonReleased(InputDeviceMap.XboxX);
case Button.Y:
case Xbox360GamePad.Button.Y:
return ButtonReleased(InputDeviceMap.XboxY);
case Button.A:
case Xbox360GamePad.Button.A:
return ButtonReleased(InputDeviceMap.XboxA);
case Button.B:
case Xbox360GamePad.Button.B:
return ButtonReleased(InputDeviceMap.XboxB);
}
return false;
Expand Down
26 changes: 26 additions & 0 deletions Engines/FlatRedBallXNA/FlatRedBall/Utilities/TaskHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace FlatRedBall.Utilities
{
public static class TaskHelper
{
public static async Task InSequence(params Func<Task>[] tasks)
{
foreach(var task in tasks)
{
await task();
}
}

public static async Task InSequence(params Task[] tasks)
{
foreach(var task in tasks)
{
await task;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-android</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants);FRB_XNA;ANDROID;MONOGAME;XNA4;MONOGAME_381</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>$(DefineConstants);FRB_XNA;ANDROID;MONOGAME;XNA4;MONOGAME_381</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\FlatRedBall\Input\Keyboard.Android.cs" Link="Input\Keyboard.Android.cs" />
<Compile Include="..\FlatRedBall\IO\FileManager.IsolatedStorage.cs" Link="IO\FileManager.IsolatedStorage.cs" />
</ItemGroup>

<ItemGroup>
<Folder Include="IO\" />
<Folder Include="Input\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Framework.Android" Version="3.8.1.303" />
</ItemGroup>

<Import Project="..\FlatRedBall\FlatRedBallShared.projitems" Label="Shared" />

</Project>
Loading

0 comments on commit 9b156ef

Please sign in to comment.