public static bool GetTextColor(LetterViewerMenu __instance, ref int __result) { if (__instance is LetterViewerMenuExtended letterViewerMenuExtended && letterViewerMenuExtended.TextColor.HasValue) { __result = (int)letterViewerMenuExtended.TextColor; return(false); }
public void receiveKeyPress(Keys k) { if (k == Keys.Escape || Game1.options.doesInputListContain(Game1.options.menuButton, k)) { if (!quit && !fadingToQuit) { Game1.playSound("bigDeSelect"); } if (letterView != null) { letterView.unload(); letterView = null; } quit = true; } else if (letterView != null) { letterView.receiveKeyPress(k); if (Game1.input.GetGamePadState().IsButtonDown(Buttons.RightTrigger) && !Game1.oldPadState.IsButtonDown(Buttons.RightTrigger)) { letterView.receiveGamePadButton(Buttons.RightTrigger); } if (Game1.input.GetGamePadState().IsButtonDown(Buttons.LeftTrigger) && Game1.oldPadState.IsButtonUp(Buttons.LeftTrigger)) { letterView.receiveGamePadButton(Buttons.LeftTrigger); } } }
public static bool Prefix(LetterViewerMenu __instance, ref int __result) { // Read mail ID from the gui field using reflection. String mailTitle = BookcaseMod.reflection.GetField <String>(__instance, "mailTitle").GetValue(); if (mailTitle != null) { // Convert mail ID to Bookcase's ID format. Ignoring validation warnings. Identifier id = new Identifier(mailTitle, false); if (Registries.Mail.HasKey(id)) { Letter currentLetter = Registries.Mail.Get(id); // If letter exists, and has a text color, modify the returned value. if (currentLetter != null && currentLetter.TextColor != -1) { __result = currentLetter.TextColor; return(false); } } } return(true); }
public static void Postfix(LetterViewerMenu __instance, string mail, string mailTitle, bool fromCollection, ref int ___moneyIncluded, ref Texture2D ___letterTexture) { // Convert mail ID to Bookcase's ID format. Ignoring validation warnings. Identifier id = new Identifier(mailTitle, false); if (Registries.Mail.HasKey(id)) { Letter currentLetter = Registries.Mail.Get(id); if (currentLetter != null) { // Set the background if the letter has one. if (currentLetter.Background != null) { ___letterTexture = currentLetter.Background; } // Add additional items if the letter has some. currentLetter.Gifts.ForEach((Action <Item>)(i => __instance.itemsToGrab.Add(new ClickableComponent(new Rectangle(__instance.xPositionOnScreen + __instance.width / 2 - 48, __instance.yPositionOnScreen + __instance.height - 32 - 96, 96, 96), i.getOne()) { myID = 104, leftNeighborID = 101, rightNeighborID = 102 }))); // Applys the current letter callback. if (currentLetter.Callback != null) { currentLetter.Callback.Invoke(currentLetter, __instance); } } } }
/*public Texture2D VillagerIcon; * * public int IconWidth = 0; * public int IconHeight = 0; * public int IndexCount = 0; * public int ChosenIndex = 0;*/ public PantryDonationSheet(string Lines, string Title, IMonitor monitor, IModHelper helper) : base(Lines, Title) { Helper = helper; Monitor = monitor; //VillagerIcon = Helper.Content.Load<Texture2D>("Assets/Textures/VillagerIcons.png", ContentSource.ModFolder); //getIconIndexCount(); MailAsSplitString = Lines.Split(','); foreach (string item in MailAsSplitString) { item.Trim(','); /*for(int i=0; i<IndexCount; i++) * { * if (item.Contains($"$VIndex{i}")) * { * item.Remove(item.IndexOf('$'), 7); * ChosenIndex = i; * } * }*/ MailAsOneString += item; } LetterViewerMenu menu = new LetterViewerMenu(MailAsOneString, Title); Game1.activeClickableMenu = menu; }
public void receiveKeyPress(Keys k) { if (k == Keys.Escape || Game1.options.doesInputListContain(Game1.options.menuButton, k)) { if (!this.quit && !this.fadingToQuit) { Game1.playSound("bigDeSelect"); } if (this.letterView != null) { this.letterView.unload(); this.letterView = null; } this.quit = true; return; } if (this.letterView != null) { this.letterView.receiveKeyPress(k); if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.RightTrigger) && !Game1.oldPadState.IsButtonDown(Buttons.RightTrigger)) { this.letterView.receiveGamePadButton(Buttons.RightTrigger); } if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.LeftTrigger) && Game1.oldPadState.IsButtonUp(Buttons.LeftTrigger)) { this.letterView.receiveGamePadButton(Buttons.LeftTrigger); } } }
private void ShowLetter() { Monitor.Log("Running the ShowLetter method.", LogLevel.Warn); LetterViewerMenu grampsLetter = new LetterViewerMenu(_i18n.Get("grandpas_letter", new { name = Game1.player.Name }));//{exitFunction = GiveItems}; Game1.activeClickableMenu = grampsLetter; Game1.activeClickableMenu.exitFunction = GiveItems; }
private void OnDayStarted(object sender, DayStartedEventArgs e) { var curDate = SDate.Now(); if (curDate < triggerDate) { Log($"new day {curDate.ToString()}, our day is coming.", LogLevel.Trace); return; } else if (curDate > triggerDate) { Log($"new day {curDate.ToString()}, our day has passed.", LogLevel.Trace); return; } Log($"new day {curDate.ToString()}, is our day", LogLevel.Trace); farmer = Game1.player; weapon = new MeleeWeapon(WEAP_ID); IClickableMenu narrationDayStart1 = new pepoHelper.DialogOnBlack(narrationMessage1) { exitFunction = () => { Game1.globalFadeToBlack(); } }; IClickableMenu narrationDayStart2 = new pepoHelper.DialogOnBlack(narrationMessage2); IClickableMenu letterGrandpa = new LetterViewerMenu(letterGrandpaMessage.Replace("@", farmer.Name)) { exitFunction = spawnChestWeapon }; Log("built the menus", LogLevel.Trace); // Make a chain of menus pepoHelper.MenuChainer menuChain = new pepoHelper.MenuChainer(); menuChain.Add(narrationDayStart1, narrationDayStart2, letterGrandpa); Log("chained the menus", LogLevel.Trace); menuChain.Start(Helper.Events.Display); Log("displayed DayStart narration1, continuing doing things in the background"); // Shift farmer to the left to leave the bed, location dependent on marriage status. if (farmer.isMarried()) { farmer.moveRelTiles(h: -1, faceDir: 2); Log("Farmer is married. Moved farmer out of spouse bed", LogLevel.Trace); } else { farmer.moveRelTiles(h: -2, faceDir: 3); Log("Farmer is not married. Moved farmer out of single bed.", LogLevel.Trace); } }
public void onLetterExit() { mouseActive = false; foregroundFadeChange = 0.0003f; fadingToQuit = true; if (letterView != null) { letterView.unload(); letterView = null; } Game1.playSound("newRecipe"); }
private void CallbackDishOfTheDay(Letter letter, LetterViewerMenu gui) { if (Game1.dishOfTheDay != null) { gui.itemsToGrab.Add(new ClickableComponent(new Rectangle(gui.xPositionOnScreen + gui.width / 2 - 48, gui.yPositionOnScreen + gui.height - 32 - 96, 96, 96), (Item)Game1.dishOfTheDay.getOne()) { myID = 104, leftNeighborID = 101, rightNeighborID = 102 }); } }
private static bool LetterViewerMenu_update_Prefix(LetterViewerMenu __instance) { if (__instance.mailTitle.Equals("ItemPipes_SendWrench")) { Item wrench = Factories.ItemFactory.CreateTool("Wrench"); if (!__instance.itemsToGrab.Any(c => c != null && c.item != null && c.item.Name.Equals("Wrench")) && !WrenchCrafted) { __instance.itemsToGrab.Add(new ClickableComponent(new Rectangle(__instance.xPositionOnScreen + __instance.width / 2 - 48, __instance.yPositionOnScreen + __instance.height - 32 - 96, 96, 96), Factories.ItemFactory.CreateTool("Wrench"))); WrenchCrafted = true; } } return(true); }
public void receiveLeftClick(int x, int y, bool playSound = true) { if (!clickedLetter && mouseActive && (clickableGrandpaLetterRect().Contains(x, y) || Game1.options.SnappyMenus)) { clickedLetter = true; Game1.playSound("newRecipe"); Game1.changeMusicTrack("musicboxsong"); letterView = new LetterViewerMenu(Game1.player.IsMale ? Game1.content.LoadString("Strings\\StringsFromCSFiles:GrandpaStory.cs.12051", Game1.player.Name, Game1.player.farmName) : Game1.content.LoadString("Strings\\StringsFromCSFiles:GrandpaStory.cs.12055", Game1.player.Name, Game1.player.farmName)); letterView.exitFunction = onLetterExit; } if (letterView != null) { letterView.receiveLeftClick(x, y); } }
internal static void LetterViewerMenuPatch(LetterViewerMenu __instance) { try { if (!__instance.IsActive()) { return; } NarrateLetterContent(__instance); } catch (Exception e) { MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); } }
public static void CollectMailAttachmentsAndQuests(LetterViewerMenu menu) { IReflectedField <int> questIdField = Reflection.GetField <int>(menu, "questID"); int questId = questIdField.GetValue(); if (menu.itemsLeftToGrab()) { foreach (ClickableComponent component in menu.itemsToGrab.ToArray()) { if (component.item == null || !CanPlayerAcceptsItemPartially(component.item)) { continue; } int stack = component.item.Stack; Game1.playSound("coin"); int remain = Util.AddItemIntoInventory(component.item); Logger.Log($"You collected {component.item.DisplayName}{(stack - remain > 1 ? " x" + (stack - remain) : "")}."); if (remain == 0) { component.item = null; } else { component.item.Stack = remain; } } } if (questId == -1) { return; } Logger.Log($"You started Quest: '{Quest.getQuestFromId(questId).questTitle}'."); Game1.player.addQuest(questId); Game1.playSound("newArtifact"); questIdField.SetValue(-1); }
public void receiveLeftClick(int x, int y, bool playSound = true) { if (!this.clickedLetter && this.mouseActive && (this.clickableGrandpaLetterRect().Contains(x, y) || Game1.options.SnappyMenus)) { this.clickedLetter = true; Game1.playSound("newRecipe"); Game1.changeMusicTrack("musicboxsong"); this.letterView = new LetterViewerMenu(Game1.player.isMale ? Game1.content.LoadString("Strings\\StringsFromCSFiles:GrandpaStory.cs.12051", new object[] { Game1.player.name, Game1.player.farmName }) : Game1.content.LoadString("Strings\\StringsFromCSFiles:GrandpaStory.cs.12055", new object[] { Game1.player.name, Game1.player.farmName })); this.letterView.exitFunction = new IClickableMenu.onExit(this.onLetterExit); } if (this.letterView != null) { this.letterView.receiveLeftClick(x, y, true); } }
internal static void NarrateLetterContent(LetterViewerMenu __instance) { int x = Game1.getMousePosition().X, y = Game1.getMousePosition().Y; #region Texts in the letter string message = __instance.mailMessage[__instance.page]; string toSpeak = $"{message}"; if (__instance.ShouldShowInteractable()) { if (__instance.moneyIncluded > 0) { string moneyText = Game1.content.LoadString("Strings\\UI:LetterViewer_MoneyIncluded", __instance.moneyIncluded); toSpeak += $"\t\n\t ,Included money: {moneyText}"; } else if (__instance.learnedRecipe != null && __instance.learnedRecipe.Length > 0) { string recipeText = Game1.content.LoadString("Strings\\UI:LetterViewer_LearnedRecipe", __instance.cookingOrCrafting); toSpeak += $"\t\n\t ,Learned Recipe: {recipeText}"; } } if (currentLetterText != toSpeak) { currentLetterText = toSpeak; // snap mouse to accept quest button if (__instance.acceptQuestButton != null && __instance.questID != -1) { toSpeak += "\t\n Left click to accept quest."; __instance.acceptQuestButton.snapMouseCursorToCenter(); } if (__instance.mailMessage.Count > 1) { toSpeak = $"Page {__instance.page + 1} of {__instance.mailMessage.Count}:\n\t{toSpeak}"; } MainClass.ScreenReader.Say(toSpeak, true); } #endregion #region Narrate items given in the mail if (__instance.ShouldShowInteractable()) { foreach (ClickableComponent c in __instance.itemsToGrab) { if (c.item == null) { continue; } string name = c.item.DisplayName; if (c.containsPoint(x, y)) { MainClass.ScreenReader.SayWithChecker($"Left click to collect {name}", false); } } } #endregion #region Narrate buttons if (__instance.backButton != null && __instance.backButton.visible && __instance.backButton.containsPoint(x, y)) { MainClass.ScreenReader.SayWithChecker($"Previous page button", false); } if (__instance.forwardButton != null && __instance.forwardButton.visible && __instance.forwardButton.containsPoint(x, y)) { MainClass.ScreenReader.SayWithChecker($"Next page button", false); } #endregion }