Example #1
0
        public bool LoadDebugConfig()
        {
            if (!File.Exists(configdebugPath))
            {
                goto err;
            }
            EraStreamReader eReader = new EraStreamReader(false);

            if (!eReader.Open(configdebugPath))
            {
                goto err;
            }
            ScriptPosition pos = null;

            try
            {
                string line = null;
                while ((line = eReader.ReadLine()) != null)
                {
                    if ((line.Length == 0) || (line[0] == ';'))
                    {
                        continue;
                    }
                    pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line);
                    string[] tokens = line.Split(new char[] { ':' });
                    if (tokens.Length < 2)
                    {
                        continue;
                    }
                    AConfigItem item = GetDebugItem(tokens[0].Trim());
                    if (item != null)
                    {
                        item.TryParse(tokens[1]);
                    }
#if UEMUERA_DEBUG
                    //else
                    //	throw new Exception("コンフィグファイルが変");
#endif
                }
            }
            catch (EmueraException ee)
            {
                ParserMediator.ConfigWarn(ee.Message, pos, 1, null);
                goto err;
            }
            catch (Exception exc)
            {
                ParserMediator.ConfigWarn(exc.GetType().ToString() + ":" + exc.Message, pos, 1, exc.StackTrace);
                goto err;
            }
            finally { eReader.Dispose(); }
            Config.SetDebugConfig(this);
            return(true);

err:
            Config.SetDebugConfig(this);
            return(false);
        }
Example #2
0
        private bool loadConfig(string confPath, bool fix)
        {
            if (!File.Exists(confPath))
            {
                return(false);
            }
            EraStreamReader eReader = new EraStreamReader(false);

            if (!eReader.Open(confPath))
            {
                return(false);
            }

            //加载二进制数据
            var bytes = File.ReadAllBytes(confPath);
            var md5s  = GenericUtils.CalcMd5ListForConfig(bytes);

            ScriptPosition pos  = null;
            int            md5i = 0;

            try
            {
                string line = null;
                //bool defineIgnoreWarningFiles = false;
                while ((line = eReader.ReadLine()) != null)
                {
                    var md5 = md5s[md5i++];
                    if ((line.Length == 0) || (line[0] == ';'))
                    {
                        continue;
                    }
                    pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line);
                    string[] tokens = line.Split(new char[] { ':' });
                    if (tokens.Length < 2)
                    {
                        continue;
                    }
                    var         token_0 = tokens[0].Trim();
                    AConfigItem item    = GetConfigItem(token_0);
                    if (item == null)
                    {
                        token_0 = uEmuera.Utils.SHIFTJIS_to_UTF8(token_0, md5);
                        if (!string.IsNullOrEmpty(token_0))
                        {
                            item = GetConfigItem(token_0);
                        }
                    }
                    if (item != null)
                    {
                        //1806beta001 CompatiDRAWLINEの廃止、CompatiLinefeedAs1739へ移行
                        if (item.Code == ConfigCode.CompatiDRAWLINE)
                        {
                            item = GetConfigItem(ConfigCode.CompatiLinefeedAs1739);
                        }
                        //if ((item.Code == ConfigCode.IgnoreWarningFiles))
                        //{
                        //    if (!defineIgnoreWarningFiles)
                        //        (item.GetValue<List<string>>()).Clear();
                        //    defineIgnoreWarningFiles = true;
                        //    if ((item.Fixed) && (fix))
                        //        item.Fixed = false;
                        //}

                        if (item.Code == ConfigCode.TextEditor)
                        {
                            //パスの関係上tokens[2]は使わないといけない
                            if (tokens.Length > 2)
                            {
                                if (tokens[2].StartsWith("\\"))
                                {
                                    tokens[1] += ":" + tokens[2];
                                }
                                if (tokens.Length > 3)
                                {
                                    for (int i = 3; i < tokens.Length; i++)
                                    {
                                        tokens[1] += ":" + tokens[i];
                                    }
                                }
                            }
                        }
                        if (item.Code == ConfigCode.EditorArgument)
                        {
                            //半角スペースを要求する引数が必要なエディタがあるので別処理で
                            ((ConfigItem <string>)item).Value = tokens[1];
                            continue;
                        }
                        if (item.Code == ConfigCode.MaxLog && Program.AnalysisMode)
                        {
                            //解析モード時はここを上書きして十分な長さを確保する
                            tokens[1] = "10000";
                        }
                        if ((item.TryParse(tokens[1])) && (fix))
                        {
                            item.Fixed = true;
                        }
                    }
#if UEMUERA_DEBUG
                    //else
                    //	throw new Exception("コンフィグファイルが変");
#endif
                }
            }
            catch (EmueraException ee)
            {
                ParserMediator.ConfigWarn(ee.Message, pos, 1, null);
            }
            catch (Exception exc)
            {
                ParserMediator.ConfigWarn(exc.GetType().ToString() + ":" + exc.Message, pos, 1, exc.StackTrace);
            }
            finally { eReader.Dispose(); }
            return(true);
        }
Example #3
0
        private bool loadConfig(string confPath, bool fix)
        {
            if (!File.Exists(confPath))
            {
                return(false);
            }
            var eReader = new EraStreamReader(false);

            if (!eReader.Open(confPath))
            {
                return(false);
            }
            ScriptPosition pos = null;

            try
            {
                string line = null;
                //bool defineIgnoreWarningFiles = false;
                while ((line = eReader.ReadLine()) != null)
                {
                    if (line.Length == 0 || line[0] == ';')
                    {
                        continue;
                    }
                    pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line);
                    var tokens = line.Split(':');
                    if (tokens.Length < 2)
                    {
                        continue;
                    }
                    var item = GetConfigItem(tokens[0].Trim());
                    if (item != null)
                    {
                        //1806beta001 CompatiDRAWLINEの廃止、CompatiLinefeedAs1739へ移行
                        if (item.Code == ConfigCode.CompatiDRAWLINE)
                        {
                            item = GetConfigItem(ConfigCode.CompatiLinefeedAs1739);
                        }
                        //if ((item.Code == ConfigCode.IgnoreWarningFiles))
                        //{
                        //    if (!defineIgnoreWarningFiles)
                        //        (item.GetValue<List<string>>()).Clear();
                        //    defineIgnoreWarningFiles = true;
                        //    if ((item.Fixed) && (fix))
                        //        item.Fixed = false;
                        //}

                        if (item.Code == ConfigCode.TextEditor)
                        {
                            if (tokens.Length > 2)
                            {
                                if (tokens[2].StartsWith("\\"))
                                {
                                    tokens[1] += ":" + tokens[2];
                                }
                                if (tokens.Length > 3)
                                {
                                    for (var i = 3; i < tokens.Length; i++)
                                    {
                                        tokens[1] += ":" + tokens[i];
                                    }
                                }
                            }
                        }
                        if (item.Code == ConfigCode.EditorArgument)
                        {
                            //半角スペースを要求する引数が必要なエディタがあるので別処理で
                            ((ConfigItem <string>)item).Value = tokens[1];
                            continue;
                        }
                        if (item.TryParse(tokens[1]) && fix)
                        {
                            item.Fixed = true;
                        }
                    }
#if DEBUG
                    //else
                    //	throw new Exception("コンフィグファイルが変");
#endif
                }
            }
            catch (EmueraException ee)
            {
                ParserMediator.ConfigWarn(ee.Message, pos, 1, null);
            }
            catch (Exception exc)
            {
                ParserMediator.ConfigWarn(exc.GetType() + ":" + exc.Message, pos, 1, exc.StackTrace);
            }
            finally
            {
                eReader.Dispose();
            }
            return(true);
        }