コード例 #1
0
    private void UpdateCountDown()
    {
        this.countDownLeft -= Time.deltaTime;

        if (this.countDownLeft > 0)
        {
            Text countdownText = this.modalTextObj.GetComponent <Text>();

            int countDown = (int)Mathf.Ceil(this.countDownLeft);

            if (countDown == 4)
            {
                countdownText.text = READY_TEXT;
            }
            else
            {
                countdownText.text = Mathf.Ceil(this.countDownLeft).ToString();
            }
        }
        else
        {
            this.newState = ModalState.NoState;
            this.state    = ModalState.NoState;
            this.NoState();
            CountDownComplete?.Invoke(this.state);
        }
    }
コード例 #2
0
ファイル: ModalUIModel.cs プロジェクト: 6a/robot-rumble
 private void SetState(ModalState state)
 {
     if (_modalState != state)
     {
         _modalState = state;
         EventDispatcher.Broadcast(ModalStateChange, _modalState);
     }
 }
コード例 #3
0
 public void GoToPreviousModalState()
 {
     if (HasPreviousModalState)
     {
         CurrentModalState = _previousStates.Pop();
         ModalStateChanged();
     }
 }
コード例 #4
0
        internal async System.Threading.Tasks.Task DownloadPlaylistAsync()
        {
            IAnnotatedBeatmapLevelCollection selectedPlaylist = annotatedBeatmapLevelCollectionsViewController.selectedAnnotatedBeatmapLevelCollection;
            List <IPlaylistSong>             missingSongs;

            if (selectedPlaylist is BlistPlaylist)
            {
                missingSongs = ((BlistPlaylist)selectedPlaylist).Where(s => s.PreviewBeatmapLevel == null).Select(s => s).ToList();
            }
            else if (selectedPlaylist is LegacyPlaylist)
            {
                missingSongs = ((LegacyPlaylist)selectedPlaylist).Where(s => s.PreviewBeatmapLevel == null).Select(s => s).ToList();
            }
            else
            {
                modalMessage.text = "Error: The selected playlist cannot be downloaded.";
                modalState        = ModalState.OkModal;
                modal.Show(true);
                return;
            }
            modalMessage.text = string.Format("{0}/{1} songs downloaded", 0, missingSongs.Count);
            modalState        = ModalState.DownloadingModal;
            modal.Show(true);
            tokenSource.Dispose();
            tokenSource = new CancellationTokenSource();
            for (int i = 0; i < missingSongs.Count; i++)
            {
                try
                {
                    if (!string.IsNullOrEmpty(missingSongs[i].Key))
                    {
                        await DownloaderUtils.instance.BeatmapDownloadByKey(missingSongs[i].Key, tokenSource.Token);
                    }
                    else if (!string.IsNullOrEmpty(missingSongs[i].Hash))
                    {
                        await DownloaderUtils.instance.BeatmapDownloadByHash(missingSongs[i].Hash, tokenSource.Token);
                    }
                    modalMessage.text = string.Format("{0}/{1} songs downloaded", i + 1, missingSongs.Count);
                }
                catch (Exception e)
                {
                    if (e is TaskCanceledException)
                    {
                        Plugin.Log.Warn("Song Download Aborted.");
                    }
                    else
                    {
                        Plugin.Log.Critical("Failed to download Song!");
                    }
                    break;
                }
            }
            modal.Hide(true);
            SongCore.Loader.Instance.RefreshSongs(false);
            downloadingBeatmapCollectionIdx = annotatedBeatmapLevelCollectionsViewController.selectedItemIndex;
            LevelFilteringNavigationController_UpdateSecondChildControllerContent.SecondChildControllerUpdatedEvent += LevelFilteringNavigationController_UpdateSecondChildControllerContent_SecondChildControllerUpdatedEvent;
        }
コード例 #5
0
 public void SetModalState(ModalState modalState)
 {
     if (CurrentModalState == modalState)
     {
         return;
     }
     _previousStates.Push(CurrentModalState);
     CurrentModalState = modalState;
     ModalStateChanged();
 }
コード例 #6
0
    private void Awake()
    {
        RestaurantManager.ModalEvent += RecieveModalEvent;
        CalendarUI.ModalNotification += RecieveModalEvent;

        buttonOne.GetComponent <Button>().onClick.AddListener(ButtonOneListener);
        buttonTwo.GetComponent <Button>().onClick.AddListener(ButtonTwoListener);

        this.state    = ModalState.NoState;
        this.newState = ModalState.NoState;
        this.NoState();
    }
