Skip to content

Commit

Permalink
Merge pull request #288 from SubnauticaModding/dev
Browse files Browse the repository at this point in the history
SMLHelper 2.15.0
  • Loading branch information
MrPurple6411 committed Dec 25, 2022
2 parents 4124baa + ccb7458 commit 0933048
Show file tree
Hide file tree
Showing 129 changed files with 9,193 additions and 4,958 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/version-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
with:
files: |
SMLHelper/Properties/AssemblyInfo.cs | /\[assembly: Assembly(?:File)?Version\("([0-9.]+)"\)\]/g
SMLHelper/mod_BelowZero.json | /"Version": "([0-9.]+)",/g
SMLHelper/mod_Subnautica.json | /"Version": "([0-9.]+)",/g
master_repo_path: ./master

- name: Add annotations
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed Dependencies/Subnautica.stable/0Harmony.dll
Binary file not shown.
2,849 changes: 0 additions & 2,849 deletions Dependencies/Subnautica.stable/0Harmony.xml

This file was deleted.

Binary file added Dependencies/Subnautica.stable/FMODUnity.dll
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/Newtonsoft.Json.dll
Binary file not shown.
Binary file removed Dependencies/Subnautica.stable/QModInstaller.dll
Binary file not shown.
569 changes: 0 additions & 569 deletions Dependencies/Subnautica.stable/QModInstaller.xml

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.AudioModule.dll
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.CoreModule.dll
Binary file not shown.
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.PhysicsModule.dll
Binary file not shown.
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.UI.dll
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.UIModule.dll
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.dll
Binary file not shown.
8 changes: 3 additions & 5 deletions Example mod/Example mod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<HintPath>$(Dependencies)\Assembly-CSharp_publicized.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="QModInstaller">
<HintPath>$(Dependencies)\QModInstaller.dll</HintPath>
<Reference Include="UnityEngine">
<HintPath>$(Dependencies)\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
Expand All @@ -63,8 +63,6 @@
<ProjectReference Include="..\SMLHelper\SMLHelper.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="mod.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<PackageReference Include="BepInEx.Core" Version="5.4.21" />
</ItemGroup>
</Project>
85 changes: 47 additions & 38 deletions Example mod/Mod.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
using HarmonyLib;
using QModManager.API.ModLoading;
using SMLHelper.V2.Commands;
using SMLHelper.V2.Handlers;
using SMLHelper.V2.Interfaces;
using SMLHelper.V2.Json;
using SMLHelper.V2.Json.Attributes;
using SMLHelper.V2.Options;
using SMLHelper.V2.Options.Attributes;
using System;
using UnityEngine;
using UnityEngine.UI;
using Logger = QModManager.Utility.Logger;

namespace SMLHelper.V2.Examples
namespace SMLHelper.V2.Examples
{
[QModCore]
public static class ExampleMod
using HarmonyLib;
using SMLHelper.V2.Commands;
using SMLHelper.V2.Handlers;
using SMLHelper.V2.Interfaces;
using SMLHelper.V2.Json;
using SMLHelper.V2.Json.Attributes;
using SMLHelper.V2.Options;
using SMLHelper.V2.Options.Attributes;
using System;
using UnityEngine;
using UnityEngine.UI;
using BepInEx;
using BepInEx.Logging;

[BepInPlugin(GUID, MODNAME, VERSION)]
public class ExampleMod: BaseUnityPlugin
{
private const string
MODNAME = "SMLHelper",
AUTHOR = "The SMLHelper Dev Team",
GUID = "SMLHelperExampleMod",
VERSION = "2.15.0.0";

internal static ManualLogSource LogSource { get; private set; }

/// <summary>
/// A simple SaveDataCache implementation, intended to save the players current position to disk.
/// </summary>
Expand All @@ -26,9 +34,10 @@ internal class SaveData : SaveDataCache
public Vector3 PlayerPosition { get; set; }
}

[QModPatch]
public static void Patch()
public void Awake()
{
LogSource = base.Logger;

/// Here, we are setting up a instance of <see cref="Config"/>, which will automatically generate an
/// options menu using Attributes. The values in this instance will be updated whenever the user changes
/// the corresponding option in the menu.
Expand All @@ -46,9 +55,9 @@ public static void Patch()
// We can use polymorphism to convert it back into a SaveData
// instance, and access its members, such as PlayerPosition.
Logger.Log(Logger.Level.Info,
$"loaded player position from save slot: {data.PlayerPosition}",
showOnScreen: true);
string msg = $"loaded player position from save slot: {data.PlayerPosition}";
LogSource.LogInfo(msg);
ErrorMessage.AddMessage(msg);
};

// Update the player position before saving it
Expand All @@ -62,9 +71,9 @@ public static void Patch()
saveData.OnFinishedSaving += (object sender, JsonFileEventArgs e) =>
{
SaveData data = e.Instance as SaveData;
Logger.Log(Logger.Level.Info,
$"saved player position to save slot: {data.PlayerPosition}",
showOnScreen: true);
string msg = $"saved player position to save slot: {data.PlayerPosition}";
LogSource.LogInfo(msg);
ErrorMessage.AddMessage(msg);
};

/// Here we are registering a console command by use of a delegate. The delegate will respond to the "delegatecommand"
Expand All @@ -90,7 +99,7 @@ public static void Patch()
/// for an example.
ConsoleCommandsHandler.Main.RegisterConsoleCommands(typeof(ExampleMod));

Logger.Log(Logger.Level.Info, "Patched successfully!");
LogSource.LogInfo("Patched successfully!");
}

