Exemple #1
0
        public ScriptLineView CreateLineView(string scriptLineText, int lineIndex, bool @default = false)
        {
            var lineType = Script.ResolveLineType(scriptLineText);
            var lineView = default(ScriptLineView);

            switch (lineType.Name)
            {
            case nameof(CommentScriptLine):
                var commentScriptLine = new CommentScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = new CommentLineView(commentScriptLine, linesContainer);
                break;

            case nameof(LabelScriptLine):
                var labelScriptLine = new LabelScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = new LabelLineView(labelScriptLine, linesContainer);
                break;

            case nameof(DefineScriptLine):
                var defineScriptLine = new DefineScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = new DefineLineView(defineScriptLine, linesContainer);
                break;

            case nameof(CommandScriptLine):
                var commandScriptLine = new CommandScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = CommandLineView.CreateOrError(commandScriptLine, linesContainer, config.HideUnusedParameters, @default);
                break;

            case nameof(GenericTextScriptLine):
                var genericTextScriptLine = new GenericTextScriptLine(null, lineIndex, scriptLineText, null, true);
                lineView = new GenericTextLineView(genericTextScriptLine, linesContainer);
                break;
            }
            return(lineView);
        }
Exemple #2
0
        private void ShowSearcher(Vector2 position, int insertIndex, int insertViewIndex)
        {
            SearcherWindow.Show(EditorWindow.focusedWindow, searchItems, "Insert Line", item => {
                if (item is null)
                {
                    return(true);              // Prevent nullref when focus is lost before item is selected.
                }
                var lineText = string.Empty;
                var lineView = default(ScriptLineView);
                switch (item.Name)
                {
                case "Commands": return(false);    // Do nothing.

                case "Comment": lineText = CommentScriptLine.IdentifierLiteral; break;

                case "Label": lineText = LabelScriptLine.IdentifierLiteral; break;

                case "Generic Text":
                    var genericTextScriptLine = new GenericTextScriptLine(null, -1, string.Empty, null, true);
                    lineView = new GenericTextLineView(genericTextScriptLine, linesContainer);
                    break;

                case "Define": lineText = DefineScriptLine.IdentifierLiteral; break;

                default: lineText = CommandScriptLine.IdentifierLiteral + item.Name; break;
                }
                if (lineView is null)
                {
                    lineView = CreateLineView(lineText, -1, true);
                }
                InsertLine(lineView, insertIndex, insertViewIndex);
                ScriptLineView.SetFocused(lineView);
                lineView.Q <TextField>().Q <VisualElement>(TextInputBaseField <string> .textInputUssName).Focus();
                return(true);
            }, position);
        }
 public GenericTextLineView(GenericTextScriptLine scriptLine, VisualElement container)
     : base(scriptLine, container)
 {
     valueField = new LineTextField(value: scriptLine.Text);
     Content.Add(valueField);
 }