Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TitleLinkButton.cs
Go to the documentation of this file.
1using System;
5using ReLogic.OS;
9
11
12public class TitleLinkButton
13{
14 private static Item _fakeItem = new Item();
15
16 public string TooltipTextKey;
17
18 public string LinkUrl;
19
21
23
25
26 public void Draw(SpriteBatch spriteBatch, Vector2 anchorPosition)
27 {
28 Rectangle r = Image.Frame();
29 if (FrameWhenNotSelected.HasValue)
30 {
31 r = FrameWhenNotSelected.Value;
32 }
33 Vector2 vector = r.Size();
34 Vector2 vector2 = anchorPosition - vector / 2f;
35 bool flag = false;
36 if (Main.MouseScreen.Between(vector2, vector2 + vector))
37 {
38 Main.LocalPlayer.mouseInterface = true;
39 flag = true;
42 }
43 Rectangle? rectangle = (flag ? FrameWehnSelected : FrameWhenNotSelected);
44 Rectangle rectangle2 = Image.Frame();
45 if (rectangle.HasValue)
46 {
47 rectangle2 = rectangle.Value;
48 }
50 spriteBatch.Draw(value, anchorPosition, rectangle2, Color.White, 0f, rectangle2.Size() / 2f, 1f, SpriteEffects.None, 0f);
51 }
52
53 private void DrawTooltip()
54 {
55 Item fakeItem = _fakeItem;
56 fakeItem.SetDefaults(0, noMatCheck: true);
57 string textValue = Language.GetTextValue(TooltipTextKey);
58 fakeItem.SetNameOverride(textValue);
59 fakeItem.type = 1;
60 fakeItem.scale = 0f;
61 fakeItem.rare = 8;
62 fakeItem.value = -1;
63 Main.HoverItem = _fakeItem;
64 Main.instance.MouseText("", 0, 0);
65 Main.mouseText = true;
66 }
67
68 private void TryClicking()
69 {
71 {
73 Main.mouseLeftRelease = false;
74 OpenLink();
75 }
76 }
77
78 private void OpenLink()
79 {
80 try
81 {
82 Platform.Get<IPathService>().OpenURL(LinkUrl);
83 }
84 catch
85 {
86 Console.WriteLine("Failed to open link?!");
87 }
88 }
89}
void Draw(Texture2D texture, Vector2 position, Color color)
static void WriteLine()
Definition Console.cs:733
static void PlaySound(int type, Vector2 position, int style=1)
void Draw(SpriteBatch spriteBatch, Vector2 anchorPosition)
void SetDefaults(int Type=0)
Definition Item.cs:47332
void SetNameOverride(string name)
Definition Item.cs:49944
static string GetTextValue(string key)
Definition Language.cs:15
static bool mouseLeftRelease
Definition Main.cs:1755
static Main instance
Definition Main.cs:283
static Vector2 MouseScreen
Definition Main.cs:2773
static bool mouseLeft
Definition Main.cs:614