private bool IsGoToSleepDialog(StardewValley.Menus.IClickableMenu menu) { StardewValley.Menus.DialogueBox dialogBox = menu as StardewValley.Menus.DialogueBox; if (dialogBox != null) { List <string> dialogs = this.Helper.Reflection.GetField <List <string> >(dialogBox, "dialogues").GetValue(); if (dialogs != null && dialogs.Count >= 1) { return(dialogs[0].Equals(StardewValley.Game1.content.LoadString("Strings\\Locations:FarmHouse_Bed_GoToSleep"))); } } return(false); }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { // Only fire after 1 sec. in-game. if (e.Ticks < 60) { return; } // And only fire once. Helper.Events.GameLoop.OneSecondUpdateTicked -= GameLoop_OneSecondUpdateTicked; // Create a warning message if patches failed to apply cleanly. if (broken_mods.Count == 0) { return; } var mod_list = new List <string>(); foreach (var i in broken_mods) { var mod = Helper.ModRegistry.Get(i).Manifest; mod_list.Add($"{mod.Name} (v{mod.Version})"); } // The message is a list containing a single string. var dialogue = new List <string>() { "StardewHack v" + ModManifest.Version + " failed to apply some bytecode patches. The following mods won't work correctly or at all: " + mod_list.Join() + ". Check your console or error log for further instructions." }; // Create the dialogue box. We can't pass a string directly as the signature differs between the PC and android version. var box = new StardewValley.Menus.DialogueBox(dialogue); StardewValley.Game1.activeClickableMenu = box; StardewValley.Game1.dialogueUp = true; box.finishTyping(); }
// private static ModEntry Mod; // public static void Init(ModEntry mod) { // Mod = mod; //} public static void Prefix(StardewValley.Menus.DialogueBox __instance) { __instance.characterIndexInDialogue = __instance.getCurrentString().Length; }
private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e != null) { currentMenu = e.NewMenu; if (currentMenu != null) { if (currentMenu is StardewValley.Menus.ShopMenu) { StardewValley.Menus.ShopMenu shopMenu = (StardewValley.Menus.ShopMenu)currentMenu; if (shopMenu != null && shopMenu.portraitPerson != null && shopMenu.portraitPerson.Name == "Marnie") { IReflectedField <Dictionary <ISalable, int[]> > inventoryInformation = Helper.Reflection.GetField <Dictionary <ISalable, int[]> >(shopMenu, "itemPriceAndStock"); Dictionary <ISalable, int[]> itemPriceAndStock = null; if (inventoryInformation != null) { itemPriceAndStock = inventoryInformation.GetValue(); } IReflectedField <List <ISalable> > forSaleInformation = Helper.Reflection.GetField <List <ISalable> >(shopMenu, "forSale"); List <ISalable> forSale = null; if (forSaleInformation != null) { forSale = forSaleInformation.GetValue(); } if (forSale != null && itemPriceAndStock != null) { Item milk = new StardewValley.Object(184, config.numMilkToStock, false, -1, 0); itemPriceAndStock.Add(milk, new[] { milk.salePrice() * 3, milk.Stack }); if (!forSale.Contains(milk)) { forSale.Add(milk); } List <Item> eggsToAdd = GetEggsOfTheDay(); if (eggsToAdd != null) { foreach (Item eggToAdd in eggsToAdd) { itemPriceAndStock.Add(eggToAdd, new[] { eggToAdd.salePrice() * 5, eggToAdd.Stack }); if (!forSale.Contains(eggToAdd)) { forSale.Add(eggToAdd); } } } inventoryInformation.SetValue(itemPriceAndStock); forSaleInformation.SetValue(forSale); } } } else if (currentMenu is StardewValley.Menus.DialogueBox) { StardewValley.Menus.DialogueBox dialogueBox = (StardewValley.Menus.DialogueBox)currentMenu; if (eventText != "") { if (dialogueBox != null && dialogueBox.getCurrentString() == "??") { string eventTextClone = eventText; Game1.drawObjectDialogue(eventTextClone); } eventText = ""; } } } } }