Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (!init)
        {
            return;
        }

        // Wait until the scene is fully loaded
        if (!transitionFinished)
        {
            return;
        }

        GameSettingsScreen.Draw();
        Util.TranslateRawImage(ref backgroundImage, Globals.BackgroundOffset);

        float ratio;

        switch (GameState.TransitionState)
        {
        case TransitionState.LeavingLoadScreen:
            ratio = DrawLoadingScreenTransition(false);
            if (ratio >= 1.0f)
            {
                GameState.TransitionState = TransitionState.ScreenActive;
                GameState.GameMode        = Mode.GameSettings;
            }
            break;

        case TransitionState.ScreenActive:
            transitionStartTime = -1;
            break;

        case TransitionState.EnteringLoadingScreen:
            ratio = DrawLoadingScreenTransition(true);
            if (ratio <= 0.0f)
            {
                GameState.TransitionState = TransitionState.SwitchingScreens;
                loadStarted = false;
            }
            break;

        case TransitionState.SwitchingScreens:
            if (!loadStarted)
            {
                Globals.CurrentNoteCollection = new NoteCollection(SongSelection.GetSelectedMetadata());
                Globals.CurrentSongMetadata   = Globals.CurrentNoteCollection.ParseFile();

                Globals.MusicManager.LoadSong(Globals.CurrentSongMetadata.FilePath + Globals.CurrentSongMetadata.SongFilename, Globals.CurrentSongMetadata.BpmEvents);
                Globals.MusicManager.Offset = Globals.CurrentSongMetadata.PlaybackOffset * 1000;

                StartCoroutine(Util.SwitchSceneAsync());
                loadStarted = true;
            }
            break;

        default:
            break;
        }
    }
        protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
        {
            if (firstActivation)
            {
                SetTitle("Qualifier Room", ViewController.AnimationType.None);
                showBackButton = true;

                _playerDataModel             = Resources.FindObjectsOfTypeAll <PlayerDataModel>().First();
                _menuLightsManager           = Resources.FindObjectsOfTypeAll <MenuLightsManager>().First();
                _soloFreePlayFlowCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();
                _campaignFlowCoordinator     = Resources.FindObjectsOfTypeAll <CampaignFlowCoordinator>().First();
                _resultsViewController       = Resources.FindObjectsOfTypeAll <ResultsViewController>().First();
                _scoreLights   = _soloFreePlayFlowCoordinator.GetField <MenuLightsPresetSO>("_resultsClearedLightsPreset");
                _redLights     = _soloFreePlayFlowCoordinator.GetField <MenuLightsPresetSO>("_resultsFailedLightsPreset");
                _defaultLights = _soloFreePlayFlowCoordinator.GetField <MenuLightsPresetSO>("_defaultLightsPreset");

                _songSelection = BeatSaberUI.CreateViewController <SongSelection>();
                _songSelection.SongSelected += songSelection_SongSelected;

                _songDetail              = BeatSaberUI.CreateViewController <SongDetail>();
                _songDetail.PlayPressed += songDetail_didPressPlayButtonEvent;
                _songDetail.DisableCharacteristicControl = true;
                _songDetail.DisableDifficultyControl     = true;
                _songDetail.DisablePlayButton            = false;
            }
            if (addedToHierarchy)
            {
                _songSelection.SetSongs(Event.QualifierMaps.ToList());
                ProvideInitialViewControllers(_songSelection);
            }
        }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        // Load list of songs

        if (SongSelection.Songlist.Count == 0)
        {
            SongSelection.ImportSongs(Defines.SongFolder);
            var meta = SongSelection.Songlist[0];   // 8 is Summery
            Globals.CurrentNoteCollection = new NoteCollection(meta);
            Globals.CurrentSongMetadata   = Globals.CurrentNoteCollection.ParseFile();

            Globals.MusicManager.LoadSong(Globals.CurrentSongMetadata.FilePath + Globals.CurrentSongMetadata.SongFilename, Globals.CurrentSongMetadata.BpmEvents);
            Globals.MusicManager.Offset = Globals.CurrentSongMetadata.PlaybackOffset * 1000;
        }

        GameObject.Find("DifficultyText").SetText(ConfigFile.GetLocalizedString("Sort_Title"));

        loadingLeft  = GameObject.Find("LoadingLeft").GetComponent <RectTransform>();
        loadingRight = GameObject.Find("LoadingRight").GetComponent <RectTransform>();

        // Set sorting order for non-sprites
        GameObject.Find("LeftHold").GetComponent <MeshRenderer>().sortingLayerName   = "LeftHold";
        GameObject.Find("RightHold").GetComponent <MeshRenderer>().sortingLayerName  = "Rightold";
        GameObject.Find("LeftSlide").GetComponent <MeshRenderer>().sortingLayerName  = "LeftHold";
        GameObject.Find("RightSlide").GetComponent <MeshRenderer>().sortingLayerName = "RightHold";
    }
