Exemplo n.º 1
0
        public async Task SetCurrentPageAsync(IScenePage page)
        {
            if (CurrentPage != page)
            {
                if (page == null)
                {
                    await _scheduler.RunAsync(() => { ReleaseCurrentPage(); });
                }
                else
                {
                    await _scheduler.RunAsync(() =>
                    {
                        ReleaseCurrentPage();
                        CurrentPage = _loading;
                        ActivateCurrentPage();
                    });

                    await page.LoadPageAsync(_scheduler, LoadingProgress);

                    await _scheduler.RunAsync(() =>
                    {
                        ReleaseCurrentPage();
                        CurrentPage = page;
                        ActivateCurrentPage();
                    });
                }
            }
        }
Exemplo n.º 2
0
        public async Task ResetTo(IScenePage page)
        {
            lock (_gate)
            {
                _stack.Clear();
                if (page != null)
                {
                    _stack.Push(page);
                }
            }

            await _container.SetCurrentPageAsync(page);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Presents a Page modally.
        /// </summary>
        public async Task PushAsync(IScenePage page)
        {
            lock (_gate)
            {
                if (_stack.Count > 0)
                {
                    if (_stack.Peek() == page)
                    {
                        return;
                    }
                }
                _stack.Push(page);
            }

            await _container.SetCurrentPageAsync(page);
        }
Exemplo n.º 4
0
        protected override async void Start()
        {
            base.Start();

#if DEBUG
            var MonoDebugHud = new MonoDebugHud(this);
            MonoDebugHud.Show();
#endif

            UI.Root.SetDefaultStyle(ResourceCache.GetXmlFile("UI/DefaultStyle.xml"));

            await CurrentPageContainer.SetLoadingPageAsync(new LoadingScenePage(ResourceCache));

            _menuPage = new MenuScenePage(Navigation);
            _gamePage = new GameScenePage(Navigation, _menuPage);
            await Navigation.PushAsync(_gamePage);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Asynchronously removes the top Page from the navigation stack if the page isn't the root page.
        /// </summary>
        public async Task <bool> GoBackAsync()
        {
            IScenePage top = null;

            lock (_gate)
            {
                if (_stack.Count <= 1)
                {
                    return(false);
                }
                _stack.Pop();
                top = _stack.Peek();
            }

            await _container.SetCurrentPageAsync(top);

            return(true);
        }
Exemplo n.º 6
0
        public GameScenePage(NavigationStack navigation, IScenePage menuPage)
        {
            this.navigation = navigation;
            _menuPage       = menuPage;
            CreateSimpleScene(100);
            var zone = Scene.GetOrCreateComponent <Zone>();

            zone.FogColor = new Color(0, 0, 1, 1);
            var box = Scene.CreateChild();

            box.Position = new Vector3(0, 0, 4);
            var boxModel = box.CreateComponent <StaticModel>();

            boxModel.Model      = ResourceCache.GetModel("Models/Box.mdl");
            NextInputSubscriber = new FreeCameraController(CameraNode);

            this.MapTouch(OnTouch, OnTouchMove2, OnTouchComplete, OnTouchCancel2);
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Pops all but the root Page off the navigation stack.
        /// </summary>
        public async Task PopToRootAsync()
        {
            IScenePage top = null;
            IScenePage res = null;

            lock (_gate)
            {
                while (_stack.Count > 1)
                {
                    _stack.Pop();
                }

                if (_stack.Count > 0)
                {
                    top = _stack.Peek();
                }
            }

            await _container.SetCurrentPageAsync(top);
        }
Exemplo n.º 8
0
 private void ReleaseCurrentPage()
 {
     lock (_gate)
     {
         var page = CurrentPage;
         CurrentPage = null;
         if (page == null)
         {
             return;
         }
         if (!_isPaused)
         {
             page.Pause();
         }
         _input.Subscriber = null;
         page.Deactivate();
         _isCurrentPageActive = false;
         PageDeactivated?.Invoke(this, new PageEventArgs(page));
     }
 }
Exemplo n.º 9
0
        /// <summary>
        ///     Asynchronously removes the top Page from the navigation stack.
        /// </summary>
        public async Task <IScenePage> PopAsync()
        {
            IScenePage top = null;
            IScenePage res = null;

            lock (_gate)
            {
                if (_stack.Count > 0)
                {
                    res = _stack.Pop();
                    if (_stack.Count > 0)
                    {
                        top = _stack.Peek();
                    }
                }
            }

            await _container.SetCurrentPageAsync(top);

            return(res);
        }
Exemplo n.º 10
0
 public PageEventArgs(IScenePage page)
 {
     Page = page;
 }
Exemplo n.º 11
0
 public async Task SetLoadingPageAsync(IScenePage loadingScenePage)
 {
     _loading = loadingScenePage;
     await _loading.LoadPageAsync(_scheduler, DummyLoadingProgress.Instance);
 }