Ejemplo n.º 1
0
        unsafe Texture IFontFactory.CreateInstance(string text, IHue hue)
        {
            int       num;
            char      ch;
            FontImage image;

            if ((text == null) || (text.Length <= 0))
            {
                return(Texture.Empty);
            }
            int yHeight = 0;
            int num3    = 0;
            int width   = 0;
            int height  = 1;

            char[] chArray = text.ToCharArray();
            for (num = 0; num < chArray.Length; num++)
            {
                ch = chArray[num];
                if ((ch >= ' ') && (ch < 'Ā'))
                {
                    image = this.m_Images[ch - ' '];
                    num3 += image.xWidth;
                    if (num3 > width)
                    {
                        width = num3;
                    }
                    if (image.yHeight > yHeight)
                    {
                        yHeight = image.yHeight;
                    }
                }
                else if (ch == '\n')
                {
                    num3 = 0;
                    height++;
                }
            }
            height *= yHeight;
            if ((width <= 0) || (height <= 0))
            {
                return(Texture.Empty);
            }
            Texture texture = new Texture(width, height, false);

            if (texture.IsEmpty())
            {
                return(Texture.Empty);
            }
            short[] numArray = new short[this.m_Palette.Length];
            fixed(short *numRef = numArray)
            {
                fixed(short *numRef2 = this.m_Palette)
                {
                    hue.CopyPixels((void *)(numRef2 + 1), (void *)(numRef + 1), this.m_Palette.Length - 1);
                }

                LockData data    = texture.Lock(LockFlags.WriteOnly);
                short *  pvSrc   = (short *)data.pvSrc;
                short *  numPtr2 = pvSrc;
                int      num6    = data.Pitch >> 1;
                int      num7    = num6 * yHeight;

                for (num = 0; num < chArray.Length; num++)
                {
                    ch = chArray[num];
                    if ((ch >= ' ') && (ch < 'Ā'))
                    {
                        image = this.m_Images[ch - ' '];
                        int    xWidth  = image.xWidth;
                        int    num11   = image.yHeight;
                        short *numPtr3 = numPtr2;
                        numPtr3 += (yHeight - num11) * num6;
                        int num8 = num6 - xWidth;
                        int num9 = image.xDelta - xWidth;
                        fixed(byte *numRef3 = image.xyPixels)
                        {
                            byte *numPtr4 = numRef3;
                            int   num12   = 0;

                            while (num12 < num11)
                            {
                                int num13 = xWidth >> 2;
                                int num14 = xWidth & 3;
                                while (--num13 >= 0)
                                {
                                    numPtr3[0] = numRef[numPtr4[0]];
                                    numPtr3[1] = numRef[numPtr4[1]];
                                    numPtr3[2] = numRef[numPtr4[2]];
                                    numPtr3[3] = numRef[numPtr4[3]];
                                    numPtr3   += 4;
                                    numPtr4   += 4;
                                }
                                while (--num14 >= 0)
                                {
                                    numPtr3++;
                                    numPtr3[0] = numRef[*(numPtr4++)];
                                }
                                num12++;
                                numPtr3 += num8;
                                numPtr4 += num9;
                            }
                        }

                        numPtr2 += image.xWidth;
                    }
                    else if (ch == '\n')
                    {
                        pvSrc  += num7;
                        numPtr2 = pvSrc;
                    }
                }
                texture.Unlock();
                return(texture);
            }
        }
