public MemoryObjectInfoUI(MethodInfo method, Vector2 pos, MemoryTableUIManager manager, ObjectMemoryInfo obj) { background = new UIPanel(this, pos, 1f - pos.x - 0.05f, (0.90f / objectsPerScreen)); AddElement(background); label = new UILabel(this, ObjectMemoryInfo.GetMethodText(method), alignment: TextAnchor.MiddleLeft); label.SetSize(1f, 1f); label.SetPosition(0.0f, 0f); label.SetParent(background); AddElement(label); expand = new UIButton(this, buttonColor: "0 0 1 1", fontSize: 10, textColor: "1 1 1 1"); expand.AddCallback((arg) => { if (method.ReturnType != null) { if (method.ReturnType.IsValueType || method.ReturnType == typeof(string)) { _plugin.PrintToChat(manager._player, method.Invoke(obj._target, null)?.ToString()); } else //When clicking on a function that returns a object to explore { var objectReturn = method.Invoke(obj._target, null); if (objectReturn != null) //Explore blue function { var rootObject = new ObjectMemoryInfo(objectReturn, int.MaxValue, objectReturn.GetType().Name, obj); manager.ShowObject(rootObject); } } } else { _plugin.PrintToChat($"Executed {ObjectMemoryInfo.GetMethodText(method)}"); } }); expand.SetSize(0.005f, 0.45f); expand.SetPosition(0.0f, 0.5f - expand.size.y / 2); expand.SetParent(background); AddElement(expand); label.SetPosition(label.position.x + expand.size.x + 0.005f, label.position.y); Show(manager._player); }
public MemoryObjectInfoUI(ObjectMemoryInfo obj, Vector2 pos, MemoryTableUIManager manager, bool parent = true) { memoryObject = obj; background = new UIPanel(this, pos, 1f - pos.x - 0.05f, (0.90f / objectsPerScreen)); AddElement(background); label = new UILabel(this, obj.GetVisualText(), alignment: TextAnchor.MiddleLeft); label.SetSize(1f, 1f); label.SetPosition(0.0f, 0f); label.SetParent(background); AddElement(label); if (!IsValueType(memoryObject._target)) { expand = new UIButton(this, buttonColor: parent ? "1 0 0 1" : "0 1 0 1", fontSize: 10, textColor: "1 1 1 1"); expand.AddCallback((arg) => { if (parent) { manager.Shrink(this); } else { manager.Expand(this); } }); expand.SetSize(0.005f, 0.45f); expand.SetPosition(0.0f, 0.5f - expand.size.y / 2); expand.SetParent(background); //expand.textComponent.Text = parent ? "-" : "+"; AddElement(expand); label.SetPosition(label.position.x + expand.size.x + 0.005f, label.position.y); } Show(manager._player); }
void Init() { _plugin = this; UI = new MemoryTableUIManager(); }
void Loaded() { _plugin = this; UI = new MemoryTableUIManager(); }