public virtual void AddCallbackOk(UnityEngine.Events.UnityAction action) { if (!inited) { Init(); } button_ok.AddCallback(action); }
public void AddCallbackNo(UnityEngine.Events.UnityAction action) { if (!inited) { Init(); } button_no.AddCallback(action); }
public MemoryTableUIManager() { nextPage = new UIButton(this, "Next"); nextPage.SetPosition(0.51f, 0f); nextPage.SetSize(0.09f, 0.03f); nextPage.AddCallback((player) => { NextPage(); }); //AddElement(nextPage); prevPage = new UIButton(this, "Prev"); prevPage.SetPosition(0.4f, 0f); prevPage.SetSize(0.09f, 0.03f); prevPage.AddCallback((player) => { PrevPage(); }); //AddElement(prevPage); }
private void Init() { var panel = new UIPanel(this, new Vector2(_position.x, _position.y), _width, _height, _panelColor); _paddingAmount = (_stackedButtons ? _height : _width) * _paddingPercentage / _buttonConfiguration.Count(); var firstButtonPosition = new Vector2(_position.x + _paddingAmount, _position.y + _paddingAmount); var titleHeight = TITLE_PERCENTAGE * _height; if (!string.IsNullOrEmpty(_title)) { _hasTitle = true; var titlePanel = new UIPanel(this, new Vector2(_position.x, _position.y + _height - titleHeight), _width, titleHeight); var titleLabel = new UILabel(this, _title, fontSize: _titleSize, parent: titlePanel.Element.Name); } var buttonHeight = (_height - (_paddingAmount * 2) - (_hasTitle ? titleHeight : 0) - (_paddingAmount * (_buttonConfiguration.Count() - 1))) / (_stackedButtons ? _buttonConfiguration.Count() : 1); var buttonWidth = _stackedButtons ? (_width - (_paddingAmount * 2)) : ((_width - (_paddingAmount * 2) - (_paddingAmount * (_buttonConfiguration.Count() - 1))) / _buttonConfiguration.Count()); _plugin.Puts($"ButtonHeight {buttonHeight} ButtonWidth {buttonWidth}"); for (var buttonId = 0; buttonId < _buttonConfiguration.Count(); buttonId++) { var buttonConfig = _buttonConfiguration.ElementAt(buttonId); var button = new UIButton(this, buttonText: buttonConfig.ButtonName, buttonColor: buttonConfig.ButtonColor, fontSize: _buttonFontSize); if (!_stackedButtons) { button.SetPosition( firstButtonPosition.x + ((buttonWidth + _paddingAmount) * buttonId + _paddingAmount), firstButtonPosition.y + (_paddingAmount) * 2); } else { button.SetPosition( firstButtonPosition.x, firstButtonPosition.y + ((buttonHeight + _paddingAmount) * buttonId + _paddingAmount)); } button.SetSize( buttonWidth - (_stackedButtons ? 0 : _paddingAmount * 2), buttonHeight - (_stackedButtons ? _paddingAmount * 2 : 0)); button.AddCallback(buttonConfig.callback); button.AddChatCommand(buttonConfig.ButtonCommand); } }
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); }