Example #1
0
            private Point?GetControlCoordinates(AnchorableGump control)
            {
                for (int x = 0; x < controlMatrix.GetLength(0); x++)
                {
                    for (int y = 0; y < controlMatrix.GetLength(1); y++)
                    {
                        if (controlMatrix[x, y] == control)
                        {
                            return(new Point(x, y));
                        }
                    }
                }

                return(null);
            }
Example #2
0
        public Point GetCandidateDropLocation(AnchorableGump draggedControl, AnchorableGump host, int x, int y)
        {
            if (host.AnchorGroupName == draggedControl.AnchorGroupName && this[draggedControl] == null)
            {
                AnchorDirection direction = GetAnchorDirection(host, x, y);

                if (this[host] == null || this[host].IsEmptyDirection(host, direction))
                {
                    var offset = _anchorDirectionMatrix[(int)direction] * new Point(draggedControl.Width, draggedControl.Height);
                    return(new Point(host.X + offset.X, host.Y + offset.Y));
                }
            }

            return(draggedControl.Location);
        }
Example #3
0
        private Point?GetAnchorDirection(AnchorableGump draggedControl, AnchorableGump host, int x, int y)
        {
            for (int xMult = 0; xMult < host.WidthMultiplier; xMult++)
            {
                for (int yMult = 0; yMult < host.HeightMultiplier; yMult++)
                {
                    var snapX = x - (host.GroupMatrixWidth * xMult);
                    var snapY = y - (host.GroupMatrixHeight * yMult);

                    var anchorPoint = new Vector2((float)snapX / host.GroupMatrixWidth, (float)snapY / host.GroupMatrixHeight);

                    if (xMult == 0)
                    {
                        if (IsPointInPolygon(_anchorTriangles[(int)AnchorDirection.Left], anchorPoint))
                        {
                            return(new Point(-draggedControl.WidthMultiplier, yMult));
                        }
                    }

                    if (yMult == 0)
                    {
                        if (IsPointInPolygon(_anchorTriangles[(int)AnchorDirection.Top], anchorPoint))
                        {
                            return(new Point(xMult, -draggedControl.HeightMultiplier));
                        }
                    }

                    if (xMult == host.WidthMultiplier - 1)
                    {
                        if (IsPointInPolygon(_anchorTriangles[(int)AnchorDirection.Right], anchorPoint))
                        {
                            return(new Point(1 + xMult, yMult));
                        }
                    }

                    if (yMult == host.HeightMultiplier - 1)
                    {
                        if (IsPointInPolygon(_anchorTriangles[(int)AnchorDirection.Bottom], anchorPoint))
                        {
                            return(new Point(xMult, 1 + yMult));
                        }
                    }
                }
            }

            return(null);
        }
Example #4
0
        public Point GetCandidateDropLocation(AnchorableGump draggedControl, AnchorableGump host, int x, int y)
        {
            if (host.AnchorGroupName == draggedControl.AnchorGroupName && this[draggedControl] == null)
            {
                Point?relativePosition = GetAnchorDirection(draggedControl, host, x, y);
                if (relativePosition.HasValue)
                {
                    if (this[host] == null || this[host].IsEmptyDirection(draggedControl, host, relativePosition.Value))
                    {
                        var offset = relativePosition.Value * new Point(host.GroupMatrixWidth, host.GroupMatrixHeight);
                        return(new Point(host.X + offset.X, host.Y + offset.Y));
                    }
                }
            }

            return(draggedControl.Location);
        }
Example #5
0
        public void DropControl(AnchorableGump draggedControl, AnchorableGump host, int x, int y)
        {
            if (host.AnchorGroupName == draggedControl.AnchorGroupName && this[draggedControl] == null)
            {
                AnchorDirection direction = GetAnchorDirection(host, x, y);

                if (this[host] == null)
                {
                    this[host] = new AnchorGroup(host);
                }

                if (this[host].IsEmptyDirection(host, direction))
                {
                    this[host].AnchorControlAt(draggedControl, host, direction);
                    this[draggedControl] = this[host];
                }
            }
        }
