Skip to content

Commit

Permalink
More fixes to drag+drop
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Apr 13, 2024
1 parent 9ae2c7a commit 542732c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions FRBDK/Glue/CompilerPlugin/CompilerPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ private void AssignControlEvents()
if (response.Succeeded)
{
_runner.IsRunning = false;
await _runner.Run(preventFocus: false);
_runner.Run(preventFocus: false);
}
else
{
var runAnywayMessage = "Your project has content errors. To fix them, see the Errors tab. You can still run the game but you may experience crashes. Run anyway?";
var innerResult = GlueCommands.Self.DialogCommands.ShowYesNoMessageBox(runAnywayMessage);
if(innerResult == System.Windows.MessageBoxResult.Yes)
{
await _runner.Run(preventFocus: false);
_runner.Run(preventFocus: false);
}
}
};
Expand Down
20 changes: 9 additions & 11 deletions FRBDK/Glue/CompilerPlugin/Managers/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ internal async Task<GeneralResponse> Run(bool preventFocus, string runArguments
{
runArguments += " LaunchedByEditor";
}
startResponse = await StartProcess(preventFocus, runArguments, exeLocation);
startResponse = StartProcess(preventFocus, runArguments, exeLocation);

if (startResponse.Succeeded)
{
Expand All @@ -328,8 +328,7 @@ internal async Task<GeneralResponse> Run(bool preventFocus, string runArguments
while (runningGameProcess == null)
{
// didn't find it, so let's wait a little and try again:

await Task.Delay(millisecondsToWaitBeforeRetry);
Thread.Sleep(millisecondsToWaitBeforeRetry);

runningGameProcess = TryFindGameProcess();

Expand All @@ -356,8 +355,7 @@ internal async Task<GeneralResponse> Run(bool preventFocus, string runArguments

if (id == null || id == IntPtr.Zero)
{

await Task.Delay(millisecondsToWaitBeforeRetry);
Thread.Sleep(millisecondsToWaitBeforeRetry);
continue;
}
else
Expand Down Expand Up @@ -399,7 +397,7 @@ internal async Task<GeneralResponse> Run(bool preventFocus, string runArguments
{
if (startResponse.Data.HasExited && startResponse.Data.ExitCode != 0)
{
var message = await GetCrashMessage();
var message = GetCrashMessage();

if (!string.IsNullOrEmpty(message))
{
Expand Down Expand Up @@ -471,7 +469,7 @@ private static string GetGameExeLocation(string configuration)
}
}

private async Task<ToolsUtilities.GeneralResponse<Process>> StartProcess(bool preventFocus, string runArguments, string exeLocation)
private ToolsUtilities.GeneralResponse<Process> StartProcess(bool preventFocus, string runArguments, string exeLocation)
{
if (preventFocus)
{
Expand Down Expand Up @@ -504,7 +502,7 @@ private static string GetGameExeLocation(string configuration)
if (hasExited && process?.ExitCode != 0)
{

var message = await GetCrashMessage();
var message = GetCrashMessage();
var response = ToolsUtilities.GeneralResponse<Process>.UnsuccessfulWith(message);
response.Data = process;
return response;
Expand Down Expand Up @@ -549,7 +547,7 @@ private async void HandleProcessExit(object sender, EventArgs e)
{
if (process.ExitCode != 0)
{
string message = await GetCrashMessage();
string message = GetCrashMessage();
if (!string.IsNullOrEmpty(message))
{
System.Windows.MessageBox.Show(message);
Expand Down Expand Up @@ -580,15 +578,15 @@ private async void HandleProcessExit(object sender, EventArgs e)
}
}

private async Task<string> GetCrashMessage()
private string GetCrashMessage()
{
string exeLocation = GetGameExeLocation(this._compilerViewModel.Configuration);

string message = string.Empty;
if (!string.IsNullOrEmpty(exeLocation))
{
// await a little to see if the crash.txt file gets written...
await Task.Delay(2);
Thread.Sleep(3);

var directory = FileManager.GetDirectory(exeLocation);
var logFile = directory + "CrashInfo.txt";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ internal async Task HandleNewObjectList(List<NamedObjectSave> newObjectList)
{
CreateStopAndRestartTask("Restarting because the add object group failed");
}
// else do we want to position based on camera? This is likely a copy/paste so...maybe not?
}
}

Expand Down
1 change: 1 addition & 0 deletions FRBDK/Glue/Glue/GlueFormsCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@

<!--<PackageReference Include="Microsoft.Build.Locator" Version="1.5.5" />-->
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
<PackageReference Include="ParallelExtensionsExtras.CrossPlatform" Version="1.0.0" />
<PackageReference Include="PropertyTools.Wpf" Version="3.1.0" />
Expand Down
5 changes: 4 additions & 1 deletion FRBDK/Glue/Glue/Plugins/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,10 @@ public static Task ReactToNewObjectListAsync(List<NamedObjectSave> newObjectList
handledByList = true;
}

if(!handledByList)
// We need to call this even if not handled by list. Some plugins, like the live edit system,
// subscribe to both events to differentiate between copy/paste and
//if(!handledByList)
if(plugin.ReactToNewObjectHandler != null)
{
foreach(var nos in newObjectList)
{
Expand Down
8 changes: 7 additions & 1 deletion FRBDK/Glue/Glue/Tasks/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using FlatRedBall.Glue.Plugins.ExportedImplementations;
using FlatRedBall.Glue.Tasks;
using FlatRedBall.IO;
using Nito.AsyncEx;

namespace FlatRedBall.Glue.Managers
{
Expand Down Expand Up @@ -227,12 +228,17 @@ public bool IsTaskProcessingEnabled

public TaskManager()
{
new Thread(DoTaskManagerLoop)
new Thread(StartDoTaskManagerLoop)
{
IsBackground = true
}.Start();
}

void StartDoTaskManagerLoop()
{
AsyncContext.Run(DoTaskManagerLoop);
}

async void DoTaskManagerLoop()
{
SyncTaskThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
Expand Down

0 comments on commit 542732c

Please sign in to comment.