Esempio n. 1
0
        private void SaveGumps(string path, List <Gump> gumps)
        {
            string gumpsXmlPath = Path.Combine(path, "gumps.xml");

            using (XmlTextWriter xml = new XmlTextWriter(gumpsXmlPath, Encoding.UTF8)
            {
                Formatting = System.Xml.Formatting.Indented,
                IndentChar = '\t',
                Indentation = 1
            })
            {
                xml.WriteStartDocument(true);
                xml.WriteStartElement("gumps");

                foreach (Gump gump in gumps)
                {
                    xml.WriteStartElement("gump");
                    gump.Save(xml);
                    xml.WriteEndElement();
                }

                xml.WriteEndElement();
                xml.WriteEndDocument();
            }

            using (BinaryWriter writer = new BinaryWriter(File.Create(Path.Combine(path, "anchors.bin"))))
                UIManager.AnchorManager.Save(writer);

            SkillsGroupManager.Save();
        }
        public override void OnButtonClick(int buttonID)
        {
            if (buttonID == 0)
            {
                string group = "New Group";

                if (SkillsGroupManager.AddNewGroup(group))
                {
                    AddSkillsToGroup(group, SkillsGroupManager.GetSkillsInGroup(group));
                }
            }
        }
Esempio n. 3
0
        private void AddSkillsToGroup(string group, List <int> skills)
        {
            MultiSelectionShrinkbox box = new MultiSelectionShrinkbox(0, 0, _container.Width - 30, group, 0, 6, false, true)
            {
                CanMove    = true,
                IsEditable = true
            };

            box.EditStateStart += (ss, e) =>
            {
                Control p     = _container;
                var     items = p.FindControls <ScrollAreaItem>().SelectMany(s => s.Children.OfType <MultiSelectionShrinkbox>());

                foreach (var item in items)
                {
                    foreach (EditableLabel c in item.FindControls <EditableLabel>())
                    {
                        c.SetEditable(false);
                    }
                }
            };

            box.EditStateEnd += (ss, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.BackupText) && !string.IsNullOrWhiteSpace(e.Text))
                {
                    SkillsGroupManager.ReplaceGroup(e.BackupText, e.Text);
                }
            };

            _container.Add(box);

            SkillControl[] controls = new SkillControl[skills.Count];
            int            idx      = 0;

            foreach (var skill in skills)
            {
                var c = new SkillControl(skill, box.Width - 15, group, box)
                {
                    Width = box.Width - 15
                };
                controls[idx++]          = c;
                _allSkillControls[skill] = c;
            }

            box.SetItemsValue(controls);

            _boxes.Add(box);
        }
        protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod)
        {
            if (key == SDL.SDL_Keycode.SDLK_DELETE)
            {
                for (int i = 0; i < _boxes.Count; i++)
                {
                    var box = _boxes[i];

                    if (box.IsEditing)
                    {
                        if (i == 0)
                        {
                            Engine.UI.Add(new MessageBoxGump(200, 150, "Cannot delete this group.", null));
                            break;
                        }

                        if (SkillsGroupManager.RemoveGroup(box.LabelText))
                        {
                            foreach (var child in box.FindControls <SkillControl>())
                            {
                                _boxes[0].AddItem(child);
                            }

                            _boxes[0].Items.Sort((a, b) =>
                            {
                                var s0 = (SkillControl)a;
                                var s1 = (SkillControl)b;

                                var skill0 = World.Player.Skills[s0.SkillIndex];
                                var skill1 = World.Player.Skills[s1.SkillIndex];

                                return(skill0.Name.CompareTo(skill1.Name));
                            });

                            _boxes[0].GenerateButtons();

                            box.Children.Clear();
                            _container.Remove(box);
                            _boxes.RemoveAt(i);
                        }

                        break;
                    }
                }
            }
        }