Beispiel #4
0
        // update each song
        public void UpdateSong(SacramentMeetingContext context, Meeting meetingToUpdate,
                               ICollection <SongSelection> songSelection, SongPosition schedule, string songID = null)
        {
            if (songID == null)                         // if songID is null, need to delete song if there is one in songPosition.
            {
                foreach (var item in songSelection)     // check songPosition in songSelections.
                {
                    if (item.Schedule.Equals(schedule)) // if there is a song in songPosition, delete it
                    {
                        SongSelection songToRemove
                            = meetingToUpdate
                              .SongSelections
                              .SingleOrDefault(i => i.SongID == item.SongID && i.Schedule == schedule);
                        context.Remove(songToRemove);
                        songSelection.Remove(songToRemove);
                        return;
                    } // if there is no song, do nothing because it is already empty
                }
            }
            else // if songID is not empty
            {
                int songIDInt = int.Parse(songID); // change songID to int
                int count     = 0;                  // count to see if songPosition is empty
                foreach (var item in songSelection) // check each songSelection in meeting for correct songPosition
                {
                    if (item.Schedule.Equals(schedule))
                    {
                        count++; // there is song in songPosition


                        if (songIDInt != item.SongID)  // if wrong song is in songPosition
                        {
                            SongSelection songToRemove // remove wrong song
                                = meetingToUpdate
                                  .SongSelections
                                  .SingleOrDefault(i => i.SongID == item.SongID && i.Schedule == schedule);
                            context.Remove(songToRemove);
                            songSelection.Remove(songToRemove);

                            meetingToUpdate.SongSelections.Add( // add the correct song
                                new SongSelection
                            {
                                SongID   = songIDInt,
                                Schedule = schedule
                            });
                            return;
                        }
                    }
                }
                if (count == 0) // the song position is empty
                {
                    meetingToUpdate.SongSelections.Add(
                        new SongSelection
                    {
                        SongID   = songIDInt,
                        Schedule = schedule
                    });
                }
            }
        }
Beispiel #5
0
    private void OnSelectedSongChanged(SongSelection songSelection)
    {
        StopSongPreview();

        if (songSelection.SongIndex != 0)
        {
            isFirstSelectedSong = false;
        }

        SongMeta songMeta = songSelection.SongMeta;

        if (songMeta == currentPreviewSongMeta)
        {
            return;
        }

        if (isFirstSelectedSong)
        {
            return;
        }

        if (songMeta != null)
        {
            int previewStartInMillis = GetPreviewStartInMillis(songMeta);
            StartCoroutine(CoroutineUtils.ExecuteAfterDelayInSeconds(previewDelayInSeconds, () => StartSongPreview(songMeta, previewStartInMillis)));
        }
        currentPreviewSongMeta = songMeta;
    }
    // Update is called once per frame
    void Update()
    {
        // Prevent inputs while the game is transitioning between screens
        if (GameState.TransitionState == TransitionState.EnteringLoadingScreen ||
            GameState.TransitionState == TransitionState.LeavingLoadScreen)
        {
            return;
        }

        if (Input.GetButtonDown("Down"))
        {
            SongSelection.ScrollDown();
        }
        else if (Input.GetButtonDown("Up"))
        {
            SongSelection.ScrollUp();
        }
        else if (Input.GetButtonDown("Left"))
        {
            SongSelection.GoBack();
        }
        else if (Input.GetButtonDown("Right"))
        {
            SongSelection.CycleDifficulty();
        }
        else if (Input.GetButtonDown("Auto"))
        {
            switch (GameState.CurrentSettings.AutoSetting)
            {
            case Settings.AutoMode.Off:
                GameState.CurrentSettings.AutoSetting = Settings.AutoMode.Auto;
                break;

            case Settings.AutoMode.Auto:
                GameState.CurrentSettings.AutoSetting = Settings.AutoMode.Off;
                break;

            case Settings.AutoMode.AutoDown:
                break;

            default:
                break;
            }
        }
        else if (Input.GetButtonDown("Select"))
        {
            if (SongSelection.Select())
            {
                GameState.TransitionState = TransitionState.EnteringLoadingScreen;
                GameState.Destination     = Mode.GamePlay;
            }
        }
        else if (Input.GetButtonDown("GameSettings"))
        {
            GameState.TransitionState = TransitionState.EnteringLoadingScreen;
            GameState.Destination     = Mode.GameSettings;
        }
    }
Beispiel #7
0
    private void OnNewSongSelection(SongSelection selection)
    {
        SongMeta selectedSong = selection.SongMeta;

        if (selectedSong == null)
        {
            SetEmptySongDetails();
            return;
        }

        artistText.SetText(selectedSong.Artist);
        songTitleText.text = selectedSong.Title;
        songCountText.text = (selection.SongIndex + 1) + "/" + selection.SongsCount;

        //Display local highscore
        highscoreLocalPlayerText.text = "";
        highscoreLocalScoreText.text  = "0";
        LocalStatistic localStats = statsManager.GetLocalStats(selectedSong);
        SongStatistic  localTopScore;

        if (localStats != null)
        {
            localTopScore = localStats.StatsEntries.TopScore;

            if (localTopScore != null)
            {
                Debug.Log("Found local highscore: " + localTopScore.PlayerName + " " + localTopScore.Score.ToString());
                highscoreLocalPlayerText.text = localTopScore.PlayerName;
                highscoreLocalScoreText.text  = localTopScore.Score.ToString();
            }
        }

        //Display web highscore
        highscoreWebPlayerText.text = "";
        highscoreWebScoreText.text  = "0";
        WebStatistic  webStats = statsManager.GetWebStats(selectedSong);
        SongStatistic webTopScore;

        if (webStats != null)
        {
            webTopScore = webStats.StatsEntries.TopScore;

            if (webTopScore != null)
            {
                Debug.Log("Found web highscore: " + webTopScore.PlayerName + " " + webTopScore.Score.ToString());
                highscoreWebPlayerText.text = webTopScore.PlayerName;
                highscoreWebScoreText.text  = webTopScore.Score.ToString();
            }
        }

        bool hasVideo = !string.IsNullOrEmpty(selectedSong.Video);

        videoIndicator.SetActive(hasVideo);

        bool isDuet = selectedSong.VoiceNames.Count > 1;

        duetIndicator.SetActive(isDuet);
    }
