private static void Add_Item(ReadStream rs)
    {
        int
            id =

            rs.ReadInt();



        string
            name =

            rs.ReadString();



        string
            Text =

            rs.ReadString();


        DialogConfig new_obj_DialogConfig = new DialogConfig(id, name, Text);

        if (dic.ContainsKey(id))
        {
            LogWarning("duplicate key: " + id);
            return;
        }

        dic.Add(id, new_obj_DialogConfig);
        array.Add(new_obj_DialogConfig);
    }
    public override void StartService(ServiceManager serviceManager)
    {
        _dialogLookup = new Dictionary <Type, GameObject>();
        _config       = Game.Instance.GetStaticDataPovider <PandeaGameDataProvider>().PandeaGameConfigurationData
                        .DialogConfigurationData;

        foreach (GameObject dialogPrefab in _config)
        {
            IDialog       dialogComponent        = dialogPrefab.GetComponent <IDialog>();
            MessageDialog messageDialogComponent = dialogPrefab.GetComponent <MessageDialog>();

            if (dialogComponent == null)
            {
                Debug.LogError("Missing Dialog component found during service setup");
                continue;
            }

            //if we find a dialog of type MessageDialog, insert it into the dictionary as our generic MessageDialog.
            if (messageDialogComponent)
            {
                _dialogLookup.Add(typeof(MessageDialog), dialogPrefab);
            }

            _dialogLookup.Add(dialogComponent.GetType(), dialogPrefab);
        }

        if (_touchBlockerObject != null)
        {
            _touchBlocker = _touchBlockerObject.GetComponent <ITouchBlocker>();
        }

        base.StartService(serviceManager);
    }
        public IDialog CreateDialog(Xamarin.Forms.View contentView, IDialogMsg dialogMsg, DialogConfig config)
        {
            if (contentView == null)
            {
                throw new ArgumentException($"dialog contentView is null");
            }
            if (config == null)
            {
                config = new DialogConfig();
            }
            IDialogResult dialogResult            = null;
            TaskCompletionSource <string> mission = null;

            if (contentView is IDialogElement)
            {
                DialogResultManager manager = new DialogResultManager();
                manager.Build();
                dialogResult = manager.GetDialogResult();
                mission      = manager.GetResultMission();
            }
            var dialogFragment = new BaseDialogFragment2(_activity, contentView, config, dialogMsg, dialogResult);
            var dialogDroid    = new DialogInstance(dialogFragment, _fragmentManager, contentView, mission);

            return(dialogDroid);
        }
    /// <summary>
    /// 保存文件选择窗口
    /// </summary>
    /// <param name="title">指定窗口名称</param>
    /// <param name="extensions">预设文件存储位置及文件名</param>
    /// <returns>文件路径</returns>
    public static string SaveDialog(string title, string path)
    {
        var          extension = Path.GetExtension(path);
        DialogConfig ofn       = new DialogConfig();

        ofn.structSize  = Marshal.SizeOf(ofn);
        ofn.filter      = Filter("All Files", "*.*", extension, "*" + extension);
        ofn.filterIndex = 2;
        var chars = new char[256];
        var it    = Path.GetFileName(path).GetEnumerator();

        for (int i = 0; i < chars.Length && it.MoveNext(); ++i)
        {
            chars[i] = it.Current;
        }
        ofn.file         = new string(chars);
        ofn.maxFile      = ofn.file.Length;
        ofn.fileTitle    = new string(new char[64]);
        ofn.maxFileTitle = ofn.fileTitle.Length;
        ofn.initialDir   = Path.GetDirectoryName(path);
        ofn.title        = title;
        ofn.flags        = 0x00000002 | 0x00000004; // OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
        ofn.dlgOwner     = GetForegroundWindow();   //这一步将文件选择窗口置顶。
        if (!GetSaveFileName(ofn))
        {
            return(null);
        }
        return(ofn.file);
    }
    /// <summary>
    /// 打开文件选择窗口
    /// </summary>
    /// <param name="title">指定窗口名称</param>
    /// <param name="extensions">指定文件选择类型</param>
    /// <returns>选中的文件路径</returns>
    public static string FileDialog(string title, params string[] extensions)
    {
        DialogConfig ofn = new DialogConfig();

        ofn.structSize = Marshal.SizeOf(ofn);

        var filters = new List <string>();

        filters.Add("All Files"); filters.Add("*.*");
        foreach (var ext in extensions)
        {
            filters.Add(ext); filters.Add("*" + ext);
        }
        ofn.filter       = Filter(filters.ToArray());
        ofn.filterIndex  = 2;
        ofn.file         = new string(new char[256]);
        ofn.maxFile      = ofn.file.Length;
        ofn.fileTitle    = new string(new char[64]);
        ofn.maxFileTitle = ofn.fileTitle.Length;
        ofn.initialDir   = UnityEngine.Application.dataPath;
        ofn.title        = title;
        ofn.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
        ofn.dlgOwner     = GetForegroundWindow();                                          //这一步将文件选择窗口置顶。
        if (!GetOpenFileName(ofn))
        {
            return(null);
        }
        return(ofn.file);
    }
 public void HideDialog(DialogConfig dialogConfig)
 {
     BaseDialog dialog = dialogMap[dialogConfig];
     if (!visibleDialog.Contains(dialog))
         return;
     dialog.DoHide();
 }
        /// <summary>
        /// PopupView
        /// </summary>
        /// <param name="baseView"></param>
        /// <param name="popupView"></param>
        /// <param name="dialogMsg"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public IDialog PopupView(Xamarin.Forms.View baseView, Xamarin.Forms.View popupView, IDialogMsg dialogMsg, DialogConfig config)
        {
            if (baseView == null || popupView == null)
            {
                throw new ArgumentException($"dialog contentView is null");
            }

            if (config == null)
            {
                config = new DialogConfig()
                {
                    DialogPosition = DialogPosition.Buttom
                };
            }
            IDialogResult dialogResult            = null;
            TaskCompletionSource <string> mission = null;

            if (popupView is IDialogElement)
            {
                DialogResultManager manager = new DialogResultManager();
                manager.Build();
                dialogResult = manager.GetDialogResult();
                mission      = manager.GetResultMission();
            }
            var rect           = GetBaseViewRect(baseView);
            var dialogFragment = new PopupDialogFragment(_activity, popupView, config, dialogMsg, rect, dialogResult);
            var dialogDroid    = new DialogInstance(dialogFragment, _fragmentManager, popupView, mission);

            return(dialogDroid);
        }
