コード例 #1
0
            private static void IncomingPackets_InternalGenericGumpEvent(int client, int serial, int ID, int x, int y, string layout, string[] text)
            {
                Gump g = GumpParser.Parse(client, serial, ID, x, y, layout, text);

                if (g != null)
                {
                    ClientInfo ci;
                    if (ClientInfoCollection.GetClient(client, out ci))
                    {
                        ci.GenericGumps.Add(g);
                        General.OnCustomGump(client, g);
                    }
                }
            }
コード例 #2
0
        public void WillParseAuctionSafeGump()
        {
            const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";

            if (!Directory.Exists(localPath))
            {
                Debug.WriteLine("Not running test, requires Cliloc.enu");
                return;
            }

            Cliloc.Initialize(localPath);

            const string layout =
                "{ resizepic 0 0 9300 400 600 }{ xmfhtmltok 10 10 400 18 0 0 22660 1114513 @Heritage Raffle@ }{ xmfhtmltok 0 70 198 18 0 0 22660 1114514 @Can Buy Unlimited Tickets:@ }{ htmlgump 202 70 200 18 0 0 0 }{ xmfhtmltok 0 100 198 18 0 0 22660 1114514 @Currency Type:@ }{ htmlgump 202 100 200 18 1 0 0 }{ xmfhtmltok 0 130 198 18 0 0 22660 1114514 @Ticket Price:@ }{ htmlgump 202 130 200 18 2 0 0 }{ xmfhtmltok 0 160 198 18 0 0 22660 1114514 @Tickets Bought:@ }{ htmlgump 202 160 200 18 3 0 0 }{ xmfhtmltok 0 190 200 18 0 0 22660 1114514 @Odds of Winning:@ }{ htmlgump 202 190 200 18 4 0 0 }{ xmfhtmltok 0 220 198 18 0 0 22660 1114514 @Raffled Item:@ }{ xmfhtmltok 202 220 200 20 0 0 16 1114779 @The Lucky Sovereign Steed@ }{ tilepichue 90 314 8413 1152 }{ itemproperty 1074292781 }{ xmfhtmltok 200 243 200 18 0 0 22660 1154645 @Raffled Item Description:@ }{ htmlgump 202 263 197 140 5 1 1 }{ xmfhtmltok 0 450 198 18 0 0 22660 1114514 @Raffle Ticket Amount@ }{ resizepic 202 450 9350 193 22 }{ textentry 204 450 192 20 0 0 6 }{ button 168 480 4005 4007 1 0 1 }{ htmlgump 202 480 198 18 7 0 0 }{ xmfhtmltok 0 530 198 18 0 0 22660 1114514 @Raffle Ends:@ }{ htmlgump 202 530 198 18 8 0 0 }{ button 360 570 4020 4022 1 0 0 }{ xmfhtmltok 250 570 100 20 0 0 0 1114514 @#1060675@ }";

            Gump gump = GumpParser.Parse(0x01, 0x01, 1, 1, layout,
                                         new[] { "unknown", "unknown", "unknown", "unknown", "unknown", "unknown", "", "", "" });
        }
コード例 #3
0
        public void WillParseXmfHtmlTokCliloc()
        {
            const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";

            if (!Directory.Exists(localPath))
            {
                Debug.WriteLine("Not running test, requires Cliloc.enu");
                return;
            }

            Cliloc.Initialize(localPath);

            const string layout = "{ xmfhtmltok 250 570 100 20 0 0 0 1114514 @#1060675@ }";

            Gump gump = GumpParser.Parse(0x01, 0x01, 1, 1, layout, new string[] { });

            GumpElement ge = gump.GetElementByXY(250, 570);

            Assert.AreEqual("<DIV ALIGN=RIGHT>CLOSE</DIV>", ge.Text);
        }
