Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
InGameNotificationsTracker.cs
Go to the documentation of this file.
1
using
System.Collections.Generic
;
2
using
Microsoft.Xna.Framework
;
3
using
Microsoft.Xna.Framework.Graphics
;
4
using
Terraria.Achievements
;
5
using
Terraria.GameInput
;
6
using
Terraria.Social
;
7
using
Terraria.Social.Base
;
8
9
namespace
Terraria.UI
;
10
11
public
class
InGameNotificationsTracker
12
{
13
private
static
List<IInGameNotification>
_notifications
=
new
List<IInGameNotification>
();
14
15
public
static
void
Initialize
()
16
{
17
Main.Achievements.OnAchievementCompleted +=
AddCompleted
;
18
SocialAPI.JoinRequests.OnRequestAdded +=
JoinRequests_OnRequestAdded
;
19
SocialAPI.JoinRequests.OnRequestRemoved +=
JoinRequests_OnRequestRemoved
;
20
}
21
22
private
static
void
JoinRequests_OnRequestAdded
(
UserJoinToServerRequest
request
)
23
{
24
AddJoinRequest
(
request
);
25
}
26
27
private
static
void
JoinRequests_OnRequestRemoved
(
UserJoinToServerRequest
request
)
28
{
29
for
(
int
num =
_notifications
.Count - 1; num >= 0; num--)
30
{
31
if
(
_notifications
[num].CreationObject ==
request
)
32
{
33
_notifications
.RemoveAt(num);
34
}
35
}
36
}
37
38
public
static
void
DrawInGame
(
SpriteBatch
sb)
39
{
40
float
num = Main.screenHeight - 40;
41
if
(
PlayerInput
.
UsingGamepad
)
42
{
43
num -= 25f;
44
}
45
Vector2
positionAnchorBottom
=
new
Vector2
(
Main
.
screenWidth
/ 2, num);
46
foreach
(
IInGameNotification
notification
in
_notifications
)
47
{
48
notification
.DrawInGame(sb,
positionAnchorBottom
);
49
notification
.PushAnchor(
ref
positionAnchorBottom
);
50
if
(
positionAnchorBottom
.Y < -100f)
51
{
52
break
;
53
}
54
}
55
}
56
57
public
static
void
DrawInIngameOptions
(
SpriteBatch
spriteBatch,
Rectangle
area
,
ref
int
gamepadPointIdLocalIndexToUse
)
58
{
59
int
num = 4;
60
int
num2
= area.Height / 5 - num;
61
Rectangle
area2
=
new
Rectangle
(
area
.X,
area
.Y,
area
.Width - 6,
num2
);
62
int
num3
= 0;
63
foreach
(
IInGameNotification
notification
in
_notifications
)
64
{
65
notification
.DrawInNotificationsArea(spriteBatch,
area2
,
ref
gamepadPointIdLocalIndexToUse
);
66
area2.Y +=
num2
+ num;
67
num3
++;
68
if
(
num3
>= 5)
69
{
70
break
;
71
}
72
}
73
}
74
75
public
static
void
AddCompleted
(
Achievement
achievement)
76
{
77
if
(
Main
.
netMode
!= 2)
78
{
79
_notifications
.Add(
new
InGamePopups
.
AchievementUnlockedPopup
(achievement));
80
}
81
}
82
83
public
static
void
AddJoinRequest
(
UserJoinToServerRequest
request
)
84
{
85
if
(
Main
.
netMode
!= 2)
86
{
87
_notifications
.Add(
new
InGamePopups
.
PlayerWantsToJoinGamePopup
(
request
));
88
}
89
}
90
91
public
static
void
Clear
()
92
{
93
_notifications
.Clear();
94
}
95
96
public
static
void
Update
()
97
{
98
for
(
int
i = 0; i <
_notifications
.Count; i++)
99
{
100
_notifications
[i].Update();
101
if
(
_notifications
[i].ShouldBeRemoved)
102
{
103
_notifications
.Remove(
_notifications
[i]);
104
i--;
105
}
106
}
107
}
108
}
Microsoft.Xna.Framework.Graphics.SpriteBatch
Definition
SpriteBatch.cs:8
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
Terraria.Achievements.Achievement
Definition
Achievement.cs:11
Terraria.GameInput.PlayerInput.UsingGamepad
static bool UsingGamepad
Definition
PlayerInput.cs:331
Terraria.GameInput.PlayerInput
Definition
PlayerInput.cs:18
Terraria.Main.netMode
static int netMode
Definition
Main.cs:2095
Terraria.Main.screenWidth
static int screenWidth
Definition
Main.cs:1719
Terraria.Main
Definition
Main.cs:79
Terraria.Social.Base.UserJoinToServerRequest
Definition
UserJoinToServerRequest.cs:6
Terraria.UI.InGameNotificationsTracker.AddCompleted
static void AddCompleted(Achievement achievement)
Definition
InGameNotificationsTracker.cs:75
Terraria.UI.InGameNotificationsTracker.Clear
static void Clear()
Definition
InGameNotificationsTracker.cs:91
Terraria.UI.InGameNotificationsTracker.Update
static void Update()
Definition
InGameNotificationsTracker.cs:96
Terraria.UI.InGameNotificationsTracker._notifications
static List< IInGameNotification > _notifications
Definition
InGameNotificationsTracker.cs:13
Terraria.UI.InGameNotificationsTracker.Initialize
static void Initialize()
Definition
InGameNotificationsTracker.cs:15
Terraria.UI.InGameNotificationsTracker.AddJoinRequest
static void AddJoinRequest(UserJoinToServerRequest request)
Definition
InGameNotificationsTracker.cs:83
Terraria.UI.InGameNotificationsTracker.JoinRequests_OnRequestRemoved
static void JoinRequests_OnRequestRemoved(UserJoinToServerRequest request)
Definition
InGameNotificationsTracker.cs:27
Terraria.UI.InGameNotificationsTracker.DrawInGame
static void DrawInGame(SpriteBatch sb)
Definition
InGameNotificationsTracker.cs:38
Terraria.UI.InGameNotificationsTracker.JoinRequests_OnRequestAdded
static void JoinRequests_OnRequestAdded(UserJoinToServerRequest request)
Definition
InGameNotificationsTracker.cs:22
Terraria.UI.InGameNotificationsTracker.DrawInIngameOptions
static void DrawInIngameOptions(SpriteBatch spriteBatch, Rectangle area, ref int gamepadPointIdLocalIndexToUse)
Definition
InGameNotificationsTracker.cs:57
Terraria.UI.InGameNotificationsTracker
Definition
InGameNotificationsTracker.cs:12
Terraria.UI.InGamePopups.AchievementUnlockedPopup
Definition
InGamePopups.cs:14
Terraria.UI.InGamePopups.PlayerWantsToJoinGamePopup
Definition
InGamePopups.cs:140
Terraria.UI.InGamePopups
Definition
InGamePopups.cs:12
Terraria.UI.IInGameNotification
Definition
IInGameNotification.cs:7
Microsoft.Xna.Framework.Graphics.SurfaceFormat.Vector2
@ Vector2
Microsoft.Xna.Framework.Graphics
Definition
AlphaTestEffect.cs:1
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
Terraria.Achievements
Definition
Achievement.cs:7
Terraria.GameInput
Definition
CursorMode.cs:1
Terraria.Social.Base
Definition
AchievementsSocialModule.cs:1
Terraria.Social
Definition
AchievementsSocialModule.cs:1
Terraria.UI
Definition
ChatLine.cs:3
Microsoft.Xna.Framework.Rectangle
Definition
Rectangle.cs:12
Microsoft.Xna.Framework.Vector2
Definition
Vector2.cs:12
source
Terraria.UI
InGameNotificationsTracker.cs
Generated by
1.10.0