diff --git a/src/OWML.Common/Interfaces/IModConsole.cs b/src/OWML.Common/Interfaces/IModConsole.cs index 0bb7978bb..dc64d12cb 100644 --- a/src/OWML.Common/Interfaces/IModConsole.cs +++ b/src/OWML.Common/Interfaces/IModConsole.cs @@ -10,5 +10,7 @@ public interface IModConsole void WriteLine(string line); void WriteLine(string line, MessageType type); + + void WriteLine(string line, MessageType type, string senderType); } } diff --git a/src/OWML.Launcher/OWML.Manifest.json b/src/OWML.Launcher/OWML.Manifest.json index 7ab4f7982..7658d60ac 100644 --- a/src/OWML.Launcher/OWML.Manifest.json +++ b/src/OWML.Launcher/OWML.Manifest.json @@ -2,7 +2,7 @@ "author": "Alek", "name": "OWML", "uniqueName": "Alek.OWML", - "version": "1.1.0", + "version": "1.1.1", "description": "The mod loader and mod framework for Outer Wilds", "minGameVersion": "1.0.7.0", "maxGameVersion": "1.0.7.481" diff --git a/src/OWML.Logging/ModConsole.cs b/src/OWML.Logging/ModConsole.cs index 6290e6ad1..e329272f2 100644 --- a/src/OWML.Logging/ModConsole.cs +++ b/src/OWML.Logging/ModConsole.cs @@ -18,6 +18,8 @@ public abstract class ModConsole : IModConsole public abstract void WriteLine(string line, MessageType type); + public abstract void WriteLine(string line, MessageType type, string senderType); + protected ModConsole(IOwmlConfig config, IModLogger logger, IModManifest manifest) { Logger = logger; diff --git a/src/OWML.Logging/ModSocketOutput.cs b/src/OWML.Logging/ModSocketOutput.cs index 2876ac04b..8fbff5801 100644 --- a/src/OWML.Logging/ModSocketOutput.cs +++ b/src/OWML.Logging/ModSocketOutput.cs @@ -21,16 +21,16 @@ public ModSocketOutput(IOwmlConfig config, IModManifest manifest, IModLogger log public override void WriteLine(params object[] objects) { var line = string.Join(" ", objects.Select(o => o.ToString()).ToArray()); - WriteLine(MessageType.Message, line, GetCallingType(new StackTrace())); + WriteLine(line, MessageType.Message, GetCallingType(new StackTrace())); } public override void WriteLine(string line) => - WriteLine(MessageType.Message, line, GetCallingType(new StackTrace())); + WriteLine(line, MessageType.Message, GetCallingType(new StackTrace())); public override void WriteLine(string line, MessageType type) => - WriteLine(type, line, GetCallingType(new StackTrace())); + WriteLine(line, type, GetCallingType(new StackTrace())); - private void WriteLine(MessageType type, string line, string senderType) + public override void WriteLine(string line, MessageType type, string senderType) { Logger?.Log($"{type}: {line}"); @@ -48,7 +48,9 @@ private void WriteLine(MessageType type, string line, string senderType) KillProcess(); } } - + private void WriteLine(MessageType type, string line, string senderType) => + WriteLine(line, type, senderType); + private void KillProcess() { _socket.Close(); diff --git a/src/OWML.Logging/OutputWriter.cs b/src/OWML.Logging/OutputWriter.cs index 54f716b66..aaad02776 100644 --- a/src/OWML.Logging/OutputWriter.cs +++ b/src/OWML.Logging/OutputWriter.cs @@ -15,5 +15,8 @@ public void WriteLine(string line) => public void WriteLine(string line, MessageType type) => ConsoleUtils.WriteByType(type, line); + + public void WriteLine(string line, MessageType type, string senderType) => + ConsoleUtils.WriteByType(type, $"{senderType}: {line}"); } } diff --git a/src/OWML.ModHelper.Menus/ModConfigMenu.cs b/src/OWML.ModHelper.Menus/ModConfigMenu.cs index 5e2c973aa..002747c0a 100644 --- a/src/OWML.ModHelper.Menus/ModConfigMenu.cs +++ b/src/OWML.ModHelper.Menus/ModConfigMenu.cs @@ -11,8 +11,8 @@ public class ModConfigMenu : ModConfigMenuBase, IModConfigMenu public IModData ModData { get; } public IModBehaviour Mod { get; } - public ModConfigMenu(IModData modData, IModBehaviour mod, IModStorage storage) - : base(modData.Manifest, storage) + public ModConfigMenu(IModData modData, IModBehaviour mod, IModStorage storage, IModConsole console) + : base(modData.Manifest, storage, console) { ModData = modData; Mod = mod; diff --git a/src/OWML.ModHelper.Menus/ModConfigMenuBase.cs b/src/OWML.ModHelper.Menus/ModConfigMenuBase.cs index 37fe25a1a..1b2766750 100644 --- a/src/OWML.ModHelper.Menus/ModConfigMenuBase.cs +++ b/src/OWML.ModHelper.Menus/ModConfigMenuBase.cs @@ -2,7 +2,6 @@ using System.Linq; using OWML.Common; using OWML.Common.Menus; -using OWML.Logging; namespace OWML.ModHelper.Menus { @@ -23,7 +22,8 @@ public abstract class ModConfigMenuBase : ModMenuWithSelectables, IModConfigMenu protected abstract void UpdateUIValues(); - protected ModConfigMenuBase(IModManifest manifest, IModStorage storage) + protected ModConfigMenuBase(IModManifest manifest, IModStorage storage, IModConsole console) + : base(console) { Manifest = manifest; Storage = storage; @@ -90,12 +90,12 @@ protected void AddConfigInput(string key, object value, int index) AddComboInput(key, index); return; default: - ModConsole.OwmlConsole.WriteLine("Error - Unrecognized complex setting: " + value, MessageType.Error); + Console.WriteLine("Error - Unrecognized complex setting: " + value, MessageType.Error); return; } } - ModConsole.OwmlConsole.WriteLine("Error - Unrecognized setting type: " + value.GetType(), MessageType.Error); + Console.WriteLine("Error - Unrecognized setting type: " + value.GetType(), MessageType.Error); } private void AddToggleInput(string key, int index) @@ -158,6 +158,5 @@ private void AddNumberInput(string key, int index) numberInput.Element.name = key; numberInput.Show(); } - } } diff --git a/src/OWML.ModHelper.Menus/ModInputCombinationElement.cs b/src/OWML.ModHelper.Menus/ModInputCombinationElement.cs index 9aca3521d..0ee550ede 100644 --- a/src/OWML.ModHelper.Menus/ModInputCombinationElement.cs +++ b/src/OWML.ModHelper.Menus/ModInputCombinationElement.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using OWML.Common; using OWML.Common.Menus; -using OWML.Logging; using OWML.ModHelper.Input; using UnityEngine; using UnityEngine.UI; @@ -25,18 +24,26 @@ public override string Title private string _combination; private readonly IModInputHandler _inputHandler; + private readonly IModPopupManager _popupManager; + private readonly IModConsole _console; + private readonly List _openCommands = new() { InputLibrary.menuConfirm }; - private static IModPopupManager _popupManager; - public ModInputCombinationElement(TwoButtonToggleElement toggle, IModMenu menu, - IModPopupManager popupManager, IModInputHandler inputHandler, string combination = "") : - base(toggle, menu) + public ModInputCombinationElement( + TwoButtonToggleElement toggle, + IModMenu menu, + IModPopupManager popupManager, + IModInputHandler inputHandler, + IModConsole console, + string combination = "") + : base(toggle, menu) { _inputHandler = inputHandler; + _console = console; _combination = combination; Initialize(menu); SetupButtons(); @@ -46,7 +53,7 @@ public ModInputCombinationElement(TwoButtonToggleElement toggle, IModMenu menu, .GetComponentInChildren(true).gameObject; if (layoutObject == null) { - ModConsole.OwmlConsole.WriteLine("Error - Failed to setup an element for combination editor.", MessageType.Error); + _console.WriteLine("Error - Failed to setup an element for combination editor.", MessageType.Error); return; } var layoutGroup = layoutObject.GetComponent(); @@ -179,7 +186,7 @@ private void OnDeleteClick() { var copy = GameObject.Instantiate(Toggle); GameObject.Destroy(copy.GetComponentInChildren(true)); - return new ModInputCombinationElement(copy, Menu, _popupManager, _inputHandler, combination); + return new ModInputCombinationElement(copy, Menu, _popupManager, _inputHandler, _console, combination); } } } diff --git a/src/OWML.ModHelper.Menus/ModInputCombinationElementMenu.cs b/src/OWML.ModHelper.Menus/ModInputCombinationElementMenu.cs index 9dd5ef8c4..682be4485 100644 --- a/src/OWML.ModHelper.Menus/ModInputCombinationElementMenu.cs +++ b/src/OWML.ModHelper.Menus/ModInputCombinationElementMenu.cs @@ -5,7 +5,6 @@ using System.Linq; using OWML.Common; using OWML.Common.Menus; -using OWML.Logging; using OWML.Utils; namespace OWML.ModHelper.Menus @@ -23,10 +22,9 @@ public class ModInputCombinationElementMenu : ModTemporaryPopup, IModInputCombin private SingleAxisCommand _cancelCommand; private string _comboName; - public ModInputCombinationElementMenu(IModInputHandler inputHandler) - { + public ModInputCombinationElementMenu(IModInputHandler inputHandler, IModConsole console) + : base(console) => _inputHandler = inputHandler; - } private GameObject CreateResetButton(Transform buttonsTransform) { @@ -45,7 +43,7 @@ private ModLayoutManager CreateLayoutManager(GameObject layoutObject, Transform { if (scaleReference == null) { - ModConsole.OwmlConsole.WriteLine("Error - scale reference is null", MessageType.Error); + Console.WriteLine("Error - scale reference is null", MessageType.Error); } var layoutGroupNew = layoutObject.GetAddComponent(); layoutGroupNew.childForceExpandWidth = false; @@ -102,7 +100,7 @@ public void Initialize(PopupInputMenu menu) if (layout == null) { - ModConsole.OwmlConsole.WriteLine("Error - Failed to create combination visualizer in combination editor.", MessageType.Error); + Console.WriteLine("Error - Failed to create combination visualizer in combination editor.", MessageType.Error); return; } @@ -161,7 +159,7 @@ public override void DestroySelf() public IModInputCombinationElementMenu Copy() { var newPopupObject = CopyMenu(); - var newPopup = new ModInputCombinationElementMenu(_inputHandler); + var newPopup = new ModInputCombinationElementMenu(_inputHandler, Console); newPopup.Initialize(newPopupObject.GetComponent()); newPopup.Init(_popupManager); return newPopup; diff --git a/src/OWML.ModHelper.Menus/ModInputCombinationMenu.cs b/src/OWML.ModHelper.Menus/ModInputCombinationMenu.cs index 1cdda83d0..fe13927ad 100644 --- a/src/OWML.ModHelper.Menus/ModInputCombinationMenu.cs +++ b/src/OWML.ModHelper.Menus/ModInputCombinationMenu.cs @@ -16,6 +16,11 @@ public class ModInputCombinationMenu : ModMenuWithSelectables, IModInputCombinat private IModInputCombinationElement _combinationElementTemplate; + public ModInputCombinationMenu(IModConsole console) + : base(console) + { + } + public string GenerateCombination() { var toDestroy = CombinationElements.Where(x => x.Title == "").ToList(); diff --git a/src/OWML.ModHelper.Menus/ModInputMenu.cs b/src/OWML.ModHelper.Menus/ModInputMenu.cs index 954e192f9..d3917d2bd 100644 --- a/src/OWML.ModHelper.Menus/ModInputMenu.cs +++ b/src/OWML.ModHelper.Menus/ModInputMenu.cs @@ -13,6 +13,11 @@ public class ModInputMenu : ModTemporaryPopup, IModInputMenu private PopupInputMenu _inputMenu; + public ModInputMenu(IModConsole console) + : base(console) + { + } + public void Initialize(PopupInputMenu menu) { if (Menu != null) @@ -52,7 +57,7 @@ public void Open(InputType inputType, string value) public IModInputMenu Copy() { var newPopupObject = CopyMenu(); - var newPopup = new ModInputMenu(); + var newPopup = new ModInputMenu(Console); newPopup.Initialize(newPopupObject.GetComponent()); return newPopup; } diff --git a/src/OWML.ModHelper.Menus/ModMainMenu.cs b/src/OWML.ModHelper.Menus/ModMainMenu.cs index 72554d06b..3e4aaa245 100644 --- a/src/OWML.ModHelper.Menus/ModMainMenu.cs +++ b/src/OWML.ModHelper.Menus/ModMainMenu.cs @@ -1,4 +1,5 @@ using System.Linq; +using OWML.Common; using OWML.Common.Menus; using OWML.Utils; using UnityEngine; @@ -25,7 +26,8 @@ public class ModMainMenu : ModMenu, IModMainMenu private TitleAnimationController _anim; private TitleScreenManager _titleManager; - public ModMainMenu(IModTabbedMenu optionsMenu) => + public ModMainMenu(IModTabbedMenu optionsMenu, IModConsole console) + : base(console) => OptionsMenu = optionsMenu; public void Initialize(TitleScreenManager titleScreenManager) diff --git a/src/OWML.ModHelper.Menus/ModMenu.cs b/src/OWML.ModHelper.Menus/ModMenu.cs index 125f00059..d16ac1e17 100644 --- a/src/OWML.ModHelper.Menus/ModMenu.cs +++ b/src/OWML.ModHelper.Menus/ModMenu.cs @@ -4,7 +4,6 @@ using Newtonsoft.Json.Linq; using OWML.Common; using OWML.Common.Menus; -using OWML.Logging; using OWML.Utils; using UnityEngine; using UnityEngine.UI; @@ -40,6 +39,12 @@ public class ModMenu : IModMenu public List Separators { get; private set; } protected LayoutGroup Layout; + protected IModConsole Console; + + public ModMenu(IModConsole console) + { + Console = console; + } public virtual void Initialize(Menu menu) { @@ -57,7 +62,7 @@ public virtual void Initialize(Menu menu, LayoutGroup layoutGroup) var promptButtons = Menu.GetComponentsInChildren(true) .Select(x => x.GetComponent