Пример #1
0
        protected override bool OnKeyDown(KeyDownEvent e)
        {
            if (e.Key != Key.S)
            {
                return(base.OnKeyDown(e));
            }

            string directory = Path.Combine(Path.GetTempPath(), @"osu!");

            Directory.CreateDirectory(directory);
            var path = Path.Combine(directory, "karaoke.txt");

            using (var sw = new StreamWriter(path))
            {
                var encoder = new KaraokeLegacyBeatmapEncoder();
                sw.WriteLine(encoder.Encode(new Beatmap
                {
                    HitObjects = Beatmap.HitObjects.OfType <HitObject>().ToList()
                }));
            }

            return(true);
        }
        public void TestEncodeBeatmapLyric()
        {
            // Because encoder is not fully implemented, so just test not crash during encoding.
            const int start_time = 1000;
            const int duration   = 2500;

            var beatmap = new Beatmap
            {
                HitObjects = new List <HitObject>
                {
                    new LyricLine
                    {
                        StartTime = start_time,
                        Duration  = duration,
                        Text      = "カラオケ!",
                        TimeTags  = new Dictionary <TimeTagIndex, double>
                        {
                            { new TimeTagIndex(0), start_time + 500 },
                            { new TimeTagIndex(1), start_time + 600 },
                            { new TimeTagIndex(2), start_time + 1000 },
                            { new TimeTagIndex(3), start_time + 1500 },
                            { new TimeTagIndex(4), start_time + 2000 },
                        },
                        RubyTags = new[]
                        {
                            new RubyTag
                            {
                                StartIndex = 0,
                                EndIndex   = 1,
                                Text       = "か"
                            },
                            new RubyTag
                            {
                                StartIndex = 2,
                                EndIndex   = 3,
                                Text       = "お"
                            }
                        },
                        RomajiTags = new[]
                        {
                            new RomajiTag
                            {
                                StartIndex = 1,
                                EndIndex   = 2,
                                Text       = "ra"
                            },
                            new RomajiTag
                            {
                                StartIndex = 3,
                                EndIndex   = 4,
                                Text       = "ke"
                            }
                        },
                        TranslateText = "karaoke"
                    }
                }
            };

            using (var ms = new MemoryStream())
                using (var sw = new StreamWriter(ms))
                {
                    var encoder      = new KaraokeLegacyBeatmapEncoder();
                    var encodeResult = encoder.Encode(beatmap);
                    sw.WriteLine(encodeResult);
                }
        }