static private void ReadEvents() { midifile = MidiPlayerGlobal.CurrentMidiSet.MidiFiles[indexEditItem]; infoEvents = MidiScan.GeneralInfo(midifile, withNoteOn, withNoteOff, withControlChange, withPatchChange, withAfterTouch, withMeta, withOthers); infoEvents.Insert(0, "Open midi file: " + midifile); infoEvents.Insert(0, "DB Midi index: " + indexEditItem); PageToDisplay = 0; scrollPosAnalyze = Vector2.zero; }
/// <summary> /// Display, add, remove Midi file /// </summary> /// <param name="localstartX"></param> /// <param name="localstartY"></param> private void ShowListMidiFiles(float localstartX, float localstartY) { try { Rect zone = new Rect(localstartX, localstartY, widthLeft, heightList); GUI.color = new Color(.8f, .8f, .8f, 1f); GUI.Box(zone, ""); GUI.color = Color.white; string caption = "Midi file available"; if (MidiPlayerGlobal.CurrentMidiSet.MidiFiles == null || MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count == 0) { caption = "No Midi file available yet"; ScanInfo = new BuilderInfo(); } GUIContent content = new GUIContent() { text = caption, tooltip = "" }; EditorGUI.LabelField(new Rect(localstartX + xpostitlebox, localstartY + ypostitlebox, 300, itemHeight), content, styleBold); if (GUI.Button(new Rect(widthLeft - buttonWidth - espace, localstartY + ypostitlebox, buttonWidth, buttonHeight), "Add Midi file")) { AddMidifile(); } if (MidiPlayerGlobal.CurrentMidiSet.MidiFiles != null) { Rect listVisibleRect = new Rect(localstartX, localstartY + itemHeight, widthLeft - 5, heightList - itemHeight - 5); Rect listContentRect = new Rect(0, 0, widthLeft - 20, MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count * itemHeight + 5); scrollPosMidiFile = GUI.BeginScrollView(listVisibleRect, scrollPosMidiFile, listContentRect); float boxY = 0; for (int i = 0; i < MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count; i++) { GUI.color = new Color(.7f, .7f, .7f, 1f); float boxX = 5; GUI.Box(new Rect(boxX, boxY + 5, widthLeft - 30, itemHeight), ""); GUI.color = Color.white; content = new GUIContent() { text = i.ToString() + " - " + MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i], tooltip = MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i] }; EditorGUI.LabelField(new Rect(boxX, boxY + 9, 200, itemHeight), content); boxX += 285 + espace; if (GUI.Button(new Rect(boxX, boxY + 9, 80, buttonHeight), "Analyse")) { ScanInfo = new BuilderInfo(); midifile = MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i]; ScanInfo.Add(midifile); MidiScan.GeneralInfo(midifile, ScanInfo); scrollPosAnalyze = Vector2.zero; } boxX += 80 + espace; GUI.color = Color.white; if (GUI.Button(new Rect(boxX, boxY + 9, 80, buttonHeight), "Remove")) { if (!string.IsNullOrEmpty(MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i])) { DeleteResource(MidiLoad.BuildOSPath(MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i])); AssetDatabase.Refresh(); ToolsEditor.CheckMidiSet(); } } boxY += itemHeight; } GUI.EndScrollView(); } } catch (Exception ex) { MidiPlayerGlobal.ErrorDetail(ex); } }