예제 #1
0
        public unsafe Texture ReadLight(int lightId)
        {
            if (lightId >= 0 && lightId < this.index.Length)
            {
                Entry3D entry3D = this.index[lightId];
                if (entry3D.m_Lookup >= 0 && entry3D.m_Length > 0)
                {
                    ushort num1 = (ushort)(entry3D.m_Extra & (int)ushort.MaxValue);
                    ushort num2 = (ushort)(entry3D.m_Extra >> 16 & (int)ushort.MaxValue);
                    if ((int)num1 > 0 && (int)num2 > 0 && entry3D.m_Length == (int)num1 * (int)num2)
                    {
                        byte[] buffer = new byte[entry3D.m_Length];
                        int    offset = 0;
                        int    length = buffer.Length;
                        this.dataStream.Seek((long)entry3D.m_Lookup, SeekOrigin.Begin);
                        int num3;
                        while (length > 0 && (num3 = this.dataStream.Read(buffer, offset, length)) > 0)
                        {
                            offset += num3;
                            length -= num3;
                        }
                        if (length == 0)
                        {
                            Texture  texture  = new Texture((int)num1, (int)num2, (Format)21, TextureTransparency.Complex);
                            LockData lockData = texture.Lock(LockFlags.WriteOnly);
                            try
                            {
                                fixed(byte *numPtr1 = buffer)
                                {
                                    sbyte *numPtr2 = (sbyte *)numPtr1;
                                    byte * numPtr3 = (byte *)lockData.pvSrc;
                                    int    num4    = lockData.Pitch - (int)num1 * 4;

                                    for (int index1 = 0; index1 < (int)num2; ++index1)
                                    {
                                        for (int index2 = 0; index2 < (int)num1; ++index2)
                                        {
                                            *numPtr3 = (byte)(((int)Math.Abs(*numPtr2++) * (int)byte.MaxValue + 15) / 31);
                                            numPtr3[1] = *numPtr3;
                                            numPtr3[2] = *numPtr3;
                                            numPtr3[3] = *numPtr3;
                                            numPtr3   += 4;
                                        }
                                        numPtr3 += num4;
                                    }
                                }
                                return(texture);
                            }
                            finally
                            {
                                texture.Unlock();
                            }
                        }
                    }
                }
            }
            return(Texture.Empty);
        }
예제 #2
0
        protected unsafe Texture Construct(bool isReconstruct)
        {
            if (!this.CoreLookup())
            {
                return(Texture.Empty);
            }
            int width;
            int height;

            this.CoreGetDimensions(out width, out height);
            Texture tex = new Texture(width, height, (Format)25, (Pool)1, isReconstruct, this.Transparency);

            if (tex.IsEmpty())
            {
                return(Texture.Empty);
            }
            LockData lockData = tex.Lock(LockFlags.WriteOnly);

            this.CoreProcessImage(lockData.Width, lockData.Height, lockData.Pitch, (ushort *)lockData.pvSrc, (ushort *)((IntPtr)lockData.pvSrc + lockData.Width * 2), (ushort *)((IntPtr)lockData.pvSrc + lockData.Height * lockData.Pitch), (lockData.Pitch >> 1) - lockData.Width, lockData.Pitch >> 1);
            tex.Unlock();
            this.CoreAssignArgs(tex);
            this.m_Textures.Add((object)tex);
            return(tex);
        }
