コード例 #1
0
ファイル: OsuBridge.cs プロジェクト: hypereddie/OsuDuino
        public static void LoadAllSongs(FoundSongCallback callback = null)
        {
            string osuDir = "C:\\Program Files\\osu!\\Songs";
            if (!Directory.Exists(osuDir))
            {
                osuDir = "C:\\Program Files (x86)\\osu!\\Songs";
                if (!Directory.Exists(osuDir)) return;
            }

            string[] folders = Directory.GetDirectories(osuDir);
            for (int i = 0; i < folders.Length; i++)
            {
                string folder = folders[i];

                string[] files = Directory.GetFiles(folder, "*.osu");
                foreach (string file in files)
                {
                    Song song = new Song()
                    {
                        Name = Path.GetFileName(file).Split('.')[0],
                        Path = file
                    };
                    double tickRate = 1;
                    song.Beats = Beat.FromSong(song, out tickRate);
                    song.SetTickRate(tickRate);
                    song.LoadTimers();
                    if (callback != null)
                        callback(song);

                }
            }
        }
コード例 #2
0
ファイル: Beat.cs プロジェクト: hypereddie/OsuDuino
        public static Queue<Beat> FromSong(Song song, out double tickRate)
        {
            tickRate = 1;
            Queue<Beat> beats = new Queue<Beat>();
            string[] lines = File.ReadAllLines(song.Path);
            bool start = false;
            foreach (string line in lines)
            {
                if (line.StartsWith("SliderTickRate") && line.Split(':').Length > 1)
                {
                    double.TryParse(line.Split(':')[1], out tickRate);
                }
                else if (line == "[HitObjects]")
                {
                    start = true;
                    continue;
                }
                else if (start)
                {
                    Beat beat = new Beat();
                    long time = 0;
                    int x = 0, y = 0;
                    long.TryParse(line.Split(',')[2], out time);
                    int.TryParse(line.Split(',')[0], out x);
                    int.TryParse(line.Split(',')[1], out y);
                    beat.Time = time;
                    beat.X = x;
                    beat.Y = y;

                    if (line.Contains('|') && line.Split(',').Length > 5)
                    {
                        try
                        {
                            int repeat = 1;
                            if (line.Split(',').Length > 6) int.TryParse(line.Split(',')[6], out repeat);

                            Slider slider = Slider.fromString(line.Split(',')[5], repeat);

                            double temp = 100;
                            if (line.Split(',').Length > 7) double.TryParse(line.Split(',')[7], out temp);
                            slider.LengthToEnd = temp;

                            beat.SliderPoints = slider;
                        }
                        catch (Exception e)
                        {
                            System.Windows.Forms.MessageBox.Show(e.ToString());
                        }
                    }
                    else beat.SliderPoints = null;

                    beats.Enqueue(beat);
                }
            }

            return beats;
        }
コード例 #3
0
ファイル: MainMenu.cs プロジェクト: hypereddie/OsuDuino
 void AddItem(Song song)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke(new SongMethod(AddItem), new object[] { song });
         return;
     }
     this.comboBox1.Items.Add(song);
 }
コード例 #4
0
ファイル: Timing.cs プロジェクト: hypereddie/OsuDuino
        public static List<Timing> FromSong(Song song)
        {
            string[] lines = File.ReadAllLines(song.Path);
            bool start = false;
            List<Timing> times = new List<Timing>();
            foreach (string line in lines)
            {
                if (start && line.StartsWith("[")) break;
                if (String.IsNullOrEmpty(line)) continue;
                if (line == "[TimingPoints]")
                {
                    start = true;
                    continue;
                }
                else if (start)
                {
                    long offset = 0;
                    long.TryParse(line.Split(',')[0], out offset);
                    double mpb = 1000;
                    double.TryParse(line.Split(',')[1], out mpb);
                    if (mpb < 0)
                    {
                        for (int i = times.Count - 1; i >= 0; i--)
                        {
                            mpb = times[i].MillisecondsPerBeat;
                            if (mpb > 0) break;
                        }
                    }

                    Timing time = new Timing();
                    time.Offset = offset;
                    time.MillisecondsPerBeat = mpb;

                    times.Add(time);
                }
            }

            return times;
        }
コード例 #5
0
ファイル: MouseMover.cs プロジェクト: hypereddie/OsuDuino
 public static void Prepare(Song song)
 {
     playingSong = song; //Set the current song playing to the one provided
     Waiting = true; //Wait for the right click
 }