using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UrGUI.UWindow.Utils;
using UrGUI.Utils;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UrGUI")]
[assembly: AssemblyDescription("Easy to use extension for Unity IMGUI system. https://github.com/Hirashi3630/UrGUI")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UrGUI")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9f3e6286-13be-456c-90f4-31b1dda6dc28")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("1.1.8841.27572")]
namespace UrGUI.UWindow
{
public class UWindow
{
public string WinGuid;
public string WindowTitle;
public float X;
public float Y;
public float Width;
public float Height;
public bool IsDraggable;
public bool DynamicHeight;
private float _startX;
private float _startY;
private float _margin;
private float _controlHeight;
private float _controlSpace;
private float _sameLineOffset;
private List<float> _nextLineRatios = new List<float>(0);
private bool _isDragging;
private float _nextControlY;
private List<WControl> _controls;
public GUISkin ActiveSkin { get; internal set; } = null;
public bool IsDrawing { get; set; }
private protected UWindow()
{
}
public static UWindow Begin(string windowTitle = "a Title", float startWidth = 200f, float margin = 10f, float controlHeight = 22f, float controlSpace = 5f, bool isEnabled = true, bool isDraggable = true, bool dynamicHeight = true)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
int num = 400;
Vector2 dynamicWindowPos = UWindowManager.GetDynamicWindowPos(startWidth);
return Begin(windowTitle, dynamicWindowPos.x, dynamicWindowPos.y, startWidth, num, margin, controlHeight, controlSpace, isEnabled, isDraggable, dynamicHeight);
}
public static UWindow Begin(string windowTitle, float startX, float startY, float startWidth, float startHeight, float margin = 10f, float controlHeight = 22f, float controlSpace = 5f, bool isDrawing = true, bool isDraggable = true, bool dynamicHeight = false)
{
UWindow uWindow = new UWindow
{
IsDrawing = isDrawing,
WindowTitle = windowTitle,
X = startX,
Y = startY,
Width = startWidth,
Height = startHeight,
_margin = margin,
_controlHeight = controlHeight,
_controlSpace = controlSpace,
IsDraggable = isDraggable,
DynamicHeight = dynamicHeight,
_controls = new List<WControl>()
};
uWindow._startX = startX;
uWindow._startY = startY;
UWindowManager.Register(uWindow);
return uWindow;
}
internal void Draw()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: 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_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Invalid comparison between Unknown and I4
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Invalid comparison between Unknown and I4
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
if (!IsDrawing)
{
return;
}
if ((Object)(object)ActiveSkin != (Object)null)
{
GUI.skin = ActiveSkin;
}
if (UWindowManager.AllWindowsDisabled)
{
GUI.enabled = false;
}
Event current = Event.current;
Rect val;
if ((int)current.type == 0)
{
val = new Rect(X, Y, Width, Height);
if (((Rect)(ref val)).Contains(current.mousePosition))
{
UWindowManager.BringUWindowToFront(this);
}
}
if (IsDraggable && (!UWindowManager.AnyWindowDragging || _isDragging))
{
if ((int)current.type == 0)
{
val = new Rect(X, Y, Width, _controlHeight * 1.25f);
if (((Rect)(ref val)).Contains(current.mousePosition))
{
_isDragging = true;
UWindowManager.AnyWindowDragging = true;
goto IL_0125;
}
}
if ((int)current.type == 1)
{
_isDragging = false;
UWindowManager.AnyWindowDragging = false;
}
goto IL_0125;
}
goto IL_0171;
IL_0125:
if ((int)current.type == 3 && _isDragging)
{
X += current.delta.x;
Y += current.delta.y;
}
goto IL_0171;
IL_0171:
if (X < 0f)
{
X = 0f;
}
if (Y < 0f)
{
Y = 0f;
}
if (X + Width > (float)Screen.width)
{
X = (float)Screen.width - Width;
}
if (Y + Height > (float)Screen.height)
{
Y = (float)Screen.height - Height;
}
_nextControlY = Y + _controlHeight + _margin;
if (_isDragging)
{
GUI.enabled = false;
}
GUI.Box(new Rect(X, Y, Width, Height), "");
GUI.Box(new Rect(X, Y, Width, 25f), WindowTitle);
if ((Object)(object)ActiveSkin != (Object)null)
{
GUI.skin = ActiveSkin;
}
foreach (WControl control in _controls)
{
control.Draw(NextControlRect(control.SameLineRatio));
}
GUI.enabled = true;
}
public void ResetPosition()
{
X = _startX;
Y = _startY;
}
public bool SaveCfg(string absolutePath)
{
try
{
INIParser iNIParser = new INIParser();
iNIParser.Open(absolutePath);
string sectionName = "UWindow." + WindowTitle;
iNIParser.WriteValue(sectionName, "windowTitle", WindowTitle);
iNIParser.WriteValue(sectionName, "x", X);
iNIParser.WriteValue(sectionName, "y", Y);
iNIParser.WriteValue(sectionName, "width", Width);
iNIParser.WriteValue(sectionName, "height", Height);
iNIParser.WriteValue(sectionName, "margin", _margin);
iNIParser.WriteValue(sectionName, "controlHeight", _controlHeight);
iNIParser.WriteValue(sectionName, "controlSpace", _controlSpace);
for (int i = 0; i < _controls.Count; i++)
{
_controls[i].ExportData(i, sectionName, $"Control{i}.", iNIParser);
}
iNIParser.Close();
return true;
}
catch
{
return false;
}
}
public bool LoadCfg(string absolutePath)
{
if (!File.Exists(absolutePath))
{
return false;
}
try
{
INIParser iNIParser = new INIParser();
iNIParser.Open(absolutePath);
string sectionName = "UWindow." + WindowTitle;
WindowTitle = iNIParser.ReadValue(sectionName, "windowTitle", WindowTitle);
X = iNIParser.ReadValue(sectionName, "x", X);
Y = iNIParser.ReadValue(sectionName, "y", Y);
Width = iNIParser.ReadValue(sectionName, "width", Width);
Height = iNIParser.ReadValue(sectionName, "height", Height);
_margin = iNIParser.ReadValue(sectionName, "margin", _margin);
_controlHeight = iNIParser.ReadValue(sectionName, "controlHeight", _controlHeight);
_controlSpace = iNIParser.ReadValue(sectionName, "controlSpace", _controlSpace);
for (int i = 0; i < _controls.Count; i++)
{
_controls[i].ImportData(i, sectionName, $"Control{i}.", iNIParser);
}
iNIParser.Close();
return true;
}
catch
{
return false;
}
}
public bool LoadSkin(GUISkin mainSkin)
{
if ((Object)(object)mainSkin == (Object)null)
{
return false;
}
ActiveSkin = mainSkin;
return true;
}
public bool LoadSkinFromAssetBundle(string absolutePathAssetBundle, string mainSkinName)
{
AssetBundle assetBundle = AssetBundle.LoadFromFile(absolutePathAssetBundle);
return LoadSkinFromAssetBundle(assetBundle, mainSkinName);
}
public bool LoadSkinFromAssetBundle(Stream assetFromStream, string mainSkinName)
{
AssetBundle assetBundle = AssetBundle.LoadFromStream(assetFromStream);
return LoadSkinFromAssetBundle(assetBundle, mainSkinName);
}
public bool LoadSkinFromAssetBundle(byte[] assetFromMemory, string mainSkinName)
{
AssetBundle assetBundle = AssetBundle.LoadFromMemory(assetFromMemory);
return LoadSkinFromAssetBundle(assetBundle, mainSkinName);
}
public bool LoadSkinFromAssetBundle(AssetBundle assetBundle, string mainSkinName)
{
if ((Object)(object)assetBundle == (Object)null)
{
return false;
}
LoadSkin(assetBundle.LoadAsset<GUISkin>(mainSkinName));
return true;
}
public bool RestoreDefaultSkin()
{
if ((Object)(object)UWindowManager.DefaultSkin == (Object)null)
{
return false;
}
ActiveSkin = UWindowManager.DefaultSkin;
return true;
}
public static bool RestoreGlobalDefaultSkin()
{
return UWindowManager.LoadGlobalSkin_internal(UWindowManager.DefaultSkin);
}
public static bool LoadGlobalSkin(GUISkin skin)
{
return UWindowManager.LoadGlobalSkin_internal(skin);
}
private Rect NextControlRect(float sameLineRatio)
{
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
float num = Width - _margin * 2f;
Rect result = default(Rect);
((Rect)(ref result))..ctor(X + _margin + _sameLineOffset, _nextControlY, num, _controlHeight);
if (sameLineRatio.Equals(1f))
{
_nextControlY += _controlHeight + _controlSpace;
}
else
{
((Rect)(ref result)).width = ((Rect)(ref result)).width * sameLineRatio;
_sameLineOffset += ((Rect)(ref result)).width;
if (_sameLineOffset.Equals(num))
{
_nextControlY += _controlHeight + _controlSpace;
_sameLineOffset = 0f;
}
}
return result;
}
public void Add(WControl c)
{
_controls.Add(c);
if (_nextLineRatios.Count > 0)
{
c.SameLineRatio = _nextLineRatios[0];
_nextLineRatios.RemoveAt(0);
}
if (!DynamicHeight)
{
return;
}
float num = 25f + _margin;
float num2 = _controlHeight + _controlSpace;
int num3 = 0;
float num4 = 1f;
foreach (WControl control in _controls)
{
if (control.SameLineRatio.Equals(1f) || num4 < 0.05f)
{
num3++;
num4 = 1f;
continue;
}
num4 -= control.SameLineRatio;
if (num4 < 0.05f)
{
num3++;
}
}
Height = num + num2 * (float)num3;
}
public bool SameLine(int ratio1 = 1, int ratio2 = 1, int ratio3 = -1, int ratio4 = -1, int ratio5 = -1)
{
if (_nextLineRatios.Count > 0)
{
return false;
}
if (ratio1 <= 0 || ratio2 <= 0)
{
return false;
}
List<int> list = new List<int> { ratio1, ratio2 };
if (ratio3 > 0)
{
list.Add(ratio3);
if (ratio4 > 0)
{
list.Add(ratio4);
if (ratio5 > 0)
{
list.Add(ratio5);
}
}
}
int num = list.Min();
List<float> list2 = new List<float>();
foreach (int item in list)
{
list2.Add((float)item / (float)num);
}
float num2 = list2.Sum();
list2.Clear();
foreach (int item2 in list)
{
list2.Add((float)item2 / num2);
}
_nextLineRatios = list2;
return true;
}
public UWindowControls.WSpace Space()
{
UWindowControls.WSpace wSpace = new UWindowControls.WSpace();
Add(wSpace);
return wSpace;
}
public UWindowControls.WLabel Label(string text)
{
UWindowControls.WLabel wLabel = new UWindowControls.WLabel(text);
Add(wLabel);
return wLabel;
}
public UWindowControls.WButton Button(string text, Action onPressed)
{
UWindowControls.WButton wButton = new UWindowControls.WButton(onPressed, text);
Add(wButton);
return wButton;
}
public UWindowControls.WToggle Toggle(string text, Action<bool> onValueChanged, bool value = false)
{
UWindowControls.WToggle wToggle = new UWindowControls.WToggle(onValueChanged, value, text);
Add(wToggle);
return wToggle;
}
public UWindowControls.WSlider Slider(string text, Action<float> onValueChanged, float value, float min, float max, bool numberIndicator = false, string numberIndicatorFormat = "0.##")
{
UWindowControls.WSlider wSlider = new UWindowControls.WSlider(onValueChanged, value, min, max, numberIndicator, numberIndicatorFormat, text);
Add(wSlider);
return wSlider;
}
public UWindowControls.WTextField TextField(string text, Action<string> onValueChanged, string value, int maxSymbolLength = int.MaxValue, string regexReplace = "")
{
UWindowControls.WTextField wTextField = new UWindowControls.WTextField(onValueChanged, value, maxSymbolLength, regexReplace, text);
Add(wTextField);
return wTextField;
}
public UWindowControls.WIntField IntField(string text, Action<int> onValueChanged, int value, int maxSymbolLength = int.MaxValue)
{
UWindowControls.WIntField wIntField = new UWindowControls.WIntField(onValueChanged, value, maxSymbolLength, text);
Add(wIntField);
return wIntField;
}
public UWindowControls.WFloatField FloatField(string text, Action<float> onValueChanged, float value, int maxSymbolLength = int.MaxValue)
{
UWindowControls.WFloatField wFloatField = new UWindowControls.WFloatField(onValueChanged, value, maxSymbolLength, text);
Add(wFloatField);
return wFloatField;
}
public UWindowControls.WColorPicker ColorPicker(string text, Action<Color> onValueChanged, Color value)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
UWindowControls.WColorPicker wColorPicker = new UWindowControls.WColorPicker(onValueChanged, value, text, _controlHeight);
Add(wColorPicker);
return wColorPicker;
}
public UWindowControls.WDropDown DropDown(string text, Action<int> onValueChanged, int value, Dictionary<int, string> list)
{
UWindowControls.WDropDown wDropDown = new UWindowControls.WDropDown(onValueChanged, value, list, text);
Add(wDropDown);
return wDropDown;
}
public UWindowControls.WSeparator Separator(Color lineColor = default(Color), float lineThickness = 2f)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (lineColor == default(Color))
{
((Color)(ref lineColor))..ctor(1f, 1f, 1f, 0.9f);
}
UWindowControls.WSeparator wSeparator = new UWindowControls.WSeparator(lineColor, lineThickness);
Add(wSeparator);
return wSeparator;
}
}
public static class UWindowControls
{
public class WLabel : WControl
{
private Rect _rect = default(Rect);
internal WLabel(string displayedString)
: base(displayedString)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (displayedString == null || string.IsNullOrEmpty(displayedString) || string.IsNullOrWhiteSpace(displayedString))
{
Logger.war("Label is null or empty! Are you sure you don't want to use Space control instead?");
}
}
internal override void Draw(Rect r)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
_rect = r;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(((Rect)(ref _rect)).x, ((Rect)(ref _rect)).y);
((Rect)(ref _rect)).x = val.x;
((Rect)(ref _rect)).y = val.y;
GUI.Label(_rect, DisplayedString);
}
internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ExportData(id, sectionName, keyBaseName, ini);
}
internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ImportData(id, sectionName, keyBaseName, ini);
}
}
public class WButton : WControl
{
private readonly Action _onPressed;
internal WButton(Action onPressed, string displayedString)
: base(displayedString)
{
_onPressed = onPressed;
}
internal override void Draw(Rect r)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (UGUI.Button(r, DisplayedString))
{
_onPressed();
}
}
}
public class WToggle : WControl
{
public readonly Action<bool> OnValueChanged;
public bool Value;
private GUIStyle _toggleStyle = null;
internal WToggle(Action<bool> onValueChanged, bool value, string displayedString)
: base(displayedString)
{
Value = value;
OnValueChanged = onValueChanged;
}
internal override void Draw(Rect r)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
Rect val = r;
if (_toggleStyle == null)
{
_toggleStyle = new GUIStyle(GUI.skin.toggle);
}
int num = Mathf.RoundToInt(((Rect)(ref r)).width - ((Rect)(ref r)).height);
_toggleStyle.overflow.left = -num;
_toggleStyle.overflow.right = num;
bool flag = GUI.Toggle(val, Value, string.Empty, _toggleStyle);
if (flag != Value)
{
OnValueChanged(flag);
}
Value = flag;
}
internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ExportData(id, sectionName, keyBaseName, ini);
ini.WriteValue(sectionName, keyBaseName + "value", Value);
}
internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ImportData(id, sectionName, keyBaseName, ini);
Value = ini.ReadValue(sectionName, keyBaseName + "value", Value);
}
}
public class WSlider : WControl
{
public readonly Action<float> OnValueChanged;
public float Value;
private float _min;
private float _max;
private bool _numberIndicator;
private bool _labelOnLeft;
private string _numberIndicatorFormat;
internal WSlider(Action<float> onValueChanged, float value, float min, float max, bool numberIndicator, string numberIndicatorFormat, string displayedString, bool labelOnLeft = true)
: base(displayedString)
{
OnValueChanged = onValueChanged;
Value = value;
_min = min;
_max = max;
_numberIndicator = numberIndicator;
_numberIndicatorFormat = numberIndicatorFormat;
_labelOnLeft = labelOnLeft;
}
internal override void Draw(Rect r)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
float num = UControls.LabelSlider(r, DisplayedString, Value, _min, _max, _numberIndicator, _numberIndicatorFormat, _labelOnLeft);
if (!num.Equals(Value))
{
OnValueChanged(num);
}
Value = num;
}
internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ExportData(id, sectionName, keyBaseName, ini);
ini.WriteValue(sectionName, keyBaseName + "value", Value);
}
internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ImportData(id, sectionName, keyBaseName, ini);
Value = ini.ReadValue(sectionName, keyBaseName + "value", Value);
}
}
public class WTextField : WControl
{
public readonly Action<string> OnValueChanged;
public string Value;
private string _regexReplace;
private int _maxSymbolLength;
private bool _labelOnLeft;
internal WTextField(Action<string> onValueChanged, string value, int maxSymbolLength, string regexReplace, string displayedString, bool labelOnLeft = true)
: base(displayedString)
{
OnValueChanged = onValueChanged;
Value = value;
_regexReplace = regexReplace;
_maxSymbolLength = maxSymbolLength;
_labelOnLeft = labelOnLeft;
}
internal override void Draw(Rect r)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
string text = UControls.LabelTextField(r, DisplayedString, Value, _maxSymbolLength, _regexReplace, _labelOnLeft);
if (_regexReplace != string.Empty)
{
text = Regex.Replace(text, _regexReplace, "");
}
if (text != Value)
{
OnValueChanged(text);
}
Value = text;
}
internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ExportData(id, sectionName, keyBaseName, ini);
ini.WriteValue(sectionName, keyBaseName + "value", Value);
}
internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ImportData(id, sectionName, keyBaseName, ini);
Value = ini.ReadValue(sectionName, keyBaseName + "value", Value);
}
}
public class WIntField : WControl
{
public readonly Action<int> OnValueChanged;
public int Value;
private string _regexReplace;
private int _maxSymbolLength;
private bool _labelOnLeft;
internal WIntField(Action<int> onValueChanged, int value, int maxSymbolLength, string displayedString, bool labelOnLeft = true)
: base(displayedString)
{
OnValueChanged = onValueChanged;
Value = value;
_regexReplace = "[^0-9]";
_maxSymbolLength = maxSymbolLength;
_labelOnLeft = labelOnLeft;
}
internal override void Draw(Rect r)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
string text = UControls.LabelTextField(r, DisplayedString, Value.ToString(), _maxSymbolLength, _regexReplace, _labelOnLeft);
if (_regexReplace != string.Empty)
{
text = Regex.Replace(text, _regexReplace, "");
}
long.TryParse(text, out var result);
int num = (int)((result > int.MaxValue) ? int.MaxValue : result);
if (!result.Equals(Value))
{
OnValueChanged(num);
}
Value = num;
}
internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ExportData(id, sectionName, keyBaseName, ini);
ini.WriteValue(sectionName, keyBaseName + "value", Value);
}
internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ImportData(id, sectionName, keyBaseName, ini);
Value = ini.ReadValue(sectionName, keyBaseName + "value", Value);
}
}
public class WFloatField : WControl
{
public readonly Action<float> OnValueChanged;
public float Value;
private string _regexReplace;
private int _maxSymbolLength;
private bool _labelOnLeft;
internal WFloatField(Action<float> onValueChanged, float value, int maxSymbolLength, string displayedString, bool labelOnLeft = true)
: base(displayedString)
{
OnValueChanged = onValueChanged;
Value = value;
_regexReplace = "[^0-9.,]";
_maxSymbolLength = maxSymbolLength;
_labelOnLeft = labelOnLeft;
}
internal override void Draw(Rect r)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
string text = UControls.LabelTextField(r, DisplayedString, Value.ToString(), _maxSymbolLength, _regexReplace, _labelOnLeft);
if (_regexReplace != string.Empty)
{
text = Regex.Replace(text, _regexReplace, "");
}
text = text.Replace(',', '.');
double.TryParse(text, out var result);
float num = (float)result;
if (!num.Equals(Value))
{
OnValueChanged(num);
}
Value = num;
}
internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ExportData(id, sectionName, keyBaseName, ini);
ini.WriteValue(sectionName, keyBaseName + "value", Value);
}
internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ImportData(id, sectionName, keyBaseName, ini);
Value = ini.ReadValue(sectionName, keyBaseName + "value", Value);
}
}
public class WColorPicker : WControl
{
public Color CurrentColor;
private readonly Action<Color> _onValueChanged;
private bool _isPickerOpen = false;
private Rect _rect;
private readonly float _controlHeight;
private Color _revertColor;
private readonly GUIStyle _whiteButtonGUIStyle = new GUIStyle
{
normal = new GUIStyleState
{
background = Texture2D.whiteTexture
}
};
private bool IsPickerOpen
{
get
{
return _isPickerOpen;
}
set
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
_isPickerOpen = value;
UWindowManager.AllWindowsDisabled = value;
if (value)
{
UWindowManager.ActiveOptionMenu = DrawPicker;
_revertColor = CurrentColor;
}
else
{
UWindowManager.ActiveOptionMenu = null;
}
}
}
internal WColorPicker(Action<Color> onValueChanged, Color clr, string displayedString, float controlHeight)
: base(displayedString)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_002a: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
_onValueChanged = onValueChanged;
CurrentColor = clr;
_controlHeight = controlHeight;
_revertColor = CurrentColor;
}
internal override void Draw(Rect r)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
_rect = r;
bool flag = !string.IsNullOrEmpty(DisplayedString);
Rect val = default(Rect);
((Rect)(ref val))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width * 0.666f, ((Rect)(ref r)).height);
Rect bounds = default(Rect);
((Rect)(ref bounds))..ctor(((Rect)(ref val)).x + ((Rect)(ref val)).width, ((Rect)(ref r)).y, ((Rect)(ref r)).width - ((Rect)(ref val)).width, ((Rect)(ref r)).height);
if (!flag)
{
((Rect)(ref bounds))..ctor(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 2f, ((Rect)(ref r)).height);
}
if (UWindowManager.AllWindowsDisabled && IsPickerOpen)
{
GUI.enabled = true;
}
if (flag)
{
GUI.Label(val, DisplayedString);
}
Color color = GUI.color;
GUI.color = CurrentColor;
if (UGUI.Button(bounds, string.Empty, _whiteButtonGUIStyle))
{
IsPickerOpen = !IsPickerOpen;
}
if (UWindowManager.AllWindowsDisabled && IsPickerOpen)
{
GUI.enabled = false;
}
GUI.color = color;
}
internal void DrawPicker()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
float num = 200f;
Color color = CurrentColor;
if (UControls.ColorPicker(new Vector2(((Rect)(ref _rect)).x + ((Rect)(ref _rect)).width - num, ((Rect)(ref _rect)).y + ((Rect)(ref _rect)).height), ref color, mainBoxColoredTexture: true, num, _controlHeight))
{
color = _revertColor;
IsPickerOpen = false;
}
if (color != CurrentColor)
{
_onValueChanged(color);
}
CurrentColor = color;
}
internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
base.ExportData(id, sectionName, keyBaseName, ini);
ini.WriteValue(sectionName, keyBaseName + "color", CurrentColor);
}
internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
base.ImportData(id, sectionName, keyBaseName, ini);
CurrentColor = ini.ReadValue(sectionName, keyBaseName + "color", CurrentColor);
}
}
public class WDropDown : WControl
{
public readonly Action<int> OnValueChanged;
public readonly Dictionary<int, string> ValuesList;
public int Value;
private bool _isDropDownOpen = false;
private Vector2 _scrollPos;
private Rect _selectedRect;
private static GUIStyle _dropDownOptionGUIStyle;
private bool IsDropDownOpen
{
get
{
return _isDropDownOpen;
}
set
{
_isDropDownOpen = value;
UWindowManager.AllWindowsDisabled = value;
if (value)
{
UWindowManager.ActiveOptionMenu = DrawDropDown;
}
else
{
UWindowManager.ActiveOptionMenu = null;
}
}
}
internal WDropDown(Action<int> onValueChanged, int value, Dictionary<int, string> valuesList, string displayedString)
: base(displayedString)
{
OnValueChanged = onValueChanged;
Value = value;
ValuesList = valuesList;
}
internal override void Draw(Rect r)
{
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
if (_dropDownOptionGUIStyle == null)
{
_dropDownOptionGUIStyle = new GUIStyle(GUI.skin.label);
_dropDownOptionGUIStyle.hover.textColor = Color.gray;
_dropDownOptionGUIStyle.onHover.textColor = Color.gray;
}
float num = 5f;
string text = ValuesList[Value];
Rect val = default(Rect);
((Rect)(ref val))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width * 0.5f, ((Rect)(ref r)).height);
_selectedRect = new Rect(((Rect)(ref r)).x + ((Rect)(ref val)).width + num, ((Rect)(ref r)).y, ((Rect)(ref r)).width - ((Rect)(ref val)).width - num, ((Rect)(ref r)).height);
if (string.IsNullOrEmpty(DisplayedString))
{
_selectedRect = r;
}
if (UWindowManager.AllWindowsDisabled && IsDropDownOpen)
{
GUI.enabled = true;
}
if (!string.IsNullOrEmpty(DisplayedString))
{
GUI.Label(val, DisplayedString);
}
if (UGUI.Button(_selectedRect, text))
{
IsDropDownOpen = !IsDropDownOpen;
}
if (UWindowManager.AllWindowsDisabled && IsDropDownOpen)
{
GUI.enabled = false;
}
}
internal void DrawDropDown()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
bool isOpen;
int num = UControls.DropDown(new Vector2(((Rect)(ref _selectedRect)).x, ((Rect)(ref _selectedRect)).y + ((Rect)(ref _selectedRect)).height), ValuesList, _scrollPos, out _scrollPos, out isOpen, _dropDownOptionGUIStyle, mainBoxColoredTexture: true, ((Rect)(ref _selectedRect)).width);
if ((num >= 0) & (num != Value))
{
OnValueChanged(num);
}
if (num >= 0)
{
Value = num;
}
IsDropDownOpen = isOpen;
}
internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ExportData(id, sectionName, keyBaseName, ini);
ini.WriteValue(sectionName, keyBaseName + "value", Value);
}
internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
base.ImportData(id, sectionName, keyBaseName, ini);
Value = ini.ReadValue(sectionName, keyBaseName + "value", Value);
}
}
public class WSeparator : WControl
{
private Color _lineColor;
private float _lineThickness;
public WSeparator(Color lineColor, float lineThickness)
: base(string.Empty)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
_lineColor = lineColor;
_lineThickness = lineThickness;
}
internal override void Draw(Rect r)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
Color color = _lineColor;
if (!GUI.enabled)
{
color = _lineColor * new Color(1f, 1f, 1f, 0.5f);
}
Rect r2 = default(Rect);
((Rect)(ref r2))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y + ((Rect)(ref r)).height / 2f - _lineThickness / 2f, ((Rect)(ref r)).width, _lineThickness);
UControls.ColoredBox(r2, color);
}
}
public class WSpace : WControl
{
internal WSpace()
: base(string.Empty)
{
}
internal override void Draw(Rect r)
{
}
internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
}
internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
}
}
}
public abstract class WControl
{
internal float SameLineRatio = 1f;
internal string DisplayedString = null;
internal WControl(string displayedString)
{
DisplayedString = displayedString;
}
internal abstract void Draw(Rect r);
internal virtual void ExportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
ini.WriteValue(sectionName, keyBaseName + "displayString", DisplayedString);
}
internal virtual void ImportData(int id, string sectionName, string keyBaseName, INIParser ini)
{
DisplayedString = ini.ReadValue(sectionName, keyBaseName + "displayString", DisplayedString);
}
}
internal static class UWindowManager
{
public static GameObject BManagerG = null;
public static UWindowManagerBehaviour BManager = null;
public static bool AllWindowsDisabled = false;
public static bool AnyWindowDragging = false;
public static Action ActiveOptionMenu = null;
public static readonly Vector2 DynamicWindowsMargin = Vector2.one * 10f;
private static Vector2 _dynamicWindowsNext = Vector2.one * 10f;
public static List<UWindow> Windows { get; private set; }
public static bool IsDrawing { get; set; } = true;
public static GUISkin DefaultSkin { get; internal set; } = null;
internal static void Register(UWindow win)
{
if (Windows == null)
{
Windows = new List<UWindow>();
}
if ((Object)(object)BManager == (Object)null || (Object)(object)BManagerG == (Object)null)
{
InitializeManager();
}
string winGuid = Guid.NewGuid().ToString();
win.WinGuid = winGuid;
Windows.Add(win);
}
internal static bool LoadGlobalSkin_internal(GUISkin skin)
{
if ((Object)(object)skin == (Object)null)
{
return false;
}
foreach (UWindow window in Windows)
{
window.LoadSkin(skin);
}
return true;
}
public static Vector2 GetDynamicWindowPos(float currentWidth)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
Vector2 dynamicWindowsNext = _dynamicWindowsNext;
_dynamicWindowsNext.x += currentWidth + DynamicWindowsMargin.x;
return dynamicWindowsNext;
}
internal static void BringUWindowToFront(UWindow win)
{
Windows.Remove(win);
Windows.Add(win);
}
private static int GetIndexByGuid(string guid)
{
return Windows.FindIndex((UWindow win) => win.WinGuid == guid);
}
private static UWindow GetUWinByGuid(string guid)
{
return Windows.FirstOrDefault((UWindow w) => w.WinGuid == guid);
}
internal static void OnBehaviourGUI()
{
if (!IsDrawing)
{
return;
}
foreach (UWindow item in Windows.ToList())
{
item.Draw();
}
if (ActiveOptionMenu != null)
{
ActiveOptionMenu();
}
}
private static void InitializeManager()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
BManagerG = new GameObject("UrGUI Manager");
BManager = BManagerG.AddComponent<UWindowManagerBehaviour>();
UWindowManagerBehaviour.Instance.LoadDefaultSkin();
}
}
internal class UWindowManagerBehaviour : MonoBehaviour
{
public static UWindowManagerBehaviour Instance { get; private set; }
private void Awake()
{
if ((Object)(object)Instance != (Object)null)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
Instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
}
private void Start()
{
}
private void OnEnable()
{
}
private void OnGUI()
{
UWindowManager.OnBehaviourGUI();
}
public void LoadDefaultSkin()
{
((MonoBehaviour)this).StartCoroutine(m_LoadDefaultSkin());
}
private IEnumerator m_LoadDefaultSkin()
{
Assembly a = Assembly.GetExecutingAssembly();
byte[] ba = null;
int nOfB = 0;
using (Stream resFilestream = a.GetManifestResourceStream("UrGUI.Skins.main"))
{
if (resFilestream == null)
{
Debug.LogWarning((object)"Couldn't load default skin! Filestream is null");
yield break;
}
ba = new byte[resFilestream.Length];
nOfB = resFilestream.Read(ba, 0, ba.Length);
}
if (ba.Length != nOfB)
{
Debug.LogError((object)"Stream didn't ready all of available bytes!");
}
AssetBundleCreateRequest assetBundleReq = AssetBundle.LoadFromMemoryAsync(ba);
while (!((AsyncOperation)assetBundleReq).isDone)
{
Logger.log($"Loading skin asset-bundle from memory... {((AsyncOperation)assetBundleReq).progress * 100f:0.##}%");
yield return null;
}
Logger.log("AssetBundle loaded!");
AssetBundleRequest skinReq = assetBundleReq.assetBundle.LoadAssetAsync<GUISkin>("main");
while (!((AsyncOperation)skinReq).isDone)
{
Logger.log($"Loading skin from asset-bundle... {((AsyncOperation)skinReq).progress * 100f:0.##}%");
yield return null;
}
Logger.log("Skin loaded!");
UWindowManager.DefaultSkin = (GUISkin)skinReq.asset;
UWindowManager.LoadGlobalSkin_internal(UWindowManager.DefaultSkin);
yield return null;
}
}
}
namespace UrGUI.UWindow.Utils
{
public static class UControls
{
public static float LabelSlider(Rect rect, string label, float value, float min, float max, bool numberIndicator = false, string numberIndicatorFormat = "0.##", bool labelOnLeft = true, float offsetX = 5f)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: 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)
Vector2 contentStringSize = GUIFormatting.GetContentStringSize(label);
Rect val = default(Rect);
if (labelOnLeft)
{
((Rect)(ref val))..ctor(0f, 0f, contentStringSize.x, ((Rect)(ref rect)).height);
}
else
{
((Rect)(ref val))..ctor(((Rect)(ref rect)).width - contentStringSize.x + offsetX, 0f, contentStringSize.x, ((Rect)(ref rect)).height);
}
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(labelOnLeft ? (((Rect)(ref val)).width + offsetX) : 0f, 0f, ((Rect)(ref rect)).width - ((Rect)(ref val)).width - offsetX, ((Rect)(ref rect)).height);
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(((Rect)(ref val2)).x + ((Rect)(ref val2)).width / 2f - 30f, 0f, ((Rect)(ref val2)).width / 2f, ((Rect)(ref rect)).height);
GUI.BeginGroup(rect);
GUI.Label(val, label);
float result = GUI.HorizontalSlider(val2, value, min, max);
if (numberIndicator)
{
GUI.Label(val3, value.ToString(numberIndicatorFormat));
}
GUI.EndGroup();
return result;
}
public static string LabelTextField(Rect rect, string label, string value, int maxSymbolLength, string regexReplace = "", bool labelOnLeft = true, float offsetX = 5f)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
Vector2 contentStringSize = GUIFormatting.GetContentStringSize(label);
Rect val = default(Rect);
if (labelOnLeft)
{
((Rect)(ref val))..ctor(0f, 0f, contentStringSize.x, ((Rect)(ref rect)).height);
}
else
{
((Rect)(ref val))..ctor(((Rect)(ref rect)).width - contentStringSize.x + offsetX, 0f, contentStringSize.x, ((Rect)(ref rect)).height);
}
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(labelOnLeft ? (((Rect)(ref val)).width + offsetX) : 0f, 0f, ((Rect)(ref rect)).width - ((Rect)(ref val)).width - offsetX, ((Rect)(ref rect)).height);
GUI.BeginGroup(rect);
GUI.Label(val, label);
string text = GUI.TextField(val2, value, maxSymbolLength);
GUI.EndGroup();
if (!string.IsNullOrEmpty(regexReplace))
{
text = Regex.Replace(text, regexReplace, string.Empty);
}
return text;
}
public static Vector3 LabelVector3Field(Rect rect, string label, Vector3 value, Vector3 min, Vector3 max)
{
throw new NotImplementedException();
}
public static bool ColorPicker(Vector2 leftTopCorner, ref Color color, bool mainBoxColoredTexture = false, float sliderWidth = 200f, float controlHeight = 12f, float offsetY = 5f, float margin = 5f)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
float x = GUIFormatting.GetContentStringSize("X: ").x;
Rect val = default(Rect);
((Rect)(ref val))..ctor(leftTopCorner.x, leftTopCorner.y, x + sliderWidth + margin * 2f, controlHeight * 4f + offsetY * 3f + margin * 2f);
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(leftTopCorner.x + margin, leftTopCorner.y + margin, x + sliderWidth, controlHeight * 4f + offsetY * 3f);
if (mainBoxColoredTexture)
{
ColoredBox(val, Color.black);
}
else
{
GUI.Box(val, "");
}
Rect bounds = default(Rect);
((Rect)(ref bounds))..ctor(((Rect)(ref val)).x, ((Rect)(ref val)).y - controlHeight, ((Rect)(ref val)).width / 3f, controlHeight);
if (UGUI.Button(bounds, "Cancel"))
{
return true;
}
GUI.BeginGroup(val2);
Color val3 = color;
val3.r = LabelSlider(new Rect(0f, controlHeight * 0f + offsetY * 0f, ((Rect)(ref val2)).width, controlHeight), "R: ", color.r, 0f, 1f);
val3.g = LabelSlider(new Rect(0f, controlHeight * 1f + offsetY * 1f, ((Rect)(ref val2)).width, controlHeight), "G: ", color.g, 0f, 1f);
val3.b = LabelSlider(new Rect(0f, controlHeight * 2f + offsetY * 2f, ((Rect)(ref val2)).width, controlHeight), "B: ", color.b, 0f, 1f);
val3.a = LabelSlider(new Rect(0f, controlHeight * 3f + offsetY * 3f, ((Rect)(ref val2)).width, controlHeight), "A: ", color.a, 0f, 1f);
GUI.EndGroup();
color = val3;
return false;
}
public static int DropDown(Vector2 leftTopCorner, Dictionary<int, string> list, Vector2 scrollPos, out Vector2 scrollPosNew, out bool isOpen, GUIStyle optionGUIStyle, bool mainBoxColoredTexture = false, float width = 0f, int optionCountShown = 4, float optionHeight = 22f)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
int num = 4;
int result = -1;
isOpen = true;
Rect val = default(Rect);
((Rect)(ref val))..ctor(leftTopCorner.x, leftTopCorner.y, width + 15f, optionHeight * (float)optionCountShown);
if (mainBoxColoredTexture)
{
ColoredBox(val, Color.black);
}
else
{
GUI.Box(val, string.Empty);
}
GUI.BeginGroup(val);
scrollPosNew = GUI.BeginScrollView(new Rect(0f, 0f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), scrollPos, new Rect(0f, 0f, 0f, (float)list.Count * optionHeight));
for (int i = 0; i < list.Count; i++)
{
if (UGUI.Button(new Rect((float)num, (float)i * optionHeight, ((Rect)(ref val)).width - (float)num - 15f, optionHeight), list[i], optionGUIStyle))
{
result = i;
isOpen = false;
}
}
GUI.EndScrollView();
GUI.EndGroup();
return result;
}
public static void ColoredBox(Rect r, Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
Color color2 = GUI.color;
GUI.color = color;
GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture);
GUI.color = color2;
}
}
public static class GUIFormatting
{
public static GUIStyle StringStyle { get; set; } = new GUIStyle(GUI.skin.label);
public static Vector2 GetContentStringSize(string text)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
GUIContent val = new GUIContent(text);
return StringStyle.CalcSize(val);
}
}
}
namespace UrGUI.Utils
{
internal static class UGUI
{
private static int highestDepthID = 0;
private static Vector2 touchBeganPosition = Vector2.zero;
private static EventType lastEventType = (EventType)8;
private static bool wasDragging = false;
private static int frame = 0;
private static int lastEventFrame = 0;
public static bool Button(string text, params GUILayoutOption[] options)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
GUIContent val = new GUIContent(text);
return Button(GUILayoutUtility.GetRect(val, GUI.skin.button, options), val, GUI.skin.button);
}
public static bool Button(string text, GUIStyle style = null, params GUILayoutOption[] options)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
GUIContent val = new GUIContent(text);
return Button(GUILayoutUtility.GetRect(val, style, options), val, style);
}
public static bool Button(Texture image, params GUILayoutOption[] options)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
GUIContent val = new GUIContent(image);
return Button(GUILayoutUtility.GetRect(val, GUI.skin.button, options), val, GUI.skin.button);
}
public static bool Button(Texture image, GUIStyle style = null, params GUILayoutOption[] options)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
GUIContent val = new GUIContent(image);
return Button(GUILayoutUtility.GetRect(val, style, options), val, style);
}
public static bool Button(GUIContent content, params GUILayoutOption[] options)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
return Button(GUILayoutUtility.GetRect(content, GUI.skin.button, options), content, GUI.skin.button);
}
public static bool Button(GUIContent content, GUIStyle style = null, params GUILayoutOption[] options)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
return Button(GUILayoutUtility.GetRect(content, style, options), content, style);
}
public static bool Button(Rect bounds, string text, GUIStyle style = null)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
GUIContent content = new GUIContent(text);
return Button(bounds, content, style);
}
public static bool Button(Rect bounds, Texture image, GUIStyle style = null)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
GUIContent content = new GUIContent(image);
return Button(bounds, content, style);
}
private static bool Button(Rect bounds, GUIContent content, GUIStyle style = null)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Invalid comparison between Unknown and I4
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Invalid comparison between Unknown and I4
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Invalid comparison between Unknown and I4
int controlID = GUIUtility.GetControlID(((object)(Rect)(ref bounds)).GetHashCode(), (FocusType)2);
bool flag = ((Rect)(ref bounds)).Contains(Event.current.mousePosition);
int num = (1000 - GUI.depth) * 1000 + controlID;
if (flag && num > highestDepthID)
{
highestDepthID = num;
}
bool flag2 = highestDepthID == num;
bool flag3 = flag2;
if (style == null)
{
style = GUI.skin.FindStyle("button");
}
if ((int)Event.current.type == 8 && (int)lastEventType != 8)
{
highestDepthID = 0;
frame++;
}
lastEventType = Event.current.type;
if ((int)Event.current.type == 7)
{
bool flag4 = GUIUtility.hotControl == controlID;
style.Draw(bounds, content, flag3, flag4, false, false);
}
if (frame <= 1 + lastEventFrame)
{
return false;
}
EventType typeForControl = Event.current.GetTypeForControl(controlID);
EventType val = typeForControl;
if ((int)val != 0)
{
if ((int)val == 1 && flag2 && !wasDragging)
{
GUIUtility.hotControl = 0;
lastEventFrame = frame;
return true;
}
}
else if (flag2 && !wasDragging)
{
GUIUtility.hotControl = controlID;
}
return false;
}
}
public static class Logger
{
[Flags]
public enum PrintType
{
None = 0,
Error = 1,
Warnings = 2,
Info = 4
}
public static readonly Action<object, PrintType> OnLoggerPrint = delegate
{
};
private static PrintType _debugFilter = PrintType.Error | PrintType.Warnings | PrintType.Info;
public static PrintType DebugFilter
{
get
{
return _debugFilter;
}
set
{
_debugFilter = value;
}
}
internal static void log(object msg)
{
if (_debugFilter.HasFlag(PrintType.Info))
{
Debug.Log(msg);
if (OnLoggerPrint != null)
{
OnLoggerPrint(msg, PrintType.Info);
}
}
}
internal static void war(object msg)
{
if (_debugFilter.HasFlag(PrintType.Warnings))
{
Debug.LogWarning(msg);
if (OnLoggerPrint != null)
{
OnLoggerPrint(msg, PrintType.Warnings);
}
}
}
internal static void err(object msg)
{
if (_debugFilter.HasFlag(PrintType.Error))
{
Debug.LogError(msg);
if (OnLoggerPrint != null)
{
OnLoggerPrint(msg, PrintType.Error);
}
}
}
}
public class INIParser
{
public int error = 0;
private object m_Lock = new object();
private string m_FileName = null;
private string m_iniString = null;
private bool m_AutoFlush = false;
private Dictionary<string, Dictionary<string, string>> m_Sections = new Dictionary<string, Dictionary<string, string>>();
private Dictionary<string, Dictionary<string, string>> m_Modified = new Dictionary<string, Dictionary<string, string>>();
private bool m_CacheModified = false;
public string FileName => m_FileName;
public string iniString => m_iniString;
public void Open(string path)
{
m_FileName = path;
if (File.Exists(m_FileName))
{
m_iniString = File.ReadAllText(m_FileName);
}
else
{
FileStream fileStream = File.Create(m_FileName);
fileStream.Close();
m_iniString = "";
}
Initialize(m_iniString, AutoFlush: false);
}
public void Open(TextAsset name)
{
if ((Object)(object)name == (Object)null)
{
error = 1;
m_iniString = "";
m_FileName = null;
Initialize(m_iniString, AutoFlush: false);
return;
}
m_FileName = Application.persistentDataPath + ((Object)name).name;
if (File.Exists(m_FileName))
{
m_iniString = File.ReadAllText(m_FileName);
}
else
{
m_iniString = name.text;
}
Initialize(m_iniString, AutoFlush: false);
}
public void OpenFromString(string str)
{
m_FileName = null;
Initialize(str, AutoFlush: false);
}
public override string ToString()
{
return m_iniString;
}
private void Initialize(string iniString, bool AutoFlush)
{
m_iniString = iniString;
m_AutoFlush = AutoFlush;
Refresh();
}
public void Close()
{
lock (m_Lock)
{
PerformFlush();
m_FileName = null;
m_iniString = null;
}
}
private string ParseSectionName(string Line)
{
if (!Line.StartsWith("["))
{
return null;
}
if (!Line.EndsWith("]"))
{
return null;
}
if (Line.Length < 3)
{
return null;
}
return Line.Substring(1, Line.Length - 2);
}
private bool ParseKeyValuePair(string Line, ref string Key, ref string Value)
{
int num;
if ((num = Line.IndexOf('=')) <= 0)
{
return false;
}
int num2 = Line.Length - num - 1;
Key = Line.Substring(0, num).Trim();
if (Key.Length <= 0)
{
return false;
}
Value = ((num2 > 0) ? Line.Substring(num + 1, num2).Trim() : "");
return true;
}
private bool isComment(string Line)
{
string Key = null;
string Value = null;
if (ParseSectionName(Line) != null)
{
return false;
}
if (ParseKeyValuePair(Line, ref Key, ref Value))
{
return false;
}
return true;
}
private void Refresh()
{
lock (m_Lock)
{
StringReader stringReader = null;
try
{
m_Sections.Clear();
m_Modified.Clear();
stringReader = new StringReader(m_iniString);
Dictionary<string, string> dictionary = null;
string Key = null;
string Value = null;
string text;
while ((text = stringReader.ReadLine()) != null)
{
text = text.Trim();
string text2 = ParseSectionName(text);
if (text2 != null)
{
if (m_Sections.ContainsKey(text2))
{
dictionary = null;
continue;
}
dictionary = new Dictionary<string, string>();
m_Sections.Add(text2, dictionary);
}
else if (dictionary != null && ParseKeyValuePair(text, ref Key, ref Value) && !dictionary.ContainsKey(Key))
{
dictionary.Add(Key, Value);
}
}
}
finally
{
stringReader?.Close();
stringReader = null;
}
}
}
private void PerformFlush()
{
if (!m_CacheModified)
{
return;
}
m_CacheModified = false;
StringWriter stringWriter = new StringWriter();
try
{
Dictionary<string, string> value = null;
Dictionary<string, string> value2 = null;
StringReader stringReader = null;
try
{
stringReader = new StringReader(m_iniString);
string Key = null;
string value3 = null;
bool flag = true;
bool flag2 = false;
string Key2 = null;
string Value = null;
while (flag)
{
string text = stringReader.ReadLine();
flag = text != null;
bool flag3;
string text2;
if (flag)
{
flag3 = true;
text = text.Trim();
text2 = ParseSectionName(text);
}
else
{
flag3 = false;
text2 = null;
}
if (text2 != null || !flag)
{
if (value != null && value.Count > 0)
{
StringBuilder stringBuilder = stringWriter.GetStringBuilder();
while (stringBuilder[stringBuilder.Length - 1] == '\n' || stringBuilder[stringBuilder.Length - 1] == '\r')
{
stringBuilder.Length--;
}
stringWriter.WriteLine();
foreach (string key in value.Keys)
{
if (value.TryGetValue(key, out value3))
{
stringWriter.Write(key);
stringWriter.Write('=');
stringWriter.WriteLine(value3);
}
}
stringWriter.WriteLine();
value.Clear();
}
if (flag && !m_Modified.TryGetValue(text2, out value))
{
value = null;
}
}
else if (value != null && ParseKeyValuePair(text, ref Key, ref value3) && value.TryGetValue(Key, out value3))
{
flag3 = false;
value.Remove(Key);
stringWriter.Write(Key);
stringWriter.Write('=');
stringWriter.WriteLine(value3);
}
if (flag3)
{
if (text2 != null)
{
if (!m_Sections.ContainsKey(text2))
{
flag2 = true;
value2 = null;
}
else
{
flag2 = false;
m_Sections.TryGetValue(text2, out value2);
}
}
else if (value2 != null && ParseKeyValuePair(text, ref Key2, ref Value))
{
flag2 = ((!value2.ContainsKey(Key2)) ? true : false);
}
}
if (flag3)
{
if (isComment(text))
{
stringWriter.WriteLine(text);
}
else if (!flag2)
{
stringWriter.WriteLine(text);
}
}
}
stringReader.Close();
stringReader = null;
}
finally
{
stringReader?.Close();
stringReader = null;
}
foreach (KeyValuePair<string, Dictionary<string, string>> item in m_Modified)
{
value = item.Value;
if (value.Count <= 0)
{
continue;
}
stringWriter.WriteLine();
stringWriter.Write('[');
stringWriter.Write(item.Key);
stringWriter.WriteLine(']');
foreach (KeyValuePair<string, string> item2 in value)
{
stringWriter.Write(item2.Key);
stringWriter.Write('=');
stringWriter.WriteLine(item2.Value);
}
value.Clear();
}
m_Modified.Clear();
m_iniString = stringWriter.ToString();
stringWriter.Close();
stringWriter = null;
if (m_FileName != null)
{
File.WriteAllText(m_FileName, m_iniString);
}
}
finally
{
stringWriter?.Close();
stringWriter = null;
}
}
public bool IsSectionExists(string SectionName)
{
return m_Sections.ContainsKey(SectionName);
}
public bool IsKeyExists(string SectionName, string Key)
{
if (m_Sections.ContainsKey(SectionName))
{
m_Sections.TryGetValue(SectionName, out var value);
return value.ContainsKey(Key);
}
return false;
}
public void SectionDelete(string SectionName)
{
if (!IsSectionExists(SectionName))
{
return;
}
lock (m_Lock)
{
m_CacheModified = true;
m_Sections.Remove(SectionName);
m_Modified.Remove(SectionName);
if (m_AutoFlush)
{
PerformFlush();
}
}
}
public void KeyDelete(string SectionName, string Key)
{
if (!IsKeyExists(SectionName, Key))
{
return;
}
lock (m_Lock)
{
m_CacheModified = true;
m_Sections.TryGetValue(SectionName, out var value);
value.Remove(Key);
if (m_Modified.TryGetValue(SectionName, out value))
{
value.Remove(SectionName);
}
if (m_AutoFlush)
{
PerformFlush();
}
}
}
public string ReadValue(string SectionName, string Key, string DefaultValue)
{
lock (m_Lock)
{
if (!m_Sections.TryGetValue(SectionName, out var value))
{
return DefaultValue;
}
if (!value.TryGetValue(Key, out var value2))
{
return DefaultValue;
}
return value2;
}
}
public void WriteValue(string SectionName, string Key, string Value)
{
lock (m_Lock)
{
m_CacheModified = true;
if (!m_Sections.TryGetValue(SectionName, out var value))
{
value = new Dictionary<string, string>();
m_Sections.Add(SectionName, value);
}
if (value.ContainsKey(Key))
{
value.Remove(Key);
}
value.Add(Key, Value);
if (!m_Modified.TryGetValue(SectionName, out value))
{
value = new Dictionary<string, string>();
m_Modified.Add(SectionName, value);
}
if (value.ContainsKey(Key))
{
value.Remove(Key);
}
value.Add(Key, Value);
if (m_AutoFlush)
{
PerformFlush();
}
}
}
private string EncodeByteArray(byte[] Value)
{
if (Value == null)
{
return null;
}
StringBuilder stringBuilder = new StringBuilder();
foreach (byte b in Value)
{
string text = Convert.ToString(b, 16);
int length = text.Length;
if (length > 2)
{
stringBuilder.Append(text.Substring(length - 2, 2));
continue;
}
if (length < 2)
{
stringBuilder.Append("0");
}
stringBuilder.Append(text);
}
return stringBuilder.ToString();
}
private byte[] DecodeByteArray(string Value)
{
if (Value == null)
{
return null;
}
int length = Value.Length;
if (length < 2)
{
return new byte[0];
}
length /= 2;
byte[] array = new byte[length];
for (int i = 0; i < length; i++)
{
array[i] = Convert.ToByte(Value.Substring(i * 2, 2), 16);
}
return array;
}
public bool ReadValue(string SectionName, string Key, bool DefaultValue)
{
string s = ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
if (int.TryParse(s, out var result))
{
return result != 0;
}
return DefaultValue;
}
public int ReadValue(string SectionName, string Key, int DefaultValue)
{
string s = ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
if (int.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
{
return result;
}
return DefaultValue;
}
public long ReadValue(string SectionName, string Key, long DefaultValue)
{
string s = ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
if (long.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
{
return result;
}
return DefaultValue;
}
public double ReadValue(string SectionName, string Key, double DefaultValue)
{
string s = ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
if (double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
{
return result;
}
return DefaultValue;
}
public float ReadValue(string SectionName, string Key, float DefaultValue)
{
string s = ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
if (float.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
{
return result;
}
return DefaultValue;
}
public byte[] ReadValue(string SectionName, string Key, byte[] DefaultValue)
{
string value = ReadValue(SectionName, Key, EncodeByteArray(DefaultValue));
try
{
return DecodeByteArray(value);
}
catch (FormatException)
{
return DefaultValue;
}
}
public DateTime ReadValue(string SectionName, string Key, DateTime DefaultValue)
{
string s = ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
if (DateTime.TryParse(s, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.NoCurrentDateDefault | DateTimeStyles.AssumeLocal, out var result))
{
return result;
}
return DefaultValue;
}
public Color ReadValue(string SectionName, string Key, Color DefaultValue)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
string text = ReadValue(SectionName, Key, "#" + ColorUtility.ToHtmlStringRGB(DefaultValue));
Color result = default(Color);
if (ColorUtility.TryParseHtmlString(text, ref result))
{
return result;
}
return DefaultValue;
}
public void WriteValue(string SectionName, string Key, bool Value)
{
WriteValue(SectionName, Key, Value ? "1" : "0");
}
public void WriteValue(string SectionName, string Key, int Value)
{
WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
public void WriteValue(string SectionName, string Key, long Value)
{
WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
public void WriteValue(string SectionName, string Key, double Value)
{
WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
public void WriteValue(string SectionName, string Key, float Value)
{
WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
public void WriteValue(string SectionName, string Key, byte[] Value)
{
WriteValue(SectionName, Key, EncodeByteArray(Value));
}
public void WriteValue(string SectionName, string Key, DateTime Value)
{
WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
public void WriteValue(string SectionName, string Key, Color Value)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
WriteValue(SectionName, Key, "#" + ColorUtility.ToHtmlStringRGB(Value));
}
}
}