/// <summary> /// Handles the left click on the UI elements /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="playSound"></param> public override void receiveLeftClick(int x, int y, bool playSound = true) { // clicked next page if (NextPageButton.containsPoint(x, y)) { if (Reminders.Count > (PageIndex + 1) * 5) { PageIndex += 1; SetUpUI(); } } // clicked previous page else if (PrevPageButton.containsPoint(x, y)) { if (PageIndex != 0) { PageIndex -= 1; SetUpUI(); } } // clicked new reminder if (NewReminderButton.containsPoint(x, y)) { Game1.activeClickableMenu = new NewReminder_Page1(Page1OnChangeBehaviour); } // clicked delete button int reminderindex = 0; foreach (ClickableTextureComponent deleteButton in DeleteButtons) { reminderindex++; if (deleteButton.containsPoint(x, y)) { int reminderIndex = (PageIndex * 5) + reminderindex; Utilities.Files.DeleteReminder(reminderIndex); SetUpUI(); break; } } }
/// <summary>The draw calls for the UI elements</summary> public override void draw(SpriteBatch b) { CursorPosition = Utilities.Data.Helper.Input.GetCursorPosition(); // suppress the Menu button Utilities.Data.Helper.Input.Suppress(Utilities.Data.MenuButton); // draw screen fade b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.75f); // draw menu box Game1.drawDialogueBox(xPositionOnScreen, yPositionOnScreen, width, height - 12, false, true); // draw title scroll SpriteText.drawStringWithScrollCenteredAt(b, "Display Recurring Reminders", Game1.viewport.Width / 2, yPositionOnScreen, "Display Recurring Reminders"); // draw boxes foreach (ClickableTextureComponent box in Boxes) { box.draw(b); } // draw labels foreach (ClickableComponent label in ReminderMessages) { string text = ""; Color color = Game1.textColor; Utility.drawTextWithShadow(b, label.name, Game1.smallFont, new Vector2(label.bounds.X, label.bounds.Y), color); if (text.Length > 0) { Utility.drawTextWithShadow(b, text, Game1.smallFont, new Vector2((label.bounds.X + Game1.tileSize / 3) - Game1.smallFont.MeasureString(text).X / 2f, (label.bounds.Y + Game1.tileSize / 2)), color); } } if (Reminders.Count > (PageIndex + 1) * 5) { NextPageButton.draw(b); } if (PageIndex != 0) { PrevPageButton.draw(b); } // draw the delete buttons foreach (ClickableTextureComponent button in DeleteButtons) { button.draw(b); } // draw the warning for no reminder if (Reminders.Count <= 0) { Utility.drawTextWithShadow(b, NoRemindersWarning.name, Game1.smallFont, new Vector2(NoRemindersWarning.bounds.X, NoRemindersWarning.bounds.Y), Game1.textColor); } // draw new reminders button NewReminderButton.draw(b); // draw the boxes hover text foreach (ClickableTextureComponent box in Boxes) { if (box.containsPoint((int)CursorPosition.ScreenPixels.X, (int)CursorPosition.ScreenPixels.Y)) { if (box.hoverText != null) { int x = Game1.getMouseX() + 32; int y = Game1.getMouseY() + 32 + 16; IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), x, y - 16, Utilities.Extras.EstimateStringDimension(box.hoverText) + 8, Game1.tileSize + 16, Color.White, 1f, true); SpriteText.drawString(b, box.hoverText, x + 32, y, 999, -1, 99, 1f, 0.88f, false, -1, "", 8, SpriteText.ScrollTextAlignment.Left); } } } // draw cursor drawMouse(b); }
/// <summary>Defines what to do when hovering over UI elements</summary> public override void performHoverAction(int x, int y) { NewReminderButton.scale = NewReminderButton.containsPoint(x, y) ? Math.Min(NewReminderButton.scale + 0.02f, NewReminderButton.baseScale + 0.1f) : Math.Max(NewReminderButton.scale - 0.02f, NewReminderButton.baseScale); }