Esempio n. 1
0
        public static Popup Open(string name,
                                 Params p,
                                 OnResultCallback resultCallback = null,
                                 OnLoadedCallback loadedCallback = null,
                                 Popup externalPrefab            = null)
        {
            Popup pop = Popup.Load(name, p.foremost, externalPrefab);

            if (null != pop)
            {
                pop.Open(p, resultCallback, loadedCallback);
                return(pop);
            }
            else
            {
                if (Popup.testMode)
                {
                    if (null != loadedCallback)
                    {
                        loadedCallback(null);
                    }
                }

                if (null != resultCallback)
                {
                    resultCallback(new Popup.Result {
                        pop = pop, isOk = Popup.testMode ? true : false,
                    });
                }
            }
            return(null);
        }
Esempio n. 2
0
 public bool Execute(OnLoadedCallback callback = null)
 {
     if (this._executing)
     {
         return(false);
     }
     this._call_back = callback;
     this._executing = true;
     this.InnerExecute();
     return(true);
 }
Esempio n. 3
0
        private void HandleUserLoaded(object sender, EventArgs e)
        {
            IsLoading = false;
            mainThread.Enqueue(() => OnLoadedCallback?.Invoke());

            if (AutoPlayAfterLoaded && !loadingAfterPlay)
            {
                Play();
            }
            loadingAfterPlay = false;
        }
Esempio n. 4
0
        public void LoadSync(OnLoadedCallback onLoadedCallback)
        {
            _random = new Random(DateTime.Now.Millisecond);
            string[] lines = Regex.Split(file.text, "[\r\n]+");
            foreach (string word in lines)
            {
                AddCountWordLength(word);
                AddGetFirstLetter(word);
                AddQwerty5Word(word);
            }

            onLoadedCallback?.Invoke();
        }
Esempio n. 5
0
        public void Open(Params p,
                         OnResultCallback resultCallback = null,
                         OnLoadedCallback loadedCallback = null)
        {
#if LOG_DEBUG
            Debug.Log("POPUP_OPEN:" + this.name + ", IS OPENED:" + this.IsOpened + ", POPUP_OPEN_COUNT:" + Popup.OpenCount + ", FOCUS:" + Popup.Focused + ", LAST_ORDER:" + Popup.lastOrder);
#endif// LOG_DEBUG

            if (this.IsOpened)
            {
                this.Close();
            }

            this.isOpened       = true;
            this.resultCallback = resultCallback;
            this.gameObject.SetActive(false);
            this.gameObject.SetActive(true);
            this.SetShow(true);
            this.keepParam = p;
            this.order     = Popup.lastOrder++;

            this.Managed = p.managed || this.forceManaged;

            if (this.isStarted)
            {
                if (p.directBuild || this.isRecycled)
                {
                    if (!this.Build())
                    {
                        Debug.LogError(string.Format("POPUP:OPEN_FAILED:{0}", this.name));
                        return;
                    }
                }

                this.loadedCallback = null;
                if (null != loadedCallback)
                {
                    loadedCallback(this);
                }
            }
            else
            {
                this.loadedCallback = loadedCallback;
            }


            if (null != Popup.onOpenedListener)
            {
                Popup.onOpenedListener(this);
            }
        }
Esempio n. 6
0
        void Start()
        {
            this.isStarted = true;
            this.OnStart();

            if (!this.isBuildDone)
            {
                if (!this.Build())
                {
                    return;
                }
            }

            var loadedCallback = this.loadedCallback;

            this.loadedCallback = null;

            if (null != loadedCallback)
            {
                loadedCallback(this);
            }
        }
Esempio n. 7
0
        public void Close()
        {
            if (!this.IsOpened)
            {
                return;
            }

            --Popup.lastOrder;

#if LOG_DEBUG
            Debug.Log("POPUP_CLOSE:" + this.name + ", OPEN_COUNT:" + Popup.OpenCount + ", FOCUS:" + Popup.Focused + ", LAST_ORDER:" + Popup.lastOrder);
#endif// LOG_DEBUG

            if (0 > Popup.lastOrder)
            {
#if LOG_DEBUG
                Debug.LogWarning("POPUP_INVALID_LAST_ORDER:" + Popup.lastOrder);
#endif// LOG_DEBUG
                Popup.lastOrder = 0;
            }

            this.isOpened    = false;
            this.isBuildDone = false;

            var p = this.keepParam;
            if (null == p || !p.keepDestroy)
            {
                this.gameObject.SetActive(false);
            }

            this.loadedCallback = null;

            // NOTE: memory managing
            var resultCallback = this.resultCallback;
            this.resultCallback = null;

            var ret = this.CreateResult();
            this.SetupResult(ret);

            var hideScene = this.keepParam.hideScene || this.forceHideScene;
            var solo      = this.keepParam.solo || this.forceSolo;

            this.OnClose();
            Popup.Unregist(this);
            if (null != Popup.onClosedListener)
            {
                Popup.onClosedListener(this);
            }

            var node = Popup.opened.First;
            while (null != node)
            {
                var pop = node.Value;
                node = node.Next;

                if (solo)
                {
                    if (pop.order < this.order)
                    {
                        pop.ShowWithCount(true);
                    }
                }

                if (pop.order >= this.order)
                {
                    --pop.order;
                }
            }

            if (hideScene)
            {
                Present.Show();
            }

            if (null != resultCallback)
            {
                resultCallback(ret);
            }
        }