示例#1
0
        public OutfitsMenu(HandMirrorMenu callbackMenu) : base(0, 0, 700, 550, showUpperRightCloseButton: true)
        {
            _callbackMenu = callbackMenu;

            // Set up menu structure
            if (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.ko || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.fr)
            {
                base.height += 64;
            }

            Vector2 topLeft = Utility.getTopLeftPositionForCenteringOnScreen(base.width, base.height);

            base.xPositionOnScreen = (int)topLeft.X;
            base.yPositionOnScreen = (int)topLeft.Y;

            Game1.playSound("bigSelect");
            PaginatePacks();

            // Establish the buttons that will be used to select the outfits
            for (int i = 0; i <= OUTFITS_PER_PAGE; i++)
            {
                ClickableComponent packButton = new ClickableComponent(new Rectangle(base.xPositionOnScreen + 16, base.yPositionOnScreen + 16 + i * ((base.height - 32) / 6), base.width - 32, (base.height - 32) / 6 + 4), string.Concat(i))
                {
                    myID            = i,
                    downNeighborID  = -7777,
                    upNeighborID    = ((i > 0) ? (i - 1) : (-1)),
                    rightNeighborID = i + 103,
                    leftNeighborID  = -7777,
                    fullyImmutable  = true
                };
                outfitButtons.Add(packButton);

                ClickableTextureComponent renameButton = new ClickableTextureComponent(new Rectangle(packButton.bounds.Right - 192, packButton.bounds.Y + packButton.bounds.Height / 4 + 8, 56, 48), Game1.mouseCursors, new Rectangle(66, 4, 14, 12), 3f)
                {
                    myID            = i + 200,
                    downNeighborID  = -7777,
                    upNeighborID    = ((i > 0) ? (i + 100 - 1) : (-1)),
                    rightNeighborID = -7777,
                    leftNeighborID  = -7777,
                    fullyImmutable  = true
                };
                renameButtons.Add(renameButton);

                ClickableTextureComponent saveButton = new ClickableTextureComponent(new Rectangle(renameButton.bounds.X + 64, packButton.bounds.Y + packButton.bounds.Height / 4 - 2, 56, 48), Game1.mouseCursors, new Rectangle(240, 320, 16, 16), 3f)
                {
                    myID            = i + 100,
                    downNeighborID  = -7777,
                    upNeighborID    = ((i > 0) ? (i + 100 - 1) : (-1)),
                    rightNeighborID = -7777,
                    leftNeighborID  = -7777,
                    fullyImmutable  = true
                };
                saveButtons.Add(saveButton);

                ClickableTextureComponent deleteButton = new ClickableTextureComponent(new Rectangle(renameButton.bounds.X + 128, packButton.bounds.Y + packButton.bounds.Height / 4 + 4, 56, 48), Game1.mouseCursors, new Rectangle(323, 433, 9, 10), 4f)
                {
                    myID            = i + 300,
                    downNeighborID  = -7777,
                    upNeighborID    = ((i > 0) ? (i + 100 - 1) : (-1)),
                    rightNeighborID = -7777,
                    leftNeighborID  = -7777,
                    fullyImmutable  = true
                };
                deleteButtons.Add(deleteButton);
            }

            // Set up the various other buttons
            backButton = new ClickableTextureComponent(new Rectangle(base.xPositionOnScreen - 64, base.yPositionOnScreen + 8, 48, 44), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f)
            {
                myID            = 102,
                rightNeighborID = -7777
            };
            forwardButton = new ClickableTextureComponent(new Rectangle(base.xPositionOnScreen + base.width + 64 - 48, base.yPositionOnScreen + base.height - 48, 48, 44), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f)
            {
                myID = 101
            };
            base.upperRightCloseButton = new ClickableTextureComponent(new Rectangle(base.xPositionOnScreen + base.width - 20, base.yPositionOnScreen - 8, 48, 48), Game1.mouseCursors, new Rectangle(337, 494, 12, 12), 4f);
        }