コード例 #7
0
 internal void DeletePlaylist()
 {
     if (PlaylistLibUtils.playlistManager.DeletePlaylist((BeatSaberPlaylistsLib.Types.IPlaylist)annotatedBeatmapLevelCollectionsViewController.selectedAnnotatedBeatmapLevelCollection))
     {
         SelectAnnotatedBeatmapCollectionByIdx(annotatedBeatmapLevelCollectionsViewController.selectedItemIndex - 1);
     }
     else
     {
         modalMessage.text = "Error: Playlist cannot be deleted.";
         CurrentModalState = ModalState.OkModal;
         modal.Show(true);
     }
 }
コード例 #8
0
        private void NewSession(object sender, RoutedEventArgs e)
        {
            ModalState ms;

            EvaluationModal.DataContext = ms = new ModalState((Athlete)AthleteContent.DataContext);

            // Scroll the modal
            (EvaluationModal.Content as ScrollViewer)?.ScrollToTop();

            // clean the current body points
            UpdateBodyView(ms, 0);
            SessionModal.IsOpen = true;
        }
コード例 #9
0
        private void OpenSession(object sender, RoutedEventArgs e)
        {
            var session    = (EvaluationSession)((Control)sender).DataContext;
            var evaluation = session.GetMedicalEvaluation();

            ModalState ms;

            EvaluationModal.DataContext = ms = new ModalState((Athlete)AthleteContent.DataContext, evaluation, session);

            // Scroll the modal
            (EvaluationModal.Content as ScrollViewer)?.ScrollToTop();

            // make the initial body points visible
            UpdateBodyView(ms, 0);
            SessionModal.IsOpen = true;
        }
コード例 #10
0
ファイル: UIManager.cs プロジェクト: dgl6789/CGD2019
        void DoModalTeardown(ModalState modal)
        {
            // Clean up the modal before closing it.
            switch (modal)
            {
            case ModalState.INVENTORY:
                SetInventoryButtonImage(false);
                break;

            case ModalState.SHOP:
                if (ModalIsOpen(ModalState.INVENTORY))
                {
                    CloseModal((int)ModalState.INVENTORY);
                }
                break;
            }
        }
コード例 #11
0
    // Update is called once per frame
    void Update()
    {
        if (this.state != this.newState)
        {
            this.state = this.newState;
            switch (this.state)
            {
            case ModalState.NoState:
                this.NoState();
                break;

            case ModalState.Loading:
                this.Loading();
                break;

            case ModalState.CountDown:
                this.CountDown();
                break;

            case ModalState.EndDay:
                this.EndGame();
                break;

            case ModalState.DaySelect:
                this.DaySelect();
                break;

            case ModalState.GameOver:
                this.GameOver();
                break;
            }
        }

        if (this.state == ModalState.CountDown)
        {
            this.UpdateCountDown();
        }

        if (this.state == ModalState.GameOver)
        {
            this.UpdateGameOver();
        }
    }
コード例 #12
0
ファイル: UIManager.cs プロジェクト: dgl6789/CGD2019
        void DoModalSetup(ModalState modal)
        {
            // Setup the modal before opening it.
            switch (modal)
            {
            case ModalState.INVENTORY:
                SetInventoryButtonImage(true);
                LoadInventoryToInventoryModal(InventoryType.PLAYER);
                ResetInventoryPanelText();
                break;

            case ModalState.SHOP:
                LoadInventoryToInventoryModal(InventoryType.SHOP);
                if (!ModalIsOpen(ModalState.INVENTORY))
                {
                    OpenModal(ModalState.INVENTORY);
                }
                break;
            }
        }
コード例 #13
0
        private void UpdateBodyView(ModalState ms, int newIdx)
        {
            var bc = BodyChartCanvas;

            ms.ActiveViewIdx = newIdx;
            var newActiveView = ms.ActiveView;

            BodyChartMarkPopup.IsPopupOpen = false;

            // Clear the canvas
            bc.Children.RemoveRange(1, int.MaxValue);
            // Add values (if they exist)
            foreach (var m in ms.Marks)
            {
                if (m.ViewId == newActiveView.Id)
                {
                    BodyChartMark.DrawMark(bc, m, BodyChartClick);
                }
            }

            // Make it visible now
            BodyChart.DataContext = newActiveView;
        }
コード例 #14
0
 /**** Events ****/
 private void RecieveModalEvent(ModalState state, string displayString)
 {
     this.SetState(state, displayString);
 }
