Implement diagnostic output opcodes
This commit is contained in:
@@ -26,6 +26,7 @@ public sealed class GodotAdvHost : IHost
|
||||
private readonly Stack<string> _scriptContexts = new();
|
||||
private readonly ScriptPresentationBarrier _presentationBarrier = new();
|
||||
private readonly AutoResetEvent _presentationRequestConsumed = new(false);
|
||||
private readonly AutoResetEvent _diagnosticMessageCompleted = new(false);
|
||||
private readonly bool _synchronizeExplicitPresentation;
|
||||
private long _explicitPresentationRequestGeneration;
|
||||
private long _consumedPresentationRequestGeneration;
|
||||
@@ -117,6 +118,20 @@ public sealed class GodotAdvHost : IHost
|
||||
|
||||
public void ReportWarning(string message) => System.Console.Error.WriteLine(message);
|
||||
|
||||
public void ShowDiagnosticMessage(DiagnosticMessage message)
|
||||
{
|
||||
if (_stopping) return;
|
||||
_timeline?.Event("diagnostic-message", new()
|
||||
{
|
||||
["caption"] = message.Caption,
|
||||
["text"] = message.Text,
|
||||
});
|
||||
_main.CallDeferred("ShowAgeDiagnostic", message.Text, message.Caption);
|
||||
while (!_stopping && !_diagnosticMessageCompleted.WaitOne(50)) { }
|
||||
}
|
||||
|
||||
public void CompleteDiagnosticMessage() => _diagnosticMessageCompleted.Set();
|
||||
|
||||
private string CurrentScene
|
||||
{
|
||||
get { lock (_scriptContextLock) return _scriptContexts.TryPeek(out var scene) ? scene : _rootScene; }
|
||||
@@ -950,6 +965,7 @@ public sealed class GodotAdvHost : IHost
|
||||
if (_gate.CurrentCount == 0) _gate.Release();
|
||||
_inputCallbackSignal.Set();
|
||||
_frameSignal.Set();
|
||||
_diagnosticMessageCompleted.Set();
|
||||
}
|
||||
|
||||
public void ResetSceneContext()
|
||||
|
||||
@@ -912,6 +912,22 @@ public partial class Main : Godot.Control
|
||||
_ageCursorTexture = null;
|
||||
}
|
||||
|
||||
public void ShowAgeDiagnostic(string text, string caption)
|
||||
{
|
||||
try
|
||||
{
|
||||
OS.Alert(text, caption);
|
||||
}
|
||||
catch (System.Exception error)
|
||||
{
|
||||
GD.PushError($"[diagnostic] native alert failed: {error.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_host?.CompleteDiagnosticMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
bool vmStopped = true;
|
||||
|
||||
Reference in New Issue
Block a user