Esempio n. 5
0
        private void SaveGumps(string path, List <Gump> gumps)
        {
            using (BinaryWriter writer = new BinaryWriter(File.Create(Path.Combine(path, "gumps.bin"))))
            {
                const uint VERSION = 1;

                writer.Write(VERSION);
                writer.Write(0);

                /*
                 * int gumpsCount
                 * loop:
                 *      ushort typeLen
                 *      string type
                 *      int x
                 *      int y
                 *      undefinited data
                 * endloop.
                 */


                if (gumps != null)
                {
                    writer.Write(gumps.Count);

                    foreach (Gump gump in gumps)
                    {
                        gump.Save(writer);
                    }
                }
                else
                {
                    writer.Write(0);
                }
            }

            using (BinaryWriter writer = new BinaryWriter(File.Create(Path.Combine(path, "anchors.bin"))))
                Engine.UI.AnchorManager.Save(writer);

            using (BinaryWriter writer = new BinaryWriter(File.Create(Path.Combine(path, "skillsgroups.bin"))))
                SkillsGroupManager.Save(writer);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        private void SaveGumps(string path)
        {
            string gumpsXmlPath = Path.Combine(path, "gumps.xml");

            using (XmlTextWriter xml = new XmlTextWriter(gumpsXmlPath, Encoding.UTF8)
            {
                Formatting = Formatting.Indented,
                IndentChar = '\t',
                Indentation = 1
            })
            {
                xml.WriteStartDocument(true);
                xml.WriteStartElement("gumps");

                UIManager.AnchorManager.Save(xml);

                LinkedList <Gump> gumps = new LinkedList <Gump>();

                foreach (Gump gump in UIManager.Gumps)
                {
                    if (!gump.IsDisposed && gump.CanBeSaved && !(gump is AnchorableGump anchored && UIManager.AnchorManager[anchored] != null))
                    {
                        gumps.AddLast(gump);
                    }
                }


                LinkedListNode <Gump> first = gumps.First;

                while (first != null)
                {
                    Gump gump = first.Value;

                    if (gump.LocalSerial != 0)
                    {
                        Item item = World.Items.Get(gump.LocalSerial);

                        if (item != null && !item.IsDestroyed && item.Opened)
                        {
                            while (SerialHelper.IsItem(item.Container))
                            {
                                item = World.Items.Get(item.Container);
                            }

                            SaveItemsGumpRecursive(item, xml, gumps);

                            if (first.List != null)
                            {
                                gumps.Remove(first);
                            }

                            first = gumps.First;

                            continue;
                        }
                    }

                    xml.WriteStartElement("gump");
                    gump.Save(xml);
                    xml.WriteEndElement();

                    if (first.List != null)
                    {
                        gumps.Remove(first);
                    }

                    first = gumps.First;
                }

                xml.WriteEndElement();
                xml.WriteEndDocument();
            }


            SkillsGroupManager.Save();
        }
Esempio n. 8
0
        public List <Gump> ReadGumps()
        {
            string path = FileSystemHelper.CreateFolderIfNotExists(ProfilePath, Username, ServerName, CharacterName);

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

            if (!File.Exists(binpath))
            {
                return(null);
            }


            string skillsGroupsPath = Path.Combine(path, "skillsgroups.bin");

            if (File.Exists(skillsGroupsPath))
            {
                try
                {
                    using (BinaryReader reader = new BinaryReader(File.OpenRead(skillsGroupsPath)))
                        SkillsGroupManager.Load(reader);
                }
                catch (Exception e)
                {
                    SkillsGroupManager.LoadDefault();
                    Log.Message(LogTypes.Error, e.StackTrace);
                }
            }

            List <Gump> gumps = new List <Gump>();

            using (BinaryReader reader = new BinaryReader(File.OpenRead(binpath)))
            {
                if (reader.BaseStream.Position + 12 < reader.BaseStream.Length)
                {
                    uint version = 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.Initialize();
                            gump.Restore(reader);
                            gump.X = x;
                            gump.Y = y;

                            //gump.SetInScreen();

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

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


            string anchorsPath = Path.Combine(path, "anchors.bin");

            if (File.Exists(anchorsPath))
            {
                try
                {
                    using (BinaryReader reader = new BinaryReader(File.OpenRead(anchorsPath)))
                        Engine.UI.AnchorManager.Restore(reader, gumps);
                }
                catch (Exception e)
                {
                    Log.Message(LogTypes.Error, e.StackTrace);
                }
            }


            return(gumps);
        }
Esempio n. 9
0
        public List <Gump> ReadGumps()
        {
            string      path  = FileSystemHelper.CreateFolderIfNotExists(ProfilePath, Username.Trim(), ServerName.Trim(), CharacterName.Trim());
            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);

                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.GetElementsByTagName("gump"))
                    {
                        try
                        {
                            GUMP_TYPE type   = (GUMP_TYPE)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"));

                            Gump gump = null;
                            switch (type)
                            {
                            case GUMP_TYPE.GT_BUFF:
                                gump = new BuffGump();
                                break;

                            case GUMP_TYPE.GT_CONTAINER:
                                gump = new ContainerGump();
                                break;

                            case GUMP_TYPE.GT_COUNTERBAR:
                                gump = new CounterBarGump();
                                break;

                            case GUMP_TYPE.GT_HEALTHBAR:
                                if (CustomBarsToggled)
                                {
                                    gump = new HealthBarGumpCustom();
                                }
                                else
                                {
                                    gump = new HealthBarGump();
                                }
                                break;

                            case GUMP_TYPE.GT_INFOBAR:
                                gump = new InfoBarGump();
                                break;

                            case GUMP_TYPE.GT_JOURNAL:
                                gump = new JournalGump();
                                break;

                            case GUMP_TYPE.GT_MACROBUTTON:
                                gump = new MacroButtonGump();
                                break;

                            case GUMP_TYPE.GT_MINIMAP:
                                gump = new MiniMapGump();
                                break;

                            case GUMP_TYPE.GT_PAPERDOLL:
                                gump = new PaperDollGump();
                                break;

                            case GUMP_TYPE.GT_SKILLMENU:
                                if (StandardSkillsGump)
                                {
                                    gump = new StandardSkillsGump();
                                }
                                else
                                {
                                    gump = new SkillGumpAdvanced();
                                }
                                break;

                            case GUMP_TYPE.GT_SPELLBOOK:
                                gump = new SpellbookGump();
                                break;

                            case GUMP_TYPE.GT_STATUSGUMP:
                                switch (Settings.GlobalSettings.ShardType)
                                {
                                default:
                                case 0:         // modern

                                    gump = new StatusGumpModern();

                                    break;

                                case 1:         // old

                                    gump = new StatusGumpOld();

                                    break;

                                case 2:         // outlands

                                    gump = new StatusGumpOutlands();

                                    break;
                                }
                                break;

                            //case GUMP_TYPE.GT_TIPNOTICE:
                            //    gump = new TipNoticeGump();
                            //    break;
                            case GUMP_TYPE.GT_ABILITYBUTTON:
                                gump = new UseAbilityButtonGump();
                                break;

                            case GUMP_TYPE.GT_SPELLBUTTON:
                                gump = new UseSpellButtonGump();
                                break;

                            case GUMP_TYPE.GT_SKILLBUTTON:
                                gump = new SkillButtonGump();
                                break;

                            case GUMP_TYPE.GT_RACIALBUTTON:
                                gump = new RacialAbilityButton();
                                break;

                            case GUMP_TYPE.GT_WORLDMAP:
                                gump = new WorldMapGump();
                                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());
                        }
                    }
                }
            }


            // load anchors
            string anchorsPath = Path.Combine(path, "anchors.bin");

            if (File.Exists(anchorsPath))
            {
                try
                {
                    using (BinaryReader reader = new BinaryReader(File.OpenRead(anchorsPath)))
                        UIManager.AnchorManager.Restore(reader, gumps);
                }
                catch (Exception e)
                {
                    Log.Error(e.StackTrace);
                }
            }


            return(gumps);
        }
