private void DrawImportButton() { // Reserve space for this part EditorGUILayout.Space(); Rect bounds = GUILayoutUtility.GetRect(EmptyLabel, "button"); // Calculate the progress bar bounds float originalWidth = bounds.width; bounds.width = originalWidth - (ImportButtonWidth + Space); // Check if we need to show the progress bar if (IsInMiddleOfImporting == true) { EditorGUI.ProgressBar(bounds, Progress, ProgressMessage.ToString()); } else { EditorGUI.ProgressBar(bounds, 1, "Waiting..."); } // Only enable if no error messages are there bool isEnabled = GUI.enabled; GUI.enabled = ((ErrorMessage.Length == 0) && (IsInMiddleOfImporting == false)); // Calculate the button bounds bounds.width = ImportButtonWidth; bounds.x = (bounds.x + originalWidth) - ImportButtonWidth; // Draw the button if ((GUI.Button(bounds, "Import") == true) && (GUI.enabled == true)) { // Reset the progress Progress = 0f; currentStatus.Value = ImportState.ReadFile; progressReport.SetTotalSteps(1); // Start a new thread ThreadPool.QueueUserWorkItem(ImportCsvFile); } // Revert enable behavior GUI.enabled = isEnabled; }
public List <TranslationCollection> UpdateSerializedTranslations(ProgressReport report = null) { // Check if we need to report our progress if (report != null) { // Set the number of steps involved in serialization report.SetTotalSteps(AllTranslations.Count); } // Grab a soft-copy of all translations KeyLanguageTextMap translationCopy = AllTranslations; // Clear the translations list (this needs to happen AFTER calling AllTranslations' getter) translations.Clear(); // Go through all the keys TranslationCollection collectionToAdd; LanguageTextPair pairToAdd; foreach (KeyValuePair <string, LanguageTextMap> collection in translationCopy) { // Create a new collection of translations collectionToAdd = new TranslationCollection(collection.Key); // Go through all translations foreach (KeyValuePair <int, string> pair in collection.Value) { // Create a new pair pairToAdd = new LanguageTextPair(pair.Key, pair.Value); // Add the pair to the collection collectionToAdd.AllTranslations.Add(pairToAdd); } // Add new collection to the list translations.Add(collectionToAdd); // Check if we need to report our progress if (report != null) { // Increment report.IncrementCurrentStep(); } } // Indicate the dictionary matches the serialization IsAllTranslationsSerialized = true; // Return the updated translations list return(translations); }