Пример #1
0
        /// <summary>
        /// Requests the screen with data.
        /// </summary>
        /// <param name="screenType">Screen type.</param>
        /// <param name="data">Data.</param>
        public void RequestView(Type screenType, SObject data)
        {
            if (_targetScreen == null || (_targetScreen.GetType() != screenType && !_targetScreen.IsSettingUp))
            {
                GameObject obj = GameObject.Instantiate(Resources.Load(_scaffoldingConfig.ViewPrefabPath(screenType.Name) + screenType.Name)) as GameObject;

                                #if UNITY_4_6 || UNITY_5
                obj.transform.SetParent(_scaffoldingConfig.DetermineParentGameObjectPath().transform);
                                #else
                obj.transform.parent = _scaffoldingConfig.DetermineParentGameObjectPath().transform;
                                #endif
                obj.transform.name = screenType.Name;

                _targetScreen = obj.GetComponent <AbstractView>();

                string s = screenType.Name + "Model";
                Type   t = ScaffoldingConfig.GetType(s);

                if (t != null)
                {
                    AbstractModel model = FindObjectOfType(t) as AbstractModel;
                    if (model != null)
                    {
                        model.RegisterView(_targetScreen);
                    }
                }

                if (_scaffoldingConfig.ScaffoldingEnableAllGameobjects)
                {
                    _targetScreen.gameObject.EnableAllChildren();
                }
                _targetScreen.Setup(this);


                obj.SetActive(false);

                _lastScreen = _currentScreen;

                _targetScreenData = data;

                if (_currentScreen != null)
                {
                    if (_targetScreen.showingType == AbstractView.ShowingTypes.ShowImmediately)
                    {
                        ScreenClose(_currentScreen.GetType());
                        ScreenOpen();
                    }
                    else
                    {
                        ScreenClose(_currentScreen.GetType());
                    }
                }
                else
                {
                    ScreenOpen();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Request to reopen an already open view
        /// </summary>
        /// <param name="screenType">Screen type.</param>
        /// <param name="viewData">View data.</param>
        public void RequestForceReopenView(Type screenType, SObject viewData)
        {
            Type tp = screenType;

            //essentially resetting the view system here.
            //resetting everything back to nothing.
            if (tp == _currentScreen.GetType())
            {
                _lastScreen = _currentScreen;
                ScreenClosedComplete(tp);
            }
            _targetScreen  = null;
            _currentScreen = null;
            RequestView(tp, viewData);
        }
Пример #3
0
        internal void ScreenClosedComplete(Type screenType)
        {
            if (_currentOverlays.ContainsKey(screenType))
            {
                Destroy(_currentOverlays[screenType].gameObject);
                _currentOverlays.Remove(screenType);

                if (_disabledInputsOnView.ContainsKey(_currentScreen.GetType()))
                {
                    List <Type> overlays = _disabledInputsOnView[_currentScreen.GetType()];
                    if (overlays.Contains(screenType))
                    {
                        overlays.Remove(screenType);
                        if (overlays.Count == 0)
                        {
                            _disabledInputsOnView.Remove(_currentScreen.GetType());
                            _currentScreen.EnableAllInputs();
                        }
                    }
                }
            }
            else if (_lastScreen != null && _lastScreen.GetType() == screenType)
            {
                if (_disabledInputsOnView.ContainsKey(_lastScreen.GetType()))
                {
                    _disabledInputsOnView.Remove(_lastScreen.GetType());
                }
                Destroy(_lastScreen.gameObject);
                if (_targetScreen.showingType != AbstractView.ShowingTypes.ShowImmediately)
                {
                    ScreenOpen();
                }
            }
            else if (_currentScreen.GetType() == screenType)
            {
                if (_loadScene)
                {
                    StartLoadingScene();
                }
            }

            Resources.UnloadUnusedAssets();
        }
Пример #4
0
        /// <summary>
        /// Requests the overlay open with data.
        /// </summary>
        /// <param name="overlayType">Overlay type.</param>
        /// <param name="data">Data.</param>
        public void RequestOverlay(Type overlayType, SObject viewData)
        {
            if (!_currentOverlays.ContainsKey(overlayType))
            {
                GameObject obj = GameObject.Instantiate(Resources.Load(_scaffoldingConfig.ViewPrefabPath(overlayType.Name) + overlayType.Name)) as GameObject;

                                #if UNITY_4_6 || UNITY_5
                obj.transform.SetParent(_scaffoldingConfig.DetermineParentGameObjectPath().transform);
                                #else
                obj.transform.parent = _scaffoldingConfig.DetermineParentGameObjectPath().transform;
                                #endif

                obj.transform.name = overlayType.Name;

                string s = overlayType.Name + "Model";
                Type   t = ScaffoldingConfig.GetType(s);

                if (t != null)
                {
                    AbstractModel model = FindObjectOfType(t) as AbstractModel;
                    if (model != null)
                    {
                        model.RegisterView(_targetScreen);
                    }
                }

                _targetOverlay = obj.GetComponent <AbstractView>();

                if (_scaffoldingConfig.ScaffoldingEnableAllGameobjects)
                {
                    _targetOverlay.gameObject.EnableAllChildren();
                }
                _targetOverlay.Setup(this);
                obj.SetActive(false);

                if (viewData != null && viewData.GetBool("Scaffolding:DisableInputsOnOverlay"))
                {
                    if (_disabledInputsOnView.ContainsKey(_currentScreen.GetType()))
                    {
                        _disabledInputsOnView[_currentScreen.GetType()].Add(overlayType);
                    }
                    else
                    {
                        List <Type> overlays = new List <Type>();
                        overlays.Add(overlayType);
                        _disabledInputsOnView.Add(_currentScreen.GetType(), overlays);
                    }
                    _currentScreen.DisableAllInputs();
                }

                _currentOverlays.Add(overlayType, _targetOverlay);
                OverlayOpen(_targetOverlay.GetType(), viewData);
            }
        }
Пример #5
0
        /// <summary>
        /// The startup sequence. Scaffolding starts from here.
        /// </summary>
        public void Init()
        {
            if (DontDestroyThisOnLoad)
            {
                GameObject.DontDestroyOnLoad(gameObject);
            }

            _scaffoldingConfig    = Resources.Load <ScaffoldingConfig>("SCConfig");
            _disabledInputsOnView = new Dictionary <Type, List <Type> >();

            _currentOverlays = new Dictionary <Type, AbstractView>();
            ScaffoldingStartingView sv = _scaffoldingConfig.GetViewDataForScene(Application.loadedLevelName);
            Type t = ScaffoldingConfig.GetType(sv.StartingViewName);

            if (t != null && GameObject.FindObjectOfType <AbstractView>() == null)
            {
                switch (sv.StartingViewType)
                {
                case ViewType.View:
                    RequestView(t);
                    break;

                case ViewType.Overlay:
                    RequestOverlay(t);
                    break;
                }
            }
            else
            {
                AbstractView v = GameObject.FindObjectOfType <AbstractView>();
                if (v != null)
                {
                    Destroy(v.gameObject);
                    RequestView(v.GetType());
                }
                else
                {
                    Debug.LogWarning("Scaffolding -- ViewManager: No views assigned to start with!");
                }
            }
        }
Пример #6
0
        /// <summary>
        /// The startup sequence. Scaffolding starts from here.
        /// </summary>
        public void Init()
        {
            _scaffoldingConfig    = Resources.Load <ScaffoldingConfig>("SCConfig");
            _disabledInputsOnView = new Dictionary <Type, List <Type> >();

            _currentOverlays = new Dictionary <Type, AbstractView>();

            Type t = System.Type.GetType(_scaffoldingConfig.StartingView);

            if (t != null && GameObject.FindObjectOfType <AbstractView>() == null)
            {
                switch (_scaffoldingConfig.StartingViewType)
                {
                case ViewType.View:
                    RequestView(t);
                    break;

                case ViewType.Overlay:
                    RequestOverlay(t);
                    break;
                }
            }
            else
            {
                AbstractView v = GameObject.FindObjectOfType <AbstractView>();
                if (v != null)
                {
                    Destroy(v.gameObject);
                    RequestView(v.GetType());
                }
                else
                {
                    Debug.LogWarning("Scaffolding -- ViewManager: No views assigned to start with!");
                }
            }
        }
Пример #7
0
 /// <summary>
 /// Request a scene using a given loading type.
 /// </summary>
 /// <param name="loadType">Load type.</param>
 /// <param name="sceneName">Scene name.</param>
 public void RequestScene(LoadSceneType loadType, string sceneName)
 {
     if (!_loadScene)
     {
         _requestedSceneName = sceneName;
         _loadScene          = true;
         _loadType           = loadType;
         //only close screens, not overlays
         ScreenClose(_currentScreen.GetType());
     }
 }