private void BuildGump() { CanMove = true; CanBeSaved = true; LocalSerial = _item.Serial; _isCorspeContainer = _gumpID == 0x0009; _item.Items.Added += ItemsOnAdded; _item.Items.Removed += ItemsOnRemoved; _data = ContainerManager.Get(_gumpID); Graphic g = _data.Graphic; Add(new GumpPicContainer(0, 0, g, 0, _item)); if (_isCorspeContainer) { Add(_eyeGumpPic = new GumpPic(45, 30, 0x0045, 0)); } ContainerManager.CalculateContainerPosition(g); X = ContainerManager.X; Y = ContainerManager.Y; if (_data.OpenSound != 0) { Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound); } }
public ContainerGump(Item item, Graphic gumpid) : base(item.Serial, 0) { _item = item; _data = ContainerManager.Get(gumpid); CanMove = true; AddChildren(new GumpPicContainer(0, 0, _data.Graphic, 0, item)); }
private void BuildGump() { LocalSerial = _item.Serial; _isCorspeContainer = _gumpID == 0x0009; _item.Items.Added += ItemsOnAdded; _item.Items.Removed += ItemsOnRemoved; AddChildren(new GumpPicContainer(0, 0, ContainerManager.Get(_gumpID).Graphic, 0, _item)); if (_isCorspeContainer) { AddChildren(_eyeGumpPic = new GumpPic(45, 30, 0x0045, 0)); } }
private void BuildGump() { CanMove = true; CanBeSaved = true; LocalSerial = _item.Serial; _isCorspeContainer = _gumpID == 0x0009; _item.Items.Added += ItemsOnAdded; _item.Items.Removed += ItemsOnRemoved; _data = ContainerManager.Get(_gumpID); Graphic g = _data.Graphic; Add(new GumpPicContainer(0, 0, g, 0, _item)); if (_isCorspeContainer) { Add(_eyeGumpPic = new GumpPic(45, 30, 0x0045, 0)); } ContainerGump gg = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == LocalSerial); if (gg == null) { if (Engine.UI.GetGumpCachePosition(LocalSerial, out Point location) && _item.Serial == World.Player.Equipment[(int)Layer.Backpack]) { Location = location; } else { ContainerManager.CalculateContainerPosition(g); X = ContainerManager.X; Y = ContainerManager.Y; } } else { X = gg.X; Y = gg.Y; } if (_data.OpenSound != 0) { Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound); } }
private void BuildGump() { CanMove = true; CanBeSaved = true; WantUpdateSize = false; _isCorspeContainer = Graphic == 0x0009; Item item = World.Items.Get(LocalSerial); if (item == null) { Dispose(); return; } item.Items.Added -= ItemsOnAdded; item.Items.Removed -= ItemsOnRemoved; item.Items.Added += ItemsOnAdded; item.Items.Removed += ItemsOnRemoved; float scale = Engine.UI.ContainerScale; _data = ContainerManager.Get(Graphic); if (_data.MinimizerArea != Rectangle.Empty && _data.IconizedGraphic != 0) { _iconizerArea = new HitBox((int)(_data.MinimizerArea.X * scale), (int)(_data.MinimizerArea.Y * scale), (int)(_data.MinimizerArea.Width * scale), (int)(_data.MinimizerArea.Height * scale)); _iconized = new GumpPic(0, 0, _data.IconizedGraphic, 0); } Graphic g = _data.Graphic; GumpPicContainer container; Add(container = new GumpPicContainer(0, 0, g, 0, item)); if (_isCorspeContainer) { _eyeGumpPic?.Dispose(); Add(_eyeGumpPic = new GumpPic((int)(45 * scale), (int)(30 * scale), 0x0045, 0)); _eyeGumpPic.Width = (int)(_eyeGumpPic.Width * scale); _eyeGumpPic.Height = (int)(_eyeGumpPic.Height * scale); } Width = container.Width = (int)(container.Width * scale); Height = container.Height = (int)(container.Height * scale); ContainerGump gg = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == LocalSerial); if (gg == null) { if (Engine.UI.GetGumpCachePosition(LocalSerial, out Point location) && item.Serial == World.Player.Equipment[(int)Layer.Backpack]) { Location = location; } else { if (Engine.Profile.Current.OverrideContainerLocation) { switch (Engine.Profile.Current.OverrideContainerLocationSetting) { case 0: SetPositionNearGameObject(g, item); break; case 1: SetPositionTopRight(); break; case 2: SetPositionByLastDragged(); break; } if ((X + Width) > Engine.WindowWidth) { X -= Width; } if ((Y + Height) > Engine.WindowHeight) { Y -= Height; } } else { ContainerManager.CalculateContainerPosition(g); X = ContainerManager.X; Y = ContainerManager.Y; } } } else { X = gg.X; Y = gg.Y; } if (_data.OpenSound != 0) { Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound); } }
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; } }
private void BuildGump() { CanMove = true; CanBeSaved = true; LocalSerial = _item.Serial; WantUpdateSize = false; _isCorspeContainer = Graphic == 0x0009; _item.Items.Added += ItemsOnAdded; _item.Items.Removed += ItemsOnRemoved; _data = ContainerManager.Get(Graphic); Graphic g = _data.Graphic; GumpPicContainer container; Add(container = new GumpPicContainer(0, 0, g, 0, _item)); if (_isCorspeContainer) { Add(_eyeGumpPic = new GumpPic(45, 30, 0x0045, 0)); } Width = container.Width; Height = container.Height; ContainerGump gg = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == LocalSerial); if (gg == null) { if (Engine.UI.GetGumpCachePosition(LocalSerial, out Point location) && _item.Serial == World.Player.Equipment[(int)Layer.Backpack]) { Location = location; } else { if (Engine.Profile.Current.OverrideContainerLocation) { switch (Engine.Profile.Current.OverrideContainerLocationSetting) { case 0: SetPositionNearGameObject(g); break; case 1: SetPositionTopRight(); break; case 2: SetPositionByLastDragged(); break; } if ((X + Width) > Engine.WindowWidth) { X -= Width; } if ((Y + Height) > Engine.WindowHeight) { Y -= Height; } } else { ContainerManager.CalculateContainerPosition(g); X = ContainerManager.X; Y = ContainerManager.Y; } } } else { X = gg.X; Y = gg.Y; } if (_data.OpenSound != 0) { Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound); } }
public void Get_WithValidName_ReturnsWrappedProviderContainer() { // Arrange var providerContainer = MockRepository.GenerateStub<IBlobContainer>(); var provider = MockRepository.GenerateStub<IBlobContainerManager>(); provider.Stub(x => x.Get(null)).IgnoreArguments().Return(providerContainer); var testManager = new ContainerManager(provider); // Act var result = testManager.Get("foo"); // Assert Assert.That(result.Provider, Is.EqualTo(providerContainer)); }
public void Get_WithValidName_CallsGetOnProvider(string name) { // Arrange var provider = MockRepository.GenerateMock<IBlobContainerManager>(); provider.Expect(x => x.Get(name)).Return(MockRepository.GenerateStub<IBlobContainer>()); var testManager = new ContainerManager(provider); // Act testManager.Get(name); // Assert provider.AssertWasCalled(x => x.Get(name)); }
public void Get_WithInvalidName_ThrowsInvalidNameException(string name) { // Arrange var testManager = new ContainerManager(null); // Act Assert.Throws<InvalidNameException>(() => testManager.Get(name)); }
private void BuildGump() { CanMove = true; CanBeSaved = true; LocalSerial = _item.Serial; WantUpdateSize = false; _isCorspeContainer = Graphic == 0x0009; _item.Items.Added += ItemsOnAdded; _item.Items.Removed += ItemsOnRemoved; _data = ContainerManager.Get(Graphic); Graphic g = _data.Graphic; GumpPicContainer container; Add(container = new GumpPicContainer(0, 0, g, 0, _item)); if (_isCorspeContainer) { Add(_eyeGumpPic = new GumpPic(45, 30, 0x0045, 0)); } Width = container.Width; Height = container.Height; ContainerGump gg = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == LocalSerial); if (gg == null) { if (Engine.UI.GetGumpCachePosition(LocalSerial, out Point location) && _item.Serial == World.Player.Equipment[(int)Layer.Backpack]) { Location = location; } else { if (Engine.Profile.Current.OpenContainersNearRealPosition) { if (World.Player.Equipment[(int)Layer.Bank] != null && _item.Serial == World.Player.Equipment[(int)Layer.Bank]) { // open bank near player X = World.Player.RealScreenPosition.X + Engine.Profile.Current.GameWindowPosition.X + 40; Y = World.Player.RealScreenPosition.Y + Engine.Profile.Current.GameWindowPosition.Y - (Height >> 1); } else if (_item.OnGround) { // item is in world X = _item.RealScreenPosition.X + Engine.Profile.Current.GameWindowPosition.X + 40; Y = _item.RealScreenPosition.Y + Engine.Profile.Current.GameWindowPosition.Y - (Height >> 1); } else { // in a container, open near the container ContainerGump parentContainer = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == _item.Container); if (parentContainer != null) { X = parentContainer.X + (Width >> 1); Y = parentContainer.Y; } else { // I don't think we ever get here? ContainerManager.CalculateContainerPosition(g); X = ContainerManager.X; Y = ContainerManager.Y; } } if ((X + Width) > Engine.WindowWidth) { X -= Width; } if ((Y + Height) > Engine.WindowHeight) { Y -= Height; } } else { ContainerManager.CalculateContainerPosition(g); X = ContainerManager.X; Y = ContainerManager.Y; } } } else { X = gg.X; Y = gg.Y; } if (_data.OpenSound != 0) { Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound); } }