Example #6
0
        private bool IsOverlapping(AnchorableGump control, AnchorableGump host)
        {
            if (control == host)
            {
                return(false);
            }

            if (control.Bounds.Top > host.Bounds.Bottom || control.Bounds.Bottom < host.Bounds.Top)
            {
                return(false);
            }

            if (control.Bounds.Right < host.Bounds.Left || control.Bounds.Left > host.Bounds.Right)
            {
                return(false);
            }

            return(true);
        }
Example #7
0
            public void AnchorControlAt(AnchorableGump control, AnchorableGump host, Point relativePosition)
            {
                Point?hostPosition = GetControlCoordinates(host);

                if (hostPosition.HasValue)
                {
                    int targetX = hostPosition.Value.X + relativePosition.X;
                    int targetY = hostPosition.Value.Y + relativePosition.Y;

                    if (IsEmptyDirection(targetX, targetY))
                    {
                        if (targetX < 0) // Create new column left
                        {
                            ResizeMatrix(controlMatrix.GetLength(0) + control.WidthMultiplier, controlMatrix.GetLength(1), control.WidthMultiplier, 0);
                        }
                        else if (targetX > controlMatrix.GetLength(0) - control.WidthMultiplier) // Create new column right
                        {
                            ResizeMatrix(controlMatrix.GetLength(0) + control.WidthMultiplier, controlMatrix.GetLength(1), 0, 0);
                        }

                        if (targetY < 0) //Create new row top
                        {
                            ResizeMatrix(controlMatrix.GetLength(0), controlMatrix.GetLength(1) + control.HeightMultiplier, 0, control.HeightMultiplier);
                        }
                        else if (targetY > controlMatrix.GetLength(1) - 1) // Create new row bottom
                        {
                            ResizeMatrix(controlMatrix.GetLength(0), controlMatrix.GetLength(1) + control.HeightMultiplier, 0, 0);
                        }


                        hostPosition = GetControlCoordinates(host);

                        if (hostPosition.HasValue)
                        {
                            targetX = hostPosition.Value.X + relativePosition.X;
                            targetY = hostPosition.Value.Y + relativePosition.Y;

                            AddControlToMatrix(targetX, targetY, control);
                        }
                    }
                }
            }
Example #8
0
 public void DetachControl(AnchorableGump control)
 {
     if (this[control] != null)
     {
         var group = reverseMap.Where(o => o.Value == this[control]).Select(o => o.Key).ToList();
         if (group.Count == 2) // if detach 1+1 - need destroy all group
         {
             foreach (var ctrl in group)
             {
                 this[ctrl].DetachControl(ctrl);
                 this[ctrl] = null;
             }
         }
         else
         {
             this[control].DetachControl(control);
             this[control] = null;
         }
     }
 }
Example #9
0
        public void DropControl(AnchorableGump draggedControl, AnchorableGump host, int x, int y)
        {
            if (host.AnchorGroupName == draggedControl.AnchorGroupName && this[draggedControl] == null)
            {
                Point?relativePosition = GetAnchorDirection(draggedControl, host, x, y);
                if (relativePosition.HasValue)
                {
                    if (this[host] == null)
                    {
                        this[host] = new AnchorGroup(host);
                    }

                    if (this[host].IsEmptyDirection(draggedControl, host, relativePosition.Value))
                    {
                        this[host].AnchorControlAt(draggedControl, host, relativePosition.Value);
                        this[draggedControl] = this[host];
                    }
                }
            }
        }