Ejemplo n.º 2
0
 unsafe Texture IFontFactory.CreateInstance(string text, IHue hue)
 {
     int num;
     char ch;
     FontImage image;
     if ((text == null) || (text.Length <= 0))
     {
         return Texture.Empty;
     }
     int yHeight = 0;
     int num3 = 0;
     int width = 0;
     int height = 1;
     char[] chArray = text.ToCharArray();
     for (num = 0; num < chArray.Length; num++)
     {
         ch = chArray[num];
         if ((ch >= ' ') && (ch < 'Ā'))
         {
             image = this.m_Images[ch - ' '];
             num3 += image.xWidth;
             if (num3 > width)
             {
                 width = num3;
             }
             if (image.yHeight > yHeight)
             {
                 yHeight = image.yHeight;
             }
         }
         else if (ch == '\n')
         {
             num3 = 0;
             height++;
         }
     }
     height *= yHeight;
     if ((width <= 0) || (height <= 0))
     {
         return Texture.Empty;
     }
     Texture texture = new Texture(width, height, false);
     if (texture.IsEmpty())
     {
         return Texture.Empty;
     }
     short[] numArray = new short[this.m_Palette.Length];
     fixed (short* numRef = numArray)
     {
         fixed (short* numRef2 = this.m_Palette)
         {
             hue.CopyPixels((void*) (numRef2 + 1), (void*) (numRef + 1), this.m_Palette.Length - 1);
         }
         LockData data = texture.Lock(LockFlags.WriteOnly);
         short* pvSrc = (short*) data.pvSrc;
         short* numPtr2 = pvSrc;
         int num6 = data.Pitch >> 1;
         int num7 = num6 * yHeight;
         for (num = 0; num < chArray.Length; num++)
         {
             ch = chArray[num];
             if ((ch >= ' ') && (ch < 'Ā'))
             {
                 image = this.m_Images[ch - ' '];
                 int xWidth = image.xWidth;
                 int num11 = image.yHeight;
                 short* numPtr3 = numPtr2;
                 numPtr3 += (yHeight - num11) * num6;
                 int num8 = num6 - xWidth;
                 int num9 = image.xDelta - xWidth;
                 fixed (byte* numRef3 = image.xyPixels)
                 {
                     byte* numPtr4 = numRef3;
                     int num12 = 0;
                     while (num12 < num11)
                     {
                         int num13 = xWidth >> 2;
                         int num14 = xWidth & 3;
                         while (--num13 >= 0)
                         {
                             numPtr3[0] = numRef[numPtr4[0]];
                             numPtr3[1] = numRef[numPtr4[1]];
                             numPtr3[2] = numRef[numPtr4[2]];
                             numPtr3[3] = numRef[numPtr4[3]];
                             numPtr3 += 4;
                             numPtr4 += 4;
                         }
                         while (--num14 >= 0)
                         {
                             numPtr3++;
                             numPtr3[0] = numRef[*(numPtr4++)];
                         }
                         num12++;
                         numPtr3 += num8;
                         numPtr4 += num9;
                     }
                 }
                 numPtr2 += image.xWidth;
             }
             else if (ch == '\n')
             {
                 pvSrc += num7;
                 numPtr2 = pvSrc;
             }
         }
         texture.Unlock();
         return texture;
     }
 }
