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
mfigueirido committed Mar 5, 2024
2 parents 597629e + 35c028a commit 7820137
Show file tree
Hide file tree
Showing 98 changed files with 5,414 additions and 1,086 deletions.
2 changes: 1 addition & 1 deletion Engines/FlatRedBallXNA/FlatRedBall/FlatRedBallServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class SyntaxVersionAttribute : Attribute
public int Version;
}

[SyntaxVersion(Version=53)]
[SyntaxVersion(Version=54)]
public static partial class FlatRedBallServices
{
internal static SingleThreadSynchronizationContext singleThreadSynchronizationContext;
Expand Down
4 changes: 0 additions & 4 deletions Engines/FlatRedBallXNA/FlatRedBall/Gui/Cursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,6 @@ public Ray GetRay(Layer layer)
}


#region XML Docs
/// <summary>
/// Returns the Sprite the cursor is over giving preference to the closest Sprite to the Camera.
/// </summary>
Expand All @@ -1031,7 +1030,6 @@ public Ray GetRay(Layer layer)
/// </remarks>
/// <param name="spriteArray">The SpriteArray to search through.</param>
/// <returns>The Sprite that is found, or null if the cursor is not over any Sprites.</returns>
#endregion
public T GetSpriteOver<T>(IList<T> spriteArray) where T : ICursorSelectable, IAttachable
{
return GetSpriteOver(spriteArray, false);
Expand All @@ -1043,15 +1041,13 @@ public T GetSpriteOver<T>(IList<T> spriteArray, bool considerInactives) where T
return GetSpriteOver(spriteArray, considerInactives, false);
}

#region XML Docs
/// <summary>
/// Returns the Sprite the cursor is over giving preference to the closest Sprite to the Camera.
/// </summary>
/// <param name="spriteArray">The SpriteArray to search through.</param>
/// <param name="considerInactives">Whether inactive Sprites (Sprites with the .active variable set to false) are considered.</param>
/// <param name="skipFirst"></param>
/// <returns>The Sprite that is found, or null if the cursor is not over any Sprites.</returns>
#endregion
public T GetSpriteOver<T>(IList<T> spriteArray, bool considerInactives, bool skipFirst) where T : ICursorSelectable, IAttachable
{
double closestDistance = -1;
Expand Down
24 changes: 7 additions & 17 deletions Engines/FlatRedBallXNA/FlatRedBall/IO/FileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ static FileManager()

#endregion

#region Public Methods
#region Public Methods

#region Caching Methods
public static void CacheObject(object objectToCache, string fileName)
Expand Down Expand Up @@ -419,7 +419,6 @@ public static void DeleteFile(string fileName)
}


#region XML Docs
/// <summary>
/// Returns whether the file exists considering the relative directory.
/// </summary>
Expand All @@ -430,7 +429,6 @@ public static void DeleteFile(string fileName)
/// a project's content. Therefore this internally will use the preferred way of checking for files per platform.
/// iOS and Android use the TitleContainer.OpenStream method.
/// </remarks>
#endregion
public static bool FileExists(string fileName)
{
if (IsRelative(fileName))
Expand Down Expand Up @@ -507,7 +505,6 @@ public static bool FileExists(string fileName)
}


#if !WINDOWS_8
/// <summary>
/// Searches the passed directory and all subdirectories for the passed file.
/// </summary>
Expand Down Expand Up @@ -539,18 +536,15 @@ public static string FindFileInDirectory(string fileToFind, string directory)
return "";
}

#region XML Docs
/// <summary>
/// Searches the executable's director and all subdirectories for the passed file.
/// </summary>
/// <param name="fileToFind">The name of the file which may or may not include an extension.</param>
/// <returns>The full path of the first file found matching the name, or an empty string if none is found</returns>
#endregion
public static string FindFileInDirectory(string fileToFind)
{
return FindFileInDirectory(FileManager.RelativeDirectory);
}
#endif



Expand Down Expand Up @@ -668,7 +662,6 @@ public static byte[] GetByteArrayFromEmbeddedResource(Assembly assemblyContainin
return buffer;
}