Exemple #8
0
        public bool ShowDialog(string signalNames, DialogConfig dialogConfig, DialogActionHandler actionHandler, int customValue)
        {
            try
            {
                var playerId = 0;

                var uniqueNames = Root.SignalEventStore.GetEvents().Keys.GetUniqueNames(signalNames).ToDictionary(N => N);
                var signals     = Root.SignalEventStore.GetEvents()
                                  .Where(S => uniqueNames.ContainsKey(S.Key))
                                  .Select(S => S.Value.LastOrDefault())
                                  .Where(S => S != null)
                                  .ToArray();

                if (signals.All(S => !S.State))
                {
                    Root.GetPersistendData().TryRemove($"DialogTo{Root.ScriptId}", out var _);
                    return(false);
                }
                else
                {
                    playerId = signals.FirstOrDefault(S => S.State)?.TriggeredByEntityId ?? 0;
                }

                var playerData = Root.IsElevatedScript
                    ? (Root.GetCurrentPlayfield().Players.TryGetValue(playerId, out var plainPlayer) ? new DataWrapper.PlayerData(Root.GetCurrentPlayfield(), plainPlayer) : null)
                    : Root.E.S.Players.FirstOrDefault(P => P.Id == playerId);

                if (playerData == null)
                {
                    return(false);
                }

                var running = (bool)Root.GetPersistendData().GetOrAdd($"DialogTo{Root.ScriptId}", false);
                if (running)
                {
                    return(false);
                }

                var success = EmpyrionScripting.ModApi.Application.ShowDialogBox(playerId, dialogConfig, actionHandler, customValue);

                if (success)
                {
                    Root.GetPersistendData().AddOrUpdate($"DialogTo{Root.ScriptId}", true, (key, value) => true);
                }

                return(success);
            }
            catch (Exception error)
            {
                if (!FunctionNeedsMainThread(error, Root))
                {
                    Console.WriteLine("{{ShowDialog}} error " + EmpyrionScripting.ErrorFilter(error));
                }
                return(false);
            }
        }
 public void ShowDialog(DialogConfig dialogConfig,DialogParams dialogParams = null)
 {
     BaseDialog dialog = dialogMap[dialogConfig];
     if (visibleDialog.Contains(dialog))
         return;
    
     visibleDialog.Add(dialog);
     dialog.SetUp(dialogParams);
     dialog.DoShow();
 }
    public DialogConfig GetDialogConfig(int id)
    {
        DialogConfigTable config = TryGetConfig <DialogConfigTable>(ConfigPath_DialogConfig);
        DialogConfig      res    = null;

        if (!config.DialogConfigMap.TryGetValue(id, out res))
        {
            Debuger.LogWarning("can't find target dialog config ,check id " + id);
        }
        return(res);
    }
