Esempio n. 1
0
 public static void Reset()
 {
     Process = null;
     ConstantData = null;
     GameBaseData = null;
     EMediator = null;
     VEvaluator = null;
     VariableData = null;
     Console = null;
     MainWindow = null;
     LabelDictionary = null;
     IdentifierDictionary = null;
     tempDic.Clear();
 }
Esempio n. 2
0
        public bool Initialize()
        {
            LexicalAnalyzer.UseMacro = false;
            state = new ProcessState(console);
            originalState = state;
            initialiing = true;
            try
            {
                ParserMediator.Initialize(console);
                if (ParserMediator.HasWarning)
                {
                    ParserMediator.FlushWarningList();
                    if (MessageBox.Show("コンフィグファイルに異常があります\nEmueraを終了しますか", "コンフィグエラー", MessageBoxButtons.YesNo)
                        == DialogResult.Yes)
                    {
                        console.PrintLine("コンフィグファイルに異常があり、終了が選択されたため処理を終了しました");
                        return false;
                    }
                }
                if (Config.UseKeyMacro && !Program.AnalysisMode)
                {
                    if (File.Exists(Program.ExeDir + "macro.txt"))
                    {
                        if (Config.DisplayReport)
                            console.PrintLine("macro.txt読み込み中・・・");
                        KeyMacro.LoadMacroFile(Program.ExeDir + "macro.txt");
                    }
                }
                if (Config.UseReplaceFile && !Program.AnalysisMode)
                {
                    if (File.Exists(Program.CsvDir + "_Replace.csv"))
                    {
                        if (Config.DisplayReport)
                            console.PrintLine("_Replace.csv読み込み中・・・");
                        ConfigData.Instance.LoadReplaceFile(Program.CsvDir + "_Replace.csv");
                        if (ParserMediator.HasWarning)
                        {
                            ParserMediator.FlushWarningList();
                            if (MessageBox.Show("_Replace.csvに異常があります\nEmueraを終了しますか", "_Replace.csvエラー", MessageBoxButtons.YesNo)
                                == DialogResult.Yes)
                            {
                                console.PrintLine("_Replace.csvに異常があり、終了が選択されたため処理を終了しました");
                                return false;
                            }
                        }
                    }
                }
                Config.SetReplace(ConfigData.Instance);
                //ここでBARを設定すれば、いいことに気づいた予感
                console.setStBar(Config.DrawLineString);

                if (Config.UseRenameFile)
                {
                    if (File.Exists(Program.CsvDir + "_Rename.csv"))
                    {
                        if (Config.DisplayReport || Program.AnalysisMode)
                            console.PrintLine("_Rename.csv読み込み中・・・");
                        ParserMediator.LoadEraExRenameFile(Program.CsvDir + "_Rename.csv");
                    }
                    else
                        console.PrintError("csv\\_Rename.csvが見つかりません");
                }
                if (!Config.DisplayReport)
                {
                    console.PrintLine(Config.LoadLabel);
                    console.RefreshStrings(true);
                }
                gamebase = new GameBase();
                gamebase.LoadGameBaseCsv(Program.CsvDir + "GAMEBASE.CSV");
                console.SetWindowTitle(gamebase.ScriptWindowTitle);
                GlobalStatic.GameBaseData = gamebase;

                ConstantData constant = new ConstantData(gamebase);
                constant.LoadData(Program.CsvDir, console, Config.DisplayReport);
                GlobalStatic.ConstantData = constant;
                TrainName = constant.GetCsvNameList(VariableCode.TRAINNAME);

                vEvaluator = new VariableEvaluator(gamebase, constant);
                GlobalStatic.VEvaluator = vEvaluator;

                idDic = new IdentifierDictionary(vEvaluator.VariableData);
                GlobalStatic.IdentifierDictionary = idDic;

                StrForm.Initialize();
                VariableParser.Initialize();

                exm = new ExpressionMediator(this, vEvaluator, console);
                GlobalStatic.EMediator = exm;

                labelDic = new LabelDictionary();
                GlobalStatic.LabelDictionary = labelDic;
                HeaderFileLoader hLoader = new HeaderFileLoader(console, idDic, this);

                LexicalAnalyzer.UseMacro = false;
                if (!hLoader.LoadHeaderFiles(Program.ErbDir, Config.DisplayReport))
                {
                    console.PrintLine("ERHの読み込み中にエラーが発生したため処理を終了しました");
                    return false;
                }
                LexicalAnalyzer.UseMacro = idDic.UseMacro();

                ErbLoader loader = new ErbLoader(console, exm, this);
                if (Program.AnalysisMode)
                    noError = loader.loadErbs(Program.AnalysisFiles, labelDic);
                else
                    noError = loader.LoadErbFiles(Program.ErbDir, Config.DisplayReport, labelDic);
                initSystemProcess();
                initialiing = false;
            }
            catch (Exception e)
            {
                handleException(e, null, true);
                console.PrintLine("初期化中に致命的なエラーが発生したため処理を終了しました");
                return false;
            }
            if (labelDic == null)
            {
                return false;
            }
            state.Begin(BeginType.TITLE);
            GC.Collect();
            return true;
        }
Esempio n. 3
0
        public ConstantData(GameBase gamebase)
        {
            this.gamebase = gamebase;
            setDefaultArrayLength();

            CharacterTmplList = new List<CharacterTemplate>();
            useCompatiName = Config.CompatiCALLNAME;
        }
