示例#1
0
 public virtual void Write(string name, GumpPage e)
 {
     AppendPage();
     CreatePageElement(e);
     SetPageAttribute("name", name);
     SetPageAttribute("value", e.Page);
 }
示例#2
0
 private void CreatePageElement(GumpPage e)
 {
     _CurrentPageNode = _Document.CreateElement(e.GetType().Name);
 }
示例#3
0
        public static Gump Parse(int client, int serial, int ID, int x, int y, string layout, string[] text)
        {
            bool closable = true, movable = true, disposable = true, resizable = true;

            List<GumpPage> pageList = new List<GumpPage>();
            List<GumpElement> gumpElementList = new List<GumpElement>();
            GumpElement lastGumpElement = null;
            GumpPage currentPage = null;
            if (String.IsNullOrEmpty(layout)) return null;
            string[] split = layout.Substring(layout.IndexOf('{')).TrimEnd('}', ' ').Split(new char[] { '}' }, StringSplitOptions.RemoveEmptyEntries);
            string[] formatted;
            for (int i = 0; i < split.Length; i++)
            {
                split[i] = split[i].TrimStart('{', ' ').Trim();
                formatted = split[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < formatted.Length; j++)
                    formatted[j] = formatted[j].Trim();

                switch (formatted[0])
                {
                    case "noclose":
                        closable = false;
                        break;
                    case "nodispose":
                        disposable = false;
                        break;
                    case "nomove":
                        movable = false;
                        break;
                    case "noresize":
                        resizable = false;
                        break;
                    case "button":
                        try
                        {
                            int gbX, gbY, gbNormalID, gbPressedID, gbID, gbType, gbParam;
                            if (Int32.TryParse(formatted[1], out gbX) &&
                                Int32.TryParse(formatted[2], out gbY) &&
                                Int32.TryParse(formatted[3], out gbNormalID) &&
                                Int32.TryParse(formatted[4], out gbPressedID) &&
                                Int32.TryParse(formatted[5], out gbType) &&
                                Int32.TryParse(formatted[6], out gbParam) &&
                                Int32.TryParse(formatted[7], out gbID))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.button;
                                ge.ParentPage = currentPage;
                                ge.X = gbX;
                                ge.Y = gbY;
                                ge.InactiveID = gbNormalID;
                                ge.ActiveID = gbPressedID;
                                ge.ElementID = gbID;
                                ge.ButtonType = gbType;
                                ge.Param = gbParam;
                                gumpElementList.Add(ge);
                            }
                            else OnError("button", layout);
                        }
                        catch { OnError("button", layout); }
                        break;
                    case "buttontileart":
                        try
                        {
                            int btX, btY, btNormalID, btPressedID, btID, btType, btParam, btItemID, btHue, btWidth, btHeight;
                            if (Int32.TryParse(formatted[1], out btX) &&
                                Int32.TryParse(formatted[2], out btY) &&
                                Int32.TryParse(formatted[3], out btNormalID) &&
                                Int32.TryParse(formatted[4], out btPressedID) &&
                                Int32.TryParse(formatted[5], out btType) &&
                                Int32.TryParse(formatted[6], out btParam) &&
                                Int32.TryParse(formatted[7], out btID) &&
                                Int32.TryParse(formatted[8], out btItemID) &&
                                Int32.TryParse(formatted[9], out btHue) &&
                                Int32.TryParse(formatted[10], out btWidth) &&
                                Int32.TryParse(formatted[11], out btHeight))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.buttontileart;
                                ge.ParentPage = currentPage;
                                ge.X = btX;
                                ge.Y = btY;
                                ge.ElementID = btID;
                                ge.ButtonType = btType;
                                ge.Height = btHeight;
                                ge.Width = btWidth;
                                ge.Hue = btHue;
                                ge.ItemID = btItemID;
                                ge.InactiveID = btNormalID;
                                ge.Param = btParam;
                                ge.ActiveID = btPressedID;
                                gumpElementList.Add(ge);
                                lastGumpElement = ge;
                            }
                            else OnError("buttontileart", layout);
                        }
                        catch { OnError("buttontileart", layout); }
                        break;
                    case "checkertrans":
                        try
                        {
                            int ctX, ctY, ctWidth, ctHeight;
                            if (Int32.TryParse(formatted[1], out ctX) &&
                                Int32.TryParse(formatted[2], out ctY) &&
                                Int32.TryParse(formatted[3], out ctWidth) &&
                                Int32.TryParse(formatted[4], out ctHeight))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.checkertrans;
                                ge.ParentPage = currentPage;
                                ge.X = ctX;
                                ge.Y = ctY;
                                ge.Width = ctWidth;
                                ge.Height = ctHeight;
                                gumpElementList.Add(ge);
                            }
                            else OnError("checkertrans", layout);
                        }
                        catch { OnError("checkertrans", layout); }
                        break;
                    case "croppedtext":
                        try
                        {
                            int crX, crY, crWidth, crHeight, crHue, crText;
                            if (Int32.TryParse(formatted[1], out crX) &&
                                Int32.TryParse(formatted[2], out crY) &&
                                Int32.TryParse(formatted[3], out crWidth) &&
                                Int32.TryParse(formatted[4], out crHeight) &&
                                Int32.TryParse(formatted[5], out crHue) &&
                                Int32.TryParse(formatted[6], out crText))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.croppedtext;
                                ge.ParentPage = currentPage;
                                ge.X = crX;
                                ge.Y = crY;
                                ge.Height = crHeight;
                                ge.Width = crWidth;
                                ge.Hue = crHue;
                                ge.Text = text[crText];
                                gumpElementList.Add(ge);
                            }
                            else OnError("croppedtext", layout);
                        }
                        catch { OnError("croppedtext", layout); }
                        break;
                    case "checkbox":
                        try
                        {
                            int cbX, cbY, cbInactiveID, cbActiveID, cbID, cbState;
                            if (Int32.TryParse(formatted[1], out cbX) &&
                                Int32.TryParse(formatted[2], out cbY) &&
                                Int32.TryParse(formatted[3], out cbInactiveID) &&
                                Int32.TryParse(formatted[4], out cbActiveID) &&
                                Int32.TryParse(formatted[5], out cbState) &&
                                Int32.TryParse(formatted[6], out cbID))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.checkbox;
                                ge.ParentPage = currentPage;
                                ge.X = cbX;
                                ge.Y = cbY;
                                ge.InactiveID = cbInactiveID;
                                ge.ActiveID = cbActiveID;
                                ge.ElementID = cbID;
                                ge.InitialState = cbState == 1;
                                gumpElementList.Add(ge);
                            }
                            else OnError("checkbox", layout);
                        }
                        catch { OnError("checkbox", layout); }
                        break;
                    case "page":
                        if (currentPage == null)
                            currentPage = new GumpPage();
                        else
                        {
                            currentPage.GumpElements = gumpElementList.ToArray();
                            pageList.Add(currentPage);
                            currentPage = new GumpPage();
                            gumpElementList = new List<GumpElement>();
                        }
                        int page;
                        if (Int32.TryParse(formatted[1], out page))
                        {
                            currentPage.Page = page;
                        }
                        else OnError("page", layout);
                        break;
                    case "gumppic":
                        try
                        {
                            int gpX, gpY, gpID, gpHue;
                            if (Int32.TryParse(formatted[1], out gpX) &&
                                Int32.TryParse(formatted[2], out gpY) &&
                                Int32.TryParse(formatted[3], out gpID))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.gumppic;
                                ge.ParentPage = currentPage;
                                if (formatted.Length > 4)
                                {
                                    for (int gp = 4; gp < formatted.Length; gp++)
                                    {
                                        if (formatted[gp].Contains("hue"))
                                        {
                                            if (GetInt(formatted[gp], out gpHue))
                                                ge.Hue = gpHue;
                                            else OnError("gumppic", layout);
                                        }
                                        else ge.Args = formatted[gp];
                                    }
                                }
                                ge.X = gpX;
                                ge.Y = gpY;
                                ge.ElementID = gpID;
                                gumpElementList.Add(ge);
                            }
                            else OnError("gumppic", layout);
                        }
                        catch { OnError("gumppic", layout); }
                        break;
                    case "gumppictiled":
                        try
                        {
                            int gtX, gtY, gtWidth, gtHeight, gtID;
                            if (Int32.TryParse(formatted[1], out gtX) &&
                                Int32.TryParse(formatted[2], out gtY) &&
                                Int32.TryParse(formatted[3], out gtWidth) &&
                                Int32.TryParse(formatted[4], out gtHeight) &&
                                Int32.TryParse(formatted[5], out gtID))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.gumppictiled;
                                ge.ParentPage = currentPage;
                                ge.X = gtX;
                                ge.Y = gtY;
                                ge.Width = gtWidth;
                                ge.Height = gtHeight;
                                ge.ElementID = gtID;
                                gumpElementList.Add(ge);
                            }
                            else OnError("gumppictiled", layout);
                        }
                        catch { OnError("gumppictiled", layout); }
                        break;
                    case "kr_xmfhtmlgump":
                        try
                        {
                            int xgX, xgY, xgWidth, xgHeight, xgCliloc, xgBackground, xgScrollbar;
                            if (Int32.TryParse(formatted[1], out xgX) &&
                               Int32.TryParse(formatted[2], out xgY) &&
                               Int32.TryParse(formatted[3], out xgWidth) &&
                               Int32.TryParse(formatted[4], out xgHeight) &&
                               Int32.TryParse(formatted[5], out xgCliloc) &&
                               Int32.TryParse(formatted[6], out xgBackground) &&
                               Int32.TryParse(formatted[7], out xgScrollbar))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.kr_xmfhtmlgump;
                                ge.ParentPage = currentPage;
                                ge.X = xgX;
                                ge.Y = xgY;
                                ge.Width = xgWidth;
                                ge.Height = xgHeight;
                                ge.Cliloc = xgCliloc;
                                ge.Background = xgBackground == 1;
                                ge.ScrollBar = xgScrollbar == 1;
                                if (xgCliloc != 0)
                                    ge.Text = Cliloc.GetProperty(xgCliloc);
                                gumpElementList.Add(ge);
                            }
                            else OnError("kr_xmfhtmlgump", layout);
                        }
                        catch { OnError("kr_xmfhtmlgump", layout); }
                        break;
                    case "mastergump":
                        try
                        {
                            int mgID;
                            if (Int32.TryParse(formatted[1], out mgID))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.mastergump;
                                ge.ParentPage = currentPage;
                                ge.ElementID = mgID;
                                gumpElementList.Add(ge);
                            }
                            else OnError("mastergump", layout);
                        }
                        catch { OnError("mastergump", layout); }
                        break;
                    case "radio":
                        try
                        {
                            int rX, rY, rInactiveID, rActiveID, rID, rState;
                            if (Int32.TryParse(formatted[1], out rX) &&
                                Int32.TryParse(formatted[2], out rY) &&
                                Int32.TryParse(formatted[3], out rInactiveID) &&
                                Int32.TryParse(formatted[4], out rActiveID) &&
                                Int32.TryParse(formatted[5], out rState) &&
                                Int32.TryParse(formatted[6], out rID))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.radio;
                                ge.ParentPage = currentPage;
                                ge.X = rX;
                                ge.Y = rY;
                                ge.InactiveID = rInactiveID;
                                ge.ActiveID = rActiveID;
                                ge.ElementID = rID;
                                ge.InitialState = rState == 1;
                                gumpElementList.Add(ge);
                            }
                            else OnError("radio", layout);
                        }
                        catch { OnError("radio", layout); }
                        break;
                    case "resizepic":
                        try
                        {
                            int rpX, rpY, rpWidth, rpHeight, rpID;
                            if (Int32.TryParse(formatted[1], out rpX) &&
                                Int32.TryParse(formatted[2], out rpY) &&
                                Int32.TryParse(formatted[3], out rpID) &&
                                Int32.TryParse(formatted[4], out rpWidth) &&
                                Int32.TryParse(formatted[5], out rpHeight))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.resizepic;
                                ge.ParentPage = currentPage;
                                ge.X = rpX;
                                ge.Y = rpY;
                                ge.Width = rpWidth;
                                ge.Height = rpWidth;
                                ge.ElementID = rpID;
                                gumpElementList.Add(ge);
                            }
                            else OnError("resizepic", layout);
                        }
                        catch { OnError("resizepic", layout); }
                        break;
                    case "text":
                        try
                        {
                            int tX, tY, tHue, tText;
                            if (Int32.TryParse(formatted[1], out tX) &&
                                Int32.TryParse(formatted[2], out tY) &&
                                Int32.TryParse(formatted[3], out tHue) &&
                                Int32.TryParse(formatted[4], out tText))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.text;
                                ge.ParentPage = currentPage;
                                ge.X = tX;
                                ge.Y = tY;
                                ge.Hue = tHue;
                                ge.Text = text[tText];
                                gumpElementList.Add(ge);
                            }
                            else OnError("text", layout);
                        }
                        catch { OnError("text", layout); }
                        break;
                    case "tooltip":
                        try
                        {
                            int tooltip;
                            if (Int32.TryParse(formatted[1], out tooltip) && lastGumpElement != null)
                            {
                                lastGumpElement.Tooltip = tooltip;
                                lastGumpElement.Text = Cliloc.GetProperty(tooltip);
                            }
                            else OnError("tooltip", layout);
                        }
                        catch { OnError("tooltip", layout); }
                        break;
                    case "htmlgump":
                        try
                        {
                            int hgX, hgY, hgWidth, hgHeight, hgText, hgBackground, hgScrollbar;
                            if (Int32.TryParse(formatted[1], out hgX) &&
                                Int32.TryParse(formatted[2], out hgY) &&
                                Int32.TryParse(formatted[3], out hgWidth) &&
                                Int32.TryParse(formatted[4], out hgHeight) &&
                                Int32.TryParse(formatted[5], out hgText) &&
                                Int32.TryParse(formatted[6], out hgBackground) &&
                                Int32.TryParse(formatted[7], out hgScrollbar))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.htmlgump;
                                ge.ParentPage = currentPage;
                                ge.X = hgX;
                                ge.Y = hgY;
                                ge.Width = hgWidth;
                                ge.Height = hgHeight;
                                ge.Text = text[hgText];
                                ge.ScrollBar = hgScrollbar == 1;
                                ge.Background = hgBackground == 1;
                                gumpElementList.Add(ge);
                            }
                            else OnError("htmlgump", layout);
                        }
                        catch { OnError("htmlgump", layout); }
                        break;
                    case "textentry":
                        try
                        {
                            int teX, teY, teWidth, teHeight, teText, teHue, teID;
                            if (Int32.TryParse(formatted[1], out teX) &&
                               Int32.TryParse(formatted[2], out teY) &&
                               Int32.TryParse(formatted[3], out teWidth) &&
                               Int32.TryParse(formatted[4], out teHeight) &&
                               Int32.TryParse(formatted[5], out teHue) &&
                               Int32.TryParse(formatted[6], out teID) &&
                               Int32.TryParse(formatted[7], out teText))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.textentry;
                                ge.ParentPage = currentPage;
                                ge.X = teX;
                                ge.Y = teY;
                                ge.Height = teHeight;
                                ge.Width = teWidth;
                                ge.Hue = teHue;
                                ge.ElementID = teID;
                                ge.Text = text[teText];
                                gumpElementList.Add(ge);
                            }
                            else OnError("textentry", layout);
                        }
                        catch { OnError("textentry", layout); }
                        break;
                    case "textentrylimited":
                        try
                        {
                            int tlX, tlY, tlWidth, tlHeight, tlText, tlHue, tlID, tlSize;
                            if (Int32.TryParse(formatted[1], out tlX) &&
                               Int32.TryParse(formatted[2], out tlY) &&
                               Int32.TryParse(formatted[3], out tlWidth) &&
                               Int32.TryParse(formatted[4], out tlHeight) &&
                               Int32.TryParse(formatted[5], out tlHue) &&
                               Int32.TryParse(formatted[6], out tlID) &&
                               Int32.TryParse(formatted[7], out tlText) &&
                               Int32.TryParse(formatted[8], out tlSize))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.textentrylimited;
                                ge.ParentPage = currentPage;
                                ge.X = tlX;
                                ge.Y = tlY;
                                ge.Height = tlHeight;
                                ge.Width = tlWidth;
                                ge.Hue = tlHue;
                                ge.ElementID = tlID;
                                ge.Text = text[tlText];
                                ge.Size = tlSize;
                                gumpElementList.Add(ge);
                            }
                            else OnError("textentrylimited", layout);
                        }
                        catch { OnError("textentrylimited", layout); }
                        break;
                    case "tilepic":
                        try
                        {
                            int tpX, tpY, tpID;
                            if (Int32.TryParse(formatted[1], out tpX) &&
                               Int32.TryParse(formatted[2], out tpY) &&
                               Int32.TryParse(formatted[3], out tpID))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.tilepic;
                                ge.ParentPage = currentPage;
                                ge.X = tpX;
                                ge.Y = tpY;
                                ge.ElementID = tpID;
                                gumpElementList.Add(ge);
                            }
                            else OnError("tilepic", layout);
                        }
                        catch { OnError("tilepic", layout); }
                        break;
                    case "tilepichue":
                        try
                        {
                            int tpX, tpY, tpID, tpHue;
                            if (Int32.TryParse(formatted[1], out tpX) &&
                               Int32.TryParse(formatted[2], out tpY) &&
                               Int32.TryParse(formatted[3], out tpID) &&
                               Int32.TryParse(formatted[4], out tpHue))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.tilepichue;
                                ge.ParentPage = currentPage;
                                ge.X = tpX;
                                ge.Y = tpY;
                                ge.ElementID = tpID;
                                ge.Hue = tpHue;
                                gumpElementList.Add(ge);
                            }
                            else OnError("tilepichue", layout);
                        }
                        catch { OnError("tilepichue", layout); }
                        break;
                    case "xmfhtmlgump":
                        try
                        {
                            int xgX, xgY, xgWidth, xgHeight, xgCliloc, xgBackground, xgScrollbar;
                            if (Int32.TryParse(formatted[1], out xgX) &&
                               Int32.TryParse(formatted[2], out xgY) &&
                               Int32.TryParse(formatted[3], out xgWidth) &&
                               Int32.TryParse(formatted[4], out xgHeight) &&
                               Int32.TryParse(formatted[5], out xgCliloc) &&
                               Int32.TryParse(formatted[6], out xgBackground) &&
                               Int32.TryParse(formatted[7], out xgScrollbar))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.xmfhtmlgump;
                                ge.ParentPage = currentPage;
                                ge.X = xgX;
                                ge.Y = xgY;
                                ge.Width = xgWidth;
                                ge.Height = xgHeight;
                                ge.Cliloc = xgCliloc;
                                ge.Background = xgBackground == 1;
                                ge.ScrollBar = xgScrollbar == 1;
                                if (xgCliloc != 0)
                                    ge.Text = Cliloc.GetProperty(xgCliloc);
                                gumpElementList.Add(ge);
                            }
                            else OnError("xmfhtmlgump", layout);
                        }
                        catch { OnError("xmfhtmlgump", layout); }
                        break;
                    case "xmfhtmlgumpcolor":
                        try
                        {
                            int xcX, xcY, xcWidth, xcHeight, xcCliloc, xcBackground, xcScrollbar, xcHue;
                            if (Int32.TryParse(formatted[1], out xcX) &&
                               Int32.TryParse(formatted[2], out xcY) &&
                               Int32.TryParse(formatted[3], out xcWidth) &&
                               Int32.TryParse(formatted[4], out xcHeight) &&
                               Int32.TryParse(formatted[5], out xcCliloc) &&
                               Int32.TryParse(formatted[6], out xcBackground) &&
                               Int32.TryParse(formatted[7], out xcScrollbar) &&
                               Int32.TryParse(formatted[8], out xcHue))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.xmfhtmlgumpcolor;
                                ge.ParentPage = currentPage;
                                ge.X = xcX;
                                ge.Y = xcY;
                                ge.Width = xcWidth;
                                ge.Height = xcHeight;
                                ge.Cliloc = xcCliloc;
                                ge.Background = xcBackground == 1;
                                ge.ScrollBar = xcScrollbar == 1;
                                ge.Hue = xcHue;
                                if (xcCliloc != 0)
                                    ge.Text = Cliloc.GetProperty(xcCliloc);
                                gumpElementList.Add(ge);
                            }
                            else OnError("xmfhtmlgumpcolor", layout);
                        }
                        catch { OnError("xmfhtmlgumpcolor", layout); }
                        break;
                    case "xmfhtmltok":
                        try
                        {
                            int xtX, xtY, xtWidth, xtHeight, xtCliloc, xtBackground, xtScrollbar, xtHue;
                            if (Int32.TryParse(formatted[1], out xtX) &&
                               Int32.TryParse(formatted[2], out xtY) &&
                               Int32.TryParse(formatted[3], out xtWidth) &&
                               Int32.TryParse(formatted[4], out xtHeight) &&
                               Int32.TryParse(formatted[5], out xtCliloc) &&
                               Int32.TryParse(formatted[6], out xtBackground) &&
                               Int32.TryParse(formatted[7], out xtScrollbar) &&
                               Int32.TryParse(formatted[8], out xtHue))
                            {
                                GumpElement ge = new GumpElement();
                                ge.Type = ElementType.xmfhtmltok;
                                ge.ParentPage = currentPage;
                                string[] args = GetTokens(formatted[9]);
                                ge.Text = Cliloc.GetLocalString(xtCliloc, args);
                                ge.Args = formatted[9];
                                ge.X = xtX;
                                ge.Y = xtY;
                                ge.Width = xtWidth;
                                ge.Height = xtHeight;
                                ge.Hue = xtHue;
                                ge.Cliloc = xtCliloc;
                                ge.ScrollBar = xtScrollbar == 1;
                                ge.Background = xtBackground == 1;
                                gumpElementList.Add(ge);
                            }
                            else OnError("xmfhtmltok", layout);
                        }
                        catch { OnError("xmfhtmltok", layout); }
                        break;
                    case "itemproperty":
                        int itemserial;
                        if (Int32.TryParse(formatted[1], out itemserial))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type = ElementType.itemproperty;
                            ge.Serial = itemserial;
                            gumpElementList.Add(ge);
                        }
                        break;
                    default:
                        Log.LogMessage(string.Format("Unknown element \"{0}\" in custom gump layout:\r\n\r\n{1}", formatted[0], layout));
                        break;
                }
            }

            if (currentPage != null)
            {
                currentPage.GumpElements = gumpElementList.ToArray();
                pageList.Add(currentPage);
            }
            Gump g = new Gump(client, x, y, ID, serial, layout, text, gumpElementList.ToArray(), pageList.ToArray());
            g.Closable = closable;
            g.Disposable = disposable;
            g.Movable = movable;
            g.Resizable = resizable;
            return g;
        }
