public IntegerEditor(string text, int startingNumber, int minimum, int maximum, Vector2 location, ClickCallback onClickCallback, int increment = 1) { if (maximum <= minimum) { throw new ArgumentException($"{nameof(minimum)} value cannot exceed {nameof(maximum)} value."); } _onClick = onClickCallback; Value = startingNumber.Clamp(minimum, maximum); Minimum = minimum; Maximum = maximum; Text = text; Increment = increment; var buttonYOffset = Game1.smallFont.MeasureString(text).Y.Ceiling() + _linePadding; _minusButton = new TextureButton(new Rectangle(location.X.Floor(), location.Y.Floor() + buttonYOffset, PixelsWide * Game1.pixelZoom, PixelsHigh * Game1.pixelZoom), Game1.mouseCursors, OptionsPlusMinus.minusButtonSource, MinusButtonClicked); var plusButtonOffset = MeasureNumberWidth(Maximum) + _minusButton.Bounds.Width; _plusButton = new TextureButton(new Rectangle(location.X.Floor() + plusButtonOffset, location.Y.Floor() + buttonYOffset, PixelsWide * Game1.pixelZoom, PixelsHigh * Game1.pixelZoom), Game1.mouseCursors, OptionsPlusMinus.plusButtonSource, PlusButtonClicked); var maxWidth = new[] { _plusButton.Bounds.X + _plusButton.Bounds.Width - location.X.Floor(), Game1.smallFont.MeasureString(text).X.Ceiling() }.Max(); var maxHeight = buttonYOffset + new[] { _minusButton.Bounds.Height, _plusButton.Bounds.Height, NumberSprite.getHeight() }.Max(); Bounds = new Rectangle(location.X.Floor(), location.Y.Floor(), maxWidth, maxHeight); }
public static int SelectionList(int selected, GUIContent[] list, GUIStyle elementStyle, ClickCallback callback) { for (int i = 0; i < list.Length; ++i) { Rect elementRect = GUILayoutUtility.GetRect(list[i], elementStyle); bool hover = elementRect.Contains(Event.current.mousePosition); if (hover && Event.current.type == EventType.MouseDown) { selected = i; callback(i); Event.current.Use(); } else if (Event.current.type == EventType.repaint) { GUIContent text = list[i]; if (i == selected) { text = new GUIContent(">> " + text.text); } elementStyle.Draw(elementRect, text, hover, false, i == selected, false); } } return(selected); }
public static int SelectionList(int selected, string[] list, ClickCallback callback) { return(SelectionList(selected, list, elementStyle, callback)); }
public static int SelectionList(int selected, string[] list, ClickCallback callback) { return SelectionList(selected, list, elementStyle, callback); }
public static int SelectionList(int selected, string[] list, GUIStyle elementStyle, ClickCallback callback) { for (int i = 0; i < list.Length; ++i) { Rect elementRect = GUILayoutUtility.GetRect(new GUIContent(list[i]), elementStyle); bool hover = elementRect.Contains(Event.current.mousePosition); if (hover && Event.current.type == EventType.MouseDown) { selected = i; callback(i); Event.current.Use(); } else if (Event.current.type == EventType.repaint) { string text = list[i]; if (i == selected) { text = ">> " + text; } elementStyle.Draw(elementRect, text, hover, false, i == selected, false); } } return selected; }
//显示提示信息 入参 tips ok按钮回调事件 ok按钮文字 cancel回调事件 cancel按钮文字 //按钮点击后,窗口自动关闭 public void ShowCommonAlert(string tip, string cmd, ClickCallback okFun, string textOk, ClickCallback cancelFun, string textCancel) { alertType = AlertTypeEnum.Common; ShowWindow(tip, cmd, okFun, textOk, cancelFun, textCancel); }
public TextureButton(Rectangle bounds, Texture2D buttonTexture, Rectangle sourceRectangle, ClickCallback onClickCallback, string hoverText = "") { Bounds = bounds; ButtonTexture = buttonTexture; HoverText = hoverText; SourceRectangle = sourceRectangle; ClickableTextureComponent = new ClickableTextureComponent(string.Empty, Bounds, string.Empty, HoverText, ButtonTexture, sourceRectangle, 1f); _onClick = onClickCallback; }
//显示Ok提示框,只有Ok按钮,没有取消、关闭按钮 //按钮点击后,窗口自动关闭 public void ShowOkAlert(string tip = "", string cmd = ConfirmCommands.OK, ClickCallback okFun = null, string txtOk = "") { ConfirmView view = GetNextView(cmd); view.ShowOkAlert(tip, cmd, okFun, txtOk); }
//显示二者选一窗口,没有关闭按钮 public void ShowSelectOneAlert(string tip = "", string cmd = ConfirmCommands.SELECT_ONE, ClickCallback okFun = null, string txtOk = "", ClickCallback cancelFun = null, string txtCancel = "") { ConfirmView view = GetNextView(cmd); view.ShowSelectOneAlert(tip, cmd, okFun, txtOk, cancelFun, txtCancel); }
//显示提示信息 入参 tips ok按钮回调事件 ok按钮文字 cancel回调事件 cancel按钮文字 //按钮点击后,窗口自动关闭 public void ShowCommonAlert(string tip = "", string cmd = ConfirmCommands.OK_CANCEL, ClickCallback okFun = null, string txtOk = "", ClickCallback cancelFun = null, string txtCancel = "") { ConfirmView view = GetNextView(cmd); view.ShowCommonAlert(tip, cmd, okFun, txtOk, cancelFun, txtCancel); }
// 显示普通信息,按钮名字为确定,取消 // 按钮点击后,窗口自动关闭 public void ShowOkCancelAlert(string tip = "", string cmd = ConfirmCommands.OK_CANCEL, ClickCallback okFun = null) { ConfirmView view = GetNextView(cmd); view.ShowOkCancelAlert(tip, cmd, okFun); }
public void SetCallback(ChoiceController controller, ClickCallback callback) { clickCallback = callback; }
protected async Task OnClick() => await ClickCallback.InvokeAsync(new ButtonControllerEvent(ID, ButtonEvent.Click));
// 显示普通信息,按钮名字为确定,取消 // 按钮点击后,窗口自动关闭 public void ShowOkCancelAlert(string tip, string cmd, ClickCallback okFun) { alertType = AlertTypeEnum.Common; ShowWindow(tip, cmd, okFun, LanguageManager.GetWord("ConfirmView.Ok"), null, LanguageManager.GetWord("ConfirmView.Cancel")); }
public static int SelectionList(int selected, string[] list, GUIStyle elementStyle, ClickCallback callback) { elementStyle.active.textColor = new Color(0.8f, 1f, 1f); for (int i = 0; i < list.Length; ++i) { Rect elementRect = GUILayoutUtility.GetRect(new GUIContent(list[i]), elementStyle); bool hover = elementRect.Contains(Event.current.mousePosition); if (hover && Event.current.type == EventType.MouseDown) { selected = i; callback(i); Event.current.Use(); } else if (Event.current.type == EventType.repaint) { elementStyle.Draw(elementRect, list[i], hover, false, i == selected, false); } } return(selected); }
public static int SelectionList(int selected, string[] list, ClickCallback callback) { return SelectionList(selected, list, "Label", callback); }
public Notification(string title, NotificationType type, HashedString group, Func <List <Notification>, object, string> tooltip = null, object tooltip_data = null, bool expires = true, float delay = 0f, ClickCallback custom_click_callback = null, object custom_click_data = null, Transform click_focus = null) { titleText = title; Group = group; Type = type; ToolTip = tooltip; tooltipData = tooltip_data; this.expires = expires; Delay = delay; customClickCallback = custom_click_callback; customClickData = custom_click_data; clickFocus = click_focus; }
public static int SelectionList(int selected, GUIContent[] list, GUIStyle elementStyle, ClickCallback callback = null) { for (var i = 0; i < list.Length; ++i) { var elementRect = GUILayoutUtility.GetRect(list[i], elementStyle); var hover = elementRect.Contains(Event.current.mousePosition); if (hover && Event.current.type == EventType.MouseDown) { selected = i; if (callback != null) { callback(i); } Event.current.Use(); } else if (Event.current.type == EventType.repaint) { elementStyle.Draw(elementRect, list[i], hover, false, i == selected, false); } } return(selected); }