#region XML Docs
/// <summary>
/// Returns the extension in a filename.
/// </summary>
Expand All @@ -684,7 +677,6 @@ public static byte[] GetByteArrayFromEmbeddedResource(Assembly assemblyContainin
/// </remarks>
/// <param name="fileName">The filename.</param>
/// <returns>Returns the extension or an empty string if no period is found in the filename.</returns>
#endregion
public static string GetExtension(string fileName)
{
if (fileName == null)
Expand Down Expand Up @@ -806,7 +798,7 @@ public static string GetDirectoryKeepRelative(string fileName)
}


#region GetAllFilesInDirectory
#region GetAllFilesInDirectory


/// <summary>
Expand Down Expand Up @@ -1035,7 +1027,6 @@ public static void InitializeUserFolder(string userName)



#region XML Docs
/// <summary>
/// Determines whether a particular file is a graphical file that can be loaded by the FRB Engine.
/// </summary>
Expand All @@ -1045,7 +1036,6 @@ public static void InitializeUserFolder(string userName)
/// </remarks>
/// <param name="fileToTest">The file name to test.</param>
/// <returns>Whether the file is a graphic file.</returns>
#endregion
public static bool IsGraphicFile(string fileToTest)
{

Expand Down Expand Up @@ -1149,7 +1139,7 @@ public static bool IsUrl(string fileName)
}


#region Make Absolute/Make Relative
#region Make Absolute/Make Relative

public static string MakeAbsolute(string pathToMakeAbsolute)
{
Expand Down Expand Up @@ -1243,7 +1233,7 @@ public static string MakeRelative(string pathToMakeRelative, string pathToMakeRe

}

#endregion
#endregion


/// <summary>
Expand Down Expand Up @@ -1750,7 +1740,7 @@ private static int GetDotDotSlashIndex(string fileNameToFix)
}


#region XML Methods
#region XML Methods

public static T XmlDeserialize<T>(string fileName)
{
Expand Down Expand Up @@ -2180,9 +2170,9 @@ private static XElement RemoveAllNamespaces(XElement xmlDocument)
return new XElement(xmlDocument.Name.LocalName, xmlDocument.Elements().Select(el => RemoveAllNamespaces(el)));
}

#endregion
#endregion

#endregion
#endregion

#region Internal Methods

Expand Down
4 changes: 0 additions & 4 deletions Engines/FlatRedBallXNA/FlatRedBall/Input/ICursorSelectable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@

namespace FlatRedBall.Input
{
#region XML Docs
/// <summary>
/// Defines an interface for objects which can be selectable by the cursor.
/// </summary>
#endregion
public interface ICursorSelectable : IPositionable, IReadOnlyScalable, IRotatable
{
#region XML Docs
/// <summary>
/// Whether the instance is currently selectable (active).
/// </summary>
#endregion
bool CursorSelectable { get; set;}
}
}
10 changes: 6 additions & 4 deletions Engines/FlatRedBallXNA/FlatRedBall/Sprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public partial class Sprite : PositionedObject, IAnimationChainAnimatable, IScal
#region Fields

/// <summary>
/// Whether the Sprite should be rotated to always face the camera.
/// Whether the Sprite should be rotated to always face the camera. If true, the Sprite will always face the camera. This is typically only used in 3D games with a camera that can rotate.
/// </summary>
public bool IsBillboarded;

Expand All @@ -72,8 +72,9 @@ public partial class Sprite : PositionedObject, IAnimationChainAnimatable, IScal
protected internal ColorOperation mColorOperation;
protected internal BlendOperation mBlendOperation;

// This used to only be on MonoDroid and WP7, but we need it on PC for premult alpha when using ColorOperation.Color.
// Protected internal to skip the property and speed things up a little.
// Individual color values used to only be on MonoDroid and WP7, but we need
// them on PC for premult alpha when using ColorOperation.Color.
// They are "protected internal" to skip property access and speed things up a little.
protected internal float mRed;
protected internal float mGreen;
protected internal float mBlue;
Expand Down Expand Up @@ -176,7 +177,7 @@ public partial class Sprite : PositionedObject, IAnimationChainAnimatable, IScal
#region IColorable

/// <summary>
/// Controls the Sprite's transparency.
/// Controls the Sprite's transparency. A value of 1 is fully opaque, a value of 0 is fully transprent.
/// </summary>
/// <remarks>
/// Alpha controls a Sprite's transparency. A completely opaque Sprite has an
Expand Down Expand Up @@ -1288,6 +1289,7 @@ public virtual bool Visible
}

#region ICursorSelectable
[Obsolete("This property exists to support (old) .scnx files. This should not be used in modern FRB projects.")]
public bool CursorSelectable
{
get { return mCursorSelectable; }
Expand Down
20 changes: 20 additions & 0 deletions Engines/FlatRedBallXNA/FlatRedBall/TimeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,21 @@ public static double CurrentScreenSecondsSince(double time)
return Screens.ScreenManager.CurrentScreen.PauseAdjustedSecondsSince(time);
}