Beispiel #8
0
    // Start is called before the first frame update
    void Start()
    {
        if (!ConfigFile.IsLoaded)
        {
            ConfigFile.Load();
        }

        loadingLeft  = GameObject.Find("LoadingLeft").GetComponent <RectTransform>();
        loadingRight = GameObject.Find("LoadingRight").GetComponent <RectTransform>();

        BgLine.SetColor(ThemeColors.Blue);

        songCards = new List <CardBase>();
        if (SongSelection.Songlist.Count == 0)
        {
            SongSelection.ImportSongs(Defines.SongFolder);
        }
        for (int i = 0; i < SongSelection.Songlist.Count; i++)
        {
            songCards.Add(new SongCard(Pools.SongCards.GetPooledObject(), SongSelection.Songlist[i]));
            songCards[i].Shift(i, SongSelection.CurrentSongIndex);
        }
        levelCards = new List <CardBase>();
        for (int i = 0; i < 10; i++)
        {
            levelCards.Add(new FolderCard(Pools.FolderCards.GetPooledObject(), "LEVEL " + (i + 1)));
        }
        folderCards = new List <CardBase>();
        foreach (var folder in SongSelection.FolderParams)
        {
            folderCards.Add(new FolderCard(Pools.FolderCards.GetPooledObject(), folder.Name));
        }

        // No Songs
        if (SongSelection.Songlist.Count == 0)
        {
            GameState.GameMode = Mode.NoSongs;
            for (int i = 0; i < transform.childCount; i++)
            {
                transform.GetChild(i).gameObject.SetActive(false);
            }
            transform.Find("Bg").gameObject.SetActive(true);
            transform.Find("NoSongs").gameObject.SetActive(true);
        }

        init = true;
    }
Beispiel #9
0
        /// <summary>
        /// Initialize most static objects and dependencies
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Copy, if needed, the required assemblies (BASS) for 32 or 64bit CPUs
            NativeAssemblies.Copy();

            // Initialize the logging tool for troubleshooting
            PulsarcLogger.Initialize();

            // Initialize Discord Rich Presence
            PulsarcDiscord.Initialize();

            // Set the default culture (Font formatting Locals) for this thread
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // Start the thread listening for user input
            InputManager.StartThread();

            // Start our time and frame-time tracker
            PulsarcTime.Start();

            // Initialize FPS
            fpsDisplay = new FPS(Vector2.Zero);

            // Initialize the game camera
            gameCamera = new Camera(Graphics.GraphicsDevice.Viewport, (int)GetDimensions().X, (int)GetDimensions().Y, 1)
            {
                Pos = new Vector2(GetDimensions().X / 2, GetDimensions().Y / 2)
            };

            // Start the song selection in the background to have music when entering the game
            SongScreen = new SongSelection();
            SongScreen.Init();

            // Create and display the default game screen
            // (Currently Main menu. In the future can implement an intro)
            Menu firstScreen = new Menu();

            ScreenManager.AddScreen(firstScreen);

            cursor = new Cursor();

            IsReadyToUpdate = true;
        }
    private void OnSongSelectionChanged(SongSelection selection)
    {
        songRouletteControl.HideSongMenuOverlay();

        SongMeta selectedSong = selection.SongMeta;

        if (selectedSong == null)
        {
            SetEmptySongDetails();
            songIndexLabel.text = "-";
            return;
        }

        genreLabel.text = selectedSong.Genre;
        yearLabel.text  = selectedSong.Year > 0
            ? selectedSong.Year.ToString()
            : "";
        songIndexLabel.text = (selection.SongIndex + 1) + "\nof " + selection.SongsCount;

        // The song duration requires loading the audio file.
        // Loading every song only to show its duration is slow (e.g. when scrolling through songs).
        // Instead, the label is updated when the AudioClip has been loaded.
        durationLabel.text = "";

        bool hasVideo = !string.IsNullOrEmpty(selectedSong.Video);

        videoIndicator.SetVisibleByVisibility(hasVideo);

        bool isDuet = selectedSong.VoiceNames.Count > 1;

        duetIcon.SetVisibleByVisibility(isDuet);

        UpdateFavoriteIcon();

        UpdateSongStatistics(selectedSong);

        if (IsSongDetailOverlayVisible)
        {
            UpdateSongDetailsInOverlay();
        }
    }
    private void OnNewSongSelection(SongSelection selection)
    {
        SongMeta selectedSong = selection.SongMeta;

        if (selectedSong == null)
        {
            SetEmptySongDetails();
            return;
        }

        artistText.SetText(selectedSong.Artist);
        songTitleText.text = selectedSong.Title;
        songCountText.text = (selection.SongIndex + 1) + "/" + selection.SongsCount;

        bool hasVideo = !string.IsNullOrEmpty(selectedSong.Video);

        videoIndicator.SetActive(hasVideo);

        bool isDuet = selectedSong.VoiceNames.Count > 1;

        duetIndicator.SetActive(isDuet);
    }
