Exemple #1
0
 private void WriteToFile(string songName, SongMetadata songMetadata)
 {
     if (!SongDataFileUtility.TryWriteSongMetadata(songName, songMetadata))
     {
         throw new System.IO.IOException();
     }
 }
Exemple #2
0
        protected void OnClickCreateBeatmapButton()
        {
            var songName    = GetSelectedName1();
            var difficulty  = GetSelectedDifficulty();
            var beatmapType = GetSelectedBeatmapType();

            void openWithNewBeatmap() => Game.OpenBeatmapEditor(songName, difficulty, new SongData.Beatmap(beatmapType));

            if (SongDataFileUtility.BeatmapFileExists(songName, beatmapType, difficulty))
            {
                if (SongDataFileUtility.TryReadBeatmap(songName, beatmapType, difficulty, out SongData.Beatmap beatmap))
                {
                    var msg = MessageTemplate.GetConfirmationBox("Create Beatmap",
                                                                 string.Format(
                                                                     "Song: \"{0}\"\n" +
                                                                     "Difficulty: \"{1}\"\n" +
                                                                     "Beatmap Type: \"{2}\"\n" +
                                                                     "A beatmap already exists for this song and difficulty. Are you sure you want to start over?",
                                                                     songName, difficulty.Name, beatmapType.Name),
                                                                 openWithNewBeatmap //on yes
                                                                 );
                    Game.MessageBox(msg);
                    return;
                }
            }
            openWithNewBeatmap();
        }
Exemple #3
0
        private void WriteToFile(string songName, BeatmapDifficulty difficulty)
        {
            var beatmapEditor = (BeatmapEditor)WeakEditor;

            if (!SongDataFileUtility.TryWriteBeatmap(songName, difficulty, beatmapEditor.BeatmapWriter.Beatmap))
            {
                throw new System.IO.IOException();
            }
        }
Exemple #4
0
        private void TryImportAudioFromPath(string filePath)
        {
            if (SongDataFileUtility.TryImportAudio(Editor.SongName, filePath))
            {
                Game.MessageBox("Audio Import", "Audio import was successful.");

                TrySetAudio();
            }
            else
            {
                // Commented out for duplicate message.
                //Game.MessageBox("Audio Import", "Audio import failed.");
            }
        }
Exemple #5
0
        public void Awake()
        {
            _songNames = PopulateDropdown(NameDropdown1, SongDataFileUtility.GetAllSongNames(), value => value);
            NameDropdown2.ClearOptions();
            NameDropdown2.AddOptions(_songNames);

            _difficulties  = PopulateDropdown(DifficultyDropdown, BeatmapDifficulty.GetAll(), value => value.Name);
            _typeInstances = PopulateDropdown(TypeDropdown, BeatmapType.GetAll(), value => value.Name);

            CreateNewSongButton.onClick.AddListener(OnClickCreateSongButton);

            CreateBeatmapButton.onClick.AddListener(OnClickCreateBeatmapButton);
            LoadBeatmapButton.onClick.AddListener(OnClickLoadBeatmapButton);
            RefreshButton.onClick.AddListener(OnClickRefreshButton);

            EditSongButton.onClick.AddListener(OnClickEditSongButton);
        }
Exemple #6
0
        public void OnClickEditSongButton()
        {
            var songName = GetSelectedName2();

            if (SongDataFileUtility.SongDirectoryExists(songName))
            {
                Game.OpenSongEditor(songName);
            }
            else
            {
                Game.MessageBox("Load Beatmap",
                                string.Format(
                                    "Song: \"{0}\"\n" +
                                    "There was a problem loading the song.",
                                    songName)
                                );
            }
        }
Exemple #7
0
        protected void OnClickCreateSongButton()
        {
            var songName = SongNameInputField.text;

            if (SongDataFileUtility.SongDirectoryExists(songName))
            {
                Game.MessageBox("Create New Song",
                                string.Format(
                                    "A song named \"{0}\" already exists. Please select it from the Load/Create dropdown to load or create new beatmap data.",
                                    songName));
            }
            else
            {
                if (SongDataFileUtility.CreateNewSong(songName))
                {
                    Game.MessageBox("Create New Song", "Song directory was created. Hit Refresh.");
                }
            }
        }
