private void LateUpdate()
        {
            if (nextLoads.Count > 0 || runningLoadOp != null)
            {
                return;
            }

            var stack = popupStack.Count > 0 ? popupStack : screenStack.Count > 0 ? screenStack : null;

            if (stack == null)
            {
                return;
            }

            var SKM = stack.Peek();

            ScreenMeta SM = null;

            screens.TryGetValue(SKM.name, out SM);

            if (SM == null || SM.screen == null)
            {
                return;
            }

            SM.screen.OnUniqueUpdate();

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                SM.screen.OnBackPressed();
            }
        }
            private void LoadScreen()
            {
                ScreenMeta SM = null;

                if (director.screens.TryGetValue(SLD.sceneName, out SM))
                {
                    loadedScreen = SM.screen;

                    director.AddScreen(loadedScreen, SLD.screenType, SLD.cache, SLD.active);

                    SceneLoader.SetOnActive(SM.screen.Name, SLD.onActive);
                    SceneLoader.SetOnDeactive(SM.screen.Name, SLD.onDeactive);

                    FinalizeScreenInit();

                    state = State.Ready;
                }
                else
                {
                    state = State.Waiting;

                    SceneLoader.Load(SLD.sceneName, SLD.additive, (screen) =>
                    {
                        loadedScreen = screen;
                        director.AddScreen(screen, SLD.screenType, SLD.cache, SLD.active);

                        FinalizeScreenInit();

                        state = State.Ready;
                    }, SLD.onActive, SLD.onDeactive);
                }
            }
        /// <summary>
        /// Get a loaded screen by name
        /// </summary>
        private Screen _GetScreenByName(string screenName)
        {
            ScreenMeta SM = null;

            if (screens.TryGetValue(screenName, out SM) == false)
            {
                Debug.LogErrorFormat("Screen \"{0}\" not found!", screenName);
            }

            return(SM.screen);
        }
示例#4
0
    private void OpenScreen(ScreenMeta screenMeta, bool closeCurrent)
    {
        //DebugToScreen.Log( "ScreenManager: OpenScreen() Title: " + screenMeta.title
        //    + " Model: " + screenMeta.modelName + " Screen: " + screenMeta.screen
        //    + " Opening..." );

        // If already open, return
        if (m_Open != null && m_Open == screenMeta && m_Open.screen.isOpen)
        {
            return;
        }

        AScreen screen = screenMeta.screen;

        screen.screenTitle = screenMeta.title;
        screen.modelName   = screenMeta.modelName;

        if (closeCurrent && m_Open != null)
        {
            if (m_Open.remember)
            {
                // Push onto History
                m_ScreenHistory.Push(m_Open);
            }
            m_Open.screen.Close(true);
            // Fire 'Closed' Event
            onEvent(new Event(Event.Type.Closed, m_Open.title));
        }

        // Open the new Screen
#if DEBUG
        //Debug.Log( "ScreenManager: About to Open Screen: " + screen.screenTitle + " isOpen: " + screen.isOpen + " isHidden: " + screen.isHidden );
#endif

        screen.Open();
        m_Open = screenMeta;

#if DEBUG
        //Debug.Log( "ScreenManager: About to Set Controls: " + screen.screenTitle + " isOpen: " + screen.isOpen + " isHidden: " + screen.isHidden );
#endif

        SetControls(screenMeta.controls);

        // Fire 'Opened' Event
        onEvent(new Event(Event.Type.Opened, screenMeta.title));

        Announce();
    }
        private void AddScreen(Screen screen, ScreenType screenType, bool cache, bool active)
        {
            ScreenMeta SM = null;

            if (screens.TryGetValue(screen.Name, out SM))
            {
                SM.cached = cache;
            }
            else
            {
                var content = screenType == ScreenType.Screen ? screenContent : popupContent;

                if (content)
                {
                    screen.transform.SetParent(content, true);
                    screen.transform.localScale = Vector3.one;
                }
                else
                {
                    DontDestroyOnLoad(screen.gameObject);
                }

                screens.Add(screen.Name, new ScreenMeta()
                {
                    screen = screen,
                    cached = cache
                });
            }

            if (!active)
            {
                return;
            }

            Stack <StackMeta> stack = screenType == ScreenType.Screen ? screenStack : popupStack;

            stack.Push(new StackMeta()
            {
                name = screen.Name,
                type = screenType
            });
        }
        private void CloseScreen(string name)
        {
            ScreenMeta SM = null;

            screens.TryGetValue(name, out SM);

            if (SM == null)
            {
                return;
            }

            SM.screen.OnClosing();

            if (SM.cached)
            {
                SM.screen.Deactivate();
            }
            else
            {
                screens.Remove(name);
                SM.screen.Destroy();
            }
        }
示例#7
0
    /// <summary>
    /// Closes the currently open Screen.
    /// Opens previous screen if one exists in History
    ///
    /// Returns true if a screen from History was opened
    /// </summary>
    public void CloseCurrent(out bool wasHistory)
    {
        wasHistory = false;

        if (m_Open != null)
        {
            m_Open.screen.Close(true);
            // Fire 'Closed' Event
            onEvent(new Event(Event.Type.Closed, m_Open.title));

            if (m_ScreenHistory.Count > 0)
            {
                // Pop screen from Stack History
                m_Open = m_ScreenHistory.Pop();
                OpenScreen(m_Open, false);
                wasHistory = true;
            }
            else
            {
                m_Open = null;
                ControlsOff();
            }
        }
    }
示例#8
0
 private void PushHistory(ScreenMeta screen)
 {
     m_ScreenHistory.Push(screen);
 }
示例#9
0
 /// <summary>
 /// 转换器
 /// </summary>
 /// <param name="screen"></param>
 /// <returns></returns>
 protected ScreenMeta Converter(Screen screen, ScreenMeta meta = null)
 {
     if (meta == null)
     {
         meta = new ScreenMeta();
         meta.CreateTime = DateTime.Now;
     }
     meta.Address = screen.Address != null ? screen.Address.Description : string.Empty;
     meta.Code = screen.Code;
     meta.CoordinateType = screen.Address != null && screen.Address.Point != null ? screen.Address.Point.CoordinateType : string.Empty;
     meta.Enabled = screen.Enabled;
     meta.Geohash = screen.Address != null && screen.Address.Point != null ? screen.Address.Point.Geohash : string.Empty;
     meta.Height = screen.Height;
     meta.Latitude = screen.Address != null && screen.Address.Point != null ? screen.Address.Point.Latitude : 0;
     meta.LocationCode = screen.Address != null ? screen.Address.Code : string.Empty;
     meta.LocationName = screen.Address != null ? screen.Address.Name : string.Empty;
     meta.Longitude = screen.Address != null && screen.Address.Point != null ? screen.Address.Point.Longitude : 0;
     meta.Status = screen.Status;
     meta.UpdateTime = DateTime.Now;
     meta.Width = screen.Width;
     return meta;
 }