Beispiel #12
0
    public void StartSongPreview(SongSelection songSelection)
    {
        if (songRouletteControl.IsDrag ||
            songRouletteControl.IsFlickGesture ||
            !gameObject.activeInHierarchy)
        {
            return;
        }

        StopSongPreview();

        if (songSelection.SongIndex != 0)
        {
            isFirstSelectedSong = false;
        }

        SongMeta songMeta = songSelection.SongMeta;

        if (songMeta == currentPreviewSongMeta)
        {
            return;
        }

        if (isFirstSelectedSong)
        {
            return;
        }

        currentPreviewSongMeta  = songMeta;
        currentSongEntryControl = songRouletteControl.SongEntryControls
                                  .FirstOrDefault(it => it.SongMeta == songMeta);
        if (songMeta != null)
        {
            StartCoroutine(CoroutineUtils.ExecuteAfterDelayInSeconds(previewDelayInSeconds, () => DoStartSongPreview(songMeta)));
        }
    }
Beispiel #13
0
 void Start()
 {
     Instance = this;
 }
Beispiel #14
0
    // Update is called once per frame
    void Update()
    {
        if (!init)
        {
            return;
        }

        // Wait until the scene is fully loaded
        if (!transitionFinished)
        {
            return;
        }

        // Always draw cards (this has to happen before the loading screen slides open)
        if (SongSelection.Songlist.Count > 0)
        {
            Util.TranslateRawImage(ref backgroundImage, Globals.BackgroundOffset);
            if (SongSelection.SelectedFolderIndex == -1)
            {
                folderCards.SetActive(true);
                levelCards.SetActive(false);
                songCards.SetActive(false);
                UpdateMetadata(false);
                UpdateLoopedSong(true);

                for (int i = 0; i < folderCards.Count; i++)
                {
                    folderCards[i].Shift(i, SongSelection.CurrentFolderIndex, SongSelectionMovement.IsAnimating(), SongSelectionMovement.AnimationMovement.x, SongSelectionMovement.AnimationMovement.y);
                }
            }
            else
            {
                if (SongSelection.FolderParams[SongSelection.SelectedFolderIndex].Type == SortType.Level && SongSelection.SelectedLevelIndex == -1)
                {
                    folderCards.SetActive(false);
                    levelCards.SetActive(true);
                    songCards.SetActive(false);
                    UpdateMetadata(false);
                    UpdateLoopedSong(true);

                    for (int i = 0; i < levelCards.Count; i++)
                    {
                        levelCards[i].Shift(i, SongSelection.CurrentLevelIndex, SongSelectionMovement.IsAnimating(), SongSelectionMovement.AnimationMovement.x, SongSelectionMovement.AnimationMovement.y);
                    }
                }
                else
                {
                    folderCards.SetActive(false);
                    levelCards.SetActive(false);
                    songCards.SetActive(true);
                    UpdateMetadata(true);
                    UpdateLoopedSong(false);

                    for (int i = 0; i < SongSelection.Songlist.Count; i++)
                    {
                        var card = songCards.FirstOrDefault(x => ((SongCard)x).SongID == SongSelection.Songlist[i].SongID);

                        card.Shift(i, SongSelection.CurrentSongIndex, SongSelectionMovement.IsAnimating(), SongSelectionMovement.AnimationMovement.x, SongSelectionMovement.AnimationMovement.y);
                        int diff = i == SongSelection.CurrentSongIndex ? SongSelection.CurrentSongLevelIndex : -1;
                        ((SongCard)card).SetDifficulty(diff);
                    }
                }
            }
        }

        this.transform.Find("AutoModeText").gameObject.SetActive(GameState.CurrentSettings.AutoSetting != Settings.AutoMode.Off);

        float ratio;

        switch (GameState.TransitionState)
        {
        case TransitionState.LeavingLoadScreen:
            ratio = DrawLoadingScreenTransition(false);
            if (ratio >= 1.0f)
            {
                GameState.TransitionState = TransitionState.ScreenActive;
                GameState.GameMode        = Mode.SongSelect;
            }
            break;

        case TransitionState.ScreenActive:
            transitionStartTime = -1;
            break;

        case TransitionState.EnteringLoadingScreen:
            ratio = DrawLoadingScreenTransition(true);
            if (ratio <= 0.0f)
            {
                GameState.TransitionState = TransitionState.SwitchingScreens;
                loadStarted = false;
            }
            break;

        case TransitionState.SwitchingScreens:
            if (!loadStarted)
            {
                Globals.CurrentNoteCollection = new NoteCollection(SongSelection.GetSelectedMetadata());
                Globals.CurrentSongMetadata   = Globals.CurrentNoteCollection.ParseFile();

                // If music is currently looping, cease it now.
                Globals.MusicManager.EndSongLoop(this);

                Globals.MusicManager.LoadSong(Globals.CurrentSongMetadata.FilePath + Globals.CurrentSongMetadata.SongFilename, Globals.CurrentSongMetadata.BpmEvents);
                Globals.MusicManager.Offset = Globals.CurrentSongMetadata.PlaybackOffset * 1000;

                StartCoroutine(Util.SwitchSceneAsync());
                loadStarted = true;
            }
            break;

        default:
            break;
        }
    }
