Exemplo n.º 1
0
    private static void CreateButton(Group parent)
    {
        Button btn1 = new Button
        {
            Text         = @"Click to mask me for 3 seconds :)",
            Icon         = Resources.Load <Texture>("Icons/star_big"),
            SkinClass    = typeof(ButtonSkin5),
            Left         = 100,
            Top          = 100,
            Width        = 250,
            Height       = 250,
            FocusEnabled = false
        };

        btn1.Click += new EventHandler(delegate
        {
            int count = 0;

            LoadingMask mask = new LoadingMask(btn1);

            Timer t = new Timer(1, 3)
            {
                TickOnStart = true
            };
            t.Tick += delegate
            {
                mask.SetMessage(string.Format("Masking... {0} seconds", count));
                count++;
            };
            t.Complete += delegate { mask.Unmask(); };
            t.Start();
        });
        parent.AddChild(btn1);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Hides the global mask
        /// </summary>
        public static void Hide()
        {
            //GlobalLoadingMaskStage.Instance.DispatchEvent(new LoadingEvent(LoadingEvent.END));
            if (null == _mask)
                return;

            _mask.Unmask();
            _mask = null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Hides the global mask
        /// </summary>
        public static void Hide()
        {
            //GlobalLoadingMaskStage.Instance.DispatchEvent(new LoadingEvent(LoadingEvent.END));
            if (null == _mask)
            {
                return;
            }

            _mask.Unmask();
            _mask = null;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Fires after the message is sent
 /// </summary>
 /// <param name="e"></param>
 private void MessageSentHandler(Event e)
 {
     _mask.Unmask();
     _mask = null;
     _timer.RemoveEventListener(Timer.COMPLETE, MessageSentHandler);
     Alert.Show("Info", "Message sent!", AlertButtonFlag.Ok,
                delegate
     {
         SetFocus();
     });
 }
Exemplo n.º 5
0
 /// <summary>
 /// Fires after the message is sent
 /// </summary>
 /// <param name="e"></param>
 private void LogInHandler(Event e)
 {
     _mask.Unmask();
     _mask = null;
     _timer.RemoveEventListener(Timer.COMPLETE, LogInHandler);
     DispatchLoginEvent();
     Alert.Show("Info", "You are logged in.", AlertButtonFlag.Ok,
                delegate
     {
         SetFocus();
     });
 }
Exemplo n.º 6
0
        private void ClosePopup(object sender, XBackRequestedEventArgs e)
        {
            // Restart Required
            if (RestartMask.State == ControlState.Active)
            {
                return;
            }

            // Go back
            LoadingMask.HandleBack(Frame, e);
            Dispose();
        }
Exemplo n.º 7
0
    void OnGUI()
    {
        if (GUILayout.Button("StartLoading"))
        {
            LoadingMask.StartLoading();
        }
        if (GUILayout.Button("EndLoading"))
        {
            LoadingMask.EndLoading();
        }
        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("EnterMajorLevel"))
            {
                PushLevelUI.Instance.EnterMajorLevel(new MajorLevelUnlockInfo(2, true));
            }
            if (GUILayout.Button("EndChallengeRound"))
            {
                GameManager.Instance.StartCoroutine(GameManager.Instance.EndChallengeRoundCoroutine());
                GameManager.Instance.EndChallengeRound(true);
            }
        }
        EditorGUILayout.EndHorizontal();

        Clip = EditorGUILayout.ObjectField("Button Audio", Clip, typeof(AudioClip), false) as AudioClip;
        if (GUILayout.Button("ChangeAllButtonAudio"))
        {
            if (!Clip)
            {
                Debug.LogError("没Clip"); return;
            }
            var allGo = Resources.FindObjectsOfTypeAll <GameObject>();

            var count = 0;
            foreach (var g in allGo)
            {
                var allPs = g.GetComponentsInChildren <UIPlaySound>();
                foreach (var uiPlaySound in allPs)
                {
                    if (uiPlaySound.GetComponent <UIButtonColor>() || uiPlaySound.GetComponent <MorlnUIButtonScale>() ||
                        uiPlaySound.GetComponent <UIButtonScale>())
                    {
                        uiPlaySound.audioClip = Clip;
                        EditorUtility.SetDirty(uiPlaySound);
                        count++;
                    }
                }
            }
            Debug.Log("Finish Op:cou:" + count);
        }
    }
Exemplo n.º 8
0
        /// <summary>
        /// Shows the global loading mask on it's own viewpoet
        /// </summary>
        /// <param name="message"></param>
        public static void Show(string message)
        {
            if (null != _mask) // destroy the previous mask
                _mask.Unmask();

            //GlobalLoadingMaskStage.Instance.Plugins[0].Initialize(GlobalLoadingMaskStage.Instance); // temp. fix (because CreationComplete not yet executed). Meditate on this!
            //GlobalLoadingMaskStage.Instance.DispatchEvent(new LoadingEvent(LoadingEvent.START, message));

            if (!_runOnce)
            {
                /* There's a glitch of not showing the first time. Investigate why this blobk is needed */
                var inst = GlobalLoadingMaskStage.Instance;
                inst.ValidateNow();
                _runOnce = true;
            }

            _mask = new LoadingMask(GlobalLoadingMaskStage.Instance, message);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Shows the global loading mask on it's own viewpoet
        /// </summary>
        /// <param name="message"></param>
        public static void Show(string message)
        {
            if (null != _mask) // destroy the previous mask
            {
                _mask.Unmask();
            }

            //GlobalLoadingMaskStage.Instance.Plugins[0].Initialize(GlobalLoadingMaskStage.Instance); // temp. fix (because CreationComplete not yet executed). Meditate on this!
            //GlobalLoadingMaskStage.Instance.DispatchEvent(new LoadingEvent(LoadingEvent.START, message));

            if (!_runOnce)
            {
                /* There's a glitch of not showing the first time. Investigate why this blobk is needed */
                var inst = GlobalLoadingMaskStage.Instance;
                inst.ValidateNow();
                _runOnce = true;
            }

            _mask = new LoadingMask(GlobalLoadingMaskStage.Instance, message);
        }
Exemplo n.º 10
0
        private void DoLogin()
        {
            if (null != _mask) // already logging in
            {
                return;
            }

            _controlToFocus = null;

            if (string.IsNullOrEmpty(_txtUsername.Text))
            {
                Alert.Show("Error", @"Username must not be empty", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtUsername;
                return;
            }
            if (string.IsNullOrEmpty(_txtPassword.Text))
            {
                Alert.Show("Error", @"Password must not be empty", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtPassword;
                return;
            }

            _username = _txtUsername.Text;
            _password = _txtPassword.Text;

            if (SendMode == SendMode.SimulateSending) // just simulate sending
            {
                _mask = new LoadingMask(this, "Logging in...");
                _timer.AddEventListener(Timer.COMPLETE, LogInHandler); // simulating sent result after 3 seconds
                _timer.Start();
            }
            else // notify the world
            {
                DispatchLoginEvent();
            }
        }
Exemplo n.º 11
0
        private void DoLogin()
        {
            if (null != _mask) // already logging in
                return;

            _controlToFocus = null;

            if (string.IsNullOrEmpty(_txtUsername.Text))
            {
                Alert.Show("Error", @"Username must not be empty", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtUsername;
                return;
            }
            if (string.IsNullOrEmpty(_txtPassword.Text))
            {
                Alert.Show("Error", @"Password must not be empty", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtPassword;
                return;
            }

            _username = _txtUsername.Text;
            _password = _txtPassword.Text;

            if (SendMode == SendMode.SimulateSending) // just simulate sending
            {
                _mask = new LoadingMask(this, "Logging in...");
                _timer.AddEventListener(Timer.COMPLETE, LogInHandler); // simulating sent result after 3 seconds
                _timer.Start();
            }
            else // notify the world
            {
                DispatchLoginEvent();
            }
        }
Exemplo n.º 12
0
    private static void CreateButton(Group parent)
    {
        Button btn1 = new Button
        {
            Text = @"Click to mask me for 3 seconds :)",
            Icon = Resources.Load<Texture>("Icons/star_big"),
            SkinClass = typeof (ButtonSkin5),
            Left = 100,
            Top = 100,
            Width = 250,
            Height = 250,
            FocusEnabled = false
        };
        btn1.Click += new EventHandler(delegate
        {
            int count = 0;

            LoadingMask mask = new LoadingMask(btn1);
            
            Timer t = new Timer(1, 3) {TickOnStart = true};
            t.Tick += delegate
            {
                mask.SetMessage(string.Format("Masking... {0} seconds", count));
                count++;
            };
            t.Complete += delegate { mask.Unmask(); };
            t.Start();
        });
        parent.AddChild(btn1);
    }
Exemplo n.º 13
0
 /// <summary>
 /// Fires after the message is sent
 /// </summary>
 /// <param name="e"></param>
 private void MessageSentHandler(Event e)
 {
     _mask.Unmask();
     _mask = null;
     _timer.RemoveEventListener(Timer.COMPLETE, MessageSentHandler);
     Alert.Show("Info", "Message sent!", AlertButtonFlag.Ok,
                delegate
                    {
                        SetFocus();
                    });
 }
Exemplo n.º 14
0
        /// <summary>
        /// Does a sanity check and then sends the message
        /// </summary>
        private void SendMessage()
        {
            if (null != _mask) // already sending
                return;

            _controlToFocus = null;

            if (string.IsNullOrEmpty(_txtTo.Text))
            {
                Alert.Show("Error", @"No recipients. Please add some...", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtTo;
                return;
            }
                
            if (!CheckRecipients(_txtTo.Text))
            {
                Alert.Show("Error", @"Error with ""To:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtTo;
                return;
            }

            if (_btnCc.Selected && !string.IsNullOrEmpty(_txtCc.Text) && !CheckRecipients(_txtCc.Text))
            {
                Alert.Show("Error", @"Error with ""Cc:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtCc;
                return;
            }

            if (_btnBcc.Selected && !string.IsNullOrEmpty(_txtBcc.Text) && !CheckRecipients(_txtBcc.Text))
            {
                Alert.Show("Error", @"Error with ""Bcc:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtBcc;
                return;
            }

            if (string.IsNullOrEmpty(_txtMessage.Text))
            {
                Alert.Show("Error", @"No message. Please add some text.", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtMessage;
                return;
            }

            if (SendMode == SendMode.SimulateSending) // just simulate sending
            {
                _mask = new LoadingMask(this, "Sending message...");
                _timer.AddEventListener(Timer.COMPLETE, MessageSentHandler); // simulating sent result after 3 seconds
                _timer.Start();
            }
            else // notify the world
            {
                var e = new ExampleEvent(ExampleEvent.SEND_MESSAGE)
                {
                    Bubbles = true, // bubble event
                    To = _txtTo.Text,
                    Cc = _txtCc.Text,
                    Bcc = _txtBcc.Text,
                    Message = _txtMessage.Text
                };
                Debug.Log("Dispatching an event, catch it from outside: " + e);
                DispatchEvent(e);
            }
        }
Exemplo n.º 15
0
        protected override void CommitProperties()
        {
            base.CommitProperties();

            if (_imageUrlChanged)
            {
                _imageUrlChanged = false;

                _mask = new LoadingMask(ContentGroup, "Loading image...");
                var cursor = CursorManager.Instance.SetCursor(CursorType.Wait);

                var oldBounds = Rectangle.FromWidthAndHeight(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                oldBounds = oldBounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));

                ImageLoader.Load(_imageUrl, delegate(Texture texture)
                {
                    //Debug.Log("texture size: " + texture.width + ", " + texture.height);
                    _image.Texture = texture;
                    _image.Visible = false;

                    // reset explicit size to allow measurement
                    ExplicitWidth  = null;
                    ExplicitHeight = null;

                    ValidateSize(true);

                    var newBounds = Rectangle.FromWidthAndHeight(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                    // center on screen
                    newBounds = newBounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                    //Debug.Log("newBounds: " + newBounds);

                    // return to the old size immediatelly, because of the flicker
                    Width  = oldBounds.Width;
                    Height = oldBounds.Height;

                    #region Alternative

                    //SetActualSize(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                    //PopupManager.Instance.CenterPopUp(this);

                    #endregion

                    Defer(delegate
                    {
                        // tween the window size
                        //var newBounds = Bounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                        ScaleBoundsTween tween = new ScaleBoundsTween(this, oldBounds, newBounds)
                        {
                            Callback = delegate
                            {
                                _image.Visible = true; // show image
                                //_image.SkipRender(2); // avoid flicker
                                _image.Alpha = 0;

                                // fade in the image
                                FadeIn fadeIn = new FadeIn
                                {
                                    Duration = 1
                                };
                                fadeIn.Play(_image);
                            }
                        };
                        tween.Play();
                    }, 1);

                    //GlobalLoadingMask.Hide();
                    _mask.Unmask();
                    CursorManager.Instance.RemoveCursor(cursor);
                });
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Fires after the message is sent
 /// </summary>
 /// <param name="e"></param>
 private void LogInHandler(Event e)
 {
     _mask.Unmask();
     _mask = null;
     _timer.RemoveEventListener(Timer.COMPLETE, LogInHandler);
     DispatchLoginEvent();
     Alert.Show("Info", "You are logged in.", AlertButtonFlag.Ok,
     delegate
     {
         SetFocus();
     });
 }
Exemplo n.º 17
0
        protected override void CommitProperties()
        {
            base.CommitProperties();

            if (_imageUrlChanged)
            {
                _imageUrlChanged = false;

                _mask = new LoadingMask(ContentGroup, "Loading image...");
                var cursor = CursorManager.Instance.SetCursor(CursorType.Wait);

                var oldBounds = Rectangle.FromWidthAndHeight(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                oldBounds = oldBounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                
                ImageLoader.Load(_imageUrl, delegate(Texture texture)
                {
                    //Debug.Log("texture size: " + texture.width + ", " + texture.height);
                    _image.Texture = texture;
                    _image.Visible = false;
                    
                    // reset explicit size to allow measurement
                    ExplicitWidth = null;
                    ExplicitHeight = null;

                    ValidateSize(true);
                    
                    var newBounds = Rectangle.FromWidthAndHeight(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                    // center on screen
                    newBounds = newBounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                    //Debug.Log("newBounds: " + newBounds);

                    // return to the old size immediatelly, because of the flicker
                    Width = oldBounds.Width;
                    Height = oldBounds.Height;

                    #region Alternative

                    //SetActualSize(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                    //PopupManager.Instance.CenterPopUp(this);

                    #endregion

                    Defer(delegate
                    {
                        // tween the window size
                        //var newBounds = Bounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                        ScaleBoundsTween tween = new ScaleBoundsTween(this, oldBounds, newBounds)
                        {
                            Callback = delegate
                            {
                                _image.Visible = true; // show image
                                //_image.SkipRender(2); // avoid flicker
                                _image.Alpha = 0;

                                // fade in the image
                                FadeIn fadeIn = new FadeIn
                                {
                                    Duration = 1
                                };
                                fadeIn.Play(_image);
                            }
                        };
                        tween.Play();
                    }, 1);

                    //GlobalLoadingMask.Hide();
                    _mask.Unmask();
                    CursorManager.Instance.RemoveCursor(cursor);
                });
            }
        }
Exemplo n.º 18
0
    IEnumerator _Goto()
    {
        _isSwitching = true;
        if (GetNeedLoadingMask())
        {
            LoadingMask.StartLoading();
            yield return(new WaitForSeconds(LoadingMask.Instance.TimeToUnload));
        }

        BaseUI newUI = null;

        switch (_targetUIState)
        {
        case UIStateName.Entrance:
            newUI = EntranceUI.EnterStage();
            break;

        case UIStateName.Menu:
            newUI = MenuUI.EnterStage();
            break;

        case UIStateName.Match:
            newUI = MatchUI.EnterStage();
            break;

        case UIStateName.Game:
            newUI = GameUI.EnterStage();
            break;

        case UIStateName.PushLevel:
            newUI = PushLevelUI.EnterStage();
            break;

        case UIStateName.EndRound:
            newUI = EndRoundUI.EnterStage();
            break;

        default:
            Debug.LogError("ERROR uiState:" + _targetUIState);
            break;
        }
        switch (_targetUIState)
        {
        case UIStateName.Entrance:
            var sr = Background.GetComponent <SpriteRenderer>();
            sr.sprite = SprSplash;
            break;

        case UIStateName.PushLevel:
            //Background.gameObject.SetActive(false);
            break;

        default:
            //Background.gameObject.SetActive(true);
            sr        = Background.GetComponent <SpriteRenderer>();
            sr.sprite = SprBg;
            break;
        }

        if (!newUI)
        {
            Debug.LogError("GotoUI却没有成功创建UI:" + _targetUIState);
        }

        for (int i = 0; i < _baseUIs.Length; i++)
        {
            if (i == (int)_targetUIState)
            {
                _baseUIs[i] = newUI;
            }
            else
            {
                if (_baseUIs[i])
                {
                    _baseUIs[i].OffStage();
                    _baseUIs[i] = null;
                    Resources.UnloadUnusedAssets();
                }
            }
        }

        LoadingMask.EndLoading();
        _isSwitching = false;
    }
Exemplo n.º 19
0
        /// <summary>
        /// Does a sanity check and then sends the message
        /// </summary>
        private void SendMessage()
        {
            if (null != _mask) // already sending
            {
                return;
            }

            _controlToFocus = null;

            if (string.IsNullOrEmpty(_txtTo.Text))
            {
                Alert.Show("Error", @"No recipients. Please add some...", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtTo;
                return;
            }

            if (!CheckRecipients(_txtTo.Text))
            {
                Alert.Show("Error", @"Error with ""To:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtTo;
                return;
            }

            if (_btnCc.Selected && !string.IsNullOrEmpty(_txtCc.Text) && !CheckRecipients(_txtCc.Text))
            {
                Alert.Show("Error", @"Error with ""Cc:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtCc;
                return;
            }

            if (_btnBcc.Selected && !string.IsNullOrEmpty(_txtBcc.Text) && !CheckRecipients(_txtBcc.Text))
            {
                Alert.Show("Error", @"Error with ""Bcc:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtBcc;
                return;
            }

            if (string.IsNullOrEmpty(_txtMessage.Text))
            {
                Alert.Show("Error", @"No message. Please add some text.", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtMessage;
                return;
            }

            if (SendMode == SendMode.SimulateSending) // just simulate sending
            {
                _mask = new LoadingMask(this, "Sending message...");
                _timer.AddEventListener(Timer.COMPLETE, MessageSentHandler); // simulating sent result after 3 seconds
                _timer.Start();
            }
            else // notify the world
            {
                var e = new ExampleEvent(ExampleEvent.SEND_MESSAGE)
                {
                    Bubbles = true, // bubble event
                    To      = _txtTo.Text,
                    Cc      = _txtCc.Text,
                    Bcc     = _txtBcc.Text,
                    Message = _txtMessage.Text
                };
                Debug.Log("Dispatching an event, catch it from outside: " + e);
                DispatchEvent(e);
            }
        }