2020-08-22 00:16:05 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using MelonLoader;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Explorer
|
|
|
|
|
{
|
2020-08-29 21:15:54 +10:00
|
|
|
|
public class CacheEnum : CacheObjectBase
|
2020-08-22 00:16:05 +10:00
|
|
|
|
{
|
2020-08-24 01:42:19 +10:00
|
|
|
|
public Type EnumType;
|
|
|
|
|
public string[] EnumNames;
|
2020-08-22 00:16:05 +10:00
|
|
|
|
|
2020-08-24 01:42:19 +10:00
|
|
|
|
public override void Init()
|
2020-08-22 00:16:05 +10:00
|
|
|
|
{
|
2020-08-24 01:42:19 +10:00
|
|
|
|
EnumType = Value.GetType();
|
|
|
|
|
EnumNames = Enum.GetNames(EnumType);
|
2020-08-22 00:16:05 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void DrawValue(Rect window, float width)
|
|
|
|
|
{
|
2020-08-24 01:42:19 +10:00
|
|
|
|
if (CanWrite)
|
2020-08-22 00:16:05 +10:00
|
|
|
|
{
|
|
|
|
|
if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(25) }))
|
|
|
|
|
{
|
|
|
|
|
SetEnum(ref Value, -1);
|
|
|
|
|
SetValue();
|
|
|
|
|
}
|
|
|
|
|
if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(25) }))
|
|
|
|
|
{
|
|
|
|
|
SetEnum(ref Value, 1);
|
|
|
|
|
SetValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-24 01:42:19 +10:00
|
|
|
|
GUILayout.Label(Value.ToString(), null);// + "<color=yellow><i> (" + ValueType + ")</i></color>", null);
|
2020-08-22 00:16:05 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetEnum(ref object value, int change)
|
|
|
|
|
{
|
2020-08-24 01:42:19 +10:00
|
|
|
|
var names = EnumNames.ToList();
|
2020-08-22 00:16:05 +10:00
|
|
|
|
|
|
|
|
|
int newindex = names.IndexOf(value.ToString()) + change;
|
|
|
|
|
|
|
|
|
|
if ((change < 0 && newindex >= 0) || (change > 0 && newindex < names.Count))
|
|
|
|
|
{
|
2020-08-24 01:42:19 +10:00
|
|
|
|
value = Enum.Parse(EnumType, names[newindex]);
|
2020-08-22 00:16:05 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|