Beispiel #15
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                //Set up UI
                title          = "Room Screen";
                showBackButton = true;

                _playerDataModel             = Resources.FindObjectsOfTypeAll <PlayerDataModel>().First();
                _menuLightsManager           = Resources.FindObjectsOfTypeAll <MenuLightsManager>().First();
                _soloFreePlayFlowCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();
                _campaignFlowCoordinator     = Resources.FindObjectsOfTypeAll <CampaignFlowCoordinator>().First();
                _resultsViewController       = Resources.FindObjectsOfTypeAll <ResultsViewController>().First();
                _scoreLights   = _soloFreePlayFlowCoordinator.GetField <MenuLightsPresetSO>("_resultsLightsPreset");
                _redLights     = _campaignFlowCoordinator.GetField <MenuLightsPresetSO>("_newObjectiveLightsPreset");
                _defaultLights = _soloFreePlayFlowCoordinator.GetField <MenuLightsPresetSO>("_defaultLightsPreset");

                _songSelection = BeatSaberUI.CreateViewController <SongSelection>();
                _songSelection.SongSelected += songSelection_SongSelected;

                _splashScreen = BeatSaberUI.CreateViewController <SplashScreen>();

                _songDetail              = BeatSaberUI.CreateViewController <SongDetail>();
                _songDetail.PlayPressed += songDetail_didPressPlayButtonEvent;
                _songDetail.DifficultyBeatmapChanged += songDetail_didChangeDifficultyBeatmapEvent;

                _playerList = BeatSaberUI.CreateViewController <PlayerList>();
            }
            if (activationType == ActivationType.AddedToHierarchy)
            {
                tournamentMode = Match == null;
                if (tournamentMode)
                {
                    _splashScreen.StatusText = $"Connecting to \"{Host.Name}\"...";
                    ProvideInitialViewControllers(_splashScreen);
                }
                else
                {
                    //If we're not in tournament mode, then a client connection has already been made
                    //by the room selection screen, so we can just assume Plugin.client isn't null
                    //NOTE: This is *such* a hack. Oh my god.
                    isHost = Match.Leader == Plugin.client.Self;
                    _songSelection.SetSongs(SongUtils.masterLevelList);
                    _playerList.Players      = Match.Players;
                    _splashScreen.StatusText = "Waiting for the host to select a song...";

                    if (isHost)
                    {
                        ProvideInitialViewControllers(_songSelection, _playerList);
                    }
                    else
                    {
                        ProvideInitialViewControllers(_splashScreen, _playerList);
                    }
                }
            }

            //The ancestor sets up the server event listeners
            //It would be possible to recieve an event that does a ui update after this call
            //and before the rest of the ui is set up, if we did this at the top.
            //So, we do it last
            base.DidActivate(firstActivation, activationType);
        }
