Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SelectionMenuEntryIconComponent.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  [Attribute("Icon")]
5  protected string m_sIcon;
6 
7  [Attribute("255 255 255 255")]
8  protected ref Color m_cDefaultColor;
9 
10  [Attribute("255 255 255 255")]
11  protected ref Color m_cAltColor;
12 
13  protected ImageWidget m_wIcon;
14 
15  protected ResourceName m_sTexture;
16  protected string m_sImage;
17 
18  //------------------------------------------------------------------------------------------------
19  // Override
20  //------------------------------------------------------------------------------------------------
21 
22  //------------------------------------------------------------------------------------------------
23  override void HandlerAttached(Widget w)
24  {
25  super.HandlerAttached(w);
26 
27  m_wIcon = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sIcon));
28  }
29 
30  //------------------------------------------------------------------------------------------------
32  override void SetEntry(SCR_SelectionMenuEntry entry)
33  {
34  // Clear previous referenced entry
35  if (m_Entry)
36  {
37  m_Entry.GetOnIconChange().Remove(OnEntryIconChange);
38  }
39 
40  // Setup new entry
41  super.SetEntry(entry);
42 
43  if (!entry)
44  return;
45 
46  m_Entry.GetOnIconChange().Insert(OnEntryIconChange);
47  }
48 
49  //------------------------------------------------------------------------------------------------
50  // Custom
51  //------------------------------------------------------------------------------------------------
52 
53  //------------------------------------------------------------------------------------------------
54  void SetImage(ResourceName texture, string image)
55  {
56  m_sTexture = texture;
57  m_sImage = image;
58 
59  SCR_WLibComponentBase.SetTexture(m_wIcon, m_sTexture, m_sImage);
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  void SetLayoutSize(float size)
64  {
65  if (m_wSizeLayout)
66  FrameSlot.SetSize(m_wSizeLayout, size, size);
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  void SetIconColor(Color color = null)
71  {
72  if (!m_wIcon)
73  return;
74 
75  if (color == null)
76  m_wIcon.SetColor(m_cDefaultColor);
77  else
78  m_wIcon.SetColor(color);
79  }
80 
81  //------------------------------------------------------------------------------------------------
82  Color GetAltColor()
83  {
84  return Color.FromInt(m_cAltColor.PackToInt());
85  }
86 
87  //------------------------------------------------------------------------------------------------
88  // Callback
89  //------------------------------------------------------------------------------------------------
90 
91  //------------------------------------------------------------------------------------------------
92  protected void OnEntryIconChange(SCR_SelectionMenuEntry entry, ResourceName texture, string image)
93  {
94  SetImage(texture, image);
95  }
96 }
m_wIcon
protected ImageWidget m_wIcon
Definition: SCR_InventoryHitZonePointUI.c:374
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition: SCR_WLibComponentBase.c:4
SCR_SelectionMenuEntryIconComponent
Definition: SCR_SelectionMenuEntryIconComponent.c:2
m_Entry
SCR_MapJournalUI m_Entry
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_SelectionMenuEntryComponent
Definition: SCR_SelectionMenuEntryComponent.c:6
SCR_SelectionMenuEntry
Definition: SCR_SelectionMenuEntry.c:7
m_sIcon
protected string m_sIcon
Definition: SCR_InventoryHitZonePointUI.c:373