Beispiel #1
0
 private void loadCharacterDataFile(string csvPath, string csvName, bool disp)
 {
     CharacterTemplate tmpl = null;
     EraStreamReader eReader = new EraStreamReader();
     if (!eReader.Open(csvPath, csvName))
     {
         output.PrintError(eReader.Filename + "のオープンに失敗しました");
         return;
     }
     ScriptPosition position = null;
     if (disp)
         output.PrintLine(eReader.Filename + "読み込み中・・・");
     try
     {
         Int64 index = -1;
         StringStream st = null;
         while ((st = eReader.ReadEnabledLine()) != null)
         {
             position = new ScriptPosition(eReader.Filename, eReader.LineNo, st.RowString);
             string[] tokens = st.Substring().Split(',');
             if (tokens.Length < 2)
             {
                 ParserMediator.Warn("\",\"が必要です", position, 1);
                 continue;
             }
             if (tokens[0].Length == 0)
             {
                 ParserMediator.Warn("\",\"で始まっています", position, 1);
                 continue;
             }
             if ((tokens[0].Equals("NO", Config.SCVariable))
                 || (tokens[0].Equals("番号", Config.SCVariable)))
             {
                 if (tmpl != null)
                 {
                     ParserMediator.Warn("番号が二重に定義されました", position, 1);
                     continue;
                 }
                 if (!Int64.TryParse(tokens[1].TrimEnd(), out index))
                 {
                     ParserMediator.Warn(tokens[1] + "を整数値に変換できません", position, 1);
                     continue;
                 }
                 tmpl = new CharacterTemplate(index, this);
                 string no = eReader.Filename.ToUpper();
                 no = no.Substring(no.IndexOf("CHARA") + 5);
                 StringBuilder sb = new StringBuilder();
                 StringStream ss = new StringStream(no);
                 while (!ss.EOS && char.IsDigit(ss.Current))
                 {
                     sb.Append(ss.Current);
                     ss.ShiftNext();
                 }
                 if (sb.Length > 0)
                     tmpl.csvNo = Convert.ToInt64(sb.ToString());
                 else
                     tmpl.csvNo = 0;
                 //tmpl.csvNo = index;
                 CharacterTmplList.Add(tmpl);
                 continue;
             }
             if (tmpl == null)
             {
                 ParserMediator.Warn("番号が定義される前に他のデータが始まりました", position, 1);
                 continue;
             }
             toCharacterTemplate(gamebase, position, tmpl, tokens);
         }
     }
     catch
     {
         System.Media.SystemSounds.Hand.Play();
         if (position != null)
             ParserMediator.Warn("予期しないエラーが発生しました", position, 3);
         else
             output.PrintError("予期しないエラーが発生しました");
         return;
     }
     finally
     {
         eReader.Dispose();
     }
 }
Beispiel #2
0
 public static void LoadMacroFile(string filename)
 {
     EraStreamReader eReader = new EraStreamReader();
     if (!eReader.Open(filename))
         return;
     try
     {
         string line = null;
         while ((line = eReader.ReadLine()) != null)
         {
             if ((line.Length == 0) || (line[0] == ';'))
                 continue;
             for(int i = 0; i < MaxMacro;i++)
             {
                 if (line.StartsWith(macroName[i]))
                     macro[i] = line.Substring(macroName[i].Length);
             }
         }
     }
     catch { return; }
     finally { eReader.Dispose(); }
 }