Example #10
0
            public void AnchorControlAt(AnchorableGump control, AnchorableGump host, AnchorDirection direction)
            {
                Point?hostDirection = GetControlCoordinates(host);

                if (hostDirection.HasValue)
                {
                    var targetX = hostDirection.Value.X + _anchorDirectionMatrix[(int)direction].X;
                    var targetY = hostDirection.Value.Y + _anchorDirectionMatrix[(int)direction].Y;

                    if (IsEmptyDirection(targetX, targetY))
                    {
                        if (targetX < 0) // Create new column left
                        {
                            ResizeMatrix(controlMatrix.GetLength(0) + 1, controlMatrix.GetLength(1), 1, 0);
                        }
                        else if (targetX > controlMatrix.GetLength(0) - 1) // Create new column right
                        {
                            ResizeMatrix(controlMatrix.GetLength(0) + 1, controlMatrix.GetLength(1), 0, 0);
                        }

                        if (targetY < 0) //Create new row top
                        {
                            ResizeMatrix(controlMatrix.GetLength(0), controlMatrix.GetLength(1) + 1, 0, 1);
                        }
                        else if (targetY > controlMatrix.GetLength(1) - 1) // Create new row bottom
                        {
                            ResizeMatrix(controlMatrix.GetLength(0), controlMatrix.GetLength(1) + 1, 0, 0);
                        }


                        hostDirection = GetControlCoordinates(host);

                        if (hostDirection.HasValue)
                        {
                            targetX = hostDirection.Value.X + _anchorDirectionMatrix[(int)direction].X;
                            targetY = hostDirection.Value.Y + _anchorDirectionMatrix[(int)direction].Y;
                            controlMatrix[targetX, targetY] = control;
                        }
                    }
                }
            }
Example #11
0
        public AnchorGroup this[AnchorableGump control]
        {
            get
            {
                reverseMap.TryGetValue(control, out AnchorGroup @group);

                return(group);
            }

            private set
            {
                if (reverseMap.ContainsKey(control) && value == null)
                {
                    reverseMap.Remove(control);
                }
                else
                {
                    reverseMap.Add(control, value);
                }
            }
        }
Example #12
0
        private (Point?, AnchorableGump) GetAnchorDirection(AnchorableGump draggedControl, AnchorableGump host)
        {
            int xdistancescale = Math.Abs(draggedControl.X - host.X) * 100 / host.Width;
            int ydistancescale = Math.Abs(draggedControl.Y - host.Y) * 100 / host.Height;

            if (xdistancescale > ydistancescale)
            {
                if (draggedControl.X > host.X)
                {
                    return(new Point(host.WidthMultiplier, 0), host);
                }

                return(new Point(-draggedControl.WidthMultiplier, 0), draggedControl);
            }

            if (draggedControl.Y > host.Y)
            {
                return(new Point(0, host.HeightMultiplier), host);
            }

            return(new Point(0, -draggedControl.HeightMultiplier), draggedControl);
        }
Example #13
0
        public AnchorableGump ClosestOverlappingControl(AnchorableGump control)
        {
            AnchorableGump closestControl  = null;
            int            closestDistance = 99999;

            var hosts = UIManager.Gumps.OfType <AnchorableGump>().Where(s => s.AnchorGroupName == control.AnchorGroupName);

            foreach (AnchorableGump host in hosts)
            {
                if (IsOverlapping(control, host))
                {
                    int dirtyDistance = Math.Abs(control.X - host.X) + Math.Abs(control.Y - host.Y);
                    if (dirtyDistance < closestDistance)
                    {
                        closestDistance = dirtyDistance;
                        closestControl  = host;
                    }
                }
            }

            return(closestControl);
        }
