public RemoveItem ( |
||
item | Item to remove | |
Résultat | void |
private void calculateMarkers(int[] frets, QbItemArray arr, QbFile text) { int minNote = this.Notes.MinNoteOffsetSynced + _startPaddingMs + _fretPadding; int maxNote = this.Notes.MaxNoteOffsetSynced + _startPaddingMs + _fretPadding; int pos = minNote; int sectionSecs = 20000; int sections = (maxNote - minNote) / sectionSecs; //every x seconds for (int c = text.Items.Count - 1; c > 0; c--) text.RemoveItem(text.Items[c]); QbItemStructArray sa = new QbItemStructArray(arr.Root); sa.Create(QbItemType.ArrayStruct); arr.Items.Clear(); arr.AddItem(sa); QbItemStruct s; QbItemInteger i; QbItemQbKey q; string sectionTitle; QbKey qbKey; QbItemString txt; for (int c = 0; c < sections; c++) { if (pos + 3000 > this.Length) break; //don't create a section less than 3 seconds long sectionTitle = string.Format("Section {0}", (c + 1).ToString()); qbKey = QbKey.Create(string.Format("{0}_markers_text_{1}", this.SongQb.Id, QbKey.Create(sectionTitle).Crc.ToString("x").ToLower())); txt = new QbItemString(text); txt.Create(QbItemType.SectionString); txt.ItemQbKey = qbKey; txt.Strings = new string[] { sectionTitle }; text.AddItem(txt); s = new QbItemStruct(arr.Root); s.Create(QbItemType.StructHeader); sa.AddItem(s); i = new QbItemInteger(arr.Root); i.Create(QbItemType.StructItemInteger); i.ItemQbKey = QbKey.Create("time"); i.Values = new uint[] { findNearestFret((uint)pos, frets) }; s.AddItem(i); pos += sectionSecs; q = new QbItemQbKey(arr.Root); q.Create(QbItemType.StructItemQbKeyString); q.ItemQbKey = QbKey.Create("marker"); q.Values = new QbKey[] { qbKey }; s.AddItem(q); } text.AlignPointers(); arr.Root.AlignPointers(); }
private void setMarkers(int[] frets, QbItemArray arr, QbFile text, NotesMarker[] markers) { int minNote = this.Notes.MinNoteOffsetSynced + _startPaddingMs + _fretPadding; QbItemStruct s; QbItemInteger i; QbItemQbKey q; QbKey qbKey; QbItemString txt; for (int c = text.Items.Count - 1; c > 0; c--) text.RemoveItem(text.Items[c]); if (arr.Items[0] is QbItemFloats) { QbItemStructArray newArr = new QbItemStructArray(arr.Root); newArr.Create(QbItemType.ArrayStruct); arr.AddItem(newArr); arr.RemoveItem(arr.Items[0]); } QbItemStructArray sa = (QbItemStructArray)arr.Items[0]; sa.Items.Clear(); NotesMarker marker; List<NotesMarker> mrk = new List<NotesMarker>(markers); if (mrk.Count > 0 && mrk[0].Offset > minNote) //some charts don't have sections at the start so you can't practice the start notes :-( { if (mrk[0].Offset > minNote + 5000) // if > 5secs then add new mrk.Insert(0, new NotesMarker("Start", minNote)); else //else move first marker back to start mrk[0].Offset = minNote; } for (int c = 0; c < mrk.Count; c++) { marker = mrk[c]; if (c < mrk.Count - 1 && mrk[c + 1].Offset < minNote) continue; //don't add sections at the start that would have no notes (crashes song??) qbKey = QbKey.Create(string.Format("{0}_markers_text_{1}", this.SongQb.Id, QbKey.Create(marker.Title).Crc.ToString("x").ToLower())); txt = new QbItemString(text); txt.Create(QbItemType.SectionString); txt.ItemQbKey = qbKey; txt.Strings = new string[] { marker.Title }; text.AddItem(txt); s = new QbItemStruct(arr.Root); s.Create(QbItemType.StructHeader); sa.AddItem(s); i = new QbItemInteger(arr.Root); i.Create(QbItemType.StructItemInteger); i.ItemQbKey = QbKey.Create("time"); i.Values = new uint[] { findNearestFret((uint)marker.Offset, frets) }; s.AddItem(i); q = new QbItemQbKey(arr.Root); q.Create(QbItemType.StructItemQbKeyString); q.ItemQbKey = QbKey.Create("marker"); q.Values = new QbKey[] { qbKey }; s.AddItem(q); } text.AlignPointers(); arr.Root.AlignPointers(); }