コード例 #1
0
ファイル: memoriesMenu.cs プロジェクト: skuldomg/Memories
        public MemoriesMenu(NetIntList eventsSeen, IMonitor monitor) : base(Game1.viewport.Width / 2 - MemoriesMenu.menuWidth / 2 - IClickableMenu.borderWidth * 2, Game1.viewport.Height / 2 - MemoriesMenu.menuHeight - IClickableMenu.borderWidth * 2, MemoriesMenu.menuWidth + IClickableMenu.borderWidth * 2, MemoriesMenu.menuHeight + IClickableMenu.borderWidth, false)
        {
            this.monitor = monitor;
            this.eventsSeen = eventsSeen;

            monitor.Log("Creating memories menu ...");

            // Iterate through events seen and create the photo album
            for (int index = 0; index < eventsSeen.Count; ++index)
            {
                List<ClickableTextureComponent> memoryToPlay = this.memoryToPlay;

                ClickableTextureComponent textureComponent = new ClickableTextureComponent(index.ToString(), // name
                    // bounds
                    new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.borderWidth + index % 3 * 64 * 2, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth / 2 + index / 3 * 85, 128, 64),
                    (string)null,
                    // Hover text
                    "Memory " + index.ToString(),
                    // Texture file to load
                    Game1.mouseCursors,
                    // Source rectangle of the texture file to load
                    // TODO: Replace this with my own asset file containing photo previews
                    new Microsoft.Xna.Framework.Rectangle(index % 3 * 16 * 2, 448 + index / 3 * 16, 32, 16),
                    4f,
                    false);

                textureComponent.myID = index;
                // alternate ID = event ID
                textureComponent.myAlternateID = eventsSeen.ElementAt(index);
                textureComponent.rightNeighborID = index % 3 == 2 ? -1 : index + 1;
                textureComponent.leftNeighborID = index % 3 == 0 ? -1 : index - 1;
                textureComponent.downNeighborID = index + 3;
                textureComponent.upNeighborID = index - 3;
                memoryToPlay.Add(textureComponent);

                monitor.Log("Created memory texture component with ID " + textureComponent.myID.ToString()+" and event ID "+textureComponent.myAlternateID.ToString());
            }

            // OK Button
            ClickableTextureComponent textureComponent1 = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - 64 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47, -1, -1), 1f, false);
            textureComponent1.myID = 101;
            textureComponent1.upNeighborID = 103;
            textureComponent1.leftNeighborID = 103;
            this.okButton = textureComponent1;

            if (!Game1.options.SnappyMenus)
                return;

            this.populateClickableComponentList();
            this.snapToDefaultClickableComponent();
        }