예제 #3
0
        private static unsafe CursorEntry LoadCursor(int idCursor, int idType)
        {
            IHue hue;
            int  itemId;

            switch (idType)
            {
            case 0:
                hue    = Hues.Default;
                itemId = 8298 + idCursor;
                break;

            case 1:
                hue    = Hues.Default;
                itemId = 8275 + idCursor;
                break;

            case 2:
                hue    = Hues.Load(35181);
                itemId = 8298 + idCursor;
                break;

            default:
                return((CursorEntry)null);
            }
            Texture texture = hue.GetItem(itemId);

            if (texture == null || texture.IsEmpty())
            {
                return(new CursorEntry(0, 0, 0, 0, Texture.Empty));
            }
            if (texture.m_Factory != null)
            {
                texture.m_Factory.Remove(texture);
                texture.m_Factory     = (TextureFactory)null;
                texture.m_FactoryArgs = (object[])null;
            }
            int xOffset = 0;
            int yOffset = 0;

            if (idType < 2)
            {
                LockData lockData = texture.Lock(LockFlags.ReadWrite);
                int      num1     = lockData.Width;
                int      num2     = lockData.Height;
                int      num3     = lockData.Pitch >> 1;
                short *  numPtr1  = (short *)lockData.pvSrc;
                short *  numPtr2  = (short *)((IntPtr)lockData.pvSrc + ((num2 - 1) * num3) * 2);
                for (int index = 0; index < num1; ++index)
                {
                    if (((int)*numPtr1 & (int)short.MaxValue) == 992)
                    {
                        xOffset = index;
                    }
                    *numPtr1++ = (short)0;
                    *numPtr2++ = (short)0;
                }
                short *numPtr3 = (short *)lockData.pvSrc;
                short *numPtr4 = (short *)((IntPtr)lockData.pvSrc + (num1 - 1) * 2);
                for (int index = 0; index < num2; ++index)
                {
                    if (((int)*numPtr3 & (int)short.MaxValue) == 992)
                    {
                        yOffset = index;
                    }
                    *numPtr3 = (short)0;
                    *numPtr4 = (short)0;
                    numPtr3 += num3;
                    numPtr4 += num3;
                }
                texture.Unlock();
            }
            else
            {
                CursorEntry cursorEntry = Cursor.m_Cursors[idCursor, 1] ?? Cursor.m_Cursors[idCursor, 0] ?? (Cursor.m_Cursors[idCursor, 1] = Cursor.LoadCursor(idCursor, 1));
                xOffset = cursorEntry.m_xOffset;
                yOffset = cursorEntry.m_yOffset;
                LockData lockData = texture.Lock(LockFlags.ReadWrite);
                int      num1     = lockData.Width;
                int      num2     = lockData.Height;
                int      num3     = lockData.Pitch >> 1;
                short *  numPtr1  = (short *)lockData.pvSrc;
                short *  numPtr2  = (short *)((IntPtr)lockData.pvSrc + ((num2 - 1) * num3) * 2);
                for (int index = 0; index < num1; ++index)
                {
                    *numPtr1++ = (short)0;
                    *numPtr2++ = (short)0;
                }
                short *numPtr3 = (short *)lockData.pvSrc;
                short *numPtr4 = (short *)((IntPtr)lockData.pvSrc + (num1 - 1) * 2);
                for (int index = 0; index < num2; ++index)
                {
                    *numPtr3 = (short)0;
                    *numPtr4 = (short)0;
                    numPtr3 += num3;
                    numPtr4 += num3;
                }
                texture.Unlock();
            }
            return(new CursorEntry(idCursor, idType, xOffset, yOffset, texture));
        }
