public static Texture2D MakeBackground() { Vector2 screenSize = ModEntry.GetScreenSize(); Texture2D phoneBook = new Texture2D(Game1.graphics.GraphicsDevice, (int)screenSize.X, (int)screenSize.Y); Color[] data = new Color[phoneBook.Width * phoneBook.Height]; for (int pixel = 0; pixel < data.Length; pixel++) { data[pixel] = Config.PhoneBookBackgroundColor; } phoneBook.SetData(data); return(phoneBook); }
public Vector2 GetScreenSize(bool rotated) { return(ModEntry.GetScreenSize(rotated)); }
public Vector2 GetScreenSize() { return(ModEntry.GetScreenSize()); }
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); } } }