public static ChordSheetCollection Create()
    {
        ChordSheetCollection newCollection = new ChordSheetCollection();

        newCollection.SheetNames = new List <string>();
        newCollection.Sheets     = new List <ChordSheet>();
        return(newCollection);
    }
Example #2
0
    public void ShowWindow(ChordSheetCollection chordSheets)
    {
        gameObject.SetActive(true);

        for (int i = 0, count = options.Count; i < count; ++i)
        {
            Destroy(options[i]);
        }
        options = new List <GameObject>();

        for (int i = 0, count = chordSheets.SheetNames.Count; i < count; ++i)
        {
            GameObject       newOption = Instantiate <GameObject>(ChordSheetOptionTemplate, ScrollContainer);
            ChordSheetOption option    = newOption.GetComponent <ChordSheetOption>();
            option.Initialize(chordSheets.SheetNames[i], (sheetName) =>
            {
                onLoad(chordSheets.Sheets[chordSheets.SheetNames.IndexOf(sheetName)]);
            });
            options.Add(newOption);
        }
    }
Example #3
0
    private void OnSheetsRetrievedForSave(ChordSheetCollection sheetCollection)
    {
        ChordSheet newSheet = new ChordSheet();

        newSheet.Chords          = new List <Chord>();
        newSheet.MelodyDiagrams  = new List <MelodyDiagramModel>();
        newSheet.Labels          = new List <string>();
        newSheet.ElementTypesInt = new List <int>();
        for (int i = 0, count = chords.Count; i < count; ++i)
        {
            newSheet.Chords.Add(chords[i].CurrentChord);
        }

        for (int i = 0, count = melodies.Count; i < count; ++i)
        {
            newSheet.MelodyDiagrams.Add(melodies[i].GetModel());
        }

        for (int i = 0, count = labels.Count; i < count; ++i)
        {
            newSheet.Labels.Add(labels[i].LabelField.text);
        }

        int numChildren = ScrollContainer.childCount;

        for (int i = 0; i < numChildren; ++i)
        {
            Transform child = ScrollContainer.GetChild(i);
            if (child.GetComponent <ChordDiagram>() != null)
            {
                newSheet.ElementTypesInt.Add((int)ElementType.Chord);
            }
            else if (child.GetComponent <MelodyDiagram>() != null)
            {
                newSheet.ElementTypesInt.Add((int)ElementType.Melody);
            }
            else if (child.GetComponent <LabelElement>() != null)
            {
                newSheet.ElementTypesInt.Add((int)ElementType.Label);
            }
        }

        if (sheetCollection == null)
        {
            sheetCollection = ChordSheetCollection.Create();
        }

        int sheetIndex = sheetCollection.SheetNames.IndexOf(currentSheetName);

        if (sheetIndex < 0)
        {
            sheetCollection.SheetNames.Add(currentSheetName);
            sheetCollection.Sheets.Add(newSheet);
        }
        else
        {
            sheetCollection.Sheets[sheetIndex] = newSheet;
        }

        string sheetJson = JsonUtility.ToJson(sheetCollection);

        WebRequestManager.PostData(sheetJson, OnSaveComplete);
    }