diff --git a/src/CachedObjects/CacheObjectBase.cs b/src/CachedObjects/CacheObjectBase.cs
index fd41eda..e1b673c 100644
--- a/src/CachedObjects/CacheObjectBase.cs
+++ b/src/CachedObjects/CacheObjectBase.cs
@@ -244,30 +244,41 @@ namespace Explorer
var input = m_argumentInput[i];
var type = m_arguments[i].ParameterType;
- if (type == typeof(string))
+ // First, try parse the input and use that.
+ if (!string.IsNullOrEmpty(input))
{
- parsedArgs.Add(input);
- }
- else
- {
- try
+ // strings can obviously just be used directly
+ if (type == typeof(string))
{
- parsedArgs.Add(type.GetMethod("Parse", new Type[] { typeof(string) })
- .Invoke(null, new object[] { input }));
+ parsedArgs.Add(input);
+ continue;
}
- catch
+ else
{
- if (m_arguments[i].HasDefaultValue)
+ // try to invoke the parse method and use that.
+ try
{
- parsedArgs.Add(m_arguments[i].DefaultValue);
+ parsedArgs.Add(type.GetMethod("Parse", new Type[] { typeof(string) })
+ .Invoke(null, new object[] { input }));
+
+ continue;
}
- else
+ catch
{
- // Try add a null arg I guess
- parsedArgs.Add(null);
+ MelonLogger.Log($"Argument #{i} '{m_arguments[i].Name}' ({type.Name}), could not parse input '{input}'.");
}
}
}
+
+ // Didn't use input, see if there is a default value.
+ if (m_arguments[i].HasDefaultValue)
+ {
+ parsedArgs.Add(m_arguments[i].DefaultValue);
+ continue;
+ }
+
+ // Try add a null arg I guess
+ parsedArgs.Add(null);
}
return parsedArgs.ToArray();
diff --git a/src/Config/ModConfig.cs b/src/Config/ModConfig.cs
new file mode 100644
index 0000000..19b6a98
--- /dev/null
+++ b/src/Config/ModConfig.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Serialization;
+using UnityEngine;
+
+namespace Explorer
+{
+ public class ModConfig
+ {
+ [XmlIgnore] public static readonly XmlSerializer Serializer = new XmlSerializer(typeof(ModConfig));
+
+ [XmlIgnore] private const string EXPLORER_FOLDER = @"Mods\CppExplorer";
+ [XmlIgnore] private const string SETTINGS_PATH = EXPLORER_FOLDER + @"\config.xml";
+
+ [XmlIgnore] public static ModConfig Instance;
+
+ public KeyCode Main_Menu_Toggle = KeyCode.F7;
+ public Vector2 Default_Window_Size = new Vector2(550, 700);
+
+ public static void OnLoad()
+ {
+ if (!Directory.Exists(EXPLORER_FOLDER))
+ {
+ Directory.CreateDirectory(EXPLORER_FOLDER);
+ }
+
+ if (File.Exists(SETTINGS_PATH))
+ {
+ LoadSettings(false);
+ }
+ else
+ {
+ Instance = new ModConfig();
+ SaveSettings(false);
+ }
+ }
+
+ public static void LoadSettings(bool checkExist = true)
+ {
+ if (checkExist && !File.Exists(SETTINGS_PATH))
+ return;
+
+ var file = File.OpenRead(SETTINGS_PATH);
+ Instance = (ModConfig)Serializer.Deserialize(file);
+ file.Close();
+ }
+
+ public static void SaveSettings(bool checkExist = true)
+ {
+ if (checkExist && File.Exists(SETTINGS_PATH))
+ File.Delete(SETTINGS_PATH);
+
+ FileStream file = File.Create(SETTINGS_PATH);
+ Serializer.Serialize(file, Instance);
+ file.Close();
+ }
+ }
+}
diff --git a/src/CppExplorer.cs b/src/CppExplorer.cs
index 555962e..e69e20d 100644
--- a/src/CppExplorer.cs
+++ b/src/CppExplorer.cs
@@ -13,7 +13,7 @@ namespace Explorer
public class CppExplorer : MelonMod
{
public const string NAME = "CppExplorer";
- public const string VERSION = "1.6.7";
+ public const string VERSION = "1.6.8";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.cppexplorer";
@@ -54,6 +54,8 @@ namespace Explorer
{
Instance = this;
+ ModConfig.OnLoad();
+
InputHelper.Init();
new MainMenu();
@@ -80,7 +82,7 @@ namespace Explorer
public override void OnUpdate()
{
// Check main toggle key input
- if (InputHelper.GetKeyDown(KeyCode.F7))
+ if (InputHelper.GetKeyDown(ModConfig.Instance.Main_Menu_Toggle))
{
ShowMenu = !ShowMenu;
}
diff --git a/src/CppExplorer.csproj b/src/CppExplorer.csproj
index 5971b5b..7eb2b91 100644
--- a/src/CppExplorer.csproj
+++ b/src/CppExplorer.csproj
@@ -85,6 +85,7 @@
+
diff --git a/src/MainMenu/MainMenu.cs b/src/MainMenu/MainMenu.cs
index 9596e5a..6d2d15e 100644
--- a/src/MainMenu/MainMenu.cs
+++ b/src/MainMenu/MainMenu.cs
@@ -27,8 +27,9 @@ namespace Explorer
}
}
- public const int MainWindowID = 10;
- public static Rect MainRect = new Rect(5, 5, 550, 700);
+ public const int MainWindowID = 5000;
+ public static Rect MainRect = new Rect(new Vector2(5,5), ModConfig.Instance.Default_Window_Size);
+
private static readonly List Pages = new List();
private static int m_currentPage = 0;
@@ -63,7 +64,7 @@ namespace Explorer
{
GUI.DragWindow(new Rect(0, 0, MainRect.width - 90, 20));
- if (GUI.Button(new Rect(MainRect.width - 90, 2, 80, 20), "Hide (F7)"))
+ if (GUI.Button(new Rect(MainRect.width - 90, 2, 80, 20), $"Hide ({ModConfig.Instance.Main_Menu_Toggle})"))
{
CppExplorer.ShowMenu = false;
return;
diff --git a/src/Windows/UIWindow.cs b/src/Windows/UIWindow.cs
index a6c837a..1427d1b 100644
--- a/src/Windows/UIWindow.cs
+++ b/src/Windows/UIWindow.cs
@@ -17,7 +17,7 @@ namespace Explorer
public object Target;
public int windowID;
- public Rect m_rect = new Rect(0, 0, 550, 700);
+ public Rect m_rect = new Rect(Vector2.zero, ModConfig.Instance.Default_Window_Size);
public Vector2 scroll = Vector2.zero;