Esempio n. 1
0
    private IEnumerator DownloadWordSet(string wordSetName)
    {
        Debug.Log("Downloading " + wordSetName);
        isDoneWordSetDataDownload = false;

        //get the word set data
        StartCoroutine(DownloadWordSetDataText(wordSetName));
        yield return(new WaitUntil(() => isDoneWordSetDataDownload));

        //download each word in the set based on the word set data
        for (int i = 0; i < wordSetArray.Length; i++)
        {
            float tempFloat1 = ((float)i) + 1;
            float tempFloat2 = (float)wordSetArray.Length;
            DownloadProgressBar.fillAmount = tempFloat1 / tempFloat2;

            if (controller.DoesDbEntryExist(wordSetArray[i]) == false)
            {
                StartCoroutine(DownloadWord(wordSetArray[i], wordSetName));
                yield return(new WaitUntil(() => doneWordDownloadStep));
            }
            else
            {
                Debug.Log(wordSetArray[i] + " already exists in the database.");
            }
        }

        //clear the wordSetArray.
        wordSetArray = null;

        //turn off the download progress panel, reset scrollview and clear data
        DownloadProgressPanel.SetActive(false);
        ResetScrollView();
        controller.ClearData();
    }
Esempio n. 2
0
    public void Save()
    {
        string word;

        if (controller.IsEditSettings) // if the word is being edited (i.e. not new)
        {
            // Check if any changes have been made.
            if (controller.GetCurrentClip() == null && controller.GetImages().Count == 0 && !imageDeleted && (wordTags == wordTagsOriginal))
            {
                loadingAnimPanel.SetActive(false);
                textModal.transform.GetChild(0).GetComponent <Text>().text = MODAL_NO_EDITS;
                EnableErrorModal();
                return;
            }

            word = controller.GetTargetWord();

            if (controller.SaveWordEdits(word, wordTags) || imageDeleted)
            {
                textModal.transform.GetChild(0).GetComponent <Text>().text = string.Format(MODAL_EDIT_TEXT, TidyCase(word));
                loadingAnimPanel.SetActive(false);
                EnableEditModal();
            }
            else
            {
                Debug.Log("VW: There was an error!");
                loadingAnimPanel.SetActive(false);
                EnableErrorModal();
                textModal.transform.GetChild(0).GetComponent <Text>().text = string.Format(MODAL_MISSING_DATA);
            }
        }
        else // the word is new (i.e. not an existing word being edited)
        {
            word = controller.GetTargetWord();

            if (controller.DoesDbEntryExist(word))
            {
                loadingAnimPanel.SetActive(false);
                textModal.transform.GetChild(0).GetComponent <Text>().text = word + " already exists\n\n(Click to try again)";
                EnableErrorModal();
            }
            else
            {
                if (controller.SaveNewWord(word, wordTags) || imageDeleted)
                {
                    //Handle UI changes to notify success and set-up popup for additional options
                    textModal.transform.GetChild(0).GetComponent <Text>().text = string.Format(MODAL_ADD_TEXT, TidyCase(word));
                    loadingAnimPanel.SetActive(false);
                    EnableAddModal();
                }
                else
                {
                    textModal.transform.GetChild(0).GetComponent <Text>().text = "Something went horribly wrong";
                    loadingAnimPanel.SetActive(false);
                    EnableErrorModal();
                    // TODO: add proper error handling
                }
            }
        }
    }