Exemple #1
0
        /// <summary>
        /// Converts an Intralism beatmap folder to a Pulsarc-compatible beatmap, and then saves the converted Beatmap to storage.
        /// </summary>
        /// <param name="folder_path">The path to the map-to-be-converted folder</param>
        public void Save(string folder_path)
        {
            Beatmap map = Convert(folder_path).First();

            // If the map is null, or audio is null, stop saving.
            if (map == null || map.Audio == null)
            {
                return;
            }

            string audioPath = $"{folder_path}/{map.Audio}";

            // If the path doesn't exist, stop saving.
            if (!File.Exists(audioPath))
            {
                return;
            }

            int id = 0;
            // The folder name will look like "0 - Unknown - MapTitle - (Mapper)"
            string folderName = string.Join("_", ($"{id} - {map.Artist} - {map.Title} ({map.Mapper})").Split(Path.GetInvalidFileNameChars()));
            string dirName    = $"Songs/{folderName}";

            if (!Directory.Exists(dirName))
            {
                Directory.CreateDirectory(dirName);
            }

            // Copy Audio File
            File.Copy(audioPath, $"{dirName}/{map.Audio}", true);

            // Copy Background Image
            string backgroundPath = $"{folder_path}/{map.Background}";

            // Find if the background exists and copy it.
            if (File.Exists(backgroundPath))
            {
                try
                {
                    File.Copy(backgroundPath, $"{dirName}/{map.Background}", true);
                }
                catch
                {
                    PulsarcLogger.Debug("Converting the background failed! Converting wtihout background.", LogType.Runtime);
                }
            }
            else
            {
                map.Background = "";
            }


            // The file name will look like "Unknown - MapTitle [Converted] (Mapper).psc"
            string difficultyFileName = string.Join("_", ($"{map.Artist} - {map.Title} [{map.Version}] ({map.Mapper})").Split(Path.GetInvalidFileNameChars()));

            BeatmapHelper.Save(map, $"{dirName}/{difficultyFileName}.psc");
        }
Exemple #2
0
        /// <summary>
        /// Convert a folder of osu!mania beatmaps to Pulsarc-compatible beatmaps, and then save the converted Beatmaps to storage.
        /// </summary>
        /// <param name="folder_path">The path to the maps-to-be-converted folder</param>
        public void Save(string folder_path)
        {
            foreach (Beatmap map in Convert(folder_path))
            {
                if (map.Audio != null)
                {
                    string audioPath = $"{folder_path}/{map.Audio}";

                    if (File.Exists(audioPath))
                    {
                        int id = 0;
                        // The folder name will look like "0 - Artist - SongTitle - (Mapper)"
                        string folderName = string.Join("_", ($"{id} - {map.Artist} - {map.Title} ({map.Mapper})").Split(Path.GetInvalidFileNameChars()));
                        string dirName    = $"Songs/{folderName}";

                        if (!Directory.Exists(dirName))
                        {
                            Directory.CreateDirectory(dirName);
                        }

                        // Copy Audio File
                        File.Copy(audioPath, $"{dirName}/{map.Audio}", true);

                        // Copy Background Image
                        string backgroundPath = $"{folder_path}/{map.Background}";

                        if (File.Exists(backgroundPath))
                        {
                            File.Copy(backgroundPath, $"{dirName}/{map.Background}", true);
                        }
                        else
                        {
                            map.Background = "";
                        }

                        // The file name will look like "Artist - SongTitle [Converted] (Mapper).psc"
                        string difficultyFileName = string.Join("_", ($"{map.Artist} - {map.Title} [{map.Version}] ({map.Mapper})").Split(Path.GetInvalidFileNameChars()));

                        BeatmapHelper.Save(map, $"{dirName}/{difficultyFileName}.psc");
                    }
                }
            }
        }