public bool Draw(ref SpriteBatch __instance, ref Texture2D texture, ref Vector4 destination, ref bool scaleDestination, ref Rectangle?sourceRectangle, ref Color color, ref float rotation, ref Vector2 origin, ref SpriteEffects effects, ref float depth) { if (TextureLoader.activeFolder <= 0 || !(Game1.activeClickableMenu is ShopMenu || Game1.activeClickableMenu is DialogueBox) || texture.Width != 128) { return(true); } NPC npc = getNPCForTexture(texture); if (npc == null) { return(true); } Texture2D newTexture = TextureLoader.getPortrait(npc.name); if (newTexture == null) { return(true); } texture = newTexture; sourceRectangle = new Rectangle?(TextureLoader.getSoureRectangle(texture)); destination.W = 64 * Game1.pixelZoom; destination.Z = 64 * Game1.pixelZoom; scaleDestination = false; PortraitureMod.activeTexure = texture; return(true); }
private void drawShopkeeper(SpriteBatch b, NPC c) { Texture2D texture = TextureLoader.getPortrait(c.name); int textureSize = Math.Max(texture.Width / 2, 64); b.Draw(texture, new Rectangle((activeShop.xPositionOnScreen - 80 * Game1.pixelZoom + Game1.pixelZoom * 5), (activeShop.yPositionOnScreen + Game1.pixelZoom * 5), 64 * Game1.pixelZoom, 64 * Game1.pixelZoom), new Rectangle?(new Rectangle(0, 0, textureSize, textureSize)), Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.92f); }
internal static bool Prefix(DialogueBox __instance, SpriteBatch b) { Dialogue characterDialogue = PortraitureMod.helper.Reflection.GetField <Dialogue>(__instance, "characterDialogue").GetValue(); ScaledTexture2D texture = TextureLoader.getPortrait(characterDialogue.speaker.Name); characterDialogue.speaker.Portrait = texture; return(true); }
internal static void Postfix(ShopMenu __instance, SpriteBatch b) { if (__instance.portraitPerson == null || !(Game1.viewport.Width > 800 && Game1.options.showMerchantPortraits)) { return; } ScaledTexture2D texture = TextureLoader.getPortrait(__instance.portraitPerson.Name); __instance.portraitPerson.Portrait = texture; return; }
internal static bool Prefix(DialogueBox __instance, SpriteBatch b) { if (__instance.width < 642) { return(false); } int x = PortraitureMod.helper.Reflection.GetField <int>(__instance, "x").GetValue(); int y = PortraitureMod.helper.Reflection.GetField <int>(__instance, "y").GetValue(); Dialogue characterDialogue = PortraitureMod.helper.Reflection.GetField <Dialogue>(__instance, "characterDialogue").GetValue(); Rectangle friendshipJewel = PortraitureMod.helper.Reflection.GetField <Rectangle>(__instance, "friendshipJewel").GetValue(); Texture2D texture = TextureLoader.getPortrait(characterDialogue.speaker.Name); if (texture == null) { texture = characterDialogue.speaker.Portrait; } Rectangle rectangle = TextureLoader.getSoureRectangle(texture, characterDialogue.getPortraitIndex()); int num1 = x + __instance.width - 448 + 4; int num2 = x + __instance.width - num1; b.Draw(Game1.mouseCursors, new Rectangle(num1 - 40, y, 36, __instance.height), new Rectangle?(new Rectangle(278, 324, 9, 1)), Color.White); b.Draw(Game1.mouseCursors, new Vector2((float)(num1 - 40), (float)(y - 20)), new Rectangle?(new Rectangle(278, 313, 10, 7)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f); b.Draw(Game1.mouseCursors, new Vector2((float)(num1 - 40), (float)(y + __instance.height)), new Rectangle?(new Rectangle(278, 328, 10, 8)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f); int num3 = num1 + 76; int num4 = y + __instance.height / 2 - 148 - 36; b.Draw(Game1.mouseCursors, new Vector2((float)(num1 - 8), (float)y), new Rectangle?(new Rectangle(583, 411, 115, 97)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f); if (!texture.Bounds.Contains(rectangle)) { rectangle = TextureLoader.getSoureRectangle(texture, 0); } int num5 = shouldPortraitShake(characterDialogue, __instance) ? Game1.random.Next(-1, 2) : 0; b.Draw(texture, new Rectangle(num3 + 16 + num5, num4 + 24, 64 * Game1.pixelZoom, 64 * Game1.pixelZoom), new Rectangle?(rectangle), Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.88f); SpriteText.drawStringHorizontallyCenteredAt(b, characterDialogue.speaker.getName(), num1 + num2 / 2, num4 + 296 + 16, 999999, -1, 999999, 1f, 0.88f, false, -1); if (Game1.eventUp || friendshipJewel.Equals(Rectangle.Empty) || (characterDialogue == null || characterDialogue.speaker == null) || !Game1.player.friendshipData.ContainsKey(characterDialogue.speaker.Name)) { return(false); } b.Draw(Game1.mouseCursors, new Vector2((float)friendshipJewel.X, (float)friendshipJewel.Y), new Rectangle?(Game1.player.getFriendshipHeartLevelForNPC(characterDialogue.speaker.Name) >= 10 ? new Rectangle(269, 494, 11, 11) : new Rectangle(Math.Max(140, 140 + (int)(Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 1000.0 / 250.0) * 11), Math.Max(532, 532 + Game1.player.getFriendshipHeartLevelForNPC(characterDialogue.speaker.Name) / 2 * 11), 11, 11)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f); return(false); }
internal static void Postfix(ShopMenu __instance, SpriteBatch b) { if (__instance.portraitPerson == null || !(Game1.viewport.Width > 800 && Game1.options.showMerchantPortraits)) { return; } Texture2D texture = TextureLoader.getPortrait(__instance.portraitPerson.name); if (texture == null) { texture = __instance.portraitPerson.Portrait; } Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(__instance.xPositionOnScreen - 80 * Game1.pixelZoom), (float)__instance.yPositionOnScreen), new Rectangle(603, 414, 74, 74), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, false, 0.91f, -1, -1, 0.35f); Rectangle rectangle = TextureLoader.getSoureRectangle(texture); b.Draw(texture, new Rectangle(__instance.xPositionOnScreen - 80 * Game1.pixelZoom + Game1.pixelZoom * 5, __instance.yPositionOnScreen + Game1.pixelZoom * 5, 64 * Game1.pixelZoom, 64 * Game1.pixelZoom), new Rectangle?(rectangle), Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.92f); IClickableMenu.drawHoverText(b, __instance.potraitPersonDialogue, Game1.dialogueFont, 0, 0, -1, (string)null, -1, (string[])null, (Item)null, 0, -1, -1, __instance.xPositionOnScreen - (int)Game1.dialogueFont.MeasureString(__instance.potraitPersonDialogue).X - Game1.tileSize, __instance.yPositionOnScreen + (__instance.portraitPerson != null ? 78 * Game1.pixelZoom : 0), 1f, (CraftingRecipe)null); __instance.drawMouse(b); }
private void drawPortraiture(SpriteBatch b, DialogueBox d, NPC cs) { if (d.width < 107 * Game1.pixelZoom * 3 / 2 || Helper.Reflection.GetPrivateValue <bool>(d, "transitioning") || Helper.Reflection.GetPrivateValue <bool>(d, "isQuestion")) { return; } Texture2D texture = TextureLoader.getPortrait(cs.name); Dialogue characterDialogue = Helper.Reflection.GetPrivateValue <Dialogue>(d, "characterDialogue"); int textureSize = Math.Max(texture.Width / 2, 64); int x = Helper.Reflection.GetPrivateValue <int>(d, "x"); int y = Helper.Reflection.GetPrivateValue <int>(d, "y"); int num1 = x + d.width - 112 * Game1.pixelZoom + Game1.pixelZoom; int num2 = x + d.width - num1; int num3 = num1 + Game1.pixelZoom * 19; int num4 = y + d.height / 2 - 74 * Game1.pixelZoom / 2 - 18 * Game1.pixelZoom / 2; int num5 = Helper.Reflection.GetPrivateMethod(d, "shouldPortraitShake").Invoke <bool>(new object[] { characterDialogue }) ? Game1.random.Next(-1, 2) : 0; Rectangle rectangle = Game1.getSourceRectForStandardTileSheet(texture, characterDialogue.getPortraitIndex(), textureSize, textureSize); if (!texture.Bounds.Contains(rectangle)) { rectangle = new Rectangle(0, 0, textureSize, textureSize); } b.Draw(texture, new Rectangle(num3 + 4 * Game1.pixelZoom + num5, num4 + 6 * Game1.pixelZoom, 64 * Game1.pixelZoom, 64 * Game1.pixelZoom), new Rectangle?(rectangle), Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.88f); if (!Game1.options.hardwareCursor) { d.drawMouse(b); } drawFolderName(b, textureSize, x, y); }
internal static bool Prefix(NPC __instance, ref Texture2D __result) { __result = TextureLoader.getPortrait(__instance.Name); return(__result == null); }