forked from gardenappl/WMITF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWMITFModSystem.cs
More file actions
47 lines (44 loc) · 1.76 KB
/
WMITFModSystem.cs
File metadata and controls
47 lines (44 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.UI;
using Terraria.UI.Chat;
using Terraria.ID;
using Terraria.ModLoader;
namespace WMITF
{
class WMITFModSystem : ModSystem
{
static public string MouseText;
static public bool SecondLine;
//Setup for drawing in world tooltips
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
{
int index = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));
if (index != -1)
{
//Thank you jopojelly! (taken from https://github.com/JavidPack/SummonersAssociation)
layers.Insert(index, new LegacyGameInterfaceLayer("WMITF: Mouse Text", delegate
{
if (ModContent.GetInstance<Config>().DisplayWorldTooltips && !String.IsNullOrEmpty(MouseText))
{
string coloredString = String.Format("[c/{1}:[{0}][c/{1}:]]", MouseText, Colors.RarityBlue.Hex3());
var text = ChatManager.ParseMessage(coloredString, Color.White).ToArray();
//float x = Main.fontMouseText.MeasureString(MouseText).X;
float x = ChatManager.GetStringSize(Terraria.GameContent.FontAssets.MouseText.Value, text, Vector2.One).X;
var pos = Main.MouseScreen + new Vector2(16f, 16f);
if (pos.Y > (float)(Main.screenHeight - 30))
pos.Y = (float)(Main.screenHeight - 30);
if (pos.X > (float)(Main.screenWidth - x))
pos.X = (float)(Main.screenWidth - x);
if (SecondLine)
pos.Y += Terraria.GameContent.FontAssets.MouseText.Value.LineSpacing;
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Terraria.GameContent.FontAssets.MouseText.Value, text, pos, 0f, Vector2.Zero, Vector2.One, out int hoveredSnippet);
}
return true;
}, InterfaceScaleType.UI));
}
}
}
}