Exemple #1
0
        public override void OnDeinit(System.Action callback)
        {
            base.OnDeinit(callback);

            this._rectTransform = null;
            this.rootComponent  = null;
            //this.subComponents = null;
        }
        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate new component manualy but wants the window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public override void RegisterSubComponent(WindowObjectElement subComponent)
        {
            if (this.GetWindow() != null)
            {
                subComponent.Setup(this.GetLayoutRoot());
            }

            base.RegisterSubComponent(subComponent);
        }
		/// <summary>
		/// Registers the sub component.
		/// If you want to instantiate new component manualy but wants the window events - register this component here.
		/// </summary>
		/// <param name="subComponent">Sub component.</param>
		public override void RegisterSubComponent(WindowObjectElement subComponent) {

            if (this.GetWindow() != null) {

                subComponent.Setup(this.GetLayoutRoot());

            }

		    base.RegisterSubComponent(subComponent);

		}
        public override void UnregisterSubComponent(WindowObjectElement subComponent, System.Action callback = null, bool immediately = true)
        {
            base.UnregisterSubComponent(subComponent, callback, immediately);

            var nav = subComponent as IWindowNavigation;

            if (nav != null)
            {
                if (this is IListComponent)
                {
                    nav.NavigationUnsetList();
                }
            }
        }
Exemple #5
0
        public WindowObjectElement GetRootComponent()
        {
                        #if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                if (this.rootComponent == null && this.transform.parent != null)
                {
                    this.rootComponent = ME.Utilities.FindReferenceParent <WindowObjectElement>(this.transform.parent.gameObject);
                }
            }
                        #endif

            return(this.rootComponent);
        }
        public override void RegisterSubComponent(WindowObjectElement subComponent)
        {
            base.RegisterSubComponent(subComponent);

            var nav = subComponent as IWindowNavigation;

            if (nav != null)
            {
                this.NavigateCopyTo(nav);

                if (this is IListComponent)
                {
                    nav.NavigationSetList(this as IListComponent);
                }
            }
        }
Exemple #7
0
        private void Update_EDITOR()
        {
            if (Application.isPlaying == true)
            {
                return;
            }

            this.rootComponent = ME.Utilities.FindReferenceParent <WindowObjectElement>(this.transform.parent);

            this.SetComponentState(WindowObjectState.NotInitialized, dontInactivate: true);

            if (this.autoRegisterSubComponents == true)
            {
                var components = this.GetComponentsInChildren <WindowObjectElement>(true).ToList();

                this.subComponents.Clear();
                foreach (var component in components)
                {
                    if (component == this)
                    {
                        continue;
                    }

                    var parents = component.GetComponentsInParent <WindowObjectElement>(true).ToList();
                    parents.Remove(component);

                    if (parents.Count > 0 && parents[0] != this)
                    {
                        continue;
                    }
                    if (component.autoRegisterInRoot == false)
                    {
                        continue;
                    }

                    this.subComponents.Add(component);
                }
            }
            else
            {
                //this.subComponents.Clear();
            }

            this.subComponents = this.subComponents.Where((c) => c != null).ToList();
        }
        public override void UnregisterSubComponent(WindowObjectElement subComponent, System.Action callback = null) {

            base.UnregisterSubComponent(subComponent, callback);

			var nav = subComponent as IWindowNavigation;
			if (nav != null) {
				
				if (this is IListComponent) {

					nav.NavigationUnsetList();

				}

			}

		}
		public override void RegisterSubComponent(WindowObjectElement subComponent) {

			base.RegisterSubComponent(subComponent);

			var nav = subComponent as IWindowNavigation;
			if (nav != null) {
				
				this.NavigateCopyTo(nav);

				if (this is IListComponent) {
					
					nav.NavigationSetList(this as IListComponent);

				}

			}

		}
Exemple #10
0
        /// <summary>
        /// Unregisters the sub component.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public void UnregisterSubComponent(WindowObjectElement subComponent, System.Action callback = null)
        {
            var sendCallback = true;

            //Debug.Log("UNREGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState());

            this.subComponents.Remove(subComponent);

            switch (this.GetComponentState())
            {
            case WindowObjectState.Shown:

                // after OnShowEnd
                subComponent.OnHideBegin(() => {
                    subComponent.OnHideEnd();
                    subComponent.OnDeinit();

                    if (callback != null)
                    {
                        callback();
                    }
                });

                sendCallback = false;

                break;

            case WindowObjectState.Hiding:

                // after OnHideBegin
                subComponent.OnHideBegin(null);

                sendCallback = false;
                if (callback != null)
                {
                    callback();
                }

                break;

            case WindowObjectState.Hidden:

                // after OnHideEnd
                subComponent.OnHideBegin(() => {
                    subComponent.OnHideEnd();
                    subComponent.OnDeinit();

                    if (callback != null)
                    {
                        callback();
                    }
                });

                sendCallback = false;

                break;
            }

            if (sendCallback == true && callback != null)
            {
                callback();
            }
        }
