private void AddEntryFromTranslationListStatus(ReorderableList list, int index) { // FIXME: add a new status at the end of the list //Debug.Log("AddEntryFromTranslationListStatus(" + index + ')'); SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(index); TranslationCollectionEditor status = new TranslationCollectionEditor(this, element, ((SupportedLanguages)supportedLanguages.objectReferenceValue)); translationStatus.Add(status); // Check the element's key //TranslationStatus.AddKeyToFrequencyDictionary(frequencyInKeyAppearance, status.KeyProperty.stringValue); }
private void UpdateTranslationListStatus(ReorderableList list, int startIndex) { //Debug.Log("UpdateTranslationListStatus(" + startIndex + ')'); // Check if the list size matches bet if (list.count > translationStatus.Count) { // Update the start index to the size of translation list if it's smaller than the actual GUI startIndex = Mathf.Min(startIndex, translationStatus.Count); // Add statuses if the status list size does not match the list count while (list.count > translationStatus.Count) { AddEntryFromTranslationListStatus(translationsList, translationStatus.Count); } } else if (list.count < translationStatus.Count) { // Remove a couple of list elements while (list.count < translationStatus.Count) { // Removing from the tail-end is more efficient! RemoveEntryFromTranslationListStatus(translationsList, (translationStatus.Count - 1)); } } // HACK: Not sure why the frequency dictionary is not drawing properly, but here it is startIndex = 0; frequencyInKeyAppearance.Clear(); // Make sure the start index value is valid if ((startIndex >= 0) && (startIndex < list.count)) { // FIXME: do not resize the TranslationListStatus, // but do update it to the latest info starting from startIndex to count. // Go through the list, starting at startIndex for (int index = startIndex; index < translationStatus.Count; ++index) { // Udpate neato based on element translationStatus[index].Update(list.serializedProperty.GetArrayElementAtIndex(index)); TranslationCollectionEditor.AddKeyToFrequencyDictionary(frequencyInKeyAppearance, translationStatus[index].KeyProperty.stringValue); } } }