Inheritance: MonoBehaviour
Exemplo n.º 1
0
        public override void Init(ModalParameters parameters)
        {
            base.Init(parameters);
            InfoModalParameters infoModalParameters = parameters as InfoModalParameters;

            if (!string.IsNullOrEmpty(infoModalParameters.Title))
            {
                titleText.text = infoModalParameters.Title;
            }
            if (!string.IsNullOrEmpty(infoModalParameters.Message))
            {
                messageText.text = infoModalParameters.Message;
            }
            if (infoModalParameters.Buttons != null)
            {
                foreach (ModalButtonParameters modalButtonParameters in infoModalParameters.Buttons)
                {
                    if (modalButtonParameters == null)
                    {
                        SpawnButton(GenerateDefaultButtonParameters());
                    }
                    else
                    {
                        ModalButton modalButton = SpawnButton(modalButtonParameters);
                        modalButton.ButtonClicked += modalWindow.CloseWindow;
                    }
                }
            }
            else
            {
                SpawnButton(GenerateDefaultButtonParameters());
            }
            closeCallback = infoModalParameters.CloseCallback;
            IsReady       = true;
        }
Exemplo n.º 2
0
 public void RenameItemContentEditor(string itemName)
 {
     ContentEditor.SendKeys(Keys.F2);
     ModalText.SendKeys(itemName);
     Driver.SwitchTo().DefaultContent();
     ModalButton.Click();
 }
Exemplo n.º 3
0
        protected virtual ModalButton SpawnButton(ModalButtonParameters parameters)
        {
            GameObject  buttonObject = Instantiate(buttonPrefab, buttonsPanel);
            ModalButton modalButton  = buttonObject.GetComponent <ModalButton>();

            modalButton.Init(parameters);
            return(modalButton);
        }
Exemplo n.º 4
0
        public void PublishItemContentEditor()
        {
            ContentEditor.SendKeys(Keys.Alt + 'p');

            PublishButton.Click();

            ModalButton.Click();
            ModalButton.Click();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Shows the modal with the component type using the specified <paramref name="title"/>,
        /// passing the specified <paramref name="parameters"/> and setting a custom CSS style.
        /// </summary>
        /// <param name="title">Modal title.</param>
        /// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
        /// <param name="options">Options to configure the modal.</param>
        public ModalReference Show(Type contentComponent, string title, ModalParameters parameters, ModalOptions options,
                                   string message         = null, ModalButton modalButton = 0, ModalType modalType = 0, string captionYesButton = null,
                                   string captionNoButton = null, string captionOkButton  = null, string captionCancelButton = null)
        {
            if (!typeof(ComponentBase).IsAssignableFrom(contentComponent))
            {
                throw new ArgumentException($"{contentComponent.FullName} must be a Blazor Component");
            }

            var modalInstanceId = Guid.NewGuid();
            var modalContent    = new RenderFragment(builder =>
            {
                var i = 0;
                builder.OpenComponent(i++, contentComponent);
                foreach (var parameter in parameters._parameters)
                {
                    builder.AddAttribute(i++, parameter.Key, parameter.Value);
                }
                builder.CloseComponent();
            });
            var modalInstance = new RenderFragment(builder =>
            {
                builder.OpenComponent <BlazoredModalInstance>(0);
                builder.AddAttribute(1, "Options", options);
                builder.AddAttribute(2, "Title", title);
                builder.AddAttribute(3, "Content", modalContent);
                builder.AddAttribute(4, "Id", modalInstanceId);
                builder.AddAttribute(5, "Message", message);
                builder.AddAttribute(6, "ModalButton", modalButton);
                builder.AddAttribute(7, "ModalType", modalType);
                builder.AddAttribute(8, "CaptionYesButton", captionYesButton);
                builder.AddAttribute(9, "CaptionNoButton", captionNoButton);
                builder.AddAttribute(10, "CaptionOkButton", captionOkButton);
                builder.AddAttribute(11, "CaptionCancelButton", captionCancelButton);
                builder.CloseComponent();
            });
            var modalReference = new ModalReference(modalInstanceId, modalInstance);

            OnModalInstanceAdded?.Invoke(modalReference);

            return(modalReference);
        }
Exemplo n.º 6
0
 private static bool manageModalButton(GameObject modalButton, string modalButtonClass)
 {
     Logger.Log(string.Format("ModalManager::manageModalButton({0}, {1})", modalButton, modalButtonClass), Logger.Level.INFO);
     if (null != modalButton && modalButton.activeInHierarchy)
     {
         //TODO check need for getting component with class name "modalButtonClass"
         ModalButton button = (ModalButton)modalButton.GetComponent(System.Type.GetType(modalButtonClass));
         if (null != button)
         {
             button.press();
             return(true);
         }
         else
         {
             Logger.Log(string.Format("ModalManager::manageModalButton({0}, {1}) - button does not have required component!", modalButton, modalButtonClass), Logger.Level.WARN);
         }
     }
     Logger.Log(string.Format("ModalManager::manageModalButton({0}, {1}) returns false", modalButton, modalButtonClass), Logger.Level.DEBUG);
     return(false);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Adds a button to the panel, use it before Display()
        /// </summary>
        /// <param name="label">Button Label</param>
        /// <param name="action">UnityAction</param>
        public void AddButton(string label, UnityAction action)
        {
            ModalButton modalButton = new ModalButton(label, action);

            ButtonCollection.Add(modalButton);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Shows the modal generic with the specific component type.
 /// </summary>
 /// <param name="contentComponent">Type of component to display.</param>
 public ModalReference ShowGeneric(string title, string message, ModalButton modalButton, ModalType modalType, string captionYesButton = null,
                                   string captionNoButton = null, string captionOkButton = null, string captionCancelButton = null)
 {
     return(Show(typeof(ModalGeneric), title, new ModalParameters(), new ModalOptions(), message: message, modalButton: modalButton,
                 modalType: modalType, captionYesButton: captionYesButton, captionNoButton: captionNoButton, captionOkButton: captionOkButton, captionCancelButton: captionCancelButton));
 }