Exemple #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);
        }
Exemple #2
0
        public static void LoadMacroFile(string filename)
        {
            var eReader = new EraStreamReader(false);

            if (!eReader.Open(filename))
            {
                return;
            }
            try
            {
                string line = null;
                while ((line = eReader.ReadLine()) != null)
                {
                    if (line.Length == 0 || line[0] == ';')
                    {
                        continue;
                    }
                    if (line.StartsWith(gID))
                    {
                        if (line.Length < gID.Length + 4)
                        {
                            continue;
                        }
                        var num = line[gID.Length] - '0';
                        if (num < 0 || num > 9)
                        {
                            continue;
                        }
                        if (line[gID.Length + 1] != ':')
                        {
                            continue;
                        }
                        groupName[num] = line.Substring(gID.Length + 2);
                    }
                    for (var i = 0; i < MaxMacro; i++)
                    {
                        if (line.StartsWith(macroName[i]))
                        {
                            macro[i] = line.Substring(macroName[i].Length);
                            break;
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                eReader.Dispose();
            }
        }
Exemple #3
0
        // 1.52a改変部分 (単位の差し替えおよび前置、後置のためのコンフィグ処理)
        public void LoadReplaceFile(string filename)
        {
            var eReader = new EraStreamReader(false);

            if (!eReader.Open(filename))
            {
                return;
            }
            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);
                    var tokens = line.Split(',', ':');
                    if (tokens.Length < 2)
                    {
                        continue;
                    }
                    var itemName = tokens[0].Trim();
                    tokens[1] = line.Substring(tokens[0].Length + 1);
                    if (string.IsNullOrEmpty(tokens[1].Trim()))
                    {
                        continue;
                    }
                    var item = GetReplaceItem(itemName);
                    if (item != null)
                    {
                        item.TryParse(tokens[1]);
                    }
                }
            }
            catch (EmueraException ee)
            {
                ParserMediator.Warn(ee.Message, pos, 1);
            }
            catch (Exception exc)
            {
                ParserMediator.Warn(exc.GetType() + ":" + exc.Message, pos, 1, exc.StackTrace);
            }
            finally
            {
                eReader.Dispose();
            }
        }
Exemple #4
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);
        }
Exemple #5
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);
        }