43 #ifdef WEAPON_INFO_DEBUG
44 static void _print(
string str)
46 int hour, minute, second;
47 System.GetHourMinuteSecondUTC(hour, minute, second);
48 string timeStr =
string.Format(
"%1.%2.%3", hour, minute, second);
49 Print(
string.Format(
"%1 [Weapon Info UI] %2", timeStr, str), LogLevel.DEBUG);
53 const float SCALE_DEFAULT = 0.6;
54 const float SCALE_FIREMODE = 0.4;
55 const float SCALE_MAGAZINE = 0.6;
57 const float UPDATE_INTERVAL = 0.1;
58 const float FADED_OPACITY = 0.3;
60 const ref Color COLOR_WHITE = Color.FromSRGBA(255, 255, 255, 255);
61 const ref Color COLOR_ORANGE = Color.FromSRGBA(226, 167, 79, 255);
63 protected const float FADEOUT_PANEL_DELAY = 6;
64 protected const float FADEOUT_OPTICS_DELAY = 6;
65 protected const float FADEOUT_AMMO_TYPE_DELAY = 6;
67 protected BaseWeaponManagerComponent m_WeaponManager;
68 protected SCR_InventoryStorageManagerComponent m_InventoryManager;
69 protected CompartmentAccessComponent m_CompartmentAccess;
77 protected const ResourceName DEFAULT_WEAPON_INFO_LAYOUT =
"{8170DE93810F928A}UI/layouts/HUD/WeaponInfo/WeaponInfo.layout";
78 protected const ResourceName DEFAULT_MAGAZINE_INDICATOR =
"{7C114BA7C59E198D}Configs/WeaponInfo/MagazineIndicators/box.conf";
86 protected bool m_bFadeInOutActive =
false;
89 ref SCR_MagazinePredicate m_pMagazineSearchPredicate =
new SCR_MagazinePredicate();
90 ref SCR_PrefabDataPredicate m_pPrefabDataPredicate =
new SCR_PrefabDataPredicate();
95 #ifdef WEAPON_INFO_DEBUG
97 _print(
string.Format(
" weapon: %1", weapon));
108 IEntity e = weaponSlot.GetWeaponEntity();
120 if (m_WeaponState.m_Weapon != weapon)
123 if (m_WeaponState.m_SightsZoomFOVInfo)
124 m_WeaponState.m_SightsZoomFOVInfo.GetEventOnZoomChanged().Remove(OnZoomChanged);
127 m_WeaponState.Init();
131 m_WeaponState.m_Weapon = weapon;
134 Show(weapon !=
null);
140 m_WeaponState.m_WeaponUI =
WeaponUIInfo.Cast(weapon.GetUIInfo());
141 m_WeaponState.m_GrenadeUI =
GrenadeUIInfo.Cast(m_WeaponState.m_WeaponUI);
144 if (m_WeaponState.m_GrenadeUI)
146 m_WeaponState.m_eAmmoTypeFlags = m_WeaponState.m_GrenadeUI.GetAmmoTypeFlags();
147 m_WeaponState.m_bHasSpecialAmmo = !(m_WeaponState.m_eAmmoTypeFlags == 0 || m_WeaponState.m_eAmmoTypeFlags &
EAmmoType.FMJ);
149 m_WeaponState.m_MagazineConfig = m_WeaponState.m_GrenadeUI.m_MagIndicator;
153 IEntity e = weapon.GetOwner();
156 m_WeaponState.m_bIsExplosive =
true;
158 m_WeaponState.m_bIsExplosive =
false;
161 m_WeaponState.m_Sights = GetSights();
162 m_WeaponState.m_SightsZoomFOVInfo =
null;
164 if (m_WeaponState.m_Sights)
167 if (m_WeaponState.m_SightsZoomFOVInfo)
168 m_WeaponState.m_SightsZoomFOVInfo.GetEventOnZoomChanged().Insert(OnZoomChanged);
171 #ifndef WEAPON_INFO_BLOCK_WATERFALL_EVENTS
172 OnMuzzleChanged_init(weapon);
173 OnADSChanged_init(weapon);
183 muzzle = weapon.GetCurrentMuzzle();
185 #ifdef WEAPON_INFO_DEBUG_WATERFALL_EVENTS
186 Print(
"OnMuzzleChanged_init");
187 Print(
string.Format(
" weapon: %1", weapon));
188 Print(
string.Format(
" muzzle: %1", muzzle));
191 OnMuzzleChanged(weapon, muzzle,
null);
198 #ifdef WEAPON_INFO_DEBUG
199 _print(
"OnMuzzleChanged");
200 _print(
string.Format(
" weapon: %1", weapon));
201 _print(
string.Format(
" muzzle: %1", muzzle));
206 m_WeaponState.m_Muzzle = muzzle;
212 m_WeaponState.m_MuzzleUI =
null;
213 m_WeaponState.m_bBarrelChambered =
false;
214 m_WeaponState.m_bBarrelCanBeChambered =
false;
220 m_WeaponState.m_MuzzleUI =
MuzzleUIInfo.Cast(muzzle.GetUIInfo());
221 m_WeaponState.m_bBarrelChambered = muzzle.IsBarrelChambered(muzzle.GetCurrentBarrelIndex());
222 m_WeaponState.m_bBarrelCanBeChambered = muzzle.IsChamberingPossible();
226 UpdateWeaponNameAndCaliber(m_WeaponState);
229 #ifndef WEAPON_INFO_BLOCK_WATERFALL_EVENTS
230 OnFiremodeChanged_init(weapon, muzzle);
231 OnZeroingChanged_init(weapon);
232 OnMagazineChanged_init(weapon, muzzle);
239 BaseMagazineComponent magazine;
242 magazine = muzzle.GetMagazine();
244 #ifdef WEAPON_INFO_DEBUG_WATERFALL_EVENTS
245 _print(
"OnMagazineChanged_init");
246 _print(
string.Format(
" weapon: %1", weapon));
247 _print(
string.Format(
" muzzle: %1", muzzle));
248 _print(
string.Format(
" magazine: %1", magazine));
251 OnMagazineChanged(weapon, magazine,
null);
253 void OnMagazineChanged(
BaseWeaponComponent weapon, BaseMagazineComponent magazine, BaseMagazineComponent prevMagazine)
258 #ifdef WEAPON_INFO_DEBUG
259 _print(
"OnMagazineChanged");
260 _print(
string.Format(
" weapon: %1", weapon));
261 _print(
string.Format(
" magazine: %1", magazine));
267 m_WeaponState.m_Magazine = magazine;
270 m_WeaponState.m_MagazineUI =
MagazineUIInfo.Cast(magazine.GetUIInfo());
272 m_WeaponState.m_MagazineUI =
null;
274 if (m_WeaponState.m_MagazineUI)
276 m_WeaponState.m_eAmmoTypeFlags = m_WeaponState.m_MagazineUI.GetAmmoTypeFlags();
277 m_WeaponState.m_bHasSpecialAmmo = !(m_WeaponState.m_eAmmoTypeFlags == 0 || m_WeaponState.m_eAmmoTypeFlags &
EAmmoType.FMJ);
281 m_WeaponState.m_MagazineConfig = GetMagazineConfig(m_WeaponState);
283 #ifndef WEAPON_INFO_BLOCK_WATERFALL_EVENTS
284 OnMagazineCountChanged_init(weapon, magazine);
285 OnAmmoCountChanged_init(weapon, magazine);
289 UpdateMagazineIndicator_Textures(m_WeaponState);
290 UpdateAmmoTypeIndicator(m_WeaponState);
294 void OnMagazineCountChanged_init(
BaseWeaponComponent weapon, BaseMagazineComponent magazine)
299 muzzle = weapon.GetCurrentMuzzle();
301 #ifdef WEAPON_INFO_DEBUG_WATERFALL_EVENTS
302 _print(
"OnMagazineCountChanged_init");
303 _print(
string.Format(
" weapon: %1", weapon));
304 _print(
string.Format(
" muzzle: %1", muzzle));
305 _print(
string.Format(
" magazine: %1", magazine));
311 if (!weapon || !invManager)
313 OnMagazineCountChanged(weapon, 0,
false);
317 int magazineCount = 0;
328 m_pMagazineSearchPredicate.magWellType = magWell.Type();
329 array<IEntity> magEntities =
new array<IEntity>;
330 invManager.FindItems(magEntities, m_pMagazineSearchPredicate);
331 magazineCount = magEntities.Count();
344 m_pPrefabDataPredicate.prefabData = weapon.GetOwner().GetPrefabData();
345 array<IEntity> sameWeapons =
new array<IEntity>;
346 invManager.FindItems(sameWeapons, m_pPrefabDataPredicate);
349 magazineCount = sameWeapons.Count();
352 bool isGrenade = m_WeaponState.m_bIsExplosive;
354 OnMagazineCountChanged(weapon, magazineCount, isGrenade);
358 if (!m_WeaponState || !weapon)
361 #ifdef WEAPON_INFO_DEBUG
362 _print(
"OnMagazineCountChanged");
363 _print(
string.Format(
" weapon: %1", weapon));
364 _print(
string.Format(
" magazineCount: %1", magazineCount));
365 _print(
string.Format(
" isGrenade: %1", isGrenade));
368 BaseMagazineComponent magazine = weapon.GetCurrentMagazine();
369 m_WeaponState.m_Magazine = magazine;
374 m_WeaponState.m_iMagCount = magazineCount;
375 m_WeaponState.m_bIsExplosive = isGrenade;
381 UpdateMagazineIndicator_Textures(m_WeaponState);
382 UpdateAmmoTypeIndicator(m_WeaponState);
385 UpdateMagazineIndicator_Count(m_WeaponState);
394 muzzle = weapon.GetCurrentMuzzle();
396 #ifdef WEAPON_INFO_DEBUG_WATERFALL_EVENTS
397 _print(
"OnAmmoCountChanged_init");
398 _print(
string.Format(
" weapon: %1", weapon));
399 _print(
string.Format(
" muzzle: %1", muzzle));
400 _print(
string.Format(
" magazine: %1", magazine));
406 ammoCount = magazine.GetAmmoCount();
408 bool isBarrelChambered =
false;
411 isBarrelChambered = muzzle.IsCurrentBarrelChambered();
413 OnAmmoCountChanged(weapon, muzzle, magazine, ammoCount, isBarrelChambered);
420 #ifdef WEAPON_INFO_DEBUG
421 _print(
"OnAmmoCountChanged");
422 _print(
string.Format(
" weapon: %1", weapon));
423 _print(
string.Format(
" muzzle: %1", muzzle));
424 _print(
string.Format(
" magazine: %1", magazine));
425 _print(
string.Format(
" ammoCount: %1", ammoCount));
426 _print(
string.Format(
" isBarrelChambered: %1", isBarrelChambered));
432 m_WeaponState.m_bBarrelChambered = isBarrelChambered;
434 m_WeaponState.m_iMagAmmoCount = ammoCount;
435 m_WeaponState.m_iMagMaxAmmoCount = 1;
438 m_WeaponState.m_iMagMaxAmmoCount = magazine.GetMaxAmmoCount();
440 if (m_WeaponState.m_iMagMaxAmmoCount == 0)
441 m_WeaponState.m_iMagMaxAmmoCount = 1;
443 m_WeaponState.m_fMagAmmoPerc = m_WeaponState.m_iMagAmmoCount / m_WeaponState.m_iMagMaxAmmoCount;
446 UpdateMagazineIndicator_Progress(m_WeaponState);
448 UpdateBulletInChamberIndicator(m_WeaponState);
457 firemode = muzzle.GetCurrentFireMode();
459 #ifdef WEAPON_INFO_DEBUG_WATERFALL_EVENTS
460 _print(
"OnFiremodeChanged_init");
461 _print(
string.Format(
" weapon: %1", weapon));
462 _print(
string.Format(
" muzzle: %1", muzzle));
463 _print(
string.Format(
" firemode: %1", firemode));
466 OnFiremodeChanged(weapon, muzzle, firemode);
474 #ifdef WEAPON_INFO_DEBUG
475 _print(
"OnFiremodeChanged");
476 _print(
string.Format(
" weapon: %1", weapon));
477 _print(
string.Format(
" muzzle: %1", muzzle));
478 _print(
string.Format(
" firemode: %1", firemode));
485 m_WeaponState.m_FireModeType = firemode.GetFiremodeType();
489 UpdateFireModeIndicator(m_WeaponState);
498 zeroing = weapon.GetCurrentSightsZeroing();
500 #ifdef WEAPON_INFO_DEBUG_WATERFALL_EVENTS
501 _print(
"OnZeroingChanged_init");
502 _print(
string.Format(
" weapon: %1", weapon));
503 _print(
string.Format(
" zeroing: %1", zeroing));
506 OnZeroingChanged(weapon, zeroing);
513 #ifdef WEAPON_INFO_DEBUG
514 _print(
"OnZeroingChanged");
515 _print(
string.Format(
" weapon: %1", weapon));
516 _print(
string.Format(
" zeroing: %1", zeroing));
522 m_WeaponState.m_iZeroing = zeroing;
524 UpdateZeroingIndicator(m_WeaponState);
533 inADS = weapon.IsSightADSActive();
535 #ifdef WEAPON_INFO_DEBUG_WATERFALL_EVENTS
536 _print(
"OnADSChanged_init");
537 _print(
string.Format(
" weapon: %1", weapon));
538 _print(
string.Format(
" inADS: %1", inADS));
541 OnADSChanged(weapon, inADS);
548 #ifdef WEAPON_INFO_DEBUG
550 _print(
string.Format(
" weapon: %1", weapon));
551 _print(
string.Format(
" inADS: %1", inADS));
557 m_WeaponState.m_bInADS = inADS;
559 #ifndef WEAPON_INFO_BLOCK_WATERFALL_EVENTS
560 OnZoomChanged_init(weapon);
569 if (m_WeaponState.m_SightsZoomFOVInfo)
570 zoom = m_WeaponState.m_SightsZoomFOVInfo.GetCurrentZoom();
572 #ifdef WEAPON_INFO_DEBUG_WATERFALL_EVENTS
573 _print(
"OnZoomChanged_init");
574 _print(
string.Format(
" weapon: %1", weapon));
575 _print(
string.Format(
" zoom: %1", zoom));
578 OnZoomChanged(zoom, -1);
580 void OnZoomChanged(
float zoom,
float fov)
585 #ifdef WEAPON_INFO_DEBUG
587 _print(
string.Format(
" zoom: %1", zoom));
588 _print(
string.Format(
" fov: %1", fov));
594 m_WeaponState.m_fZoom = zoom;
596 UpdateZoomIndicator(m_WeaponState);
600 void OnInspectionModeChanged(
bool state)
605 #ifdef WEAPON_INFO_DEBUG
606 _print(
"OnInspectionModeChanged");
607 _print(
string.Format(
" state: %1", state));
613 m_WeaponState.m_bInInspectionMode = state;
617 void OnAttachmentChanged(WeaponComponent weapon,
bool isAttached, IEntity attachmentEntity)
622 #ifdef WEAPON_INFO_DEBUG
623 _print(
"OnAttachmentChanged");
624 _print(
string.Format(
" isAttached: %1", isAttached));
625 _print(
string.Format(
" attachmentEntity: %1", attachmentEntity));
628 SCR_2DSightsComponent sights = GetSights();
631 if (sights != m_WeaponState.m_Sights)
634 if (m_WeaponState.m_SightsZoomFOVInfo)
635 m_WeaponState.m_SightsZoomFOVInfo.GetEventOnZoomChanged().Remove(OnZoomChanged);
637 m_WeaponState.m_Sights = sights;
638 m_WeaponState.m_SightsZoomFOVInfo =
null;
640 if (m_WeaponState.m_Sights)
643 if (m_WeaponState.m_SightsZoomFOVInfo)
644 m_WeaponState.m_SightsZoomFOVInfo.GetEventOnZoomChanged().Insert(OnZoomChanged);
649 m_WeaponState.m_Sights =
null;
650 m_WeaponState.m_SightsZoomFOVInfo =
null;
657 override void DisplayUpdate(IEntity owner,
float timeSlice)
659 if (!
m_wRoot || !m_WeaponState || !m_WeaponState.m_Weapon)
668 m_bFadeInOutActive =
true;
671 if (!m_bFadeInOutActive)
674 if (m_ZeroingAnimator)
675 m_ZeroingAnimator.Update(timeSlice);
676 if (m_WeaponInfoPanelAnimator)
677 m_WeaponInfoPanelAnimator.Update(timeSlice);
681 m_bFadeInOutActive = m_WeaponInfoPanelAnimator.IsRunning() || m_ZeroingAnimator.IsRunning();
689 #ifdef WEAPON_INFO_DEBUG_STATES
690 string weaponStateDebug =
"Weapon event flags: " + m_eWeaponStateEvent.ToString();
693 weaponStateDebug +=
"|WEAPON";
696 weaponStateDebug +=
"|MUZZLE";
699 weaponStateDebug +=
"|MAGAZINE";
702 weaponStateDebug +=
"|AMMOCOUNT";
705 weaponStateDebug +=
"|FIREMODE";
708 weaponStateDebug +=
"|ZEROING";
711 weaponStateDebug +=
"|ADS";
714 weaponStateDebug +=
"|MAGAZINE_COUNT";
717 weaponStateDebug +=
"|INSPECTION";
720 weaponStateDebug +=
"|ZOOM";
723 weaponStateDebug +=
"|MISC";
725 Print(weaponStateDebug);
730 bool isGrenade = m_WeaponState && m_WeaponState.m_bIsExplosive;
731 bool inADS = m_WeaponState && m_WeaponState.m_bInADS;
732 bool inInspection = m_WeaponState && m_WeaponState.m_bInInspectionMode;
735 bool panelVisibleEvent = m_eWeaponStateEvent != 0;
736 bool panelVisibleOverride = isGrenade || inADS || inInspection;
737 if (panelVisibleEvent || panelVisibleOverride)
738 m_WeaponInfoPanelAnimator.FadeIn(!panelVisibleOverride);
741 bool zeroingWidgetHasText = !
m_Widgets.m_ZeroingText.GetText().IsEmpty();
743 bool zeroingVisibleOverride = inADS || inInspection;
744 if (zeroingWidgetHasText && (zeroingVisibleEvent || zeroingVisibleOverride))
745 m_ZeroingAnimator.FadeIn(!zeroingVisibleOverride);
749 SCR_2DSightsComponent GetSights()
756 return SCR_2DSightsComponent.Cast(sights);
770 if (!state.m_MuzzleUI)
778 if (state.m_Magazine)
781 config = state.m_MagazineUI.m_MagIndicator;
784 config = state.m_MuzzleUI.m_MagIndicator;
791 config = state.m_MuzzleUI.m_MagIndicator;
798 if (state.m_WeaponUI)
800 config = state.m_WeaponUI.m_MagIndicator;
817 if (!state.m_MagazineConfig)
818 state.m_MagazineConfig = GetMagazineConfig(state);
824 m_Widgets.m_MagazineIndicator.SetVisible(
false);
828 m_Widgets.m_MagazineIndicator.SetVisible(
true);
830 if (config.m_bProgressBar)
832 SetWidgetImage(
m_Widgets.m_MagazineOutline, config.m_sImagesetIcons, config.m_sOutline, SCALE_MAGAZINE);
833 SetWidgetImage(
m_Widgets.m_MagazineBackground, config.m_sImagesetIcons, config.m_sBackground, SCALE_MAGAZINE);
834 SetWidgetImage(
m_Widgets.m_MagazineGlow, config.m_sImagesetGlows, config.m_sBackground, SCALE_MAGAZINE);
838 SetWidgetImage(
m_Widgets.m_MagazineOutline, config.m_sImagesetIcons, config.m_sOutline, SCALE_MAGAZINE);
840 SetWidgetImage(
m_Widgets.m_MagazineGlow, config.m_sImagesetGlows, config.m_sOutline, SCALE_MAGAZINE);
844 SetWidgetImage(
m_Widgets.m_ReloadBackground, config.m_sImagesetIcons, config.m_sProgress, SCALE_MAGAZINE);
845 m_Widgets.m_ReloadBackground.SetVisible(
false);
846 SetWidgetImage(
m_Widgets.m_ReloadOutline, config.m_sImagesetIcons, config.m_sOutline, SCALE_MAGAZINE);
847 m_Widgets.m_ReloadOutline.SetVisible(
false);
851 m_Widgets.m_MagazineProgress.SetVisible(config.m_bProgressBar && state.m_Magazine);
852 m_Widgets.m_MagazineBackground.SetVisible(config.m_bProgressBar);
853 m_Widgets.m_MagazineOutline.SetOpacity(1);
855 if (state.m_Magazine)
857 if (config.m_bProgressBar)
859 SetWidgetImage(
m_Widgets.m_MagazineProgress, config.m_sImagesetIcons, config.m_sProgress, SCALE_MAGAZINE);
860 m_Widgets.m_MagazineProgress.LoadMaskFromSet(config.m_sImagesetIcons, config.m_sProgressAlphaMask);
861 m_Widgets.m_MagazineProgress.SetMaskMode(ImageMaskMode.REGULAR);
866 if (!state.m_bIsExplosive)
867 m_Widgets.m_MagazineOutline.SetOpacity(FADED_OPACITY);
882 m_Widgets.m_MagazineProgress.SetMaskProgress(state.m_fMagAmmoPerc);
891 int count = state.m_iMagCount;
894 if (state.m_bIsExplosive)
897 string countText = count.ToString();
907 m_Widgets.m_MagCountText.SetOpacity(FADED_OPACITY);
909 if (
m_Widgets.m_MagCountText.GetText() == countText)
912 m_Widgets.m_MagCountText.SetText(countText);
924 if (state.m_bBarrelChambered)
927 m_Widgets.m_FiremodeIcon.SetOpacity(FADED_OPACITY);
936 m_Widgets.m_FiremodeIcon.SetVisible(
false);
937 m_Widgets.m_FiremodeGlow.SetVisible(
false);
939 if (state.m_Muzzle && state.m_MuzzleUI && state.m_MuzzleUI.ShowFiremodeIcon())
941 auto fm = state.m_FireModeType;
942 string icon = state.m_MuzzleUI.GetFiremodeIconName(fm);
944 if (icon !=
string.Empty)
946 SetWidgetImage(
m_Widgets.m_FiremodeIcon, state.m_MuzzleUI.GetFiremodeIconImageset(), icon, SCALE_FIREMODE);
947 SetWidgetImage(
m_Widgets.m_FiremodeGlow, state.m_MuzzleUI.GetFiremodeGlowImageset(), icon, SCALE_FIREMODE);
949 m_Widgets.m_FiremodeIcon.SetVisible(
true);
950 m_Widgets.m_FiremodeGlow.SetVisible(
true);
963 int zeroing = state.m_iZeroing;
968 m_Widgets.m_ZeroingText.SetText(
string.Empty);
973 string sZeroing =
string.Format(
"%1 m", zeroing);
974 m_Widgets.m_ZeroingText.SetText(sZeroing);
986 float zoom = state.m_fZoom;
988 if (zoom <= 0 || !state.m_bInADS)
991 m_Widgets.m_OpticsText.SetText(
string.Empty);
995 string sZoom = zoom.ToString(-1,1);
996 sZoom =
string.Format(
"%1 ×", sZoom);
1011 if (!state.m_bHasSpecialAmmo || (!state.m_MagazineUI && !state.m_GrenadeUI))
1017 string sAmmoTypeText;
1018 bool bShowAmmoTypeText;
1020 if (state.m_GrenadeUI)
1022 sAmmoTypeText = state.m_GrenadeUI.GetAmmoType();
1023 bShowAmmoTypeText = state.m_GrenadeUI.ShowAmmoTypeText();
1027 sAmmoTypeText = state.m_MagazineUI.GetAmmoType();
1028 bShowAmmoTypeText = state.m_MagazineUI.ShowAmmoTypeText();
1031 if (!bShowAmmoTypeText)
1034 m_Widgets.m_AmmoTypeText.SetText(sAmmoTypeText);
1044 m_Widgets.m_AmmoType_Incendiary.SetVisible(state.m_eAmmoTypeFlags &
EAmmoType.INCENDIARY);
1054 if (!state || !
m_Widgets || !state.m_WeaponUI)
1058 bool showName = state.m_WeaponUI.ShowWeaponName();
1061 m_Widgets.m_WeaponName.SetText(state.m_WeaponUI.GetName());
1063 m_Widgets.m_WeaponName.SetVisible(showName);
1068 if (state.m_MuzzleUI)
1070 showCaliber = state.m_MuzzleUI.ShowCaliber();
1073 m_Widgets.m_Caliber.SetText(state.m_MuzzleUI.GetCaliber());
1076 m_Widgets.m_Caliber.SetVisible(showCaliber);
1085 if (requiredFlag != -1 && m_eWeaponStateEvent != requiredFlag)
1088 w.SetColor(COLOR_ORANGE);
1093 void AnimateWidget_TextPopUp(Widget w,
float size,
float sizeBoosted,
EWeaponFeature requiredFlag = -1,
float speed =
UIConstants.FADE_RATE_SLOW)
1098 if (requiredFlag != -1 && m_eWeaponStateEvent != requiredFlag)
1101 float width = FrameSlot.GetSizeX(w);
1103 FrameSlot.SetSize(w, width, sizeBoosted);
1104 float widthHeight[2] = {width, size};
1105 AnimateWidget.Size(w, widthHeight, speed);
1109 override bool DisplayStartDrawInit(IEntity owner)
1111 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(owner);
1115 m_WeaponManager = BaseWeaponManagerComponent.Cast(character.FindComponent(BaseWeaponManagerComponent));
1119 m_CompartmentAccess = CompartmentAccessComponent.Cast(owner.FindComponent(CompartmentAccessComponent));
1120 if (!m_CompartmentAccess)
1128 AddEventHandlers(owner);
1131 if (m_LayoutPath ==
string.Empty)
1132 m_LayoutPath = DEFAULT_WEAPON_INFO_LAYOUT;
1138 override void DisplayStartDraw(IEntity owner)
1146 m_Widgets.m_MagazineIndicator.SetVisible(
true);
1148 if (!m_WeaponInfoPanelAnimator)
1151 if (!m_ZeroingAnimator)
1159 override void DisplayStopDraw(IEntity owner)
1161 if (m_WeaponState && m_WeaponState.m_SightsZoomFOVInfo)
1162 m_WeaponState.m_SightsZoomFOVInfo.GetEventOnZoomChanged().Remove(OnZoomChanged);
1164 m_WeaponState =
null;
1167 RemoveEventHandlers(owner);
1170 m_WeaponInfoPanelAnimator =
null;
1171 m_ZeroingAnimator =
null;
1177 void AddEventHandlers(IEntity owner)
1184 m_EventHandlerManager.RegisterScriptHandler(
"OnMagazineCountChanged",
this, OnMagazineCountChanged);
1189 m_EventHandlerManager.RegisterScriptHandler(
"OnInspectionModeChanged",
this, OnInspectionModeChanged);
1190 m_EventHandlerManager.RegisterScriptHandler(
"OnWeaponAttachmentChanged",
this, OnAttachmentChanged);
1195 void RemoveEventHandlers(IEntity owner)
1207 m_EventHandlerManager.RemoveScriptHandler(
"OnInspectionModeChanged",
this, OnInspectionModeChanged);
1217 PlayerController pc =
GetGame().GetPlayerController();
1222 IEntity playerEntity = pc.GetControlledEntity();
1229 CompartmentAccessComponent compAccess = CompartmentAccessComponent.Cast(playerEntity.FindComponent(CompartmentAccessComponent));
1234 BaseCompartmentSlot compSlot = compAccess.GetCompartment();
1239 IEntity vehEntity = compSlot.GetVehicle();
1245 vehEntity = compSlot.GetOwner();
1256 protected BaseWeaponManagerComponent GetWeaponManager(IEntity owner)
1258 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(owner);
1263 BaseWeaponManagerComponent weaponManager = BaseWeaponManagerComponent.Cast(character.FindComponent(BaseWeaponManagerComponent));
1267 return weaponManager;
1272 protected void SetWidgetImage(ImageWidget w,
string imageOrImageset,
string imageName =
"",
float scale = SCALE_DEFAULT)
1274 if (!imageName.IsEmpty())
1277 w.LoadImageFromSet(0, imageOrImageset, imageName);
1279 else if (!imageOrImageset.IsEmpty())
1282 w.LoadImageTexture(0, imageOrImageset);
1287 w.GetImageSize(0, sx, sy);
1288 w.SetSize(sx * scale, sy * scale);