コード例 #15
0
        internal async Task SyncPlaylistAsync()
        {
            var selectedBeatmapLevelCollection = annotatedBeatmapLevelCollectionsViewController.selectedAnnotatedBeatmapLevelCollection;

            if (!(selectedBeatmapLevelCollection is Playlist))
            {
                modalMessage.text = "Error: The selected playlist cannot be synced";
                CurrentModalState = ModalState.OkModal;
                modal.Show(true);
                return;
            }
            var selectedPlaylist = (Playlist)selectedBeatmapLevelCollection;

            if (selectedPlaylist.CustomData == null || !selectedPlaylist.CustomData.ContainsKey("syncURL"))
            {
                modalMessage.text = "Error: The selected playlist cannot be synced";
                CurrentModalState = ModalState.OkModal;
                modal.Show(true);
                return;
            }

            string path    = Path.Combine(PlaylistLibUtils.playlistManager.PlaylistPath, selectedPlaylist.Filename + '.' + selectedPlaylist.SuggestedExtension);
            string syncURL = (string)selectedPlaylist.CustomData["syncURL"];

            tokenSource.Dispose();
            tokenSource = new CancellationTokenSource();

            modalMessage.text = "Syncing Playlist";
            CurrentModalState = ModalState.DownloadingModal;
            modal.Show(true);

            Stream playlistStream = null;

            try
            {
                playlistStream = new MemoryStream(await DownloaderUtils.instance.DownloadFileToBytesAsync(syncURL, tokenSource.Token));
                modal.Show(false);
                ((BeatSaberPlaylistsLib.Types.IPlaylist)selectedPlaylist).RemoveAll((playlistSong) => true); // Clear all songs
                PlaylistLibUtils.playlistManager.DefaultHandler.Populate(playlistStream, (BeatSaberPlaylistsLib.Types.IPlaylist)selectedPlaylist);
            }
            catch (Exception e)
            {
                modal.Show(false);
                if (!(e is TaskCanceledException))
                {
                    modalMessage.text = "Error: The selected playlist cannot be synced";
                    CurrentModalState = ModalState.OkModal;
                    modal.Show(true);
                }
                return;
            }
            finally
            {
                // If the downloaded playlist doesn't have the sync url, add it back
                if (selectedPlaylist.CustomData == null)
                {
                    selectedPlaylist.CustomData = new Dictionary <string, object>();
                }
                if (!selectedPlaylist.CustomData.ContainsKey("syncURL"))
                {
                    selectedPlaylist.CustomData["syncURL"] = syncURL;
                }

                PlaylistLibUtils.playlistManager.StorePlaylist((BeatSaberPlaylistsLib.Types.IPlaylist)selectedPlaylist);
                await DownloadPlaylistAsync();

                modalMessage.text = "Playlist Synced";
                CurrentModalState = ModalState.OkModal;
                modal.Show(true);
            }
        }
コード例 #16
0
ファイル: UIManager.cs プロジェクト: dgl6789/CGD2019
 /// <summary>
 /// Open a modal by ModalState.
 /// </summary>
 /// <param name="modal">Modal to open.</param>
 public void OpenModal(ModalState modal)
 {
     OpenModal((int)modal);
 }
