-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathHUDMessage.cs
178 lines (166 loc) · 8.21 KB
/
HUDMessage.cs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// Decompiled with JetBrains decompiler
// Type: StardewValley.HUDMessage
// Assembly: Stardew Valley, Version=1.2.6400.27469, Culture=neutral, PublicKeyToken=null
// MVID: 77B7094A-F6F0-4ACC-91F4-E335E2733EDB
// Assembly location: D:\SteamLibrary\steamapps\common\Stardew Valley\Stardew Valley.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewValley.Menus;
using System;
namespace StardewValley
{
public class HUDMessage
{
public float transparency = 1f;
public int number = -1;
public const float defaultTime = 3500f;
public const int achievement_type = 1;
public const int newQuest_type = 2;
public const int error_type = 3;
public const int stamina_type = 4;
public const int health_type = 5;
public string message;
public string type;
public Color color;
public float timeLeft;
public int whatType;
public bool add;
public bool achievement;
public bool fadeIn;
public bool noIcon;
private Item messageSubject;
public string Message
{
get
{
if (this.type == null)
return this.message;
if (this.type.Equals("Money"))
return (this.add ? (object) "+ " : (object) "- ").ToString() + (object) this.number + "g";
return (this.add ? "+ " : "- ") + (object) this.number + " " + this.type;
}
set
{
this.message = value;
}
}
public HUDMessage(string message)
{
this.message = message;
this.color = Color.SeaGreen;
this.timeLeft = 3500f;
}
public HUDMessage(string message, bool achievement)
{
if (!achievement)
return;
this.message = Game1.content.LoadString("Strings\\StringsFromCSFiles:HUDMessage.cs.3824") + message;
this.color = Color.OrangeRed;
this.timeLeft = 5250f;
this.achievement = true;
this.whatType = 1;
}
public HUDMessage(string message, int whatType)
{
this.message = message;
this.color = Color.OrangeRed;
this.timeLeft = 5250f;
this.achievement = true;
this.whatType = whatType;
}
public HUDMessage(string type, int number, bool add, Color color, Item messageSubject = null)
{
this.type = type;
this.add = add;
this.color = color;
this.timeLeft = 3500f;
this.number = number;
this.messageSubject = messageSubject;
}
public HUDMessage(string message, Color color, float timeLeft)
: this(message, color, timeLeft, false)
{
}
public HUDMessage(string message, string leaveMeNull)
{
this.message = Game1.parseText(message, Game1.dialogueFont, Game1.tileSize * 6);
this.timeLeft = 3500f;
this.color = Game1.textColor;
this.noIcon = true;
}
public HUDMessage(string message, Color color, float timeLeft, bool fadeIn)
{
this.message = message;
this.color = color;
this.timeLeft = timeLeft;
this.fadeIn = fadeIn;
if (!fadeIn)
return;
this.transparency = 0.0f;
}
public bool update(GameTime time)
{
this.timeLeft = this.timeLeft - (float) time.ElapsedGameTime.Milliseconds;
if ((double) this.timeLeft < 0.0)
{
this.transparency = this.transparency - 0.02f;
if ((double) this.transparency < 0.0)
return true;
}
else if (this.fadeIn)
this.transparency = Math.Min(this.transparency + 0.02f, 1f);
return false;
}
public void draw(SpriteBatch b, int i)
{
if (this.noIcon)
{
IClickableMenu.drawHoverText(b, this.message, Game1.dialogueFont, 0, 0, -1, (string) null, -1, (string[]) null, (Item) null, 0, -1, -1, Game1.tileSize / 4, (Game1.viewport.Width < 1400 ? -Game1.tileSize : 0) + Game1.graphics.GraphicsDevice.Viewport.Height - (i + 1) * Game1.tileSize * 7 / 4 - Game1.tileSize / 3 - (int) Game1.dialogueFont.MeasureString(this.message).Y, this.transparency, (CraftingRecipe) null);
}
else
{
Vector2 vector2 = new Vector2((float) (Game1.tileSize / 4), (float) (Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - (i + 1) * Game1.tileSize * 7 / 4 - Game1.tileSize));
if (Game1.isOutdoorMapSmallerThanViewport())
vector2.X = (float) Math.Max(Game1.tileSize / 4, -Game1.viewport.X + Game1.tileSize / 4);
if (Game1.viewport.Width < 1400)
vector2.Y -= (float) (Game1.tileSize * 3 / 4);
b.Draw(Game1.mouseCursors, vector2, new Rectangle?(this.messageSubject == null || !(this.messageSubject is Object) || (this.messageSubject as Object).sellToStorePrice() <= 500 ? new Rectangle(293, 360, 26, 24) : new Rectangle(163, 399, 26, 24)), Color.White * this.transparency, 0.0f, Vector2.Zero, (float) Game1.pixelZoom, SpriteEffects.None, 1f);
float x = Game1.smallFont.MeasureString(this.messageSubject == null || this.messageSubject.DisplayName == null ? (this.message == null ? "" : this.message) : this.messageSubject.DisplayName).X;
b.Draw(Game1.mouseCursors, new Vector2(vector2.X + (float) (26 * Game1.pixelZoom), vector2.Y), new Rectangle?(new Rectangle(319, 360, 1, 24)), Color.White * this.transparency, 0.0f, Vector2.Zero, new Vector2(x, (float) Game1.pixelZoom), SpriteEffects.None, 1f);
b.Draw(Game1.mouseCursors, new Vector2(vector2.X + (float) (26 * Game1.pixelZoom) + x, vector2.Y), new Rectangle?(new Rectangle(323, 360, 6, 24)), Color.White * this.transparency, 0.0f, Vector2.Zero, (float) Game1.pixelZoom, SpriteEffects.None, 1f);
vector2.X += (float) (Game1.pixelZoom * 4);
vector2.Y += (float) (Game1.pixelZoom * 4);
if (this.messageSubject == null)
{
switch (this.whatType)
{
case 1:
b.Draw(Game1.mouseCursors, vector2 + new Vector2(8f, 8f) * (float) Game1.pixelZoom, new Rectangle?(new Rectangle(294, 392, 16, 16)), Color.White * this.transparency, 0.0f, new Vector2(8f, 8f), (float) Game1.pixelZoom + Math.Max(0.0f, (float) (((double) this.timeLeft - 3000.0) / 900.0)), SpriteEffects.None, 1f);
break;
case 2:
b.Draw(Game1.mouseCursors, vector2 + new Vector2(8f, 8f) * (float) Game1.pixelZoom, new Rectangle?(new Rectangle(403, 496, 5, 14)), Color.White * this.transparency, 0.0f, new Vector2(3f, 7f), (float) Game1.pixelZoom + Math.Max(0.0f, (float) (((double) this.timeLeft - 3000.0) / 900.0)), SpriteEffects.None, 1f);
break;
case 3:
b.Draw(Game1.mouseCursors, vector2 + new Vector2(8f, 8f) * (float) Game1.pixelZoom, new Rectangle?(new Rectangle(268, 470, 16, 16)), Color.White * this.transparency, 0.0f, new Vector2(8f, 8f), (float) Game1.pixelZoom + Math.Max(0.0f, (float) (((double) this.timeLeft - 3000.0) / 900.0)), SpriteEffects.None, 1f);
break;
case 4:
b.Draw(Game1.mouseCursors, vector2 + new Vector2(8f, 8f) * (float) Game1.pixelZoom, new Rectangle?(new Rectangle(0, 411, 16, 16)), Color.White * this.transparency, 0.0f, new Vector2(8f, 8f), (float) Game1.pixelZoom + Math.Max(0.0f, (float) (((double) this.timeLeft - 3000.0) / 900.0)), SpriteEffects.None, 1f);
break;
case 5:
b.Draw(Game1.mouseCursors, vector2 + new Vector2(8f, 8f) * (float) Game1.pixelZoom, new Rectangle?(new Rectangle(16, 411, 16, 16)), Color.White * this.transparency, 0.0f, new Vector2(8f, 8f), (float) Game1.pixelZoom + Math.Max(0.0f, (float) (((double) this.timeLeft - 3000.0) / 900.0)), SpriteEffects.None, 1f);
break;
}
}
else
this.messageSubject.drawInMenu(b, vector2, 1f + Math.Max(0.0f, (float) (((double) this.timeLeft - 3000.0) / 900.0)), this.transparency, 1f, false);
vector2.X += (float) (Game1.tileSize * 4 / 5);
vector2.Y += (float) (Game1.tileSize * 4 / 5);
if (this.number > 1)
Utility.drawTinyDigits(this.number, b, vector2, 3f, 1f, Color.White * this.transparency);
vector2.X += (float) (Game1.tileSize / 2);
vector2.Y -= (float) (Game1.tileSize * 2 / 5 + Game1.pixelZoom * 2);
Utility.drawTextWithShadow(b, this.messageSubject == null ? this.message : this.messageSubject.DisplayName, Game1.smallFont, vector2, Game1.textColor * this.transparency, 1f, 1f, -1, -1, this.transparency, 3);
}
}
}
}