示例#4
0
        protected override void CompileLayout(SuperGumpLayout layout)
        {
            base.CompileLayout(layout);

            if (Sources == null)
            {
                return;
            }

            Sources.ForEach(
                source =>
            {
                if (source == null || source.IsDisposed || !source.Compiled || !source.IsOpen)
                {
                    return;
                }

                source.Entries.For(
                    (i, src) =>
                {
                    if (src is GumpPage)
                    {
                        GumpPage e = (GumpPage)src;
                        layout.Add(source.Serial + "/" + i + "/GumpPage", () => AddPage(e.Page));
                    }
                    else if (src is GumpTooltip)
                    {
                        GumpTooltip e = (GumpTooltip)src;
                        layout.Add(source.Serial + "/" + i + "/GumpTooltip", () => AddTooltip(e.Number));
                    }
                    else if (src is GumpBackground)
                    {
                        GumpBackground e = (GumpBackground)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpBackground", () => AddBackground(e.X, e.Y, e.Width, e.Height, e.GumpID));
                    }
                    else if (src is GumpAlphaRegion)
                    {
                        GumpAlphaRegion e = (GumpAlphaRegion)src;
                        layout.Add(source.Serial + "/" + i + "/GumpAlphaRegion", () => AddAlphaRegion(e.X, e.Y, e.Width, e.Height));
                    }
                    else if (src is GumpItem)
                    {
                        GumpItem e = (GumpItem)src;
                        layout.Add(source.Serial + "/" + i + "/GumpItem", () => AddItem(e.X, e.Y, e.ItemID, e.Hue));
                    }
                    else if (src is GumpImage)
                    {
                        GumpImage e = (GumpImage)src;
                        layout.Add(source.Serial + "/" + i + "/GumpImage", () => AddImage(e.X, e.Y, e.GumpID, e.Hue));
                    }
                    else if (src is GumpImageTiled)
                    {
                        GumpImageTiled e = (GumpImageTiled)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpImageTiled", () => AddImageTiled(e.X, e.Y, e.Width, e.Height, e.GumpID));
                    }
                    else if (src is GumpImageTileButton)
                    {
                        GumpImageTileButton e = (GumpImageTileButton)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpImageTileButton",
                            () =>
                            AddImageTiledButton(
                                e.X, e.Y, e.NormalID, e.PressedID, e.ButtonID, e.Type, e.Param, e.ItemID, e.Hue, e.Width, e.Height));
                    }
                    else if (src is GumpLabel)
                    {
                        GumpLabel e = (GumpLabel)src;
                        layout.Add(source.Serial + "/" + i + "/GumpLabel", () => AddLabel(e.X, e.Y, e.Hue, e.Text));
                    }
                    else if (src is GumpLabelCropped)
                    {
                        GumpLabelCropped e = (GumpLabelCropped)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpLabelCropped",
                            () => AddLabelCropped(e.X, e.Y, e.Width, e.Height, e.Hue, e.Text));
                    }
                    else if (src is GumpHtml)
                    {
                        GumpHtml e = (GumpHtml)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpHtml",
                            () => AddHtml(e.X, e.Y, e.Width, e.Height, e.Text, e.Background, e.Scrollbar));
                    }
                    else if (src is GumpHtmlLocalized)
                    {
                        GumpHtmlLocalized e = (GumpHtmlLocalized)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpHtmlLocalized",
                            () => AddHtmlLocalized(e.X, e.Y, e.Width, e.Height, e.Number, e.Args, e.Color, e.Background, e.Scrollbar));
                    }
                    else if (src is GumpButton)
                    {
                        GumpButton e = (GumpButton)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpButton",
                            () => AddButton(e.X, e.Y, e.NormalID, e.PressedID, e.ButtonID, source.Buttons.GetValue(e)));
                    }
                    else if (src is GumpCheck)
                    {
                        GumpCheck e = (GumpCheck)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpCheck",
                            () => AddCheck(e.X, e.Y, e.InactiveID, e.ActiveID, e.SwitchID, e.InitialState, source.Switches.GetValue(e)));
                    }
                    else if (src is GumpRadio)
                    {
                        GumpRadio e = (GumpRadio)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpRadio",
                            () => AddRadio(e.X, e.Y, e.InactiveID, e.ActiveID, e.SwitchID, e.InitialState, source.Radios.GetValue(e)));
                    }
                    else if (src is GumpTextEntry)
                    {
                        GumpTextEntry e = (GumpTextEntry)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpTextEntry",
                            () => AddTextEntry(e.X, e.Y, e.Width, e.Height, e.Hue, e.EntryID, e.InitialText, source.TextInputs.GetValue(e)));
                    }
                    else if (src is GumpTextEntryLimited)
                    {
                        GumpTextEntryLimited e = (GumpTextEntryLimited)src;
                        var action             = source.LimitedTextInputs.GetValue(e);

                        layout.Add(
                            source.Serial + "/" + i + "/GumpTextEntryLimited",
                            () => AddTextEntryLimited(e.X, e.Y, e.Width, e.Height, e.Hue, e.EntryID, e.InitialText, e.Size, action));
                    }
                });

                layout.Add(
                    source.Serial + "/frame",
                    () =>
                {
                    AddImageTiled(source.X, source.Y, source.OuterWidth, 2, 11340);                                     //top
                    AddImageTiled(source.X + source.OuterWidth, source.Y, 2, source.OuterHeight, 11340);                //right
                    AddImageTiled(source.X, source.Y + source.OuterHeight, source.OuterWidth, 2, 11340);                //bottom
                    AddImageTiled(source.X, source.Y, 2, source.OuterHeight, 11340);                                    //left
                });
            });
        }
