public void TestDecodeKaraokeSkin() { using (var resStream = TestResources.OpenSkinResource("default")) using (var stream = new LineBufferedReader(resStream)) { var decoder = new KaraokeSkinDecoder(); var skin = decoder.Decode(stream); // Checking font decode result var firstDecodedFont = skin.Fonts.FirstOrDefault(); Assert.IsNotNull(firstDecodedFont); Assert.AreEqual(firstDecodedFont.Name, "標準配色"); // Test back text brush var backTextBrushInfo = firstDecodedFont.BackTextBrushInfo.TextBrush; Assert.AreEqual(backTextBrushInfo.BrushGradients.Count, 3); Assert.AreEqual(backTextBrushInfo.SolidColor, new Color4(255, 255, 255, 255)); Assert.AreEqual(backTextBrushInfo.Type, BrushType.Solid); // Test font info var lyricTextFontInfo = firstDecodedFont.LyricTextFontInfo.LyricTextFontInfo; Assert.AreEqual(lyricTextFontInfo.FontName, "游明朝 Demibold"); Assert.AreEqual(lyricTextFontInfo.Bold, true); Assert.AreEqual(lyricTextFontInfo.CharSize, 40); Assert.AreEqual(lyricTextFontInfo.EdgeSize, 10); // Checking layout decode result var firstDecodedLayout = skin.Layouts.FirstOrDefault(); Assert.NotNull(firstDecodedLayout); Assert.AreEqual(firstDecodedLayout.Name, "下-1"); Assert.AreEqual(firstDecodedLayout.Alignment, Anchor.BottomRight); Assert.AreEqual(firstDecodedLayout.HorizontalMargin, 30); Assert.AreEqual(firstDecodedLayout.VerticalMargin, 45); Assert.AreEqual(firstDecodedLayout.Continuous, false); Assert.AreEqual(firstDecodedLayout.SmartHorizon, KaraokeTextSmartHorizon.Multi); Assert.AreEqual(firstDecodedLayout.LyricsInterval, 4); Assert.AreEqual(firstDecodedLayout.RubyInterval, 2); Assert.AreEqual(firstDecodedLayout.RubyAlignment, LyricTextAlignment.Auto); Assert.AreEqual(firstDecodedLayout.RomajiAlignment, LyricTextAlignment.Auto); Assert.AreEqual(firstDecodedLayout.RubyMargin, 4); Assert.AreEqual(firstDecodedLayout.RomajiMargin, 0); // Checking note decode result var firstDecodedNoteSkin = skin.NoteSkins.FirstOrDefault(); Assert.NotNull(firstDecodedNoteSkin); Assert.AreEqual(firstDecodedNoteSkin.Name, "Note-1"); Assert.AreEqual(firstDecodedNoteSkin.NoteColor, new Color4(68, 170, 221, 255)); Assert.AreEqual(firstDecodedNoteSkin.BlinkColor, new Color4(255, 102, 170, 255)); Assert.AreEqual(firstDecodedNoteSkin.TextColor, new Color4(255, 255, 255, 255)); Assert.AreEqual(firstDecodedNoteSkin.BoldText, true); // Checking singer decode result var firstDecodedSinger = skin.Singers.FirstOrDefault(); Assert.NotNull(firstDecodedSinger); Assert.AreEqual(firstDecodedSinger.Name, "Singer-1"); Assert.AreEqual(firstDecodedSinger.Romaji, "Singer-1"); Assert.AreEqual(firstDecodedSinger.EnglishName, "Singer-1"); Assert.AreEqual(firstDecodedSinger.Color, new Color4(255, 128, 128, 255)); } }
private static KaraokeSkin decode(string filename, out KaraokeSkin encoded) { using (var stream = TestResources.OpenSkinResource(filename)) using (var sr = new LineBufferedReader(stream)) { // Read file and decode to file var legacyDecoded = new KaraokeSkinDecoder().Decode(sr); using (var ms = new MemoryStream()) using (var sw = new StreamWriter(ms)) using (var sr2 = new LineBufferedReader(ms)) { // Then encode file to stream var encodeResult = new KaraokeSkinEncoder().Encode(legacyDecoded); sw.WriteLine(encodeResult); sw.Flush(); ms.Position = 0; // Decode result from stream encoded = new KaraokeSkinDecoder().Decode(sr2); return(legacyDecoded); } } }
protected KaraokeInternalSkin() { // TODO : need a better way to load resource var assembly = Assembly.GetExecutingAssembly(); using (var stream = assembly.GetManifestResourceStream(ResourceName)) using (var reader = new LineBufferedReader(stream)) { var skin = new KaraokeSkinDecoder().Decode(reader); BindableFont = new Bindable <LyricFont>(skin.Fonts.FirstOrDefault()); BindableLayout = new Bindable <LyricLayout>(skin.Layouts.FirstOrDefault()); } }
public KaraokeLegacySkinTransformer(ISkinSource source) : base(source) { this.source = source; if (source != null) { source.SourceChanged += sourceChanged; } sourceChanged(); // TODO : need a better way to load resource var assembly = Assembly.GetExecutingAssembly(); const string resource_name = @"osu.Game.Rulesets.Karaoke.Resources.Skin.default.skin"; using (var stream = assembly.GetManifestResourceStream(resource_name)) using (var reader = new LineBufferedReader(stream)) { var skin = new KaraokeSkinDecoder().Decode(reader); // Create bindables for (int i = 0; i < skin.Fonts.Count; i++) { bindableFonts.Add(i, new Bindable <KaraokeFont>(skin.Fonts[i])); } for (int i = 0; i < skin.Layouts.Count; i++) { bindableLayouts.Add(i, new Bindable <KaraokeLayout>(skin.Layouts[i])); } for (int i = 0; i < skin.NoteSkins.Count; i++) { bindableNotes.Add(i, new Bindable <NoteSkin>(skin.NoteSkins[i])); } for (int i = 0; i < skin.Singers.Count; i++) { bindableSingers.Add(i, new Bindable <Singer>(skin.Singers[i])); } // Create lookups bindableFontsLookup.Value = skin.Fonts.ToDictionary(k => skin.Fonts.IndexOf(k), y => y.Name); bindableLayoutsLookup.Value = skin.Layouts.ToDictionary(k => skin.Layouts.IndexOf(k), y => y.Name); bindableNotesLookup.Value = skin.NoteSkins.ToDictionary(k => skin.NoteSkins.IndexOf(k), y => y.Name); bindableSingersLookup.Value = skin.Singers.ToDictionary(k => skin.Singers.IndexOf(k), y => y.Name); } }
public LayoutGenerator(LayoutGeneratorConfig config) { Config = config; // todo : need better way to load resource var assembly = Assembly.GetExecutingAssembly(); const string resource_name = @"osu.Game.Rulesets.Karaoke.Resources.Skin.default.skin"; using (var stream = assembly.GetManifestResourceStream(resource_name)) using (var reader = new LineBufferedReader(stream)) { var skin = new KaraokeSkinDecoder().Decode(reader); var groups = skin.LayoutGroups; foreach (var group in groups) { var matchLayouts = skin.Layouts.Where(x => x.Group == group.Id).ToArray(); layouts.Add(group.Id, matchLayouts); } } }