/// <summary> /// Create a new instance of the <see cref="LetterViewerMenuEx2"/> class. /// </summary> /// <param name="id">The ID of the mail.</param> /// <param name="text">The text content of the mail.</param> /// <param name="questId">The ID of the quest included in the mail.</param> /// <param name="isAutomaticallyAccepted"> /// Indicates whether the included quest is automatically accepted when the mail is opened or if the /// player needs to manually accept it. /// </param> /// <returns>The created <see cref="LetterViewerMenuEx2"/> instance.</returns> public static LetterViewerMenuEx2 CreateQuestMailMenu(string id, string text, int questId, bool isAutomaticallyAccepted) { var menu = new LetterViewerMenuEx2(id, text) { mailType = MailType.QuestMail, attachedQuestId = questId < 1 ? QUEST_ID_NO_QUEST : questId, }; // If the ID does not represent an existing quest, we don't include it in the mail. if (menu.attachedQuestId == QUEST_ID_NO_QUEST) { menu.QuestId = QUEST_ID_NO_QUEST; return(menu); } // Add the quest to the player's quest log if it is an automatically accepted quest. if (isAutomaticallyAccepted) { Game1.player.addQuest(questId); menu.questAccepted = true; menu.QuestId = QUEST_ID_NO_QUEST; return(menu); } // Specified quest has to be manually accepted by the player -> setup [quest accept] button in the menu. menu.QuestId = questId; string label = Game1.content.LoadString("Strings\\UI:AcceptQuest"); menu.acceptQuestButton = new ClickableComponent( new Rectangle(menu.xPositionOnScreen + menu.width / 2 - 128, menu.yPositionOnScreen + menu.height - 128, (int)Game1.dialogueFont.MeasureString(label).X + 24, (int)Game1.dialogueFont.MeasureString(label).Y + 24), "") { myID = region_acceptQuestButton, rightNeighborID = region_forwardButton, leftNeighborID = region_backButton }; menu.backButton.rightNeighborID = region_acceptQuestButton; menu.forwardButton.leftNeighborID = region_acceptQuestButton; if (!Game1.options.SnappyMenus) { return(menu); } menu.populateClickableComponentList(); menu.snapToDefaultClickableComponent(); return(menu); }
/// <summary> /// Create a new instance of the <see cref="LetterViewerMenuEx2"/> class. /// </summary> /// <param name="id">The ID of the mail.</param> /// <param name="text">The text content of the mail.</param> /// <param name="attachedItems">The items attached to the mail. Can be <c>null</c>.</param> /// <returns>The created <see cref="LetterViewerMenuEx2"/> instance.</returns> public static LetterViewerMenuEx2 CreateItemMailMenu(string id, string text, IList <Item> attachedItems) { var menu = new LetterViewerMenuEx2(id, text) { selectedItems = new List <Item>(), mailType = MailType.ItemMail }; // If the mail has attached items, add them to the LetterViewerMenu so they will be shown when the // mail is drawn to the screen. if (attachedItems?.Count > 0) { foreach (var item in attachedItems) { var attachedItemComponent = new ClickableComponent( new Rectangle(menu.xPositionOnScreen + menu.width / 2 - 48, menu.yPositionOnScreen + menu.height - 32 - 96, 96, 96), item) { myID = region_itemGrabButton, leftNeighborID = region_backButton, rightNeighborID = region_forwardButton }; menu.itemsToGrab.Add(attachedItemComponent); } menu.backButton.rightNeighborID = region_itemGrabButton; menu.forwardButton.leftNeighborID = region_itemGrabButton; if (!Game1.options.SnappyMenus) { return(menu); } menu.populateClickableComponentList(); menu.snapToDefaultClickableComponent(); } return(menu); }