Skip to content

Commit

Permalink
Gum codegen methods now try multiple times to avoid a possible except…
Browse files Browse the repository at this point in the history
…ion.

Added ToastManager documentations.
  • Loading branch information
vchelaru committed Nov 25, 2023
1 parent 086900b commit ab3da82
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ToastInfo

/// <summary>
/// Object responsible for manging the lifecycle of toasts. This can be used to perform fire-and-forget showing of Toast objects.
/// Internally this creates a Toast object using the FlatRedBall.Forms Toast control.
/// </summary>
public static class ToastManager
{
Expand All @@ -39,8 +40,6 @@ public static class ToastManager
public static Layer DefaultToastLayer { get; set; }
static IList liveToasts;
static bool hasBeenStarted;
#if !UWP
// threading works differently in UWP. do we care? Is UWP going to live?

static void Start()
{
Expand All @@ -59,13 +58,18 @@ static void Start()
thread.Start();
}
}
#endif

/// <summary>
/// Queues a toast to be shown for the given duration. This method can be called from any thread.
/// If a toast is currently shown, then this message is queued and will be shown on the next toast.
/// </summary>
/// <param name="message">The message to display</param>
/// <param name="frbLayer">The layer for the Toast instance.</param>
/// <param name="durationInSeconds">The number of seconds to display the toast.</param>
public static void Show(string message, Layer frbLayer = null, double durationInSeconds = 2.0)
{
if(!hasBeenStarted)
{
#if !UWP
if(FlatRedBallServices.IsThreadPrimary())
{
Start();
Expand All @@ -74,14 +78,16 @@ public static void Show(string message, Layer frbLayer = null, double durationIn
{
Instructions.InstructionManager.AddSafe(Start);
}
#endif
}

var toastInfo = new ToastInfo { Message = message, FrbLayer = frbLayer, DurationInSeconds = durationInSeconds};

toastMessages.Add(toastInfo);
}

/// <summary>
/// Removes all live toasts from all managers. This is called automatically when a Screen is destroyed.
/// </summary>
public static void DestroyLiveToasts()
{
int numberOfToastsToClean = liveToasts?.Count ?? 0;
Expand Down
35 changes: 19 additions & 16 deletions FRBDK/Glue/GumPlugin/GumPlugin/Managers/EventExportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,29 @@ await TaskManager.Self.AddAsync(async () =>
{
if(oldCodeFileName.Exists())
{
System.IO.File.Copy(oldCodeFileName.FullPath, newCodeFileName.FullPath, overwrite: true);
GlueCommands.Self.TryMultipleTimes(() =>
{
System.IO.File.Copy(oldCodeFileName.FullPath, newCodeFileName.FullPath, overwrite: true);
var contents = System.IO.File.ReadAllText(newCodeFileName.FullPath);
RefactorManager.Self.RenameClassInCode(
oldCodeFileName.NoPathNoExtension,
newCodeFileName.NoPathNoExtension,
ref contents);
var contents = System.IO.File.ReadAllText(newCodeFileName.FullPath);
RefactorManager.Self.RenameClassInCode(
oldCodeFileName.NoPathNoExtension,
newCodeFileName.NoPathNoExtension,
ref contents);
var oldNamespace = GueDerivingClassCodeGenerator.Self.GetFullRuntimeNamespaceFor(false, exportedEvent.OldName);
var newNamespace = GueDerivingClassCodeGenerator.Self.GetFullRuntimeNamespaceFor(false, exportedEvent.NewName);
var oldNamespace = GueDerivingClassCodeGenerator.Self.GetFullRuntimeNamespaceFor(false, exportedEvent.OldName);
var newNamespace = GueDerivingClassCodeGenerator.Self.GetFullRuntimeNamespaceFor(false, exportedEvent.NewName);
if(oldNamespace != newNamespace)
{
RefactorManager.Self.RenameNamespaceInCode(
oldNamespace,
newNamespace,
ref contents);
}
if (oldNamespace != newNamespace)
{
RefactorManager.Self.RenameNamespaceInCode(
oldNamespace,
newNamespace,
ref contents);
}
System.IO.File.WriteAllText(newCodeFileName.FullPath, contents);
System.IO.File.WriteAllText(newCodeFileName.FullPath, contents);
});
await GlueCommands.Self.ProjectCommands.TryAddCodeFileToProjectAsync(newCodeFileName, saveOnAdd:true);
}
Expand Down

0 comments on commit ab3da82

Please sign in to comment.