public ScenarioText(IPluginHost pluginHost, string file, int id) { InitializeComponent(); this.fileName = Path.GetFileNameWithoutExtension(file).Substring(12); this.pluginHost = pluginHost; this.id = id; enc = Encoding.GetEncoding("shift_jis"); sce = Read(file); sce_old = Read(file); numericBlock.Maximum = 2; numericBlock_ValueChanged(null, null); }
private Scenario Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); Scenario sce = new Scenario(); sce.type = br.ReadUInt32(); // Must be 0x0006050A sce.blocks = new Scenario.Block[3]; for (int i = 0; i < 3; i++) { sce.blocks[i].size = br.ReadUInt32(); List<Scenario.Element> elements = new List<Scenario.Element>(); for (; ; ) { Scenario.Element e = new Scenario.Element(); e.id = br.ReadUInt32(); if (e.id == 0xFFFFFFFF) break; e.size = br.ReadByte(); if (i == 0) { e.text = Get_Furigana(Encoding.GetEncoding(932).GetChars(br.ReadBytes(e.size))); e.text = Helper.SJISToLatin(e.text); } else if (i == 1) { e.text = Get_Furigana(Encoding.GetEncoding(932).GetChars(br.ReadBytes(e.size))); e.text = Helper.SJISToLatin(e.text); e.unk = br.ReadUInt16(); } else if (i == 2) { e.unk = br.ReadUInt16(); e.text = Get_Furigana(Encoding.GetEncoding(932).GetChars(br.ReadBytes(e.size - 4))); e.text = Helper.SJISToLatin(e.text); e.unk2 = br.ReadUInt16(); } elements.Add(e); } sce.blocks[i].elements = elements.ToArray(); } br.Close(); return sce; }