public void LoadSkillText(string text)
 {
     Dsl.DslFile dataFile = new Dsl.DslFile();
     #if DEBUG
     try {
         if (dataFile.LoadFromString(text, "skill", LogSystem.Log)) {
             Load(dataFile);
         } else {
             LogSystem.Error("LoadSkillText text:{0} failed", text);
         }
     } catch (Exception ex) {
         LogSystem.Error("LoadSkillText text:{0} Exception:{1}\n{2}", text, ex.Message, ex.StackTrace);
     }
     #else
       try {
     dataFile.LoadBinaryCode(text, GlobalVariables.Instance.DecodeTable);
     Load(dataFile);
       } catch {
       }
     #endif
 }
예제 #2
0
        public static Dsl.DslFile LoadStoryText(string text)
        {
#if DEBUG
            try {
                Dsl.DslFile dataFile = new Dsl.DslFile();
                if (dataFile.LoadFromString(text, "storytext", LogSystem.Log))
                {
                    return(dataFile);
                }
                else
                {
                    LogSystem.Error("LoadStoryText text:{0} failed", text);
                }
            } catch (Exception ex) {
                LogSystem.Error("LoadStoryText text:{0} Exception:{1}\n{2}", text, ex.Message, ex.StackTrace);
            }
            return(null);
#else
            return(LoadStoryCode(text));
#endif
        }
 public static Dsl.DslFile LoadStoryText(string file, byte[] bytes)
 {
     if (Dsl.DslFile.IsBinaryDsl(bytes, 0))
     {
         try {
             Dsl.DslFile dataFile = new Dsl.DslFile();
             dataFile.LoadBinaryCode(bytes);
             return(dataFile);
         }
         catch (Exception ex) {
             var sb = new System.Text.StringBuilder();
             sb.AppendFormat("[LoadStory] LoadStoryText file:{0} Exception:{1}\n{2}", file, ex.Message, ex.StackTrace);
             sb.AppendLine();
             Helper.LogInnerException(ex, sb);
             LogSystem.Error("{0}", sb.ToString());
         }
     }
     else
     {
         string text = Converter.FileContent2Utf8String(bytes);
         try {
             Dsl.DslFile dataFile = new Dsl.DslFile();
             if (dataFile.LoadFromString(text, file, LogSystem.Log))
             {
                 return(dataFile);
             }
             else
             {
                 LogSystem.Error("LoadStoryText file:{0} failed", file);
             }
         } catch (Exception ex) {
             var sb = new System.Text.StringBuilder();
             sb.AppendFormat("[LoadStory] LoadStoryText file:{0} Exception:{1}\n{2}", file, ex.Message, ex.StackTrace);
             sb.AppendLine();
             Helper.LogInnerException(ex, sb);
             LogSystem.Error("{0}", sb.ToString());
         }
     }
     return(null);
 }
 public void LoadStoryText(string file, byte[] bytes, int sceneId, string _namespace)
 {
     if (Dsl.DslFile.IsBinaryDsl(bytes, 0))
     {
         try {
             Dsl.DslFile dataFile = new Dsl.DslFile();
             dataFile.LoadBinaryCode(bytes);
             Load(dataFile, sceneId, _namespace, file);
         }
         catch (Exception ex) {
             var sb = new System.Text.StringBuilder();
             sb.AppendFormat("[LoadStory] LoadStoryText file:{0} scene:{1} Exception:{2}\n{3}", file, sceneId, ex.Message, ex.StackTrace);
             sb.AppendLine();
             Helper.LogInnerException(ex, sb);
             LogSystem.Error("{0}", sb.ToString());
         }
     }
     else
     {
         try {
             string      text     = Converter.FileContent2Utf8String(bytes);
             Dsl.DslFile dataFile = new Dsl.DslFile();
             if (dataFile.LoadFromString(text, file, LogSystem.Log))
             {
                 Load(dataFile, sceneId, _namespace, file);
             }
             else
             {
                 LogSystem.Error("[LoadStory] LoadStoryText file:{0} scene:{1} failed", file, sceneId);
             }
         }
         catch (Exception ex) {
             var sb = new System.Text.StringBuilder();
             sb.AppendFormat("[LoadStory] LoadStoryText file:{0} scene:{1} Exception:{2}\n{3}", file, sceneId, ex.Message, ex.StackTrace);
             sb.AppendLine();
             Helper.LogInnerException(ex, sb);
             LogSystem.Error("{0}", sb.ToString());
         }
     }
 }
 public void LoadStoryText(string file, byte[] bytes, int sceneId, string _namespace)
 {
     if (Dsl.DslFile.IsBinaryDsl(bytes, 0))
     {
         try {
             Dsl.DslFile dataFile = new Dsl.DslFile();
             dataFile.LoadBinaryCode(bytes);
             Load(dataFile, sceneId, _namespace, file);
         } catch (Exception ex) {
             while (null != ex.InnerException)
             {
                 ex = ex.InnerException;
             }
             LogSystem.Error("[LoadStory] LoadStoryText text:{0} scene:{1} Exception:{2}\n{3}", file, sceneId, ex.Message, ex.StackTrace);
         }
     }
     else
     {
         try {
             string      text     = Converter.FileContent2Utf8String(bytes);
             Dsl.DslFile dataFile = new Dsl.DslFile();
             if (dataFile.LoadFromString(text, file, LogSystem.Log))
             {
                 Load(dataFile, sceneId, _namespace, file);
             }
             else
             {
                 LogSystem.Error("[LoadStory] LoadStoryText text:{0} scene:{1} failed", file, sceneId);
             }
         } catch (Exception ex) {
             while (null != ex.InnerException)
             {
                 ex = ex.InnerException;
             }
             LogSystem.Error("[LoadStory] LoadStoryText text:{0} scene:{1} Exception:{2}\n{3}", file, sceneId, ex.Message, ex.StackTrace);
         }
     }
 }
