Refactor YesNtWindowStatements to use constructor for ownerProcess

This commit is contained in:
Stone_Red
2026-06-12 16:53:10 +02:00
parent 61c0ceb7f8
commit 2f1563d374
2 changed files with 3 additions and 7 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ public class YesNtInterpreterProcess() : Process("YesNtInterpreter")
]; ];
interpreter = new(); interpreter = new();
YesNtWindowStatements.Register(interpreter, this); new YesNtWindowStatements(this).Register(interpreter);
interpreter.Prepare([.. args]); interpreter.Prepare([.. args]);
} }
+2 -6
View File
@@ -33,7 +33,7 @@ namespace RemSox.Utils;
/// %win_last_id expands to the id of the last created window /// %win_last_id expands to the id of the last created window
/// %ui_last_id expands to the id of the last created UI element /// %ui_last_id expands to the id of the last created UI element
/// </summary> /// </summary>
public class YesNtWindowStatements public class YesNtWindowStatements(Process ownerProcess)
{ {
// Maps script-visible integer ids to actual Window objects. // Maps script-visible integer ids to actual Window objects.
private readonly Dictionary<int, Window> windows = []; private readonly Dictionary<int, Window> windows = [];
@@ -42,8 +42,6 @@ public class YesNtWindowStatements
private int lastWindowId = 0; private int lastWindowId = 0;
private int lastUiId = 0; private int lastUiId = 0;
private Process ownerProcess = null!;
/// <summary> /// <summary>
/// Call this from <see cref="YesNtInterpreterProcess.Start"/> to register /// Call this from <see cref="YesNtInterpreterProcess.Start"/> to register
/// every window-related statement with the given interpreter. /// every window-related statement with the given interpreter.
@@ -53,10 +51,8 @@ public class YesNtWindowStatements
/// The <see cref="Process"/> that will own created windows /// The <see cref="Process"/> that will own created windows
/// (usually the <see cref="YesNtInterpreterProcess"/> itself). /// (usually the <see cref="YesNtInterpreterProcess"/> itself).
/// </param> /// </param>
public void Register(YesNtInterpreter interpreter, Process ownerProcess) public void Register(YesNtInterpreter interpreter)
{ {
this.ownerProcess = ownerProcess;
RegisterWindowStatements(interpreter); RegisterWindowStatements(interpreter);
RegisterButtonStatement(interpreter); RegisterButtonStatement(interpreter);
RegisterCheckBoxStatement(interpreter); RegisterCheckBoxStatement(interpreter);