|
1 |
| -using System.Text; |
| 1 | +using System.Reflection.Emit; |
| 2 | +using System.Text; |
2 | 3 | using HarmonyLib;
|
3 | 4 | using Microsoft.Xna.Framework;
|
4 | 5 | using Microsoft.Xna.Framework.Graphics;
|
|
9 | 10 |
|
10 | 11 | namespace DPS_Stat
|
11 | 12 | {
|
12 |
| - public class ModEntry : Mod |
13 |
| - { |
| 13 | + public class ModEntry : Mod { |
14 | 14 | private Harmony harmony;
|
15 | 15 | public static IMonitor StaticMonitor;
|
16 | 16 |
|
17 | 17 | public override void Entry(IModHelper helper) {
|
18 | 18 | // Initialize Harmony and apply patches
|
| 19 | + StaticMonitor = Monitor; |
19 | 20 | harmony = new Harmony(ModManifest.UniqueID);
|
20 | 21 | harmony.Patch(
|
21 |
| - original: AccessTools.Method(typeof(IClickableMenu), nameof(IClickableMenu.drawHoverText), new[] {typeof(SpriteBatch), typeof(StringBuilder), typeof(SpriteFont), typeof(int), typeof(int), typeof(int), typeof(string), typeof(int), typeof(string[]), typeof(Item), typeof(int), typeof(string), typeof(int), typeof(int), typeof(int), typeof(float), typeof(CraftingRecipe), typeof(IList<Item>), typeof(Texture2D), typeof(Rectangle), typeof(Color), typeof(Color), typeof(float), typeof(int), typeof(int)}), |
22 |
| - prefix: new HarmonyMethod(typeof(ModEntry), nameof(ModifyItemDescription)) |
| 22 | + original: AccessTools.Method(typeof(MeleeWeapon), nameof(MeleeWeapon.drawTooltip)), |
| 23 | + postfix: new HarmonyMethod(typeof(ModEntry), nameof(ModifyItemDescription)) |
23 | 24 | );
|
24 |
| - StaticMonitor = Monitor; |
| 25 | + harmony.Patch( |
| 26 | + original: AccessTools.Method(typeof(MeleeWeapon), |
| 27 | + nameof(MeleeWeapon.getExtraSpaceNeededForTooltipSpecialIcons)), |
| 28 | + postfix: new HarmonyMethod(typeof(ModEntry), nameof(ModifyTooltipHeight)) |
| 29 | + ); |
| 30 | + |
25 | 31 |
|
26 | 32 | Monitor.Log("DPS Stat loaded with Harmony patch.", LogLevel.Info);
|
27 | 33 | helper.Events.GameLoop.ReturnedToTitle += OnReturnedToTitle;
|
28 | 34 | }
|
29 |
| - |
30 |
| - [HarmonyPrefix] |
31 |
| - private static void ModifyItemDescription(MeleeWeapon __instance, ref string[] __8, ref Item __9) { |
32 |
| - if (__9 == null || __9 is not MeleeWeapon) { |
33 |
| - return; |
34 |
| - } |
35 |
| - string[] altered; |
36 |
| - if (__8 != null) { |
37 |
| - altered = new string[__8.Length + 1]; |
38 |
| - for (int i = 0; i < __8.Length; i++) { |
39 |
| - altered[i] = __8[i]; |
40 |
| - } |
41 |
| - } |
42 |
| - else { |
43 |
| - altered = new string[1]; |
44 |
| - } |
45 | 35 |
|
46 |
| - altered[altered.Length - 1] = "1"; |
47 |
| - __8 = altered; |
| 36 | + [HarmonyPostfix] |
| 37 | + private static void ModifyTooltipHeight(MeleeWeapon __instance, ref Point __result) { |
| 38 | + StaticMonitor.Log("Modifying tooltip height...", LogLevel.Info); |
| 39 | + __result.Y += 48; |
| 40 | + } |
48 | 41 |
|
49 |
| - |
50 |
| - StaticMonitor.Log("Modified buffs array", LogLevel.Info); |
| 42 | + [HarmonyPostfix] |
| 43 | + private static void ModifyItemDescription(MeleeWeapon __instance, SpriteBatch __0, ref int __1, ref int __2, SpriteFont __3, float __4, StringBuilder __5) { |
| 44 | + Utility.drawWithShadow(__0, Game1.mouseCursors2, new Vector2(__1 + 16 + 4, __2 + 16 + 4), new Rectangle(127, 35, 10, 10), Color.White, 0f, Vector2.Zero, 4f, flipped: false, 1f); |
| 45 | + Utility.drawTextWithShadow(__0, "Hello", __3, new Vector2(__1 + 16 + 52, __2 + 16 + 52), Color.White); |
| 46 | + __2 += (int)Math.Max(__3.MeasureString("TT").Y, 48f); |
| 47 | + //StaticMonitor.Log("Modified tooltip", LogLevel.Info); |
51 | 48 | }
|
52 | 49 |
|
53 | 50 | private void OnReturnedToTitle(object sender, EventArgs e) {
|
|
0 commit comments