Ejemplo n.º 1
0
        public void InitScreenManager(ISceneStarter sceneStarter)
        {
            var screens = GetComponentsInChildren <WScreen>(true);

            // setup the components
            for (int i = 0; i < screens.Length; ++i)
            {
                WScreen screen = screens[i];
                screen.InitScreen(sceneStarter, this);
                // add to the dictionary
                _screens.Add(screen.id, screen);
            }
            // init screen objects
            var screenObjs = GetComponentsInChildren <IScreenObject>(true);

            foreach (IScreenObject so in screenObjs)
            {
                so.InitScreenObject(this);
                _screenObjects.Add(so);
            }
            // start the views afterwards
            foreach (KeyValuePair <string, WScreen> kvp in _screens)
            {
                WScreen view = kvp.Value;
                // show if default, hide immediately otherwise
                if (view.isDefault)
                {
                    ShowView(view, true);
                }
                else
                {
                    view.IsVisible = false;
                }
            }
        }
Ejemplo n.º 2
0
        bool TryShow(WScreen view, bool flag)
        {
            // dont process if the flag is same as the visibility
            if (view.IsVisible == flag)
            {
                return(false);
            }
            // or if the screen is currently transitioning and it's not stackable
            if (IsTransitioning && !isStackable)
            {
                return(false);
            }
            // check whether the view manager is not stackable
            if (!isStackable && flag)
            {
                // hide the last showing
                if (_showings.Count > 0)
                {
                    ShowView(_showings.Last(), false);
                }
            }
            // finally, show time
            ShowView(view, flag);

            return(true);
        }
Ejemplo n.º 3
0
 void ShowView(WScreen screen, bool flag)
 {
     // set visibly on appear
     if (flag)
     {
         OnShowScreen(screen.id, ShowState.WillShow);
     }
     else
     {
         OnHideScreen(screen.id, HideState.WillHide);
     }
     // show the screen
     screen.SetShow(flag, () => {
         // hide on did disappear
         if (!flag)
         {
             OnHideScreen(screen.id, HideState.DidHide);
         }
         else
         {
             OnShowScreen(screen.id, ShowState.DidShow);
         }
     });
     // add the view to the showing list if flag is true
     if (flag)
     {
         _showings.Add(screen);
     }
     else
     {
         _showings.Remove(screen);
     }
 }
Ejemplo n.º 4
0
        public bool SwitchView(string viewId, bool flag)
        {
            if (IsTransitioning)
            {
                return(false);
            }

            WScreen view = null;

            // if the view exists, try showing it
            if (_screens.TryGetValue(viewId, out view))
            {
                return(TryShow(view, flag));
            }

            return(false);
        }