diff --git a/ModMenu/IniFile.cs b/ModMenu/IniFile.cs deleted file mode 100644 index 4f44bdf..0000000 --- a/ModMenu/IniFile.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace LLModMenu -{ - class IniFile // revision 11 - { - string Path; - string EXE = Assembly.GetExecutingAssembly().GetName().Name; - - [DllImport("kernel32", CharSet = CharSet.Unicode)] - static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath); - - [DllImport("kernel32", CharSet = CharSet.Unicode)] - static extern int GetPrivateProfileString(string Section, string Key, string Default, StringBuilder RetVal, int Size, string FilePath); - - public IniFile(string IniPath = null) - { - Path = new FileInfo(IniPath ?? EXE + ".ini").FullName.ToString(); - } - - public string Read(string Key, string Section = null) - { - var RetVal = new StringBuilder(255); - GetPrivateProfileString(Section ?? EXE, Key, "", RetVal, 255, Path); - return RetVal.ToString(); - } - - public void Write(string Key, string Value, string Section = null) - { - WritePrivateProfileString(Section ?? EXE, Key, Value, Path); - } - - public void DeleteKey(string Key, string Section = null) - { - Write(Key, null, Section ?? EXE); - } - - public void DeleteSection(string Section = null) - { - Write(null, null, Section ?? EXE); - } - - public bool KeyExists(string Key, string Section = null) - { - return Read(Key, Section).Length > 0; - } - } -} diff --git a/ModMenu/Libs/0Harmony.dll b/ModMenu/Libs/0Harmony.dll new file mode 120000 index 0000000..1670607 --- /dev/null +++ b/ModMenu/Libs/0Harmony.dll @@ -0,0 +1 @@ +../../../../BepInEx/BepInEx/core/0Harmony.dll \ No newline at end of file diff --git a/ModMenu/Libs/Assembly-CSharp-publicized.dll b/ModMenu/Libs/Assembly-CSharp-publicized.dll new file mode 120000 index 0000000..eb66175 --- /dev/null +++ b/ModMenu/Libs/Assembly-CSharp-publicized.dll @@ -0,0 +1 @@ +../../../../llb_dlls/Assembly-CSharp-publicized.dll \ No newline at end of file diff --git a/ModMenu/Libs/BepInEx.dll b/ModMenu/Libs/BepInEx.dll new file mode 120000 index 0000000..e0a9178 --- /dev/null +++ b/ModMenu/Libs/BepInEx.dll @@ -0,0 +1 @@ +../../../../BepInEx/BepInEx/core/BepInEx.dll \ No newline at end of file diff --git a/ModMenu/Libs/SFB.dll b/ModMenu/Libs/SFB.dll new file mode 120000 index 0000000..6de4a56 --- /dev/null +++ b/ModMenu/Libs/SFB.dll @@ -0,0 +1 @@ +../../../SFB/SFB/bin/Release/SFB.dll \ No newline at end of file diff --git a/ModMenu/Libs/TextMeshPro.dll b/ModMenu/Libs/TextMeshPro.dll new file mode 120000 index 0000000..2e1451a --- /dev/null +++ b/ModMenu/Libs/TextMeshPro.dll @@ -0,0 +1 @@ +../../../../llb_dlls/TextMeshPro.dll \ No newline at end of file diff --git a/ModMenu/Libs/UnityEngine.CoreModule.dll b/ModMenu/Libs/UnityEngine.CoreModule.dll new file mode 120000 index 0000000..e4b7cbe --- /dev/null +++ b/ModMenu/Libs/UnityEngine.CoreModule.dll @@ -0,0 +1 @@ +../../../../llb_dlls/UnityEngine.CoreModule.dll \ No newline at end of file diff --git a/ModMenu/Libs/UnityEngine.IMGUIModule.dll b/ModMenu/Libs/UnityEngine.IMGUIModule.dll new file mode 120000 index 0000000..279cd98 --- /dev/null +++ b/ModMenu/Libs/UnityEngine.IMGUIModule.dll @@ -0,0 +1 @@ +../../../../llb_dlls/UnityEngine.IMGUIModule.dll \ No newline at end of file diff --git a/ModMenu/Libs/UnityEngine.TextCoreModule.dll b/ModMenu/Libs/UnityEngine.TextCoreModule.dll new file mode 120000 index 0000000..a78ec8e --- /dev/null +++ b/ModMenu/Libs/UnityEngine.TextCoreModule.dll @@ -0,0 +1 @@ +../../../../llb_dlls/UnityEngine.TextCoreModule.dll \ No newline at end of file diff --git a/ModMenu/Libs/UnityEngine.TextRenderingModule.dll b/ModMenu/Libs/UnityEngine.TextRenderingModule.dll new file mode 120000 index 0000000..e35bcd2 --- /dev/null +++ b/ModMenu/Libs/UnityEngine.TextRenderingModule.dll @@ -0,0 +1 @@ +../../../../llb_dlls/UnityEngine.TextRenderingModule.dll \ No newline at end of file diff --git a/ModMenu/Libs/UnityEngine.dll b/ModMenu/Libs/UnityEngine.dll new file mode 120000 index 0000000..4e87fd9 --- /dev/null +++ b/ModMenu/Libs/UnityEngine.dll @@ -0,0 +1 @@ +../../../../llb_dlls/UnityEngine.dll \ No newline at end of file diff --git a/ModMenu/ModMenu.cs b/ModMenu/ModMenu.cs old mode 100644 new mode 100755 index 682df02..be11a50 --- a/ModMenu/ModMenu.cs +++ b/ModMenu/ModMenu.cs @@ -1,117 +1,105 @@ using System; +using System.IO; using System.Collections; using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; using UnityEngine; using LLScreen; using LLGUI; -using LLHandlers; -using System.IO; -using System.Text.RegularExpressions; -using System.Linq; +using HarmonyLib; +using BepInEx; +using BepInEx.Configuration; -namespace LLModMenu +namespace ModMenu { - public class ModMenu : MonoBehaviour + [BepInPlugin(PluginInfos.PLUGIN_ID, PluginInfos.PLUGIN_NAME, PluginInfos.PLUGIN_VERSION)] + [BepInDependency(SFB.PluginInfos.PLUGIN_ID, BepInDependency.DependencyFlags.HardDependency)] + [BepInProcess("LLBlaze.exe")] + public class ModMenu : BaseUnityPlugin { - private static ModMenu instance = null; - public static ModMenu Instance { get { return instance; } } - public static void Initialize() { GameObject gameObject = new GameObject("ModMenu"); ModMenu modLoader = gameObject.AddComponent(); DontDestroyOnLoad(gameObject); instance = modLoader; ModMenuStyle.InitStyle(); } + public static ModMenu Instance { get; private set; } = null; + public static Dictionary> registeredMods = new Dictionary>(); + public void Awake() + { + Instance = this; + ModMenuStyle.InitStyle(); + } - public LLButton button = null; - public List mods = new List(); + private readonly Array keyCodes = System.Enum.GetValues(typeof(KeyCode)); + + private ScreenMenu mainmenu = null; + private ScreenBase submenu = null; + private LLButton modSettingsButton = null; public List modButtons = new List(); - public bool inModOptions = false; - public bool inModSubOptions = false; - public ScreenMenu mainmenu = null; - public ScreenBase submenu = null; - public Dictionary configKeys = new Dictionary(); - public Dictionary configBools = new Dictionary(); - public Dictionary configInts = new Dictionary(); - public List intList = new List(); - public Dictionary configHeaders = new Dictionary(); - public Dictionary configSliders = new Dictionary(); - public List sliderList = new List(); - public Dictionary configText = new Dictionary(); - public List optionsQueue = new List(); - - public string currentOpenMod = ""; - public string newKey = ""; - public Vector2 keybindScrollpos = new Vector2(0,0); + + public Vector2 keybindScrollpos = new Vector2(0, 0); public Vector2 optionsScrollpos = new Vector2(0, 0); public Vector2 optionsTextpos = new Vector2(0, 0); - public ModMenuIntegration MMI = null; + private BepInEx.PluginInfo currentOpenMod; + private BepInEx.PluginInfo previousOpenMod; - public int switchInputModeTimer = 0; - - private string modVersion = "v1.1.0"; - private string iniLocation = Path.GetDirectoryName(Application.dataPath) + "\\ModSettings"; + private bool sliderChange = false; + private ConfigDefinition definitionToRebind = null; + private bool rebindingKey = false; + private bool inModOptions = false; + public static bool InModOptions() => Instance.inModOptions; + private bool inModSubOptions = false; + public static void RegisterMod(BepInEx.PluginInfo pluginInfo, List modmenu_textinfo = null) + { + registeredMods.Add(pluginInfo, modmenu_textinfo); + } private void Update() { - if (!Directory.Exists(iniLocation)) Directory.CreateDirectory(iniLocation); - if (mainmenu == null) { mainmenu = FindObjectOfType(); } - if (submenu == null) { submenu = UIScreen.currentScreens[1]; } - else + if (this.sliderChange && Input.GetKeyUp(KeyCode.Mouse0)) { + this.currentOpenMod.Instance.Config.Save(); + this.currentOpenMod.Instance.Config.SaveOnConfigSet = true; + this.sliderChange = false; + } - List buttons = new List(); - if (submenu.screenType == ScreenType.MENU_OPTIONS && button == null) + if (this.rebindingKey && Input.anyKeyDown) + { + foreach (KeyCode keyCode in keyCodes) { - ScreenMenuOptions SMO = FindObjectOfType(); - buttons.Add(SMO.btGame); - buttons.Add(SMO.btInput); - buttons.Add(SMO.btAudio); - buttons.Add(SMO.btVideo); - buttons.Add(SMO.btCredits); - - button = Instantiate(buttons[4], buttons[4].transform, true); - button.name = "btMods"; - button.SetText("mod settings"); - button.onClick = new LLClickable.ControlDelegate(this.ModSettingsClick); - - buttons.Add(button); - - for(var i = 0; i < buttons.Count(); i++) + if (Input.GetKey(keyCode)) { - Vector3 scale = buttons[i].transform.localScale; - - int modx = 2560; - int mody = 1440; - - if (buttons[i] == button) - { - buttons[i].transform.localPosition = new Vector3(buttons[i].transform.localPosition.x - ((modx / 100) * 1), buttons[i].transform.localPosition.y - ((mody / 100) * 9.5f)); - } - else if (buttons[i] != SMO.btGame) - { - buttons[i].transform.localPosition = new Vector3(SMO.btGame.transform.localPosition.x - (((modx / 100) * 0.55f) * i), SMO.btGame.transform.localPosition.y - (((mody / 100) * 5.3f) * i)); - buttons[i].transform.localScale = new Vector3(scale.x * 0.85f, scale.y * 0.85f, scale.z); - } - else - { - buttons[i].transform.localPosition = new Vector3(-((modx / 100)*8.375f), ((mody / 100) * 12.625f)); - buttons[i].transform.localScale = new Vector3(scale.x * 0.85f, scale.y * 0.85f, scale.z); - } + ConfigFile modConfig = this.currentOpenMod.Instance.Config; + modConfig[this.definitionToRebind].BoxedValue = keyCode; + modConfig.Save(); + this.rebindingKey = false; } } } + if (mainmenu == null && UIScreen.currentScreens[0] is ScreenMenu screen0) + mainmenu = screen0; + if (submenu == null) + { + submenu = UIScreen.currentScreens[1]; + } + else + { + if (submenu.screenType == ScreenType.MENU_OPTIONS && modSettingsButton == null) + { + modSettingsButton = this.InitModSettingsButton(); + } + } - if (switchInputModeTimer != 30) switchInputModeTimer++; - - if (inModSubOptions) //If we are within the options of a spiesific mod. + if (inModSubOptions && this.currentOpenMod != this.previousOpenMod) //If we are within the options of a spiesific mod. { - Component comp = GameObject.Find(currentOpenMod).GetComponent(currentOpenMod); //Get the script for that mod. - comp.SendMessage("ReadIni"); //Tell it to run the "ReadIni" method. + this.previousOpenMod = this.currentOpenMod; } - if (Controller.mouseKeyboard.GetButton(InputAction.ESC)) + if (inModOptions) { - if (inModOptions) + if (LLHandlers.Controller.mouseKeyboard.GetButton(LLHandlers.InputAction.ESC)) { + this.previousOpenMod = null; UIScreen.Open(ScreenType.MENU_OPTIONS, 1, ScreenTransition.MOVE_RIGHT); inModOptions = false; inModSubOptions = false; @@ -119,34 +107,44 @@ private void Update() } } - private void ModSettingsClick(int playerNr) + #region Handles + public void HandleModSettingsClick(int playerNr) { ScreenBase screen = UIScreen.Open(ScreenType.OPTIONS, 1); inModOptions = true; - GameObject.Find("btQuit").GetComponent().onClick = new LLClickable.ControlDelegate(QuitClick); + GameObject.Find("btQuit").GetComponent().onClick = new LLClickable.ControlDelegate(this.HandleQuitClick); mainmenu.lbTitle.text = "MOD SETTINGS"; var vcount = 0; var hcount = 0; - - foreach (string mod in mods) + foreach (BepInEx.PluginInfo plugin in registeredMods.Keys) { - var obj = Instantiate(button, screen.transform); - obj.SetText(mod, 50); + var obj = Instantiate(modSettingsButton, screen.transform); + obj.SetText(plugin.Metadata.Name, 50); obj.transform.localScale = new Vector3(0.4f, 0.3f); obj.transform.position = new Vector3(-1.5f + (0.75f * hcount), 0.80f - (0.125f * vcount)); - obj.onClick = delegate (int pNr) { ModSubSettingsClick(mod); }; + obj.onClick = delegate (int pNr) { this.HandleModSubSettingsClick(plugin); }; modButtons.Add(obj); if (vcount < 12) { vcount++; } else { hcount++; vcount = 0; } } } - private void QuitClick(int playerNr) + private void HandleModSubSettingsClick(BepInEx.PluginInfo plugin) + { + inModSubOptions = true; + currentOpenMod = plugin; + ScreenBase screen = UIScreen.Open(ScreenType.OPTIONS, 1); + mainmenu.lbTitle.text = plugin.Metadata.Name.ToUpper() + " SETTINGS"; + } + + private void HandleQuitClick(int playerNr) { + this.previousOpenMod = null; if (inModOptions == true) { UIScreen.Open(ScreenType.MENU_OPTIONS, 1); - } else + } + else { if (submenu != null) { @@ -165,115 +163,131 @@ private void QuitClick(int playerNr) mainmenu.lbTitle.text = "OPTIONS"; inModOptions = false; inModSubOptions = false; - AudioHandler.PlayMenuSfx(Sfx.MENU_BACK); - AudioHandler.PlayMenuSfx(Sfx.MENU_CONFIRM); + LLHandlers.AudioHandler.PlayMenuSfx(LLHandlers.Sfx.MENU_BACK); + LLHandlers.AudioHandler.PlayMenuSfx(LLHandlers.Sfx.MENU_CONFIRM); } } + #endregion + + public LLButton InitModSettingsButton() + { + LLButton _modSettingsButton = null; + List buttons = new List(); + ScreenMenuOptions SMO = FindObjectOfType(); + buttons.Add(SMO.btGame); + buttons.Add(SMO.btInput); + buttons.Add(SMO.btAudio); + buttons.Add(SMO.btVideo); + buttons.Add(SMO.btCredits); + + _modSettingsButton = Instantiate(buttons[4], buttons[4].transform, true); + _modSettingsButton.name = "btMods"; + _modSettingsButton.SetText("mod settings"); + _modSettingsButton.onClick = new LLClickable.ControlDelegate(this.HandleModSettingsClick); + + buttons.Add(_modSettingsButton); + + for (var i = 0; i < buttons.Count(); i++) + { + if (buttons[i] == null) continue; + Vector3 scale = buttons[i].transform.localScale; + + int modx = 2560; + int mody = 1440; + + if (buttons[i] == _modSettingsButton) + { + buttons[i].transform.localPosition = new Vector3(buttons[i].transform.localPosition.x - ((modx / 100) * 1), buttons[i].transform.localPosition.y - ((mody / 100) * 9.5f)); + } + else if (buttons[i] != SMO.btGame) + { + buttons[i].transform.localPosition = new Vector3(SMO.btGame.transform.localPosition.x - (((modx / 100) * 0.55f) * i), SMO.btGame.transform.localPosition.y - (((mody / 100) * 5.3f) * i)); + buttons[i].transform.localScale = new Vector3(scale.x * 0.85f, scale.y * 0.85f, scale.z); + } + else + { + buttons[i].transform.localPosition = new Vector3(-((modx / 100) * 8.375f), ((mody / 100) * 12.625f)); + buttons[i].transform.localScale = new Vector3(scale.x * 0.85f, scale.y * 0.85f, scale.z); + } + } + + return _modSettingsButton; + } #region GUIStuff + + private GUI.WindowFunction keybindWindowFunction = null; + private GUI.WindowFunction optionsWindowFunction = null; + private GUI.WindowFunction textWindowFunction = null; private void OnGUI() { + + + if (keybindWindowFunction == null) + keybindWindowFunction = new GUI.WindowFunction(OpenKeybindsWindow); + if (optionsWindowFunction == null) + optionsWindowFunction = new GUI.WindowFunction(OpenOptionsWindow); + if (textWindowFunction == null) + textWindowFunction = new GUI.WindowFunction(OpenTextWindow); + var x1 = Screen.width / 6; var y1 = Screen.height / 10; - var x2 = Screen.width - (Screen.width/6)*2; + var x2 = Screen.width - (Screen.width / 6) * 2; var y2 = Screen.height - (Screen.height / 6); - if (inModSubOptions) { - GUIContent guic = new GUIContent(" ModMenu " + modVersion + " "); + GUIContent guic = new GUIContent(" ModMenu " + this.Info.Metadata.Version + " "); Vector2 calc = GUI.skin.box.CalcSize(guic); - GUI.Box(new Rect(10, 10, calc.x, calc.y), "ModMenu " + modVersion, ModMenuStyle.versionBox); - GUI.Window(0, new Rect(x1, y1, x2, y2 / 3), new GUI.WindowFunction(OpenKeybindsWindow), "Keybindings", ModMenuStyle.windStyle); - GUI.Window(1, new Rect(x1, y1 + y2 / 3 + 10, x2, y2 / 3), new GUI.WindowFunction(OpenOptionsWindow), "Options", ModMenuStyle.windStyle); - GUI.Window(2, new Rect(x1, y1 + ((y2 / 3 + 10)*2), x2, y2 / 5), new GUI.WindowFunction(OpenTextWindow), "Mod Information", ModMenuStyle.windStyle); - GUI.skin.window = null; - } - GUI.skin.label.fontSize = 15; - } + GUI.Box(new Rect(10, 10, calc.x + 20, calc.y), "ModMenu " + this.Info.Metadata.Version, ModMenuStyle.versionBox); - private void ModSubSettingsClick(string modName) - { - inModSubOptions = true; - currentOpenMod = modName; - ScreenBase screen = UIScreen.Open(ScreenType.OPTIONS, 1); - mainmenu.lbTitle.text = modName.ToUpper() + " SETTINGS"; - configKeys.Clear(); - configBools.Clear(); - configInts.Clear(); - intList.Clear(); - configSliders.Clear(); - sliderList.Clear(); - configHeaders.Clear(); - configText.Clear(); - - string[] lines = File.ReadAllLines(iniLocation + @"\" + modName + ".ini"); - foreach (string line in lines) - { - if (line.StartsWith("(key)")) - { - string[] split = line.Split('='); - configKeys.Add(split[0], split[1]); - } - else if (line.StartsWith("(bool)")) + GUI.Window(0, new Rect(x1, y1, x2, y2 / 3), keybindWindowFunction, "Keybindings", ModMenuStyle.windStyle); + if (registeredMods[currentOpenMod] != null) { - string[] split = line.Split('='); - configBools.Add(split[0], split[1]); + GUI.Window(1, new Rect(x1, y1 + y2 / 3 + 10, x2, y2 / 3), optionsWindowFunction, "Options", ModMenuStyle.windStyle); + GUI.Window(2, new Rect(x1, y1 + ((y2 / 3 + 10) * 2), x2, y2 / 5), textWindowFunction, "Mod Information", ModMenuStyle.windStyle); } - else if (line.StartsWith("(int)")) + else { - string[] split = line.Split('='); - configInts.Add(split[0], split[1]); - intList.Add(split[1]); + GUI.Window(1, new Rect(x1, y1 + y2 / 3 + 10, x2, 2 * y2 / 3), optionsWindowFunction, "Options", ModMenuStyle.windStyle); } - else if (line.StartsWith("(slider)")) - { - string[] split = line.Split('='); - configSliders.Add(split[0], split[1]); - string[] valMinMax = split[1].Split('|'); - sliderList.Add(float.Parse(valMinMax[0])); - } - else if (line.StartsWith("(header)")) - { - string[] split = line.Split('='); - configHeaders.Add(split[0], split[1]); - } - else if (line.StartsWith("(text)")) - { - string[] split = line.Split('='); - configText.Add(split[0], split[1]); - } + GUI.skin.window = null; } + GUI.skin.label.fontSize = 15; } - - private void OpenKeybindsWindow(int wId) { GUILayout.Space(30); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); keybindScrollpos = GUILayout.BeginScrollView(keybindScrollpos, false, true); - var keyList = new List(); - if (configKeys.Count > 0) + + ConfigFile modConfig = currentOpenMod.Instance.Config; + + foreach (ConfigDefinition setting in modConfig.Keys.Where((ConfigDefinition setting) => modConfig[setting].SettingType == typeof(KeyCode))) { - foreach (KeyValuePair keyval in configKeys) keyList.Add(keyval.Key); + string formatted = UppercaseFirst(Regex.Replace(setting.Key, "([a-z])([A-Z])", "$1 $2")); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label(formatted + ":", ModMenuStyle.labStyle); + GUILayout.Space(10); - foreach (string key in keyList) + string displayText; + + if (this.rebindingKey && setting == this.definitionToRebind) + displayText = "WAITING FOR KEY"; + else + displayText = currentOpenMod.Instance.Config[setting].BoxedValue.ToString(); + + if (GUILayout.Button("[" + displayText + "]", ModMenuStyle.button, GUILayout.MinWidth(100))) { - string format = key.Remove(0, 5); - string formatted = UppercaseFirst(Regex.Replace(format, "([a-z])([A-Z])", "$1 $2")); - GUILayout.BeginHorizontal(); - GUILayout.FlexibleSpace(); - GUILayout.Label(formatted + ":", ModMenuStyle.labStyle); - GUILayout.Space(10); - if (GUILayout.Button("[" + configKeys[key] + "]", ModMenuStyle.button, GUILayout.MinWidth(100))) - { - StartCoroutine(BindKey(key)); - } - GUILayout.FlexibleSpace(); - GUILayout.EndHorizontal(); + this.rebindingKey = true; + this.definitionToRebind = setting; } + + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); @@ -286,277 +300,304 @@ private void OpenOptionsWindow(int wId) GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); optionsScrollpos = GUILayout.BeginScrollView(optionsScrollpos, false, true); + ConfigFile modConfig = currentOpenMod.Instance.Config; - optionsQueue = GetOptionsQueue(currentOpenMod); - int bools = 0; - int ints = 0; - int sliders = 0; - int headers = 0; - - if (optionsQueue != null) + foreach (ConfigDefinition setting in modConfig.Keys) { - foreach (string option in optionsQueue) + object[] settingTags = modConfig[setting].Description.Tags; + Type settingType = modConfig[setting].SettingType; + + if (modConfig[setting].Description.Tags.Contains("modmenu_hidden")) + { + continue; + } + else if (settingTags.Contains("modmenu_filepicker") || + settingTags.Contains("modmenu_directorypicker")) + { + MakeFilePickerSettingGUI(modConfig, setting); + } + else if (settingTags.Contains("modmenu_header")) + { + MakeHeaderGUI(modConfig, setting); + } + else if (settingTags.Contains("modmenu_gap")) + { + MakeGapGUI(modConfig, setting); + } + else if (settingType == typeof(bool)) { - if (option == "(bool)") + MakeBoolSettingGUI(modConfig, setting); + } + else if (settingType == typeof(int)) + { + if (modConfig[setting].Description?.AcceptableValues is AcceptableValueRange + // TODO NYI || modConfig[setting].Description.AcceptableValues is AcceptableValueRange + ) { - var key = configBools.Keys.ElementAt(bools); - var val = configBools.Values.ElementAt(bools); - string format = key.Remove(0, 6); - string formatted = UppercaseFirst(Regex.Replace(format, "([a-z])([A-Z])", "$1 $2")); - GUILayout.BeginHorizontal(); - GUILayout.FlexibleSpace(); - GUILayout.Label(formatted + ":", ModMenuStyle.labStyle); - GUILayout.Space(10); - var str = ""; - if (val == "true") str = "Enabled"; - else str = "Disabled"; - - if (GUILayout.Button(str, ModMenuStyle.button, GUILayout.MinWidth(100))) - { - IniFile modIni = new IniFile(iniLocation + @"\" + currentOpenMod + ".ini"); - if (val == "true") - { - modIni.Write(key, "false"); - configBools[key] = "false"; - } - else - { - modIni.Write(key, "true"); - configBools[key] = "true"; - } - } - GUILayout.FlexibleSpace(); - GUILayout.EndHorizontal(); - bools++; + MakeSliderSettingGUI(modConfig, setting); } - else if (option == "(int)") + else { - var key = configInts.Keys.ElementAt(ints); - string format = key.Remove(0, 5); - string formatted = UppercaseFirst(Regex.Replace(format, "([a-z])([A-Z])", "$1 $2")); - GUILayout.BeginHorizontal(); - GUILayout.FlexibleSpace(); - - GUILayout.Label(formatted + ": ", ModMenuStyle.labStyle); - GUILayout.Box(configInts[key], ModMenuStyle.box); - GUILayout.Space(10); - if (GUILayout.Button(" - ", ModMenuStyle.button)) - { - IniFile modIni = new IniFile(iniLocation + @"\" + currentOpenMod + ".ini"); - var j = Convert.ToInt32(configInts[key]); - j--; - modIni.Write(key, j.ToString()); - configInts[key] = j.ToString(); - } - - if (GUILayout.Button(" + ", ModMenuStyle.button)) - { - IniFile modIni = new IniFile(iniLocation + @"\" + currentOpenMod + ".ini"); - var j = Convert.ToInt32(configInts[key]); - j++; - modIni.Write(key, j.ToString()); - configInts[key] = j.ToString(); - } - - GUILayout.Space(30); - - intList[ints] = GUILayout.TextField(intList[ints].ToString(), 10, ModMenuStyle._textFieldStyle, GUILayout.MinWidth(32)); - - if (GUILayout.Button("Set Value From Textbox", ModMenuStyle.button)) - { - IniFile modIni = new IniFile(iniLocation + @"\" + currentOpenMod + ".ini"); - if (Int32.TryParse(intList[ints], out int n)) - { - modIni.Write(key, intList[ints]); - configInts[key] = intList[ints]; - } - } - GUILayout.FlexibleSpace(); - GUILayout.EndHorizontal(); - ints++; + MakeNumericSettingGUI(modConfig, setting); } - else if (option == "(slider)") - { - IniFile modIni = new IniFile(iniLocation + @"\" + currentOpenMod + ".ini"); + } + else if (settingType == typeof(string)) + { + MakeStringSettingGUI(modConfig, setting); + } + } - var key = configSliders.Keys.ElementAt(sliders); - string format = key.Remove(0, 8); - string formatted = UppercaseFirst(Regex.Replace(format, "([a-z])([A-Z])", "$1 $2")); + GUILayout.EndScrollView(); + GUILayout.EndVertical(); + GUILayout.EndHorizontal(); + } - string[] valMinMax = configSliders[key].Split('|'); + private void MakeHeaderGUI(ConfigFile modConfig, ConfigDefinition setting) + { + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Box((string)modConfig[setting].BoxedValue, ModMenuStyle.headerBox); + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + } - GUILayout.BeginHorizontal(); - GUILayout.FlexibleSpace(); + private void MakeGapGUI(ConfigFile modConfig, ConfigDefinition setting) + { + Type settingType = modConfig[setting].SettingType; + if (settingType == typeof(int)) + { + GUILayout.Space((int)modConfig[setting].BoxedValue); + } + else if (Int32.TryParse((string)modConfig[setting].BoxedValue, out int n)) + { + GUILayout.Space(n); + } + else + { + GUILayout.Space(20); + } + } - GUILayout.Label(formatted + ": ", ModMenuStyle.labStyle); - sliderList[sliders] = GUILayout.HorizontalSlider(sliderList[sliders], float.Parse(valMinMax[1]), float.Parse(valMinMax[2]), ModMenuStyle._sliderBackgroundStyle, ModMenuStyle._sliderThumbStyle, GUILayout.Width(300)); - GUILayout.Box(System.Math.Round(Double.Parse(sliderList[sliders].ToString())).ToString(), ModMenuStyle.box); + private void MakeBoolSettingGUI(ConfigFile modConfig, ConfigDefinition setting) + { - modIni.Write(key, System.Math.Round(Double.Parse(sliderList[sliders].ToString())).ToString() + "|" + valMinMax[1] + "|" + valMinMax[2]); + bool val = (bool)modConfig[setting].BoxedValue; + string formatted = UppercaseFirst(Regex.Replace(setting.Key, "([a-z])([A-Z])", "$1 $2")); - GUILayout.FlexibleSpace(); - GUILayout.EndHorizontal(); - sliders++; - } - else if (option == "(header)") - { - var key = configHeaders.Keys.ElementAt(headers); - GUILayout.BeginHorizontal(); - GUILayout.FlexibleSpace(); - GUILayout.Box(configHeaders[key], ModMenuStyle.headerBox); - GUILayout.FlexibleSpace(); - GUILayout.EndHorizontal(); - headers++; - } - else if (option == "(gap)") - { - GUILayout.Space(20); - } - } - } + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label(formatted + ":", ModMenuStyle.labStyle); + GUILayout.Space(10); - GUILayout.EndScrollView(); - GUILayout.EndVertical(); + var str = ""; + if (val) str = "Enabled"; + else str = "Disabled"; + + bool isPressed = GUILayout.Button(str, ModMenuStyle.button, GUILayout.MinWidth(100)); + if (isPressed) + { + modConfig[setting].BoxedValue = !val; + modConfig.Save(); + } + GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } - private void OpenTextWindow(int wId) + private void MakeNumericSettingGUI(ConfigFile modConfig, ConfigDefinition setting) { + int value = (int)modConfig[setting].BoxedValue; + + string formatted = UppercaseFirst(Regex.Replace(setting.Key, "([a-z])([A-Z])", "$1 $2")); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label(formatted + ": ", ModMenuStyle.labStyle); + GUILayout.Box(value.ToString(), ModMenuStyle.box); + GUILayout.Space(10); + + bool isMinusPressed = GUILayout.Button(" - ", ModMenuStyle.button); + bool isPlusPressed = GUILayout.Button(" + ", ModMenuStyle.button); + + GUILayout.Space(30); - GUILayout.BeginVertical(); - optionsTextpos = GUILayout.BeginScrollView(optionsTextpos, false, true); - if (configText.Count > 0) + string intValue = GUILayout.TextField(value.ToString(), 10, ModMenuStyle._textFieldStyle, GUILayout.MinWidth(32)); + + bool isFromTextPressed = GUILayout.Button("Set Value From Textbox", ModMenuStyle.button); + + if (isPlusPressed) + { + modConfig[setting].BoxedValue = value + 1; + modConfig.Save(); + } + else if (isMinusPressed) { - foreach (KeyValuePair keyval in configText) + modConfig[setting].BoxedValue = value - 1; + modConfig.Save(); + } + else if (Int32.TryParse(intValue, out int n)) + { + if ((int)modConfig[setting].BoxedValue != n) { - GUILayout.BeginHorizontal(); - GUILayout.Label(keyval.Value, ModMenuStyle.readStyle); - GUILayout.EndHorizontal(); + modConfig[setting].BoxedValue = n; + modConfig.Save(); + } + if (isFromTextPressed) + { + modConfig[setting].BoxedValue = n; + modConfig.Save(); } } + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + } - GUILayout.EndScrollView(); - GUILayout.EndVertical(); + private void MakeSliderSettingGUI(ConfigFile modConfig, ConfigDefinition setting) + { + int storedSliderValue = (int)modConfig[setting].BoxedValue; + AcceptableValueRange range = modConfig[setting].Description.AcceptableValues as AcceptableValueRange; + string formatted = UppercaseFirst(Regex.Replace(setting.Key, "([a-z])([A-Z])", "$1 $2")); + + float sliderValue = storedSliderValue; + + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label(formatted + ": ", ModMenuStyle.labStyle); + sliderValue = GUILayout.HorizontalSlider(sliderValue, (float)range.MinValue, (float)range.MaxValue, ModMenuStyle._sliderBackgroundStyle, ModMenuStyle._sliderThumbStyle, GUILayout.Width(300)); + GUILayout.Box(System.Math.Round(Double.Parse(sliderValue.ToString())).ToString(), ModMenuStyle.box); + + int newSliderValue = (int)System.Math.Round(sliderValue); + if (newSliderValue != storedSliderValue) + { + modConfig.SaveOnConfigSet = false; + this.sliderChange = true; + modConfig[setting].BoxedValue = newSliderValue; + } + + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); } - public void WriteIni(string modName, List writeQueue, Dictionary keyBinds, Dictionary bools, Dictionary ints, Dictionary sliders, Dictionary headers, Dictionary gaps, Dictionary text) + private void MakeStringSettingGUI(ConfigFile modConfig, ConfigDefinition setting) { + string value = (string)modConfig[setting].BoxedValue; + + string formatted = UppercaseFirst(Regex.Replace(setting.Key, "([a-z])([A-Z])", "$1 $2")); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label(formatted + ": ", ModMenuStyle.labStyle); + GUILayout.Space(30); - if (File.Exists(iniLocation + @"\" + modName + ".ini")) + string textFieldString = GUILayout.TextField(value, 256, ModMenuStyle._textFieldStyle, GUILayout.MinWidth(120)); + + + GUIStyle test = ModMenuStyle.button; + if ((string)modConfig[setting].BoxedValue != textFieldString) { - string[] lines = File.ReadAllLines(iniLocation + @"\" + modName + ".ini"); - foreach (string key in writeQueue) - { - try - { - if (!lines[writeQueue.IndexOf(key) + 1].Contains(key)) - { - Debug.Log("ModMenu: " + iniLocation + @"\" + modName + ".ini has been remade because it did not match what was expected"); - File.Delete(iniLocation + @"\" + modName + ".ini"); - break; - }; - } catch - { - Debug.Log("ModMenu: " + iniLocation + @"\" + modName + ".ini has been remade because it did not match what was expected"); - File.Delete(iniLocation + @"\" + modName + ".ini"); - break; - } - } + test.fontStyle = FontStyle.Bold; + modConfig.SaveOnConfigSet = false; + modConfig[setting].BoxedValue = textFieldString; } - IniFile modIni = new IniFile(iniLocation + @"\" + modName + ".ini"); + bool isFromTextPressed = GUILayout.Button("Set Value", test); + if (isFromTextPressed) + { + modConfig.Save(); + modConfig.SaveOnConfigSet = true; + } + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + } + + private void MakeFilePickerSettingGUI(ConfigFile modConfig, ConfigDefinition setting) + { + string value = (string)modConfig[setting].BoxedValue; + string formatted = UppercaseFirst(Regex.Replace(setting.Key, "([a-z])([A-Z])", "$1 $2")); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label(formatted + ": ", ModMenuStyle.labStyle); + GUILayout.Space(30); + string textFieldString = GUILayout.TextField(value, 256, ModMenuStyle._textFieldStyle, GUILayout.MinWidth(120)); - if (writeQueue.Count() > 0) + GUIStyle llbButtonStyle = ModMenuStyle.button; + if ((string)modConfig[setting].BoxedValue != textFieldString) + { + llbButtonStyle.fontStyle = FontStyle.Bold; + modConfig.SaveOnConfigSet = false; + modConfig[setting].BoxedValue = textFieldString; + } + + bool isFromTextPressed = GUILayout.Button("Set Value", llbButtonStyle); + bool isBrowseFilesPressed = GUILayout.Button("Browse Files", ModMenuStyle.button); + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + + if (isFromTextPressed) + { + modConfig.Save(); + modConfig.SaveOnConfigSet = true; + return; + } + if (isBrowseFilesPressed) { - foreach (string key in writeQueue) + object[] settingTags = modConfig[setting].Description.Tags; + if (settingTags.Contains("modmenu_directorypicker")) { - if (key.StartsWith("(bool)")) - { - if (!modIni.KeyExists(key)) modIni.Write(key, bools[key]); - } - else if (key.StartsWith("(int)")) - { - if (!modIni.KeyExists(key)) modIni.Write(key, ints[key]); - } - else if (key.StartsWith("(slider)")) - { - if (!modIni.KeyExists(key)) modIni.Write(key, sliders[key]); - } - else if (key.StartsWith("(header)")) - { - if (!modIni.KeyExists(key)) modIni.Write(key, headers[key]); - } - else if (key.StartsWith("(gap)")) - { - if (!modIni.KeyExists(key)) modIni.Write(key, gaps[key]); - } - else if (key.StartsWith("(key)")) - { - if (!modIni.KeyExists(key)) modIni.Write(key, keyBinds[key]); - } - else if (key.StartsWith("(text)")) - { - if (!modIni.KeyExists(key)) modIni.Write(key, text[key]); - } + SFB.StandaloneFileBrowser.OpenFolderPanelAsync( + "Select Folder for: " + modConfig[setting].Definition.Key, + value, + false, + FileSelectionCallback(modConfig[setting]) + ); + } else if (settingTags.Contains("modmenu_filepicker")) + { + SFB.StandaloneFileBrowser.OpenFilePanelAsync( + "Select File for: " + modConfig[setting].Definition.Key, + value, + "*", + false, + FileSelectionCallback(modConfig[setting]) + ); } } } - public List GetOptionsQueue(string modName) + private Action FileSelectionCallback(ConfigEntryBase setting) { - List ret = new List(); - string[] lines = File.ReadAllLines(iniLocation + @"\" + modName + ".ini"); - if (lines.Length > 0) + return (string[] results) => { - foreach (string line in lines) + if (results.Length > 0 && results[0].Length > 0) { - if (line.StartsWith("(bool)")) - { - ret.Add("(bool)"); - } - else if (line.StartsWith("(int)")) - { - ret.Add("(int)"); - } - else if (line.StartsWith("(slider)")) - { - ret.Add("(slider)"); - } - else if (line.StartsWith("(header)")) - { - ret.Add("(header)"); - } - else if (line.StartsWith("(gap)")) - { - ret.Add("(gap)"); - } + Logger.LogDebug("Got directory: '" + results[0] + "'."); + setting.BoxedValue = results[0]; } - } - return ret; + else + { + Logger.LogInfo("File selection was cancelled."); + } + }; } - IEnumerator BindKey(string key) + private void OpenTextWindow(int wId) { - bool pressed = false; - configKeys[key] = "WAITING FOR KEY"; - IniFile modIni = new IniFile(iniLocation + @"\" + currentOpenMod + ".ini"); - while (!pressed) + GUILayout.Space(30); + GUILayout.BeginVertical(); + optionsTextpos = GUILayout.BeginScrollView(optionsTextpos, false, true); + + ConfigFile modConfig = currentOpenMod.Instance.Config; + if (registeredMods.ContainsKey(currentOpenMod.Instance.Info) && registeredMods[currentOpenMod.Instance.Info] != null) { - foreach (KeyCode vKey in System.Enum.GetValues(typeof(KeyCode))) + foreach (string textLine in registeredMods[currentOpenMod.Instance.Info]) { - if (Input.GetKey(vKey)) - { - newKey = vKey.ToString(); - configKeys[key] = newKey; - pressed = true; - modIni.Write(key, newKey); - break; - } + GUILayout.BeginHorizontal(); + GUILayout.Label(textLine, ModMenuStyle.readStyle); + GUILayout.EndHorizontal(); } - yield return null; } + + GUILayout.EndScrollView(); + GUILayout.EndVertical(); } + #endregion static string UppercaseFirst(string s) { @@ -566,6 +607,5 @@ static string UppercaseFirst(string s) } return char.ToUpper(s[0]) + s.Substring(1); } - #endregion } } diff --git a/ModMenu/ModMenu.csproj b/ModMenu/ModMenu.csproj index 0b7654a..6563788 100644 --- a/ModMenu/ModMenu.csproj +++ b/ModMenu/ModMenu.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,10 +9,15 @@ Properties ModMenu ModMenu - v4.5 + v3.5 512 true + + + $(MSBuildWarningsAsMessages);MSB3277 + + true full @@ -21,196 +26,69 @@ DEBUG;TRACE prompt 4 + true + + false - pdbonly + true + embedded true bin\Release\ TRACE prompt 4 + true - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\Assembly-CSharp.dll + Libs\Assembly-CSharp-publicized.dll + False - - - - - - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\TextMeshPro.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.AccessibilityModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.AIModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.AnimationModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.ARModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.AssetBundleModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.AudioModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.ClothModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.ClusterInputModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.ClusterRendererModule.dll + Libs\TextMeshPro.dll + False - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.CoreModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.CrashReportingModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.DirectorModule.dll + Libs\UnityEngine.CoreModule.dll + False - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.GameCenterModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.GridModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.ImageConversionModule.dll + + Libs\UnityEngine.dll + False - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.IMGUIModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.InputModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.JSONSerializeModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.Networking.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.ParticlesLegacyModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.ParticleSystemModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.PerformanceReportingModule.dll + Libs\UnityEngine.IMGUIModule.dll + False - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.Physics2DModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.PhysicsModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.ScreenCaptureModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.SharedInternalsModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.SpatialTracking.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.SpriteMaskModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.SpriteShapeModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.StandardEvents.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.StyleSheetsModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.TerrainModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.TerrainPhysicsModule.dll + + Libs\UnityEngine.TextCoreModule.dll + False - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.TextRenderingModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.TilemapModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.Timeline.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UI.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UIElementsModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UIModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UNETModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UnityAnalyticsModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UnityConnectModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UnityWebRequestModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.VehiclesModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.VideoModule.dll - - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.VRModule.dll + Libs\UnityEngine.TextRenderingModule.dll + False - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.WebModule.dll + + Libs\0Harmony.dll + False - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\UnityEngine.WindModule.dll + + Libs\BepInEx.dll + False - - F:\Games\SteamLibrary\steamapps\common\LLBlaze\LLBlaze_Data\Managed\XboxOneCommonImport.dll + + + Libs\SFB.dll + False - - + - \ No newline at end of file + diff --git a/ModMenu/ModMenuIntegration/ModMenuIntegration.cs b/ModMenu/ModMenuIntegration/ModMenuIntegration.cs deleted file mode 100644 index cd742ff..0000000 --- a/ModMenu/ModMenuIntegration/ModMenuIntegration.cs +++ /dev/null @@ -1,189 +0,0 @@ -// Script used to connect to ModMenu -using System.Collections.Generic; -using UnityEngine; -using LLModMenu; -using System.IO; -using System; - -namespace LLModMenu -{ - public class ModMenuIntegration : MonoBehaviour - { - private ModMenu mm; - private bool mmAdded = false; - - public Dictionary configKeys = new Dictionary(); - public Dictionary configBools = new Dictionary(); - public Dictionary configInts = new Dictionary(); - public Dictionary configSliders = new Dictionary(); - public Dictionary configHeaders = new Dictionary(); - public Dictionary configGaps = new Dictionary(); - public Dictionary configText = new Dictionary(); - public List writeQueue = new List(); - - private void Start() - { - try { ReadIni(); } catch { Debug.Log("ModMenu: Could not load " + @"\ModSettings\" + gameObject.name + ".ini" + " so we will create it instead"); } - InitConfig(); - ReadIni(); - } - - private void Update() - { - mm = FindObjectOfType(); - if (mm != null) - { - if (mmAdded == false) - { - mm.mods.Add(base.gameObject.name); - mmAdded = true; - } - } - } - - private void InitConfig() - { - /* - * Mod menu now uses a single function to add options etc. (AddToWriteQueue) - * your specified options should be added to this function in the same format as stated under - * - Keybindings: - AddToWriteQueue("(key)keyName", "LeftShift"); value can be: Any KeyCode as a string e.g. "LeftShift" - - Options: - AddToWriteQueue("(bool)boolName", "true"); value can be: ["true" | "false"] - AddToWriteQueue("(int)intName", "27313"); value can be: any number as a string. For instance "123334" - AddToWriteQueue("(slider)sliderName", "50|0|100"); value must be: "Default value|Min Value|MaxValue" - AddToWriteQueue("(header)headerName", "Header Text"); value can be: Any string - AddToWriteQueue("(gap)gapName", "identifier"); value does not matter, just make name and value unique from other gaps - - ModInformation: - AddToWriteQueue("(text)text1", "Descriptive text"); value can be: Any string - */ - - - // Insert your options here \/ - - ModMenu.Instance.WriteIni(gameObject.name, writeQueue, configKeys, configBools, configInts, configSliders, configHeaders, configGaps, configText); - writeQueue.Clear(); - } - - public void ReadIni() - { - string[] lines = File.ReadAllLines(Directory.GetParent(Application.dataPath).FullName + @"\ModSettings\" + gameObject.name + ".ini"); - configBools.Clear(); - configKeys.Clear(); - configInts.Clear(); - configSliders.Clear(); - configHeaders.Clear(); - configGaps.Clear(); - configText.Clear(); - foreach (string line in lines) - { - if (line.StartsWith("(key)")) - { - string[] split = line.Split('='); - configKeys.Add(split[0], split[1]); - } - else if (line.StartsWith("(bool)")) - { - string[] split = line.Split('='); - configBools.Add(split[0], split[1]); - } - else if (line.StartsWith("(int)")) - { - string[] split = line.Split('='); - configInts.Add(split[0], split[1]); - } - else if (line.StartsWith("(slider)")) - { - string[] split = line.Split('='); - configSliders.Add(split[0], split[1]); - } - else if (line.StartsWith("(header)")) - { - string[] split = line.Split('='); - configHeaders.Add(split[0], split[1]); - } - else if (line.StartsWith("(gap)")) - { - string[] split = line.Split('='); - configGaps.Add(split[0], split[1]); - } - else if (line.StartsWith("(text)")) - { - string[] split = line.Split('='); - configText.Add(split[0], split[1]); - } - } - } - - public void AddToWriteQueue(string key, string value) - { - if (key.StartsWith("(key)")) - { - configKeys.Add(key, value); - writeQueue.Add(key); - } - else if (key.StartsWith("(bool)")) - { - configBools.Add(key, value); - writeQueue.Add(key); - } - else if (key.StartsWith("(int)")) - { - configInts.Add(key, value); - writeQueue.Add(key); - } - else if (key.StartsWith("(slider)")) - { - configSliders.Add(key, value); - writeQueue.Add(key); - } - else if (key.StartsWith("(header)")) - { - configHeaders.Add(key, value); - writeQueue.Add(key); - } - else if (key.StartsWith("(gap)")) - { - configGaps.Add(key, value); - writeQueue.Add(key); - } - else if (key.StartsWith("(text)")) - { - configText.Add(key, value); - writeQueue.Add(key); - } - } - - public KeyCode GetKeyCode(string keyCode) - { - foreach (KeyCode vKey in System.Enum.GetValues(typeof(KeyCode))) - { - if (vKey.ToString() == keyCode) - { - return vKey; - } - } - return KeyCode.A; - } - - public bool GetTrueFalse(string boolName) - { - if (boolName == "true") return true; - else return false; - } - - public int GetSliderValue(string sliderName) - { - string[] vals = configSliders[sliderName].Split('|'); - return Convert.ToInt32(vals[0]); - } - - public int GetInt(string intName) - { - return Convert.ToInt32(configInts[intName]); - } - } -} \ No newline at end of file diff --git a/ModMenu/ModMenuStyle.cs b/ModMenu/ModMenuStyle.cs old mode 100644 new mode 100755 index f5dacc9..b378cc1 --- a/ModMenu/ModMenuStyle.cs +++ b/ModMenu/ModMenuStyle.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using UnityEngine; -namespace LLModMenu +namespace ModMenu { public static class ModMenuStyle { @@ -10,6 +10,7 @@ public static class ModMenuStyle public static void InitStyle() { + texColors.Clear(); texColors.Add("Yellow", ColorToTexture2D(new Color(1f, 0.968f, 0.3f))); texColors.Add("LightYellow", ColorToTexture2D(new Color(1f, 1f, 0.5f))); texColors.Add("DarkGray", ColorToTexture2D(new Color(0.145f, 0.145f, 0.145f))); diff --git a/ModMenu/PluginInfos.cs b/ModMenu/PluginInfos.cs new file mode 100755 index 0000000..9bbbaed --- /dev/null +++ b/ModMenu/PluginInfos.cs @@ -0,0 +1,47 @@ +using System.Reflection; +using ModMenu; + +#region Assembly attributes +/* + * These attributes define various metainformation of the generated DLL. + * In general, you don't need to touch these. Instead, edit the values in PluginInfo. + */ +[assembly: AssemblyVersion(PluginInfos.PLUGIN_VERSION)] +[assembly: AssemblyTitle(PluginInfos.PLUGIN_NAME + " (" + PluginInfos.PLUGIN_ID + ")")] +[assembly: AssemblyProduct(PluginInfos.PLUGIN_NAME)] +#endregion + +namespace ModMenu +{ + /// + /// The main metadata of the plugin. + /// This information is used for BepInEx plugin metadata. + /// + /// + /// See also description of BepInEx metadata: + /// https://bepinex.github.io/bepinex_docs/master/articles/dev_guide/plugin_tutorial/2_plugin_start.html#basic-information-about-the-plug-in + /// + public static class PluginInfos + { + /// + /// Human-readable name of the plugin. In general, it should be short and concise. + /// This is the name that is shown to the users who run BepInEx and to modders that inspect BepInEx logs. + /// + public const string PLUGIN_NAME = "ModMenu"; + + /// + /// Unique ID of the plugin. + /// This must be a unique string that contains only characters a-z, 0-9 underscores (_) and dots (.) + /// Prefer using the reverse domain name notation: https://eqdn.tech/reverse-domain-notation/ + /// + /// When creating Harmony patches, prefer using this ID for Harmony instances as well. + /// + public const string PLUGIN_ID = "no.mrgentle.plugins.llb.modmenu"; + + /// + /// Version of the plugin. Must be in form .... + /// Major and minor versions are mandatory, but build and revision can be left unspecified. + /// + public const string PLUGIN_VERSION = "1.3.2"; + } +} diff --git a/ModMenu/Properties/AssemblyInfo.cs b/ModMenu/Properties/AssemblyInfo.cs old mode 100644 new mode 100755 index 7c6bdc6..db3b8b5 --- a/ModMenu/Properties/AssemblyInfo.cs +++ b/ModMenu/Properties/AssemblyInfo.cs @@ -5,12 +5,8 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("ModMenu")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("ModMenu")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +28,4 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/README.md b/README.md new file mode 100644 index 0000000..5745134 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# ModMenu +Configure options straight from the game!