Skip to content

Commit

Permalink
Merge pull request #327 from amazingalek/dev
Browse files Browse the repository at this point in the history
* fixed nuspec
* console overload for QSB
  • Loading branch information
amazingalek authored Dec 20, 2020
2 parents 1d68039 + 04df810 commit c03274c
Show file tree
Hide file tree
Showing 26 changed files with 143 additions and 77 deletions.
2 changes: 2 additions & 0 deletions src/OWML.Common/Interfaces/IModConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/OWML.Launcher/OWML.Manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/OWML.Logging/ModConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions src/OWML.Logging/ModSocketOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");

Expand All @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/OWML.Logging/OutputWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
4 changes: 2 additions & 2 deletions src/OWML.ModHelper.Menus/ModConfigMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions src/OWML.ModHelper.Menus/ModConfigMenuBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Linq;
using OWML.Common;
using OWML.Common.Menus;
using OWML.Logging;

namespace OWML.ModHelper.Menus
{
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -158,6 +158,5 @@ private void AddNumberInput(string key, int index)
numberInput.Element.name = key;
numberInput.Show();
}

}
}
21 changes: 14 additions & 7 deletions src/OWML.ModHelper.Menus/ModInputCombinationElement.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<SingleAxisCommand> _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();
Expand All @@ -46,7 +53,7 @@ public ModInputCombinationElement(TwoButtonToggleElement toggle, IModMenu menu,
.GetComponentInChildren<HorizontalLayoutGroup>(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<HorizontalLayoutGroup>();
Expand Down Expand Up @@ -179,7 +186,7 @@ private void OnDeleteClick()
{
var copy = GameObject.Instantiate(Toggle);
GameObject.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
return new ModInputCombinationElement(copy, Menu, _popupManager, _inputHandler, combination);
return new ModInputCombinationElement(copy, Menu, _popupManager, _inputHandler, _console, combination);
}
}
}
12 changes: 5 additions & 7 deletions src/OWML.ModHelper.Menus/ModInputCombinationElementMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Linq;
using OWML.Common;
using OWML.Common.Menus;
using OWML.Logging;
using OWML.Utils;

namespace OWML.ModHelper.Menus
Expand All @@ -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)
{
Expand All @@ -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<HorizontalLayoutGroup>();
layoutGroupNew.childForceExpandWidth = false;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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<ModInputCombinationPopup>());
newPopup.Init(_popupManager);
return newPopup;
Expand Down
5 changes: 5 additions & 0 deletions src/OWML.ModHelper.Menus/ModInputCombinationMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion src/OWML.ModHelper.Menus/ModInputMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<PopupInputMenu>());
return newPopup;
}
Expand Down
4 changes: 3 additions & 1 deletion src/OWML.ModHelper.Menus/ModMainMenu.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using OWML.Common;
using OWML.Common.Menus;
using OWML.Utils;
using UnityEngine;
Expand All @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions src/OWML.ModHelper.Menus/ModMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -40,6 +39,12 @@ public class ModMenu : IModMenu
public List<IModSeparator> Separators { get; private set; }

protected LayoutGroup Layout;
protected IModConsole Console;

public ModMenu(IModConsole console)
{
Console = console;
}

public virtual void Initialize(Menu menu)
{
Expand All @@ -57,7 +62,7 @@ public virtual void Initialize(Menu menu, LayoutGroup layoutGroup)

var promptButtons = Menu.GetComponentsInChildren<ButtonWithHotkeyImageElement>(true)
.Select(x => x.GetComponent<Button>()).ToList();
BaseButtons = promptButtons.Select(x => new ModPromptButton(x, this)).Cast<IModButtonBase>().ToList();
BaseButtons = promptButtons.Select(x => new ModPromptButton(x, this, Console)).Cast<IModButtonBase>().ToList();

var ordinaryButtons = Menu.GetComponentsInChildren<Button>(true).Except(promptButtons);
BaseButtons.AddRange(ordinaryButtons.Select(x => new ModTitleButton(x, this)).Cast<IModButtonBase>().ToList());
Expand Down Expand Up @@ -96,7 +101,7 @@ private T GetTitleButton<T>(string title, List<T> buttons) where T : IModButton
var button = buttons.FirstOrDefault(x => x.Title == title || x.Button.name == title);
if (button == null)
{
ModConsole.OwmlConsole.WriteLine("Warning - No button found with title or name: " + title, MessageType.Warning);
Console.WriteLine("Warning - No button found with title or name: " + title, MessageType.Warning);
}
return button;
}
Expand Down Expand Up @@ -296,7 +301,7 @@ public object GetInputValue(string key)
{
return numberInput.Value;
}
ModConsole.OwmlConsole.WriteLine($"Error - No input found with name {key}", MessageType.Error);
Console.WriteLine($"Error - No input found with name {key}", MessageType.Error);
return null;
}

Expand Down Expand Up @@ -344,7 +349,7 @@ public void SetInputValue(string key, object value)
numberInput.Value = Convert.ToSingle(val);
return;
}
ModConsole.OwmlConsole.WriteLine("Error - No input found with name " + key, MessageType.Error);
Console.WriteLine("Error - No input found with name " + key, MessageType.Error);
}

protected void InvokeOnInit()
Expand Down
6 changes: 6 additions & 0 deletions src/OWML.ModHelper.Menus/ModMenuWithSelectables.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OWML.Common;
using OWML.Common.Menus;
using OWML.ModHelper.Input;
using OWML.Utils;
Expand All @@ -16,6 +17,11 @@ public class ModMenuWithSelectables : ModPopupMenu, IModMenuWithSelectables
protected List<Selectable> Selectables;
protected ModCommandListener CommandListener;

public ModMenuWithSelectables(IModConsole console)
: base(console)
{
}

private void SetupCommands()
{
var listenerObject = new GameObject("ConfigurationMenu_Listener");
Expand Down
12 changes: 8 additions & 4 deletions src/OWML.ModHelper.Menus/ModMessagePopup.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using OWML.Common;
using OWML.Common.Menus;
using OWML.Logging;
using OWML.Utils;
using UnityEngine.UI;

Expand All @@ -13,6 +12,11 @@ public class ModMessagePopup : ModTemporaryPopup, IModMessagePopup

private PopupMenu _twoButtonPopup;

public ModMessagePopup(IModConsole console)
: base(console)
{
}

public void Initialize(PopupMenu popup)
{
if (Menu != null)
Expand All @@ -38,7 +42,7 @@ public override void DestroySelf()
public IModMessagePopup Copy()
{
var newPopupObject = CopyMenu();
var newPopup = new ModMessagePopup();
var newPopup = new ModMessagePopup(Console);
newPopup.Initialize(newPopupObject.GetComponent<PopupMenu>());
return newPopup;
}
Expand All @@ -47,8 +51,8 @@ public void ShowMessage(string message, bool addCancel = false, string okMessage
{
if (_twoButtonPopup == null)
{
ModConsole.OwmlConsole.WriteLine("Failed to create popup for a following message:", MessageType.Warning);
ModConsole.OwmlConsole.WriteLine(message, MessageType.Info);
Console.WriteLine("Failed to create popup for a following message:", MessageType.Warning);
Console.WriteLine(message, MessageType.Info);
}
RegisterEvents();
_twoButtonPopup.EnableMenu(true);
Expand Down
Loading

0 comments on commit c03274c

Please sign in to comment.