Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapJournalUI.c
Go to the documentation of this file.
1// todo@lk: figure out what to call this, journal is probably not the best choice, idiot
3{
4 [Attribute("JournalFrame", desc: "Root frame widget name")]
5 protected string m_sRootWidgetName;
6
7 [Attribute("faction", desc: "Map task list imageset quad name")]
9
10 [Attribute("exclamationCircle", desc: "Toolmenu imageset quad name")]
11 protected string m_sToolMenuIconName;
12
13 [Attribute("8", desc: "Offset substracted from total widget size.")]
14 protected int m_iOffset;
15
22
23 protected ref array<SCR_MapJournalUIButton> m_aEntries = {};
24 protected int m_iCurrentEntryId = -1;
25
27
28 //We'll store the bool in order to know if is it the first opening or not
29 protected bool m_bFirstOpening = true;
30
32
33 //------------------------------------------------------------------------------------------------
34 override void Init()
35 {
36 SCR_RespawnBriefingComponent briefingComp = SCR_RespawnBriefingComponent.GetInstance();
37 if (!briefingComp)
38 return;
39
40 if (!briefingComp.LoadJournalConfig())
41 return;
42
43 m_JournalConfig = briefingComp.GetJournalSetup();
44 if (!m_JournalConfig)
45 return;
46
48 if (m_ToolMenu)
49 {
50 m_ToolMenuEntry = m_ToolMenu.RegisterToolMenuEntry(SCR_MapToolMenuUI.s_sToolMenuIcons, m_sToolMenuIconName, 1, m_bIsExclusive);
51 m_ToolMenuEntry.m_OnClick.Insert(ToggleVisible);
52 m_ToolMenuEntry.GetOnDisableMapUIInvoker().Insert(DisableMapUIComponent);
53 m_ToolMenuEntry.SetEnabled(true);
54 }
55
57 }
58
59 //------------------------------------------------------------------------------------------------
60 override void OnMapOpen(MapConfiguration config)
61 {
62 super.OnMapOpen(config);
63
64 if (!m_JournalConfig)
65 return;
66
68 if (!m_wJournalFrame)
69 return;
70
71 if (!m_wJournalFrame.GetChildren())
72 {
73 Widget journal = GetGame().GetWorkspace().CreateWidgets(m_Widgets.GetLayout(), m_wJournalFrame);
74 if (!journal)
75 return;
76
77 m_Widgets.Init(journal);
78 }
79
80 if (m_Widgets.m_wFocusButton)
81 m_Widgets.m_FocusButtonComponent.GetOnFocus().Insert(FocusOnFirstEntry);
82
83 PlayerController pc = GetGame().GetPlayerController();
84 if (!pc)
85 return;
86
89 return;
90
91 m_PlyFactionAffilComp.GetOnPlayerFactionResponseInvoker_O().Insert(OnPlayerFactionResponse);
92
94
95 SCR_RespawnBriefingComponent briefingComp = SCR_RespawnBriefingComponent.GetInstance();
96
97 if (!m_bFirstOpening || !briefingComp || (briefingComp && !briefingComp.ShowJournalOnStart()))
99
100 if (m_bFirstOpening)
101 {
102 //if opened for the first time, use the value from config
103 ShowEntryByID(m_JournalConfig.GetJournalEntryToBeShown());
104 m_bFirstOpening = false;
105 }
106 else
107 {
108 //if opened the second and other times, use the last opened one
110 }
111
112 //## Need to be called in order to wait for widget initialization.
113 GetGame().GetCallqueue().Call(UpdateJournalPosition);
114 }
115
116 //------------------------------------------------------------------------------------------------
118 protected void UpdateJournalPosition()
119 {
120 Widget toolMenuBackground = m_ToolMenu.GetBackgroundWidget();
121 toolMenuBackground.Update();
122
123 float sizeW, sizeY;
124 toolMenuBackground.GetScreenSize(sizeW, sizeY);
125
126 sizeY = GetGame().GetWorkspace().DPIUnscale(sizeY) - m_iOffset;
127
128 m_Widgets.m_wSizeLayout.SetHeightOverride(sizeY);
129 }
130
131 //------------------------------------------------------------------------------------------------
132 protected void OnPlayerFactionResponse(SCR_PlayerFactionAffiliationComponent component, int factionIndex, bool response)
133 {
135 return;
136
137 if (response)
138 {
139 m_Widgets.m_wEntryLayout.SetVisible(false);
141 }
142 }
143
144 //------------------------------------------------------------------------------------------------
146 protected void ToggleVisible()
147 {
149 return;
150
151 bool visible = m_wJournalFrame.IsVisible();
152 m_wJournalFrame.SetVisible(!visible);
153 if (m_ToolMenuEntry)
154 m_ToolMenuEntry.SetActive(!visible);
155
156 if (!visible)
158 }
159
160 //------------------------------------------------------------------------------------------------
162 void SetJournalVisibility(bool visibility)
163 {
164 m_ToolMenuEntry.SetActive(visibility);
165 m_wJournalFrame.SetVisible(visibility);
166
167 if (m_ToolMenuEntry)
168 m_ToolMenuEntry.SetActive(visibility);
169
170 if (visibility)
172 }
173
174 //------------------------------------------------------------------------------------------------
175 protected void GetJournalForPlayer()
176 {
177 m_aEntries.Clear();
178
180
181 FactionKey factionKey = FactionKey.Empty;
183 {
184 Faction plyFaction = m_PlyFactionAffilComp.GetAffiliatedFaction();
185 if (plyFaction)
186 factionKey = plyFaction.GetFactionKey();
187 }
188
189 SCR_JournalConfig factionJournal = m_JournalConfig.GetJournalConfig(factionKey);
190 if (!factionJournal)
191 return;
192
193 array<ref SCR_JournalEntry> journalEntries = factionJournal.GetEntries();
194 if (!journalEntries)
195 return;
196
197 Widget widget;
198 SCR_MapJournalUIButton component;
199 WorkspaceWidget workspace = GetGame().GetWorkspace();
200 foreach (int entryId, SCR_JournalEntry entry : journalEntries)
201 {
202 entry = journalEntries[entryId];
203
204 widget = workspace.CreateWidgets(entry.GetEntryButtonLayout(), m_Widgets.m_wEntriesWrapper);
205 component = SCR_MapJournalUIButton.Cast(widget.FindHandler(SCR_MapJournalUIButton));
206 if (!component)
207 continue;
208
209 component.SetContent(entry.GetEntryName());
210 component.SetEntry(entry, entryId);
211
212 component.GetOnToggled().Insert(ShowEntry);
213 m_aEntries.Insert(component);
214 }
215 }
216
217 //------------------------------------------------------------------------------------------------
220 protected void ShowEntryByID(int id)
221 {
222 if (id < 0)
223 return;
224
225 SCR_MapJournalUIButton entryBtn;
226
227 Widget child = m_Widgets.m_wEntriesWrapper.GetChildren();
228 while (child)
229 {
230 entryBtn = SCR_MapJournalUIButton.Cast(child.FindHandler(SCR_MapJournalUIButton));
231 if (!entryBtn)
232 continue;
233
234 if (entryBtn.GetId() == id)
235 {
236 ShowEntry(entryBtn);
237 break;
238 }
239
240 child = child.GetSibling();
241 }
242 }
243
244 //------------------------------------------------------------------------------------------------
247 protected void ShowEntry(SCR_MapJournalUIButton journalBtn)
248 {
249 if (journalBtn.GetId() == m_iCurrentEntryId)
250 {
251 journalBtn.SetToggled(false);
252 m_Widgets.m_wEntryLayout.SetVisible(!m_Widgets.m_wEntryLayout.IsVisible());
254 }
255 else
256 {
257 Widget child = m_Widgets.m_wEntryLayout.GetChildren();
258 if (child)
259 delete child;
260
261 // Toggle off last interacted button
263 m_LastInteractedEntry.SetToggled(false);
264
265 m_iCurrentEntryId = journalBtn.GetId();
266
267 journalBtn.SetToggled(true);
268 journalBtn.ShowEntry(m_Widgets.m_wEntryLayout);
269 m_Widgets.m_wEntryLayout.SetVisible(true);
270 }
271
272 m_LastInteractedEntry = journalBtn;
273 }
274
275 //------------------------------------------------------------------------------------------------
276 protected void FocusOnFirstEntry()
277 {
278 if (!m_aEntries.IsEmpty() && m_aEntries[0])
279 GetGame().GetWorkspace().SetFocusedWidget(m_aEntries[0].GetRootWidget());
280 }
281
282 //------------------------------------------------------------------------------------------------
284 {
285 return m_wJournalFrame && m_wJournalFrame.IsVisible();
286 }
287
288 //------------------------------------------------------------------------------------------------
290 {
292 }
293
294 //------------------------------------------------------------------------------------------------
295 override void HandlerDeattached(Widget w)
296 {
297 if (m_ToolMenuEntry)
298 m_ToolMenuEntry.GetOnDisableMapUIInvoker().Remove(DisableMapUIComponent);
299 }
300}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_MapToolMenuUI()
Widget GetRootWidget()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
array< ref SCR_JournalEntry > GetEntries()
void SetToggled(bool newToggled)
void SetEntry(SCR_JournalEntry entry, int id)
void ShowEntry(Widget target)
void ShowEntryByID(int id)
SCR_PlayerFactionAffiliationComponent m_PlyFactionAffilComp
void SetJournalVisibility(bool visibility)
void ShowEntry(SCR_MapJournalUIButton journalBtn)
SCR_MapToolEntry m_ToolMenuEntry
void OnPlayerFactionResponse(SCR_PlayerFactionAffiliationComponent component, int factionIndex, bool response)
SCR_JournalSetupConfig m_JournalConfig
void UpdateJournalPosition()
Adjuts size of journal to match height of tool bar.
ref SCR_JournalWidgets m_Widgets
override void HandlerDeattached(Widget w)
override void Init()
ref array< SCR_MapJournalUIButton > m_aEntries
override void OnMapOpen(MapConfiguration config)
SCR_MapJournalUIButton m_LastInteractedEntry
SCR_MapTaskListUI m_MapTaskList
void ToggleVisible()
Toggle visibility for the journal.
string m_sTaskListToolMenuIconName
SCR_MapToolMenuUI m_ToolMenu
Map tool menu entry data class.
SCR_FieldOfViewSettings Attribute