Beispiel #16
0
 private void Start()
 {
     Instance   = this;
     background = Background.GetComponent <Image>();
 }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                PopulateBishopricSL(_context, Meeting.Calling);
                PopulatePrayersSLI(_context, Meeting);
                PopulateSongsSLI(_context, Meeting);
                Message = "There was an error saving meeting.";
                return(Page());
            }

            Message = ValidateMeetingInput(OpeningSong, ClosingSong, SacramentSong, OpeningPrayer, ClosingPrayer);

            if (Message != "")
            {
                PopulateBishopricSL(_context, Meeting.Calling);
                PopulatePrayersSLI(_context, Meeting);
                PopulateSongsSLI(_context, Meeting);

                return(Page());
            }

            // Validation
            // Meeting date is not unique - "Meeting date already exists."
            if (Meeting != null)
            {
                Message = "";
                var meetings = _context.Meeting;
                foreach (Meeting item in meetings)
                {
                    if (item.MeetingDate == Meeting.MeetingDate)
                    {
                        Message = "A meeting for this date already exists.";


                        PopulateBishopricSL(_context, Meeting.Calling);
                        PopulatePrayersSLI(_context, Meeting);
                        PopulateSongsSLI(_context, Meeting);

                        return(Page());
                    }
                }
            }

            // if songs not null, check if int
            var newMeeting = new Meeting();

            // Add prayers
            if (OpeningPrayer != null || ClosingPrayer != null)
            {
                newMeeting.Prayers = new List <Prayer>();
                if (OpeningPrayer != null)
                {
                    var prayerToAddO = new Prayer
                    {
                        MemberID = int.Parse(OpeningPrayer),
                        Schedule = PrayerPosition.Opening
                    };
                    newMeeting.Prayers.Add(prayerToAddO);
                }
                if (ClosingPrayer != null)
                {
                    var prayerToAddC = new Prayer
                    {
                        MemberID = int.Parse(ClosingPrayer),
                        Schedule = PrayerPosition.Closing
                    };
                    newMeeting.Prayers.Add(prayerToAddC);
                }
            }

            // add songs
            if (OpeningSong != null || SacramentSong != null || ClosingSong != null)
            {
                newMeeting.SongSelections = new List <SongSelection>();
                if (OpeningSong != null)
                {
                    var songToAddO = new SongSelection
                    {
                        SongID   = int.Parse(OpeningSong),
                        Schedule = SongPosition.Opening
                    };
                    newMeeting.SongSelections.Add(songToAddO);
                }
                if (SacramentSong != null)
                {
                    var songToAddS = new SongSelection
                    {
                        SongID   = int.Parse(SacramentSong),
                        Schedule = SongPosition.Sacrament
                    };
                    newMeeting.SongSelections.Add(songToAddS);
                }
                if (ClosingSong != null)
                {
                    var songToAddC = new SongSelection
                    {
                        SongID   = int.Parse(ClosingSong),
                        Schedule = SongPosition.Closing
                    };
                    newMeeting.SongSelections.Add(songToAddC);
                }
            }

            try
            {
                if (await TryUpdateModelAsync <Meeting>(
                        newMeeting,
                        "Meeting",
                        i => i.MeetingDate,
                        i => i.CallingID))
                {
                    _context.Meeting.Add(newMeeting);
                    await _context.SaveChangesAsync();

                    //return RedirectToPage("./Index");
                    return(RedirectToPage("../Talks/Create", new { id = newMeeting.MeetingID }));
                }
            }
            catch (Exception)
            {
                PopulateBishopricSL(_context);
                PopulateSongsSLI(_context);
                PopulatePrayersSLI(_context);
                Message = "There was an error saving meeting.";
                return(RedirectToPage("./Create"));
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #18
0
        public static void Initialize(SacramentMeetingContext context)
        {
            // context.Database.EnsureCreated();

            // Look for any Members
            if (context.Member.Any())
            {
                return; // Db already has data
            }
            var members = new Member[]
            {
                new Member {
                    FirstName = "Joseph", LastName = "Smith", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Emma", LastName = "Smith", MembersGender = Gender.Female
                },
                new Member {
                    FirstName = "Jeffrey", LastName = "Holland", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Donnie", LastName = "Osmond", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Marie", LastName = "Osmond", MembersGender = Gender.Female
                },
                new Member {
                    FirstName = "David", LastName = "Archuletta", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Katherine", LastName = "Heigl", MembersGender = Gender.Female
                },
                new Member {
                    FirstName = "Glenn", LastName = "Beck", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Mitt", LastName = "Romney", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Julianne", LastName = "Hough", MembersGender = Gender.Female
                },
                new Member {
                    FirstName = "Brandon", LastName = "Flowers", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Merlin", LastName = "Olsen", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Ricky", LastName = "Schroder", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Gladys", LastName = "Knight", MembersGender = Gender.Female
                },
                new Member {
                    FirstName = "Jack", LastName = "Dempsey", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Danny", LastName = "Ainge", MembersGender = Gender.Male
                },
                new Member {
                    FirstName = "Dieter", LastName = "Uchtdorf", MembersGender = Gender.Male
                },
            };

            foreach (Member m in members)
            {
                context.Member.Add(m);
            }
            context.SaveChanges();

            var callings = new Calling[]
            {
                new Calling {
                    Title = "Bishop", Organization = Organizations.Bishopric, CallingGender = GenderCl.Male
                },
                new Calling {
                    Title = "1st Counselor", Organization = Organizations.Bishopric, CallingGender = GenderCl.Male
                },
                new Calling {
                    Title = "2nd Counselor", Organization = Organizations.Bishopric, CallingGender = GenderCl.Male
                },
                new Calling {
                    Title = "Organist", Organization = Organizations.Music, CallingGender = GenderCl.Both
                },
                new Calling {
                    Title = "Choirister", Organization = Organizations.Music, CallingGender = GenderCl.Both
                },
                new Calling {
                    Title = "2nd Counselor", Organization = Organizations.Young_Men, CallingGender = GenderCl.Male
                },
                new Calling {
                    Title = "President", Organization = Organizations.Young_Men, CallingGender = GenderCl.Male
                },
                new Calling {
                    Title = "1st Counselor", Organization = Organizations.Young_Men, CallingGender = GenderCl.Male
                },
                new Calling {
                    Title = "2nd Counselor", Organization = Organizations.Primary, CallingGender = GenderCl.Female
                },
                new Calling {
                    Title = "2nd Counselor", Organization = Organizations.Young_Women, CallingGender = GenderCl.Female
                },
                new Calling {
                    Title = "President", Organization = Organizations.Primary, CallingGender = GenderCl.Female
                },
                new Calling {
                    Title = "President", Organization = Organizations.Young_Women, CallingGender = GenderCl.Female
                },
                new Calling {
                    Title = "1st Counselor", Organization = Organizations.Young_Women, CallingGender = GenderCl.Female
                },
                new Calling {
                    Title = "1st Counselor", Organization = Organizations.Primary, CallingGender = GenderCl.Female
                },
                new Calling {
                    Title = "Teacher 8yr Olds", Organization = Organizations.Primary, CallingGender = GenderCl.Both
                },
                new Calling {
                    Title = "Teacher 7yr Old", Organization = Organizations.Primary, CallingGender = GenderCl.Both
                },
            };

            foreach (Calling c in callings)
            {
                context.Calling.Add(c);
            }
            context.SaveChanges();

            var currentCallings = new CurrentCalling[]
            {
                new CurrentCalling {
                    MemberID = 4, CallingID = 1, DateCalled = DateTime.Parse("2018-3-01")
                },
                new CurrentCalling {
                    MemberID = 1, CallingID = 2, DateCalled = DateTime.Parse("2018-3-01")
                },
                new CurrentCalling {
                    MemberID = 9, CallingID = 3, DateCalled = DateTime.Parse("2018-3-01")
                },
                new CurrentCalling {
                    MemberID = 5, CallingID = 4, DateCalled = DateTime.Parse("2002-9-05")
                },
                new CurrentCalling {
                    MemberID = 7, CallingID = 5, DateCalled = DateTime.Parse("2017-4-19")
                },
                new CurrentCalling {
                    MemberID = 11, CallingID = 6, DateCalled = DateTime.Parse("2015-8-13")
                },
                new CurrentCalling {
                    MemberID = 13, CallingID = 7, DateCalled = DateTime.Parse("2015-8-06")
                },
            };

            foreach (CurrentCalling c in currentCallings)
            {
                context.CurrentCalling.Add(c);
            }
            context.SaveChanges();

            var songs = new Song[]
            {
                new Song {
                    SongID = 2, Title = "The Spirit of God"
                },
                new Song {
                    SongID = 8, Title = "Redeemer Of Israel"
                },
                new Song {
                    SongID = 19, Title = "We Thank The O God For A Prophet"
                },
                new Song {
                    SongID = 26, Title = "Joseph Smith's First Prayer"
                },
                new Song {
                    SongID = 35, Title = "For The Strength Of The Hills"
                },
                new Song {
                    SongID = 41, Title = "Let Zion In Her Beauty Rise"
                },
                new Song {
                    SongID = 58, Title = "Come Ye Children Of The Lord"
                },
                new Song {
                    SongID = 66, Title = "Rejoice, The Lord Is King"
                },
                new Song {
                    SongID = 85, Title = "How Firm A Foundation"
                },
                new Song {
                    SongID = 89, Title = "The Lord Is My Light"
                },
                new Song {
                    SongID = 92, Title = "For The Beauty Of The Earth"
                },
                new Song {
                    SongID = 96, Title = "Dearest Children God Is Near You"
                },
                new Song {
                    SongID = 97, Title = "Lead Kindly Light"
                },
                new Song {
                    SongID = 98, Title = "I Need Thee Every Hour"
                },
                new Song {
                    SongID = 116, Title = "Come, Follow Me"
                },
                new Song {
                    SongID = 169, Title = "As Now We Take The Sacrament"
                },
                new Song {
                    SongID = 173, Title = "While Of These Emblems We Partake"
                },
                new Song {
                    SongID = 181, Title = "Jesus Of Nazereth, Savior And King"
                },
                new Song {
                    SongID = 184, Title = "Upon The Cross of Calvary"
                },
                new Song {
                    SongID = 185, Title = "Reverently And Meekly Now"
                },
                new Song {
                    SongID = 188, Title = "Thy Will O Lord, Be Done"
                },
                new Song {
                    SongID = 193, Title = "I Stand All Amazed"
                },
                new Song {
                    SongID = 194, Title = "There Is A Green Hill Far Away"
                },
                new Song {
                    SongID = 196, Title = "Jesus, Once Of Humble Birth"
                }
            };

            foreach (Song s in songs)
            {
                context.Song.Add(s);
            }
            context.SaveChanges();

            var meetings = new Meeting[]
            {
                new Meeting {
                    MeetingDate = DateTime.Parse("2019-12-9"), CallingID = 1
                },
                new Meeting {
                    MeetingDate = DateTime.Parse("2019-12-16"), CallingID = 1
                },
                new Meeting {
                    MeetingDate = DateTime.Parse("2019-12-23"), CallingID = 1
                },
                new Meeting {
                    MeetingDate = DateTime.Parse("2019-12-30"), CallingID = 1
                },
            };

            foreach (Meeting m in meetings)
            {
                context.Meeting.Add(m);
            }
            context.SaveChanges();

            var songSelections = new SongSelection[]
            {
                new SongSelection {
                    SongID = 2, MeetingID = 1, Schedule = SongPosition.Opening
                },
                new SongSelection {
                    SongID = 173, MeetingID = 1, Schedule = SongPosition.Sacrament
                },
                new SongSelection {
                    SongID = 8, MeetingID = 1, Schedule = SongPosition.Closing
                },
                new SongSelection {
                    SongID = 19, MeetingID = 2, Schedule = SongPosition.Opening
                },
                new SongSelection {
                    SongID = 181, MeetingID = 2, Schedule = SongPosition.Sacrament
                },
                new SongSelection {
                    SongID = 26, MeetingID = 2, Schedule = SongPosition.Closing
                },
                new SongSelection {
                    SongID = 35, MeetingID = 3, Schedule = SongPosition.Opening
                },
                new SongSelection {
                    SongID = 194, MeetingID = 3, Schedule = SongPosition.Sacrament
                },
                new SongSelection {
                    SongID = 66, MeetingID = 3, Schedule = SongPosition.Closing
                },
                new SongSelection {
                    SongID = 85, MeetingID = 4, Schedule = SongPosition.Opening
                },
                new SongSelection {
                    SongID = 196, MeetingID = 4, Schedule = SongPosition.Sacrament
                },
                new SongSelection {
                    SongID = 98, MeetingID = 4, Schedule = SongPosition.Closing
                },
            };

            foreach (SongSelection s in songSelections)
            {
                context.SongSelection.Add(s);
            }
            context.SaveChanges();

            var prayers = new Prayer[]
            {
                new Prayer {
                    MeetingID = 1, MemberID = 10, Schedule = PrayerPosition.Opening
                },
                new Prayer {
                    MeetingID = 1, MemberID = 11, Schedule = PrayerPosition.Closing
                },
                new Prayer {
                    MeetingID = 2, MemberID = 12, Schedule = PrayerPosition.Opening
                },
                new Prayer {
                    MeetingID = 2, MemberID = 13, Schedule = PrayerPosition.Closing
                },
                new Prayer {
                    MeetingID = 3, MemberID = 14, Schedule = PrayerPosition.Opening
                },
                new Prayer {
                    MeetingID = 3, MemberID = 15, Schedule = PrayerPosition.Closing
                },
                new Prayer {
                    MeetingID = 4, MemberID = 16, Schedule = PrayerPosition.Opening
                },
                new Prayer {
                    MeetingID = 4, MemberID = 1, Schedule = PrayerPosition.Closing
                },
            };

            foreach (Prayer p in prayers)
            {
                context.Prayer.Add(p);
            }
            context.SaveChanges();

            var talks = new Talk[]
            {
                new Talk {
                    MeetingID = 1, MemberID = 1, Topic = "Coming closer to Christ through Christmas traditions"
                },
                new Talk {
                    MeetingID = 1, MemberID = 2, Topic = "Jesus in America"
                },
                new Talk {
                    MeetingID = 1, MemberID = 3, Topic = "Prophets fortell of Jesus Birth"
                },
                new Talk {
                    MeetingID = 2, MemberID = 4, Topic = "Forgiveness"
                },
                new Talk {
                    MeetingID = 2, MemberID = 5, Topic = "Giving Service during the Holidays"
                },
                new Talk {
                    MeetingID = 3, MemberID = 6, Topic = "Christ-Like Attributes"
                },
                new Talk {
                    MeetingID = 3, MemberID = 7, Topic = "'Taking Upon Ourselves the Name of Jesus Christ' by Robert C Gay Oct.2018"
                },
            };

            foreach (Talk t in talks)
            {
                context.Talk.Add(t);
            }
            context.SaveChanges();
        }
Beispiel #19
0
    // Start is called before the first frame update
    void Start()
    {
        if (!ConfigFile.IsLoaded)
        {
            ConfigFile.Load();
        }

        loadingLeft  = GameObject.Find("LoadingLeft").GetComponent <RectTransform>();
        loadingRight = GameObject.Find("LoadingRight").GetComponent <RectTransform>();

        BgLine.SetColor(ThemeColors.Blue);

        songCards = new List <CardBase>();
        if (SongSelection.Songlist.Count == 0)
        {
            SongSelection.ImportSongs(Defines.SongFolder);
        }
        for (int i = 0; i < SongSelection.Songlist.Count; i++)
        {
            songCards.Add(new SongCard(Pools.SongCards.GetPooledObject(), SongSelection.Songlist[i]));
            songCards[i].Shift(i, SongSelection.CurrentSongIndex);
        }
        levelCards = new List <CardBase>();
        for (int i = 0; i < 10; i++)
        {
            levelCards.Add(new FolderCard(Pools.FolderCards.GetPooledObject(), "LEVEL " + (i + 1)));
        }
        folderCards = new List <CardBase>();
        foreach (var folder in SongSelection.FolderParams)
        {
            switch (folder.Type)
            {
            case SortType.Title: folder.Name = ConfigFile.GetLocalizedString("Sort_Title"); break;

            case SortType.Artist: folder.Name = ConfigFile.GetLocalizedString("Sort_Artist"); break;

            case SortType.Level: folder.Name = ConfigFile.GetLocalizedString("Sort_Level"); break;

            default: break;
            }
            folderCards.Add(new FolderCard(Pools.FolderCards.GetPooledObject(), folder.Name));
        }

        transform.Find("AutoModeText").gameObject.SetText(ConfigFile.GetLocalizedString("Auto_Mode_Enabled"));

        // No Songs
        if (SongSelection.Songlist.Count == 0)
        {
            GameState.GameMode = Mode.NoSongs;
            for (int i = 0; i < transform.childCount; i++)
            {
                transform.GetChild(i).gameObject.SetActive(false);
            }
            transform.Find("Bg").gameObject.SetActive(true);
            transform.Find("NoSongs").gameObject.SetActive(true);
        }
        else
        {
            backgroundImage = GameObject.Find("BgLine").GetComponent <UnityEngine.UI.RawImage>();
            if (backgroundImage != null && backgroundImage.texture != null)
            {
                backgroundImage.texture.wrapMode = TextureWrapMode.Repeat;
            }
        }

        init = true;
    }