コード例 #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);
        }
コード例 #2
0
        public ScriptLineView CreateLineView(int lineIndex, string lineText)
        {
            tokens.Clear();
            var lineType = lexer.TokenizeLine(lineText, tokens);
            var lineView = default(ScriptLineView);

            switch (lineType)
            {
            case LineType.Comment:
                lineView = new CommentLineView(lineIndex, lineText, linesContainer);
                break;

            case LineType.Label:
                lineView = new LabelLineView(lineIndex, lineText, linesContainer);
                break;

            case LineType.Command:
                lineView = CommandLineView.CreateOrError(lineIndex, lineText, tokens, linesContainer, config.HideUnusedParameters);
                break;

            default:
                lineView = new GenericTextLineView(lineIndex, lineText, linesContainer);
                break;
            }
            return(lineView);
        }
コード例 #3
0
        public ScriptLineView CreateLineView(int lineIndex, string lineText)
        {
            var lineView = default(ScriptLineView);

            switch (Script.ResolveLineType(lineText?.TrimFull()).Name)
            {
            case nameof(CommentScriptLine):
                lineView = new CommentLineView(lineIndex, lineText, linesContainer);
                break;

            case nameof(LabelScriptLine):
                lineView = new LabelLineView(lineIndex, lineText, linesContainer);
                break;

            case nameof(CommandScriptLine):
                lineView = CommandLineView.CreateOrError(lineIndex, lineText, linesContainer, config.HideUnusedParameters);
                break;

            case nameof(GenericTextScriptLine):
                lineView = new GenericTextLineView(lineIndex, lineText, linesContainer);
                break;
            }
            return(lineView);
        }
コード例 #4
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);
        }