public static bool OpenBackpack() { Item backpack = World.Player.FindItemByLayer(Layer.Backpack); if (backpack == null) { return(false); } ContainerGump backpackGump = UIManager.GetGump <ContainerGump>(backpack); if (backpackGump == null) { GameActions.DoubleClick(backpack); } else { if (backpackGump.IsMinimized) { backpackGump.IsMinimized = false; } backpackGump.SetInScreen(); backpackGump.BringOnTop(); } return(true); }
public Gump OpenContainerGump(AEntity entity) // used by ultimaclient. { Gump gump; if ((gump = (Gump)m_UserInterface.GetControl(entity.Serial)) != null) { gump.Dispose(); } else { if (entity is Corpse) { gump = new ContainerGump(entity, 0x2006); m_UserInterface.AddControl(gump, 96, 96); } else if (entity is SpellBook) { gump = new SpellbookGump((SpellBook)entity, ((Container)entity).ItemID); m_UserInterface.AddControl(gump, 96, 96); } else { gump = new ContainerGump(entity, ((Container)entity).ItemID); m_UserInterface.AddControl(gump, 64, 64); } } return(gump); }
public Gump OpenCorpseGump(AEntity entity) // used by UltimaClient { Gump gump; if ((gump = (Gump)World.Engine.UserInterface.GetControl(entity.Serial)) != null) { gump.Dispose(); } gump = new ContainerGump(entity, 0x2006); World.Engine.UserInterface.AddControl(gump, 96, 96); return(gump); }
public Gump OpenContainerGump(AEntity entity) // used by ultimaclient. { Gump gump; if ((gump = (Gump)World.Engine.UserInterface.GetControl(entity.Serial)) != null) { gump.Dispose(); } gump = new ContainerGump(entity, ((Container)entity).ItemID); World.Engine.UserInterface.AddControl(gump, 64, 64); return(gump); }
private static void SetPositionNearGameObject(ushort g, uint serial, int width, int height) { Item item = World.Items.Get(serial); if (item == null) { return; } Item bank = World.Player.FindItemByLayer(Layer.Bank); if (bank != null && serial == bank) { // open bank near player X = World.Player.RealScreenPosition.X + ProfileManager.CurrentProfile.GameWindowPosition.X + 40; Y = World.Player.RealScreenPosition.Y + ProfileManager.CurrentProfile.GameWindowPosition.Y - (height >> 1); } else if (item.OnGround) { // item is in world X = item.RealScreenPosition.X + ProfileManager.CurrentProfile.GameWindowPosition.X + 40; Y = item.RealScreenPosition.Y + ProfileManager.CurrentProfile.GameWindowPosition.Y - (height >> 1); } else if (SerialHelper.IsMobile(item.Container)) { // pack animal, snooped player, npc vendor Mobile mobile = World.Mobiles.Get(item.Container); if (mobile != null) { X = mobile.RealScreenPosition.X + ProfileManager.CurrentProfile.GameWindowPosition.X + 40; Y = mobile.RealScreenPosition.Y + ProfileManager.CurrentProfile.GameWindowPosition.Y - (height >> 1); } } else { // in a container, open near the container ContainerGump parentContainer = UIManager.GetGump <ContainerGump>(item.Container); if (parentContainer != null) { X = parentContainer.X + (width >> 1); Y = parentContainer.Y; } } }
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); }
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); }
public void DropHeldItemToContainer(Item container, int x = 0xFFFF, int y = 0xFFFF) { if (ItemHold.Enabled && container != null && ItemHold.Serial != container.Serial) { ContainerGump gump = UIManager.GetGump<ContainerGump>(container); if (gump != null && (x != 0xFFFF || y != 0xFFFF)) { Rectangle bounds = ContainerManager.Get(gump.Graphic).Bounds; ArtTexture texture = ArtLoader.Instance.GetTexture(ItemHold.DisplayedGraphic); float scale = UIManager.ContainerScale; bounds.X = (int) (bounds.X * scale); bounds.Y = (int) (bounds.Y * scale); bounds.Width = (int) (bounds.Width * scale); bounds.Height = (int) (bounds.Height * scale); if (texture != null && !texture.IsDisposed) { int textureW, textureH; if (ProfileManager.Current != null && ProfileManager.Current.ScaleItemsInsideContainers) { textureW = (int) (texture.Width * scale); textureH = (int) (texture.Height * scale); } else { textureW = texture.Width; textureH = texture.Height; } x -= textureW >> 1; y -= textureH >> 1; if (x + textureW > bounds.Width) x = bounds.Width - textureW; if (y + textureH > bounds.Height) y = bounds.Height - textureH; } if (x < bounds.X) x = bounds.X; if (y < bounds.Y) y = bounds.Y; x = (int) (x / scale); y = (int) (y / scale); } else { x = 0xFFFF; y = 0xFFFF; } GameActions.DropItem(ItemHold.Serial, x, y, 0, container); ItemHold.Enabled = false; ItemHold.Dropped = true; } }
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); }