Client LuaCsForBarotrauma
CreditsPlayer.cs
1
using
Microsoft.Xna.Framework;
2
3
namespace
Barotrauma
4
{
5
class
CreditsPlayer
:
GUIComponent
6
{
7
private
GUIListBox
listBox;
8
9
private
readonly
ContentXElement
configElement;
10
11
private
float
scrollSpeed;
12
13
public
bool
AutoRestart
=
true
;
14
15
public
bool
Finished
16
{
17
get
{
return
listBox.
BarScroll
>= 1.0f; }
18
}
19
20
public
bool
ScrollBarEnabled
21
{
22
get
{
return
listBox.
ScrollBarEnabled
; }
23
set
{ listBox.
ScrollBarEnabled
= value; }
24
}
25
26
public
bool
AllowMouseWheelScroll
27
{
28
get
{
return
listBox.
AllowMouseWheelScroll
; }
29
set
{ listBox.
AllowMouseWheelScroll
= value; }
30
}
31
32
public
float
Scroll
33
{
34
get
{
return
listBox.
BarScroll
; }
35
set
{ listBox.
BarScroll
= value; }
36
}
37
38
public
readonly
GUIButton
CloseButton
;
39
40
41
public
CreditsPlayer
(
RectTransform
rectT,
string
configFile) : base(null, rectT)
42
{
43
GameMain
.
Instance
.
ResolutionChanged
+= () =>
44
{
45
ClearChildren
();
46
Load();
47
};
48
49
var doc = XMLExtensions.TryLoadXml(configFile);
50
if
(doc ==
null
) {
return
; }
51
configElement = doc.Root.FromPackage(ContentPackageManager.VanillaCorePackage);
52
53
Load();
54
55
CloseButton
=
new
GUIButton
(
new
RectTransform
(
new
Vector2(0.1f),
RectTransform
,
Anchor
.BottomRight, maxSize:
new
Point(GUI.IntScale(300), GUI.IntScale(50)))
56
{ AbsoluteOffset = new Point(GUI.IntScale(20), GUI.IntScale(20) + (Rect.Bottom - GameMain.GraphicsHeight)) },
57
TextManager.Get(
"close"
));
58
}
59
60
private
void
Load()
61
{
62
scrollSpeed = configElement.GetAttributeFloat(
"scrollspeed"
, 100.0f);
63
int
spacing = configElement.GetAttributeInt(
"spacing"
, 0);
64
65
listBox =
new
GUIListBox
(
new
RectTransform
(Vector2.One,
RectTransform
), style:
null
)
66
{
67
Spacing = spacing
68
};
69
70
foreach
(var subElement
in
configElement.Elements())
71
{
72
FromXML
(subElement, listBox.
Content
.
RectTransform
);
73
}
74
foreach
(
GUIComponent
child
in
listBox.
Content
.
Children
)
75
{
76
child.CanBeFocused =
false
;
77
}
78
79
listBox.
RecalculateChildren
();
80
listBox.
UpdateScrollBarSize
();
81
}
82
83
public
void
Restart
()
84
{
85
listBox.
BarScroll
= 0.0f;
86
}
87
88
protected
override
void
Update
(
float
deltaTime)
89
{
90
if
(!
Visible
) {
return
; }
91
92
listBox.
BarScroll
+= scrollSpeed / listBox.
TotalSize
* deltaTime;
93
94
if
(
AutoRestart
&& listBox.
BarScroll
>= 1.0f)
95
{
96
listBox.
BarScroll
= 0.0f;
97
}
98
}
99
}
100
}
Barotrauma.ContentXElement
Definition:
ContentXElement.cs:13
Barotrauma.CreditsPlayer
Definition:
CreditsPlayer.cs:6
Barotrauma.CreditsPlayer.CreditsPlayer
CreditsPlayer(RectTransform rectT, string configFile)
Definition:
CreditsPlayer.cs:41
Barotrauma.CreditsPlayer.AutoRestart
bool AutoRestart
Definition:
CreditsPlayer.cs:13
Barotrauma.CreditsPlayer.Update
override void Update(float deltaTime)
Definition:
CreditsPlayer.cs:88
Barotrauma.CreditsPlayer.AllowMouseWheelScroll
bool AllowMouseWheelScroll
Definition:
CreditsPlayer.cs:27
Barotrauma.CreditsPlayer.CloseButton
readonly GUIButton CloseButton
Definition:
CreditsPlayer.cs:38
Barotrauma.CreditsPlayer.ScrollBarEnabled
bool ScrollBarEnabled
Definition:
CreditsPlayer.cs:21
Barotrauma.CreditsPlayer.Restart
void Restart()
Definition:
CreditsPlayer.cs:83
Barotrauma.CreditsPlayer.Scroll
float Scroll
Definition:
CreditsPlayer.cs:33
Barotrauma.CreditsPlayer.Finished
bool Finished
Definition:
CreditsPlayer.cs:16
Barotrauma.GUIButton
Definition:
GUIButton.cs:9
Barotrauma.GUIComponent
Definition:
GUIComponent.cs:18
Barotrauma.GUIComponent.FromXML
static GUIComponent FromXML(ContentXElement element, RectTransform parent)
Definition:
GUIComponent.cs:1029
Barotrauma.GUIComponent.GUIComponent
GUIComponent(string style, RectTransform rectT)
This is the new constructor.
Definition:
GUIComponent.cs:406
Barotrauma.GUIComponent.ClearChildren
virtual void ClearChildren()
Definition:
GUIComponent.cs:134
Barotrauma.GUIComponent.Visible
bool Visible
Definition:
GUIComponent.cs:231
Barotrauma.GUIComponent.RectTransform
RectTransform RectTransform
Definition:
GUIComponent.cs:390
Barotrauma.GUIComponent.Children
IEnumerable< GUIComponent > Children
Definition:
GUIComponent.cs:29
Barotrauma.GUIListBox
Definition:
GUIListBox.cs:13
Barotrauma.GUIListBox.RecalculateChildren
void RecalculateChildren()
Definition:
GUIListBox.cs:890
Barotrauma.GUIListBox.ScrollBarEnabled
bool ScrollBarEnabled
Disables the scroll bar without hiding it.
Definition:
GUIListBox.cs:222
Barotrauma.GUIListBox.TotalSize
float TotalSize
Definition:
GUIListBox.cs:199
Barotrauma.GUIListBox.AllowMouseWheelScroll
bool AllowMouseWheelScroll
Definition:
GUIListBox.cs:92
Barotrauma.GUIListBox.Content
GUIFrame Content
A frame that contains the contents of the listbox. The frame itself is not rendered.
Definition:
GUIListBox.cs:42
Barotrauma.GUIListBox.UpdateScrollBarSize
void UpdateScrollBarSize()
Definition:
GUIListBox.cs:1196
Barotrauma.GUIListBox.BarScroll
float BarScroll
Definition:
GUIListBox.cs:188
Barotrauma.GameMain
Definition:
GameMain.cs:25
Barotrauma.GameMain.ResolutionChanged
Action ResolutionChanged
NOTE: Use very carefully. You need to ensure that you ALWAYS unsubscribe from this when you no longer...
Definition:
GameMain.cs:133
Barotrauma.GameMain.Instance
static GameMain Instance
Definition:
GameMain.cs:144
Barotrauma.RectTransform
Definition:
RectTransform.cs:32
Barotrauma
Definition:
AchievementManager.cs:12
Barotrauma.Anchor
Anchor
Definition:
RectTransform.cs:11
Barotrauma
BarotraumaClient
ClientSource
Screens
CreditsPlayer.cs
Generated by
1.9.1