Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private void txtTrans_TextChanged(object sender, EventArgs e)
        {
            int i = (int)numBlock.Value;
            int j = (int)numElement.Value;

            MainQuest.Block.Element el = mq.blocks[i].elements[j];
            el.text = txtTrans.Text.Replace("\r\n", "\n");
            mq.blocks[i].elements[j] = el;
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
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;
        }