コード例 #1
0
    public InventoryMerchantPane(MerchantId id)
    {
        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 header = new Header(Base.SystemText.Shop_Merchant);
        var stack  = new VerticalStack(header, slotHalfFrame)
        {
            Greedy = false
        };

        AttachChild(stack);
    }
コード例 #2
0
    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);
    }
コード例 #3
0
    public InventoryRightPane(PartyMemberId activeCharacter, bool showTotalPartyGold)
    {
        var header = new Header(Base.SystemText.Inv_Backpack);

        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(activeCharacter,
                                                                             (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
        };

        HorizontalStack moneyAndFoodStack;

        if (showTotalPartyGold)
        {
            var tf    = Resolve <ITextFormatter>();
            int total = Resolve <IParty>().StatusBarOrder.Sum(x => x.Apparent.Inventory.Gold.Amount);
            var money = new Button(
                new VerticalStack(
                    new Spacing(64, 0),
                    new UiSpriteElement(Base.CoreSprite.UiGold)
            {
                Flags = SpriteFlags.Highlight
            },
                    new UiText(tf.Format(Base.SystemText.Shop_GoldAll)),
                    new SimpleText($"{total / 10}.{total % 10}")
                    )
            {
                Greedy = false
            })
            {
                IsPressed = true
            };
            moneyAndFoodStack = new HorizontalStack(money);
        }
        else
        {
            var goldButton = new LogicalInventorySlot(new InventorySlotId(activeCharacter, ItemSlotId.Gold));
            var foodButton = new LogicalInventorySlot(new InventorySlotId(activeCharacter, ItemSlotId.Rations));
            moneyAndFoodStack = new HorizontalStack(goldButton, foodButton);
        }

        var stack = new VerticalStack(
            new Spacing(0, 1),
            header,
            new Spacing(0, 1),
            slotHalfFrame,
            new Spacing(0, 2),
            moneyAndFoodStack,
            new Spacing(0, 9),
            new InventoryExitButton().OnClick(() => Raise(new InventoryCloseEvent()))
            )
        {
            Greedy = false
        };

        AttachChild(stack);
    }