示例#5
0
        public static Gump Parse(int client, int serial, int ID, int x, int y, string layout, string[] text)
        {
            bool closable = true, movable = true, disposable = true, resizable = true;

            List <GumpPage>    pageList        = new List <GumpPage>();
            List <GumpElement> gumpElementList = new List <GumpElement>();
            GumpElement        lastGumpElement = null;
            GumpPage           currentPage     = null;

            if (String.IsNullOrEmpty(layout))
            {
                return(null);
            }
            string[] split = layout.Substring(layout.IndexOf('{')).TrimEnd('}', ' ').Split(new char[] { '}' }, StringSplitOptions.RemoveEmptyEntries);
            string[] formatted;
            for (int i = 0; i < split.Length; i++)
            {
                split[i]  = split[i].TrimStart('{', ' ').Trim();
                formatted = split[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < formatted.Length; j++)
                {
                    formatted[j] = formatted[j].Trim();
                }

                switch (formatted[0])
                {
                case "noclose":
                    closable = false;
                    break;

                case "nodispose":
                    disposable = false;
                    break;

                case "nomove":
                    movable = false;
                    break;

                case "noresize":
                    resizable = false;
                    break;

                case "button":
                    try
                    {
                        int gbX, gbY, gbNormalID, gbPressedID, gbID, gbType, gbParam;
                        if (Int32.TryParse(formatted[1], out gbX) &&
                            Int32.TryParse(formatted[2], out gbY) &&
                            Int32.TryParse(formatted[3], out gbNormalID) &&
                            Int32.TryParse(formatted[4], out gbPressedID) &&
                            Int32.TryParse(formatted[5], out gbType) &&
                            Int32.TryParse(formatted[6], out gbParam) &&
                            Int32.TryParse(formatted[7], out gbID))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.button;
                            ge.ParentPage = currentPage;
                            ge.X          = gbX;
                            ge.Y          = gbY;
                            ge.InactiveID = gbNormalID;
                            ge.ActiveID   = gbPressedID;
                            ge.ElementID  = gbID;
                            ge.ButtonType = gbType;
                            ge.Param      = gbParam;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("button", layout);
                        }
                    }
                    catch { OnError("button", layout); }
                    break;

                case "buttontileart":
                    try
                    {
                        int btX, btY, btNormalID, btPressedID, btID, btType, btParam, btItemID, btHue, btWidth, btHeight;
                        if (Int32.TryParse(formatted[1], out btX) &&
                            Int32.TryParse(formatted[2], out btY) &&
                            Int32.TryParse(formatted[3], out btNormalID) &&
                            Int32.TryParse(formatted[4], out btPressedID) &&
                            Int32.TryParse(formatted[5], out btType) &&
                            Int32.TryParse(formatted[6], out btParam) &&
                            Int32.TryParse(formatted[7], out btID) &&
                            Int32.TryParse(formatted[8], out btItemID) &&
                            Int32.TryParse(formatted[9], out btHue) &&
                            Int32.TryParse(formatted[10], out btWidth) &&
                            Int32.TryParse(formatted[11], out btHeight))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.buttontileart;
                            ge.ParentPage = currentPage;
                            ge.X          = btX;
                            ge.Y          = btY;
                            ge.ElementID  = btID;
                            ge.ButtonType = btType;
                            ge.Height     = btHeight;
                            ge.Width      = btWidth;
                            ge.Hue        = btHue;
                            ge.ItemID     = btItemID;
                            ge.InactiveID = btNormalID;
                            ge.Param      = btParam;
                            ge.ActiveID   = btPressedID;
                            gumpElementList.Add(ge);
                            lastGumpElement = ge;
                        }
                        else
                        {
                            OnError("buttontileart", layout);
                        }
                    }
                    catch { OnError("buttontileart", layout); }
                    break;

                case "checkertrans":
                    try
                    {
                        int ctX, ctY, ctWidth, ctHeight;
                        if (Int32.TryParse(formatted[1], out ctX) &&
                            Int32.TryParse(formatted[2], out ctY) &&
                            Int32.TryParse(formatted[3], out ctWidth) &&
                            Int32.TryParse(formatted[4], out ctHeight))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.checkertrans;
                            ge.ParentPage = currentPage;
                            ge.X          = ctX;
                            ge.Y          = ctY;
                            ge.Width      = ctWidth;
                            ge.Height     = ctHeight;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("checkertrans", layout);
                        }
                    }
                    catch { OnError("checkertrans", layout); }
                    break;

                case "croppedtext":
                    try
                    {
                        int crX, crY, crWidth, crHeight, crHue, crText;
                        if (Int32.TryParse(formatted[1], out crX) &&
                            Int32.TryParse(formatted[2], out crY) &&
                            Int32.TryParse(formatted[3], out crWidth) &&
                            Int32.TryParse(formatted[4], out crHeight) &&
                            Int32.TryParse(formatted[5], out crHue) &&
                            Int32.TryParse(formatted[6], out crText))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.croppedtext;
                            ge.ParentPage = currentPage;
                            ge.X          = crX;
                            ge.Y          = crY;
                            ge.Height     = crHeight;
                            ge.Width      = crWidth;
                            ge.Hue        = crHue;
                            ge.Text       = text[crText];
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("croppedtext", layout);
                        }
                    }
                    catch { OnError("croppedtext", layout); }
                    break;

                case "checkbox":
                    try
                    {
                        int cbX, cbY, cbInactiveID, cbActiveID, cbID, cbState;
                        if (Int32.TryParse(formatted[1], out cbX) &&
                            Int32.TryParse(formatted[2], out cbY) &&
                            Int32.TryParse(formatted[3], out cbInactiveID) &&
                            Int32.TryParse(formatted[4], out cbActiveID) &&
                            Int32.TryParse(formatted[5], out cbState) &&
                            Int32.TryParse(formatted[6], out cbID))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type         = ElementType.checkbox;
                            ge.ParentPage   = currentPage;
                            ge.X            = cbX;
                            ge.Y            = cbY;
                            ge.InactiveID   = cbInactiveID;
                            ge.ActiveID     = cbActiveID;
                            ge.ElementID    = cbID;
                            ge.InitialState = cbState == 1;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("checkbox", layout);
                        }
                    }
                    catch { OnError("checkbox", layout); }
                    break;

                case "page":
                    if (currentPage == null)
                    {
                        currentPage = new GumpPage();
                    }
                    else
                    {
                        currentPage.GumpElements = gumpElementList.ToArray();
                        pageList.Add(currentPage);
                        currentPage     = new GumpPage();
                        gumpElementList = new List <GumpElement>();
                    }
                    int page;
                    if (Int32.TryParse(formatted[1], out page))
                    {
                        currentPage.Page = page;
                    }
                    else
                    {
                        OnError("page", layout);
                    }
                    break;

                case "gumppic":
                    try
                    {
                        int gpX, gpY, gpID, gpHue;
                        if (Int32.TryParse(formatted[1], out gpX) &&
                            Int32.TryParse(formatted[2], out gpY) &&
                            Int32.TryParse(formatted[3], out gpID))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.gumppic;
                            ge.ParentPage = currentPage;
                            if (formatted.Length > 4)
                            {
                                for (int gp = 4; gp < formatted.Length; gp++)
                                {
                                    if (formatted[gp].Contains("hue"))
                                    {
                                        if (GetInt(formatted[gp], out gpHue))
                                        {
                                            ge.Hue = gpHue;
                                        }
                                        else
                                        {
                                            OnError("gumppic", layout);
                                        }
                                    }
                                    else
                                    {
                                        ge.Args = formatted[gp];
                                    }
                                }
                            }
                            ge.X         = gpX;
                            ge.Y         = gpY;
                            ge.ElementID = gpID;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("gumppic", layout);
                        }
                    }
                    catch { OnError("gumppic", layout); }
                    break;

                case "gumppictiled":
                    try
                    {
                        int gtX, gtY, gtWidth, gtHeight, gtID;
                        if (Int32.TryParse(formatted[1], out gtX) &&
                            Int32.TryParse(formatted[2], out gtY) &&
                            Int32.TryParse(formatted[3], out gtWidth) &&
                            Int32.TryParse(formatted[4], out gtHeight) &&
                            Int32.TryParse(formatted[5], out gtID))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.gumppictiled;
                            ge.ParentPage = currentPage;
                            ge.X          = gtX;
                            ge.Y          = gtY;
                            ge.Width      = gtWidth;
                            ge.Height     = gtHeight;
                            ge.ElementID  = gtID;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("gumppictiled", layout);
                        }
                    }
                    catch { OnError("gumppictiled", layout); }
                    break;

                case "kr_xmfhtmlgump":
                    try
                    {
                        int xgX, xgY, xgWidth, xgHeight, xgCliloc, xgBackground, xgScrollbar;
                        if (Int32.TryParse(formatted[1], out xgX) &&
                            Int32.TryParse(formatted[2], out xgY) &&
                            Int32.TryParse(formatted[3], out xgWidth) &&
                            Int32.TryParse(formatted[4], out xgHeight) &&
                            Int32.TryParse(formatted[5], out xgCliloc) &&
                            Int32.TryParse(formatted[6], out xgBackground) &&
                            Int32.TryParse(formatted[7], out xgScrollbar))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.kr_xmfhtmlgump;
                            ge.ParentPage = currentPage;
                            ge.X          = xgX;
                            ge.Y          = xgY;
                            ge.Width      = xgWidth;
                            ge.Height     = xgHeight;
                            ge.Cliloc     = xgCliloc;
                            ge.Background = xgBackground == 1;
                            ge.ScrollBar  = xgScrollbar == 1;
                            if (xgCliloc != 0)
                            {
                                ge.Text = Cliloc.GetProperty(xgCliloc);
                            }
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("kr_xmfhtmlgump", layout);
                        }
                    }
                    catch { OnError("kr_xmfhtmlgump", layout); }
                    break;

                case "mastergump":
                    try
                    {
                        int mgID;
                        if (Int32.TryParse(formatted[1], out mgID))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.mastergump;
                            ge.ParentPage = currentPage;
                            ge.ElementID  = mgID;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("mastergump", layout);
                        }
                    }
                    catch { OnError("mastergump", layout); }
                    break;

                case "radio":
                    try
                    {
                        int rX, rY, rInactiveID, rActiveID, rID, rState;
                        if (Int32.TryParse(formatted[1], out rX) &&
                            Int32.TryParse(formatted[2], out rY) &&
                            Int32.TryParse(formatted[3], out rInactiveID) &&
                            Int32.TryParse(formatted[4], out rActiveID) &&
                            Int32.TryParse(formatted[5], out rState) &&
                            Int32.TryParse(formatted[6], out rID))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type         = ElementType.radio;
                            ge.ParentPage   = currentPage;
                            ge.X            = rX;
                            ge.Y            = rY;
                            ge.InactiveID   = rInactiveID;
                            ge.ActiveID     = rActiveID;
                            ge.ElementID    = rID;
                            ge.InitialState = rState == 1;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("radio", layout);
                        }
                    }
                    catch { OnError("radio", layout); }
                    break;

                case "resizepic":
                    try
                    {
                        int rpX, rpY, rpWidth, rpHeight, rpID;
                        if (Int32.TryParse(formatted[1], out rpX) &&
                            Int32.TryParse(formatted[2], out rpY) &&
                            Int32.TryParse(formatted[3], out rpID) &&
                            Int32.TryParse(formatted[4], out rpWidth) &&
                            Int32.TryParse(formatted[5], out rpHeight))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.resizepic;
                            ge.ParentPage = currentPage;
                            ge.X          = rpX;
                            ge.Y          = rpY;
                            ge.Width      = rpWidth;
                            ge.Height     = rpWidth;
                            ge.ElementID  = rpID;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("resizepic", layout);
                        }
                    }
                    catch { OnError("resizepic", layout); }
                    break;

                case "text":
                    try
                    {
                        int tX, tY, tHue, tText;
                        if (Int32.TryParse(formatted[1], out tX) &&
                            Int32.TryParse(formatted[2], out tY) &&
                            Int32.TryParse(formatted[3], out tHue) &&
                            Int32.TryParse(formatted[4], out tText))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.text;
                            ge.ParentPage = currentPage;
                            ge.X          = tX;
                            ge.Y          = tY;
                            ge.Hue        = tHue;
                            ge.Text       = text[tText];
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("text", layout);
                        }
                    }
                    catch { OnError("text", layout); }
                    break;

                case "tooltip":
                    try
                    {
                        int tooltip;
                        if (Int32.TryParse(formatted[1], out tooltip) && lastGumpElement != null)
                        {
                            lastGumpElement.Tooltip = tooltip;
                            lastGumpElement.Text    = Cliloc.GetProperty(tooltip);
                        }
                        else
                        {
                            OnError("tooltip", layout);
                        }
                    }
                    catch { OnError("tooltip", layout); }
                    break;

                case "htmlgump":
                    try
                    {
                        int hgX, hgY, hgWidth, hgHeight, hgText, hgBackground, hgScrollbar;
                        if (Int32.TryParse(formatted[1], out hgX) &&
                            Int32.TryParse(formatted[2], out hgY) &&
                            Int32.TryParse(formatted[3], out hgWidth) &&
                            Int32.TryParse(formatted[4], out hgHeight) &&
                            Int32.TryParse(formatted[5], out hgText) &&
                            Int32.TryParse(formatted[6], out hgBackground) &&
                            Int32.TryParse(formatted[7], out hgScrollbar))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.htmlgump;
                            ge.ParentPage = currentPage;
                            ge.X          = hgX;
                            ge.Y          = hgY;
                            ge.Width      = hgWidth;
                            ge.Height     = hgHeight;
                            ge.Text       = text[hgText];
                            ge.ScrollBar  = hgScrollbar == 1;
                            ge.Background = hgBackground == 1;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("htmlgump", layout);
                        }
                    }
                    catch { OnError("htmlgump", layout); }
                    break;

                case "textentry":
                    try
                    {
                        int teX, teY, teWidth, teHeight, teText, teHue, teID;
                        if (Int32.TryParse(formatted[1], out teX) &&
                            Int32.TryParse(formatted[2], out teY) &&
                            Int32.TryParse(formatted[3], out teWidth) &&
                            Int32.TryParse(formatted[4], out teHeight) &&
                            Int32.TryParse(formatted[5], out teHue) &&
                            Int32.TryParse(formatted[6], out teID) &&
                            Int32.TryParse(formatted[7], out teText))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.textentry;
                            ge.ParentPage = currentPage;
                            ge.X          = teX;
                            ge.Y          = teY;
                            ge.Height     = teHeight;
                            ge.Width      = teWidth;
                            ge.Hue        = teHue;
                            ge.ElementID  = teID;
                            ge.Text       = text[teText];
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("textentry", layout);
                        }
                    }
                    catch { OnError("textentry", layout); }
                    break;

                case "textentrylimited":
                    try
                    {
                        int tlX, tlY, tlWidth, tlHeight, tlText, tlHue, tlID, tlSize;
                        if (Int32.TryParse(formatted[1], out tlX) &&
                            Int32.TryParse(formatted[2], out tlY) &&
                            Int32.TryParse(formatted[3], out tlWidth) &&
                            Int32.TryParse(formatted[4], out tlHeight) &&
                            Int32.TryParse(formatted[5], out tlHue) &&
                            Int32.TryParse(formatted[6], out tlID) &&
                            Int32.TryParse(formatted[7], out tlText) &&
                            Int32.TryParse(formatted[8], out tlSize))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.textentrylimited;
                            ge.ParentPage = currentPage;
                            ge.X          = tlX;
                            ge.Y          = tlY;
                            ge.Height     = tlHeight;
                            ge.Width      = tlWidth;
                            ge.Hue        = tlHue;
                            ge.ElementID  = tlID;
                            ge.Text       = text[tlText];
                            ge.Size       = tlSize;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("textentrylimited", layout);
                        }
                    }
                    catch { OnError("textentrylimited", layout); }
                    break;

                case "tilepic":
                    try
                    {
                        int tpX, tpY, tpID;
                        if (Int32.TryParse(formatted[1], out tpX) &&
                            Int32.TryParse(formatted[2], out tpY) &&
                            Int32.TryParse(formatted[3], out tpID))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.tilepic;
                            ge.ParentPage = currentPage;
                            ge.X          = tpX;
                            ge.Y          = tpY;
                            ge.ElementID  = tpID;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("tilepic", layout);
                        }
                    }
                    catch { OnError("tilepic", layout); }
                    break;

                case "tilepichue":
                    try
                    {
                        int tpX, tpY, tpID, tpHue;
                        if (Int32.TryParse(formatted[1], out tpX) &&
                            Int32.TryParse(formatted[2], out tpY) &&
                            Int32.TryParse(formatted[3], out tpID) &&
                            Int32.TryParse(formatted[4], out tpHue))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.tilepichue;
                            ge.ParentPage = currentPage;
                            ge.X          = tpX;
                            ge.Y          = tpY;
                            ge.ElementID  = tpID;
                            ge.Hue        = tpHue;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("tilepichue", layout);
                        }
                    }
                    catch { OnError("tilepichue", layout); }
                    break;

                case "xmfhtmlgump":
                    try
                    {
                        int xgX, xgY, xgWidth, xgHeight, xgCliloc, xgBackground, xgScrollbar;
                        if (Int32.TryParse(formatted[1], out xgX) &&
                            Int32.TryParse(formatted[2], out xgY) &&
                            Int32.TryParse(formatted[3], out xgWidth) &&
                            Int32.TryParse(formatted[4], out xgHeight) &&
                            Int32.TryParse(formatted[5], out xgCliloc) &&
                            Int32.TryParse(formatted[6], out xgBackground) &&
                            Int32.TryParse(formatted[7], out xgScrollbar))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.xmfhtmlgump;
                            ge.ParentPage = currentPage;
                            ge.X          = xgX;
                            ge.Y          = xgY;
                            ge.Width      = xgWidth;
                            ge.Height     = xgHeight;
                            ge.Cliloc     = xgCliloc;
                            ge.Background = xgBackground == 1;
                            ge.ScrollBar  = xgScrollbar == 1;
                            if (xgCliloc != 0)
                            {
                                ge.Text = Cliloc.GetProperty(xgCliloc);
                            }
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("xmfhtmlgump", layout);
                        }
                    }
                    catch { OnError("xmfhtmlgump", layout); }
                    break;

                case "xmfhtmlgumpcolor":
                    try
                    {
                        int xcX, xcY, xcWidth, xcHeight, xcCliloc, xcBackground, xcScrollbar, xcHue;
                        if (Int32.TryParse(formatted[1], out xcX) &&
                            Int32.TryParse(formatted[2], out xcY) &&
                            Int32.TryParse(formatted[3], out xcWidth) &&
                            Int32.TryParse(formatted[4], out xcHeight) &&
                            Int32.TryParse(formatted[5], out xcCliloc) &&
                            Int32.TryParse(formatted[6], out xcBackground) &&
                            Int32.TryParse(formatted[7], out xcScrollbar) &&
                            Int32.TryParse(formatted[8], out xcHue))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.xmfhtmlgumpcolor;
                            ge.ParentPage = currentPage;
                            ge.X          = xcX;
                            ge.Y          = xcY;
                            ge.Width      = xcWidth;
                            ge.Height     = xcHeight;
                            ge.Cliloc     = xcCliloc;
                            ge.Background = xcBackground == 1;
                            ge.ScrollBar  = xcScrollbar == 1;
                            ge.Hue        = xcHue;
                            if (xcCliloc != 0)
                            {
                                ge.Text = Cliloc.GetProperty(xcCliloc);
                            }
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("xmfhtmlgumpcolor", layout);
                        }
                    }
                    catch { OnError("xmfhtmlgumpcolor", layout); }
                    break;

                case "xmfhtmltok":
                    try
                    {
                        int xtX, xtY, xtWidth, xtHeight, xtCliloc, xtBackground, xtScrollbar, xtHue;
                        if (Int32.TryParse(formatted[1], out xtX) &&
                            Int32.TryParse(formatted[2], out xtY) &&
                            Int32.TryParse(formatted[3], out xtWidth) &&
                            Int32.TryParse(formatted[4], out xtHeight) &&
                            Int32.TryParse(formatted[5], out xtCliloc) &&
                            Int32.TryParse(formatted[6], out xtBackground) &&
                            Int32.TryParse(formatted[7], out xtScrollbar) &&
                            Int32.TryParse(formatted[8], out xtHue))
                        {
                            GumpElement ge = new GumpElement();
                            ge.Type       = ElementType.xmfhtmltok;
                            ge.ParentPage = currentPage;
                            string[] args = GetTokens(formatted[9]);
                            ge.Text       = Cliloc.GetLocalString(xtCliloc, args);
                            ge.Args       = formatted[9];
                            ge.X          = xtX;
                            ge.Y          = xtY;
                            ge.Width      = xtWidth;
                            ge.Height     = xtHeight;
                            ge.Hue        = xtHue;
                            ge.Cliloc     = xtCliloc;
                            ge.ScrollBar  = xtScrollbar == 1;
                            ge.Background = xtBackground == 1;
                            gumpElementList.Add(ge);
                        }
                        else
                        {
                            OnError("xmfhtmltok", layout);
                        }
                    }
                    catch { OnError("xmfhtmltok", layout); }
                    break;

                case "itemproperty":
                    int itemserial;
                    if (Int32.TryParse(formatted[1], out itemserial))
                    {
                        GumpElement ge = new GumpElement();
                        ge.Type   = ElementType.itemproperty;
                        ge.Serial = itemserial;
                        gumpElementList.Add(ge);
                    }
                    break;

                default:
                    Log.LogMessage(string.Format("Unknown element \"{0}\" in custom gump layout:\r\n\r\n{1}", formatted[0], layout));
                    break;
                }
            }

            if (currentPage != null)
            {
                currentPage.GumpElements = gumpElementList.ToArray();
                pageList.Add(currentPage);
            }
            Gump g = new Gump(client, x, y, ID, serial, layout, text, gumpElementList.ToArray(), pageList.ToArray());

            g.Closable   = closable;
            g.Disposable = disposable;
            g.Movable    = movable;
            g.Resizable  = resizable;
            return(g);
        }
示例#6
0
 public static void AppendTo(this GumpPage g, IGumpWriter disp, List <string> strings)
 {
     disp.AppendLayout(GumpPage.LayoutName);
     disp.AppendLayout(g.Page);
 }
示例#7
0
 public static void AppendTo(this GumpPage g, IGumpWriter disp, List <string> strings)
 {
     disp.AppendLayout(Gump.StringToBuffer("page"));
     disp.AppendLayout(g.Page);
 }