Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Debugger: Lua - Add option to auto-restart scripts after power cyclin…
Browse files Browse the repository at this point in the history
…g or reloading the rom
  • Loading branch information
SourMesen committed May 3, 2020
1 parent 9772aa0 commit 527db70
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
1 change: 1 addition & 0 deletions GUI.NET/Config/DebugInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ public class DebugInfo
public int ScriptCodeWindowHeight = 0;
public List<string> RecentScripts = new List<string>();
public bool SaveScriptBeforeRun = true;
public bool AutoRestartScript = true;
public ScriptStartupBehavior ScriptStartupBehavior = ScriptStartupBehavior.ShowTutorial;
public bool AutoLoadLastScript = true;
public string ScriptFontFamily = BaseControl.MonospaceFontFamily;
Expand Down
25 changes: 18 additions & 7 deletions GUI.NET/Debugger/frmScript.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 23 additions & 5 deletions GUI.NET/Debugger/frmScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public frmScript(bool forceBlank = false)

RestoreLocation(config.ScriptWindowLocation, config.ScriptWindowSize);
mnuSaveBeforeRun.Checked = config.SaveScriptBeforeRun;
mnuAutoRestart.Checked = config.AutoRestartScript;

if(config.ScriptCodeWindowHeight >= ctrlSplit.Panel1MinSize) {
if(config.ScriptCodeWindowHeight == Int32.MaxValue) {
Expand Down Expand Up @@ -151,11 +152,27 @@ private void InitShortcuts()

private void _notifListener_OnNotification(InteropEmu.NotificationEventArgs e)
{
if(e.NotificationType == InteropEmu.ConsoleNotificationType.GameStopped) {
this._scriptId = -1;
this.BeginInvoke((Action)(() => {
lblScriptActive.Visible = false;
}));
switch(e.NotificationType) {
case InteropEmu.ConsoleNotificationType.EmulationStopped:
this._scriptId = -1;
break;

case InteropEmu.ConsoleNotificationType.GameStopped:
if(e.Parameter == IntPtr.Zero) {
this._scriptId = -1;
}
break;

case InteropEmu.ConsoleNotificationType.GameInitCompleted:
bool wasRunning = this._scriptId >= 0;
this._scriptId = -1;
this.BeginInvoke((Action)(() => {
lblScriptActive.Visible = false;
if(e.NotificationType == InteropEmu.ConsoleNotificationType.GameInitCompleted && wasRunning && mnuAutoRestart.Checked) {
RunScript();
}
}));
break;
}
}

Expand Down Expand Up @@ -185,6 +202,7 @@ protected override void OnClosing(CancelEventArgs e)
ConfigManager.Config.DebugInfo.ScriptFontStyle = txtScriptContent.OriginalFont.Style;
ConfigManager.Config.DebugInfo.ScriptFontSize = txtScriptContent.OriginalFont.Size;
ConfigManager.Config.DebugInfo.AutoLoadLastScript = mnuAutoLoadLastScript.Checked;
ConfigManager.Config.DebugInfo.AutoRestartScript = mnuAutoRestart.Checked;
ConfigManager.ApplyChanges();

base.OnClosing(e);
Expand Down

0 comments on commit 527db70

Please sign in to comment.