示例#1
0
        public XmlSimpleGump(object invoker, string gumptext, string gumptitle, int gumptype, BaseXmlSpawner.KeywordTag tag, Mobile from, XmlGumpCallback gumpcallback) : base(0, 0)
        {
            string maintext    = gumptext;
            int    nselections = 0;
            int    height      = 400;
            int    width       = 369;

            Closable   = false;
            Dragable   = true;
            m_gumptype = gumptype;

            m_invoker      = invoker;
            m_keywordtag   = tag;
            m_gumpcallback = gumpcallback;

            AddPage(0);


            // for the multiple selection gump, parse the gumptext for selections and responses
            if (gumptype == 4)
            {
                maintext    = ParseGumpText(gumptext);
                nselections = gumpSelections.Count;
                height      = height + nselections * 40;
            }
            if (gumptype == 5)
            {
                maintext    = ParseGumpText(gumptext);
                nselections = gumpSelections.Count;
                // the maintext in this case is a width,height specifier so parse it
                string [] args = maintext.Split(',');
                if (args != null && args.Length > 1)
                {
                    int.TryParse(args[0].Trim(), out width);
                    int.TryParse(args[1].Trim(), out height);
                }
            }

            AddImageTiled(54, 33, width, height, 2624);
            AddAlphaRegion(54, 33, width, height);

            AddImageTiled(width + 47, 39, 44, height - 11, 203);



            AddImageTiled(58, 39, 29, height - 10, 10460);             // left hand border
            AddImageTiled(width + 43, 37, 31, height - 11, 10460);     // right hand border

            AddImageTiled(40, 38, 17, height - 9, 9263);               // leftmost border



            //AddImageTiled( 94, 25, width - 27, 15, 10304 );  // top border
            AddImageTiled(40, 25, width + 48, 15, 10304);                // top border
            AddImageTiled(40, height + 27, width + 46, 16, 10304);       // bottom border

            if (gumptype != 5)
            {
                AddImage(width + 61, 9, 10441);                  // dragon borders
                AddImage(6, 25, 10421);
                AddImage(34, 12, 10420);
                AddImage(-10, height - 86, 10402);
                AddImage(56, 150, 10411);

                AddImage(136, 84, 96);                   // divider
                AddImage(width + 3, 57, 1417);           // quest icons
                AddImage(width + 12, 66, 5576);

                AddButton(width - 31, height - 8, 2130, 2129, 3, GumpButtonType.Reply, 0);                   // Okay button
            }
            else
            {
                AddButton(width + 70, 25, 0x138b, 0x138b, 0, GumpButtonType.Reply, 0);                   // closegump button
            }


            if (gumptitle != null && gumptitle.Length > 0 && gumptype != 5)
            {                             // display the title if it is there
                AddImage(156, 126, 2103); // bullet
                LocalAddHtml(gumptitle, 174, 121, 200, 40, 0x00FF42, false, false);
            }

            if (gumptype == 0)
            {             // simple message gump
                LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true);
            }
            else
            if (gumptype == 1)
            {                                                                               // Yes/no type gump
                AddRadio(101, height - 45, 9721, 9724, true, 1);                            // accept/yes radio
                AddRadio(101, height - 11, 9721, 9724, false, 2);                           // decline/no radio
                AddHtmlLocalized(137, height - 41, 200, 30, 1049016, 0x7fff, false, false); // Yes
                AddHtmlLocalized(137, height - 7, 200, 30, 1049017, 0x7fff, false, false);  // No

                LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true);
            }
            else
            if (gumptype == 2)
            {             // reply type gump
                AddImageTiled(134, height - 7, 159, 23, 0x52);
                AddImageTiled(135, height - 6, 157, 21, 0xBBC);
                AddHtmlLocalized(105, height - 7, 200, 30, 3002006, 0x7fff, false, false);                    // Say:
                AddTextEntry(135, height - 7, 150, 21, 0, 99, null);

                LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true);
            }
            else
            if (gumptype == 3)
            {                                                                               // Quest type gump
                AddImage(97, 49, 9005);                                                     // quest ribbon
                AddRadio(101, height - 45, 9721, 9724, true, 1);                            // accept/yes radio
                AddRadio(101, height - 11, 9721, 9724, false, 2);                           // decline/no radio
                AddHtmlLocalized(139, 59, 200, 30, 1046013, 0x7fff, false, false);          // Quest Offer
                AddHtmlLocalized(137, height - 41, 200, 30, 1049011, 0x7fff, false, false); // I accept!
                AddHtmlLocalized(137, height - 7, 200, 30, 1049012, 0x7fff, false, false);  // No thanks, I decline.

                LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true);
            }
            else
            if (gumptype == 4)
            {             // multiple selection type gump
                // parse the gump text to get the selections and responses

                for (int i = 0; i < gumpSelections.Count; i++)
                {
                    int y = 360 + i * 40;
                    AddRadio(101, y, 9721, 9724, i == 0 ? true: false, i);                     // accept/yes radio
                    AddHtml(137, y + 4, 250, 40, XmlSimpleGump.Color(gumpSelections[i].Selection, "FFFFFF"), false, false);
                }

                LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true);
            }
            else
            if (gumptype == 5)
            {
                // parse the gump text to get the selections and responses

                for (int i = 0; i < gumpSelections.Count; i++)
                {
                    string selection = gumpSelections[i].Selection;
                    string response  = gumpSelections[i].Response;

                    int       gx      = 0;
                    int       gy      = 0;
                    int       gwidth  = 0;
                    int       gheight = 0;
                    string    label   = null;
                    string [] args    = null;
                    int       gumpid  = 0;
                    int       color   = 0;

                    if (selection != null)
                    {
                        args = selection.Split(',');
                    }

                    // process the gumpitem specifications
                    if (args.Length > 1)
                    {
                        for (int j = 0; j < args.Length; j++)
                        {
                            args[j] = args[j].Trim();
                        }

                        if (args[0].ToLower() == "button")
                        {
                            // syntax is button,gumpid,x,y
                            if (args.Length > 3)
                            {
                                if (args[1].StartsWith("0x"))
                                {
                                    int.TryParse(args[1].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out gumpid);
                                }
                                else
                                {
                                    int.TryParse(args[1], out gumpid);
                                }
                                int.TryParse(args[2], out gx);
                                int.TryParse(args[3], out gy);

                                int buttonid = 1000 + i;

                                // add the button
                                AddButton(gx, gy, gumpid, gumpid, buttonid, GumpButtonType.Reply, 0);
                            }
                        }
                        else
                        if (args[0].ToLower() == "label")
                        {
                            // syntax is label,x,y,label[,color]
                            if (args.Length > 3)
                            {
                                int.TryParse(args[1], out gx);
                                int.TryParse(args[2], out gy);

                                label = args[3];
                            }
                            // set the default label color
                            color = 0x384;
                            if (args.Length > 4)
                            {
                                int.TryParse(args[4], out color);
                            }

                            // add the label
                            AddLabel(gx, gy, color, label);
                        }
                        else
                        if (args[0].ToLower() == "html")
                        {
                            // reparse the specification to allow for the possibility of commas in the html text
                            args  = selection.Split(new char[] { ',' }, 6);
                            color = 0xEFEF5A;

                            // syntax is html,x,y,width,height,text[,hue] * hue has to be in HEX format, ex: 0xFF00AA (lenght of 8 mandatory!)
                            if (args.Length > 5)
                            {
                                int.TryParse(args[1].Trim(), out gx);
                                int.TryParse(args[2].Trim(), out gy);
                                int.TryParse(args[3].Trim(), out gwidth);
                                int.TryParse(args[4].Trim(), out gheight);
                                if (args.Length > 6 && args[5].StartsWith("0x") && args[5].Trim().Length == 8)
                                {
                                    if (!int.TryParse(args[5].Trim().Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out color))
                                    {
                                        color = 0xEFEF5A;
                                    }
                                    label = args[6];
                                }
                                else
                                {
                                    label = args[5];
                                }
                            }

                            // add the html area
                            //AddHtml( gx, gy, gwidth, gheight, label, false, true );
                            LocalAddHtml(label, gx, gy, gwidth, gheight, color, false, true);
                        }
                        else
                        if (args[0].ToLower() == "textentry")
                        {
                            gumpSelections[i].GumpItemType = 1;

                            // syntax is textentry,x,y,width,height[,textcolor][,text]
                            if (args.Length > 4)
                            {
                                int.TryParse(args[1].Trim(), out gx);
                                int.TryParse(args[2].Trim(), out gy);
                                int.TryParse(args[3].Trim(), out gwidth);
                                int.TryParse(args[4].Trim(), out gheight);
                            }

                            if (args.Length > 5)
                            {
                                label = args[5];
                            }

                            // set the default textentry color
                            color = 0x384;
                            if (args.Length > 6)
                            {
                                int.TryParse(args[6], out color);
                            }

                            AddTextEntry(gx, gy, gwidth, gheight, color, i, label);
                        }
                        else
                        if (args[0].ToLower() == "radio")
                        {
                            int gumpid1 = 0;
                            int gumpid2 = 0;

                            // syntax is radio,gumpid1,gumpid2,x,y[,initialstate]
                            if (args.Length > 4)
                            {
                                int.TryParse(args[1].Trim(), out gumpid1);
                                int.TryParse(args[2].Trim(), out gumpid2);
                                int.TryParse(args[3].Trim(), out gx);
                                int.TryParse(args[4].Trim(), out gy);
                            }

                            bool initial = false;
                            if (args.Length > 5)
                            {
                                bool.TryParse(args[5], out initial);
                            }

                            AddRadio(gx, gy, gumpid1, gumpid2, initial, i);
                        }
                        else
                        if (args[0].ToLower() == "image")
                        {
                            // syntax is image,gumpid,x,y[,hue]
                            if (args.Length > 3)
                            {
                                if (args[1].StartsWith("0x"))
                                {
                                    int.TryParse(args[1].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out gumpid);
                                }
                                else
                                {
                                    int.TryParse(args[1], out gumpid);
                                }
                                int.TryParse(args[2], out gx);
                                int.TryParse(args[3], out gy);

                                if (args.Length > 4)
                                {
                                    int.TryParse(args[4], out color);
                                }

                                // add the image
                                AddImage(gx, gy, gumpid, color);
                            }
                        }
                        else
                        if (args[0].ToLower() == "imagetiled")
                        {
                            // syntax is imagetiled,gumpid,x,y,width,height
                            if (args.Length > 5)
                            {
                                if (args[1].StartsWith("0x"))
                                {
                                    int.TryParse(args[1].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out gumpid);
                                }
                                else
                                {
                                    int.TryParse(args[1], out gumpid);
                                }
                                int.TryParse(args[2], out gx);
                                int.TryParse(args[3], out gy);
                                int.TryParse(args[4], out gwidth);
                                int.TryParse(args[5], out gheight);

                                // add the image
                                AddImageTiled(gx, gy, gwidth, gheight, gumpid);
                            }
                        }
                        else
                        if (args[0].ToLower() == "item")
                        {
                            // syntax is item,itemid,x,y[,hue]
                            if (args.Length > 3)
                            {
                                if (args[1].StartsWith("0x"))
                                {
                                    int.TryParse(args[1].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out gumpid);
                                }
                                else
                                {
                                    int.TryParse(args[1], out gumpid);
                                }
                                int.TryParse(args[2], out gx);
                                int.TryParse(args[3], out gy);

                                if (args.Length > 4)
                                {
                                    int.TryParse(args[4], out color);
                                }

                                // add the image
                                AddItem(gx, gy, gumpid, color);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
 public XmlSimpleGump(object invoker, string gumptext, string gumptitle, int gumptype, BaseXmlSpawner.KeywordTag tag, Mobile from) : this(invoker, gumptext, gumptitle, gumptype, tag, from, null)
 {
 }