public UIDialogData(string title = null, string message = null, DialogActions buttons = null, string focusButton = null, Vector3?position = null, Sprite icon = null, bool modal = false, bool hideByModalClick = true, Sprite modalSprite = null, Color?modalColor = null, UnityAction closeButtonAction = null, int forbidOperTime = 0, UnityAction modalClickAction = null, EDialogType eDialogType = EDialogType.Default, bool mutex = false) { strTitle = title; strMessage = message; strFocusButton = focusButton; actButtons = buttons; vec3Position = position; sprIcon = icon; sprModal = modalSprite; colorModal = modalColor; bModal = modal; bHideByModalClick = hideByModalClick; actCloseButton = closeButtonAction; nForbidOperTime = forbidOperTime; actModalClick = modalClickAction; DialogType = eDialogType; bMutex = mutex; }
ConsoleColor GetConsoleColor(EDialogType dialogType) { ConsoleColor?result = null; switch (dialogType) { case EDialogType.Debug: result = DebugForegronudColor; break; case EDialogType.Information: result = InformationForegroundColor; break; case EDialogType.Warning: result = WarningForegroundColor; break; case EDialogType.Error: result = ErrorForegroundColor; break; case EDialogType.Question: result = QuestionForegroundColor; break; } return(result ?? Console.ForegroundColor); }
public GUIDialogParameters(String p_title, String p_text, EDialogType p_type, Callback p_callback, Boolean p_isPopup) { m_title = p_title; m_text = p_text; m_type = p_type; m_callback = p_callback; m_isPopup = p_isPopup; }
public IEnumerator DialogEnter(EDialogType tp = EDialogType.DialogBox) { Image_NextStepTip.gameObject.SetActive(false); CurrentDialogType = tp; Text_Dialog.color = DialogTextColorMap[tp]; if (tp == EDialogType.Black) { ImageSwitch_DialogBg.SetImage(2); } IsDialogShow = true; Anim_Dialog.SetBool("IsShow", true); yield break; }
public async void ShowDialog(string content, EDialogType dialogType) { var dialog = new MessageDialog(content); switch (dialogType) { case EDialogType.Success: dialog.Title = "Success"; break; case EDialogType.Error: dialog.Title = "Error"; break; default: throw new ArgumentOutOfRangeException(nameof(dialogType), dialogType, null); } await dialog.ShowAsync(); }
/// <summary> /// Shows dialog /// </summary> /// <param name="title">Title</param> /// <param name="message">Message</param> /// <param name="dialogType">Dialog type</param> /// <param name="dialogButtons">Dialog buttons</param> /// <param name="onDialogResponse">On dialog response</param> public static void Show(string title, string message, EDialogType dialogType, EDialogButtons dialogButtons, DialogRespondedDelegate onDialogResponse) { if (title == null) { throw new ArgumentNullException(nameof(title)); } if (message == null) { throw new ArgumentNullException(nameof(message)); } DialogManagerScript dialog_manager = DialogManagerScript.Instance; if (dialog_manager != null) { dialog_manager.Show(new Dialog(title, message, dialogType, dialogButtons, null, onDialogResponse)); } }
/// <summary> /// Constructor /// </summary> /// <param name="title">Title</param> /// <param name="message">Message</param> /// <param name="dialogType">Dialog tyoe</param> /// <param name="dialogButtons">Dialog buttons</param> /// <param name="buttons">Buttons</param> /// <param name="onDialogResponded">On dialog responded</param> internal Dialog(string title, string message, EDialogType dialogType, EDialogButtons dialogButtons, IReadOnlyList <string> buttons, DialogRespondedDelegate onDialogResponded) { Title = title ?? throw new ArgumentNullException(nameof(title)); Message = message ?? throw new ArgumentNullException(nameof(message)); DialogType = dialogType; DialogButtons = dialogButtons; Buttons = DialogButtons switch { EDialogButtons.OKCancel => new string[] { Dialogs.OKString, Dialogs.CancelString }, EDialogButtons.YesNo => new string[] { Dialogs.YesString, Dialogs.NoString }, EDialogButtons.YesNoCancel => new string[] { Dialogs.YesString, Dialogs.NoString, Dialogs.CancelString }, EDialogButtons.OK => new string[] { Dialogs.OKString }, EDialogButtons.Custom => buttons ?? throw new ArgumentNullException(nameof(buttons)), _ => throw new NotImplementedException() }; OnDialogResponded = onDialogResponded; } }
/// <summary> /// Show dialog and wait for it closes. /// </summary> /// <param name="initializer">Dialog initializer</param> /// <param name="dialogType">Alert type</param> /// <param name="selections">Selections</param> /// <returns></returns> public static string ShowDialog( this IDialogManager dialogManager, Action <IDialogConfig <DialogSelection> > initializer, EDialogType dialogType, params string[] selections) { return(dialogManager.ShowDialog( initializer, dialogType, selections?.Any() == true ? selections?.Select((x, i) => new DialogSelection { Id = i, Content = x, IsDefault = (i == 0) }).ToArray() : new DialogSelection[] { OkSelection(0, true) } ) ?.Content as string); }
/// <summary> /// Show dialog. /// </summary> /// <param name="initializer">Dialog initializer</param> /// <param name="dialogType">Alert type</param> /// <param name="selections">Selections</param> /// <returns></returns> public static async Task <string> ShowDialogAsync( this IDialogManager dialogManager, Action <IDialogConfig <DialogSelection> > initializer, EDialogType dialogType, Action <string> onResult, params string[] selections) { var ret = await dialogManager.ShowDialogAsync( initializer, dialogType, selection => onResult(selection.Content as string), selections?.Any() == true ?selections?.Select((x, i) => new DialogSelection { Id = i, Content = x, IsDefault = (i == 0) }).ToArray() : new DialogSelection[] { OkSelection(0, true) } ); return(ret?.Content as string); }
/// <summary> /// Shows dialog /// </summary> /// <param name="title">Title</param> /// <param name="message">Message</param> /// <param name="dialogType">Dialog type</param> /// <param name="dialogButtons">Dialog buttons</param> public static void Show(string title, string message, EDialogType dialogType, EDialogButtons dialogButtons) => Show(title, message, dialogType, dialogButtons, null);
/// <summary> /// Shows dialog /// </summary> /// <param name="title">Title</param> /// <param name="message">Message</param> /// <param name="dialogType">Dialog type</param> /// <param name="buttons">Buttons</param> public static void Show(string title, string message, EDialogType dialogType, IReadOnlyList <string> buttons) => Show(title, message, dialogType, buttons, null);
public UIDialogHide(EDialogType dialogType) { this.dialogType = dialogType; }
public DialogSelection ShowDialog(Action <IDialogConfig <DialogSelection> > initializer, EDialogType dialogType, params DialogSelection[] selections) { if (initializer == null) { throw new ArgumentNullException(nameof(initializer)); } if (selections.Select(x => x.Id).Distinct().Count() != selections.Length) { throw new ArgumentException("Duplicated ID.", nameof(selections)); } var config = new DialogConfig { Selections = selections }; initializer.Invoke(config); DialogSelection selectedItem = null; using (new ForegroundColorScope(GetConsoleColor(dialogType))) { var message = string.IsNullOrEmpty(config.Caption) ? config.Content?.ToString() ?? "" : string.Format("[{0}] {1}", config.Caption, config.Content ?? ""); Console.WriteLine(message); if (config.Selections?.Any() == true) { var indexAndSelections = config.Selections.Select((x, i) => new { ActualIndex = x.Id, Selection = x }); var selectionsMessage = string.Join(" ", indexAndSelections.Select(x => $"{x.ActualIndex}: {x.Selection.Content.ToString()}")); var defaultSelection = indexAndSelections.FirstOrDefault(x => x.Selection.IsDefault); if (defaultSelection != null) { selectionsMessage += string.Format(" ({0}: {1}:{2}", LocalizedStringProvider.GetString(DialogLocalizerStringResourceNames.Default), defaultSelection.ActualIndex, defaultSelection.Selection); } do { Console.WriteLine(selectionsMessage); Console.Write(">"); var ret = Console.ReadLine(); if (defaultSelection != null && string.IsNullOrWhiteSpace(ret)) { selectedItem = defaultSelection.Selection; } else { int selectedIndex; if (int.TryParse(ret, out selectedIndex)) { selectedItem = indexAndSelections.FirstOrDefault(x => x.ActualIndex == selectedIndex)?.Selection; } } }while (selectedItem == null); } } return(selectedItem); }
public Task <string> ShowMessageAsync(string content, string caption, Exception exception, EDialogType dialogType, Action <string> onResult, params string[] selections) { return(Task.Run(() => { var ret = ShowMessage( content, caption, exception, dialogType, selections); onResult.Invoke(ret); return ret; })); }
public string ShowMessage(string content, string caption, Exception exception, EDialogType dialogType, params string[] selections) { var dialogSelections = selections .Select((x, i) => new DialogSelection { Content = x, Id = i, IsDefault = false, }) .ToArray(); var ret = ShowDialog( config => { config.Caption = caption; var sb = new StringBuilder(); sb.Append(content); if (exception != null) { sb.AppendLine(); sb.AppendLine(LocalizedStringProvider.GetString(LocalizedStringNameExceptionInfo) ?? LocalizedStringDefaultExceptionInfo); sb.Append(exception.ToString()); } config.Content = sb.ToString() ; }, dialogType, dialogSelections); return(ret?.Content as string); }
public Task <DialogSelection> ShowDialogAsync(Action <IDialogConfig <DialogSelection> > initializer, EDialogType dialogType, Action <DialogSelection> onResult, params DialogSelection[] selections) { return(Task.Run(() => { var ret = ShowDialog( initializer, dialogType, selections); onResult?.Invoke(ret); return ret; })); }