static bool EqualComponent(CuiButtonComponent e1, CuiButtonComponent e2) { if (e1.Command != e2.Command) { return(false); } if (e1.Close != e2.Close) { return(false); } if (e1.Color != e2.Color) { return(false); } if (e1.Sprite != e2.Sprite) { return(false); } if (e1.Material != e2.Material) { return(false); } if (e1.ImageType != e2.ImageType) { return(false); } return(!(Math.Abs(e1.FadeIn - e2.FadeIn) > 0.01)); }
public UIButton(Vector2 min = default(Vector2), Vector2 max = default(Vector2), string buttonText = "", string buttonColor = "0 0 0 0.85", string textColor = "1 1 1 1", int fontSize = 15, UIBaseElement parent = null) : base(min, max, parent) { buttonComponent = new CuiButtonComponent(); _fontSize = fontSize; _textColor = textColor; _buttonText = buttonText; buttonComponent.Command = CuiHelper.GetGuid(); buttonComponent.Color = buttonColor; Element.Components.Insert(0, buttonComponent); _plugin.cmd.AddConsoleCommand(buttonComponent.Command, _plugin, "OnButtonClick"); _plugin.UIButtonCallBacks[buttonComponent.Command] = this; label = new UILabel(new Vector2(0, 0), new Vector2(1, 1), fontSize: _fontSize, parent: this); textComponent = label.text; label.text.Align = TextAnchor.MiddleCenter; label.text.Color = _textColor; label.Text = _buttonText; label.text.FontSize = _fontSize; }
private static void AddNonActiveButton( int tabIndex, CuiElementContainer container, HelpTab helpTab, string mainPanelName, string activeTabButtonName) { Color nonActiveButtonColor; ColorExtensions.TryParseHexString(_settings.InactiveButtonColor, out nonActiveButtonColor); CuiButton helpTabButton = CreateTabButton(tabIndex, helpTab, nonActiveButtonColor); string helpTabButtonName = container.Add(helpTabButton, mainPanelName); CuiElement helpTabButtonCuiElement = container.First(i => i.Name.Equals(helpTabButtonName, StringComparison.OrdinalIgnoreCase)); CuiButtonComponent generatedHelpTabButton = helpTabButtonCuiElement.Components.OfType <CuiButtonComponent>().First(); string command = string.Format("changeTab {0} {1} {2} {3}", tabIndex, activeTabButtonName, helpTabButtonName, mainPanelName); generatedHelpTabButton.Command = command; }