コード例 #4
0
        public void WillParseXmfHtmlTokString()
        {
            const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";

            if (!Directory.Exists(localPath))
            {
                Debug.WriteLine("Not running test, requires Cliloc.enu");
                return;
            }

            Cliloc.Initialize(localPath);

            const string layout = "{ xmfhtmltok 10 10 400 18 0 0 22660 1114513 @Heritage Raffle@ }";

            Gump gump = GumpParser.Parse(0x01, 0x01, 1, 1, layout, new string[] { });

            GumpElement ge = gump.GetElementByXY(10, 10);

            Assert.AreEqual("<DIV ALIGN=CENTER>Heritage Raffle</DIV>", ge.Text);
        }
コード例 #5
0
        public void WillParseGump()
        {
            /*
             * Gump ID: 0x93a564c3
             * Pages: 1
             *
             * Layout: (230)
             *
             * { page 0 }
             * { resizepic 10 10 2600 500 135 }
             * { xmfhtmlgump 52 35 420 55 1006046 1 1 }
             * { button 60 95 4005 4007 1 0 1 }
             * { xmfhtmlgump 95 96 150 35 1006044 0 0 }
             * { button 285 95 4017 4019 1 0 0 }
             * { xmfhtmlgump 320 96 150 35 1006045 0 0 }
             *
             * Elements (6):
             *
             * X: 10, Y: 10, Type: resizepic, Cliloc: 0, Text:
             * X: 52, Y: 35, Type: xmfhtmlgump, Cliloc: 1006046, Text: You have reward items available.  Click 'ok' below to get the selection menu or 'cancel' to be prompted upon your next login.
             * X: 60, Y: 95, Type: button, Cliloc: 0, Text:
             * X: 95, Y: 96, Type: xmfhtmlgump, Cliloc: 1006044, Text: OK
             * X: 285, Y: 95, Type: button, Cliloc: 0, Text:
             * X: 320, Y: 96, Type: xmfhtmlgump, Cliloc: 1006045, Text: Cancel
             */

            // Clilocs removed to prevent dependancy on Cliloc.enu
            const string layout =
                "{ page 0 }{ resizepic 10 10 2600 500 135 }{ xmfhtmlgump 52 35 420 55 0 1 1 }{ button 60 95 4005 4007 1 0 1 }{ xmfhtmlgump 95 96 150 35 0 0 0 }{ button 285 95 4017 4019 1 0 0 }{ xmfhtmlgump 320 96 150 35 0 0 0 }";

            Gump gump = GumpParser.Parse(0x01, 0x93a564c3, 10, 10, layout, new string[0]);

            Assert.IsNotNull(gump);

            GumpElement gumpElement = gump.GetElementByXY(285, 95);

            Assert.IsNotNull(gumpElement);

            Assert.AreEqual(ElementType.button, gumpElement.Type);
        }
コード例 #6
0
ファイル: GumpObservers.cs プロジェクト: uoinfusion/Infusion
        public string LastGumpInfo()
        {
            lock (gumpLock)
            {
                if (CurrentGump == null)
                {
                    return("no gump");
                }

                var processor = new GumpParserDescriptionProcessor();
                var parser    = new GumpParser(processor);
                parser.Parse(CurrentGump);

                var builder = new StringBuilder();
                builder.AppendLine($"Id {CurrentGump.Id}, GumpId {CurrentGump.GumpTypeId}");
                builder.AppendLine(CurrentGump.Commands);
                builder.AppendLine("-----------------");
                builder.AppendLine(processor.GetDescription());

                return(builder.ToString());
            }
        }
