Ejemplo n.º 1
0
 public PictureGroup(ref FileBase file)
 {
     // idx + 0x30 done intentionally by Nintendo
     mCharIdx = Convert.ToUInt16(file.ReadUInt16() + 0x30);
     mFont    = file.ReadUInt16();
     mCharID  = file.ReadUInt16();
 }
Ejemplo n.º 2
0
 public EventNode(ref FileBase file) : base()
 {
     mNodeType = NodeType.NodeType_Event;
     file.Skip(0x2);
     mEvent    = file.ReadUInt16();
     mJumpFlow = file.ReadUInt16();
     file.Skip(0x2);
     mFlowID = file.ReadUInt16();
 }
Ejemplo n.º 3
0
 public BranchNode(ref FileBase file) : base()
 {
     mNodeType = NodeType.NodeType_Branch;
     file.Skip(0x2);                       // Unk1
     mUnk2            = file.ReadUInt16(); // Unk2
     mCondition       = file.ReadUInt16(); // Unk3
     mYesNoBoxChoices = file.ReadUInt16(); // Unk4
     mLabelsToUse     = file.ReadUInt16(); // Unk5
 }
Ejemplo n.º 4
0
 public MessageNode(ref FileBase file) : base()
 {
     mNodeType = NodeType.NodeType_Message;
     // skip 0x4 bytes because they are unused
     file.Skip(0x4);
     mMessageID = file.ReadUInt16();
     mNextNode  = file.ReadUInt16();
     file.Skip(0x2);
 }
Ejemplo n.º 5
0
        public Flow(ref FileBase file)
        {
            mNodes = new List <Node>();

            file.Skip(0xC);
            ushort flowCount  = file.ReadUInt16();
            ushort labelCount = file.ReadUInt16();

            file.Skip(0x4);

            for (int i = 0; i < flowCount; i++)
            {
                Node.NodeType type = (Node.NodeType)file.ReadUInt16();

                switch (type)
                {
                case Node.NodeType.NodeType_Message:
                    mNodes.Add(new MessageNode(ref file));
                    break;

                case Node.NodeType.NodeType_Entry:
                    mNodes.Add(new EntryNode(ref file));
                    break;

                case Node.NodeType.NodeType_Event:
                    mNodes.Add(new EventNode(ref file));
                    break;

                case Node.NodeType.NodeType_Branch:
                    mNodes.Add(new BranchNode(ref file));
                    break;

                default:
                    Console.WriteLine($"Unsupported type: {(int)type}");
                    break;
                }
            }

            mLabels = new List <ushort>();

            for (int i = 0; i < labelCount; i++)
            {
                mLabels.Add(file.ReadUInt16());
            }

            while (file.Position() % 0x10 != 0)
            {
                file.Skip(0x1);
            }
        }
Ejemplo n.º 6
0
        public DisplayGroup(ref FileBase file)
        {
            mType = file.ReadUInt16();

            if (mType != 0)
            {
                file.Skip(0x4);
            }
            else
            {
                file.Skip(0x2);
                mFrames = file.ReadUInt16();
            }
        }
Ejemplo n.º 7
0
        public SoundGroup(ref FileBase file)
        {
            file.Skip(0x4);
            ushort len = file.ReadUInt16();

            string str = "";

            for (int i = 0; i < len / 2; i++)
            {
                byte[] e = BitConverter.GetBytes(file.ReadUInt16());
                str += Encoding.Unicode.GetString(e);
            }

            mSoundID = str;
        }
Ejemplo n.º 8
0
 public EntryNode(ref FileBase file) : base()
 {
     mNodeType = NodeType.NodeType_Entry;
     file.Skip(0x2);
     mNextNode = file.ReadUInt16();
     file.Skip(0x6);
 }
Ejemplo n.º 9
0
        public SystemGroup(ref FileBase file)
        {
            ushort mType = file.ReadUInt16();

            // we skip the data size here, we can safely determine the size by the type
            file.Skip(0x2);
            // type 0 is japanese only
            // type 3 is color
            if (mType == 3)
            {
                mColor = file.ReadInt16();
            }
        }
