コード例 #1
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.IsSwitch)
            {
                Name = loader.LoadString();
                uint DataOffset = loader.ReadOffset();
                uint count      = 0;
                if (loader.ResFile.VersionMajor2 <= 2 && loader.ResFile.VersionMajor == 0)
                {
                    char[] Reserved = loader.ReadChars(8);
                    count = loader.ReadUInt32();
                    Type  = (UserDataType)loader.ReadUInt32();
                }
                else
                {
                    count = loader.ReadUInt32();
                    Type  = loader.ReadEnum <UserDataType>(true);
                    char[] Reserved = loader.ReadChars(43);
                }

                switch (Type)
                {
                case UserDataType.Byte:
                    _value = loader.LoadCustom(() => loader.ReadSBytes((int)count), DataOffset);
                    break;

                case UserDataType.Int32:
                    _value = loader.LoadCustom(() => loader.ReadInt32s((int)count), DataOffset);
                    break;

                case UserDataType.Single:
                    _value = loader.LoadCustom(() => loader.ReadSingles((int)count), DataOffset);
                    break;

                case UserDataType.String:
                    _value = loader.LoadCustom(() => loader.LoadStrings((int)count, Encoding.UTF8), DataOffset);
                    break;

                case UserDataType.WString:
                    _value = loader.LoadCustom(() => loader.LoadStrings((int)count, Encoding.Unicode), DataOffset);
                    break;
                }
            }
            else
            {
                Name = loader.LoadString();
                ushort count = loader.ReadUInt16();
                Type = loader.ReadEnum <UserDataType>(true);
                loader.Seek(1);
                switch (Type)
                {
                case UserDataType.Int32:
                    _value = loader.ReadInt32s(count);
                    break;

                case UserDataType.Single:
                    _value = loader.ReadSingles(count);
                    break;

                case UserDataType.String:
                    _value = loader.LoadStrings(count, Encoding.UTF8);
                    break;

                case UserDataType.WString:
                    _value = loader.LoadStrings(count, Encoding.Unicode);
                    break;

                case UserDataType.Byte:
                    _value = loader.ReadBytes(count);
                    break;
                }
            }
        }