コード例 #7
0
        private static void OnCompressedGump(PacketReader reader)
        {
            int  senderSerial = reader.ReadInt32();
            uint gumpId       = reader.ReadUInt32();

            Engine.GumpList.AddOrUpdate(gumpId, senderSerial, (k, v) => senderSerial);

            int x = reader.ReadInt32();
            int y = reader.ReadInt32();
            int compressedLength   = reader.ReadInt32();
            int decompressedLength = reader.ReadInt32() + 1;

            if (compressedLength <= 4)
            {
                return;
            }

            compressedLength -= 4;

            byte[] decompressedBuffer = new byte[decompressedLength];

            byte[] compressedBuffer = reader.ReadByteArray(compressedLength);

            bool success = Compression.Uncompress(ref decompressedBuffer, ref decompressedLength, compressedBuffer,
                                                  compressedLength);

            if (!success)
            {
                return;
            }

            string layout = Encoding.ASCII.GetString(decompressedBuffer);

            int linesCount = reader.ReadInt32();

            compressedLength   = reader.ReadInt32();
            decompressedLength = reader.ReadInt32() + 1;

            string[] text = new string[linesCount];

            if (compressedLength > 4)
            {
                compressedLength -= 4;

                decompressedBuffer = new byte[decompressedLength];

                compressedBuffer = reader.ReadByteArray(compressedLength);

                success = Compression.Uncompress(ref decompressedBuffer, ref decompressedLength, compressedBuffer,
                                                 compressedLength);

                if (!success)
                {
                    return;
                }

                int offset = 0;

                for (int i = 0; i < linesCount; i++)
                {
                    int length = ((decompressedBuffer[offset] << 8) | decompressedBuffer[offset + 1]) * 2;
                    offset += 2;
                    text[i] = Encoding.BigEndianUnicode.GetString(decompressedBuffer, offset, length);
                    offset += length;
                }
            }

            Gump gump = GumpParser.Parse(senderSerial, gumpId, x, y, layout, text);

            Engine.Gumps.Add(gump);

            GumpEvent?.Invoke(gumpId, senderSerial, gump);
        }
コード例 #8
0
        private static void OnCompressedGump(PacketReader reader)
        {
            int  senderSerial = reader.ReadInt32();
            uint gumpId       = reader.ReadUInt32();

            Engine.GumpList.AddOrUpdate(gumpId, senderSerial, (k, v) => senderSerial);

            int x = reader.ReadInt32();
            int y = reader.ReadInt32();
            int compressedLength   = reader.ReadInt32();
            int decompressedLength = reader.ReadInt32() + 1;

            if (compressedLength <= 4)
            {
                return;
            }

            compressedLength -= 4;

            byte[] decompressedBuffer = new byte[decompressedLength];

            byte[] compressedBuffer = reader.ReadByteArray(compressedLength);

            bool success = Compression.Uncompress(ref decompressedBuffer, ref decompressedLength, compressedBuffer,
                                                  compressedLength);

            if (!success)
            {
                return;
            }

            string layout = Encoding.ASCII.GetString(decompressedBuffer);

            int linesCount = reader.ReadInt32();

            compressedLength   = reader.ReadInt32();
            decompressedLength = reader.ReadInt32() + 1;

            string[] text = new string[linesCount];

            if (compressedLength > 4)
            {
                compressedLength -= 4;

                decompressedBuffer = new byte[decompressedLength];

                compressedBuffer = reader.ReadByteArray(compressedLength);

                success = Compression.Uncompress(ref decompressedBuffer, ref decompressedLength, compressedBuffer,
                                                 compressedLength);

                if (!success)
                {
                    return;
                }

                int offset = 0;

                for (int i = 0; i < linesCount; i++)
                {
                    int length = ((decompressedBuffer[offset] << 8) | decompressedBuffer[offset + 1]) * 2;
                    offset += 2;
                    text[i] = Encoding.BigEndianUnicode.GetString(decompressedBuffer, offset, length);
                    offset += length;
                }
            }

            try
            {
                Gump gump = GumpParser.Parse(senderSerial, gumpId, x, y, layout, text);
                Engine.Gumps.Add(gump);

                GumpEvent?.Invoke(gumpId, senderSerial, gump);
            }
            catch (Exception e)
            {
                e.ToExceptionless().SetProperty("Serial", senderSerial).SetProperty("GumpID", gumpId)
                .SetProperty("Layout", layout).SetProperty("Text", text)
                .SetProperty("Packet", reader.GetData()).SetProperty("Player", Engine.Player.ToString())
                .SetProperty("WorldItemCount", Engine.Items.Count())
                .SetProperty("WorldMobileCount", Engine.Mobiles.Count()).Submit();
            }
        }
コード例 #9
0
 public void Initialize()
 {
     processor = new GumpParserDescriptionProcessor();
     parser    = new GumpParser(processor);
 }