private void Display_RenderingActiveMenu(object sender, StardewModdingAPI.Events.RenderingActiveMenuEventArgs e) { if (!MenuOverride) return; if (!Context.IsWorldReady) return; if (_openedNonCustomMenu) { return; } _openedNonCustomMenu = true; var activeMenu = Game1.activeClickableMenu; if (activeMenu == null) return; IClickableMenu instance; if (activeMenu is CraftingPage) instance = activeMenu; else if (activeMenu is GameMenu gameMenu) instance = gameMenu.pages[GameMenu.craftingTab]; else if (activeMenu.GetType() == CookingSkillMenu) instance = activeMenu; else return; OpenAndFixMenu(instance); }
/// <summary> /// Event handler to render the button to the screen before the rest of the SpriteBatch is drawn. /// </summary> /// <param name="sender">The object from which the event originated.</param> /// <param name="e">These are the arguments sent along with the event from SMAPI, used to access the SpriteBatch.</param> private void Display_RenderingActiveMenu(object sender, StardewModdingAPI.Events.RenderingActiveMenuEventArgs e) { GameMenu menu = Game1.activeClickableMenu as GameMenu; if (menu != null && menu.currentTab == 0) { organiseButton.draw(e.SpriteBatch, Color.White, (float)(0.860000014305115 + (double)organiseButton.bounds.Y / 20000.0)); } }
private static void Display_RenderingActiveMenu(object sender, StardewModdingAPI.Events.RenderingActiveMenuEventArgs e) { if (Helper.Input.IsDown(SButton.MouseLeft) && ModEntry.screenRect.Contains(Game1.getMousePosition())) { int dy = Game1.getMouseY() - lastMousePositionY; if (Math.Abs(dy) > 0) { dragging = true; } if (dragging) { yOffset = (int)Math.Max(Math.Min(0, yOffset + dy), -1 * Math.Max(0, listHeight - ModEntry.GetScreenSize().Y)); } } lastMousePositionY = Game1.getMouseY(); if (!ModEntry.appRunning || !ModEntry.phoneOpen || !(Game1.activeClickableMenu is PhoneBookMenu)) { ModEntry.appRunning = false; ModEntry.phoneAppRunning = false; Helper.Events.Display.RenderingActiveMenu -= Display_RenderingActiveMenu; Helper.Events.Input.ButtonPressed -= Input_ButtonPressed; Helper.Events.Input.ButtonReleased -= Input_ButtonReleased; return; } e.SpriteBatch.Draw(ModEntry.phoneBookTexture, ModEntry.screenPosition, Color.White); if (yOffset < 0) { e.SpriteBatch.Draw(ModEntry.upArrowTexture, ModEntry.upArrowPosition, Color.White); } if (yOffset > ModEntry.GetScreenSize().Y - listHeight) { e.SpriteBatch.Draw(ModEntry.downArrowTexture, ModEntry.downArrowPosition, Color.White); } int screenBottom = (int)(ModEntry.screenPosition.Y + ModEntry.GetScreenSize().Y); for (int i = 0; i < callableList.Count; i++) { Vector2 npcPos = GetNPCPos(i); Rectangle r = callableList[i].sourceRect; if (npcPos.Y < ModEntry.screenPosition.Y - r.Height * 2 || npcPos.Y >= screenBottom) { continue; } Rectangle sourceRect = r; int cutTop = 0; int cutBottom = 0; if (npcPos.Y < ModEntry.screenPosition.Y) { cutTop = (int)Math.Round((ModEntry.screenPosition.Y - (int)npcPos.Y) / 2f); sourceRect = new Rectangle(r.X, r.Y + cutTop, r.Width, r.Height - cutTop); npcPos = new Vector2(npcPos.X, ModEntry.screenPosition.Y); } else if (npcPos.Y > screenBottom - r.Height * 2) { cutBottom = (int)Math.Round((screenBottom - r.Height * 2 - (int)npcPos.Y) / 2f); sourceRect = new Rectangle(r.X, r.Y, r.Width, r.Height + cutBottom); } e.SpriteBatch.Draw(callableList[i].portrait, npcPos + new Vector2((Config.ContactWidth - 32) / 2, 0), sourceRect, Color.White, 0, Vector2.Zero, 2, SpriteEffects.None, 0.86f); if (Config.ShowNamesInPhoneBook && npcPos.Y < screenBottom - Config.ContactHeight - callableList[i].nameSize.Y * 0.4f + 6) { e.SpriteBatch.DrawString(Game1.dialogueFont, callableList[i].name, GetNPCPos(i) + new Vector2(Config.ContactWidth / 2 - callableList[i].nameSize.X * 0.2f, Config.ContactHeight - 6), Color.Black, 0, Vector2.Zero, 0.4f, SpriteEffects.None, 0.86f); } } }