From 2f1563d37425142d43fbac6c243c2b99109e87e6 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Fri, 12 Jun 2026 16:52:43 +0200 Subject: [PATCH] Refactor YesNtWindowStatements to use constructor for ownerProcess --- Processes/YesNtInterpreterProcess.cs | 2 +- Utils/YesNtWindowStatements.cs | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Processes/YesNtInterpreterProcess.cs b/Processes/YesNtInterpreterProcess.cs index 266fe79..7719d3e 100644 --- a/Processes/YesNtInterpreterProcess.cs +++ b/Processes/YesNtInterpreterProcess.cs @@ -22,7 +22,7 @@ public class YesNtInterpreterProcess() : Process("YesNtInterpreter") ]; interpreter = new(); - YesNtWindowStatements.Register(interpreter, this); + new YesNtWindowStatements(this).Register(interpreter); interpreter.Prepare([.. args]); } diff --git a/Utils/YesNtWindowStatements.cs b/Utils/YesNtWindowStatements.cs index 64191a6..ef655ff 100644 --- a/Utils/YesNtWindowStatements.cs +++ b/Utils/YesNtWindowStatements.cs @@ -33,7 +33,7 @@ namespace RemSox.Utils; /// %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 /// -public class YesNtWindowStatements +public class YesNtWindowStatements(Process ownerProcess) { // Maps script-visible integer ids to actual Window objects. private readonly Dictionary windows = []; @@ -42,8 +42,6 @@ public class YesNtWindowStatements private int lastWindowId = 0; private int lastUiId = 0; - private Process ownerProcess = null!; - /// /// Call this from to register /// every window-related statement with the given interpreter. @@ -53,10 +51,8 @@ public class YesNtWindowStatements /// The that will own created windows /// (usually the itself). /// - public void Register(YesNtInterpreter interpreter, Process ownerProcess) + public void Register(YesNtInterpreter interpreter) { - this.ownerProcess = ownerProcess; - RegisterWindowStatements(interpreter); RegisterButtonStatement(interpreter); RegisterCheckBoxStatement(interpreter);