コード例 #1
0
ファイル: IOHelper.cs プロジェクト: 2poi/Mapping_Tools
        public static string GetCurrentBeatmap()
        {
            string path;

            try {
                string songs = SettingsManager.GetSongsPath();

                if (string.IsNullOrEmpty(songs))
                {
                    throw new Exception(
                              @"Can't fetch current in-game beatmap, because there is no Songs path specified in Preferences.");
                }

                string folder   = PioReader.GetMapFolderName();
                string filename = PioReader.GetOsuFileName();

                if (string.IsNullOrEmpty(folder))
                {
                    throw new Exception(@"Can't fetch the folder name of the current in-game beatmap.");
                }

                if (string.IsNullOrEmpty(filename))
                {
                    throw new Exception(@"Can't fetch the file name of the current in-game beatmap.");
                }

                path = Path.Combine(songs, folder, filename);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                try {
                    var reader = EditorReaderStuff.GetEditorReader();
                    reader.FetchEditor();
                    reader.SetHOM();
                    reader.ReadHOM();
                    reader.FetchBeatmap();
                    path = EditorReaderStuff.GetCurrentBeatmap(reader);
                }
                catch (Exception ex2) {
                    Console.WriteLine(ex2.Message);
                    Console.WriteLine(ex2.StackTrace);
                    throw ex;
                }
            }

            return(path);
        }