Skip to content

Commit

Permalink
New FRB Android engine now compiles!
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Mar 15, 2024
1 parent 2c4989d commit 4238930
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 99 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

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

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
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34607.119
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine", "Engine", "{F649B263-C76E-439E-AD3D-1A685871193B}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "FlatRedBallShared", "..\..\FlatRedBallXNA\FlatRedBall\FlatRedBallShared.shproj", "{0BB8CBE3-8503-46C1-9272-D98E153A230E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GumCore", "GumCore", "{3757E7DC-EDBA-4A7C-9846-DBBFDBB9DD12}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StateInterpolation", "StateInterpolation", "{27F64810-F98D-4965-8800-1BEFD8BADE25}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "StateInterpolationShared", "..\..\..\FRBDK\Glue\StateInterpolationPlugin\StateInterpolationPlugin\StateInterpolationShared.shproj", "{D00D287D-385B-42FB-BF5F-04401E7D37D0}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "GumCoreShared", "..\..\..\..\Gum\GumCoreShared.shproj", "{F919C045-EAC7-4806-9A1F-CE421F923E97}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "GumCoreShared.FlatRedBall", "..\..\..\FRBDK\Glue\GumPlugin\GumPlugin\GumCoreShared.FlatRedBall.shproj", "{0EE8A96C-A754-453D-9E65-19A24E9A5E76}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "FlatRedBall.Forms.Shared", "FlatRedBall.Forms.Shared\FlatRedBall.Forms.Shared.shproj", "{728151F0-03E0-4253-94FE-46B9C77EDEA6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{988B0672-8A1B-4A36-912D-91BC8BF4BE8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{988B0672-8A1B-4A36-912D-91BC8BF4BE8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{988B0672-8A1B-4A36-912D-91BC8BF4BE8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{988B0672-8A1B-4A36-912D-91BC8BF4BE8D}.Release|Any CPU.Build.0 = Release|Any CPU
{25D8F0AD-BC12-43D1-94CD-4B1F98DD91E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25D8F0AD-BC12-43D1-94CD-4B1F98DD91E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25D8F0AD-BC12-43D1-94CD-4B1F98DD91E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25D8F0AD-BC12-43D1-94CD-4B1F98DD91E6}.Release|Any CPU.Build.0 = Release|Any CPU
{D36F5561-18B2-44C5-98BA-0D54D395FC25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D36F5561-18B2-44C5-98BA-0D54D395FC25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D36F5561-18B2-44C5-98BA-0D54D395FC25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D36F5561-18B2-44C5-98BA-0D54D395FC25}.Release|Any CPU.Build.0 = Release|Any CPU
{48D1BF33-C315-41D0-A127-D0FEF2C7FFFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48D1BF33-C315-41D0-A127-D0FEF2C7FFFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48D1BF33-C315-41D0-A127-D0FEF2C7FFFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48D1BF33-C315-41D0-A127-D0FEF2C7FFFC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0BB8CBE3-8503-46C1-9272-D98E153A230E} = {F649B263-C76E-439E-AD3D-1A685871193B}
{988B0672-8A1B-4A36-912D-91BC8BF4BE8D} = {F649B263-C76E-439E-AD3D-1A685871193B}
{25D8F0AD-BC12-43D1-94CD-4B1F98DD91E6} = {27F64810-F98D-4965-8800-1BEFD8BADE25}
{D00D287D-385B-42FB-BF5F-04401E7D37D0} = {27F64810-F98D-4965-8800-1BEFD8BADE25}
{D36F5561-18B2-44C5-98BA-0D54D395FC25} = {3757E7DC-EDBA-4A7C-9846-DBBFDBB9DD12}
{F919C045-EAC7-4806-9A1F-CE421F923E97} = {3757E7DC-EDBA-4A7C-9846-DBBFDBB9DD12}
{0EE8A96C-A754-453D-9E65-19A24E9A5E76} = {3757E7DC-EDBA-4A7C-9846-DBBFDBB9DD12}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F29E3999-836A-4A12-A760-2BD6418FE592}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\..\FlatRedBallXNA\FlatRedBall\FlatRedBallShared.projitems*{0bb8cbe3-8503-46c1-9272-d98e153a230e}*SharedItemsImports = 13
..\..\..\FRBDK\Glue\GumPlugin\GumPlugin\GumCoreShared.FlatRedBall.projitems*{0ee8a96c-a754-453d-9e65-19a24e9a5e76}*SharedItemsImports = 13
..\..\..\FRBDK\Glue\StateInterpolationPlugin\StateInterpolationPlugin\StateInterpolationShared.projitems*{25d8f0ad-bc12-43d1-94cd-4b1f98dd91e6}*SharedItemsImports = 5
FlatRedBall.Forms.Shared\FlatRedBall.Forms.Shared.projitems*{48d1bf33-c315-41d0-a127-d0fef2c7fffc}*SharedItemsImports = 5
FlatRedBall.Forms.Shared\FlatRedBall.Forms.Shared.projitems*{728151f0-03e0-4253-94fe-46b9c77edea6}*SharedItemsImports = 13
..\..\FlatRedBallXNA\FlatRedBall\FlatRedBallShared.projitems*{988b0672-8a1b-4a36-912d-91bc8bf4be8d}*SharedItemsImports = 5
..\..\..\FRBDK\Glue\StateInterpolationPlugin\StateInterpolationPlugin\StateInterpolationShared.projitems*{d00d287d-385b-42fb-bf5f-04401e7d37d0}*SharedItemsImports = 13
..\..\..\FRBDK\Glue\GumPlugin\GumPlugin\GumCoreShared.FlatRedBall.projitems*{d36f5561-18b2-44c5-98ba-0d54d395fc25}*SharedItemsImports = 5
..\..\..\..\Gum\GumCoreShared.projitems*{d36f5561-18b2-44c5-98ba-0d54d395fc25}*SharedItemsImports = 5
..\..\..\..\Gum\GumCoreShared.projitems*{f919c045-eac7-4806-9a1f-ce421f923e97}*SharedItemsImports = 13
EndGlobalSection
EndGlobal
Loading

0 comments on commit 4238930

Please sign in to comment.