Exemple #11
0
        /*public virtual void DeactivateComponents() {
         *
         *              for (int i = 0; i < this.subComponents.Count; ++i) this.subComponents[i].DeactivateComponents();
         *
         *  if (this == null) return;
         *  this.gameObject.SetActive(false);
         *
         * }*/

        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate a new component manualy but wants window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public virtual void RegisterSubComponent(WindowObjectElement subComponent)
        {
            //Debug.Log("REGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState());
            switch (this.GetComponentState())
            {
            case WindowObjectState.Hiding:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    // after OnInit
                    subComponent.OnInit();
                }

                subComponent.SetComponentState(this.GetComponentState());

                break;

            case WindowObjectState.Hidden:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    // after OnInit
                    subComponent.OnInit();
                }

                subComponent.SetComponentState(this.GetComponentState());

                break;

            case WindowObjectState.Initializing:
            case WindowObjectState.Initialized:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    // after OnInit
                    subComponent.OnInit();
                }

                break;

            case WindowObjectState.Showing:

                // after OnShowBegin

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.OnInit();
                }

                subComponent.OnShowBegin(null);

                break;

            case WindowObjectState.Shown:

                // after OnShowEnd

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.OnInit();
                }

                subComponent.OnShowBegin(() => {
                    subComponent.OnShowEnd();
                });

                break;
            }

            if (this.GetWindow() != null)
            {
                subComponent.Setup(this.GetWindow());
                // subComponent.Setup(this.GetLayoutRoot());
            }

            if (this.subComponents.Contains(subComponent) == false)
            {
                this.subComponents.Add(subComponent);
            }
        }
Exemple #12
0
        /// <summary>
        /// Unregisters the sub component.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public virtual void UnregisterSubComponent(WindowObjectElement subComponent, System.Action callback = null, bool immediately = true)
        {
                        #if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                return;
            }
                        #endif

            var sendCallback = true;

            //Debug.Log("UNREGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState());

            subComponent.rootComponent = null;
            this.subComponents.Remove(subComponent);

            var controller = (subComponent as IWindowEventsController);

            switch (subComponent.GetComponentState())
            {
            case WindowObjectState.Showing:
            case WindowObjectState.Shown:

                // after OnShowEnd
                controller.DoWindowClose();
                controller.DoWindowInactive();
                controller.DoHideBegin(AppearanceParameters.Default().ReplaceForced(forced: true).ReplaceImmediately(immediately));
                controller.DoHideEnd(AppearanceParameters.Default().ReplaceForced(forced: true).ReplaceImmediately(immediately));
                controller.DoWindowUnload();
                controller.DoDeinit(() => { if (callback != null)
                                            {
                                                callback();
                                            }
                                    });

                sendCallback = false;

                break;

            case WindowObjectState.Hiding:

                // after OnHideBegin
                controller.DoWindowClose();
                controller.DoWindowInactive();
                controller.DoHideEnd(AppearanceParameters.Default().ReplaceForced(forced: true).ReplaceImmediately(immediately));
                controller.DoWindowUnload();
                controller.DoDeinit(() => { if (callback != null)
                                            {
                                                callback();
                                            }
                                    });

                sendCallback = false;

                break;

            case WindowObjectState.Hidden:

                // after OnHideEnd
                controller.DoWindowClose();
                controller.DoWindowInactive();
                controller.DoWindowUnload();
                controller.DoDeinit(() => { if (callback != null)
                                            {
                                                callback();
                                            }
                                    });

                sendCallback = false;

                break;
            }

            if (sendCallback == true && callback != null)
            {
                callback();
            }
        }