Ejemplo n.º 3
0
        public unsafe object Create(int realID, IHue hue)
        {
            int length;
            int lookup;
            int num3;
            Stream stream;
            switch (this.ConvertRealID(ref realID))
            {
                case 1:
                {
                    if (((realID < 0) || (realID >= this.m_Count)) || (realID >= this.m_Index.Length))
                    {
                        return Frames.Empty;
                    }
                    Entry3D entryd = this.m_Index[realID];
                    length = entryd.m_Length;
                    lookup = entryd.m_Lookup;
                    num3 = entryd.m_Extra & 0xff;
                    stream = m_Stream;
                    break;
                }
                case 2:
                {
                    if (((realID < 0) || (realID >= this.m_Count2)) || (realID >= this.m_Index2.Length))
                    {
                        return Frames.Empty;
                    }
                    Entry3D entryd2 = this.m_Index2[realID];
                    length = entryd2.m_Length;
                    lookup = entryd2.m_Lookup;
                    num3 = entryd2.m_Extra & 0xff;
                    stream = m_Stream2;
                    break;
                }
                case 3:
                {
                    if (((realID < 0) || (realID >= this.m_Count3)) || (realID >= this.m_Index3.Length))
                    {
                        return Frames.Empty;
                    }
                    Entry3D entryd3 = this.m_Index3[realID];
                    length = entryd3.m_Length;
                    lookup = entryd3.m_Lookup;
                    num3 = entryd3.m_Extra & 0xff;
                    stream = m_Stream3;
                    break;
                }
                default:
                {
                    if (((realID < 0) || (realID >= this.m_Count4)) || (realID >= this.m_Index4.Length))
                    {
                        return Frames.Empty;
                    }
                    Entry3D entryd4 = this.m_Index4[realID];
                    length = entryd4.m_Length;
                    lookup = entryd4.m_Lookup;
                    num3 = entryd4.m_Extra & 0xff;
                    stream = m_Stream4;
                    break;
                }
            }
            if (((lookup < 0) || (length <= 0)) || ((num3 <= 0) || (stream == null)))
            {
                return Frames.Empty;
            }
            if ((this.m_Data == null) || (length > this.m_Data.Length))
            {
                this.m_Data = new byte[length];
            }
            stream.Seek((long) lookup, SeekOrigin.Begin);
            stream.Read(this.m_Data, 0, length);
            fixed (short* numRef = this.m_Palette)
            {
                short* numPtr = numRef;
                fixed (byte* numRef2 = this.m_Data)
                {
                    if (hue.HueID() == 0)
                    {
                        numPtr = (short*) numRef2;
                        int* numPtr2 = (int*) numPtr;
                        int* numPtr3 = numPtr2 + 0x80;
                        while (numPtr2 < numPtr3)
                        {
                            numPtr2[0] |= -2147450880;
                            int* numPtr1 = numPtr2 + 1;
                            numPtr1[0] |= -2147450880;
                            int* numPtr9 = numPtr2 + 2;
                            numPtr9[0] |= -2147450880;
                            int* numPtr10 = numPtr2 + 3;
                            numPtr10[0] |= -2147450880;
                            numPtr2 += 4;
                        }
                    }
                    else
                    {
                        hue.CopyPixels((void*) numRef2, (void*) numPtr, 0x100);
                    }
                    Frames frames = new Frames {
                        FrameCount = num3,
                        FrameList = new Frame[num3]
                    };
                    for (int i = 0; i < num3; i++)
                    {
                        int num6 = (numRef2 + 0x204)[i << 2];
                        byte* numPtr4 = (numRef2 + 0x200) + num6;
                        short* numPtr5 = (short*) numPtr4;
                        int num7 = numPtr5[0];
                        int num8 = numPtr5[1];
                        int width = numPtr5[2];
                        int height = numPtr5[3];
                        numPtr4 += 8;
                        frames.FrameList[i] = new Frame();
                        frames.FrameList[i].CenterX = num7;
                        frames.FrameList[i].CenterY = num8;
                        if ((width <= 0) || (height <= 0))
                        {
                            frames.FrameList[i].Image = Texture.Empty;
                        }
                        else
                        {
                            Texture texture = new Texture(width, height, true);
                            if (texture.IsEmpty())
                            {
                                frames.FrameList[i].Image = Texture.Empty;
                            }
                            else
                            {
                                int num11 = 0;
                                short* numPtr6 = null;
                                int num12 = num7 - 0x200;
                                int num13 = (num8 + height) - 0x200;
                                LockData data = texture.Lock(LockFlags.WriteOnly);
                                short* pvSrc = (short*) data.pvSrc;
                                int num14 = data.Pitch >> 1;
                                pvSrc += num12;
                                pvSrc += num13 * num14;
                                while ((num11 = *((int*) numPtr4)) != 0x7fff7fff)
                                {
                                    numPtr4 += 4;
                                    num11 ^= -2145386496;
                                    numPtr6 = pvSrc + ((((num11 >> 12) & 0x3ff) * num14) + ((num11 >> 0x16) & 0x3ff));
                                    short* numPtr8 = numPtr6 + (num11 & 0xffc);
                                    while (numPtr6 < numPtr8)
                                    {
                                        numPtr6[0] = numPtr[numPtr4[0]];
                                        numPtr6[1] = numPtr[numPtr4[1]];
                                        numPtr6[2] = numPtr[numPtr4[2]];
                                        numPtr6[3] = numPtr[numPtr4[3]];
                                        numPtr6 += 4;
                                        numPtr4 += 4;
                                    }
                                    switch ((num11 & 3))
                                    {
                                        case 1:
                                            goto Label_04A6;

                                        case 2:
                                            break;

                                        case 3:
                                            numPtr6[2] = numPtr[numPtr4[2]];
                                            break;

                                        default:
                                            goto Label_04B5;
                                    }
                                    numPtr6[1] = numPtr[numPtr4[1]];
                                Label_04A6:
                                    numPtr6[0] = numPtr[numPtr4[0]];
                                Label_04B5:
                                    numPtr4 += num11 & 3;
                                }
                                texture.Unlock();
                                texture.SetPriority(0);
                                frames.FrameList[i].Image = texture;
                            }
                        }
                    }
                    this.m_Frames.Add(frames);
                    return frames;
                }
            }
        }