Exemple #11
0
 public BaseDialogFragment(Context context, Xamarin.Forms.View view,
                           DialogConfig dialogConfig, IDialogMsg dialogMsg)
 {
     _xfView       = view;
     _mContext     = context;
     _dialogConfig = dialogConfig;
     _iDialogMsg   = dialogMsg;
     if (view is IDialogElement)
     {
         _dialogElement = view as IDialogElement;
     }
 }
Exemple #12
0
 public BaseDialogFragment(Context context, Xamarin.Forms.View view, DialogConfig dialogConfig
                           , DialogMsg dialogMsg)
 {
     if (view == null)
     {
         IsNative = true;
     }
     _xfView       = view;
     _mContext     = context;
     _dialogConfig = dialogConfig;
     _dialogMsg    = dialogMsg;
 }
    /// <summary>
    /// Show the dialog
    /// </summary>
    /// <param name="config">Settings with which the dialog should be created.</param>
    public void Show(DialogConfig config)
    {
        activeConfig = config;

        messageField.text = config.Message;
        okButton.GetComponent <Button>().interactable = config.OK.Interactable;
        okButton.transform.Find("Text").GetComponent <Text>().text     = config.OK.Text;
        cancelButton.GetComponent <Button>().interactable              = config.Cancel.Interactable;
        cancelButton.transform.Find("Text").GetComponent <Text>().text = config.Cancel.Text;

        animator.SetBool("IsOpen", true);
        gameObject.SetActive(true);
    }
 public BaseDialogFragment2(Activity activity, Xamarin.Forms.View contentView,
                            DialogConfig dialogConfig, IDialogMsg dialogMsg, IDialogResult dialogResult = null)
 {
     _context      = activity;
     _dialogConfig = dialogConfig;
     _iDialogMsg   = dialogMsg;
     _contentView  = contentView;
     _dialogResult = dialogResult;
     if (contentView is IDialogElement dialogElement)
     {
         _dialogElement = contentView as IDialogElement;
     }
 }
Exemple #15
0
    void Display(DialogConfig config) {
        _grandFather.GetComponent<SpriteRenderer>().enabled = true;

        //sets the text's string
        dialogText.GetComponent<Text>().text = config.text;

        //launches the animation
        dialogText.GetComponent<Animator>().SetBool("FadeIn", true);

        //sets the timer and launches it
        _globalDialogLength = config.duration;
        _countdownON = true;
    }
 public void LoadDialog()
 {
     int dialogCount = (int)DialogConfig.COUNT;
     for (int i=0;i<dialogCount;++i)
     {
         DialogConfig dialogConfig = (DialogConfig)i;
         BaseDialog dialog = Resources.Load<BaseDialog>("Dialogs/" + dialogConfig.ToString());
         BaseDialog dialogInstance = Instantiate(dialog, this.transform);
         dialogInstance.gameObject.SetActive(false);
         dialogMap.Add(dialogConfig, dialogInstance);
         //Resources.UnloadAsset(dialog);
     }
 }
 public void SetDialogCloseWays(DialogConfig config, Android.App.Dialog dialog)
 {
     if (!config.IsCanCancel)
     {
         dialog.SetCancelable(false);
         return;
     }
     if (!config.IsCloseByTouchMask)
     {
         dialog.SetCancelable(true);
         dialog.SetCanceledOnTouchOutside(false);
     }
 }
 public ToastDialogUtil(Activity context, Xamarin.Forms.View view, DialogConfig dialogConfig
                        , IDialogMsg dialogMsg, bool isLong, bool isNative)
 {
     _toastView    = view;
     _mContext     = context;
     _dialogConfig = dialogConfig;
     _dialogMsg    = dialogMsg;
     _isLong       = isLong;
     _isNative     = isNative;
     if (_toastView == null)
     {
         _isNative = true;
     }
 }
Exemple #19
0
    /// <summary>
    /// Callback for the quit button. Brings up the dialog to ask for confirmation.
    /// </summary>
    public void OnQuit()
    {
        DialogConfig config = new DialogConfig
        {
            Message = "Are you sure you want to quit?",
            OK      = new DialogButton(
                text: "Yes",
                onClick: Application.Quit
                ),
            Cancel = new DialogButton(
                text: "Cancel"
                )
        };

        dialog.Show(config);
    }