Example #14
0
        public List <Gump> ReadGumps(string path)
        {
            List <Gump> gumps = new List <Gump>();


            // #########################################################
            // [FILE_FIX]
            // TODO: this code is a workaround to port old macros to the new xml system.
            string skillsGroupsPath = Path.Combine(path, "skillsgroups.bin");

            if (File.Exists(skillsGroupsPath))
            {
                try
                {
                    using (BinaryReader reader = new BinaryReader(File.OpenRead(skillsGroupsPath)))
                    {
                        int version = reader.ReadInt32();

                        int groupCount = reader.ReadInt32();

                        for (int i = 0; i < groupCount; i++)
                        {
                            int    entriesCount = reader.ReadInt32();
                            string groupName    = reader.ReadUTF8String(reader.ReadInt32());

                            SkillsGroup g = new SkillsGroup();
                            g.Name = groupName;

                            for (int j = 0; j < entriesCount; j++)
                            {
                                byte idx = (byte)reader.ReadInt32();
                                g.Add(idx);
                            }

                            g.Sort();

                            SkillsGroupManager.Add(g);
                        }
                    }
                }
                catch (Exception e)
                {
                    SkillsGroupManager.MakeDefault();
                    Log.Error(e.StackTrace);
                }


                SkillsGroupManager.Save();

                try
                {
                    File.Delete(skillsGroupsPath);
                }
                catch
                {
                }
            }

            string binpath = Path.Combine(path, "gumps.bin");

            if (File.Exists(binpath))
            {
                using (BinaryReader reader = new BinaryReader(File.OpenRead(binpath)))
                {
                    if (reader.BaseStream.Position + 12 < reader.BaseStream.Length)
                    {
                        GumpsVersion = reader.ReadUInt32();
                        uint empty = reader.ReadUInt32();

                        int count = reader.ReadInt32();

                        for (int i = 0; i < count; i++)
                        {
                            try
                            {
                                int    typeLen  = reader.ReadUInt16();
                                string typeName = reader.ReadUTF8String(typeLen);
                                int    x        = reader.ReadInt32();
                                int    y        = reader.ReadInt32();

                                Type type = Type.GetType(typeName, true);
                                Gump gump = (Gump)Activator.CreateInstance(type);
                                gump.Restore(reader);
                                gump.X = x;
                                gump.Y = y;

                                //gump.SetInScreen();

                                if (gump.LocalSerial != 0)
                                {
                                    UIManager.SavePosition(gump.LocalSerial, new Point(x, y));
                                }

                                if (!gump.IsDisposed)
                                {
                                    gumps.Add(gump);
                                }
                            }
                            catch (Exception e)
                            {
                                Log.Error(e.StackTrace);
                            }
                        }
                    }
                }

                SaveGumps(path);

                gumps.Clear();

                try
                {
                    File.Delete(binpath);
                }
                catch
                {
                }
            }
            // #########################################################


            // load skillsgroup
            //SkillsGroupManager.Load();
            SkillsGroupManager.Load();

            // load gumps
            string gumpsXmlPath = Path.Combine(path, "gumps.xml");

            if (File.Exists(gumpsXmlPath))
            {
                XmlDocument doc = new XmlDocument();

                try
                {
                    doc.Load(gumpsXmlPath);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());

                    return(gumps);
                }

                XmlElement root = doc["gumps"];

                if (root != null)
                {
                    foreach (XmlElement xml in root.ChildNodes /*.GetElementsByTagName("gump")*/)
                    {
                        if (xml.Name != "gump")
                        {
                            continue;
                        }

                        try
                        {
                            GumpType type   = (GumpType)int.Parse(xml.GetAttribute(nameof(type)));
                            int      x      = int.Parse(xml.GetAttribute(nameof(x)));
                            int      y      = int.Parse(xml.GetAttribute(nameof(y)));
                            uint     serial = uint.Parse(xml.GetAttribute(nameof(serial)));

                            Gump gump = null;

                            switch (type)
                            {
                            case GumpType.Buff:
                                gump = new BuffGump();

                                break;

                            case GumpType.Container:
                                gump = new ContainerGump();

                                break;

                            case GumpType.CounterBar:
                                gump = new CounterBarGump();

                                break;

                            case GumpType.HealthBar:
                                if (CustomBarsToggled)
                                {
                                    gump = new HealthBarGumpCustom();
                                }
                                else
                                {
                                    gump = new HealthBarGump();
                                }

                                break;

                            case GumpType.InfoBar:
                                gump = new InfoBarGump();

                                break;

                            case GumpType.Journal:
                                gump = new JournalGump();

                                break;

                            case GumpType.MacroButton:
                                gump = new MacroButtonGump();

                                break;

                            case GumpType.MiniMap:
                                gump = new MiniMapGump();

                                break;

                            case GumpType.PaperDoll:
                                gump = new PaperDollGump();

                                break;

                            case GumpType.SkillMenu:
                                if (StandardSkillsGump)
                                {
                                    gump = new StandardSkillsGump();
                                }
                                else
                                {
                                    gump = new SkillGumpAdvanced();
                                }

                                break;

                            case GumpType.SpellBook:
                                gump = new SpellbookGump();

                                break;

                            case GumpType.StatusGump:
                                gump = StatusGumpBase.AddStatusGump(0, 0);

                                break;

                            //case GumpType.TipNotice:
                            //    gump = new TipNoticeGump();
                            //    break;
                            case GumpType.AbilityButton:
                                gump = new UseAbilityButtonGump();

                                break;

                            case GumpType.SpellButton:
                                gump = new UseSpellButtonGump();

                                break;

                            case GumpType.SkillButton:
                                gump = new SkillButtonGump();

                                break;

                            case GumpType.RacialButton:
                                gump = new RacialAbilityButton();

                                break;

                            case GumpType.WorldMap:
                                gump = new WorldMapGump();

                                break;

                            case GumpType.Debug:
                                gump = new DebugGump(100, 100);

                                break;

                            case GumpType.NetStats:
                                gump = new NetworkStatsGump(100, 100);

                                break;
                            }

                            if (gump == null)
                            {
                                continue;
                            }

                            gump.LocalSerial = serial;
                            gump.Restore(xml);
                            gump.X = x;
                            gump.Y = y;

                            if (gump.LocalSerial != 0)
                            {
                                UIManager.SavePosition(gump.LocalSerial, new Point(x, y));
                            }

                            if (!gump.IsDisposed)
                            {
                                gumps.Add(gump);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex.ToString());
                        }
                    }

                    foreach (XmlElement group in root.GetElementsByTagName("anchored_group_gump"))
                    {
                        int matrix_width  = int.Parse(group.GetAttribute("matrix_w"));
                        int matrix_height = int.Parse(group.GetAttribute("matrix_h"));

                        AnchorManager.AnchorGroup ancoGroup = new AnchorManager.AnchorGroup();
                        ancoGroup.ResizeMatrix(matrix_width, matrix_height, 0, 0);

                        foreach (XmlElement xml in group.GetElementsByTagName("gump"))
                        {
                            try
                            {
                                GumpType type   = (GumpType)int.Parse(xml.GetAttribute("type"));
                                int      x      = int.Parse(xml.GetAttribute("x"));
                                int      y      = int.Parse(xml.GetAttribute("y"));
                                uint     serial = uint.Parse(xml.GetAttribute("serial"));

                                int matrix_x = int.Parse(xml.GetAttribute("matrix_x"));
                                int matrix_y = int.Parse(xml.GetAttribute("matrix_y"));

                                AnchorableGump gump = null;

                                switch (type)
                                {
                                case GumpType.SpellButton:
                                    gump = new UseSpellButtonGump();

                                    break;

                                case GumpType.SkillButton:
                                    gump = new SkillButtonGump();

                                    break;

                                case GumpType.HealthBar:
                                    if (CustomBarsToggled)
                                    {
                                        gump = new HealthBarGumpCustom();
                                    }
                                    else
                                    {
                                        gump = new HealthBarGump();
                                    }

                                    break;

                                case GumpType.AbilityButton:
                                    gump = new UseAbilityButtonGump();

                                    break;

                                case GumpType.MacroButton:
                                    gump = new MacroButtonGump();

                                    break;
                                }

                                if (gump != null)
                                {
                                    gump.LocalSerial = serial;
                                    gump.Restore(xml);
                                    gump.X = x;
                                    gump.Y = y;

                                    if (!gump.IsDisposed)
                                    {
                                        if (UIManager.AnchorManager[gump] == null && ancoGroup.IsEmptyDirection(matrix_x, matrix_y))
                                        {
                                            gumps.Add(gump);
                                            UIManager.AnchorManager[gump] = ancoGroup;
                                            ancoGroup.AddControlToMatrix(matrix_x, matrix_y, gump);
                                        }
                                        else
                                        {
                                            gump.Dispose();
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error(ex.ToString());
                            }
                        }
                    }
                }
            }

            return(gumps);
        }
Example #15
0
            public void DetachControl(AnchorableGump control)
            {
                var coords = GetControlCoordinates(control);

                controlMatrix[coords.Value.X, coords.Value.Y] = null;
            }
Example #16
0
 public AnchorGroup(AnchorableGump initial)
 {
     controlMatrix       = new AnchorableGump[1, 1];
     controlMatrix[0, 0] = initial;
 }
Example #17
0
 public void Load(AnchorableGump control)
 {
 }
Example #18
0
 public AnchorGroup(AnchorableGump initial)
 {
     controlMatrix = new AnchorableGump[initial.WidthMultiplier, initial.HeightMultiplier];
     AddControlToMatrix(0, 0, initial);
 }
Example #19
0
 public AnchorableGump GetAnchorableControlUnder(AnchorableGump draggedControl)
 {
     return(ClosestOverlappingControl(draggedControl));
 }
Example #20
0
        public List <Gump> ReadGumps(string path)
        {
            List <Gump> gumps = new List <Gump>();

            // load skillsgroup
            SkillsGroupManager.Load();

            // load gumps
            string gumpsXmlPath = Path.Combine(path, "gumps.xml");

            if (File.Exists(gumpsXmlPath))
            {
                XmlDocument doc = new XmlDocument();

                try
                {
                    doc.Load(gumpsXmlPath);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());

                    return(gumps);
                }

                XmlElement root = doc["gumps"];

                if (root != null)
                {
                    foreach (XmlElement xml in root.ChildNodes /*.GetElementsByTagName("gump")*/)
                    {
                        if (xml.Name != "gump")
                        {
                            continue;
                        }

                        try
                        {
                            GumpType type   = (GumpType)int.Parse(xml.GetAttribute(nameof(type)));
                            int      x      = int.Parse(xml.GetAttribute(nameof(x)));
                            int      y      = int.Parse(xml.GetAttribute(nameof(y)));
                            uint     serial = uint.Parse(xml.GetAttribute(nameof(serial)));

                            Gump gump = null;

                            switch (type)
                            {
                            case GumpType.Buff:
                                gump = new BuffGump();

                                break;

                            case GumpType.Container:
                                gump = new ContainerGump();

                                break;

                            case GumpType.CounterBar:
                                gump = new CounterBarGump();

                                break;

                            case GumpType.HealthBar:
                                if (CustomBarsToggled)
                                {
                                    gump = new HealthBarGumpCustom();
                                }
                                else
                                {
                                    gump = new HealthBarGump();
                                }

                                break;

                            case GumpType.InfoBar:
                                gump = new InfoBarGump();

                                break;

                            case GumpType.Journal:
                                gump = new JournalGump();

                                break;

                            case GumpType.MacroButton:
                                gump = new MacroButtonGump();

                                break;

                            case GumpType.MiniMap:
                                gump = new MiniMapGump();

                                break;

                            case GumpType.PaperDoll:
                                gump = new PaperDollGump();

                                break;

                            case GumpType.SkillMenu:
                                if (StandardSkillsGump)
                                {
                                    gump = new StandardSkillsGump();
                                }
                                else
                                {
                                    gump = new SkillGumpAdvanced();
                                }

                                break;

                            case GumpType.SpellBook:
                                gump = new SpellbookGump();

                                break;

                            case GumpType.StatusGump:
                                gump = StatusGumpBase.AddStatusGump(0, 0);

                                break;

                            //case GumpType.TipNotice:
                            //    gump = new TipNoticeGump();
                            //    break;
                            case GumpType.AbilityButton:
                                gump = new UseAbilityButtonGump();

                                break;

                            case GumpType.SpellButton:
                                gump = new UseSpellButtonGump();

                                break;

                            case GumpType.SkillButton:
                                gump = new SkillButtonGump();

                                break;

                            case GumpType.RacialButton:
                                gump = new RacialAbilityButton();

                                break;

                            case GumpType.WorldMap:
                                gump = new WorldMapGump();

                                break;

                            case GumpType.Debug:
                                gump = new DebugGump(100, 100);

                                break;

                            case GumpType.NetStats:
                                gump = new NetworkStatsGump(100, 100);

                                break;
                            }

                            if (gump == null)
                            {
                                continue;
                            }

                            gump.LocalSerial = serial;
                            gump.Restore(xml);
                            gump.X = x;
                            gump.Y = y;

                            if (gump.LocalSerial != 0)
                            {
                                UIManager.SavePosition(gump.LocalSerial, new Point(x, y));
                            }

                            if (!gump.IsDisposed)
                            {
                                gumps.Add(gump);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex.ToString());
                        }
                    }

                    foreach (XmlElement group in root.GetElementsByTagName("anchored_group_gump"))
                    {
                        int matrix_width  = int.Parse(group.GetAttribute("matrix_w"));
                        int matrix_height = int.Parse(group.GetAttribute("matrix_h"));

                        AnchorManager.AnchorGroup ancoGroup = new AnchorManager.AnchorGroup();
                        ancoGroup.ResizeMatrix(matrix_width, matrix_height, 0, 0);

                        foreach (XmlElement xml in group.GetElementsByTagName("gump"))
                        {
                            try
                            {
                                GumpType type   = (GumpType)int.Parse(xml.GetAttribute("type"));
                                int      x      = int.Parse(xml.GetAttribute("x"));
                                int      y      = int.Parse(xml.GetAttribute("y"));
                                uint     serial = uint.Parse(xml.GetAttribute("serial"));

                                int matrix_x = int.Parse(xml.GetAttribute("matrix_x"));
                                int matrix_y = int.Parse(xml.GetAttribute("matrix_y"));

                                AnchorableGump gump = null;

                                switch (type)
                                {
                                case GumpType.SpellButton:
                                    gump = new UseSpellButtonGump();

                                    break;

                                case GumpType.SkillButton:
                                    gump = new SkillButtonGump();

                                    break;

                                case GumpType.HealthBar:
                                    if (CustomBarsToggled)
                                    {
                                        gump = new HealthBarGumpCustom();
                                    }
                                    else
                                    {
                                        gump = new HealthBarGump();
                                    }

                                    break;

                                case GumpType.AbilityButton:
                                    gump = new UseAbilityButtonGump();

                                    break;

                                case GumpType.MacroButton:
                                    gump = new MacroButtonGump();

                                    break;
                                }

                                if (gump != null)
                                {
                                    gump.LocalSerial = serial;
                                    gump.Restore(xml);
                                    gump.X = x;
                                    gump.Y = y;

                                    if (!gump.IsDisposed)
                                    {
                                        if (UIManager.AnchorManager[gump] == null && ancoGroup.IsEmptyDirection(matrix_x, matrix_y))
                                        {
                                            gumps.Add(gump);
                                            UIManager.AnchorManager[gump] = ancoGroup;
                                            ancoGroup.AddControlToMatrix(matrix_x, matrix_y, gump);
                                        }
                                        else
                                        {
                                            gump.Dispose();
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error(ex.ToString());
                            }
                        }
                    }
                }
            }

            return(gumps);
        }