public void Initialize(ProposalElement proposal, AutoCompletionWindow autoCompleteWindow)
        {
            this.autoCompleteWindow = autoCompleteWindow;
            this.proposalElement    = proposal;

            proposalOutput.text = proposal.simple;
        }
Esempio n. 2
0
 public void ApplyCurrentProposal()
 {
     if (currentProposal != null && currentSelectedElementID < currentProposal.proposalElements.Count)
     {
         ProposalElement currentProposalElement = currentProposal.proposalElements[currentSelectedElementID];
         ApplyProposal(currentProposalElement);
     }
 }
Esempio n. 3
0
        void SpawnItem(ProposalElement proposal)
        {
            GameObject proposalItemGO = Instantiate(proposalItemPrefab) as GameObject;

            proposalItemGO.transform.SetParent(proposalItemContainer, false);
            AutoCompletionProposalItem proposalItem = proposalItemGO.GetComponent <AutoCompletionProposalItem>();

            proposalItem.Initialize(proposal, this);
            proposalItems.Add(proposalItem);
        }
Esempio n. 4
0
        /// <summary>
        /// Adds the selected proposal to the input field.
        /// </summary>
        /// <param name="proposalElement"></param>
        public void ApplyProposal(ProposalElement proposalElement)
        {
            if (currentProposal == null)
            {
                return;
            }

            ClearItems();

            currentSelectedElementID = 0;
            try {
                string beginning = consoleInput.text.Substring(0, currentProposal.replaceStringStart);
                string end       = consoleInput.text.Substring(currentProposal.replaceStringEnd, consoleInput.text.Length - currentProposal.replaceStringEnd);
                consoleInput.text          = beginning + proposalElement.full + end;
                consoleInput.caretPosition = currentProposal.replaceStringStart + proposalElement.full.Length;
            }
            catch (Exception e) {
                Debug.Log("Problem with autocompletion:");
                Debug.LogException(e);
                currentProposal = null;
            }
        }