Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
WorkshopItemActions.c
Go to the documentation of this file.
1
/*
2
Specific workshop item actions, inherited from base action class.
3
*/
4
5
//-----------------------------------------------------------------------------------------------
7
class
SCR_WorkshopItemActionDownloadDependenciesLatest :
SCR_WorkshopItemActionComposite
8
{
9
// Optionally it is possible to provide dependencies externally,
10
// In this case only these will be downloaded.
11
ref array<ref SCR_WorkshopItem> m_aProvidedDependencies;
12
13
//-----------------------------------------------------------------------------------------------
15
void
SCR_WorkshopItemActionDownloadDependenciesLatest(
SCR_WorkshopItem
wrapper, array<ref SCR_WorkshopItem> dependencies)
16
{
17
if
(dependencies.Count() > 0)
18
{
19
// Copy the provided dependencies
20
m_aProvidedDependencies =
new
array<ref SCR_WorkshopItem>;
21
foreach
(
auto
dep : dependencies)
22
m_aProvidedDependencies.Insert(dep);
23
24
// Create actions for all dependencies
25
#ifdef WORKSHOP_DEBUG
26
_print
(
"New() Creating actions:"
);
27
#endif
28
m_aActions.Clear();
29
foreach
(
SCR_WorkshopItem
dep : m_aProvidedDependencies)
30
{
31
if
(!dep.GetOffline() || dep.GetUpdateAvailable())
32
{
33
#ifdef WORKSHOP_DEBUG
34
_print
(
string
.Format(
" Dependency: %1 - Creating action"
, dep.GetName()));
35
#endif
36
37
SCR_WorkshopItemAction
action = dep.DownloadLatestVersion();
38
m_aActions.Insert(action);
39
}
40
else
41
{
42
#ifdef WORKSHOP_DEBUG
43
_print
(
string
.Format(
" Dependency: %1 - Download is not required."
, dep.GetName()));
44
#endif
45
}
46
}
47
}
48
}
49
50
//-----------------------------------------------------------------------------------------------
51
protected
override
bool
OnActivate
()
52
{
53
bool
success =
true
;
54
55
// Activate all created actions
56
foreach
(
auto
action : m_aActions)
57
{
58
if
(action.IsPaused())
59
success = success && action.Resume();
60
else
if
(action.IsInactive())
61
success = success && action.Activate();
62
}
63
64
return
success;
65
}
66
67
//-----------------------------------------------------------------------------------------------
68
protected
override
bool
OnReactivate
()
69
{
70
return
OnActivate
();
71
}
72
73
//-----------------------------------------------------------------------------------------------
74
protected
override
bool
OnCancel
()
75
{
76
CancelAll
();
77
return
true
;
78
}
79
80
//-----------------------------------------------------------------------------------------------
81
protected
override
bool
OnPause
()
82
{
83
PauseAll
();
84
return
true
;
85
}
86
87
//-----------------------------------------------------------------------------------------------
88
protected
override
bool
OnResume
()
89
{
90
ResumeAll
();
91
return
true
;
92
}
93
94
//-----------------------------------------------------------------------------------------------
95
override
void
Internal_Update
(
float
timeSlice)
96
{
97
if
(!
m_Wrapper
)
98
return
;
99
100
// Check if comms have failed
101
if
(
m_State
!=
STATE_COMPLETED
&&
m_State
!=
STATE_FAILED
)
102
{
103
if
(
m_Wrapper
.GetRequestFailed())
104
this.
Fail
();
105
}
106
107
// Unregister dependnecy actions which were canceled
108
array<SCR_WorkshopItemAction> removeActions =
new
array<SCR_WorkshopItemAction>;
109
foreach
(
SCR_WorkshopItemAction
action : m_aActions)
110
{
111
if
(action.IsCanceled() || action.IsPaused() || action.IsFailed())
// todo should paused actions be removed too?
112
removeActions.Insert(action);
113
}
114
UnregisterActions
(removeActions);
115
116
// Complete when all actions are completed
117
if
(
AllCompleted
())
118
{
119
this.
Complete
();
120
}
121
}
122
};
123
124
//-----------------------------------------------------------------------------------------------
126
class
SCR_WorkshopItemActionReportBase
:
SCR_WorkshopItemAction
127
{
128
ref
BackendCallback
m_Callback;
129
130
//-----------------------------------------------------------------------------------------------
131
protected
bool
OnActivateInternal
();
132
133
//-----------------------------------------------------------------------------------------------
134
protected
override
bool
OnActivate
()
135
{
136
m_Callback =
new
BackendCallback
();
137
m_Callback.SetOnSuccess(
Callback_OnSuccess
);
138
m_Callback.SetOnError(
Callback_OnError
);
139
140
bool
success =
OnActivateInternal
();
141
return
success;
142
}
143
144
145
//-----------------------------------------------------------------------------------------------
146
protected
override
bool
OnReactivate
()
147
{
148
return
this.
OnActivate
();
149
}
150
151
//-----------------------------------------------------------------------------------------------
152
protected
void
Callback_OnError
(
BackendCallback
cb)
153
{
154
Fail
();
155
if
(cb.GetRestResult() ==
ERestResult
.EREST_ERROR_TIMEOUT)
156
{
157
SCR_CommonDialogs
.CreateTimeoutOkDialog();
158
}
159
else
160
{
161
SCR_CommonDialogs
.CreateRequestErrorDialog();
162
}
163
}
164
165
//-----------------------------------------------------------------------------------------------
166
protected
void
Callback_OnSuccess
()
167
{
168
this.
Complete
();
169
}
170
};
171
172
//-----------------------------------------------------------------------------------------------
174
class
SCR_WorkshopItemActionReport
:
SCR_WorkshopItemActionReportBase
175
{
176
protected
EWorkshopReportType
m_eReportType
;
177
protected
string
m_sMessage
;
178
179
//-----------------------------------------------------------------------------------------------
180
void
SCR_WorkshopItemActionReport
(
SCR_WorkshopItem
wrapper,
EWorkshopReportType
eReport,
string
sMessage)
181
{
182
m_eReportType
= eReport;
183
m_sMessage
= sMessage;
184
}
185
186
187
//-----------------------------------------------------------------------------------------------
188
protected
override
bool
OnActivateInternal
()
189
{
190
return
m_Wrapper
.Internal_Report(
m_eReportType
,
m_sMessage
, m_Callback);
191
}
192
};
193
194
195
196
//-----------------------------------------------------------------------------------------------
198
class
SCR_WorkshopItemActionCancelReport
:
SCR_WorkshopItemActionReportBase
199
{
200
protected
override
bool
OnActivateInternal
()
201
{
202
return
m_Wrapper
.Internal_CancelReport(m_Callback);
203
}
204
};
205
206
207
//-----------------------------------------------------------------------------------------------
209
class
SCR_WorkshopItemActionAddAuthorBlock
:
SCR_WorkshopItemActionReportBase
210
{
211
protected
override
bool
OnActivateInternal
()
212
{
213
return
m_Wrapper
.Internal_AddAuthorBlock(m_Callback);
214
}
215
};
216
217
//-----------------------------------------------------------------------------------------------
219
class
SCR_WorkshopItemActionRemoveAuthorBlock
:
SCR_WorkshopItemActionReportBase
220
{
221
protected
override
bool
OnActivateInternal
()
222
{
223
return
m_Wrapper
.Internal_RemoveAuthorBlock(m_Callback);
224
}
225
};
BackendCallback
Definition
Backend_Storage.c:5
SCR_CommonDialogs
Definition
CommonDialogs.c:6
SCR_WorkshopItemActionAddAuthorBlock
Action for blocking author.
Definition
WorkshopItemActions.c:210
SCR_WorkshopItemActionAddAuthorBlock::OnActivateInternal
override bool OnActivateInternal()
Definition
WorkshopItemActions.c:211
SCR_WorkshopItemActionCancelReport
Action for canceling report of an item.
Definition
WorkshopItemActions.c:199
SCR_WorkshopItemActionCancelReport::OnActivateInternal
override bool OnActivateInternal()
Definition
WorkshopItemActions.c:200
SCR_WorkshopItemActionComposite
Composite action which includes multiple subactions.
Definition
SCR_WorkshopItemAction.c:421
SCR_WorkshopItemActionComposite::ResumeAll
void ResumeAll()
Definition
SCR_WorkshopItemAction.c:492
SCR_WorkshopItemActionComposite::UnregisterActions
void UnregisterActions(array< SCR_WorkshopItemAction > actions)
Definition
SCR_WorkshopItemAction.c:449
SCR_WorkshopItemActionComposite::PauseAll
void PauseAll()
Definition
SCR_WorkshopItemAction.c:485
SCR_WorkshopItemActionComposite::CancelAll
void CancelAll()
Definition
SCR_WorkshopItemAction.c:478
SCR_WorkshopItemActionComposite::AllCompleted
bool AllCompleted()
Definition
SCR_WorkshopItemAction.c:456
SCR_WorkshopItemActionDownloadDependenciesLatest::OnActivate
override bool OnActivate()
Definition
WorkshopItemActions.c:51
SCR_WorkshopItemActionDownloadDependenciesLatest::OnReactivate
override bool OnReactivate()
Definition
WorkshopItemActions.c:68
SCR_WorkshopItemActionDownloadDependenciesLatest::OnCancel
override bool OnCancel()
Definition
WorkshopItemActions.c:74
SCR_WorkshopItemActionDownloadDependenciesLatest::OnResume
override bool OnResume()
Definition
WorkshopItemActions.c:88
SCR_WorkshopItemActionDownloadDependenciesLatest::Internal_Update
override void Internal_Update(float timeSlice)
Definition
WorkshopItemActions.c:95
SCR_WorkshopItemActionDownloadDependenciesLatest::OnPause
override bool OnPause()
Definition
WorkshopItemActions.c:81
SCR_WorkshopItemAction::Fail
void Fail(int reason=-1)
Action must call this when it has failed.
Definition
SCR_WorkshopItemAction.c:335
SCR_WorkshopItemAction::SCR_WorkshopItemAction
void SCR_WorkshopItemAction(SCR_WorkshopItem wrapper)
Definition
SCR_WorkshopItemAction.c:53
SCR_WorkshopItemAction::Complete
void Complete()
Action must call this when it is completed.
Definition
SCR_WorkshopItemAction.c:356
SCR_WorkshopItemAction::_print
void _print(string str, LogLevel logLevel=LogLevel.DEBUG)
Definition
SCR_WorkshopItemAction.c:410
SCR_WorkshopItemAction::m_Wrapper
SCR_WorkshopItem m_Wrapper
Definition
SCR_WorkshopItemAction.c:40
SCR_WorkshopItemAction::m_State
int m_State
Definition
SCR_WorkshopItemAction.c:38
SCR_WorkshopItemAction::STATE_COMPLETED
const int STATE_COMPLETED
Definition
SCR_WorkshopItemAction.c:32
SCR_WorkshopItemAction::STATE_FAILED
const int STATE_FAILED
Definition
SCR_WorkshopItemAction.c:33
SCR_WorkshopItemActionRemoveAuthorBlock
Action for removing author mod content blocking.
Definition
WorkshopItemActions.c:220
SCR_WorkshopItemActionRemoveAuthorBlock::OnActivateInternal
override bool OnActivateInternal()
Definition
WorkshopItemActions.c:221
SCR_WorkshopItemActionReportBase
Action for reporting an item.
Definition
WorkshopItemActions.c:127
SCR_WorkshopItemActionReportBase::Callback_OnSuccess
void Callback_OnSuccess()
Definition
WorkshopItemActions.c:166
SCR_WorkshopItemActionReportBase::OnActivateInternal
bool OnActivateInternal()
SCR_WorkshopItemActionReportBase::OnActivate
override bool OnActivate()
Definition
WorkshopItemActions.c:134
SCR_WorkshopItemActionReportBase::Callback_OnError
void Callback_OnError(BackendCallback cb)
Definition
WorkshopItemActions.c:152
SCR_WorkshopItemActionReportBase::OnReactivate
override bool OnReactivate()
Definition
WorkshopItemActions.c:146
SCR_WorkshopItemActionReport::OnActivateInternal
override bool OnActivateInternal()
Definition
WorkshopItemActions.c:188
SCR_WorkshopItemActionReport::m_eReportType
EWorkshopReportType m_eReportType
Definition
WorkshopItemActions.c:176
SCR_WorkshopItemActionReport::SCR_WorkshopItemActionReport
void SCR_WorkshopItemActionReport(SCR_WorkshopItem wrapper, EWorkshopReportType eReport, string sMessage)
Definition
WorkshopItemActions.c:180
SCR_WorkshopItemActionReport::m_sMessage
string m_sMessage
Definition
WorkshopItemActions.c:177
SCR_WorkshopItem
Definition
SCR_WorkshopItem.c:28
ERestResult
ERestResult
States and result + error code produced by RestApi.
Definition
ERestResult.c:14
EWorkshopReportType
EWorkshopReportType
Definition
EWorkshopReportType.c:16
scripts
Game
Workshop
WorkshopItemActions.c
Generated by
1.17.0