Esempio n. 4
0
        private void toCharacterTemplate(GameBase gamebase, ScriptPosition position, CharacterTemplate chara, string[] tokens)
        {
            if (chara == null)
                return;
            int length = -1;
            Int64 p1 = -1;
            Int64 p2 = -1;
            Dictionary<int, Int64> intArray = null;
            Dictionary<int, string> strArray = null;
            Dictionary<string, int> namearray = null;

            string errPos = null;
            string varname = tokens[0].ToUpper();
            switch (varname)
            {
                case "NAME":
                case "名前":
                    chara.Name = tokens[1];
                    return;
                case "CALLNAME":
                case "呼び名":
                    chara.Callname = tokens[1];
                    return;
                case "NICKNAME":
                case "あだ名":
                    chara.Nickname = tokens[1];
                    return;
                case "MASTERNAME":
                case "主人の呼び方":
                    chara.Mastername = tokens[1];
                    return;
                case "MARK":
                case "刻印":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.MARK)];
                    intArray = chara.Mark;
                    namearray = nameToIntDics[markIndex];
                    errPos = "mark.csv";
                    break;
                case "EXP":
                case "経験":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.EXP)];
                    intArray = chara.Exp;
                    namearray = nameToIntDics[expIndex];//ExpName;
                    errPos = "exp.csv";
                    break;
                case "ABL":
                case "能力":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.ABL)];
                    intArray = chara.Abl;
                    namearray = nameToIntDics[ablIndex];//AblName;
                    errPos = "abl.csv";
                    break;
                case "BASE":
                case "基礎":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.MAXBASE)];
                    intArray = chara.Maxbase;
                    namearray = nameToIntDics[baseIndex];//BaseName;
                    errPos = "base.csv";
                    break;
                case "TALENT":
                case "素質":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.TALENT)];
                    intArray = chara.Talent;
                    namearray = nameToIntDics[talentIndex];//TalentName;
                    errPos = "talent.csv";
                    break;
                case "RELATION":
                case "相性":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.RELATION)];
                    intArray = chara.Relation;
                    namearray = null;
                    break;
                case "CFLAG":
                case "フラグ":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.CFLAG)];
                    intArray = chara.CFlag;
                    namearray = nameToIntDics[cflagIndex];//CFlagName;
                    errPos = "cflag.csv";
                    break;
                case "EQUIP":
                case "装着物":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.EQUIP)];
                    intArray = chara.Equip;
                    namearray = nameToIntDics[equipIndex];//EquipName;
                    errPos = "equip.csv";
                    break;
                case "JUEL":
                case "珠":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.JUEL)];
                    intArray = chara.Juel;
                    namearray = nameToIntDics[paramIndex];//ParamName;
                    errPos = "palam.csv";
                    break;
                case "CSTR":
                    length = CharacterStrArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.CSTR)];
                    strArray = chara.CStr;
                    namearray = nameToIntDics[cstrIndex];//CStrName;
                    errPos = "cstr.csv";
                    break;
                default:
                    ParserMediator.Warn("\"" + tokens[0] + "\"は解釈できない識別子です", position, 1);
                    return;
            }
            if (length < 0)
            {
                ParserMediator.Warn("プログラムミス", position, 3);
                return;
            }
            bool p1isNumeric = tryToInt64(tokens[1].TrimEnd(), out p1);
            if (p1isNumeric && ((p1 < 0) || (p1 >= length)))
            {
                ParserMediator.Warn(p1.ToString() + "は配列の範囲外です", position, 1);
                return;
            }
            int index = (int)p1;
            if ((!p1isNumeric) && (namearray != null))
            {
                if (!namearray.TryGetValue(tokens[1], out index))
                {
                    ParserMediator.Warn(errPos + "に\"" + tokens[1] + "\"の定義がありません", position, 1);
                    //ParserMediator.Warn("\"" + tokens[1] + "\"は解釈できない識別子です", position, 1);
                    return;
                }
                else if (index >= length)
                {
                    ParserMediator.Warn("\"" + tokens[1] + "\"は配列の範囲外です", position, 1);
                    return;
                }
            }

            if ((index < 0) || (index >= length))
            {
                if (p1isNumeric)
                    ParserMediator.Warn(index.ToString() + "は配列の範囲外です", position, 1);
                else if (tokens[1].Length == 0)
                    ParserMediator.Warn("二つ目の識別子がありません", position, 1);
                else
                    ParserMediator.Warn("\"" + tokens[1] + "\"は解釈できない識別子です", position, 1);
                return;
            }
            if (strArray != null)
            {
                if (tokens.Length < 3)
                    ParserMediator.Warn("三つ目の識別子がありません", position, 1);
                if (strArray.ContainsKey(index))
                    ParserMediator.Warn(varname + "の" + index.ToString() + "番目の要素は既に定義されています(上書きします)", position, 1);
                strArray[index] = tokens[2];
            }
            else
            {
                if ((tokens.Length < 3) || !tryToInt64(tokens[2], out p2))
                    p2 = 1;
                if (intArray.ContainsKey(index))
                    ParserMediator.Warn(varname + "の" + index.ToString() + "番目の要素は既に定義されています(上書きします)", position, 1);
                intArray[index] = p2;
            }
        }