-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All Credit for this commit goes to BadRyuner.
-Added Libs. -Added Mod Management GUI. -Modified and renamed Patches.LoadPlugin to include GUI and Config Init. -Added Option to unload mods during runtime.
- Loading branch information
Showing
10 changed files
with
391 additions
and
175 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using UnityEngine; | ||
|
||
namespace PulsarPluginLoader.CustomGUI | ||
{ | ||
public abstract class ModSettingsMenu | ||
{ | ||
public abstract string Name(); | ||
public abstract void Draw(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using UnityEngine; | ||
using static UnityEngine.GUILayout; | ||
|
||
|
||
namespace PulsarPluginLoader.CustomGUI | ||
{ | ||
class PPLSettings : ModSettingsMenu | ||
{ | ||
public override string Name() => "PulsarPluginLoader"; | ||
public override void Draw() | ||
{ | ||
GUI.skin.label.alignment = TextAnchor.UpperLeft; | ||
BeginHorizontal(); | ||
{ | ||
Label($"ModInfoTextAnchor: {PPLConfig.instance.ModInfoTextAnchor.ToString()}"); | ||
|
||
if (Button("<")) | ||
PPLConfig.instance.ModInfoTextAnchor = Enum.GetValues(typeof(TextAnchor)).Cast<TextAnchor>().SkipWhile(e => (int)e != (int)PPLConfig.instance.ModInfoTextAnchor - 1).First(); | ||
if (Button(">")) | ||
PPLConfig.instance.ModInfoTextAnchor = Enum.GetValues(typeof(TextAnchor)).Cast<TextAnchor>().SkipWhile(e => (int)e != (int)PPLConfig.instance.ModInfoTextAnchor).Skip(1).First(); | ||
} | ||
EndHorizontal(); | ||
BeginHorizontal(); | ||
{ | ||
if (Button("Save")) PPLConfig.SaveConfig(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/PulsarPluginLoaderConfig.json"); | ||
if (Button("Reset to default")) PPLConfig.CreateDefaultConfig(string.Empty, false); | ||
} | ||
EndHorizontal(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.IO; | ||
using System.Text.RegularExpressions; | ||
using UnityEngine; | ||
using Valve.Newtonsoft.Json; | ||
using Valve.Newtonsoft.Json.Converters; | ||
|
||
namespace PulsarPluginLoader | ||
{ | ||
public class PPLConfig | ||
{ | ||
internal static PPLConfig instance { get; private set; } | ||
internal PPLConfig(bool @default) | ||
{ | ||
if (@default) | ||
{ | ||
instance = this; | ||
ModInfoTextAnchor = TextAnchor.UpperLeft; | ||
} | ||
} | ||
|
||
internal PPLConfig() => instance = this; | ||
|
||
internal static void CreateDefaultConfig(string path, bool save) | ||
{ | ||
new PPLConfig(true); | ||
if (save) | ||
SaveConfig(path); | ||
} | ||
|
||
internal static void CreateConfigFromFile(string path) => | ||
JsonConvert.DeserializeObject<PPLConfig>(File.ReadAllText(path), settings()); | ||
|
||
internal static void SaveConfig(string path) => | ||
File.WriteAllText(path, JsonConvert.SerializeObject(instance, typeof(PPLConfig), settings())); | ||
//.Replace("{", "{\n\t").Replace("}", "\n}").Replace(",\"", ",\n\t\"")); | ||
|
||
private static JsonSerializerSettings settings() | ||
{ | ||
var settings = new JsonSerializerSettings(); | ||
settings.Formatting = Formatting.Indented; | ||
settings.Converters.Add(new StringEnumConverter() { }); | ||
return settings; | ||
} | ||
|
||
public TextAnchor ModInfoTextAnchor { get; set; } | ||
} | ||
} |
13 changes: 10 additions & 3 deletions
13
PulsarPluginLoader/Patches/LoadPlugins.cs → PulsarPluginLoader/Patches/PLGlobalStart.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.