Example #1
0
        void InitializeDir()
        {
            Destination = Path.Combine(Directory.GetLogicalDrives().First(), "osu!Export");
            try
            {
                Source = tryGetSource();
                ConsoleAdd("osu! folder found automatically at " + Source);

                try
                {
                    FileList = OsuSong.ParseAll(Source);
                }
                catch (Exception e)
                {
                    ConsoleAdd(e.Message);
                }

                StreamWriter sw = new StreamWriter("path.dat", false, Encoding.Unicode);
                sw.Write(Source + "?" + Destination);
                sw.Close();
            }
            catch (NoOsuFoundException)
            {
                BrowseForSource();
            }
        }
Example #2
0
        public static List <OsuSong> ParseAll(string path)
        {
            List <OsuSong> osuList = new List <OsuSong>();

            foreach (string file in Directory.EnumerateDirectories(path + "\\Songs").ToList())
            {
                osuList.Add(OsuSong.Parse(file));
            }
            osuList.Sort();
            return(osuList);
        }
Example #3
0
        private ViewModel()
        {
            FilteredList = new ObservableCollection <OsuSong>();
            consoleBox   = new ObservableCollection <string>();

            //TODO: clean this shit up, especially: if path.dat exists but it's bullshit then try to get the actual osu! directory

            //get source+destination
            //if file exists, import from it
            //it it doesn't, try to get default osu! folder
            //if all else fails, make the user browse
            //if no valid folder found, put message


            if (File.Exists("path.dat"))
            {
                string[] paths = File.ReadAllText("path.dat", Encoding.Unicode).Split('?');

                Source      = paths[0];
                Destination = paths[1];
                if (Directory.Exists(Source))
                {
                    ConsoleAdd("osu! folder found in cache");

                    try
                    {
                        FileList = OsuSong.ParseAll(Source);
                    }
                    catch (Exception e)
                    {
                        ConsoleAdd(e.Message);
                    }
                }
                else
                {
                    InitializeDir();
                }
            }
            else
            {
                InitializeDir();
            }
            FilteredList.Clear();
            foreach (OsuSong file in FileList)
            {
                FilteredList.Add(file);
            }
        }
Example #4
0
        public void BrowseForSource()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = Source;
            dialog.Title            = "Please select your osu! executable.";
            dialog.Filter           = "osu! launcher (osu!.exe)|osu!.exe";
            DialogResult result = dialog.ShowDialog();

            if (result.ToString() == "OK")
            {
                Source   = dialog.FileName.Replace("osu!.exe", "");
                FileList = OsuSong.ParseAll(Source);
                FilteredList.Clear();
                foreach (OsuSong file in FileList)
                {
                    FilteredList.Add(file);
                }
                StreamWriter sw = new StreamWriter("path.dat", false, Encoding.Unicode);
                sw.Write(Source + "?" + Destination);
                sw.Close();
            }
        }