public InventoryLockPane(ILockedInventoryEvent lockEvent) { On <PickLockEvent>(_ => PickLock()); _lockEvent = lockEvent; bool isChest = lockEvent is ChestEvent; var background = new UiSpriteElement(isChest ? Base.Picture.ClosedChest : Base.Picture.WoodenDoor); var backgroundStack = new FixedPositionStack(); backgroundStack.Add(background, 0, 0); AttachChild(backgroundStack); var lockButton = new Button( new Padding( new UiSpriteElement(Base.CoreSprite.Lock), 4)) .OnHover(LockHovered) .OnBlur(() => { Raise(new HoverTextEvent(null)); if (Resolve <IInventoryManager>().ItemInHand.Item == null) { Raise(new SetCursorEvent(Base.CoreSprite.Cursor)); } }) .OnClick(LockClicked) // If holding key etc .OnRightClick(LockRightClicked) ; AttachChild(new FixedPosition(new Rectangle(50, isChest ? 50 : 112, 32, 32), lockButton)); }
public ConversationParticipantLabel(ICharacterSheet sheet, bool isRight) : base(isRight ? DialogPositioning.TopRight : DialogPositioning.TopLeft) { if (sheet == null) { throw new ArgumentNullException(nameof(sheet)); } var portraitId = sheet.PortraitId ?? SmallPortraitId.GibtEsNicht; var name = GetName(sheet, false); var fixedPos = new FixedPositionStack(); fixedPos.Add( new RepeatedBackground( new ButtonFrame( new UiSpriteElement <SmallPortraitId>(portraitId))), isRight ? 315 : 9, 4); fixedPos.Add( new RepeatedBackground( new ButtonFrame( new UiText(name))), isRight ? 236 : 45, 4, 79, 12); AttachChild(fixedPos); /* * Portrait background * Portrait background drop shadow * Portrait * Text * * Frame: * (9,4) (45,4) (124,4) * /-------x---------------------\ | Name (79x12) | | /---------------------/ (124,16) | | |(36x39)| | | \-------/ (45, 43) | | (236, 4) (315, 4) | /---------------------x-------\ |Name (79x12) | \-------------------- \ | |(36x39)| | | | | \-------/ (351, 43) | */ }
public InventoryMidPane(PartyCharacterId activeCharacter, InventoryConfig.PlayerInventory config) { var background = new FixedPositionStack(); background.Add(new UiSprite <FullBodyPictureId>((FullBodyPictureId)activeCharacter), 1, -3); Children.Add(background); var bodyStack = new FixedPositionStack(); foreach (var bodyPart in config) { var itemSlotId = bodyPart.Key; var position = bodyPart.Value; bodyStack.Add(new InventoryBodyPart(activeCharacter, itemSlotId), (int)position.X, (int)position.Y); } var frame = new ButtonFrame(bodyStack) { Theme = new FrameTheme() }; var labelStack = new HorizontalStack( new InventoryOffensiveLabel(activeCharacter), new InventoryWeightLabel(activeCharacter), new InventoryDefensiveLabel(activeCharacter) ); var mainStack = new VerticalStack( new Header(new DynamicText(() => { var member = Resolve <IParty>()[activeCharacter]; var settings = Resolve <ISettings>(); if (member == null) { return(new TextBlock[0]); } var name = member.Apparent.GetName(settings.Gameplay.Language); return(new[] { new TextBlock(name) { Alignment = TextAlignment.Center } }); })), new HorizontalStack( new Padding(3, 0), frame, new Padding(3, 0)), labelStack ); Children.Add(mainStack); }
public InventoryChestPane(ChestId id) { On <InventoryChangedEvent>(e => { if (e.Id != new InventoryId(_id)) { return; } UpdateBackground(); }); _id = id; _background = new UiSpriteElement(Base.Picture.OpenChestWithGold); var backgroundStack = new FixedPositionStack(); backgroundStack.Add(_background, 0, 0); AttachChild(backgroundStack); var slotSpans = new IUiElement[InventoryHeight]; for (int j = 0; j < InventoryHeight; j++) { var slotsInRow = new IUiElement[InventoryWidth]; for (int i = 0; i < InventoryWidth; i++) { int index = j * InventoryWidth + i; slotsInRow[i] = new LogicalInventorySlot(new InventorySlotId(_id, (ItemSlotId)((int)ItemSlotId.Slot0 + index))); } slotSpans[j] = new HorizontalStack(slotsInRow); } var slotStack = new VerticalStack(slotSpans); var slotHalfFrame = new ButtonFrame(slotStack) { Theme = ButtonTheme.InventoryOuterFrame, Padding = -1 }; var goldButton = new LogicalInventorySlot(new InventorySlotId(_id, ItemSlotId.Gold)); var foodButton = new LogicalInventorySlot(new InventorySlotId(_id, ItemSlotId.Rations)); var takeAllButton = new Button( (UiElement) new UiTextBuilder(TextId.From(Base.UAlbionString.TakeAll)).Center() ).OnClick(() => Raise(new InventoryTakeAllEvent(_id))); var header = new Header(Base.SystemText.Chest_Chest); var moneyAndFoodStack = new HorizontalStack(goldButton, takeAllButton, foodButton); var stack = new VerticalStack( header, slotHalfFrame, new Spacing(0, 78), moneyAndFoodStack ) { Greedy = false }; AttachChild(stack); }