示例#2
0
        public SearchMenu(Farmer who, string appearanceFilter, HandMirrorMenu callbackMenu) : base(0, 0, 832, 576, showUpperRightCloseButton: true)
        {
            // Set up menu structure
            if (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.ko || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.fr)
            {
                base.height += 64;
            }

            Vector2 topLeft = Utility.getTopLeftPositionForCenteringOnScreen(base.width, base.height);

            base.xPositionOnScreen = (int)topLeft.X;
            base.yPositionOnScreen = (int)topLeft.Y;

            // Populate the texture selection components
            var appearancePacks = FashionSense.textureManager.GetAllAppearanceModels();

            switch (appearanceFilter)
            {
            case HandMirrorMenu.HAIR_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is HairContentPack).ToList();
                break;

            case HandMirrorMenu.ACCESSORY_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is AccessoryContentPack).ToList();
                break;

            case HandMirrorMenu.HAT_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is HatContentPack).ToList();
                break;

            case HandMirrorMenu.SHIRT_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is ShirtContentPack).ToList();
                break;

            case HandMirrorMenu.PANTS_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is PantsContentPack).ToList();
                break;

            case HandMirrorMenu.SLEEVES_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is SleevesContentPack).ToList();

                if (callbackMenu.GetCurrentFeatureSlotKey() == ModDataKeys.CUSTOM_SHOES_ID)
                {
                    appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is ShoesContentPack).ToList();
                }
                break;
            }

            for (int m = 0; m < appearancePacks.Count; m++)
            {
                filteredTextureOptions.Add(appearancePacks[m]);
                cachedTextureOptions.Add(appearancePacks[m]);
            }

            _displayFarmer    = who;
            _appearanceFilter = appearanceFilter;
            _callbackMenu     = callbackMenu;

            var drawingScale     = 4f;
            var widthOffsetScale = 3;
            var sourceRect       = new Rectangle(0, 0, Game1.daybg.Width, Game1.daybg.Height);

            for (int r = 0; r < _maxRows; r++)
            {
                for (int c = 0; c < _texturesPerRow; c++)
                {
                    var componentId = c + r * _texturesPerRow;
                    availableTextures.Add(new ClickableTextureComponent(new Rectangle(32 + base.xPositionOnScreen + IClickableMenu.borderWidth + componentId % _texturesPerRow * 64 * widthOffsetScale, base.yPositionOnScreen + sourceRect.Height / 2 + componentId + (r * sourceRect.Height) + (r > 0 ? 64 : 0) - 32, sourceRect.Width, sourceRect.Height), null, new Rectangle(), drawingScale, false)
                    {
                        myID            = componentId,
                        downNeighborID  = componentId + _texturesPerRow,
                        upNeighborID    = r >= _texturesPerRow ? componentId - _texturesPerRow : -1,
                        rightNeighborID = c == 5 ? 9997 : componentId + 1,
                        leftNeighborID  = c > 0 ? componentId - 1 : 9998
                    });

                    var fakeFarmer = _displayFarmer.CreateFakeEventFarmer();
                    fakeFarmer.faceDirection(who.facingDirection);
                    foreach (var key in _displayFarmer.modData.Keys)
                    {
                        fakeFarmer.modData[key] = _displayFarmer.modData[key];
                    }
                    fakeFarmers.Add(fakeFarmer);
                }
            }
            UpdateDisplayFarmers();

            backButton = new ClickableTextureComponent(new Rectangle(base.xPositionOnScreen - 64, base.yPositionOnScreen + 8, 48, 44), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f)
            {
                myID            = 9998,
                rightNeighborID = 0
            };
            forwardButton = new ClickableTextureComponent(new Rectangle(base.xPositionOnScreen + base.width + 64 - 48, base.yPositionOnScreen + base.height - 48, 48, 44), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f)
            {
                myID = 9997
            };

            // Textbox related
            var xTextbox = base.xPositionOnScreen + 64 + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + 320;
            var yTextbox = base.yPositionOnScreen - 58;

            _searchBox = new TextBox(Game1.content.Load <Texture2D>("LooseSprites\\textBox"), null, Game1.smallFont, Game1.textColor)
            {
                X          = xTextbox,
                Y          = yTextbox,
                Width      = 384,
                limitWidth = false,
                Text       = String.Empty
            };

            _searchBoxCC = new ClickableComponent(new Rectangle(xTextbox, yTextbox, 192, 48), "")
            {
                myID            = 9999,
                upNeighborID    = -99998,
                leftNeighborID  = -99998,
                rightNeighborID = -99998,
                downNeighborID  = -99998
            };
            Game1.keyboardDispatcher.Subscriber = _searchBox;
            _searchBox.Selected = true;

            queryButton = new ClickableTextureComponent(new Rectangle(xTextbox - 32, base.yPositionOnScreen - 48, 48, 44), Game1.mouseCursors, new Rectangle(208, 320, 16, 16), 2f)
            {
                myID = -1
            };

            // Call snap functions
            if (Game1.options.SnappyMenus)
            {
                base.populateClickableComponentList();
                snapToDefaultClickableComponent();
            }
        }