Esempio n. 10
0
            protected override void OnMouseOver(int x, int y)
            {
                if (CanMove)
                {
                    return;
                }

                var c = Engine.UI.MouseOverControl;

                if (c != null && c != this)
                {
                    var p = c.Parent;

                    while (p != null)
                    {
                        if (p is MultiSelectionShrinkbox box)
                        {
                            if (box.LabelText != Group)
                            {
                                SkillsGroupManager.MoveSkillToGroup(Group, box.LabelText, _skillIndex);

                                int index = -1;

                                foreach (SkillControl skillControl in box.Items.OfType <SkillControl>())
                                {
                                    index++;

                                    if (skillControl._skillIndex > _skillIndex)
                                    {
                                        break;
                                    }
                                }

                                _parent.Remove(this);
                                box.AddItem(this, index);

                                _parent = box;
                                Group   = box.LabelText;
                            }

                            break;
                        }

                        p = p.Parent;
                    }
                }

                if (!(c?.RootParent is StandardSkillsGump))
                {
                    uint serial = (uint)(World.Player + _skillIndex + 1);

                    if (Engine.UI.GetGump <SkillButtonGump>(serial) != null)
                    {
                        Engine.UI.Remove <SkillButtonGump>(serial);
                    }

                    SkillButtonGump skillButtonGump = new SkillButtonGump(World.Player.Skills[_skillIndex], Mouse.Position.X, Mouse.Position.Y);
                    Engine.UI.Add(skillButtonGump);
                    Rectangle rect = FileManager.Gumps.GetTexture(0x24B8).Bounds;
                    Engine.UI.AttemptDragControl(skillButtonGump, new Point(Mouse.Position.X + (rect.Width >> 1), Mouse.Position.Y + (rect.Height >> 1)), true);
                }

                base.OnMouseOver(x, y);
            }
Esempio n. 11
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);
        }