private delegate string MyCommand(string myString, int myInt, bool myBool);
Expand Down Expand Up @@ -250,8 +259,8 @@ public class Config : ConfigFile
[Button("My button"), OnGameObjectCreated(nameof(MyGameObjectCreatedEvent))]
public void MyButtonClickEvent(ButtonClickedEventArgs e)
{
Logger.Log(Logger.Level.Info, "Button was clicked!");
Logger.Log(Logger.Level.Info, $"{e.Id}");
ExampleMod.LogSource.LogInfo("Button was clicked!");
ExampleMod.LogSource.LogInfo($"{e.Id}");
}

/// <summary>
Expand All @@ -264,8 +273,8 @@ public void MyButtonClickEvent(ButtonClickedEventArgs e)
/// parameter if you do not need the data it contains.</param>
private void MyCheckboxToggleEvent(ToggleChangedEventArgs e)
{
Logger.Log(Logger.Level.Info, "Checkbox value was changed!");
Logger.Log(Logger.Level.Info, $"{e.Value}");
ExampleMod.LogSource.LogInfo("Checkbox value was changed!");
ExampleMod.LogSource.LogInfo($"{e.Value}");
}

/// <summary>
Expand All @@ -283,22 +292,22 @@ private void MyCheckboxToggleEvent(ToggleChangedEventArgs e)
/// it contains.</para></param>
private void MyGenericValueChangedEvent(IModOptionEventArgs e)
{
Logger.Log(Logger.Level.Info, "Generic value changed!");
Logger.Log(Logger.Level.Info, $"{e.Id}: {e.GetType()}");
ExampleMod.LogSource.LogInfo("Generic value changed!");
ExampleMod.LogSource.LogInfo($"{e.Id}: {e.GetType()}");

switch (e)
{
case KeybindChangedEventArgs keybindChangedEventArgs:
Logger.Log(Logger.Level.Info, keybindChangedEventArgs.KeyName);
ExampleMod.LogSource.LogInfo(keybindChangedEventArgs.KeyName);
break;
case ChoiceChangedEventArgs choiceChangedEventArgs:
Logger.Log(Logger.Level.Info, $"{choiceChangedEventArgs.Index}: {choiceChangedEventArgs.Value}");
ExampleMod.LogSource.LogInfo($"{choiceChangedEventArgs.Index}: {choiceChangedEventArgs.Value}");
break;
case SliderChangedEventArgs sliderChangedEventArgs:
Logger.Log(Logger.Level.Info, sliderChangedEventArgs.Value.ToString());
ExampleMod.LogSource.LogInfo(sliderChangedEventArgs.Value.ToString());
break;
case ToggleChangedEventArgs toggleChangedEventArgs:
Logger.Log(Logger.Level.Info, toggleChangedEventArgs.Value.ToString());
ExampleMod.LogSource.LogInfo(toggleChangedEventArgs.Value.ToString());
break;
}
}
Expand All @@ -313,8 +322,8 @@ private void MyGenericValueChangedEvent(IModOptionEventArgs e)
/// as a string as well as the newly created <see cref="GameObject"/>.</param>
private void MyGameObjectCreatedEvent(GameObjectCreatedEventArgs e)
{
Logger.Log(Logger.Level.Info, "GameObject was created");
Logger.Log(Logger.Level.Info, $"{e.Id}: {e.GameObject}");
ExampleMod.LogSource.LogInfo("GameObject was created");
ExampleMod.LogSource.LogInfo($"{e.Id}: {e.GameObject}");
}
}
}
13 changes: 0 additions & 13 deletions Example mod/mod.json

This file was deleted.

104 changes: 0 additions & 104 deletions SMLHelper.Tests/LanguagePatcherTests.cs

This file was deleted.

Loading

0 comments on commit 0933048

Please sign in to comment.