Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ColorComponent.c
Go to the documentation of this file.
2 {
6 };
7 
9 {
10  static Color colorNormal = Color.Green;
11  static Color colorWarning = Color.Yellow;
12  static Color colorError = Color.Red;
13 
14  //------------------------------------------------------------------------------------------------
15  static Color GetColorFromEnum(UiStyleColors color)
16  {
17  switch (color)
18  {
19  case UiStyleColors.NORMAL:
20  return colorNormal;
21  case UiStyleColors.WARNING:
22  return colorWarning;
23  case UiStyleColors.ERROR:
24  return colorError;
25  default :
26  Debug.Error("Invalid color selected");
27  }
28  return null;
29  }
30 
31  //------------------------------------------------------------------------------------------------
32  static string GetColorString(Color color)
33  {
34  return "0.5 0.5 0.5 0.5";
35  }
36 
37  //------------------------------------------------------------------------------------------------
38  static string GetColorString(UiStyleColors colorStyle)
39  {
40  return GetColorString(GetColorFromEnum(colorStyle));
41  }
42 };
43 
45 class SCR_ColorComponent : ScriptedWidgetComponent
46 {
47  [Attribute("true")]
48  protected bool m_bUseStyleValue;
49 
50  [Attribute("0", UIWidgets.ComboBox, "Color style to be applied", "", ParamEnumArray.FromEnum(UiStyleColors) )]
51  protected UiStyleColors m_eColorValue;
52 
53  protected Widget m_wRoot;
54 
55  //------------------------------------------------------------------------------------------------
56  override void HandlerAttached(Widget w)
57  {
58  m_wRoot = w;
59  if (m_bUseStyleValue)
60  ApplyColorization();
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  protected void ApplyColorization()
65  {
66  Color c = SCR_UIStyle.GetColorFromEnum(m_eColorValue);
67  m_wRoot.SetColor(c);
68  }
69 
70  //------------------------------------------------------------------------------------------------
71  bool IsUsingSyleValue()
72  {
73  return m_bUseStyleValue;
74  }
75 
76  //------------------------------------------------------------------------------------------------
77  void SetUsingStyleValue(bool enable)
78  {
79  m_bUseStyleValue = enable;
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  bool GetUsedStyle()
84  {
85  return m_eColorValue;
86  }
87 
88  //------------------------------------------------------------------------------------------------
89  void SetUsedStyle(UiStyleColors style)
90  {
91  if (style == m_eColorValue)
92  return;
93 
94  m_bUseStyleValue = style;
95  ApplyColorization();
96  }
97 };
UiStyleColors
UiStyleColors
Definition: SCR_ColorComponent.c:1
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
WARNING
@ WARNING
Definition: SCR_ColorComponent.c:4
NORMAL
@ NORMAL
Definition: SCR_ColorComponent.c:3
SCR_ColorComponent
Minimalist progress bar.
Definition: SCR_ColorComponent.c:45
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_UIStyle
Definition: SCR_ColorComponent.c:8
ERROR
@ ERROR
Definition: SCR_ColorComponent.c:5