Пример #1
0
 public ScriptDlg(Script scr, AdvData data)
 {
     mData   = data;
     mScript = scr;
     InitializeComponent();
     int[] tabs = { 20, 40, 60, 80, 100, 120, 140 };
     scripttext.SelectionTabs      = tabs;
     linenumberbox.Paint          += new PaintEventHandler(linenumberbox_Paint);
     scripttext.VScroll           += new EventHandler(scripttext_VScroll);
     scripttext.TextChanged       += new EventHandler(scripttext_TextChanged);
     scripttext.MouseDown         += new MouseEventHandler(scripttext_MouseDown);
     scripttext.KeyUp             += new KeyEventHandler(scripttext_KeyUp);
     scripttext.KeyDown           += new KeyEventHandler(scripttext_KeyDown);
     matches.SelectedIndexChanged += new EventHandler(matches_SelectedIndexChanged);
     this.FormClosed += new FormClosedEventHandler(ScriptDlg_FormClosed);
     //scripttext
     updateScript();
     //parsing stuff
     mParser = new PcdkParser(data.Settings.ScriptingLanguage);
     mParser.initSyntax();
     mParser.Comment    += new PcdkParser.commentCB(colorComment);
     mParser.Function   += new PcdkParser.functionCB(colorFunction);
     mParser.ParseError += new PcdkParser.parseError(mParser_ParseError);
     mKeywordFont        = new Font(scripttext.Font, FontStyle.Bold);
     parseScript();
     if (!mHistory.Contains(scr))
     {
         if (mHistory.Count > 4)
         {
             mHistory.RemoveAt(4);
         }
         mHistory.Insert(0, scr);
     }
     else
     {
         mHistory.Remove(scr);
         mHistory.Insert(0, scr);
     }
 }
Пример #2
0
 public ScriptDlg(Script scr, AdvData data)
 {
     mData = data;
     mScript = scr;
     InitializeComponent();
     int[] tabs = { 20, 40, 60, 80, 100, 120, 140 };
     scripttext.SelectionTabs = tabs;
     linenumberbox.Paint += new PaintEventHandler(linenumberbox_Paint);
     scripttext.VScroll += new EventHandler(scripttext_VScroll);
     scripttext.TextChanged += new EventHandler(scripttext_TextChanged);
     scripttext.MouseDown += new MouseEventHandler(scripttext_MouseDown);
     scripttext.KeyUp += new KeyEventHandler(scripttext_KeyUp);
     scripttext.KeyDown += new KeyEventHandler(scripttext_KeyDown);
     matches.SelectedIndexChanged += new EventHandler(matches_SelectedIndexChanged);
     this.FormClosed += new FormClosedEventHandler(ScriptDlg_FormClosed);
     //scripttext
     updateScript();
     //parsing stuff
     mParser = new PcdkParser(data.Settings.ScriptingLanguage);
     mParser.initSyntax();
     mParser.Comment += new PcdkParser.commentCB(colorComment);
     mParser.Function += new PcdkParser.functionCB(colorFunction);
     mParser.ParseError += new PcdkParser.parseError(mParser_ParseError);
     mKeywordFont = new Font(scripttext.Font, FontStyle.Bold);
     parseScript();
     if (!mHistory.Contains(scr))
     {
         if (mHistory.Count > 4)
             mHistory.RemoveAt(4);
         mHistory.Insert(0, scr);
     }
     else
     {
         mHistory.Remove(scr);
         mHistory.Insert(0, scr);
     }
 }
Пример #3
0
 void parser_Function(PcdkParser.Argument funcname, object[] args, int startidx)
 {
     if (funcname.Text == "speech")
     {
         PcdkParser.Argument text = (PcdkParser.Argument)args[1];
         string voice = "";
         if (args.Length > 2)
         {
             PcdkParser.Argument voicearg = (PcdkParser.Argument)args[2];
             if (voicearg.Text != "dontwait")
                 voice = voicearg.Text;
         }
         mLanguages["origin"].addWord(Language.Section.Speech, text.Text, voice);
         return;
     }
     else if (funcname.Text == "offspeech")
     {
         PcdkParser.Argument text = (PcdkParser.Argument)args[2];
         string voice = "";
         if (args.Length > 3)
         {
             PcdkParser.Argument voicearg = (PcdkParser.Argument)args[3];
             if (voicearg.Text != "dontwait")
                 voice = voicearg.Text;
         }
         mLanguages["origin"].addWord(Language.Section.Offspeech, text.Text, voice);
         return;
     }
     else if (funcname.Text == "showinfo")
     {
         PcdkParser.Argument text = (PcdkParser.Argument)args[0];
         mLanguages["origin"].addWord(Language.Section.Showinfo, text.Text, null);
     }
     else if (funcname.Text == "textout")
     {
         if (args.Length > 1)
         {
             PcdkParser.Argument text = (PcdkParser.Argument)args[1];
             mLanguages["origin"].addWord(Language.Section.Textout, text.Text, null);
         }
     }
     else if (funcname.Text == "setstring")
     {
         PcdkParser.Argument text = (PcdkParser.Argument)args[1];
         mLanguages["origin"].addWord(Language.Section.Setstring, text.Text, null);
     }
     else if (funcname.Text == "row")
     {
         PcdkParser.Argument text = (PcdkParser.Argument)args[1];
         mLanguages["origin"].addWord(Language.Section.Textscenes, text.Text, null);
     }
 }
Пример #4
0
        public void updateLanguageList()
        {
            PcdkParser parser = new PcdkParser(Settings.ScriptingLanguage);
            parser.initSyntax();
            parser.Function += new PcdkParser.functionCB(parser_Function);

            Language.beginRefresh();
            foreach (Dictionary<string, Script> scripts in mScripts)
            {
                foreach (KeyValuePair<string, Script> pair in scripts)
                {
                    parser.parseText(pair.Value.Text);
                }
            }
            mLanguages["origin"].addWord(Language.Section.Commands, Settings.WalkText, null);
            mLanguages["origin"].addWord(Language.Section.Commands, Settings.LinkText, null);
            mLanguages["origin"].addWord(Language.Section.Commands, Settings.GiveLink, null);
            foreach (KeyValuePair<string,string> pair in Settings.Commands){
                mLanguages["origin"].addWord(Language.Section.Commands, pair.Value, null);
            }
            Language.endRefresh(this);
        }
Пример #5
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);
            }
        }
Пример #6
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;
     }
 }
Пример #7
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);
     }
 }