예제 #1
0
        public InventoryScreen(
            ISetInventoryModeEvent modeEvent,
            PartyCharacterId activeCharacter,
            Func <InventoryPage> getPage,
            Action <InventoryPage> setPage) : base(DialogPositioning.TopLeft)
        {
            var leftPane =
                modeEvent.Mode switch
            {
                InventoryMode.Character => (IUiElement) new InventoryCharacterPane(activeCharacter, getPage, setPage),
                InventoryMode.Merchant => new InventoryMerchantPane((MerchantId)modeEvent.Submode),
                InventoryMode.Chest => new InventoryChestPane((ChestId)modeEvent.Submode),
                InventoryMode.LockedChest => new InventoryLockPane((ILockedInventoryEvent)modeEvent),
                InventoryMode.LockedDoor => new InventoryLockPane((ILockedInventoryEvent)modeEvent),
                _ => throw new InvalidOperationException($"Unexpected inventory mode {modeEvent.Mode}")
            };

            var middlePane = new InventoryMidPane(activeCharacter);
            var rightPane  = new InventoryRightPane(
                activeCharacter,
                modeEvent.Mode == InventoryMode.Merchant);

            // var frameDivider = new FrameDivider(135, 0, 4, 192);

            AttachChild(new UiFixedPositionElement <SlabId>(SlabId.SLAB, UiConstants.UiExtents));
            AttachChild(new FixedPosition(new Rectangle(0, 0, 135, UiConstants.ActiveAreaExtents.Height), leftPane));
            AttachChild(new FixedPosition(new Rectangle(142, 0, 134, UiConstants.ActiveAreaExtents.Height), middlePane));
            AttachChild(new FixedPosition(new Rectangle(280, 0, 71, UiConstants.ActiveAreaExtents.Height), rightPane));
        }
    }
예제 #2
0
        void Rebuild()
        {
            foreach (var child in Children)
            {
                child.Detach();
            }
            Children.Clear();

            var background = new UiFixedPositionElement <SlabId>(SlabId.SLAB, UiConstants.UiExtents);
            var leftPane   =
                _mode switch
            {
                InventoryMode.Character => (IUiElement) new InventoryCharacterPane(_activeCharacter, () => _page),
                InventoryMode.Merchant => new InventoryChestPane(false),
                InventoryMode.Chest => new InventoryChestPane(true),
                InventoryMode.LockedChest => new InventoryLockPane(true),
                InventoryMode.LockedDoor => new InventoryLockPane(false),
                _ => throw new InvalidOperationException($"Unexpected inventory mode {_mode}")
            };

            var middlePane = new InventoryMidPane(_activeCharacter, _config.Positions[_activeCharacter]);
            var rightPane  = new InventoryRightPane(_activeCharacter, ExitButtonId, _mode == InventoryMode.Merchant);
            // var frameDivider = new FrameDivider(135, 0, 4, 192);

            var leftContainer = new FixedPosition(
                new Rectangle(0, 0, 135, UiConstants.ActiveAreaExtents.Height), leftPane);

            var middleContainer = new FixedPosition(
                new Rectangle(142, 0, 134, UiConstants.ActiveAreaExtents.Height), middlePane);

            var rightContainer = new FixedPosition(
                new Rectangle(280, 0, 71, UiConstants.ActiveAreaExtents.Height), rightPane);

            Exchange
            .Attach(background)
            .Attach(leftContainer)
            .Attach(middleContainer)
            .Attach(rightContainer)
            ;
            Children.Add(background);
            Children.Add(leftContainer);
            Children.Add(middleContainer);
            Children.Add(rightContainer);
        }
    }
예제 #3
0
        public InventoryScreen(
            IEvent modeEvent,
            PartyMemberId activeCharacter,
            Func <InventoryPage> getPage,
            Action <InventoryPage> setPage) : base(DialogPositioning.TopLeft)
        {
            if (modeEvent == null)
            {
                throw new ArgumentNullException(nameof(modeEvent));
            }
            if (getPage == null)
            {
                throw new ArgumentNullException(nameof(getPage));
            }
            if (setPage == null)
            {
                throw new ArgumentNullException(nameof(setPage));
            }

            var leftPane =
                modeEvent switch
            {
                InventoryOpenEvent ioe => new InventoryCharacterPane(activeCharacter, getPage, setPage),
                MerchantEvent me => new InventoryMerchantPane(me.MerchantId),
                ChestEvent ce => ce.PickDifficulty == 0 ? (IUiElement) new InventoryChestPane(ce.ChestId) : new InventoryLockPane(ce),
                DoorEvent de => new InventoryLockPane(de),
                _ => throw new InvalidOperationException($"Unexpected inventory mode event {modeEvent}")
            };

            var middlePane = new InventoryMidPane(activeCharacter);
            var rightPane  = new InventoryRightPane(activeCharacter, modeEvent is MerchantEvent);

            // var frameDivider = new FrameDivider(135, 0, 4, 192);

            AttachChild(new UiFixedPositionElement(Base.UiBackground.Slab, UiConstants.UiExtents));
            AttachChild(new FixedPosition(new Rectangle(0, 0, 135, UiConstants.ActiveAreaExtents.Height), leftPane));
            AttachChild(new FixedPosition(new Rectangle(142, 0, 134, UiConstants.ActiveAreaExtents.Height), middlePane));
            AttachChild(new FixedPosition(new Rectangle(280, 0, 71, UiConstants.ActiveAreaExtents.Height), rightPane));
        }
    }