Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_LoadingHintComponent.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
class
SCR_LoadingHintComponent
:
ScriptedWidgetComponent
3
{
4
protected
const
int
HINT_INDEX
= -1;
5
protected
const
float
SWITCH_TIME
= 10;
6
7
protected
int
m_iHintCount
;
8
protected
int
m_iHintIndex
= -1;
9
protected
float
m_fTime
;
10
protected
TextWidget
m_wText
;
11
protected
ResourceName
m_Config
=
"{CB10921F1096D4A0}Configs/UI/LoadingScreenHints.conf"
;
12
protected
ref array<string>
m_aAllHints
;
13
protected
ref array<string>
m_aReadHints
;
14
15
//------------------------------------------------------------------------------------------------
16
override
void
HandlerAttached
(
Widget
w)
17
{
18
m_wText
=
TextWidget
.Cast(w);
19
20
// Init arrays of all hints and read hints
21
BaseContainer
cont =
GetGame
().GetGameUserSettings().GetModule(
"SCR_LoadingHints"
);
22
if
(cont)
23
{
24
cont.Get(
"m_aReadHints"
,
m_aReadHints
);
25
if
(
m_aReadHints
)
26
m_iHintCount
=
m_aReadHints
.Count();
27
}
28
29
Resource
resource =
BaseContainerTools
.LoadContainer(
m_Config
);
30
31
if
(!resource)
32
return
;
33
34
BaseContainer
entries = resource.GetResource().ToBaseContainer();
35
36
if
(!entries)
37
return
;
38
39
entries.Get(
"m_aHints"
,
m_aAllHints
);
40
41
// Show first hint
42
ShowHint
(
HINT_INDEX
);
43
}
44
45
//------------------------------------------------------------------------------------------------
46
void
OnLoadingFinished
()
47
{
48
// Save hints to the settings module
49
UserSettings
settings =
GetGame
().GetGameUserSettings();
50
if
(!settings)
51
return
;
52
53
BaseContainer
cont = settings.GetModule(
"SCR_LoadingHints"
);
54
if
(!cont || !
m_aReadHints
||
m_aReadHints
.Count() ==
m_iHintCount
)
55
return
;
56
57
cont.Set(
"m_aReadHints"
,
m_aReadHints
);
58
GetGame
().UserSettingsChanged();
59
}
60
61
//------------------------------------------------------------------------------------------------
62
override
void
HandlerDeattached
(
Widget
w)
63
{
64
// Mark the current hint read if shown for infinite time
65
if
(
SWITCH_TIME
< 0)
66
MarkHintRead
();
67
}
68
69
//------------------------------------------------------------------------------------------------
70
void
Update
(
float
timeSlice)
71
{
72
m_fTime
+= timeSlice;
73
74
if
(
m_fTime
<
SWITCH_TIME
)
75
return
;
76
77
// Switch to a new hint
78
MarkHintRead
();
79
ShowHint
(
HINT_INDEX
);
80
m_fTime
= 0;
81
}
82
83
//------------------------------------------------------------------------------------------------
84
void
ShowHint
(
int
entryIndex = -1)
85
{
86
if
(!
m_wText
|| !
m_aAllHints
)
87
return
;
88
89
if
(!
m_aReadHints
)
90
m_aReadHints
= {};
91
92
string
hint;
93
if
(entryIndex == -1)
94
{
95
array<string> unread = {};
96
int
count =
GetUnreadHints
(unread);
97
if
(count == 0)
98
return
;
99
100
int
i =
Math
.RandomInt(0, count);
101
hint = unread[i];
102
m_iHintIndex
=
m_aAllHints
.Find(hint);
103
}
104
else
if
(entryIndex <
m_aAllHints
.Count())
105
{
106
hint =
m_aAllHints
[entryIndex];
107
}
108
109
m_wText
.SetTextFormat(hint);
110
}
111
112
//------------------------------------------------------------------------------------------------
113
void
MarkHintRead
()
114
{
115
if
(
m_iHintIndex < 0 || m_iHintIndex >
=
m_aAllHints
.Count())
116
return
;
117
118
m_aReadHints
.Insert(
m_aAllHints
[
m_iHintIndex
]);
119
m_iHintIndex
= -1;
120
}
121
122
// Get all hints which were not read yet
123
//------------------------------------------------------------------------------------------------
124
protected
int
GetUnreadHints
(array<string> hints)
125
{
126
hints.Clear();
127
128
foreach
(
string
hint :
m_aAllHints
)
129
{
130
if
(!
m_aReadHints
.Contains(hint))
131
hints.Insert(hint);
132
}
133
134
// If there is no unread hint, reset the read array and start it again
135
if
(hints.Count() == 0)
136
hints.InsertAll(
m_aAllHints
);
137
138
return
hints.Count();
139
}
140
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
ShowHint
void ShowHint()
Definition
SCR_PerceivedFactionManagerComponent.c:54
BaseContainer
Definition
BaseContainer.c:13
BaseContainerTools
Definition
BaseContainerTools.c:13
Math
Definition
Math.c:13
Resource
Object holding reference to resource. In destructor release the resource.
Definition
Resource.c:25
ResourceName
Definition
ResourceName.c:13
SCR_LoadingHintComponent
Definition
SCR_LoadingHintComponent.c:3
SCR_LoadingHintComponent::GetUnreadHints
int GetUnreadHints(array< string > hints)
Definition
SCR_LoadingHintComponent.c:124
SCR_LoadingHintComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_LoadingHintComponent.c:16
SCR_LoadingHintComponent::Update
void Update(float timeSlice)
Definition
SCR_LoadingHintComponent.c:70
SCR_LoadingHintComponent::m_iHintCount
int m_iHintCount
Definition
SCR_LoadingHintComponent.c:7
SCR_LoadingHintComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_LoadingHintComponent.c:62
SCR_LoadingHintComponent::m_Config
ResourceName m_Config
Definition
SCR_LoadingHintComponent.c:11
SCR_LoadingHintComponent::ShowHint
void ShowHint(int entryIndex=-1)
Definition
SCR_LoadingHintComponent.c:84
SCR_LoadingHintComponent::m_fTime
float m_fTime
Definition
SCR_LoadingHintComponent.c:9
SCR_LoadingHintComponent::m_aReadHints
ref array< string > m_aReadHints
Definition
SCR_LoadingHintComponent.c:13
SCR_LoadingHintComponent::SWITCH_TIME
const float SWITCH_TIME
Definition
SCR_LoadingHintComponent.c:5
SCR_LoadingHintComponent::m_aAllHints
ref array< string > m_aAllHints
Definition
SCR_LoadingHintComponent.c:12
SCR_LoadingHintComponent::m_iHintIndex
int m_iHintIndex
Definition
SCR_LoadingHintComponent.c:8
SCR_LoadingHintComponent::MarkHintRead
void MarkHintRead()
Definition
SCR_LoadingHintComponent.c:113
SCR_LoadingHintComponent::m_wText
TextWidget m_wText
Definition
SCR_LoadingHintComponent.c:10
SCR_LoadingHintComponent::OnLoadingFinished
void OnLoadingFinished()
Definition
SCR_LoadingHintComponent.c:46
SCR_LoadingHintComponent::HINT_INDEX
const int HINT_INDEX
Definition
SCR_LoadingHintComponent.c:4
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
TextWidget
Definition
TextWidget.c:16
UserSettings
Definition
UserSettings.c:13
Widget
Definition
Widget.c:13
scripts
Game
UI
LoadingScreen
SCR_LoadingHintComponent.c
Generated by
1.17.0