Skip to content

Commit 8d1b62e

Browse files
committed
Adjust tooltip size
1 parent 63c68c9 commit 8d1b62e

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

Diff for: .idea/.idea.DPS Stat/.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: DPS Stat/ModEntry.cs

+23-26
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text;
1+
using System.Reflection.Emit;
2+
using System.Text;
23
using HarmonyLib;
34
using Microsoft.Xna.Framework;
45
using Microsoft.Xna.Framework.Graphics;
@@ -9,45 +10,41 @@
910

1011
namespace DPS_Stat
1112
{
12-
public class ModEntry : Mod
13-
{
13+
public class ModEntry : Mod {
1414
private Harmony harmony;
1515
public static IMonitor StaticMonitor;
1616

1717
public override void Entry(IModHelper helper) {
1818
// Initialize Harmony and apply patches
19+
StaticMonitor = Monitor;
1920
harmony = new Harmony(ModManifest.UniqueID);
2021
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))
2324
);
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+
2531

2632
Monitor.Log("DPS Stat loaded with Harmony patch.", LogLevel.Info);
2733
helper.Events.GameLoop.ReturnedToTitle += OnReturnedToTitle;
2834
}
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-
}
4535

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+
}
4841

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);
5148
}
5249

5350
private void OnReturnedToTitle(object sender, EventArgs e) {

Diff for: DPS Stat/bin/Debug/net6.0/DPS Stat 1.0.0.zip

130 Bytes
Binary file not shown.

Diff for: DPS Stat/bin/Debug/net6.0/DPS Stat.dll

0 Bytes
Binary file not shown.

Diff for: DPS Stat/obj/Debug/net6.0/DPS Stat.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)