Ejemplo n.º 10
0
        public BCSV(FileBase file)
        {
            mFile = file;

            mFields  = new Dictionary <int, Field>();
            mEntries = new List <Entry>();

            if (mFile.GetLength() == 0)
            {
                return;
            }

            int entryCount    = mFile.ReadInt32();
            int fieldCount    = mFile.ReadInt32();
            int dataOffs      = mFile.ReadInt32();
            int entryDataSize = mFile.ReadInt32();

            int stringTableOffs = (dataOffs + (entryCount * entryDataSize));

            for (int i = 0; i < fieldCount; i++)
            {
                Field f = new Field();
                mFile.Seek(0x10 + (0xC * i));

                f.mHash        = mFile.ReadInt32();
                f.mMask        = mFile.ReadInt32();
                f.mEntryOffset = mFile.ReadUInt16();
                f.mShiftAmount = mFile.ReadByte();
                f.mType        = mFile.ReadByte();

                string fieldName = HashToFieldName(f.mHash);
                f.mName = fieldName;
                mFields.Add(f.mHash, f);
            }

            for (int i = 0; i < entryCount; i++)
            {
                Entry e = new Entry();

                foreach (Field f in mFields.Values)
                {
                    mFile.Seek(dataOffs + (i * entryDataSize) + f.mEntryOffset);

                    object val = null;

                    switch (f.mType)
                    {
                    case 0:
                    case 3:
                        val = Convert.ToInt32((mFile.ReadInt32() & f.mMask) >> f.mShiftAmount);
                        break;

                    case 4:
                        val = (short)((mFile.ReadInt16() & f.mMask) >> f.mShiftAmount);
                        break;

                    case 5:
                        val = Convert.ToByte((mFile.ReadByte() & f.mMask) >> f.mShiftAmount);
                        break;

                    case 2:
                        val = mFile.ReadSingle();
                        break;

                    case 6:
                        int offs = mFile.ReadInt32();
                        mFile.Seek(stringTableOffs + offs);
                        val = mFile.ReadString();
                        break;

                    default:
                        throw new Exception($"BCSV::BCSV() - Unknown field type {f.mType}.");
                    }

                    e[f.mHash] = val;
                }

                mEntries.Add(e);
            }
        }
Ejemplo n.º 11
0
 public NumberGroup(ref FileBase file)
 {
     mMaxWidth = file.ReadUInt16();
     mWidth    = file.ReadUInt16();
     mNumber   = BitConverter.ToInt32(file.ReadBytes(mWidth), 0);
 }
Ejemplo n.º 12
0
 public FontSizeGroup(ref FileBase file)
 {
     mFontSize = file.ReadUInt16();
     file.Skip(0x2);
 }
Ejemplo n.º 13
0
        public TXT2(ref FileBase file)
        {
            int start = file.ReadInt32();

            file.Skip(0x8);
            int dataStartOffs = file.Position();
            int count         = file.ReadInt32();

            mMessages = new Dictionary <uint, List <MessageBase> >();

            for (uint i = 0; i < count; i++)
            {
                List <MessageBase> msgs = new List <MessageBase>();

                file.Seek(Convert.ToInt32(dataStartOffs + (i * 4) + 4));
                int offs = file.ReadInt32();
                file.Seek(offs + dataStartOffs);

                short cur = -1;

                while (cur != 0)
                {
                    cur = file.ReadInt16();

                    if (cur == 0)
                    {
                        mMessages.Add(i, msgs);
                        break;
                    }

                    switch (cur)
                    {
                    // new command
                    case 0xE:
                        ushort opcode = file.ReadUInt16();

                        switch (opcode)
                        {
                        case 0:
                            msgs.Add(new SystemGroup(ref file));
                            break;

                        case 1:
                            msgs.Add(new DisplayGroup(ref file));
                            break;

                        case 2:
                            msgs.Add(new SoundGroup(ref file));
                            break;

                        case 3:
                            msgs.Add(new PictureGroup(ref file));
                            break;

                        case 4:
                            msgs.Add(new FontSizeGroup(ref file));
                            break;

                        case 5:
                            msgs.Add(new LocalizeGroup(ref file));
                            break;

                        case 6:
                            msgs.Add(new NumberGroup(ref file));
                            break;

                        default:
                            Console.WriteLine($"Unsupported opcode {opcode}");
                            break;
                        }
                        break;

                    default:
                        // normal char
                        msgs.Add(new Character(cur));
                        break;
                    }
                }
            }

            file.Seek(start + dataStartOffs);

            while (file.Position() % 0x10 != 0)
            {
                file.Skip(0x1);
            }
        }