/// <summary>
/// Returns a task which completes after the argument timespan has passed in screen time. This considers slow-motion and pausing.
/// </summary>
/// <param name="timeSpan">The amount of time to wait.</param>
/// <returns>A task which will complete when the arugment time passes.</returns>
public static Task Delay(TimeSpan timeSpan)
{
return DelaySeconds(timeSpan.TotalSeconds);
}

/// <summary>
/// Returns a task which completes after the argument seconds have passed in screen time. This considers slow-motion and pausing.
/// </summary>
/// <param name="seconds">The number of seconds to wait.</param>
/// <returns>The task which will complete when the argument time passes.</returns>
public static Task DelaySeconds(double seconds)
{
if(seconds <= 0)
Expand All @@ -609,6 +619,11 @@ public static Task DelaySeconds(double seconds)
return taskSource.Task;
}

/// <summary>
/// Returns a task which completes once the argument predicate is fulfilled. This is checked once per frame.
/// </summary>
/// <param name="predicate">The predicate to check for completion.</param>
/// <returns>The task which will complete when the predicate returns true.</returns>
public static Task DelayUntil(Func<bool> predicate)
{
if(predicate())
Expand All @@ -620,6 +635,11 @@ public static Task DelayUntil(Func<bool> predicate)
return taskSource.Task;
}

/// <summary>
/// Returns a task which completes after the argument number of frames have passed.
/// </summary>
/// <param name="frameCount">The number of frames to wait.</param>
/// <returns>That task which completes once the argument number of rames have passed.</returns>
public static Task DelayFrames(int frameCount)
{
if(frameCount <= 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ protected override void ReactToVisualChanged()
/// <param name="frbLayer">The FlatRedBall Layer to add the DialogBox to. If null, the dialog box will not be layered. This will attempt to use a Gum layer matching the FRB layer. This will automatically work if the Layer has been added through the FlatRedBall Editor.</param>
public void Show(string text, FlatRedBall.Graphics.Layer frbLayer = null)
{
base.Show(frbLayer);
showNextPageOnDismissedPage = true;
ShowInternal(text, forceImmediatePrint:false);
var pages = ConvertToPages(text);
Show(pages, frbLayer);
}

public void Show(IEnumerable<string> pages, FlatRedBall.Graphics.Layer frbLayer = null)
Expand Down Expand Up @@ -206,7 +205,7 @@ public async Task ShowAsync(IEnumerable<DialogPageTask> pageTasks, FlatRedBall.G
// have ShowDialog? Is it
// to match the ShowDialog
// from the base FrameworkElement?
// If so, what's the poinnt because
// If so, what's the point because
// this doesn't override the base parameters.
// It requires pages.
[Obsolete("Use ShowAsync")]
Expand Down Expand Up @@ -404,13 +403,15 @@ private string[] ConvertToPages(string text)
var withRemovedTags = BbCodeParser.RemoveTags(text, foundTagsWithNewlines);

var unlimitedLines = new List<string>();
var oldVerticalMode = this.coreTextObject.TextOverflowVerticalMode;
this.coreTextObject.TextOverflowVerticalMode = RenderingLibrary.Graphics.TextOverflowVerticalMode.SpillOver;
var oldVerticalMode = this.textComponent.TextOverflowVerticalMode;
this.textComponent.TextOverflowVerticalMode = RenderingLibrary.Graphics.TextOverflowVerticalMode.SpillOver;
coreTextObject.RawText = withRemovedTags;
coreTextObject.UpdateLines(unlimitedLines);

this.coreTextObject.TextOverflowVerticalMode = oldVerticalMode;
this.textComponent.TextOverflowVerticalMode = RenderingLibrary.Graphics.TextOverflowVerticalMode.TruncateLine;

this.textComponent.SetProperty("Text", withRemovedTags);
this.textComponent.TextOverflowVerticalMode = oldVerticalMode;

var limitedLines = coreTextObject.WrappedText;

Expand Down Expand Up @@ -442,7 +443,12 @@ private string[] ConvertToPages(string text)
{
toAppend = BbCodeParser.AddTags(toAppend, foundTagsWithoutNewlines, strippedTextCount);
}

strippedTextCount += sizeBeforeTags;
if(toAppend?.EndsWith(" ") == true)
{
toAppend = toAppend.Substring(0, toAppend.Length - 1);
}
stringBuilder.Append(toAppend + "\n");
absoluteLineNumber++;
}
Expand Down Expand Up @@ -531,6 +537,7 @@ public void Dismiss()
LastTimeDismissed = TimeManager.CurrentTime;
PageAdvanced?.Invoke(this, null);
FinishedShowing?.Invoke(this, null);
this.Pages.Clear();
IsFocused = false;
}

Expand Down
Loading

0 comments on commit 7820137

Please sign in to comment.