Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SingleMagazineWidgetComponent_Base.c
Go to the documentation of this file.
2{
3 //Magazine
4 [Attribute("m_MagazineGlow")]
5 protected string m_sMagazineGlow;
6
7 [Attribute("m_MagazineBackground")]
8 protected string m_sMagazineBackground;
9
10 [Attribute("m_MagazineOutline")]
11 protected string m_sMagazineOutline;
12
13 [Attribute("m_MagazineProgress")]
14 protected string m_sMagazineProgress;
15
16 [Attribute("m_ReloadBackground")]
17 protected string m_sReloadBackground;
18
19 [Attribute("m_ReloadOutline")]
20 protected string m_sReloadOutline;
21
22 [Attribute("m_MagazineEmpty")]
23 protected string m_sMagazineEmpty;
24
25 //color sets
26 [Attribute()]
27 protected ref WeaponInfoColorSet m_IdleColorSet;
28
29 [Attribute()]
30 protected ref WeaponInfoColorSet m_HighlightColorSet;
31
32 [Attribute()]
33 protected ref WeaponInfoColorSet m_DisabledColorSet;
34
35 //Magazine indicator
43
45
46 protected bool m_bIsActive = true, m_bIsSelected;
47
48
49 //------------------------------------------------------------------------------------------------
54
55 //------------------------------------------------------------------------------------------------
56 protected override void HandlerAttached(Widget w)
57 {
58 super.HandlerAttached(w);
59
60 //magazine
61 m_wMagazineGlow = ImageWidget.Cast(w.FindAnyWidget(m_sMagazineGlow));
63 m_wMagazineOutline = ImageWidget.Cast(w.FindAnyWidget(m_sMagazineOutline));
65 m_wMagazineEmpty = ImageWidget.Cast(w.FindAnyWidget(m_sMagazineEmpty));
67 m_wReloadOutline = ImageWidget.Cast(w.FindAnyWidget(m_sReloadOutline));
68
69 }
70
71 //------------------------------------------------------------------------------------------------
72 void Init(BaseWeaponComponent weapon, int height, SCR_MagazineIndicatorConfiguration magConfig, bool isSelected)
73 {
74 SetMagazineTextures(magConfig, height);
75 UpdateAmmoCount(weapon);
76 SetSelected(isSelected);
77 }
78
79 //------------------------------------------------------------------------------------------------
80 protected void SetAllSize(int height)
81 {
82 //magazine icons size
83
91 }
92
93 //------------------------------------------------------------------------------------------------
94 protected float GetImageDesiredWidth(ImageWidget w, int height)
95 {
96 int sx, sy;
97 float ratio;
98
99 w.GetImageSize(0, sx, sy);
100
101 if (sy == 0)
102 ratio = 0;
103 else
104 ratio = sx / sy;
105
106 return height * ratio;
107 }
108
109 //------------------------------------------------------------------------------------------------
111 {
112 if (!config)
113 {
114 SetAllSize(height);
115 return;
116 }
117
118 if (config.m_bProgressBar)
119 {
120 SetWidgetImage(m_wMagazineOutline, config.m_sImagesetIcons, config.m_sOutline);
121 SetWidgetImage(m_wMagazineBackground, config.m_sImagesetIcons, config.m_sBackground);
122 SetWidgetImage(m_wMagazineGlow, config.m_sImagesetGlows, config.m_sBackground);
123 }
124 else
125 {
126 SetWidgetImage(m_wMagazineOutline, config.m_sImagesetIcons, config.m_sOutline);
127 SetWidgetImage(m_wMagazineGlow, config.m_sImagesetGlows, config.m_sOutline);
128 }
129
130 SetWidgetImage(m_wMagazineEmpty, config.m_sImagesetIcons, config.m_sEmptyMagazine);
131
132 // Setup textures for reloading indicator
133 SetWidgetImage(m_wReloadBackground, config.m_sImagesetIcons, config.m_sProgress);
134 m_wReloadBackground.SetVisible(false);
135 SetWidgetImage(m_wReloadOutline, config.m_sImagesetIcons, config.m_sOutline);
136 m_wReloadOutline.SetVisible(false);
137
138
139 // Setup visibility, keep only Outline texture, if there is no progress indication
140 m_wMagazineProgress.SetVisible(config.m_bProgressBar);
141 m_wMagazineBackground.SetVisible(config.m_bProgressBar);
142 m_wMagazineOutline.SetOpacity(1);
143
144
145 if (config.m_bProgressBar)
146 {
147 SetWidgetImage(m_wMagazineProgress, config.m_sImagesetIcons, config.m_sProgress);
148 m_wMagazineProgress.LoadMaskFromSet(config.m_sImagesetIcons, config.m_sProgressAlphaMask);
149 m_wMagazineProgress.SetMaskMode(ImageMaskMode.REGULAR);
150 }
151
152 SetAllSize(height);
153 //AnimateWidget_ColorFlash(m_Widgets.m_wMagazineIndicator);
154 }
155
156 //---------------------------------------------------------------------------------------------------------
158 protected void SetWidgetImage(ImageWidget w, string imageOrImageset, string imageName = "", int size = -1)
159 {
160 if (!imageName.IsEmpty())
161 {
162 // Assume it's an image set
163 w.LoadImageFromSet(0, imageOrImageset, imageName);
164 }
165 else if (!imageOrImageset.IsEmpty())
166 {
167 // Assume it's an image
168 w.LoadImageTexture(0, imageOrImageset);
169 }
170
171 if (size == -1)
172 return;
173
174 // Perform resizing
175 int sx, sy;
176 w.GetImageSize(0, sx, sy);
177
178 float ratio = sx / sy;
179
180 w.SetSize(size * ratio, size);
181 }
182
183 //DELEGATED TO CHILDREN
184 //------------------------------------------------------------------------------------------------
186
187 //------------------------------------------------------------------------------------------------
188 protected void SetColors(WeaponInfoColorSet colorSet)
189 {
190 m_wMagazineOutline.SetColor(colorSet.m_IconColor);
191 m_wMagazineProgress.SetColor(colorSet.m_IconColor);
192 m_wMagazineEmpty.SetColor(colorSet.m_IconColor);
193 m_wMagazineBackground.SetColor(colorSet.m_BackgroundColor);
194 }
195
196 //------------------------------------------------------------------------------------------------
197 protected void SetState(SCR_EWeaponInfoIconState newState)
198 {
199 m_eCurrentState = newState;
200
201 switch (m_eCurrentState){
202 case SCR_EWeaponInfoIconState.IDLE:
204 break;
205
206 case SCR_EWeaponInfoIconState.HIGHLIGHTED:
208 break;
209
210 case SCR_EWeaponInfoIconState.DISABLED:
212 break;
213 }
214 }
215
216 //------------------------------------------------------------------------------------------------
217 void SetSelected(bool selected)
218 {
220 {
221 if (selected)
223 else
225 }
226 }
227
228 //------------------------------------------------------------------------------------------------
229 void SetActive(bool active)
230 {
231 if (active)
233 else
235 }
236
237 //------------------------------------------------------------------------------------------------
239 {
240 m_wRoot.RemoveFromHierarchy();
241 }
242}
int size
void SetMagazineTextures(SCR_MagazineIndicatorConfiguration config, int height)
void Init(BaseWeaponComponent weapon, int height, SCR_MagazineIndicatorConfiguration magConfig, bool isSelected)
void UpdateAmmoCount(BaseWeaponComponent weapon)
void SetWidgetImage(ImageWidget w, string imageOrImageset, string imageName="", int size=-1)
Sets widget's image to an image or imageset.
SCR_FieldOfViewSettings Attribute
ImageMaskMode