Ejemplo n.º 4
0
        public unsafe object Create(int realID, IHue hue)
        {
            int    length;
            int    lookup;
            int    num3;
            Stream stream;

            switch (this.ConvertRealID(ref realID))
            {
            case 1:
            {
                if (((realID < 0) || (realID >= this.m_Count)) || (realID >= this.m_Index.Length))
                {
                    return(Frames.Empty);
                }
                Entry3D entryd = this.m_Index[realID];
                length = entryd.m_Length;
                lookup = entryd.m_Lookup;
                num3   = entryd.m_Extra & 0xff;
                stream = m_Stream;
                break;
            }

            case 2:
            {
                if (((realID < 0) || (realID >= this.m_Count2)) || (realID >= this.m_Index2.Length))
                {
                    return(Frames.Empty);
                }
                Entry3D entryd2 = this.m_Index2[realID];
                length = entryd2.m_Length;
                lookup = entryd2.m_Lookup;
                num3   = entryd2.m_Extra & 0xff;
                stream = m_Stream2;
                break;
            }

            case 3:
            {
                if (((realID < 0) || (realID >= this.m_Count3)) || (realID >= this.m_Index3.Length))
                {
                    return(Frames.Empty);
                }
                Entry3D entryd3 = this.m_Index3[realID];
                length = entryd3.m_Length;
                lookup = entryd3.m_Lookup;
                num3   = entryd3.m_Extra & 0xff;
                stream = m_Stream3;
                break;
            }

            default:
            {
                if (((realID < 0) || (realID >= this.m_Count4)) || (realID >= this.m_Index4.Length))
                {
                    return(Frames.Empty);
                }
                Entry3D entryd4 = this.m_Index4[realID];
                length = entryd4.m_Length;
                lookup = entryd4.m_Lookup;
                num3   = entryd4.m_Extra & 0xff;
                stream = m_Stream4;
                break;
            }
            }
            if (((lookup < 0) || (length <= 0)) || ((num3 <= 0) || (stream == null)))
            {
                return(Frames.Empty);
            }
            if ((this.m_Data == null) || (length > this.m_Data.Length))
            {
                this.m_Data = new byte[length];
            }
            stream.Seek((long)lookup, SeekOrigin.Begin);
            stream.Read(this.m_Data, 0, length);
            fixed(short *numRef = this.m_Palette)
            {
                short *numPtr = numRef;

                fixed(byte *numRef2 = this.m_Data)
                {
                    if (hue.HueID() == 0)
                    {
                        numPtr = (short *)numRef2;
                        int *numPtr2 = (int *)numPtr;
                        int *numPtr3 = numPtr2 + 0x80;
                        while (numPtr2 < numPtr3)
                        {
                            numPtr2[0] |= -2147450880;
                            int *numPtr1 = numPtr2 + 1;
                            numPtr1[0] |= -2147450880;
                            int *numPtr9 = numPtr2 + 2;
                            numPtr9[0] |= -2147450880;
                            int *numPtr10 = numPtr2 + 3;
                            numPtr10[0] |= -2147450880;
                            numPtr2     += 4;
                        }
                    }
                    else
                    {
                        hue.CopyPixels((void *)numRef2, (void *)numPtr, 0x100);
                    }
                    Frames frames = new Frames {
                        FrameCount = num3,
                        FrameList  = new Frame[num3]
                    };

                    for (int i = 0; i < num3; i++)
                    {
                        int    num6    = (numRef2 + 0x204)[i << 2];
                        byte * numPtr4 = (numRef2 + 0x200) + num6;
                        short *numPtr5 = (short *)numPtr4;
                        int    num7    = numPtr5[0];
                        int    num8    = numPtr5[1];
                        int    width   = numPtr5[2];
                        int    height  = numPtr5[3];
                        numPtr4                    += 8;
                        frames.FrameList[i]         = new Frame();
                        frames.FrameList[i].CenterX = num7;
                        frames.FrameList[i].CenterY = num8;
                        if ((width <= 0) || (height <= 0))
                        {
                            frames.FrameList[i].Image = Texture.Empty;
                        }
                        else
                        {
                            Texture texture = new Texture(width, height, true);
                            if (texture.IsEmpty())
                            {
                                frames.FrameList[i].Image = Texture.Empty;
                            }
                            else
                            {
                                int      num11   = 0;
                                short *  numPtr6 = null;
                                int      num12   = num7 - 0x200;
                                int      num13   = (num8 + height) - 0x200;
                                LockData data    = texture.Lock(LockFlags.WriteOnly);
                                short *  pvSrc   = (short *)data.pvSrc;
                                int      num14   = data.Pitch >> 1;
                                pvSrc += num12;
                                pvSrc += num13 * num14;
                                while ((num11 = *((int *)numPtr4)) != 0x7fff7fff)
                                {
                                    numPtr4 += 4;
                                    num11   ^= -2145386496;
                                    numPtr6  = pvSrc + ((((num11 >> 12) & 0x3ff) * num14) + ((num11 >> 0x16) & 0x3ff));
                                    short *numPtr8 = numPtr6 + (num11 & 0xffc);
                                    while (numPtr6 < numPtr8)
                                    {
                                        numPtr6[0] = numPtr[numPtr4[0]];
                                        numPtr6[1] = numPtr[numPtr4[1]];
                                        numPtr6[2] = numPtr[numPtr4[2]];
                                        numPtr6[3] = numPtr[numPtr4[3]];
                                        numPtr6   += 4;
                                        numPtr4   += 4;
                                    }
                                    switch ((num11 & 3))
                                    {
                                    case 1:
                                        goto Label_04A6;

                                    case 2:
                                        break;

                                    case 3:
                                        numPtr6[2] = numPtr[numPtr4[2]];
                                        break;

                                    default:
                                        goto Label_04B5;
                                    }
                                    numPtr6[1] = numPtr[numPtr4[1]];
Label_04A6:
                                    numPtr6[0] = numPtr[numPtr4[0]];
Label_04B5:
                                    numPtr4 += num11 & 3;
                                }
                                texture.Unlock();
                                texture.SetPriority(0);
                                frames.FrameList[i].Image = texture;
                            }
                        }
                    }
                    this.m_Frames.Add(frames);
                    return(frames);
                }
            }
        }