Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditBoxSearchComponent.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
4 [Attribute("1")]
5 protected bool m_bColorizeText;
6
7 [Attribute(UIColors.GetColorAttribute(UIColors.NEUTRAL_ACTIVE_STANDBY), UIWidgets.ColorPicker)]
8 protected ref Color m_cDefault;
9
10 [Attribute(UIColors.GetColorAttribute(UIColors.HIGHLIGHTED), UIWidgets.ColorPicker)]
11 protected ref Color m_cFocused;
12
13 [Attribute(UIColors.GetColorAttribute(UIColors.CONTRAST_COLOR), UIWidgets.ColorPicker)]
14 protected ref Color m_cSearched;
15
16 [Attribute()]
17 protected string m_sMessage;
18
19 [Attribute("1", desc: "Should the message be hidden if there's text in the search bar")]
20 protected bool m_bHideMessageOnSearch;
21
22 protected ref array<Widget> m_aColorizedElements = {};
23 protected SCR_ESearchBoxState m_eState;
24 protected bool m_bIsFilterActive;
25
27 protected SCR_ModularButtonComponent m_MessageButton;
28 protected string m_sLastSearch;
29
30 //------------------------------------------------------------------------------------------------
31 override protected void HandlerAttached(Widget w)
32 {
33 super.HandlerAttached(w);
34
35 m_wMessage = RichTextWidget.Cast(m_wRoot.FindAnyWidget("EditBoxMessage"));
36 if (m_wMessage)
38
41
44
45 // Message button
46 Widget messageButton = m_wRoot.FindAnyWidget("EditBoxMessageButton");
47 if (messageButton)
48 m_MessageButton = SCR_ModularButtonComponent.FindComponent(messageButton);
49
51 m_MessageButton.m_OnClicked.Insert(OnInternalButtonClicked);
52
54
55 m_wBorder.SetVisible(!m_bColorizeText);
56
57 UpdateWidgets(false);
58 }
59
60 //------------------------------------------------------------------------------------------------
61 override bool OnMouseEnter(Widget w, int x, int y)
62 {
63 // Moving from the write icon button to the edit field will trigger OnMouseEnter, which we don't want if we're in write mode already
64 if (IsInWriteMode())
65 return false;
66
67 return super.OnMouseEnter(w, x, y);
68 }
69
70 //------------------------------------------------------------------------------------------------
71 override void OnHandlerFocus()
72 {
73 super.OnHandlerFocus();
74
75 m_eState = SCR_ESearchBoxState.FOCUSED;
77 }
78
79 //------------------------------------------------------------------------------------------------
80 override void OnHandlerFocusLost()
81 {
82 // On PC, changing focus doubles as confirmation
85
86 super.OnHandlerFocusLost();
87
89 m_eState = SCR_ESearchBoxState.SEARCHED;
90 else
91 m_eState = SCR_ESearchBoxState.DEFAULT;
92
94 }
95
96 //------------------------------------------------------------------------------------------------
97 override protected void OnConfirm(Widget w)
98 {
100 super.OnConfirm(w);
101
102 m_bIsFilterActive = GetValue() != string.Empty;
104 }
105
106 //------------------------------------------------------------------------------------------------
107 override void UpdateInteractionState(bool forceDisabled)
108 {
109 super.UpdateInteractionState(forceDisabled);
110
111 if (!m_wMessage)
112 return;
113
114 bool hideMessage = m_bHideMessageOnSearch && (m_bIsInWriteMode || !GetEditBoxText().IsEmpty());
115
116 m_wMessage.SetVisible(!hideMessage);
117 }
118
119 //------------------------------------------------------------------------------------------------
120 protected void UpdateWidgets(bool animate = true)
121 {
122 Color color;
123
124 switch (m_eState)
125 {
126 case SCR_ESearchBoxState.FOCUSED:
127 color = m_cFocused;
128 break;
129
130 case SCR_ESearchBoxState.SEARCHED:
131 color = m_cSearched;
132 break;
133
134 default:
135 color = m_cDefault;
136 break;
137 }
138
139 foreach (Widget element : m_aColorizedElements)
140 {
141 if (animate)
143 else
144 element.SetColor(color);
145 }
146 }
147
148 //------------------------------------------------------------------------------------------------
149 bool SetMessage(string message)
150 {
152 return false;
153
154 m_MessageButton.SetVisible(!message.IsEmpty());
155
156 if (!message.IsEmpty())
157 m_wMessage.SetTextFormat(message);
158
159 return true;
160 }
161
162 //------------------------------------------------------------------------------------------------
165 static SCR_EditBoxSearchComponent GetEditBoxSearchComponent(string name, Widget parent, bool searchAllChildren = true)
166 {
168 SCR_WLibComponentBase.GetComponent(SCR_EditBoxSearchComponent, name, parent, searchAllChildren)
169 );
170 return comp;
171 }
172}
173
174//------------------------------------------------------------------------------------------------
175enum SCR_ESearchBoxState
176{
179 SEARCHED
180}
bool IsPlatformGameConsole()
Definition game.c:1357
ArmaReforgerScripted GetGame()
Definition game.c:1398
Widget m_wRoot
SCR_NewSessionToolbarAction SCR_EditorToolbarAction OnConfirm()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void UpdateWidgets()
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
Definition Color.c:13
override void UpdateInteractionState(bool forceDisabled)
override bool OnMouseEnter(Widget w, int x, int y)
SCR_ModularButtonComponent m_MessageButton
static SCR_EditBoxSearchComponent GetEditBoxSearchComponent(string name, Widget parent, bool searchAllChildren=true)
Base class for all final Reforger interactive elements.
@ DEFAULT
Use currently set main RT format (based on game options).
SCR_FieldOfViewSettings Attribute
@ FOCUSED
Entity is focused (as opposed to HOVER, multiple entities can be focused, e.g., when hovering over a ...