Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SelectionMenuEntryPreviewComponent.c
Go to the documentation of this file.
1 /*
2 Selsection menu entry widget component for displaying 3d rendered objects
3 */
4 
5 //------------------------------------------------------------------------------------------------
7 {
8  protected const float DEFAULT_FOV = 10;
9 
10  [Attribute("ItemPreview")]
11  protected string m_sPreviewItem;
12 
13  [Attribute("ItemShadow", desc: "Reference to Item Shadow")]
14  protected string m_sItemShadow;
15 
16  [Attribute("FallbackIcon")]
17  protected string m_sFallbackIcon;
18 
19  [Attribute(UIColors.GetColorAttribute(UIColors.NEUTRAL_INFORMATION), UIWidgets.ColorPicker, desc: "Default color for Item Shadow")]
20  protected ref Color m_DefaulItemColor;
21 
22  [Attribute(UIColors.GetColorAttribute(UIColors.NEUTRAL_INFORMATION), UIWidgets.ColorPicker, desc: "Medical color for Item Shadow")]
23  protected ref Color m_MedicalItemColor;
24 
25 
26  protected ItemPreviewWidget m_wPreviewItem;
27  protected ImageWidget m_wItemShadow;
28  protected ImageWidget m_wFallbackIcon;
29 
30  protected IEntity m_Item;
31  protected PreviewRenderAttributes m_PreviewAttributes;
32 
33  //------------------------------------------------------------------------------------------------
34  override void HandlerAttached(Widget w)
35  {
36  super.HandlerAttached(w);
37 
38  m_wPreviewItem = ItemPreviewWidget.Cast(m_wRoot.FindAnyWidget(m_sPreviewItem));
39  m_wItemShadow = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sItemShadow));
40  m_wFallbackIcon = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sFallbackIcon));
41  }
42 
43  //------------------------------------------------------------------------------------------------
45  void SetPreviewItem(IEntity item)
46  {
47  if (!m_wPreviewItem || ! m_wFallbackIcon)
48  {
49  Print("[SCR_SelectionMenuEntryPreviewComponent] - missing widgets!", LogLevel.DEBUG);
50  return;
51  }
52 
53  // Visibility
54  m_wPreviewItem.SetVisible(item != null);
55  m_wItemShadow.SetVisible(item != null);
56  m_wFallbackIcon.SetVisible(!item);
57 
58  m_Item = item;
59 
60  if (!item)
61  return;
62 
63 
64  // Get manager and render preview
65  ChimeraWorld world = ChimeraWorld.CastFrom(item.GetWorld());
66  if (!world)
67  return;
68 
69  ItemPreviewManagerEntity manager = world.GetItemPreviewManager();
70  if (!manager)
71  return;
72 
73  // Set rendering and preview properties
74  SetupPreviewAttributes(m_PreviewAttributes);
75  manager.SetPreviewItem(m_wPreviewItem, item, m_PreviewAttributes);
76  m_wPreviewItem.SetResolutionScale(1, 1);
77  }
78 
79  //------------------------------------------------------------------------------------------------
81  protected void SetupPreviewAttributes(out PreviewRenderAttributes preview)
82  {
83  if (!m_Item)
84  return;
85 
86  // Inventory item cmp
88  m_Item.FindComponent(InventoryItemComponent));
89 
90  if (!invetoryItem)
91  return;
92 
93  preview = PreviewRenderAttributes.Cast(
94  invetoryItem.FindAttribute(PreviewRenderAttributes));
95 
96  // Get custom radial attribute
98  invetoryItem.FindAttribute(SCR_SelectionMenuPreviewAttributes));
99 
100  if (preview && menuPreview)
101  {
102  preview.ZoomCamera(10, menuPreview.m_fCustomFov, menuPreview.m_fCustomFov);
103 
104  // Change widget size
105  if (preview && m_wSizeLayout && menuPreview.m_fIconSizeXMultiplier != -1)
106  {
107  float size = m_fOriginalSize * menuPreview.m_fIconSizeXMultiplier;
108  FrameSlot.SetSize(m_wSizeLayout, size, size);
109 
110  m_fAdjustedSize = size;
111  }
112 
113  // Colorize Item shadow
114  if (menuPreview.m_bShowMedicalColor == true)
115  m_wItemShadow.SetColor(m_MedicalItemColor);
116  else
117  m_wItemShadow.SetColor(m_DefaulItemColor);
118  }
119  else
120  {
121  m_wItemShadow.SetColor(m_DefaulItemColor);
122  }
123  }
124 }
ChimeraWorld
Definition: ChimeraWorld.c:12
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
m_Item
NewsFeedItem m_Item
Definition: SCR_NewsSubMenu.c:2
PreviewRenderAttributes
Definition: PreviewRenderAttributes.c:12
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_SelectionMenuPreviewAttributes
Definition: SCR_SelectionMenu.c:867
Attribute
typedef Attribute
Post-process effect of scripted camera.
UIColors
Definition: Constants.c:16
SCR_SelectionMenuEntryComponent
Definition: SCR_SelectionMenuEntryComponent.c:6
InventoryItemComponent
Definition: InventoryItemComponent.c:12
ItemPreviewWidget
Definition: ItemPreviewWidget.c:12
SCR_SelectionMenuEntryPreviewComponent
Definition: SCR_SelectionMenuEntryPreviewComponent.c:6