Exemple #20
0
    /// <summary>
    /// Callback for the quit button. Brings up the dialog for confirmation and loads the main scene if confirmed.
    /// </summary>
    public void OnQuit()
    {
        DialogConfig config = new DialogConfig
        {
            Message = "Are you sure you want to return to the Main Menu?",
            OK      = new DialogButton(
                text: "Yes",
                onClick: ReturnToMainMenu
                ),
            Cancel = new DialogButton(
                text: "Cancel"
                )
        };

        dialog.Show(config);
    }
Exemple #21
0
        /// <summary>
        /// Show dialog with config class
        /// </summary>
        public static ShowDialogResult ShowDialog(DialogConfig Config)
        {
            // Set custom buttons
            DialogInputForm.SetButton(1, Config.CustomButton1Text);
            DialogInputForm.SetButton(2, Config.CustomButton2Text);
            DialogInputForm.SetButton(3, Config.CustomButton3Text);

            // Show dialog
            return(DialogInputForm.ShowDialog(Config.Message,
                                              Config.Title,
                                              Config.DefaultInput,
                                              Config.Input,
                                              Config.Button1,
                                              Config.Button2,
                                              Config.Button3,
                                              Config.Icon));
        }
Exemple #22
0
 public static void Register()
 {
     DialogConfig.Init();
     EffectConfig.Init();
     GameBouquetsConfig.Init();
     GameDailyTaskConfig.Init();
     GameGuideConfig.Init();
     GameInitConfig.Init();
     GDailyTaskGiftConfig.Init();
     GuiConfig.Init();
     IPConfig.Init();
     LuckDrawConfig.Init();
     RepConfig.Init();
     RoleConfig.Init();
     SoundConfig.Init();
     StrConfig.Init();
     TalkConfig.Init();
 }
        public DialogConfig[] GetIntroDialogs()
        {
            DialogConfig           one = new DialogConfig();
            DynData <DialogConfig> d1  = new DynData <DialogConfig>(one);

            d1.Set <Amplitude.StaticString>("Name", "Intro1");
            d1.Set <string>("Text", "%Hero_" + GetName() + "_Intro1");
            DialogConfig           two = new DialogConfig();
            DynData <DialogConfig> d2  = new DynData <DialogConfig>(two);

            d2.Set <Amplitude.StaticString>("Name", "Intro2");
            d2.Set <string>("Text", "%Hero_" + GetName() + "_Intro2");
            DialogConfig           three = new DialogConfig();
            DynData <DialogConfig> d3    = new DynData <DialogConfig>(three);

            d3.Set <Amplitude.StaticString>("Name", "Intro3");
            d3.Set <string>("Text", "%Hero_" + GetName() + "_Intro3");
            return(new DialogConfig[] { one, two, three });
        }
        public void Toast(IDialogMsg dialogMsg, DialogConfig config = null, bool islong = false, bool isNative = false)
        {
            Xamarin.Forms.View toastView = isNative ? null : _dialogsInitize.GetInitToastView();
            if (config == null)
            {
                config = new DialogConfig()
                {
                    DialogPosition = DialogPosition.ToastDefault
                };
            }
            ToastDialogUtil toastDialog = new ToastDialogUtil(_activity, toastView, config
                                                              , dialogMsg, islong, isNative);
            var toast = toastDialog.Builder();

            if (toast != null)
            {
                toast.Show();
            }
        }
