예제 #1
0
        private MainQuest ReadFile(string file)
        {
            BinaryReader br = new BinaryReader(File.OpenRead(file));
            MainQuest    mq = new MainQuest();

            mq.num_blocks = br.ReadUInt16();
            mq.blocks     = new MainQuest.Block[mq.num_blocks];

            for (int i = 0; i < mq.num_blocks; i++)
            {
                Console.WriteLine("Reading block " + i.ToString());
                mq.blocks[i].size = br.ReadUInt16();
                mq.blocks[i].id   = br.ReadUInt32();

                List <MainQuest.Block.Element> elements = new List <MainQuest.Block.Element>();
                int pos = 4;
                while (pos + 1 != mq.blocks[i].size)
                {
                    Console.WriteLine("\tElement " + (elements.Count + 1).ToString());
                    MainQuest.Block.Element e = new MainQuest.Block.Element();
                    e.size = br.ReadUInt16();
                    e.text = new String(Encoding.GetEncoding(932).GetChars(br.ReadBytes((int)e.size)));
                    e.text = Helper.SJISToLatin(e.text);

                    elements.Add(e);
                    pos += 2 + e.size;
                }
                br.ReadByte();  // 00

                mq.blocks[i].elements = elements.ToArray();
            }

            br.Close();
            return(mq);
        }
예제 #2
0
        public MQuestText(IPluginHost pluginHost, string file, int id)
        {
            InitializeComponent();
            this.id         = id;
            this.pluginHost = pluginHost;
            fileName        = Path.GetFileNameWithoutExtension(file).Substring(12);

            mq               = ReadFile(file);
            mq_old           = ReadFile(file);
            numBlock.Maximum = mq.num_blocks - 1;
            lblBlockNum.Text = "of " + numBlock.Maximum;
            numBlock_ValueChanged(null, null);
        }
예제 #3
0
파일: MQuestText.cs 프로젝트: MetLob/tinke
        public MQuestText(IPluginHost pluginHost, string file, int id)
        {
            InitializeComponent();
            this.id = id;
            this.pluginHost = pluginHost;
            fileName = Path.GetFileNameWithoutExtension(file).Substring(12);

            mq = ReadFile(file);
            mq_old = ReadFile(file);
            numBlock.Maximum = mq.num_blocks - 1;
            lblBlockNum.Text = "of " + numBlock.Maximum;
            numBlock_ValueChanged(null, null);
        }
예제 #4
0
파일: MQuestText.cs 프로젝트: MetLob/tinke
        private MainQuest ReadFile(string file)
        {
            BinaryReader br = new BinaryReader(File.OpenRead(file));
            MainQuest mq = new MainQuest();

            mq.num_blocks = br.ReadUInt16();
            mq.blocks = new MainQuest.Block[mq.num_blocks];

            for (int i = 0; i < mq.num_blocks; i++)
            {
                Console.WriteLine("Reading block " + i.ToString());
                mq.blocks[i].size = br.ReadUInt16();
                mq.blocks[i].id = br.ReadUInt32();

                List<MainQuest.Block.Element> elements = new List<MainQuest.Block.Element>();
                int pos = 4;
                while (pos + 1 != mq.blocks[i].size)
                {
                    Console.WriteLine("\tElement " + (elements.Count + 1).ToString());
                    MainQuest.Block.Element e = new MainQuest.Block.Element();
                    e.size = br.ReadUInt16();
                    e.text = new String(Encoding.GetEncoding(932).GetChars(br.ReadBytes((int)e.size)));
                    e.text = Helper.SJISToLatin(e.text);

                    elements.Add(e);
                    pos += 2 + e.size;
                }
                br.ReadByte();  // 00

                mq.blocks[i].elements = elements.ToArray();
            }

            br.Close();
            return mq;
        }
예제 #5
0
파일: MQuestText.cs 프로젝트: MetLob/tinke
        public void Update_Block(ref MainQuest.Block block)
        {
            ushort size = 0;
            for (int i = 0; i < block.elements.Length; i++)
            {
                MainQuest.Block.Element e = block.elements[i];
                e.size = (ushort)Encoding.GetEncoding("shift_jis").GetByteCount(Helper.LatinToSJIS(e.text));
                block.elements[i] = e;

                size += (ushort)(e.size + 2);
            }
            size += 5;  // ID + last 0 byte
            block.size = size;
        }