예제 #4
0
        protected internal override unsafe void Draw(int X, int Y)
        {
            if (this.m_ScrollTexture == null)
            {
                this.m_ScrollTexture = new Texture(16, 16, TextureTransparency.None);
                LockData lockData = this.m_ScrollTexture.Lock(LockFlags.WriteOnly);
                ushort   num1     = Engine.C32216(GumpColors.ControlLightLight);
                ushort   num2     = Engine.C32216(GumpColors.ScrollBar);
                for (int index1 = 0; index1 < 16; ++index1)
                {
                    ushort *numPtr = (ushort *)((IntPtr)lockData.pvSrc + index1 * lockData.Pitch);
                    for (int index2 = 0; index2 < 16; ++index2)
                    {
                        *numPtr++ = ((index1 & 1) + index2 & 1) != 0 ? num2 : num1;
                    }
                }
                this.m_ScrollTexture.Unlock();
            }
            this.m_ScrollTexture.Draw(X, Y, this.Width, this.Height);
            int barHeight = this.GetBarHeight();
            int num3      = Y + 16;
            int num4      = this.Height - 32;
            int position  = this.GetPosition(num4 - barHeight);

            Renderer.SetTexture((Texture)null);
            if (this.m_State == GEditorScroller.State.LargeScrollUp)
            {
                if (position > 0)
                {
                    Renderer.PushAlpha(0.9f);
                    Renderer.SolidRect(GumpColors.ControlDarkDark, X, Y + this.Width, this.Width, position);
                    Renderer.PopAlpha();
                    int num1 = this.PointToClient(new Point(Engine.m_xMouse, Engine.m_yMouse)).Y - 16;
                    if (position > num1)
                    {
                        this.Value -= this.LargeOffset;
                    }
                    else
                    {
                        this.m_State = GEditorScroller.State.Inactive;
                    }
                }
            }
            else if (this.m_State == GEditorScroller.State.LargeScrollDown && num4 - position - barHeight > 0)
            {
                Renderer.PushAlpha(0.9f);
                Renderer.SolidRect(GumpColors.ControlDarkDark, X, num3 + position + barHeight, this.Width, num4 - position - barHeight);
                Renderer.PopAlpha();
                int num1 = this.PointToClient(new Point(Engine.m_xMouse, Engine.m_yMouse)).Y - 16;
                if (position + barHeight < num1)
                {
                    this.Value += this.LargeOffset;
                }
                else
                {
                    this.m_State = GEditorScroller.State.Inactive;
                }
            }
            GumpPaint.DrawRaised3D(X, num3 + position, 16, barHeight);
            if (this.m_State == GEditorScroller.State.SmallScrollUp)
            {
                GumpPaint.DrawFlat(X, Y, this.Width, this.Width);
                Engine.m_WinScrolls[0].Draw(X + 5, Y + 7, GumpColors.ControlText);
                this.Value -= this.SmallOffset;
            }
            else
            {
                GumpPaint.DrawRaised3D(X, Y, this.Width, this.Width);
                Engine.m_WinScrolls[0].Draw(X + 4, Y + 6, GumpColors.ControlText);
            }
            Renderer.SetTexture((Texture)null);
            if (this.m_State == GEditorScroller.State.SmallScrollDown)
            {
                GumpPaint.DrawFlat(X, Y + this.Height - this.Width, this.Width, this.Width);
                Engine.m_WinScrolls[1].Draw(X + 5, Y + this.Height - this.Width + 7, GumpColors.ControlText);
                this.Value += this.SmallOffset;
            }
            else
            {
                GumpPaint.DrawRaised3D(X, Y + this.Height - this.Width, this.Width, this.Width);
                Engine.m_WinScrolls[1].Draw(X + 4, Y + this.Height - this.Width + 6, GumpColors.ControlText);
            }
        }
