private void ParseSoundChannelSummary(IJsonWrapper rawData, HashSet <int> channels) { string name = rawData.GetChild("name").AsString(); if (string.IsNullOrEmpty(name)) { return; } IJsonWrapper notes = rawData.GetChild("notes"); foreach (IJsonWrapper note in notes.GetChilds()) { channels.Add(GetChannelMap(note.GetChild("x").AsInt32())); if (note.GetChild("l").AsInt32() > 0) { maxCombos++; } } maxCombos += notes.Count; }
private void ParseBGAEvents(ParseType parseType, List <BMSEvent> bmev) { IJsonWrapper bga = bmsonData.GetChild("bga"); if ((parseType & ParseType.Resources) == ParseType.Resources) { foreach (IJsonWrapper entry in bga.GetChild("bga_header").GetChilds()) { AddResource( ResourceType.bmp, entry.GetChild("id").AsInt32(), entry.GetChild("name").AsString() ); } } if ((parseType & ParseType.Content) == ParseType.Content) { ParseBGALayer(bga.GetChild("bga_events"), 0, bmev); ParseBGALayer(bga.GetChild("layer_events"), 1, bmev); ParseBGALayer(bga.GetChild("poor_events"), -1, bmev); } }
private void ParseSoundChannel(List <BMSEvent> bmev, IJsonWrapper rawData, int index) { string name = rawData.GetChild("name").AsString(); if (string.IsNullOrEmpty(name)) { return; } AddResource(ResourceType.wav, index, name); BMSEvent? lastEvent = null; TimeSpan slicedPosition = TimeSpan.Zero; IList <BMSEvent> events = Events; foreach (IJsonWrapper note in rawData.GetChild("notes").GetChilds()) { BMSEvent currentEvent; int ticks = note.GetChild("y").AsInt32(); int channelId = GetChannelMap(note.GetChild("x").AsInt32()); int length = note.GetChild("l").AsInt32(); TimeSpan currentTime = CalculateTime(bmev, ticks); if (lastEvent.HasValue) { currentEvent = lastEvent.Value; int lastIndex = FindEventIndex(currentEvent); if (note.GetChild("c").AsBoolean()) { currentEvent.sliceEnd = slicedPosition = currentTime - currentEvent.time + currentEvent.sliceStart; } else { currentEvent.sliceEnd = TimeSpan.MaxValue; slicedPosition = TimeSpan.Zero; } ReplaceEvent(lastIndex, currentEvent); } if (length > 0) { TimeSpan endTime = CalculateTime(bmev, ticks + length); lastEvent = currentEvent = new BMSEvent { type = BMSEventType.LongNoteStart, ticks = ticks, time = currentTime, data1 = channelId, data2 = index, time2 = endTime - currentTime, sliceStart = slicedPosition, sliceEnd = TimeSpan.MaxValue }; AddEvent(currentEvent); AddEvent(new BMSEvent { type = BMSEventType.LongNoteEnd, ticks = ticks + length, time = endTime, data1 = channelId, data2 = index }); } else { lastEvent = currentEvent = new BMSEvent { type = channelId == 0 ? BMSEventType.WAV : BMSEventType.Note, ticks = ticks, time = currentTime, data1 = channelId, data2 = index, sliceStart = slicedPosition, sliceEnd = TimeSpan.MaxValue }; AddEvent(currentEvent); } } }
private void ParseHeader() { IJsonWrapper info = bmsonData.GetChild("info"); title = info.GetChild("title").AsString(); subTitle = info.GetChild("subtitle").AsString(); artist = info.GetChild("artist").AsString(); subArtist = string.Join("\n", info.GetChild("subartists").GetChilds() .Select(entry => entry.AsString()) .ToArray() ); genre = info.GetChild("genre").AsString(); modeHint = info.GetChild("mode_hint").AsString("beat-7k"); chartName = info.GetChild("chart_name").AsString(); playLevel = info.GetChild("level").AsInt32(); initialBPM = info.GetChild("init_bpm").AsSingle(); minBpm = Math.Min(minBpm, initialBPM); AddMetaImageResource(-2, info.GetChild("banner_image")); AddMetaImageResource(-1, info.GetChild("eyecatch_image")); AddMetaImageResource(-3, info.GetChild("back_image")); tickResoultion = info.GetChild("resolution").AsInt32(240); }