Esempio n. 1
0
 void colorFunction(PcdkParser.Argument funcname, Object[] args, int startidx)
 {
     scripttext.SelectionStart  = startidx + funcname.Startidx;
     scripttext.SelectionLength = funcname.Stopidx - funcname.Startidx;
     scripttext.SelectionFont   = mKeywordFont;
     if (mParser.IsKeyword(funcname))
     {
         scripttext.SelectionColor = Color.Blue;
     }
     else
     {
         scripttext.SelectionColor = Color.Black;
     }
     if (scripttext.SelectionStart <= mCursorPos && scripttext.SelectionStart + scripttext.SelectionLength >= mCursorPos)
     {
         fillMatchList(funcname);
     }
     foreach (PcdkParser.Argument arg in args)
     {
         scripttext.SelectionStart  = startidx + arg.Startidx;
         scripttext.SelectionLength = arg.Stopidx - arg.Startidx;
         scripttext.SelectionFont   = scripttext.Font;
         scripttext.SelectionColor  = Color.Brown;
         if (scripttext.SelectionStart <= mCursorPos && scripttext.SelectionStart + scripttext.SelectionLength >= mCursorPos)
         {
             fillMatchList(arg);
         }
     }
 }
Esempio n. 2
0
 void mParser_ParseError(int charpos, int length, string text, PcdkParser.Error error)
 {
     scripttext.SelectionStart  = charpos;
     scripttext.SelectionLength = length;
     scripttext.SelectionColor  = Color.Black;
     if (error == PcdkParser.Error.LINE_NOT_RECOGINZED)
     {
         for (int i = text.Length - 1; i >= 0; --i)
         {
             if (text[i] == ' ')
             {
                 text = text.Substring(i);
                 scripttext.SelectionStart  = charpos + i;
                 scripttext.SelectionLength = length - i;
                 break;
             }
         }
         PcdkParser.Argument arg = new PcdkParser.Argument(charpos, charpos + length, text.Trim(),
                                                           new PcdkParser.ArgDef("Command", PcdkParser.ArgType.Function));
         if (mParser.IsKeyword(arg))
         {
             scripttext.SelectionColor = Color.Blue;
         }
         scripttext.SelectionFont = mKeywordFont;
         fillMatchList(arg);
     }
 }
Esempio n. 3
0
        void fillMatchList(PcdkParser.Argument arg)
        {
            info.Text = arg.Definition.Name;
            int length = mCursorPos - scripttext.SelectionStart;

            if (length < 0)
            {
                length = 0;
            }
            string match = scripttext.Text.Substring(scripttext.SelectionStart, length).Trim();

            matches.Items.Clear();
            if (arg.Definition.AdditionalValues != null)
            {
                foreach (string val in arg.Definition.AdditionalValues)
                {
                    addMatch(val, match);
                }
            }
            switch (arg.Definition.Type)
            {
            case PcdkParser.ArgType.Boolean:
                addMatch("true", match);
                addMatch("false", match);
                break;

            case PcdkParser.ArgType.Character:
                addMatch("self", match);
                foreach (KeyValuePair <string, ArrayList> pair in mData.CharacterInstances)
                {
                    foreach (CharacterInstance chr in pair.Value)
                    {
                        addMatch(chr.Name, match);
                    }
                }
                break;

            case PcdkParser.ArgType.Command:
                foreach (KeyValuePair <string, string> pair in mData.Settings.Commands)
                {
                    addMatch(pair.Key, match);
                }
                break;

            case PcdkParser.ArgType.Event:
            {
                foreach (KeyValuePair <string, string> pair in mData.Settings.Commands)
                {
                    addMatch(pair.Key, match);
                    addMatch("cant" + pair.Key, match);
                }
                break;
            }

            case PcdkParser.ArgType.Function:
                foreach (KeyValuePair <string, PcdkParser.ArgDef[]> func in mParser.Functions)
                {
                    addMatch(func.Key, match);
                }
                break;

            case PcdkParser.ArgType.Item:
                foreach (KeyValuePair <string, Item> it in mData.Items)
                {
                    addMatch(it.Value.Name, match);
                }
                break;

            case PcdkParser.ArgType.Music:
                foreach (KeyValuePair <string, string> music in mData.Music)
                {
                    addMatch(music.Key, match);
                }
                break;

            case PcdkParser.ArgType.Object:
                foreach (KeyValuePair <string, Room> room in mData.Rooms)
                {
                    foreach (ObjectInstance obj in room.Value.Objects)
                    {
                        addMatch(obj.Name, match);
                    }
                }
                break;

            case PcdkParser.ArgType.PresetVariable:
                foreach (KeyValuePair <string, bool> bov in mData.Settings.Booleans)
                {
                    addMatch(bov.Key, match);
                }
                break;

            case PcdkParser.ArgType.Room:
                foreach (KeyValuePair <string, Room> room in mData.Rooms)
                {
                    addMatch(room.Value.Name, match);
                }
                break;

            case PcdkParser.ArgType.Script:
                foreach (KeyValuePair <string, Script> scr in mData.getScripts(Script.Type.CUTSCENE))
                {
                    addMatch(scr.Value.Name, match);
                }
                break;

            case PcdkParser.ArgType.Sound:
                foreach (KeyValuePair <string, string> snd in mData.Sounds)
                {
                    addMatch(snd.Key, match);
                }
                break;

            case PcdkParser.ArgType.Video:
                foreach (KeyValuePair <string, string> video in mData.Videos)
                {
                    if (System.IO.Path.GetExtension(video.Value) != ".swf")
                    {
                        addMatch(video.Key, match);
                    }
                }
                break;

            case PcdkParser.ArgType.VideoSwf:
                foreach (KeyValuePair <string, string> video in mData.Videos)
                {
                    if (System.IO.Path.GetExtension(video.Value) == ".swf")
                    {
                        addMatch(video.Key, match);
                    }
                }
                break;

            case PcdkParser.ArgType.Language:
                foreach (KeyValuePair <string, Language> lang in mData.Languages)
                {
                    addMatch(lang.Key, match);
                }
                break;

            case PcdkParser.ArgType.DSPEffect:
                foreach (DSPEffect effect in mData.Settings.DSPEffects)
                {
                    addMatch(effect.name, match);
                }
                addMatch("off", match);
                break;
            }
        }
Esempio n. 4
0
        void mParser_ParseError(int charpos, int length, string text, PcdkParser.Error error)
        {
            scripttext.SelectionStart = charpos;
            scripttext.SelectionLength = length;
            scripttext.SelectionColor = Color.Black;
            if (error == PcdkParser.Error.LINE_NOT_RECOGINZED)
            {
                for (int i = text.Length - 1; i >= 0; --i)
                {
                    if (text[i] == ' ')
                    {
                        text = text.Substring(i);
                        scripttext.SelectionStart = charpos+i;
                        scripttext.SelectionLength = length-i;
                        break;
                    }

                }
                PcdkParser.Argument arg = new PcdkParser.Argument(charpos, charpos + length, text.Trim(),
                new PcdkParser.ArgDef("Command", PcdkParser.ArgType.Function));
                if (mParser.IsKeyword(arg))
                    scripttext.SelectionColor = Color.Blue;
                scripttext.SelectionFont = mKeywordFont;
                fillMatchList(arg);
            }
        }