예제 #5
0
        private static unsafe void Load(int x, int y, int w, int h, int world, Texture tex)
        {
            if (GRadar.m_Colors == null)
            {
                GRadar.LoadColors();
            }
            if (GRadar.m_StrongReferences == null || GRadar.m_StrongReferences.Length != w * h)
            {
                GRadar.m_StrongReferences = new MapBlock[w * h];
            }
            if (GRadar.m_Guarded == null || GRadar.m_Guarded.Length != w * h * 64)
            {
                GRadar.m_Guarded = new BitArray(w * h * 64);
            }
            else
            {
                GRadar.m_Guarded.SetAll(false);
            }
            Region[] guardedRegions = Region.GuardedRegions;
            int      num1           = x * 8;
            int      num2           = y * 8;
            int      num3           = w * 8;
            int      num4           = h * 8;

            for (int index1 = 0; index1 < guardedRegions.Length; ++index1)
            {
                Region      region = guardedRegions[index1];
                RegionWorld world1 = region.World;
                bool        flag   = false;
                switch (world1)
                {
                case RegionWorld.Britannia:
                    flag = world == 0 || world == 1;
                    break;

                case RegionWorld.Felucca:
                    flag = world == 0;
                    break;

                case RegionWorld.Trammel:
                    flag = world == 1;
                    break;

                case RegionWorld.Ilshenar:
                    flag = world == 2;
                    break;

                case RegionWorld.Malas:
                    flag = world == 3;
                    break;

                case RegionWorld.Tokuno:
                    flag = world == 4;
                    break;
                }
                if (flag)
                {
                    int num5 = region.X - num1;
                    int num6 = region.Y - num2;
                    if (num5 < num3 && num6 < num4 && (num5 > -region.Width && num6 > -region.Height))
                    {
                        int num7 = num5 + region.Width;
                        int num8 = num6 + region.Height;
                        if (num5 < 0)
                        {
                            num5 = 0;
                        }
                        if (num6 < 0)
                        {
                            num6 = 0;
                        }
                        for (int index2 = num5; index2 < num7 && index2 < num3; ++index2)
                        {
                            for (int index3 = num6; index3 < num8 && index3 < num4; ++index3)
                            {
                                GRadar.m_Guarded[index3 * num3 + index2] = true;
                            }
                        }
                    }
                }
            }
            TileMatrix matrix   = Map.GetMatrix(world);
            LockData   lockData = tex.Lock(LockFlags.WriteOnly);
            int        num9     = lockData.Pitch >> 1;

            fixed(short *numPtr1 = GRadar.m_Colors)
            {
                for (int index1 = 0; index1 < w; ++index1)
                {
                    short *numPtr2 = (short *)((IntPtr)lockData.pvSrc + (index1 << 3) * 2);
                    for (int index2 = 0; index2 < h; ++index2)
                    {
                        MapBlock block = matrix.GetBlock(x + index1, y + index2);
                        GRadar.m_StrongReferences[index2 * w + index1] = block;
                        HuedTile[][][] huedTileArray = block == null ? matrix.EmptyStaticBlock : block.m_StaticTiles;
                        Tile[]         tileArray     = block == null ? matrix.InvalidLandBlock : block.m_LandTiles;
                        int            index3        = 0;
                        int            num5          = 0;
                        while (index3 < 8)
                        {
                            for (int index4 = 0; index4 < 8; ++index4)
                            {
                                int num6   = -255;
                                int num7   = -255;
                                int index5 = 0;
                                int num8   = 0;
                                for (int index6 = 0; index6 < huedTileArray[index4][index3].Length; ++index6)
                                {
                                    HuedTile huedTile = huedTileArray[index4][index3][index6];
                                    int      num10    = 16384 + (int)huedTile.itemId;
                                    switch (num10)
                                    {
                                    case 16385:
                                    case 22422:
                                    case 24996:
                                    case 24984:
                                    case 25020:
                                    case 24985:
                                        goto case 16385;

                                    default:
                                        int num11 = (int)huedTile.z;
                                        int num12 = num11 + (int)Map.GetItemHeight(huedTile.itemId);
                                        if (num12 > num6 || num11 > num7 && num12 >= num6)
                                        {
                                            num6   = num12;
                                            num7   = num11;
                                            index5 = num10;
                                            num8   = (int)huedTile.hueId;
                                            goto case 16385;
                                        }
                                        else
                                        {
                                            goto case 16385;
                                        }
                                    }
                                }
                                if ((int)tileArray[num5 + index4].z > num6 && tileArray[num5 + index4].Visible)
                                {
                                    index5 = (int)tileArray[num5 + index4].landId;
                                    num8   = 0;
                                }
                                numPtr2[index4] = num8 != 0 ? (short)Hues.Load(num8 & 16383 | 32768).Pixel((ushort)numPtr1[index5]) : numPtr1[index5];
                            }
                            numPtr2 += num9;
                            ++index3;
                            num5 += 8;
                        }
                    }
                }
                ArrayList items = Engine.Multis.Items;

                for (int index1 = 0; index1 < items.Count; ++index1)
                {
                    Item obj = (Item)items[index1];
                    if (obj.InWorld)
                    {
                        CustomMultiEntry customMulti = CustomMultiLoader.GetCustomMulti(obj.Serial, obj.Revision);
                        Multi            multi       = (Multi)null;
                        if (customMulti != null)
                        {
                            multi = customMulti.Multi;
                        }
                        if (multi == null)
                        {
                            multi = obj.Multi;
                        }
                        if (multi != null)
                        {
                            short[][] radar = multi.Radar;
                            if (radar != null)
                            {
                                int xMin;
                                int yMin;
                                int xMax;
                                int yMax;
                                multi.GetBounds(out xMin, out yMin, out xMax, out yMax);
                                int index2 = 0;
                                int num5   = obj.Y - (y << 3) + yMin;
                                while (index2 < radar.Length)
                                {
                                    if (num5 >= 0 && num5 < h << 3)
                                    {
                                        short * numPtr2  = (short *)((IntPtr)lockData.pvSrc + (num5 * num9) * 2);
                                        short[] numArray = radar[index2];
                                        int     index3   = 0;
                                        int     index4   = obj.X - (x << 3) + xMin;
                                        while (index3 < numArray.Length)
                                        {
                                            if (index4 >= 0 && index4 < w << 3 && (int)numArray[index3] != 0)
                                            {
                                                numPtr2[index4] = numPtr1[16384 + (int)numArray[index3]];
                                            }
                                            ++index3;
                                            ++index4;
                                        }
                                    }
                                    ++index2;
                                    ++num5;
                                }
                            }
                        }
                    }
                }
            }

            tex.Unlock();
        }