Exemple #8
0
        protected override SaveArgs PrepareSave()
        {
            BeatmapEditor beatmapEditor = (BeatmapEditor)WeakEditor;

            string            songName    = WeakEditor.SongName;
            BeatmapDifficulty difficulty  = beatmapEditor.Difficulty;
            BeatmapType       beatmapType = beatmapEditor.BeatmapWriter.TypeInstance;

            var saveDataIsValid = !string.IsNullOrEmpty(songName) &&
                                  difficulty != null &&
                                  beatmapType != null;

            var dataWillOverwrite = SongDataFileUtility.BeatmapFileExists(songName, beatmapType, difficulty);

            var willOverwriteMessage =
                string.Format(
                    "Song: \"{0}\"\n" +
                    "Difficulty: \"{1}\"\n" +
                    "Beatmap Type: \"{2}\"\n" +
                    "A beatmap already exists for this song and difficulty. Are you sure you want to overwrite it?",
                    songName, difficulty.Name, beatmapType);

            var successMessage =
                string.Format(
                    "Song: \"{0}\"\n" +
                    "Difficulty: \"{1}\"\n" +
                    "Beatmap Type: \"{2}\"\n" +
                    "Beatmap saved successfully.",
                    songName, difficulty.Name, beatmapType);

            void writeToFile() => WriteToFile(songName, difficulty);    //local function

            return(new SaveArgs()
            {
                SaveDataIsValid = saveDataIsValid,
                DataWillOverwrite = dataWillOverwrite,
                WillOverwriteMessage = willOverwriteMessage,
                SuccessMessage = successMessage,
                WriteToFileDelegate = writeToFile,
            });
        }
Exemple #9
0
        protected override SaveArgs PrepareSave()
        {
            SongMetadataEditor songEditor = (SongMetadataEditor)WeakEditor;

            string       songName     = songEditor.SongName;
            SongMetadata songMetadata = songEditor.SongMetadataComponent.SongMetadata;

            var saveDataIsValid =
                !string.IsNullOrEmpty(songName) &&
                songMetadata != null;

            var dataWillOverwrite =
                SongDataFileUtility.SongMetadataFileExists(songName);

            var willOverwriteMessage =
                string.Format(
                    "Song: \"{0}\"\n" +
                    "Are you sure you want to update this song metadata?",
                    songName);

            var successMessage =
                string.Format(
                    "Song: \"{0}\"\n" +
                    "Song metadata updated successfully.",
                    songName);

            void writeToFile() => WriteToFile(songName, songMetadata);    //local function, how quaint

            return(new SaveArgs()
            {
                SaveDataIsValid = saveDataIsValid,
                DataWillOverwrite = dataWillOverwrite,
                WillOverwriteMessage = willOverwriteMessage,
                SuccessMessage = successMessage,
                WriteToFileDelegate = writeToFile,
            });
        }
Exemple #10
0
        protected void OnClickLoadBeatmapButton()
        {
            var songName    = GetSelectedName1();
            var difficulty  = GetSelectedDifficulty();
            var beatmapType = GetSelectedBeatmapType();

            if (SongDataFileUtility.BeatmapFileExists(songName, beatmapType, difficulty))
            {
                if (SongDataFileUtility.TryReadBeatmap(songName, beatmapType, difficulty, out SongData.Beatmap beatmap))
                {
                    Game.OpenBeatmapEditor(songName, difficulty, beatmap);
                }
                else
                {
                    Game.MessageBox("Load Beatmap",
                                    string.Format(
                                        "Song: \"{0}\"\n" +
                                        "Difficulty: \"{1}\"\n" +
                                        "Beatmap Type: \"{2}\"\n" +
                                        "There was a problem loading the beatmap for this song and difficulty.",
                                        songName, difficulty.Name, beatmapType.Name)
                                    );
                }
            }
            else
            {
                Game.MessageBox("Load Beatmap",
                                string.Format(
                                    "Song: \"{0}\"\n" +
                                    "Difficulty: \"{1}\"\n" +
                                    "Beatmap Type: \"{2}\"\n" +
                                    "Unable to locate a beatmap for this song and difficulty.",
                                    songName, difficulty.Name, beatmapType.Name)
                                );
            }
        }