Exemple #13
0
        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate a new component manualy but wants window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public virtual void RegisterSubComponent(WindowObjectElement subComponent)
        {
            //Debug.Log("TRY REGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState(), this);
            if (this.subComponents.Contains(subComponent) == false)
            {
                subComponent.rootComponent = this;
                this.subComponents.Add(subComponent);
            }
            else
            {
                WindowSystemLogger.Warning(this, "RegisterSubComponent can't complete because of duplicate item.");
                return;
            }

                        #if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                return;
            }
                        #endif

            var controller = (subComponent as IWindowEventsController);
            subComponent.DoLoad(async: false, onItem: null, callback: () => {
                switch (this.GetComponentState())
                {
                case WindowObjectState.Hiding:

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    subComponent.SetComponentState(this.GetComponentState());

                    break;

                case WindowObjectState.Hidden:

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    subComponent.SetComponentState(this.GetComponentState());

                    break;

                case WindowObjectState.Initializing:
                case WindowObjectState.Initialized:

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    break;

                case WindowObjectState.Showing:

                    // after OnShowBegin

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    if (subComponent.showOnStart == true)
                    {
                        controller.DoShowBegin(AppearanceParameters.Default());
                    }

                    break;

                case WindowObjectState.Shown:

                    // after OnShowEnd

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    if (subComponent.showOnStart == true)
                    {
                        controller.DoShowBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                            controller.DoShowEnd(AppearanceParameters.Default());
                        }));
                    }

                    break;
                }

                if (this.GetWindow() != null)
                {
                    subComponent.Setup(this.GetWindow());
                    // subComponent.Setup(this.GetLayoutRoot());
                }
            });
        }
        /// <summary>
        /// Unregisters the sub component.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
		public void UnregisterSubComponent(WindowObjectElement subComponent) {

			switch (this.GetComponentState()) {

                case WindowObjectState.Shown:
                    // after OnShowEnd
                    subComponent.OnHideBegin(() => {

                        subComponent.OnHideEnd();
                        subComponent.OnDeinit();

                    });
                    break;

                case WindowObjectState.Hiding:
                    // after OnHideBegin
                    subComponent.OnHideBegin(null);
                    break;

                case WindowObjectState.Hidden:
                    // after OnHideEnd
                    subComponent.OnHideBegin(() => {

                        subComponent.OnHideEnd();
                        subComponent.OnDeinit();

                    });
                    break;

            }

            this.subComponents.Remove(subComponent);

        }
        /*public virtual void DeactivateComponents() {

			for (int i = 0; i < this.subComponents.Count; ++i) this.subComponents[i].DeactivateComponents();

            if (this == null) return;
            this.gameObject.SetActive(false);

        }*/

        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate new component manualy but wants the window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
		public virtual void RegisterSubComponent(WindowObjectElement subComponent) {

			switch (this.GetComponentState()) {
				
				case WindowObjectState.Initializing:
				case WindowObjectState.Initialized:
                    // after OnInit
                    subComponent.OnInit();
                    break;

                case WindowObjectState.Showing:
                    // after OnShowBegin
                    subComponent.OnInit();
                    subComponent.OnShowBegin(null);
                    break;

                case WindowObjectState.Shown:
                    // after OnShowEnd
                    subComponent.OnInit();
                    subComponent.OnShowBegin(() => {

                        subComponent.OnShowEnd();

                    });
                    break;

            }
			
			if (this.GetWindow() != null) {

                subComponent.Setup(this.GetWindow());
                // subComponent.Setup(this.GetLayoutRoot());

            }

            if (this.subComponents.Contains(subComponent) == false) this.subComponents.Add(subComponent);

        }
        /// <summary>
        /// Unregisters the sub component.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
		public void UnregisterSubComponent(WindowObjectElement subComponent, System.Action callback = null) {

#if UNITY_EDITOR
			if (Application.isPlaying == false) return;
#endif

			var sendCallback = true;

			//Debug.Log("UNREGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState());
			
			this.subComponents.Remove(subComponent);

			switch (this.GetComponentState()) {

                case WindowObjectState.Shown:

                    // after OnShowEnd
                    subComponent.OnHideBegin(() => {

                        subComponent.OnHideEnd();
                        subComponent.OnDeinit();

						if (callback != null) callback();

                    });

					sendCallback = false;

                    break;

                case WindowObjectState.Hiding:

                    // after OnHideBegin
                    subComponent.OnHideBegin(null);

					sendCallback = false;
					if (callback != null) callback();

                    break;

                case WindowObjectState.Hidden:

                    // after OnHideEnd
                    subComponent.OnHideBegin(() => {

                        subComponent.OnHideEnd();
                        subComponent.OnDeinit();
						
						if (callback != null) callback();

					});

					sendCallback = false;

                    break;

            }

			if (sendCallback == true && callback != null) callback();

        }
        /*public virtual void DeactivateComponents() {

			for (int i = 0; i < this.subComponents.Count; ++i) this.subComponents[i].DeactivateComponents();

            if (this == null) return;
            this.gameObject.SetActive(false);

        }*/

        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate a new component manualy but wants window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
		public virtual void RegisterSubComponent(WindowObjectElement subComponent) {

			//Debug.Log("REGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState());
			switch (this.GetComponentState()) {
				
				case WindowObjectState.Hiding:
					
					if (subComponent.GetComponentState() == WindowObjectState.NotInitialized) {
						
						subComponent.OnInit();
						
					}

					subComponent.SetComponentState(this.GetComponentState());

					break;

				case WindowObjectState.Hidden:
					
					if (subComponent.GetComponentState() == WindowObjectState.NotInitialized) {
						
						subComponent.OnInit();
						
					}

					subComponent.SetComponentState(this.GetComponentState());

					break;

				case WindowObjectState.Initializing:
				case WindowObjectState.Initialized:
					
					if (subComponent.GetComponentState() == WindowObjectState.NotInitialized) {
						
						subComponent.OnInit();
						
					}

	                break;

                case WindowObjectState.Showing:
                    
					// after OnShowBegin
					
					if (subComponent.GetComponentState() == WindowObjectState.NotInitialized) {
						
						subComponent.OnInit();
						
					}

					if (subComponent.showOnStart == true) {

	                    subComponent.OnShowBegin(null);

					}

                    break;

                case WindowObjectState.Shown:

                    // after OnShowEnd
					
					if (subComponent.GetComponentState() == WindowObjectState.NotInitialized) {
						
						subComponent.OnInit();
						
					}

					if (subComponent.showOnStart == true) {

	                    subComponent.OnShowBegin(() => {

	                        subComponent.OnShowEnd();

	                    });

					}

                    break;

            }
			
			if (this.GetWindow() != null) {

                subComponent.Setup(this.GetWindow());
                // subComponent.Setup(this.GetLayoutRoot());

            }

            if (this.subComponents.Contains(subComponent) == false) this.subComponents.Add(subComponent);

        }
