Пример #1
0
    private void EditOrAdd()
    {
        if (controller.IsEditSettings)
        {
            Debug.Log("VW: In Edit");

            // Enable wordText and disable word field
            wordText.SetActive(true);
            wordField.SetActive(false);

            if (!(controller.IsTextureSet() || controller.IsClipSet()))
            {
                Debug.Log("No pic or audio clip change yet");
                saveButton.interactable = false;
                CleanUpScroll();
            }

            if (controller.IsTextureSet() || controller.IsClipSet())
            {
                Debug.Log("Change made to pic and/or audio clip. Save is now allowed.");
                saveButton.interactable = true;
                CleanUpScroll();
            }

            string word = controller.GetTargetWord();
            Debug.Log("Inside edit. word is = " + word);
            Debug.Log("Inside edit. word tags are: " + wordTags);

            if (word != null || word != "")
            {
                Debug.Log("attempting to load Word_DO for Word Name");
                WordDO dataObject = controller.GetWordDO(word);
                Debug.Log("Got the Word_DO, now attempting to get the text component");
                wordText.GetComponent <Text>().text = TidyCase(word);
                titleLabel.text = TITLE_EDIT;
            }
            else
            {
                //TODO: THROW AN ERROR
                Debug.Log("Error, word is null or blank. Word = " + word);
            }

            if (wordTags != null || wordTags != "")
            {
                Debug.Log("attempting to load Word_DO for Word Tags");
                WordDO dataObject = controller.GetWordDO(word);
                Debug.Log("Got the Word_DO, now attempting to get the text component");
                wordTagsText.text = wordTags;
            }
            else
            {
                //TODO: THROW AN ERROR
                Debug.Log("Error, wordtags is null or blank. Wordtags = " + wordTags);
            }
        }
        else
        {
            Debug.Log("VW: In ADD");
            titleLabel.text = TITLE_ADD;
            string word     = controller.GetTargetWord();
            string wordTags = controller.GetTargetWordTags();

            // Enable word field and disable word text
            wordField.SetActive(true);
            wordText.SetActive(false);
            wordTagsText.text = wordTags;

            if (controller.GetTargetWord() == null || !controller.IsTextureSet())
            {
                saveButton.interactable = false;
                CleanUpScroll();
            }
            else
            {
                saveButton.interactable = true;
                CleanUpScroll();
            }

            if (word != null)
            {
                Debug.Log("VW: Setting text to " + controller.GetTargetWord());
                wordFieldText.text   = word;
                placeHolderText.text = word;
            }
        }
    }