29 protected Room m_Room;
30 protected Dependency m_ScenarioDependency;
34 protected bool m_bModsMatching =
false;
35 protected bool m_bBlockedMods;
36 protected ref array<ref SCR_WorkshopItem> m_aCollidingDependencies = {};
39 protected ref array<ref SCR_WorkshopItem> m_aRoomItemsScripted = {};
41 protected ref array<ref SCR_WorkshopItem> m_aItemsUpdated = {};
42 protected ref array<ref SCR_WorkshopItem> m_aItemsToUpdate = {};
48 protected ref array<ref SCR_OnlineServiceBackendCallbacks> m_aModsCallbacks = {};
55 protected ref ScriptInvoker m_OnGetAllDependencies =
new ScriptInvoker();
57 protected ref ScriptInvoker m_OnGetScenario =
new ScriptInvoker();
60 protected ref ScriptInvokerBase<ScriptInvoker_RoomModsDependencies> m_OnDependenciesLoadingPrevented;
63 ScriptInvoker GetOnGetAllDependencies()
65 return m_OnGetAllDependencies;
69 ScriptInvoker GetOnGetScenario()
71 return m_OnGetScenario;
84 ScriptInvokerBase<ScriptInvoker_RoomModsDependencies> GetOnDependenciesLoadingPrevented()
86 if (!m_OnDependenciesLoadingPrevented)
87 m_OnDependenciesLoadingPrevented =
new ScriptInvokerBase<ScriptInvoker_RoomModsDependencies>();
89 return m_OnDependenciesLoadingPrevented;
101 m_bModsMatching =
false;
102 m_bBlockedMods =
false;
103 m_aCollidingDependencies.Clear();
104 m_aRoomItemsScripted.Clear();
105 m_aItemsUpdated.Clear();
106 m_aItemsToUpdate.Clear();
107 m_ModsCallback =
null;
109 m_aModsCallbacks.Clear();
110 m_DownloadSequence =
null;
111 m_ScenarioDependency =
null;
118 void ReceiveRoomMods(notnull Room room)
123 array<Dependency> deps = {};
126 m_bBlockedMods =
false;
127 m_aCollidingDependencies.Clear();
131 m_ModsCallback.GetEventOnResponse().Insert(OnRoomCallbackResponse);
132 m_Room.LoadDownloadList(m_ModsCallback);
137 void ReceiveRoomScenario(notnull Room room)
141 Debug.Error(
"Received data for non active room");
144 OnScenarioModLoaded();
150 protected void OnLoadingModsFail(Room room)
157 m_OnModsFail.Invoke(
m_Room);
168 protected void UpdatedDependencies(notnull array<ref SCR_WorkshopItem> items)
170 m_aItemsUpdated.Clear();
171 m_aItemsToUpdate.Clear();
178 protected void AllItemsLoaded()
183 UpdatedDependencies(m_aRoomItemsScripted);
186 if (m_OnGetAllDependencies)
188 m_OnGetAllDependencies.Invoke();
190 m_bModsMatching = (m_aItemsToUpdate.IsEmpty());
193 ReceiveRoomScenario(
m_Room);
198 protected void LoadScenario()
200 m_ScenarioCallback.m_OnItem.Clear();
205 m_ScenarioDependency =
m_Room.HostScenarioMod();
224 reportedDialog.GetOnAllReportsCanceled().Insert(OnAllReportsCanceled);
226 return reportedDialog;
236 dialog.GetOnAllReportsCanceled().Remove(OnAllReportsCanceled);
238 m_DownloadSequence.OnAllReportsCanceled(dialog);
247 protected void OnScenarioModLoaded()
250 m_ScenarioCallback.m_OnItem.Remove(OnScenarioModLoaded);
256 protected void OnScenarioDetails()
258 m_ScenarioCallback.m_OnScenarios.Remove(OnScenarioDetails);
259 m_OnGetScenario.Invoke(m_ScenarioDependency);
273 OnLoadingModsFail(
callback.GetRoom());
276 callback.GetEventOnResponse().Remove(OnRoomCallbackResponse);
281 protected void OnRoomFullList()
285 OnLoadingModsFail(
null);
289 if (!
m_Room.IsAuthorized())
291 OnLoadingModsFail(
m_Room);
295 array<Dependency> deps =
new array<Dependency>;
298 array<Dependency> depsItems =
new array<Dependency>;
301 m_aRoomItemsScripted.Clear();
313 foreach (Dependency dep : deps)
317 item.SetItemTargetRevision(dep.GetRevision());
318 m_aRoomItemsScripted.Insert(item);
322 if (m_DownloadSequence)
324 m_DownloadSequence.GetOnReady().Remove(OnDownloadSequenceReady);
325 m_DownloadSequence.GetOnError().Remove(OnDownloadSequenceError);
329 InitDownloadSequence();
333 protected void InitDownloadSequence()
336 m_DownloadSequence.GetOnReady().Insert(OnDownloadSequenceReady);
337 m_DownloadSequence.GetOnDependenciesLoadingPrevented().Insert(OnDependenciesLoadingPrevented);
338 m_DownloadSequence.GetOnError().Insert(OnDownloadSequenceError);
339 m_DownloadSequence.GetOnRestrictedDependency().Insert(OnDownloadSequenceRestrictedAddons);
341 m_DownloadSequence.Init();
350 sequence.GetOnReady().Remove(OnDownloadSequenceReady);
351 sequence.GetOnDependenciesLoadingPrevented().Remove(OnDependenciesLoadingPrevented);
352 sequence.GetOnError().Remove(OnDownloadSequenceError);
353 sequence.GetOnRestrictedDependency().Remove(OnDownloadSequenceRestrictedAddons);
359 protected void OnDependenciesLoadingPrevented(
SCR_DownloadSequence sequence, array<ref SCR_WorkshopItem> dependencies)
361 m_aCollidingDependencies = dependencies;
363 if (m_OnDependenciesLoadingPrevented)
364 m_OnDependenciesLoadingPrevented.Invoke(
m_Room, dependencies);
367 sequence.GetOnDependenciesLoadingPrevented().Remove(OnDependenciesLoadingPrevented);
371 array<ref SCR_WorkshopItem> GetCollidingDependencies()
373 array<ref SCR_WorkshopItem> dependencies = {};
377 dependencies.Insert(item);
392 InitDownloadSequence();
394 dialog.m_OnConfirm.Remove(OnCancelDownloadConfirm);
395 dialog.m_OnClose.Remove(OnCancelDownloadDialogClose);
402 sequence.GetOnReady().Remove(OnDownloadSequenceReady);
403 sequence.GetOnDependenciesLoadingPrevented().Remove(OnDependenciesLoadingPrevented);
404 sequence.GetOnError().Remove(OnDownloadSequenceError);
405 sequence.GetOnRestrictedDependency().Remove(OnDownloadSequenceRestrictedAddons);
407 m_OnModsFail.Invoke(
m_Room);
411 protected void OnDownloadSequenceRestrictedAddons(
SCR_DownloadSequence sequence, array<ref SCR_WorkshopItem> items)
413 m_bBlockedMods = m_DownloadSequence.GetBlockedAddons();
420 string GetModListSizeString(array<ref SCR_WorkshopItem> items)
422 float size = GetModsSize(items);
434 float GetModsSize(array<ref SCR_WorkshopItem> items)
441 string GetModListPatchSizeString(array<ref SCR_WorkshopItem> items)
443 float size = GetModListPatchSize(items);
453 float GetModListPatchSize(array<ref SCR_WorkshopItem> items)
456 for (
int i = 0, count = items.Count(); i < count; i++)
458 size += items[i].GetTargetRevisionPatchSize();
465 bool HasBlockedMods()
467 return m_bBlockedMods;
471 array<ref SCR_WorkshopItem> GetRoomItemsScripted()
473 return m_aRoomItemsScripted;
477 array<ref SCR_WorkshopItem> GetRoomItemsUpdated()
479 return m_aItemsUpdated;
483 array<ref SCR_WorkshopItem> GetRoomItemsToUpdate()
485 array<ref SCR_WorkshopItem> items = {};
496 void SetRoom(Room room)
502 bool GetModsMatching()
504 return m_bModsMatching;