Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RespawnBriefingComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/GameMode/Components", description: "Briefing screen shown in respawn menu.")]
3 {
4 }
5 
6 class 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  protected bool m_bWasShown = false;
26  protected ref map<int, ref array<string>> m_BriefingInfo = new map<int, ref array<string>>();
27 
28  //------------------------------------------------------------------------------------------------
29  override bool RplSave(ScriptBitWriter writer)
30  {
31  writer.WriteInt(m_BriefingInfo.Count());
32  array<string> temporaryInfo = {};
33  foreach (int entryID, array<string> info : m_BriefingInfo)
34  {
35  temporaryInfo.Copy(info);
36 
37  writer.WriteString(temporaryInfo[0]);
38  writer.WriteInt(entryID);
39  writer.WriteString(temporaryInfo[1]);
40 
41  //We need to remove faction key and text (Which are the first two elements) so only parameters remain
42  temporaryInfo.RemoveOrdered(0);
43  temporaryInfo.RemoveOrdered(0);
44 
45  writer.WriteInt(temporaryInfo.Count());
46  foreach (string briefingStringParam : temporaryInfo)
47  {
48  writer.WriteString(briefingStringParam);
49  }
50  }
51 
52  return true;
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  override bool RplLoad(ScriptBitReader reader)
57  {
58  int count;
59  FactionKey factionKey;
60  int entryID;
61  string newText;
62  int paramCount;
63  string paramTemp;
64  array<string> param1;
65  reader.ReadInt(count);
66  for (int i = 0; i < count; i++)
67  {
68  param1 = {};
69  reader.ReadString(factionKey);
70  reader.ReadInt(entryID);
71  reader.ReadString(newText);
72  reader.ReadInt(paramCount);
73  for (int j = 0; j < paramCount; j++)
74  {
75  reader.ReadString(paramTemp);
76  param1.Insert(paramTemp);
77  }
78 
79  RewriteEntryMain(factionKey, entryID, newText, param1);
80  }
81 
82  return true;
83  }
84 
85  //------------------------------------------------------------------------------------------------
91  void RewriteEntry_SA(FactionKey factionKey, int entryID, string newText, array<string> param1)
92  {
93  RewriteEntryMain(factionKey, entryID, newText, param1);
94  Rpc(RpcDo_RewriteEntry, factionKey, entryID, newText, param1);
95  }
96 
97  //------------------------------------------------------------------------------------------------
103  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
104  void RpcDo_RewriteEntry(FactionKey factionKey, int entryID, string newText, array<string> param1)
105  {
106  RewriteEntryMain(factionKey, entryID, newText, param1);
107  }
108 
109  //------------------------------------------------------------------------------------------------
115  void RewriteEntryMain(FactionKey factionKey, int entryID, string newText, array<string> param1)
116  {
117  m_BriefingInfo.Remove(entryID);
118  array<string> infoStrings = {};
119  infoStrings.Insert(factionKey);
120  infoStrings.Insert(newText);
121  infoStrings.InsertAll(param1);
122  m_BriefingInfo.Insert(entryID, infoStrings);
123 
124  RewriteEntry(factionKey, entryID, newText, param1);
125 
126  SCR_GameplaySettingsSubMenu.m_OnLanguageChanged.Remove(OnLanguageChanged);
127  SCR_GameplaySettingsSubMenu.m_OnLanguageChanged.Insert(OnLanguageChanged);
128  }
129 
130  //------------------------------------------------------------------------------------------------
136  void RewriteEntry(FactionKey factionKey, int entryID, string newText, array<string> param1)
137  {
138  if (!m_JournalConfig)
140 
141  if (!m_JournalConfig)
142  return;
143 
144  SCR_JournalConfig journalConfig = m_JournalConfig.GetJournalConfig(factionKey);
145  if (!journalConfig)
146  return;
147 
148  array<ref SCR_JournalEntry> journalEntries = {};
149  journalEntries = journalConfig.GetEntries();
150  if (journalEntries.IsEmpty())
151  return;
152 
153  SCR_JournalEntry targetJournalEntry;
154  foreach (SCR_JournalEntry journalEntry : journalEntries)
155  {
156 
157  if (journalEntry.GetEntryID() != entryID)
158  continue;
159 
160  targetJournalEntry = journalEntry;
161  break;
162  }
163 
164  if (!targetJournalEntry)
165  return;
166 
167  targetJournalEntry.SetEntryText(newText);
168  string stringParam1;
169 
170  for (int i = 0, count = param1.Count() * 2; i < count; i += 2) // step 2
171  {
172  if (!param1.IsIndexValid(i))
173  break;
174 
175  stringParam1 = stringParam1 + "<br/><br/>" + LocalizedString.Format(WidgetManager.Translate(param1[i], param1[i + 1]));
176 
177  }
178 
179  targetJournalEntry.SetEntryTextParam1(stringParam1);
180 
181  Widget widgetToRefresh;
182  widgetToRefresh = targetJournalEntry.GetWidget();
183  if (widgetToRefresh)
184  targetJournalEntry.SetEntryLayoutTo(widgetToRefresh);
185  }
186 
187  //------------------------------------------------------------------------------------------------
189  {
190  array<string> temporaryInfo = {};
191  foreach (int entryID, array<string> info : m_BriefingInfo)
192  {
193  temporaryInfo.Copy(info);
194  FactionKey factionKey = temporaryInfo[0];
195  string newText = temporaryInfo[1];
196 
197  //We need to remove faction key and text (Which are the first two elements) so only parameters remain
198  temporaryInfo.RemoveOrdered(0);
199  temporaryInfo.RemoveOrdered(0);
200 
201  RewriteEntry(factionKey, entryID, newText, temporaryInfo);
202  }
203  }
204 
205  //------------------------------------------------------------------------------------------------
208  array<string> GetBriefingStringParamByID(int targetID)
209  {
210  // change it to get last element
211  array<string> strings = {};
212  strings = m_BriefingInfo.Get(targetID);
213  if (!strings || strings.IsEmpty())
214  return null;
215 
216  array<string> stringsCopy = {};
217  stringsCopy.Copy(strings);
218 
219  //We need to remove faction key and text (Which are the first two elements) so only parameters remain
220  stringsCopy.RemoveOrdered(0);
221  stringsCopy.RemoveOrdered(0);
222 
223  return stringsCopy;
224  }
225 
226  //------------------------------------------------------------------------------------------------
229  {
230  if (!m_JournalConfig)
232 
233  return m_JournalConfig;
234  }
235 
236  //------------------------------------------------------------------------------------------------
238  void ResetConfig()
239  {
240  m_JournalConfig = null;
241  }
242 
243  //------------------------------------------------------------------------------------------------
247  {
248  if (m_JournalConfig)
249  return true;
250 
251  if (m_sJournalConfigPath.GetPath().IsEmpty())
252  {
253  Print("Journal config path is empty!", LogLevel.WARNING);
254  return false;
255  }
256 
257  Resource holder = BaseContainerTools.LoadContainer(m_sJournalConfigPath);
258  if (!holder || !holder.IsValid())
259  return false;
260 
261  BaseContainer container = holder.GetResource().ToBaseContainer();
262  if (!container)
263  return false;
264 
265  m_JournalConfig = SCR_JournalSetupConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(container));
266  if (!m_JournalConfig)
267  {
268  Print("Journal config couldn't be created!", LogLevel.WARNING);
269  return false;
270  }
271 
272  return true;
273  }
274 
275  //------------------------------------------------------------------------------------------------
277  static SCR_RespawnBriefingComponent GetInstance()
278  {
279  if (GetGame().GetGameMode())
280  return SCR_RespawnBriefingComponent.Cast(GetGame().GetGameMode().FindComponent(SCR_RespawnBriefingComponent));
281  else
282  return null;
283  }
284 
285  //------------------------------------------------------------------------------------------------
288  {
289  return m_Info;
290  }
291 
292  //------------------------------------------------------------------------------------------------
295  {
296  return m_SimpleBriefingBackground;
297  }
298 
299  //------------------------------------------------------------------------------------------------
301  ResourceName GetJournalConfigPath()
302  {
303  return m_sJournalConfigPath;
304  }
305 
306  //------------------------------------------------------------------------------------------------
309  int GetGameModeHints(out array<ref SCR_UIInfo> hints)
310  {
311  hints = m_aGameModeHints;
312 
313  return m_aGameModeHints.Count();
314  }
315 
316  //------------------------------------------------------------------------------------------------
319  int GetWinConditions(out array<ref SCR_BriefingVictoryCondition> conditions)
320  {
321  conditions = m_aWinConditions;
322 
323  return m_aWinConditions.Count();
324  }
325 
326  //------------------------------------------------------------------------------------------------
328  void SetBriefingShown(bool shown = true)
329  {
330  m_bWasShown = shown;
331  }
332 
333  //------------------------------------------------------------------------------------------------
336  {
337  return m_bWasShown;
338  }
339 }
340 
343 {
344  [Attribute("1", UIWidgets.ComboBox, "Type of victory condition", "", ParamEnumArray.FromEnum(ETaskIconType))]
345  protected ETaskIconType victoryCondition;
346 
347  [Attribute()]
348  protected string name;
349 
350  [Attribute()]
351  protected string description;
352 
353  //------------------------------------------------------------------------------------------------
355  string GetName()
356  {
357  return name;
358  }
359 
360  //------------------------------------------------------------------------------------------------
362  string GetDescription()
363  {
364  return description;
365  }
366 
367  //------------------------------------------------------------------------------------------------
369  ETaskIconType GetConditionType()
370  {
371  return victoryCondition;
372  }
373 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_JournalSetupConfig
Definition: SCR_JournalConfig.c:12
LoadJournalConfig
bool LoadJournalConfig()
Definition: SCR_RespawnBriefingComponent.c:246
RewriteEntryMain
void RewriteEntryMain(FactionKey factionKey, int entryID, string newText, array< string > param1)
Definition: SCR_RespawnBriefingComponent.c:115
m_aGameModeHints
protected ref array< ref SCR_UIInfo > m_aGameModeHints
Definition: SCR_RespawnBriefingComponent.c:20
GetGameModeHints
int GetGameModeHints(out array< ref SCR_UIInfo > hints)
Definition: SCR_RespawnBriefingComponent.c:309
GetInstance
SCR_TextsTaskManagerComponentClass ScriptComponentClass GetInstance()
Definition: SCR_TextsTaskManagerComponent.c:50
ETaskIconType
ETaskIconType
Definition: SCR_TaskIconComponent.c:173
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_JournalConfig
Definition: SCR_JournalConfig.c:45
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
GetInfo
SCR_UIInfo GetInfo()
Definition: SCR_RespawnBriefingComponent.c:287
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
RplLoad
override bool RplLoad(ScriptBitReader reader)
Definition: SCR_RespawnBriefingComponent.c:56
GetJournalSetup
SCR_JournalSetupConfig GetJournalSetup()
Definition: SCR_RespawnBriefingComponent.c:228
m_Info
protected ref SCR_HintUIInfo m_Info
Definition: SCR_BaseHintCondition.c:3
RplSave
override bool RplSave(ScriptBitWriter writer)
Definition: SCR_RespawnBriefingComponent.c:29
m_bWasShown
protected bool m_bWasShown
Definition: SCR_RespawnBriefingComponent.c:25
GetSimpleBriefingBackground
ResourceName GetSimpleBriefingBackground()
Definition: SCR_RespawnBriefingComponent.c:294
RewriteEntry
void RewriteEntry(FactionKey factionKey, int entryID, string newText, array< string > param1)
Definition: SCR_RespawnBriefingComponent.c:136
RewriteEntry_SA
void RewriteEntry_SA(FactionKey factionKey, int entryID, string newText, array< string > param1)
Definition: SCR_RespawnBriefingComponent.c:91
ResetConfig
void ResetConfig()
Definition: SCR_RespawnBriefingComponent.c:238
SCR_BriefingVictoryCondition
Definition: SCR_RespawnBriefingComponent.c:342
GetWinConditions
int GetWinConditions(out array< ref SCR_BriefingVictoryCondition > conditions)
Definition: SCR_RespawnBriefingComponent.c:319
SCR_UIInfo
Definition: SCR_UIInfo.c:7
OnLanguageChanged
protected void OnLanguageChanged(SCR_GameplaySettingsSubMenu menu)
Definition: SCR_RespawnBriefingComponent.c:188
SCR_JournalEntry
Definition: SCR_JournalConfig.c:65
SCR_RespawnBriefingComponentClass
Definition: SCR_RespawnBriefingComponent.c:2
m_BriefingInfo
protected ref map< int, ref array< string > > m_BriefingInfo
Definition: SCR_RespawnBriefingComponent.c:26
GetBriefingStringParamByID
array< string > GetBriefingStringParamByID(int targetID)
Definition: SCR_RespawnBriefingComponent.c:208
Attribute
SCR_RespawnBriefingComponentClass SCR_BaseGameModeComponentClass Attribute("")
Definition: SCR_RespawnBriefingComponent.c:8
m_aWinConditions
protected ref array< ref SCR_BriefingVictoryCondition > m_aWinConditions
Definition: SCR_RespawnBriefingComponent.c:23
SCR_GameplaySettingsSubMenu
Definition: SCR_GameplaySettingsSubMenu.c:5
SetBriefingShown
void SetBriefingShown(bool shown=true)
Definition: SCR_RespawnBriefingComponent.c:328
LocalizedString
Definition: LocalizedString.c:21
SCR_BaseGameModeComponentClass
Definition: SCR_BaseGameModeComponent.c:2
RpcDo_RewriteEntry
void RpcDo_RewriteEntry(FactionKey factionKey, int entryID, string newText, array< string > param1)
Definition: SCR_RespawnBriefingComponent.c:104
GetWasBriefingShown
bool GetWasBriefingShown()
Definition: SCR_RespawnBriefingComponent.c:335
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_BaseGameModeComponent
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_BaseGameModeComponent.c:199
GetJournalConfigPath
ResourceName GetJournalConfigPath()
Definition: SCR_RespawnBriefingComponent.c:301