Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RespawnBriefingComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/GameMode/Components", description: "Briefing screen shown in respawn menu.")]
5
6class SCR_RespawnBriefingComponent : SCR_BaseGameModeComponent
7{
8 [Attribute("")]
9 protected ResourceName m_sJournalConfigPath;
10
11 protected ref SCR_JournalSetupConfig m_JournalConfig;
12
13 [Attribute()]
14 protected ref SCR_UIInfo m_Info;
15
16 [Attribute("{324E923535DCACF8}UI/Textures/DeployMenu/Briefing/conflict_HintBanner_1_UI.edds", desc: "background shown when briefing has no hints")]
17 protected ResourceName m_SimpleBriefingBackground;
18
19 [Attribute()]
20 protected ref array<ref SCR_UIInfo> m_aGameModeHints;
21
22 [Attribute()]
23 protected ref array<ref SCR_BriefingVictoryCondition> m_aWinConditions;
24
25 [Attribute()]
26 protected bool m_bShowJournalOnStart;
27
28 protected bool m_bWasShown = false;
30
31 //------------------------------------------------------------------------------------------------
32 override bool RplSave(ScriptBitWriter writer)
33 {
34 writer.WriteInt(m_BriefingInfo.Count());
35 array<string> temporaryInfo = {};
36 foreach (int entryID, array<string> info : m_BriefingInfo)
37 {
38 temporaryInfo.Copy(info);
39
40 writer.WriteString(temporaryInfo[0]);
41 writer.WriteInt(entryID);
42 writer.WriteString(temporaryInfo[1]);
43
44 //We need to remove faction key and text (Which are the first two elements) so only parameters remain
45 temporaryInfo.RemoveOrdered(0);
46 temporaryInfo.RemoveOrdered(0);
47
48 writer.WriteInt(temporaryInfo.Count());
49 foreach (string briefingStringParam : temporaryInfo)
50 {
51 writer.WriteString(briefingStringParam);
52 }
53 }
54
55 return true;
56 }
57
58 //------------------------------------------------------------------------------------------------
59 override bool RplLoad(ScriptBitReader reader)
60 {
61 int count;
62 FactionKey factionKey;
63 int entryID;
64 string newText;
65 int paramCount;
66 string paramTemp;
67 array<string> param1;
68 reader.ReadInt(count);
69 for (int i = 0; i < count; i++)
70 {
71 param1 = {};
72 reader.ReadString(factionKey);
73 reader.ReadInt(entryID);
74 reader.ReadString(newText);
75 reader.ReadInt(paramCount);
76 for (int j = 0; j < paramCount; j++)
77 {
78 reader.ReadString(paramTemp);
79 param1.Insert(paramTemp);
80 }
81
82 RewriteEntryMain(factionKey, entryID, newText, param1);
83 }
84
85 return true;
86 }
87
88 //------------------------------------------------------------------------------------------------
94 void RewriteEntry_SA(FactionKey factionKey, int entryID, string newText, array<string> param1)
95 {
96 RewriteEntryMain(factionKey, entryID, newText, param1);
97 Rpc(RpcDo_RewriteEntry, factionKey, entryID, newText, param1);
98 }
99
100 //------------------------------------------------------------------------------------------------
106 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
107 void RpcDo_RewriteEntry(FactionKey factionKey, int entryID, string newText, array<string> param1)
108 {
109 RewriteEntryMain(factionKey, entryID, newText, param1);
110 }
111
112 //------------------------------------------------------------------------------------------------
118 void RewriteEntryMain(FactionKey factionKey, int entryID, string newText, array<string> param1)
119 {
120 m_BriefingInfo.Remove(entryID);
121 array<string> infoStrings = {};
122 infoStrings.Insert(factionKey);
123 infoStrings.Insert(newText);
124 infoStrings.InsertAll(param1);
125 m_BriefingInfo.Insert(entryID, infoStrings);
126
127 RewriteEntry(factionKey, entryID, newText, param1);
128
131 }
132
133 //------------------------------------------------------------------------------------------------
139 void RewriteEntry(FactionKey factionKey, int entryID, string newText, array<string> param1)
140 {
141 if (!m_JournalConfig)
143
144 if (!m_JournalConfig)
145 return;
146
147 SCR_JournalConfig journalConfig = m_JournalConfig.GetJournalConfig(factionKey);
148 if (!journalConfig)
149 return;
150
151 array<ref SCR_JournalEntry> journalEntries = {};
152 journalEntries = journalConfig.GetEntries();
153 if (journalEntries.IsEmpty())
154 return;
155
156 SCR_JournalEntry targetJournalEntry;
157 foreach (SCR_JournalEntry journalEntry : journalEntries)
158 {
159
160 if (journalEntry.GetEntryID() != entryID)
161 continue;
162
163 targetJournalEntry = journalEntry;
164 break;
165 }
166
167 if (!targetJournalEntry)
168 return;
169
170 targetJournalEntry.SetEntryText(newText);
171 string stringParam1;
172
173 for (int i = 0, count = param1.Count() * 2; i < count; i += 2) // step 2
174 {
175 if (!param1.IsIndexValid(i))
176 break;
177
178 stringParam1 = stringParam1 + "<br/><br/>" + LocalizedString.Format(WidgetManager.Translate(param1[i], param1[i + 1]));
179
180 }
181
182 targetJournalEntry.SetEntryTextParam1(stringParam1);
183
184 Widget widgetToRefresh;
185 widgetToRefresh = targetJournalEntry.GetWidget();
186 if (widgetToRefresh)
187 targetJournalEntry.SetEntryLayoutTo(widgetToRefresh);
188 }
189
190 //------------------------------------------------------------------------------------------------
192 {
193 array<string> temporaryInfo = {};
194 foreach (int entryID, array<string> info : m_BriefingInfo)
195 {
196 temporaryInfo.Copy(info);
197 FactionKey factionKey = temporaryInfo[0];
198 string newText = temporaryInfo[1];
199
200 //We need to remove faction key and text (Which are the first two elements) so only parameters remain
201 temporaryInfo.RemoveOrdered(0);
202 temporaryInfo.RemoveOrdered(0);
203
204 RewriteEntry(factionKey, entryID, newText, temporaryInfo);
205 }
206 }
207
208 //------------------------------------------------------------------------------------------------
211 array<string> GetBriefingStringParamByID(int targetID)
212 {
213 // change it to get last element
214 array<string> strings = {};
215 strings = m_BriefingInfo.Get(targetID);
216 if (!strings || strings.IsEmpty())
217 return null;
218
219 array<string> stringsCopy = {};
220 stringsCopy.Copy(strings);
221
222 //We need to remove faction key and text (Which are the first two elements) so only parameters remain
223 stringsCopy.RemoveOrdered(0);
224 stringsCopy.RemoveOrdered(0);
225
226 return stringsCopy;
227 }
228
229 //------------------------------------------------------------------------------------------------
232 {
233 if (!m_JournalConfig)
235
236 return m_JournalConfig;
237 }
238
239 //------------------------------------------------------------------------------------------------
242 {
243 m_JournalConfig = null;
244 }
245
246 //------------------------------------------------------------------------------------------------
250 {
251 if (m_JournalConfig)
252 return true;
253
254 if (m_sJournalConfigPath.GetPath().IsEmpty())
255 {
256 Print("Journal config path is empty!", LogLevel.WARNING);
257 return false;
258 }
259
260 Resource holder = BaseContainerTools.LoadContainer(m_sJournalConfigPath);
261 if (!holder || !holder.IsValid())
262 return false;
263
264 BaseContainer container = holder.GetResource().ToBaseContainer();
265 if (!container)
266 return false;
267
268 m_JournalConfig = SCR_JournalSetupConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(container));
269 if (!m_JournalConfig)
270 {
271 Print("Journal config couldn't be created!", LogLevel.WARNING);
272 return false;
273 }
274
275 return true;
276 }
277
278 //------------------------------------------------------------------------------------------------
280 static SCR_RespawnBriefingComponent GetInstance()
281 {
282 if (GetGame().GetGameMode())
283 return SCR_RespawnBriefingComponent.Cast(GetGame().GetGameMode().FindComponent(SCR_RespawnBriefingComponent));
284 else
285 return null;
286 }
287
288 //------------------------------------------------------------------------------------------------
291 {
292 return m_Info;
293 }
294
295 //------------------------------------------------------------------------------------------------
298 {
299 return m_SimpleBriefingBackground;
300 }
301
302 //------------------------------------------------------------------------------------------------
305 {
306 return m_sJournalConfigPath;
307 }
308
309 //------------------------------------------------------------------------------------------------
312 int GetGameModeHints(out array<ref SCR_UIInfo> hints)
313 {
314 hints = m_aGameModeHints;
315
316 return m_aGameModeHints.Count();
317 }
318
319 //------------------------------------------------------------------------------------------------
322 int GetWinConditions(out array<ref SCR_BriefingVictoryCondition> conditions)
323 {
324 conditions = m_aWinConditions;
325
326 return m_aWinConditions.Count();
327 }
328
329 //------------------------------------------------------------------------------------------------
331 void SetBriefingShown(bool shown = true)
332 {
333 m_bWasShown = shown;
334 }
335
336 //------------------------------------------------------------------------------------------------
339 {
340 return m_bWasShown;
341 }
342
343 //------------------------------------------------------------------------------------------------
345 {
347 }
348}
349
352{
353 [Attribute("1", UIWidgets.ComboBox, "Type of victory condition", "", ParamEnumArray.FromEnum(ETaskIconType))]
355
356 [Attribute()]
357 protected string name;
358
359 [Attribute()]
360 protected string description;
361
362 //------------------------------------------------------------------------------------------------
364 string GetName()
365 {
366 return name;
367 }
368
369 //------------------------------------------------------------------------------------------------
372 {
373 return description;
374 }
375
376 //------------------------------------------------------------------------------------------------
382}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
override bool RplLoad(ScriptBitReader reader)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
ref SCR_HintUIInfo m_Info
override bool RplSave(ScriptBitWriter writer)
override SCR_UIInfo GetInfo()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
bool ShowJournalOnStart()
ResourceName GetJournalConfigPath()
int GetWinConditions(out array< ref SCR_BriefingVictoryCondition > conditions)
ref array< ref SCR_UIInfo > m_aGameModeHints
ResourceName GetSimpleBriefingBackground()
int GetGameModeHints(out array< ref SCR_UIInfo > hints)
bool GetWasBriefingShown()
void RewriteEntry_SA(FactionKey factionKey, int entryID, string newText, array< string > param1)
void SetBriefingShown(bool shown=true)
bool m_bShowJournalOnStart
array< string > GetBriefingStringParamByID(int targetID)
ref array< ref SCR_BriefingVictoryCondition > m_aWinConditions
void OnLanguageChanged(SCR_GameplaySettingsSubMenu menu)
void RewriteEntry(FactionKey factionKey, int entryID, string newText, array< string > param1)
SCR_JournalSetupConfig GetJournalSetup()
void RewriteEntryMain(FactionKey factionKey, int entryID, string newText, array< string > param1)
bool LoadJournalConfig()
ref map< int, ref array< string > > m_BriefingInfo
void RpcDo_RewriteEntry(FactionKey factionKey, int entryID, string newText, array< string > param1)
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
static ref ScriptInvoker_GameplaySettingsSubMenuChanged m_OnLanguageChanged
array< ref SCR_JournalEntry > GetEntries()
void SetEntryText(string text)
void SetEntryTextParam1(string text)
Widget GetWidget()
Widget SetEntryLayoutTo(out notnull Widget parent)
Definition Types.c:486
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
Tuple param1