Example #1
0
 internal static void Add(string key,string file)
 {
     if (fileDict.ContainsKey(file))
     {
         SoundUnit old = fileDict[file];
         sampleDict.Add(key, old);
         return;
     }
     if (sampleDict.ContainsKey(key))
     {
         return;
     }
     SoundUnit su = new SoundUnit();
     su.Custom = currentCustom;
     su.Sound = currentSound;
     su.Set = currentSet;
     su.File = file;
     sampleDict.Add(key, su);
     fileDict.Add(file, su);
     update();
 }
Example #2
0
        private void writeToFile()
        {
            moveFile();
            using (FileStream fs = new FileStream(Dir + Filename, FileMode.OpenOrCreate))
            {
                using (StreamWriter writer = new StreamWriter(fs))
                {
                    writer.WriteLine("osu file format v11");
                    writer.WriteLine();
                    writer.WriteLine("[General]");
                    writer.WriteLine("AudioFilename: virtual");
                    writer.WriteLine("AudioLeadIn: 0");
                    writer.WriteLine("PreviewTime: 0");
                    writer.WriteLine("Countdown: 0");
                    writer.WriteLine("SampleSet: 0");
                    writer.WriteLine("StackLeniency: 0.4");
                    writer.WriteLine("Mode: 3");
                    writer.WriteLine("SpecialStyle:" + (Special ? "1" : "0"));//new value, for 7+1 and 5+1 only.
                    writer.WriteLine();

                    writer.WriteLine("[Metadata]");
                    writer.WriteLine("Title:" + Title);
                    writer.WriteLine("TitleUnicode:" + Title);
                    writer.WriteLine("Artist:" + Artist);
                    writer.WriteLine("ArtistUnicode:" + Artist);
                    writer.WriteLine("Creator: BMXC_V1");
                    writer.WriteLine("Version:" + Diff);
                    writer.WriteLine("Source:" + Source);
                    writer.WriteLine("Tags:");
                    writer.WriteLine("BeatmapID:0");
                    writer.WriteLine("BeatmapSetID:-1");
                    writer.WriteLine();

                    writer.WriteLine("[Difficulty]");
                    writer.WriteLine("HPDrainRate: "+HPRate.ToString());
                    writer.WriteLine("CircleSize: " + Column.ToString());
                    writer.WriteLine("OverallDifficulty: 7");
                    writer.WriteLine("ApproachRate: 7");
                    writer.WriteLine("SliderMultiplier: 0.4");
                    writer.WriteLine("SliderTickRate:1");
                    writer.WriteLine();

                    writer.WriteLine("[Events]");
                    if (Background != "")
                    {
                        writer.WriteLine("//Background and Video events");
                        writer.WriteLine("{0},{1},\"{2}\"", 0, 0, Background);
                    }
                    if (EventList.Count > 0 && WithSample)
                    {
                        writer.WriteLine("//Storyboard Sound Samples");

                        foreach (Event e in EventList)
                            writer.WriteLine("{0},{1},{2},\"{3}\",{4}", 5, (int)e.Time, 0, e.Filename, 70);
                        writer.WriteLine();
                    }

                    writer.WriteLine("[TimingPoints]");
                    double lastTime = -1;
                    foreach (Timing t in TimingList)
                    {
                        writer.WriteLine("{0:0},{1},{2},{3},{4},{5},{6},{7}", t.Time,
                                    t.changed ? 60000 / t.bpm : -100, (int)(t.beat * 4), (int)t.SampleSet,
                                     (int)t.CustomSampleSet, 70, (t.changed ? "1" : "0"), 0);
                    }
                    writer.WriteLine();

                    SoundUnit empty = new SoundUnit();
                    writer.WriteLine("[HitObjects]");
                    foreach (Note n in NoteList)
                    {
                        string extra = "";
                        SoundUnit su = n.Sound;
                        if (su == null || !WithSample)
                            su = empty;
                        if (n.Type == NoteType.ManiaLong)
                        {
                            extra = "," + (int)n.TimeEnd;
                            extra += string.Format(":{0}:{1}:{2}", (int)su.Set, 0, (int)su.Custom);
                        }
                        else
                            extra += string.Format(",{0}:{1}:{2}", (int)su.Set, 0, (int)su.Custom);
                        writer.WriteLine((int)((n.Column + 0.5) * 512 / Column) + ",192," + (int)n.TimeStart + "," + (int)n.Type + "," + (int)su.Sound + extra);
                    }
                }
            }
        }