Exemple #25
0
        private OverlayReference Open <TContentData>(Type componentType, DialogConfig dialogConfig, ContentData contentData)
        {
            if (!typeof(ComponentBase).IsAssignableFrom(componentType))
            {
                throw new ArgumentException($"{componentType.FullName} must be a Blazor Component");
            }

            var globalPositionStrategy = new GlobalPositionStrategyBuilder();

            globalPositionStrategy.CenterVertically("");
            globalPositionStrategy.CenterHorizontally("");

            var overlayConfig = new OverlayConfig()
            {
                HasBackdrop            = dialogConfig.HasBackdrop,
                HasTransparentBackdrop = dialogConfig.HasTransparentBackdrop,
                Width  = dialogConfig.Width,
                Height = dialogConfig.Height,
                GlobalPositionStrategy = globalPositionStrategy
            };

            var userContent = new RenderFragment(x =>
            {
                x.OpenComponent(0, componentType);
                x.AddAttribute(1, "ContentData", contentData);
                x.CloseComponent();
            });

            var dialog = new RenderFragment(x =>
            {
                x.OpenComponent(0, typeof(DnetDialog));
                x.AddAttribute(1, "Title", dialogConfig.Title);
                x.AddAttribute(2, "DialogClass", dialogConfig.DialogClass);
                x.AddAttribute(3, "ContentChild", userContent);
                x.CloseComponent();
            });

            var overlayReference = _overlayService.Attach(dialog, overlayConfig);

            return(overlayReference);
        }
        public IDialog CreateDialog(DialogType dialogType, IDialogMsg dialogMsg, DialogConfig config = null)
        {
            var contentView = _dialogsInitize.GetInitDialogContentView(dialogType);

            if (contentView == null)
            {
                throw new Exception($"{dialogType} not map");
            }
            if (config == null)
            {
                config = _dialogsInitize.GetInitDialogConfig(dialogType);
            }
            DialogResultManager manager = new DialogResultManager();

            manager.Build();
            var dialogFragment = new BaseDialogFragment2(_activity, contentView, config, dialogMsg,
                                                         manager.GetDialogResult());
            var dialogDroid = new DialogInstance(dialogFragment, _fragmentManager, contentView,
                                                 manager.GetResultMission());

            return(dialogDroid);
        }
Exemple #27
0
    /// <summary>
    /// Callback for "showMoveDialog" event. Generates content for the move confirmation
    /// dialog and enables it.
    /// </summary>
    /// <param name="type"></param>
    public void ShowMoveDialog(ETowerType type)
    {
        currentType = type;
        DialogConfig config = new DialogConfig();

        int    cost = currentType.GetMoveCost();
        string messageString;

        if (cost > GameState.CurrentCash)
        {
            messageString = "You don't have enough cash. Required: " + cost + ". You have $" + GameState.CurrentCash;

            // As both buttons won't do anything special in this case, you could leave the callback
            config.OK = new DialogButton(
                interactable: false,
                text: "Move"
                );
            config.Cancel = new DialogButton(
                onClick: OnCancelClickMove,
                text: "Cancel"
                );
        }
        else
        {
            messageString = "Moving " + type.GetString() + " will cost $" + cost + ". You have $" + GameState.CurrentCash;
            config.OK     = new DialogButton(
                onClick: OnOKClickMove,
                text: "Move"
                );
            config.Cancel = new DialogButton(
                onClick: OnCancelClickMove,
                text: "Cancel"
                );
        }

        config.Message = messageString;
        dialogSystem.Show(config);
    }
Exemple #28
0
        public bool ShowDialog(int playerId, DialogConfig dialogConfig, DialogActionHandler actionHandler, int customValue)
        {
            try
            {
                var playerData = Root.IsElevatedScript
                    ? (Root.GetCurrentPlayfield().Players.TryGetValue(playerId, out var plainPlayer) ? new DataWrapper.PlayerData(Root.GetCurrentPlayfield(), plainPlayer) : null)
                    : Root.E.S.Players.FirstOrDefault(P => P.Id == playerId);

                if (playerData == null)
                {
                    return(false);
                }

                return(EmpyrionScripting.ModApi.Application.ShowDialogBox(playerId, dialogConfig, actionHandler, customValue));
            }
            catch (Exception error)
            {
                if (!FunctionNeedsMainThread(error, Root))
                {
                    Console.WriteLine("{{ShowDialog}} error " + EmpyrionScripting.ErrorFilter(error));
                }
                return(false);
            }
        }
Exemple #29
0
    void PlayDialog(DialogConfig config) {
        Display(config);

        var audio = (AudioClip)Resources.Load("Voices/" + config.audio, typeof(AudioClip));
        _grandFather.GetComponent<AudioSource>().PlayOneShot(audio);
    }
 public PopupDialogFragment(Activity activity, Xamarin.Forms.View contentView, DialogConfig dialogConfig, IDialogMsg dialogMsg,
                            BaseViewRect baseViewRect, IDialogResult dialogResult = null)
     : base(activity, contentView, dialogConfig, dialogMsg, dialogResult)
 {
     this._baseViewRect = baseViewRect;
 }
Exemple #31
0
 public Dialog(DialogConfig config)
 {
     this.Config = config;
 }
 public LoadDialogFragment(Context context, Xamarin.Forms.View view, DialogConfig dialogConfig, DialogMsg dialogMsg)
     : base(context, view, dialogConfig, dialogMsg)
 {
 }