Exemple #18
0
        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate a new component manualy but wants window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public virtual void RegisterSubComponent(WindowObjectElement subComponent)
        {
            //Debug.Log("TRY REGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState(), this);
            if (this.subComponents.Contains(subComponent) == false)
            {
                this.subComponents.Add(subComponent);
            }
            else
            {
                WindowSystemLogger.Warning(this, "RegisterSubComponent can't complete because of duplicate item.");
                return;
            }

            switch (this.GetComponentState())
            {
            case WindowObjectState.Hiding:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                subComponent.SetComponentState(this.GetComponentState());

                break;

            case WindowObjectState.Hidden:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                subComponent.SetComponentState(this.GetComponentState());

                break;

            case WindowObjectState.Initializing:
            case WindowObjectState.Initialized:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                break;

            case WindowObjectState.Showing:

                // after OnShowBegin

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                if (subComponent.showOnStart == true)
                {
                    subComponent.DoShowBegin(AppearanceParameters.Default());
                }

                break;

            case WindowObjectState.Shown:

                // after OnShowEnd

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                if (subComponent.showOnStart == true)
                {
                    subComponent.DoShowBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                        subComponent.DoShowEnd(AppearanceParameters.Default());
                    }));
                }

                break;
            }

            if (this.GetWindow() != null)
            {
                subComponent.Setup(this.GetWindow());
                // subComponent.Setup(this.GetLayoutRoot());
            }
        }
Exemple #19
0
        /// <summary>
        /// Unregisters the sub component.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public void UnregisterSubComponent(WindowObjectElement subComponent, System.Action callback = null)
        {
#if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                return;
            }
#endif

            var sendCallback = true;

            //Debug.Log("UNREGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState());

            this.subComponents.Remove(subComponent);

            switch (this.GetComponentState())
            {
            case WindowObjectState.Shown:

                // after OnShowEnd
                subComponent.DoHideBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                    subComponent.DoHideEnd(AppearanceParameters.Default());
                    subComponent.DoDeinit();

                    if (callback != null)
                    {
                        callback();
                    }
                }));

                sendCallback = false;

                break;

            case WindowObjectState.Hiding:

                // after OnHideBegin
                subComponent.DoHideBegin(AppearanceParameters.Default());

                sendCallback = false;
                if (callback != null)
                {
                    callback();
                }

                break;

            case WindowObjectState.Hidden:

                // after OnHideEnd
                subComponent.DoHideBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                    subComponent.DoHideEnd(AppearanceParameters.Default());
                    subComponent.DoDeinit();

                    if (callback != null)
                    {
                        callback();
                    }
                }));

                sendCallback = false;

                break;
            }

            if (sendCallback == true && callback != null)
            {
                callback();
            }
        }