Example #1
0
        private void ComponentHovered(ModStatus which, int offset)
        {
            switch (offset)
            {
            case 0:
                this.hoverText = $"{which.ModName}^By: {which.ModAuthor}";
                break;

            case 1:
                switch (which.UpdateStatus)
                {
                case UpdateStatus.UpToDate:
                    this.hoverText = $"You have: {which.CurrentVersion}.";
                    break;

                case UpdateStatus.OutOfDate:
                    this.hoverText = $"You have: {which.CurrentVersion}^Latest version: {which.NewVersion}";
                    break;

                case UpdateStatus.Error:
                    this.hoverText = $"Failed to check updates: ^{which.ErrorReason}";
                    break;

                case UpdateStatus.Skipped:
                    this.hoverText = $"Mod not loaded: ^{which.ErrorReason}";
                    break;
                }
                break;

            case 2:
                this.hoverText = $"Click to go to: ^{which.UpdateURL}";
                break;
            }

            this.hoverTextDimensions = UpdateMenu.GetDimensions(this.hoverText);
        }
Example #2
0
        public override void draw(SpriteBatch b)
        {
            Vector2 centeringOnScreen = Utility.getTopLeftPositionForCenteringOnScreen(this.width, ((IClickableMenu)this).height - 100, 0, 0);

            b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.75f);
            IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(473, 36, 24, 24), (int)centeringOnScreen.X, (int)centeringOnScreen.Y, this.width, ((IClickableMenu)this).height - 150, Color.White, 4f, true);

            int startX = (int)centeringOnScreen.X + 32;
            int startY = (int)centeringOnScreen.Y + 32;

            for (int i = 0; i < UpdateMenu.sections.Length; i++)
            {
                int xOffset = (i * this.width) / UpdateMenu.sections.Length;
                if (i != 0)
                {
                    SpriteText.drawString(b, UpdateMenu.HeaderDivider, startX + xOffset - this.headerDividerDimensions.X, startY, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
                }

                xOffset += (this.width / UpdateMenu.sections.Length) / 2 - SpriteText.getWidthOfString(UpdateMenu.sections[i]) / 2;
                SpriteText.drawString(b, UpdateMenu.sections[i], startX + xOffset, startY, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
            }


            SpriteText.drawString(b, this.modDivider, startX, startY + 32, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);

            if (!this.notified)
            {
                SpriteText.drawString(b, $"{UpdateMenu.UpdateProgress}{this.GetDots(this.numDots)}", startX + this.width / 2 - this.updateProgressDimensions.X, startY + (((IClickableMenu)this).height - 100) / 2 - this.updateProgressDimensions.Y, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
            }
            else if (this.statuses == null)
            {
                SpriteText.drawString(b, UpdateMenu.ErrorChecking, startX + this.width / 2 - this.errorCheckingDimensions.X, startY + (((IClickableMenu)this).height - 100) / 2 - this.errorCheckingDimensions.Y, 9999, -1, 9999, 1f, 0.88f, false, -1, "", SpriteText.color_Red);
            }
            else
            {
                startX += this.headerDividerDimensions.X;
                int yOffset = startY + 64 + 16;
                foreach (ModStatus status in this.statuses)
                {
                    string modName = status.ModName;
                    while (SpriteText.getWidthOfString(modName) > this.width / UpdateMenu.sections.Length)
                    {
                        modName = modName.Substring(0, modName.Length - 1);
                    }

                    if (modName != status.ModName)
                    {
                        modName = modName.Substring(0, modName.Length - 3) + "...";
                    }
                    SpriteText.drawString(b, modName, startX, yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
                    SpriteText.drawString(b, status.UpdateStatus.ToString(), startX + this.width / UpdateMenu.sections.Length, yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", UpdateMenu.GetColorForStatus(status.UpdateStatus));
                    SpriteText.drawString(b, status.UpdateURLType, startX + 2 * this.width / UpdateMenu.sections.Length, yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
                    yOffset += 64;
                }

                if (this.hoverText != null)
                {
                    int xPos = Game1.getMouseX() + 32;
                    if (xPos > Game1.viewport.Width / 2)
                    {
                        xPos -= this.hoverTextDimensions.X + 32;
                    }
                    IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), xPos, Game1.getMouseY() + 32, this.hoverTextDimensions.X + 32, this.hoverTextDimensions.Y + 32, Color.White);
                    SpriteText.drawString(b, this.hoverText, xPos + 16, Game1.getMouseY() + 32 + 16, 9999, -1, 9999, 1f, 0.88f, false, -1, "", SpriteText.color_Gray);
                }
            }
        }
Example #3
0
        public override void draw(SpriteBatch b)
        {
            Vector2 centeringOnScreen = Utility.getTopLeftPositionForCenteringOnScreen(this.width, ((IClickableMenu)this).height - 100, 0, 0);

            b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.75f);
            IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(473, 36, 24, 24), (int)centeringOnScreen.X, (int)centeringOnScreen.Y, this.width, ((IClickableMenu)this).height - 150, Color.White, 4f, true);

            int startX = (int)centeringOnScreen.X + 32;
            int startY = (int)centeringOnScreen.Y + 32;

            for (int i = 0; i < UpdateMenu.sections.Length; i++)
            {
                double width   = this.GetColumnWidth(i);
                int    xOffset = 0;
                for (int j = 0; j < i; j++)
                {
                    xOffset += this.GetColumnWidth(j);
                }

                if (i != 0)
                {
                    SpriteText.drawString(b, UpdateMenu.HeaderDivider, startX + xOffset - this.headerDividerDimensions.X, startY, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
                }

                string headerText = UpdateMenu.sections[i] +
                                    (this.currentSortColumn == i ? (this.currentSortDirection == 0 ? " A" : " V") : "");
                xOffset += (int)(width / 2) - SpriteText.getWidthOfString(UpdateMenu.sections[i]) / 2;
                SpriteText.drawString(b, headerText, startX + xOffset, startY, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
            }


            SpriteText.drawString(b, this.modDivider, startX, startY + 32, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);

            if (!this.notified)
            {
                SpriteText.drawString(b, $"{UpdateMenu.UpdateProgress}{this.GetDots(this.numDots)}", startX + this.width / 2 - this.updateProgressDimensions.X, startY + (((IClickableMenu)this).height - 100) / 2 - this.updateProgressDimensions.Y, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
            }
            else if (this.statuses == null)
            {
                SpriteText.drawString(b, UpdateMenu.ErrorChecking, startX + this.width / 2 - this.errorCheckingDimensions.X, startY + (((IClickableMenu)this).height - 100) / 2 - this.errorCheckingDimensions.Y, 9999, -1, 9999, 1f, 0.88f, false, -1, "", SpriteText.color_Red);
            }
            else
            {
                startX += this.headerDividerDimensions.X;
                int yOffset = startY + 64 + 16;
                foreach (ModStatus status in this.statuses)
                {
                    string modName = status.ModName;
                    while (SpriteText.getWidthOfString(modName) > this.GetColumnWidth(0))
                    {
                        modName = modName.Substring(0, modName.Length - 1);
                    }

                    if (modName != status.ModName)
                    {
                        modName = modName.Substring(0, modName.Length - 3) + "...";
                    }
                    SpriteText.drawString(b, modName, startX, yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
                    SpriteText.drawString(b, status.UpdateStatus.ToString(), startX + (int)this.GetColumnWidth(0), yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", UpdateMenu.GetColorForStatus(status.UpdateStatus));
                    SpriteText.drawString(b, status.UpdateURLType, startX + (int)this.GetColumnWidth(0) + (int)this.GetColumnWidth(1), yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
                    yOffset += 64;
                }

                if (this.hoverText != null)
                {
                    int xPos = Game1.getMouseX() + 32;
                    if (xPos > Game1.viewport.Width / 2)
                    {
                        xPos -= this.hoverTextDimensions.X + 32;
                    }
                    int yPos = Game1.getMouseY() + 32 + 16;
                    if (yPos > Game1.viewport.Height * (3.0 / 4))
                    {
                        yPos -= this.hoverTextDimensions.Y + 64;
                    }
                    IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), xPos, yPos - 16, this.hoverTextDimensions.X + 32, this.hoverTextDimensions.Y + 32, Color.White);
                    SpriteText.drawString(b, this.hoverText, xPos + 16, yPos, 9999, -1, 9999, 1f, 0.88f, false, -1, "", SpriteText.color_Gray);
                }

                if (this.statuses != null)
                {
                    int numSteps = this.originalStatuses.Count - this.numDisplayableMods;
                    yOffset = (int)((((float)this.displayIndex) / numSteps) * (((IClickableMenu)this).height - 200 + 16));

                    drawTextureBox(b, Game1.mouseCursors, new Rectangle(325, 448, 5, 17),
                                   (int)centeringOnScreen.X + this.width,
                                   (int)centeringOnScreen.Y + yOffset, 16, 32, Color.White, 4f, false);
                }
            }
        }
Example #4
0
        private void ComponentHovered(ModStatus which, int offset)
        {
            if (which == null)
            {
                if (this.currentSortColumn == -1 || offset != this.currentSortColumn)
                {
                    this.hoverText = "Click to Sort By:^Mod ";
                    switch (offset)
                    {
                    case 0:
                        this.hoverText += "Name";
                        break;

                    case 1:
                        this.hoverText += "Status";
                        break;

                    case 2:
                        this.hoverText += "Link";
                        break;
                    }
                }
                else if (offset == this.currentSortColumn)
                {
                    this.hoverText = "Currently Sorting:^" +
                                     (this.currentSortDirection == 0 ? "Ascending" : "Descending");
                }
            }
            else
            {
                switch (offset)
                {
                case 0:
                    this.hoverText = $"{which.ModName}^By: {which.ModAuthor}";
                    break;

                case 1:
                    switch (which.UpdateStatus)
                    {
                    case UpdateStatus.UpToDate:
                        this.hoverText = $"You have: {which.CurrentVersion}.";
                        break;

                    case UpdateStatus.OutOfDate:
                        this.hoverText = $"You have: {which.CurrentVersion}^Latest version: {which.NewVersion}";
                        break;

                    case UpdateStatus.Error:
                        this.hoverText = $"Failed to check updates: ^{which.ErrorReason}";
                        break;

                    case UpdateStatus.Skipped:
                        this.hoverText = $"Mod not loaded: ^{which.ErrorReason}";
                        break;
                    }
                    break;

                case 2:
                    if (which.UpdateURLType != "???")
                    {
                        this.hoverText = $"Click to go to: ^{which.UpdateURL}";
                    }
                    else
                    {
                        this.hoverText = "Unknown update link.";
                    }
                    break;
                }
            }

            this.SplitHoverText();
            this.hoverTextDimensions = UpdateMenu.GetDimensions(this.hoverText);
        }