colors, readme and menu cleanup (#333)

This commit is contained in:
AmazingAlek 2020-12-25 22:16:15 +01:00 committed by GitHub
parent 1f5b4bdbc5
commit fec3221651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 55 deletions

View File

@ -1,6 +1,6 @@
# Outer Wilds Mod Loader # Outer Wilds Mod Loader
OWML is the mod loader and mod framework for Outer Wilds. It patches Outer Wilds to load mods, and provides mods with a framework to interact with the game. OWML is inspired by SMAPI for Stardew Valley. OWML is the mod loader and mod framework for Outer Wilds. It patches Outer Wilds to load mods, and provides mods a framework to interact with the game. OWML is inspired by SMAPI for Stardew Valley.
## How it works ## How it works
@ -20,21 +20,13 @@ Manual install:
2. [Download Outer Wilds mods](https://outerwildsmods.com/mods) and put them in the Mods folder, each mod in a separate folder. 2. [Download Outer Wilds mods](https://outerwildsmods.com/mods) and put them in the Mods folder, each mod in a separate folder.
3. Start the game with OWML.Launcher.exe. 3. Start the game with OWML.Launcher.exe.
## Sample mod
One mod is included as an example. It's disabled by default, enable in manifest.json.
|Sample mod|Description|
|----------|-----------|
|OWML.EnableDebugMode|Enables the built-in debug mode in the game. Highlights: cycle through debug UIs with F1, warp to planets with the number keys, and explode the sun with the End key.|
## For modders ## For modders
Refer to the sample mods for examples. Refer to the sample mods in the source code for examples. These mods are not included in releases.
### Get started ### Get started
1. Create a class library project targeting .Net Framework 3.5. 1. Create a C# class library project targeting .Net Framework 3.5.
2. Install the [OWML Nuget package](https://www.nuget.org/packages/OWML/). 2. Install the [OWML Nuget package](https://www.nuget.org/packages/OWML/).
3. Reference the following files in {gamePath}\OuterWilds_Data\Managed: 3. Reference the following files in {gamePath}\OuterWilds_Data\Managed:
* Assembly-CSharp.dll * Assembly-CSharp.dll
@ -46,11 +38,12 @@ For more info, see [For modders](https://github.com/amazingalek/owml/wiki/For-mo
## Configuration ## Configuration
OWML is configured by OWML.Config.json: OWML is configured in the in-game MODS menu, or in OWML.Config.json:
|Key|Description| |Key|Description|
|---|-----------| |---|-----------|
|gamePath|The path to the game files. OWML will try to locate the game automatically.| |gamePath|The path to the game files. OWML will try to locate the game automatically.|
|debugMode|If enabled, a lot more information is written to the console. Intended for developers.|
|combinationsBlockInput|If this is true, mod input combinations will block game input.| |combinationsBlockInput|If this is true, mod input combinations will block game input.|
Each mod is defined in a manifest.json file: Each mod is defined in a manifest.json file:
@ -65,7 +58,7 @@ Each mod is defined in a manifest.json file:
|owmlVersion|The version of OWML the mod was built for.| |owmlVersion|The version of OWML the mod was built for.|
|dependencies|Array of dependency names. Make sure to use the unique name.| |dependencies|Array of dependency names. Make sure to use the unique name.|
Each mod can be configured with an **optional** config.json file: Each mod can be configured in the in-game MODS menu, or in config.json:
|Key|Description| |Key|Description|
|---|-----------| |---|-----------|

View File

@ -2,7 +2,7 @@
"author": "Alek", "author": "Alek",
"name": "OWML", "name": "OWML",
"uniqueName": "Alek.OWML", "uniqueName": "Alek.OWML",
"version": "1.1.5", "version": "1.1.6",
"description": "The mod loader and mod framework for Outer Wilds", "description": "The mod loader and mod framework for Outer Wilds",
"minGameVersion": "1.0.7.0", "minGameVersion": "1.0.7.0",
"maxGameVersion": "1.0.7.481" "maxGameVersion": "1.0.7.481"

View File

@ -17,15 +17,14 @@ namespace OWML.Logging
MessageType.Error => ConsoleColor.Red, MessageType.Error => ConsoleColor.Red,
MessageType.Warning => ConsoleColor.Yellow, MessageType.Warning => ConsoleColor.Yellow,
MessageType.Success => ConsoleColor.Green, MessageType.Success => ConsoleColor.Green,
MessageType.Message => ConsoleColor.Gray, MessageType.Message => ConsoleColor.White,
MessageType.Info => ConsoleColor.Cyan, MessageType.Info => ConsoleColor.Cyan,
MessageType.Fatal => ConsoleColor.Magenta, MessageType.Fatal => ConsoleColor.Magenta,
MessageType.Debug => ConsoleColor.Blue, MessageType.Debug => ConsoleColor.DarkGray,
_ => ConsoleColor.Gray _ => ConsoleColor.White
}; };
Console.WriteLine(line); Console.WriteLine(line);
Console.ForegroundColor = ConsoleColor.Gray;
} }
} }
} }

