Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AddonPatchSizeLoader.c
Go to the documentation of this file.
1
4//------------------------------------------------------------------------------------------------
7
8//------------------------------------------------------------------------------------------------
10{
11 protected ref array<SCR_WorkshopItem> m_aItems = {};
12 protected ref array<SCR_WorkshopItem> m_aItemsFailed = {};
13 protected int m_iLoadedPatches;
14
15 protected ref ScriptInvokerBase<ScriptInvoker_AddonPatchSizeLoad> m_OnAllPatchSizeLoaded;
16
17 //------------------------------------------------------------------------------------------------
18 // Public
19 //------------------------------------------------------------------------------------------------
20
21 //------------------------------------------------------------------------------------------------
23 {
24 m_aItems.Insert(item);
25 }
26
27 //------------------------------------------------------------------------------------------------
29 {
30 m_aItems.RemoveItem(item);
31 }
32
33 //------------------------------------------------------------------------------------------------
35 {
36 m_aItems.Clear();
37 }
38
39 protected ref array<ref BackendCallback> m_aCallbacks = {};
40
41 //------------------------------------------------------------------------------------------------
44 {
45 foreach (SCR_WorkshopItem item : m_aItems)
46 {
47 Revision revision = item.GetCurrentLocalRevision();
48 Revision target = item.GetItemTargetRevision();
49
50 // Is matching
51 if (Revision.AreEqual(revision, target))
52 {
54 continue;
55 }
56
57 // Compute patch size
59 callback.SetOnSuccess(OnPatchSizeLoadResponse);
60 callback.SetOnError(OnPatchSizeLoadError);
61 m_aCallbacks.Insert(callback);
62
63 target.ComputePatchSize(callback);
64 }
65 }
66
67 //------------------------------------------------------------------------------------------------
68 // Protected
69 //------------------------------------------------------------------------------------------------
70
71 //------------------------------------------------------------------------------------------------
73 {
74 SCR_WorkshopItem item = callback.GetItem();
75
76 float size;
77 if (item.GetItemTargetRevision().GetPatchSize(size))
78 {
79 // Setup size
82 }
83 else
84 {
85 // Patch size not loaded
86 m_aItemsFailed.Insert(item);
87 }
88
89 // All loaded
90 if (m_iLoadedPatches + m_aItemsFailed.Count() == m_aItems.Count())
91 {
92 bool allLoaded = m_aItemsFailed.IsEmpty();
93
95 m_OnAllPatchSizeLoaded.Invoke(this, allLoaded);
96 }
97
98 m_aCallbacks.RemoveItem(callback);
99 }
100
101 //------------------------------------------------------------------------------------------------
103 {
104 SCR_WorkshopItem item = callback.GetItem();
105
106 // Fail or timeout
107 m_aItemsFailed.Insert(item);
108
109 // All loaded
110 if (m_iLoadedPatches + m_aItemsFailed.Count() == m_aItems.Count())
111 {
112 bool allLoaded = m_aItemsFailed.IsEmpty();
113
115 m_OnAllPatchSizeLoaded.Invoke(this, allLoaded);
116 }
117
118 m_aCallbacks.RemoveItem(callback);
119 }
120
121 //------------------------------------------------------------------------------------------------
122 // Get set
123 //------------------------------------------------------------------------------------------------
124
125 //------------------------------------------------------------------------------------------------
126 ScriptInvokerBase<ScriptInvoker_AddonPatchSizeLoad> GetOnAllPatchSizeLoaded()
127 {
129 m_OnAllPatchSizeLoaded = new ScriptInvokerBase<ScriptInvoker_AddonPatchSizeLoad>();
130
132 }
133
134 //------------------------------------------------------------------------------------------------
135 // Construct
136 //------------------------------------------------------------------------------------------------
137
138 //------------------------------------------------------------------------------------------------
140 {
141 m_aItems.Clear();
142 m_aItemsFailed.Clear();
143
146 }
147}
148
149//------------------------------------------------------------------------------------------------
151{
153
154 //------------------------------------------------------------------------------------------------
156 {
157 return m_Item;
158 }
159
160 //------------------------------------------------------------------------------------------------
162 {
163 m_Item = item;
164 }
165}
int size
SCR_WorkshopItem GetItem()
void SCR_BackendCallbackWorkshopItem(SCR_WorkshopItem item)
func ScriptInvoker_AddonPatchSizeLoad
NewsFeedItem m_Item
ref array< ref BackendCallback > m_aCallbacks
void LoadPatchSizes()
Call compute patch size and setup response reaction.
void OnPatchSizeLoadResponse(SCR_BackendCallbackWorkshopItem callback)
ScriptInvokerBase< ScriptInvoker_AddonPatchSizeLoad > GetOnAllPatchSizeLoaded()
ref array< SCR_WorkshopItem > m_aItems
void InsertItem(SCR_WorkshopItem item)
void RemoveItem(SCR_WorkshopItem item)
ref ScriptInvokerBase< ScriptInvoker_AddonPatchSizeLoad > m_OnAllPatchSizeLoaded
ref array< SCR_WorkshopItem > m_aItemsFailed
void OnPatchSizeLoadError(SCR_BackendCallbackWorkshopItem callback)
Revision GetItemTargetRevision()
void SetTargetRevisionPatchSize(float size)