コード例 #1
0
ファイル: TwitchChat.cs プロジェクト: pnolin/LiveSplit
 protected void AddFlag(String username, ChatBadges flag)
 {
     if (UserFlags.ContainsKey(username))
     {
         UserFlags[username] |= flag;
     }
     else
     {
         UserFlags.Add(username, flag);
     }
 }
コード例 #2
0
        public VertexChunk(byte[] file, int address)
            : this()
        {
            Header1 = ByteConverter.ToUInt32(file, address);
            Header2 = ByteConverter.ToUInt32(file, address + 4);
            address = address + 8;
            for (int i = 0; i < VertexCount; i++)
            {
                switch (Type)
                {
                case ChunkType.Vertex_VertexSH:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size + sizeof(float);
                    break;

                case ChunkType.Vertex_VertexNormalSH:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size + sizeof(float);
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size + sizeof(float);
                    break;

                case ChunkType.Vertex_Vertex:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    break;

                case ChunkType.Vertex_VertexDiffuse8:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Diffuse.Add(VColor.FromBytes(file, address, ColorType.ARGB8888_32));
                    address += VColor.Size(ColorType.ARGB8888_32);
                    break;

                case ChunkType.Vertex_VertexUserFlags:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    UserFlags.Add(ByteConverter.ToUInt32(file, address));
                    address += sizeof(uint);
                    break;

                case ChunkType.Vertex_VertexNinjaFlags:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    NinjaFlags.Add(ByteConverter.ToUInt32(file, address));
                    address += sizeof(uint);
                    break;

                case ChunkType.Vertex_VertexDiffuseSpecular5:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    uint tmpcolor = ByteConverter.ToUInt32(file, address);
                    address += sizeof(uint);
                    Diffuse.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor & 0xFFFF)), 0, ColorType.RGB565));
                    Specular.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor >> 16)), 0, ColorType.RGB565));
                    break;

                case ChunkType.Vertex_VertexDiffuseSpecular4:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    tmpcolor = ByteConverter.ToUInt32(file, address);
                    address += sizeof(uint);
                    Diffuse.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor & 0xFFFF)), 0, ColorType.ARGB4444));
                    Specular.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor >> 16)), 0, ColorType.RGB565));
                    break;

                case ChunkType.Vertex_VertexNormal:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    break;

                case ChunkType.Vertex_VertexNormalDiffuse8:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Diffuse.Add(VColor.FromBytes(file, address, ColorType.ARGB8888_32));
                    address += VColor.Size(ColorType.ARGB8888_32);
                    break;

                case ChunkType.Vertex_VertexNormalUserFlags:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    UserFlags.Add(ByteConverter.ToUInt32(file, address));
                    address += sizeof(uint);
                    break;

                case ChunkType.Vertex_VertexNormalNinjaFlags:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    NinjaFlags.Add(ByteConverter.ToUInt32(file, address));
                    address += sizeof(uint);
                    break;

                case ChunkType.Vertex_VertexNormalDiffuseSpecular5:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    tmpcolor = ByteConverter.ToUInt32(file, address);
                    address += sizeof(uint);
                    Diffuse.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor & 0xFFFF)), 0, ColorType.RGB565));
                    Specular.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor >> 16)), 0, ColorType.RGB565));
                    break;

                case ChunkType.Vertex_VertexNormalDiffuseSpecular4:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    tmpcolor = ByteConverter.ToUInt32(file, address);
                    address += sizeof(uint);
                    Diffuse.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor & 0xFFFF)), 0, ColorType.ARGB4444));
                    Specular.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor >> 16)), 0, ColorType.RGB565));
                    break;

                default:
                    throw new NotSupportedException("Unsupported chunk type " + Type + " at " + address.ToString("X8") + ".");
                }
            }
        }