Beispiel #1
0
    private void DrawNotesheetNotes(Difficulty difficulty, SerializedProperty notesArrayProp)
    {
        notesArrayProp.isExpanded = EditorGUILayout.Foldout(notesArrayProp.isExpanded, "Notes", true);
        if (!notesArrayProp.isExpanded)
        {
            return;
        }

        EditorGUI.indentLevel++;

        // Buttons
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Import .txt"))
        {
            string path = EditorUtility.OpenFilePanel("Open note sheet .txt", "", "txt");

            NoteGroup[] notes = null;
            if (NotesheetText.Import(path, ref notes) && notes != null)
            {
                AssignNoteArray(notesArrayProp, notes);
            }
        }
        if (GUILayout.Button("Export .txt"))
        {
            string path = EditorUtility.SaveFilePanel("Save note sheet as .txt", "", "notesheet.txt", "txt");
            NotesheetText.Export(song, path, difficulty);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        string ext = NoteInfo.notesheetFileFormat;

        if (GUILayout.Button("Import ." + ext))
        {
            string path = EditorUtility.OpenFilePanel("Open note sheet ." + ext, "", ext);
            if (!string.IsNullOrEmpty(path))
            {
                AssignNoteArray(notesArrayProp, NoteInfo.LoadNoteSheetAsNoteGroups(path, song.BPM));
            }
        }
        if (GUILayout.Button("Export ." + ext))
        {
            string path = EditorUtility.SaveFilePanel("Save note sheet as ." + ext, "", "notesheet." + ext, ext);
            if (!string.IsNullOrEmpty(path))
            {
                NoteInfo.SaveNotesheetFromNoteGroups(song.GetNotesheet(difficulty).GetNoteGroups, (byte)difficulty,
                                                     song.BPM, path);
            }
        }
        GUILayout.EndHorizontal();


        // Array
        int oldSize = notesArrayProp.arraySize;

        notesArrayProp.arraySize = Math.Max(EditorGUILayout.DelayedIntField("Size", oldSize), 0);
        if (oldSize <= 0)
        {
            for (int i = 0; i < notesArrayProp.arraySize; i++)
            {
                notesArrayProp.GetArrayElementAtIndex(i).FindPropertyRelative(relativeTimeName).intValue =
                    Subdivision.substepDivision;
            }
        }

        string[] labels = new string[(int)difficulty];
        Array.Copy(noteLabels, labels, labels.Length);
        for (int i = 0, lastStep = 0; i < notesArrayProp.arraySize; i++)
        {
            DrawNoteGroup(difficulty, notesArrayProp.GetArrayElementAtIndex(i), i, ref lastStep, labels);
        }

        EditorGUI.indentLevel--;
    }