コード例 #17
0
        private void OnModalStateChange(ModalState state)
        {
            if (_state != state)
            {
                _state = state;

                switch (_state)
                {
                case ModalState.Hidden:
                {
                    Properties.Wrapper.SetActive(false);
                    Properties.MessageText.text = string.Empty;
                    Properties.MessageText.gameObject.SetActive(true);
                    Properties.Logo.gameObject.SetActive(false);
                    Properties.Spinner.gameObject.SetActive(false);
                    Properties.ReadyButton.gameObject.SetActive(false);
                    Properties.PlayButton.gameObject.SetActive(false);
                    Properties.LeaderboardsButton.gameObject.SetActive(false);
                    Properties.Countdown.gameObject.SetActive(false);
                    Properties.ReadyButton.interactable        = false;
                    Properties.PlayButton.interactable         = false;
                    Properties.LeaderboardsButton.interactable = false;
                    break;
                }

                case ModalState.Lobby:
                {
                    Properties.Wrapper.SetActive(true);
                    Properties.MessageText.text = string.Empty;
                    Properties.MessageText.gameObject.SetActive(false);
                    Properties.Logo.gameObject.SetActive(true);
                    Properties.Spinner.gameObject.SetActive(false);
                    Properties.ReadyButton.gameObject.SetActive(false);
                    Properties.PlayButton.gameObject.SetActive(true);
                    Properties.LeaderboardsButton.gameObject.SetActive(true);
                    Properties.Countdown.gameObject.SetActive(false);
                    Properties.ReadyButton.interactable        = true;
                    Properties.PlayButton.interactable         = true;
                    Properties.LeaderboardsButton.interactable = true;
                    break;
                }

                case ModalState.ConnectingToServer:
                {
                    Properties.Wrapper.SetActive(true);
                    Properties.MessageText.text = "Connecting to Server";
                    Properties.MessageText.gameObject.SetActive(true);
                    Properties.Logo.gameObject.SetActive(false);
                    Properties.Spinner.gameObject.SetActive(true);
                    Properties.ReadyButton.gameObject.SetActive(false);
                    Properties.PlayButton.gameObject.SetActive(false);
                    Properties.LeaderboardsButton.gameObject.SetActive(false);
                    Properties.Countdown.gameObject.SetActive(false);
                    Properties.ReadyButton.interactable        = false;
                    Properties.PlayButton.interactable         = false;
                    Properties.LeaderboardsButton.interactable = false;
                    break;
                }

                case ModalState.SearchingForGame:
                {
                    Properties.Wrapper.SetActive(true);
                    Properties.MessageText.text = "Searching for Game";
                    Properties.MessageText.gameObject.SetActive(true);
                    Properties.Logo.gameObject.SetActive(false);
                    Properties.Spinner.gameObject.SetActive(true);
                    Properties.ReadyButton.gameObject.SetActive(false);
                    Properties.PlayButton.gameObject.SetActive(false);
                    Properties.LeaderboardsButton.gameObject.SetActive(false);
                    Properties.Countdown.gameObject.SetActive(false);
                    Properties.ReadyButton.interactable        = false;
                    Properties.PlayButton.interactable         = false;
                    Properties.LeaderboardsButton.interactable = false;
                    break;
                }

                case ModalState.WaitingForPlayers:
                {
                    Properties.Wrapper.SetActive(true);
                    Properties.MessageText.text = "Waiting for players";
                    Properties.MessageText.gameObject.SetActive(true);
                    Properties.Logo.gameObject.SetActive(false);
                    Properties.Spinner.gameObject.SetActive(true);
                    Properties.ReadyButton.gameObject.SetActive(false);
                    Properties.PlayButton.gameObject.SetActive(false);
                    Properties.LeaderboardsButton.gameObject.SetActive(false);
                    Properties.Countdown.gameObject.SetActive(false);
                    Properties.ReadyButton.interactable        = false;
                    Properties.PlayButton.interactable         = false;
                    Properties.LeaderboardsButton.interactable = false;
                    break;
                }

                case ModalState.ReadyCheck:
                {
                    Properties.Wrapper.SetActive(true);
                    Properties.MessageText.text = "Ready?";
                    Properties.MessageText.gameObject.SetActive(true);
                    Properties.Logo.gameObject.SetActive(false);
                    Properties.Spinner.gameObject.SetActive(false);
                    Properties.ReadyButton.gameObject.SetActive(true);
                    Properties.PlayButton.gameObject.SetActive(false);
                    Properties.LeaderboardsButton.gameObject.SetActive(false);
                    Properties.Countdown.gameObject.SetActive(true);
                    Properties.ReadyButton.interactable        = true;
                    Properties.PlayButton.interactable         = false;
                    Properties.LeaderboardsButton.interactable = false;

                    if (_countdownCoroutine != null)
                    {
                        StopCoroutine(_countdownCoroutine);
                    }
                    _countdownCoroutine = StartCoroutine(DecrementCountdown(30));

                    break;
                }
                }
            }
        }
コード例 #18
0
ファイル: UIManager.cs プロジェクト: dgl6789/CGD2019
 public bool ModalIsOpen(ModalState modal)
 {
     return(modalAnimators[(int)modal].GetBool("Open"));
 }
コード例 #19
0
 // display string only used to pass endgame scores for now, kept because potentially useful in future
 private void SetState(ModalState state, string displayString)
 {
     this.newState      = state;
     this.displayString = displayString;
 }
コード例 #20
0
ファイル: ModalUIPresenter.cs プロジェクト: 6a/robot-rumble
 private void OnModalStateChange(ModalState state)
 {
     EventDispatcher.Broadcast(ModalStateChange, state);
 }
コード例 #21
0
 public void SetModalState(ModalState modalState)
 {
     _modalStateManager.SetModalState(modalState);
 }
コード例 #22
0
 private void SetModalsStates()
 {
     modalState = new ModalState(this, _sequenceMachine, modalUIScreen);
     congratulationModalState = new CongratulationModalState(this, _sequenceMachine, congratulationModalUIScreen);
 }