View File

@ -34,6 +34,7 @@ namespace OWML.Logging
{ {
LogType.Error => MessageType.Error, LogType.Error => MessageType.Error,
LogType.Exception => MessageType.Error, LogType.Exception => MessageType.Error,
LogType.Warning => MessageType.Warning,
_ => MessageType.Debug _ => MessageType.Debug
}; };

View File

@ -18,29 +18,31 @@ namespace OWML.ModHelper.Menus
public List<IModButtonBase> BaseButtons { get; private set; } public List<IModButtonBase> BaseButtons { get; private set; }
public List<IModToggleInput> ToggleInputs { get; private set; }
public List<IModSliderInput> SliderInputs { get; private set; }
public List<IModSelectorInput> SelectorInputs { get; private set; }
public List<IModTextInput> TextInputs { get; private set; }
public List<IModComboInput> ComboInputs { get; private set; }
public List<IModNumberInput> NumberInputs { get; private set; }
public List<IModButton> Buttons => BaseButtons.OfType<IModButton>().ToList(); public List<IModButton> Buttons => BaseButtons.OfType<IModButton>().ToList();
public List<IModLayoutButton> LayoutButtons => BaseButtons.OfType<IModLayoutButton>().ToList(); public List<IModLayoutButton> LayoutButtons => BaseButtons.OfType<IModLayoutButton>().ToList();
public List<IModPromptButton> PromptButtons => BaseButtons.OfType<IModPromptButton>().ToList(); public List<IModPromptButton> PromptButtons => BaseButtons.OfType<IModPromptButton>().ToList();
public List<IModToggleInput> ToggleInputs => _inputs.OfType<IModToggleInput>().ToList();
public List<IModSliderInput> SliderInputs => _inputs.OfType<IModSliderInput>().ToList();
public List<IModSelectorInput> SelectorInputs => _inputs.OfType<IModSelectorInput>().ToList();
public List<IModTextInput> TextInputs => _inputs.OfType<IModTextInput>().ToList();
public List<IModComboInput> ComboInputs => _inputs.OfType<IModComboInput>().ToList();
public List<IModNumberInput> NumberInputs => _inputs.OfType<IModNumberInput>().ToList();
public List<IModSeparator> Separators { get; private set; } public List<IModSeparator> Separators { get; private set; }
protected LayoutGroup Layout; protected LayoutGroup Layout;
protected IModConsole Console; protected IModConsole Console;
private List<IModInputBase> _inputs;
public ModMenu(IModConsole console) => public ModMenu(IModConsole console) =>
Console = console; Console = console;
@ -58,23 +60,18 @@ namespace OWML.ModHelper.Menus
Menu = menu; Menu = menu;
Layout = layoutGroup; Layout = layoutGroup;
var promptButtons = Menu.GetComponentsInChildren<ButtonWithHotkeyImageElement>(true) var promptButtons = Menu.GetComponentsInChildren<ButtonWithHotkeyImageElement>(true).Select(x => x.GetComponent<Button>()).ToList();
.Select(x => x.GetComponent<Button>()).ToList(); BaseButtons = new List<IModButtonBase>()
BaseButtons = promptButtons.Select(x => new ModPromptButton(x, this, Console)).Cast<IModButtonBase>().ToList(); .Concat(promptButtons.Select(x => new ModPromptButton(x, this, Console)).Cast<IModButtonBase>())
.Concat(Menu.GetComponentsInChildren<Button>(true).Except(promptButtons).Select(x => new ModTitleButton(x, this)).Cast<IModButtonBase>())
.ToList();
var ordinaryButtons = Menu.GetComponentsInChildren<Button>(true).Except(promptButtons); _inputs = new List<IModInputBase>()
BaseButtons.AddRange(ordinaryButtons.Select(x => new ModTitleButton(x, this)).Cast<IModButtonBase>().ToList()); .Concat(Menu.GetComponentsInChildren<TwoButtonToggleElement>(true).Select(x => new ModToggleInput(x, this)).Cast<IModInputBase>())
.Concat(Menu.GetComponentsInChildren<SliderElement>(true).Select(x => new ModSliderInput(x, this)).Cast<IModInputBase>())
.Concat(Menu.GetComponentsInChildren<OptionsSelectorElement>(true).Select(x => new ModSelectorInput(x, this)).Cast<IModInputBase>())
.ToList();
ToggleInputs = Menu.GetComponentsInChildren<TwoButtonToggleElement>(true)
.Select(x => new ModToggleInput(x, this)).Cast<IModToggleInput>().ToList();
SliderInputs = Menu.GetComponentsInChildren<SliderElement>(true)
.Select(x => new ModSliderInput(x, this)).Cast<IModSliderInput>().ToList();
SelectorInputs = Menu.GetComponentsInChildren<OptionsSelectorElement>(true)
.Select(x => new ModSelectorInput(x, this)).Cast<IModSelectorInput>().ToList();
TextInputs = new List<IModTextInput>();
NumberInputs = new List<IModNumberInput>();
ComboInputs = new List<IModComboInput>();
Separators = new List<IModSeparator>(); Separators = new List<IModSeparator>();
} }
@ -129,7 +126,7 @@ namespace OWML.ModHelper.Menus
public IModToggleInput AddToggleInput(IModToggleInput input, int index) public IModToggleInput AddToggleInput(IModToggleInput input, int index)
{ {
ToggleInputs.Add(input); _inputs.Add(input);
AddInput(input, index); AddInput(input, index);
return input; return input;
} }
@ -142,7 +139,7 @@ namespace OWML.ModHelper.Menus
public IModSliderInput AddSliderInput(IModSliderInput input, int index) public IModSliderInput AddSliderInput(IModSliderInput input, int index)
{ {
SliderInputs.Add(input); _inputs.Add(input);
AddInput(input, index); AddInput(input, index);
return input; return input;
} }
@ -155,7 +152,7 @@ namespace OWML.ModHelper.Menus
public IModSelectorInput AddSelectorInput(IModSelectorInput input, int index) public IModSelectorInput AddSelectorInput(IModSelectorInput input, int index)
{ {
SelectorInputs.Add(input); _inputs.Add(input);
AddInput(input, index); AddInput(input, index);
return input; return input;
} }
@ -168,7 +165,7 @@ namespace OWML.ModHelper.Menus
public IModTextInput AddTextInput(IModTextInput input, int index) public IModTextInput AddTextInput(IModTextInput input, int index)
{ {
TextInputs.Add(input); _inputs.Add(input);
AddInput(input, index); AddInput(input, index);
return input; return input;
} }
@ -181,7 +178,7 @@ namespace OWML.ModHelper.Menus
public IModComboInput AddComboInput(IModComboInput input, int index) public IModComboInput AddComboInput(IModComboInput input, int index)
{ {
ComboInputs.Add(input); _inputs.Add(input);
AddInput(input, index); AddInput(input, index);
return input; return input;
} }
@ -194,7 +191,7 @@ namespace OWML.ModHelper.Menus
public IModNumberInput AddNumberInput(IModNumberInput input, int index) public IModNumberInput AddNumberInput(IModNumberInput input, int index)
{ {
NumberInputs.Add(input); _inputs.Add(input);
AddInput(input, index); AddInput(input, index);
return input; return input;
} }

View File

@ -65,9 +65,9 @@ namespace OWML.ModHelper.Menus
PopupManager.Initialize(inputMenu); PopupManager.Initialize(inputMenu);
ModsMenu.Initialize(this, MainMenu); ModsMenu.Initialize(this, MainMenu);
} }
catch (Exception) catch (Exception ex)
{ {
_console.WriteLine("Menu system crashed.", MessageType.Error); _console.WriteLine($"Menu system crashed: {ex}", MessageType.Error);
} }
} }
@ -78,9 +78,9 @@ namespace OWML.ModHelper.Menus
PauseMenu.Initialize(settingsManager); PauseMenu.Initialize(settingsManager);
ModsMenu.Initialize(this, PauseMenu); ModsMenu.Initialize(this, PauseMenu);
} }
catch (Exception) catch (Exception ex)
{ {
_console.WriteLine("Menu system crashed.", MessageType.Error); _console.WriteLine($"Menu system crashed: {ex}", MessageType.Error);
} }
} }
} }