Skip to content

Commit

Permalink
Fixed Runtime margin for SqfVmDebugger & if no sqf document is availa…
Browse files Browse the repository at this point in the history
…ble, active document will be used to run now.
  • Loading branch information
X39 committed Mar 16, 2020
1 parent c9a0f89 commit 84ed8a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
35 changes: 22 additions & 13 deletions Arma.Studio.SqfVmDebugger/PluginMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,39 @@ await Task.Run(() =>
Logger.Warning($"No config file located for PBO {pbo.Name}.");
}
}
if (!hasConfig)
{
Logger.Error("No config files available.");
break;
}
// Apply Breakpoints
foreach (var breakpoint in this.GetApplication().MainWindow.BreakpointManager.Breakpoints)
{
this.SetBreakpoint(breakpoint);
}
// Run CfgFunctions script
if (hasConfig)
{
// Run CfgFunctions script
var text = this.CfgFunctionsScript;
var preprocessed = this.Virtualmachine.PreProcess(text, "SqfVmDebugger/CfgFunctions.sqf");
this.Virtualmachine.ParseSqf(preprocessed, "SqfVmDebugger/CfgFunctions.sqf");
this.State = EDebugState.Running;
execResult = this.Virtualmachine.Start();
Logger.Diagnostic($"Result of Start: {execResult}");
}
else
{
Logger.Warning("No config files available. Trying to use currently open document.");
var editorDocument = this.GetApplication().MainWindow.ActiveDockable as Data.UI.IEditorDocument;
if (editorDocument != null && editorDocument.File.Extension == ".sqf")
{
var text = editorDocument.GetContents();
var preprocessed = this.Virtualmachine.PreProcess(text, editorDocument.TextEditorInstance.File.FullPath);
this.Virtualmachine.ParseSqf(preprocessed, editorDocument.TextEditorInstance.File.FullPath);
this.State = EDebugState.Running;
execResult = this.Virtualmachine.Start();
Logger.Diagnostic($"Result of Start: {execResult}");
}
else
{
Logger.Error("Found nothing to run.");
}
}
//var text = textEditorDocuments.GetContents();
//var preprocessed = this.Virtualmachine.PreProcess(text, textEditorDocuments.TextEditorInstance.File.FullPath);
//this.Virtualmachine.ParseSqf(preprocessed, textEditorDocuments.TextEditorInstance.File.FullPath);
//this.State = EDebugState.Running;
//execResult = this.Virtualmachine.Start();
Logger.Diagnostic($"Result of Start: {execResult}");
break;
case EDebugAction.Stop:
execResult = this.Virtualmachine.Abort();
Expand Down Expand Up @@ -247,7 +256,7 @@ public IEnumerable<HaltInfo> GetHaltInfos()
{
if (this.Virtualmachine == null)
{
throw new InvalidOperationException();
return Array.Empty<HaltInfo>();
}
Logger.Diagnostic($"IEnumerable<HaltInfo> GetHaltInfos()");
var callstack = this.Virtualmachine.GetCallstack();
Expand Down
2 changes: 1 addition & 1 deletion Arma.Studio/UI/RuntimeBackgroundRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Draw(TextView textView, DrawingContext drawingContext)
{
if (this.Editor.Document == null ||
App.MWContext.Debugger is null ||
App.MWContext.Debugger.State == Data.Debugging.EDebugState.Running)
App.MWContext.Debugger.State != Data.Debugging.EDebugState.Halted)
{
return;
}
Expand Down

0 comments on commit 84ed8a1

Please sign in to comment.