diff --git a/Directory.Packages.props b/Directory.Packages.props
index 1310a8ae4..3017e8569 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -55,7 +55,7 @@
-
+
diff --git a/src/Ryujinx/Systems/Starscript/StarscriptTextBox.axaml.cs b/src/Ryujinx/Systems/Starscript/StarscriptTextBox.axaml.cs
index 8a772d134..5797c3f4a 100644
--- a/src/Ryujinx/Systems/Starscript/StarscriptTextBox.axaml.cs
+++ b/src/Ryujinx/Systems/Starscript/StarscriptTextBox.axaml.cs
@@ -1,6 +1,5 @@
using Avalonia;
using Avalonia.Controls;
-using Avalonia.Input;
using Avalonia.Styling;
using FluentAvalonia.UI.Controls;
using Humanizer;
@@ -8,6 +7,7 @@ using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Controls;
using Ryujinx.Ava.UI.Helpers;
using Starscript;
+using Starscript.Internal;
using System;
using System.Collections.Generic;
using System.Text;
@@ -20,7 +20,7 @@ namespace Ryujinx.Ava.Systems.Starscript
{
public IReadOnlyList CurrentSuggestions => ViewModel.CurrentSuggestions;
- public string CurrentScriptSource => ViewModel.CurrentScriptSource;
+ public ParserResult CurrentScriptSource => ViewModel.CurrentScriptSource;
public Exception Exception => ViewModel.Exception;
public Script CurrentScript => ViewModel.CurrentScript;
public StringSegment CurrentScriptResult => ViewModel.CurrentScriptResult;
@@ -28,8 +28,6 @@ namespace Ryujinx.Ava.Systems.Starscript
public StarscriptTextBox()
{
InitializeComponent();
-
- InputBox.TextInput += HandleTextChanged;
InputBox.AsyncPopulator = GetSuggestionsAsync;
InputBox.MinimumPopulateDelay = 0.Seconds();
@@ -70,12 +68,6 @@ namespace Ryujinx.Ava.Systems.Starscript
private Task> GetSuggestionsAsync(string input, CancellationToken token)
=> Task.FromResult(ViewModel.GetSuggestions(input, token));
- private void HandleTextChanged(object sender, TextInputEventArgs eventArgs)
- {
- if (sender is AutoCompleteBox)
- ViewModel.CurrentScriptSource = eventArgs.Text;
- }
-
public static StarscriptTextBox Create(StarscriptHypervisor hv)
=> new() { ViewModel = new StarscriptTextBoxViewModel(hv) };
diff --git a/src/Ryujinx/Systems/Starscript/StarscriptTextBoxViewModel.cs b/src/Ryujinx/Systems/Starscript/StarscriptTextBoxViewModel.cs
index 3a2cd591c..5a4929dee 100644
--- a/src/Ryujinx/Systems/Starscript/StarscriptTextBoxViewModel.cs
+++ b/src/Ryujinx/Systems/Starscript/StarscriptTextBoxViewModel.cs
@@ -5,6 +5,7 @@ using Starscript.Internal;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Linq;
using System.Threading;
namespace Ryujinx.Ava.Systems.Starscript
@@ -24,7 +25,7 @@ namespace Ryujinx.Ava.Systems.Starscript
[ObservableProperty] private StringSegment _currentScriptResult;
[ObservableProperty] private string _errorMessage;
private Exception _exception;
- private string _currentScriptSource;
+ private ParserResult _currentScriptSource;
private Script _currentScript;
public Exception Exception
@@ -38,12 +39,14 @@ namespace Ryujinx.Ava.Systems.Starscript
StarscriptException se => se.Message,
_ => string.Empty
};
+
+ HasError = value is not null;
OnPropertyChanged();
}
}
- public string CurrentScriptSource
+ public ParserResult CurrentScriptSource
{
get => _currentScriptSource;
set
@@ -55,23 +58,11 @@ namespace Ryujinx.Ava.Systems.Starscript
CurrentScript = null;
CurrentScriptResult = null;
Exception = null;
- HasError = false;
return;
}
-
- try
- {
- CurrentScript = Compiler.DirectCompile(CurrentScriptSource);
- Exception = null;
- HasError = false;
- }
- catch (ParseException pe)
- {
- CurrentScript = null;
- CurrentScriptResult = null;
- Exception = pe;
- HasError = true;
- }
+
+ CurrentScript = Compiler.SingleCompile(value);
+ Exception = null;
OnPropertyChanged();
}
@@ -87,25 +78,41 @@ namespace Ryujinx.Ava.Systems.Starscript
CurrentScriptResult = value?.Execute(_hv)!;
_currentScript = value;
Exception = null;
- HasError = false;
}
catch (StarscriptException se)
{
_currentScript = null;
CurrentScriptResult = null;
Exception = se;
- HasError = true;
}
OnPropertyChanged();
}
}
+ public void ReExecuteScript()
+ {
+ if (_currentScript is null) return;
+
+ try
+ {
+ CurrentScriptResult = _currentScript.Execute(_hv)!;
+ }
+ catch (StarscriptException se)
+ {
+ CurrentScriptResult = null;
+ Exception = se;
+ }
+ }
+
public IEnumerable