using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Singletons;
using Newtonsoft.Json.Linq;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ConfigEditorPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConfigEditorPlugin")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("ConfigEditorPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.3.1.0")]
namespace LordAshes;
[BepInPlugin("org.lordashes.plugins.configeditor", "Config Editor Plug-In", "1.3.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class ConfigEditorPlugin : BaseUnityPlugin
{
private class JSONFormatter
{
private enum JSONType
{
OBJECT,
ARRAY
}
public static Dictionary<string, string> Flatten(string json)
{
JObject val = JObject.Parse(json);
IEnumerable<JToken> source = from p in ((JContainer)val).Descendants()
where ((IEnumerable<JToken>)p).Count() == 0
select p;
return source.Aggregate(new Dictionary<string, string>(), delegate(Dictionary<string, string> properties, JToken jToken)
{
properties.Add(jToken.Path, ((object)jToken).ToString());
return properties;
});
}
public static string Unflatten(IDictionary<string, string> keyValues)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
JContainer val = null;
JsonMergeSettings val2 = new JsonMergeSettings();
val2.MergeArrayHandling = (MergeArrayHandling)3;
foreach (KeyValuePair<string, string> keyValue in keyValues)
{
if (val == null)
{
val = UnflatenSingle(keyValue);
}
else
{
val.Merge((object)UnflatenSingle(keyValue), val2);
}
}
return ((object)((val is JObject) ? val : null)).ToString();
}
private static JContainer UnflatenSingle(KeyValuePair<string, string> keyValue)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
string key = keyValue.Key;
string value = keyValue.Value;
IList<string> source = SplitPath(key);
JContainer val = null;
foreach (string item in source.Reverse())
{
switch (GetJSONType(item))
{
case JSONType.OBJECT:
{
JObject val2 = new JObject();
if (val == null)
{
val2.Add(item, JToken.op_Implicit(value));
}
else
{
val2.Add(item, (JToken)(object)val);
}
val = (JContainer)(object)val2;
break;
}
case JSONType.ARRAY:
{
JArray array = new JArray();
int arrayIndex = GetArrayIndex(item);
array = FillEmpty(array, arrayIndex);
if (val == null)
{
array[arrayIndex] = JToken.op_Implicit(value);
}
else
{
array[arrayIndex] = (JToken)(object)val;
}
val = (JContainer)(object)array;
break;
}
}
}
return val;
}
public static IList<string> SplitPath(string path)
{
IList<string> list = new List<string>();
Regex regex = new Regex("(?!\\.)([^. ^\\[\\]]+)|(?!\\[)(\\d+)(?=\\])");
foreach (Match item in regex.Matches(path))
{
list.Add(item.Value);
}
return list;
}
private static JArray FillEmpty(JArray array, int index)
{
for (int i = 0; i <= index; i++)
{
array.Add((JToken)null);
}
return array;
}
private static JSONType GetJSONType(string pathSegment)
{
int result;
return int.TryParse(pathSegment, out result) ? JSONType.ARRAY : JSONType.OBJECT;
}
private static int GetArrayIndex(string pathSegment)
{
if (int.TryParse(pathSegment, out var result))
{
return result;
}
throw new Exception("Unable to parse array index: " + pathSegment);
}
}
public static class Utility
{
private static GameInput gameInputInstance;
private static MethodInfo gameInputDisable;
private static MethodInfo gameInputEnable;
public static void GameInputEnabled(bool setting)
{
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
if (gameInputInstance == null || gameInputDisable == null || gameInputEnable == null)
{
try
{
Debug.Log((object)"Plane Image Plugin: Getting Game Input Reference");
gameInputInstance = null;
gameInputDisable = null;
gameInputEnable = null;
gameInputInstance = (GameInput)(from f in typeof(ControllerManager).GetRuntimeFields()
where f.Name == "_gameInput"
select f).ToArray()[0].GetValue(null);
gameInputDisable = (from m in typeof(GameInput).GetMethods()
where m.Name == "Disable"
select m).ElementAt(0);
gameInputEnable = (from m in typeof(GameInput).GetMethods()
where m.Name == "Enable"
select m).ElementAt(0);
}
catch
{
Debug.LogWarning((object)"Plane Image Plugin: Unable To Get Game Input Reference Or Reference To One Of Its Methods");
}
}
if (setting)
{
Debug.Log((object)"Plane Image Plugin: Enabling Game Input");
gameInputEnable.Invoke(gameInputInstance, new object[0]);
}
else
{
Debug.Log((object)"Plane Image Plugin: Disabling Game Input");
gameInputDisable.Invoke(gameInputInstance, new object[0]);
}
}
public static bool isBoardLoaded()
{
return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
}
public static bool StrictKeyCheck(KeyboardShortcut check)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
if (!((KeyboardShortcut)(ref check)).IsUp())
{
return false;
}
KeyCode[] array = new KeyCode[6];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
KeyCode[] array2 = (KeyCode[])(object)array;
foreach (KeyCode val in array2)
{
if (Input.GetKey(val) != ((KeyboardShortcut)(ref check)).Modifiers.Contains(val))
{
return false;
}
}
return true;
}
public static string GetCreatureName(string name)
{
if (name.Contains("<"))
{
name = name.Substring(0, name.IndexOf("<"));
}
return name;
}
public static GameObject GetBaseLoader(CreatureGuid cid)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
CreatureBoardAsset val = null;
CreaturePresenter.TryGetAsset(cid, ref val);
if ((Object)(object)val != (Object)null)
{
CreatureBase match = null;
StartWith(val, "_base", ref match);
Transform match2 = null;
Traverse(((Component)match).transform, "BaseLoader", ref match2);
if ((Object)(object)match2 != (Object)null)
{
return ((Component)match2.GetChild(0)).gameObject;
}
Debug.LogWarning((object)"Config Editor Plugin: Could Not Find Base Loader");
return null;
}
return null;
}
public static GameObject GetAssetLoader(CreatureGuid cid)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
CreatureBoardAsset val = null;
CreaturePresenter.TryGetAsset(cid, ref val);
if ((Object)(object)val != (Object)null)
{
Transform match = null;
StartWith(val, "_creatureRoot", ref match);
Transform match2 = null;
Traverse(match, "AssetLoader", ref match2);
if ((Object)(object)match2 != (Object)null)
{
return ((Component)match2.GetChild(0)).gameObject;
}
Debug.LogWarning((object)"Config Editor Plugin: Could Not Find Asset Loader");
return null;
}
return null;
}
public static void StartWith<T>(CreatureBoardAsset asset, string seek, ref T match)
{
Type typeFromHandle = typeof(CreatureBoardAsset);
match = default(T);
foreach (FieldInfo runtimeField in typeFromHandle.GetRuntimeFields())
{
if (runtimeField.Name == seek)
{
match = (T)runtimeField.GetValue(asset);
break;
}
}
}
public static void Traverse(Transform root, string seek, ref Transform match, string path = "")
{
path = path + ((Object)root).name + ".";
Debug.Log((object)("Config Editor Plugin: Found '" + path + "' (with " + root.childCount + " Children)"));
if ((Object)(object)match != (Object)null)
{
return;
}
if (Convert.ToString(((Object)root).name) == Convert.ToString(seek))
{
match = root;
return;
}
foreach (Transform item in ExtensionMethods.Children(root))
{
Traverse(item, seek, ref match, path);
if ((Object)(object)match != (Object)null)
{
break;
}
}
}
}
public enum EditorElementType
{
header,
label,
textEntry,
button
}
public sealed class EditorElement
{
public Rect layout { get; set; } = new Rect(0f, 0f, 20f, 20f);
public string content { get; set; } = "MenuItem";
public EditorElementType style { get; set; } = EditorElementType.header;
public Type dataType { get; set; } = typeof(string);
public string linkRef { get; set; } = null;
}
public const string Name = "Config Editor Plug-In";
public const string Guid = "org.lordashes.plugins.configeditor";
public const string Version = "1.3.1.0";
private static GUIStyle headerStyle = new GUIStyle();
private static GUIStyle labelStyle = new GUIStyle();
private static GUIStyle entryStyle = new GUIStyle();
private static GUIStyle buttonStyle = new GUIStyle();
private static Texture2D menuBackground = null;
private static Texture2D colorPickerIcon = null;
private static float debunchingFactor = 0.8f;
public static int initX = 90;
public static int initY = 60;
public static int indentPerLevel = 5;
public static int entryWidth = 280;
public static int offsetYPerItem = 20;
public static int offsetXToEntry = 200;
public static int offsetXToNextRow = 300;
private static int extendsX = 0;
private static int extendsY = 0;
private static Dictionary<string, string> currentFlattenedJson = new Dictionary<string, string>();
private static List<EditorElement> currentGUI = new List<EditorElement>();
private static Dictionary<Guid, Action<string, string>> _buttonCallbacks = new Dictionary<Guid, Action<string, string>>();
public static bool diagnostics = false;
public static bool isEditorOpen = false;
private static object padlock = new object();
private void Awake()
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
diagnostics = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Diagnostics", false, (ConfigDescription)null).Value;
Debug.Log((object)("Config Editor Plugin: " + ((object)this).GetType().AssemblyQualifiedName + " Active."));
if (File.Exists("ConfigEditor.Menu.Background.png"))
{
menuBackground = Image.LoadTexture("ConfigEditor.Menu.Background.png", (CacheType)999);
}
else
{
menuBackground = Texture2D.blackTexture;
}
headerStyle.normal.textColor = Color.white;
headerStyle.alignment = (TextAnchor)3;
headerStyle.fontSize = (int)((float)offsetYPerItem * debunchingFactor);
headerStyle.fontStyle = (FontStyle)1;
if (File.Exists("ConfigEditor.Header.Background.png"))
{
headerStyle.normal.background = Image.LoadTexture("ConfigEditor.Header.Background.png", (CacheType)999);
}
else
{
headerStyle.normal.background = Texture2D.blackTexture;
}
labelStyle.normal.textColor = Color.white;
labelStyle.alignment = (TextAnchor)3;
labelStyle.fontSize = (int)((float)offsetYPerItem * debunchingFactor);
labelStyle.fontStyle = (FontStyle)2;
if (File.Exists("ConfigEditor.Label.Background.png"))
{
labelStyle.normal.background = Image.LoadTexture("ConfigEditor.Label.Background.png", (CacheType)999);
}
else
{
labelStyle.normal.background = Texture2D.blackTexture;
}
entryStyle.normal.textColor = Color.black;
entryStyle.alignment = (TextAnchor)3;
entryStyle.fontSize = (int)((float)offsetYPerItem * debunchingFactor);
entryStyle.fontStyle = (FontStyle)0;
if (File.Exists("ConfigEditor.Entry.Background.png"))
{
entryStyle.normal.background = Image.LoadTexture("ConfigEditor.Entry.Background.png", (CacheType)999);
}
else
{
entryStyle.normal.background = Texture2D.blackTexture;
}
buttonStyle.normal.textColor = Color.black;
buttonStyle.alignment = (TextAnchor)4;
buttonStyle.fontSize = (int)((float)offsetYPerItem * debunchingFactor);
buttonStyle.fontStyle = (FontStyle)0;
if (File.Exists("ConfigEditor.Button.Background.png"))
{
buttonStyle.normal.background = Image.LoadTexture("ConfigEditor.Button.Background.png", (CacheType)999);
}
else
{
buttonStyle.normal.background = Texture2D.grayTexture;
}
if (File.Exists("ConfigEditor.ColorPicker.Background.png"))
{
colorPickerIcon = Image.LoadTexture("ConfigEditor.ColorPicker.Background.png", (CacheType)999);
}
else
{
colorPickerIcon = Texture2D.grayTexture;
}
debunchingFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Debuncing Factor", 0.8f, (ConfigDescription)null).Value;
initX = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Initial X Position", 90, (ConfigDescription)null).Value;
initY = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Initial Y Position", 60, (ConfigDescription)null).Value;
indentPerLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Indent Value Per Content Level", 5, (ConfigDescription)null).Value;
entryWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Total Entry Width", 280, (ConfigDescription)null).Value;
offsetYPerItem = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Y Offset Per Item", 20, (ConfigDescription)null).Value;
offsetXToEntry = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "X Offset To Entry", 200, (ConfigDescription)null).Value;
offsetXToNextRow = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "X Offset To Next Column", 300, (ConfigDescription)null).Value;
}
public static void SetLayout(int startX = 60, int startY = 90, int menuVerticalSpacing = 20, int menuHorizontalSpacing = 300, int menuEntryWidth = 280, int menuHorizontalOffsetToEntry = 200, int menuEntryIndent = 5, float menuEntrydebunchngFactor = 0.8f)
{
initX = startX;
initY = startY;
entryWidth = menuEntryWidth;
offsetYPerItem = menuVerticalSpacing;
offsetXToEntry = menuHorizontalOffsetToEntry;
offsetXToNextRow = menuEntryWidth;
indentPerLevel = menuEntryIndent;
debunchingFactor = menuEntrydebunchngFactor;
}
public static void SetColorization(string headerFontColor, FontStyle headerFontStyle, Texture2D headerBackground, string labelFontColor, FontStyle labelFontStyle, Texture2D labelBackground, string entryFontColor, FontStyle entryFontStyle, Texture2D entryBackground, string buttonFontColor, FontStyle buttonFontStyle, Texture2D buttonBackground, Texture2D editorBackground)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
headerStyle.normal.textColor = (Color)typeof(Color).GetProperty(headerFontColor.ToLowerInvariant()).GetValue(null, null);
labelStyle.normal.textColor = (Color)typeof(Color).GetProperty(labelFontColor.ToLowerInvariant()).GetValue(null, null);
entryStyle.normal.textColor = (Color)typeof(Color).GetProperty(entryFontColor.ToLowerInvariant()).GetValue(null, null);
buttonStyle.normal.textColor = (Color)typeof(Color).GetProperty(buttonFontColor.ToLowerInvariant()).GetValue(null, null);
headerStyle.fontStyle = headerFontStyle;
labelStyle.fontStyle = labelFontStyle;
entryStyle.fontStyle = entryFontStyle;
buttonStyle.fontStyle = entryFontStyle;
headerStyle.normal.background = headerBackground;
labelStyle.normal.background = labelBackground;
entryStyle.normal.background = entryBackground;
buttonStyle.normal.background = entryBackground;
menuBackground = editorBackground;
}
public static void Subscribe(Action<string, string> saveCallback)
{
Debug.Log((object)"Config Editor Plugin: Registering Buttons Callback");
Guid key = System.Guid.NewGuid();
_buttonCallbacks.Add(key, saveCallback);
}
public static Guid Subscription(Action<string, string> saveCallback)
{
Debug.Log((object)"Config Editor Plugin: Registering Buttons Callback");
Guid guid = System.Guid.NewGuid();
_buttonCallbacks.Add(guid, saveCallback);
return guid;
}
public static void RemoveSubscription(Guid subscriptionGuid)
{
Debug.Log((object)("Config Editor Plugin: Unregistering Buttons Callback With Id " + subscriptionGuid));
if (_buttonCallbacks.ContainsKey(subscriptionGuid))
{
_buttonCallbacks.Remove(subscriptionGuid);
}
}
public static void Open(string header, string json, string[] buttons = null)
{
//IL_0588: Unknown result type (might be due to invalid IL or missing references)
//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Unknown result type (might be due to invalid IL or missing references)
//IL_0495: Unknown result type (might be due to invalid IL or missing references)
if (isEditorOpen)
{
Debug.Log((object)"Config Editor Plugin: Editor Open. Try Again Later.");
return;
}
Utility.GameInputEnabled(setting: false);
if (buttons == null)
{
buttons = new string[2] { "Save", "Cancel" };
}
lock (padlock)
{
currentGUI.Clear();
currentFlattenedJson.Clear();
}
int num = initY;
int num2 = initX;
List<string> list = new List<string>();
Rect layout;
foreach (KeyValuePair<string, string> item in JSONFormatter.Flatten(json))
{
if (diagnostics)
{
Debug.Log((object)("Config Editor Plugin: Preparing Element " + item.Key));
}
int num3 = 0;
string[] array = (header + "." + item.Key).Substring(0, (header + "." + item.Key).LastIndexOf(".")).Split(new char[1] { '.' });
if (diagnostics)
{
Debug.Log((object)("Config Editor Plugin: Parent " + (header + "." + item.Key).Substring(0, (header + "." + item.Key).LastIndexOf("."))));
}
string[] array2 = array;
foreach (string text in array2)
{
if (!list.Contains(text))
{
list.Add(text);
lock (padlock)
{
List<EditorElement> list2 = currentGUI;
EditorElement editorElement = new EditorElement();
EditorElement editorElement2 = editorElement;
layout = default(Rect);
((Rect)(ref layout)).x = num2 + num3 * indentPerLevel;
((Rect)(ref layout)).y = num;
((Rect)(ref layout)).width = entryWidth - num3 * indentPerLevel;
((Rect)(ref layout)).height = (int)((float)offsetYPerItem * debunchingFactor);
editorElement2.layout = layout;
editorElement.content = text.Substring(0, 1).ToUpper() + text.Substring(1);
editorElement.style = EditorElementType.header;
editorElement.dataType = typeof(string);
list2.Add(editorElement);
}
num += offsetYPerItem;
if (num > Screen.height - offsetYPerItem)
{
num = initY;
num2 += offsetXToNextRow;
}
}
num3++;
}
string text2 = (header + "." + item.Key).Substring((header + "." + item.Key).LastIndexOf(".") + 1);
if (diagnostics)
{
Debug.Log((object)("Config Editor Plugin: Item " + text2 + " (" + item.Key + ")"));
}
lock (padlock)
{
List<EditorElement> list3 = currentGUI;
EditorElement editorElement = new EditorElement();
EditorElement editorElement3 = editorElement;
layout = default(Rect);
((Rect)(ref layout)).x = num2 + num3 * indentPerLevel;
((Rect)(ref layout)).y = num;
((Rect)(ref layout)).width = offsetXToEntry - num3 * indentPerLevel;
((Rect)(ref layout)).height = (int)((float)offsetYPerItem * debunchingFactor);
editorElement3.layout = layout;
editorElement.content = text2;
editorElement.style = EditorElementType.label;
editorElement.dataType = typeof(string);
list3.Add(editorElement);
}
if (!currentFlattenedJson.ContainsKey(item.Key))
{
currentFlattenedJson.Add(item.Key, item.Value);
}
lock (padlock)
{
List<EditorElement> list4 = currentGUI;
EditorElement editorElement = new EditorElement();
EditorElement editorElement4 = editorElement;
layout = default(Rect);
((Rect)(ref layout)).x = num2 + offsetXToEntry;
((Rect)(ref layout)).y = num;
((Rect)(ref layout)).width = entryWidth - offsetXToEntry;
((Rect)(ref layout)).height = (int)((float)offsetYPerItem * debunchingFactor);
editorElement4.layout = layout;
editorElement.content = currentFlattenedJson[item.Key];
editorElement.style = EditorElementType.textEntry;
editorElement.dataType = typeof(string);
editorElement.linkRef = item.Key;
list4.Add(editorElement);
}
num += offsetYPerItem;
if (num > Screen.height - offsetYPerItem)
{
num = initY;
num2 += offsetXToNextRow;
}
}
int num4 = entryWidth / buttons.Length;
int num5 = 0;
string[] array3 = buttons;
foreach (string content in array3)
{
lock (padlock)
{
List<EditorElement> list5 = currentGUI;
EditorElement editorElement = new EditorElement();
EditorElement editorElement5 = editorElement;
layout = default(Rect);
((Rect)(ref layout)).x = num2 + 2 + num4 * num5;
((Rect)(ref layout)).y = num;
((Rect)(ref layout)).width = num4 - 4;
((Rect)(ref layout)).height = (int)((float)offsetYPerItem * debunchingFactor);
editorElement5.layout = layout;
editorElement.content = content;
editorElement.style = EditorElementType.button;
editorElement.dataType = typeof(string);
list5.Add(editorElement);
}
num5++;
}
num += offsetYPerItem;
extendsX = num2 + entryWidth - initX;
extendsY = num - initY;
isEditorOpen = true;
}
public static void SetItemDataType(string key, Type dataType)
{
lock (padlock)
{
Debug.Log((object)("Config Editor: Update '" + key + "' To DataType '" + Convert.ToString(dataType) + "'"));
for (int i = 0; i < currentGUI.Count; i++)
{
Debug.Log((object)("Config Editor: Found '" + currentGUI.ElementAt(i).content + "' when looking for '" + key + "'"));
if (currentGUI.ElementAt(i).linkRef == key)
{
Debug.Log((object)"Config Editor: Found!");
currentGUI.ElementAt(i).dataType = dataType;
break;
}
}
}
}
public static void Render()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
if (!isEditorOpen)
{
return;
}
GUI.DrawTexture(new Rect((float)(initX - 10), (float)(initY - 10), (float)(extendsX + 20), (float)(extendsY + 20)), (Texture)(object)menuBackground, (ScaleMode)0);
lock (padlock)
{
Rect val = default(Rect);
foreach (EditorElement item in currentGUI)
{
switch (item.style)
{
case EditorElementType.header:
GUI.Label(item.layout, item.content, headerStyle);
break;
case EditorElementType.label:
GUI.Label(item.layout, item.content, labelStyle);
break;
case EditorElementType.textEntry:
currentFlattenedJson[item.linkRef] = GUI.TextField(item.layout, currentFlattenedJson[item.linkRef], entryStyle);
break;
case EditorElementType.button:
if (!GUI.Button(item.layout, item.content, buttonStyle) || _buttonCallbacks == null)
{
break;
}
foreach (Action<string, string> value in _buttonCallbacks.Values)
{
value(item.content, JSONFormatter.Unflatten(currentFlattenedJson));
}
break;
}
if (item.dataType == typeof(Color))
{
Rect layout = item.layout;
float num = ((Rect)(ref layout)).x - 22f;
layout = item.layout;
float y = ((Rect)(ref layout)).y;
layout = item.layout;
((Rect)(ref val))..ctor(num, y, 20f, ((Rect)(ref layout)).height);
if (GUI.Button(val, (Texture)(object)colorPickerIcon, buttonStyle))
{
layout = item.layout;
float x = ((Rect)(ref layout)).x - 11f;
layout = item.layout;
ShowColorPicker(item, x, ((Rect)(ref layout)).y);
}
}
}
}
}
public static string Save()
{
Debug.Log((object)"Config Editor Plugin: Plugin Initiated Save");
Utility.GameInputEnabled(setting: true);
return JSONFormatter.Unflatten(currentFlattenedJson);
}
public static void Close()
{
Utility.GameInputEnabled(setting: true);
isEditorOpen = false;
}
private static void ShowColorPicker(EditorElement colorPickerElement, float x, float y)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
ColorDialog val = new ColorDialog();
if ((int)((CommonDialog)val).ShowDialog() == 1)
{
currentFlattenedJson[colorPickerElement.linkRef] = val.Color.A + "," + val.Color.R + "," + val.Color.G + "," + val.Color.B;
}
}
}