예제 #6
0
        internal bool Compile(string txt)
        {
            bool ret = false;

            if (!txt.EndsWith(";"))
            {
                txt = txt + ";";
            }
            var err = new StringBuilder();

            Dsl.DslFile file = new Dsl.DslFile();
            if (file.LoadFromString(txt, "expression", (msg) => { err.AppendLine(msg); }))
            {
                int count = file.DslInfos.Count;
                for (int i = 0; i < count; ++i)
                {
                    var func = file.DslInfos[i] as Dsl.FunctionData;
                    if (null != func && func.IsHighOrder)
                    {
                        var    codes = new List <Instruction>();
                        string name  = func.LowerOrderFunction.GetParamId(0);
                        CompileSyntaxComponent(func, codes, err);
                        int proc = GetApiOrProcId(name);
                        m_Procs[proc] = codes;
                    }
                }
            }
            if (err.Length <= 0)
            {
                ret = true;
            }
            else
            {
                Console.WriteLine(err.ToString());
            }
            return(ret);
        }
        public void LoadSkillText(int id, string text)
        {
            Dsl.DslFile dataFile = new Dsl.DslFile();
#if DEBUG
            try {
                if (dataFile.LoadFromString(text, "skill", LogSystem.Log))
                {
                    Load(id, dataFile);
                }
                else
                {
                    LogSystem.Error("LoadSkillText text:{0} failed", text);
                }
            } catch (Exception ex) {
                LogSystem.Error("LoadSkillText text:{0} Exception:{1}\n{2}", text, ex.Message, ex.StackTrace);
            }
#else
            try {
                dataFile.LoadBinaryCode(text, GlobalVariables.Instance.DecodeTable);
                Load(id, dataFile);
            } catch {
            }
#endif
        }
        public void LoadSkillText(int id, string text)
        {
            Dsl.DslFile dataFile = new Dsl.DslFile();
#if DEBUG
            try {
                if (dataFile.LoadFromString(text, "skill", LogSystem.Log))
                {
                    Load(id, dataFile);
                }
                else
                {
                    LogSystem.Error("LoadSkillText text:{0} failed", text);
                }
            } catch (Exception ex) {
                LogSystem.Error("LoadSkillText text:{0} Exception:{1}\n{2}", text, ex.Message, ex.StackTrace);
            }
#else
            try {
                dataFile.LoadBinaryCode(System.Text.Encoding.UTF8.GetBytes(text));
                Load(id, dataFile);
            } catch {
            }
#endif
        }
 public void LoadStoryText(string text, int sceneId, string _namespace)
 {
     #if DEBUG
     try {
         Dsl.DslFile dataFile = new Dsl.DslFile();
         if (dataFile.LoadFromString(text, "storytext", LogSystem.Log)) {
             Load(dataFile, sceneId, _namespace, "storytext");
         } else {
             LogSystem.Error("LoadStoryText text:{0} scene:{1} failed", text, sceneId);
         }
     } catch (Exception ex) {
         LogSystem.Error("LoadStoryText text:{0} scene:{1} Exception:{2}\n{3}", text, sceneId, ex.Message, ex.StackTrace);
     }
     #else
       LoadStoryCode(text, sceneId, _namespace);
     #endif
 }
 public static Dsl.DslFile LoadStoryText(string text)
 {
     #if DEBUG
     try {
         Dsl.DslFile dataFile = new Dsl.DslFile();
         if (dataFile.LoadFromString(text, "storytext", LogSystem.Log)) {
             return dataFile;
         } else {
             LogSystem.Error("LoadStoryText text:{0} failed", text);
         }
     } catch (Exception ex) {
         LogSystem.Error("LoadStoryText text:{0} Exception:{1}\n{2}", text, ex.Message, ex.StackTrace);
     }
     return null;
     #else
     return LoadStoryCode(text);
     #endif
 }