Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditboxDialogUI.c
Go to the documentation of this file.
1 //-------------------------------------------------------------------------------------------
4 {
5  const string WIDGET_EDITBOX = "EditBox";
6  const string WIDGET_WARNING = "DialogWarning";
7  const string WIDGET_TEXT_WARNING = "TxtDialogWarning";
8 
9  protected Widget m_wWarningMessage;
10  protected TextWidget m_wTxtWarningMessage;
11 
12  protected SCR_EditBoxComponent m_Editbox;
13 
14  ref ScriptInvokerString m_OnTextChange = new ScriptInvokerString();
15  ref ScriptInvokerString m_OnWriteModeLeave = new ScriptInvokerString();
16 
17  //-------------------------------------
18  // Override functions
19  //-------------------------------------
20 
21  //----------------------------------------------------------------------------------------
22  override protected void InitWidgets()
23  {
24  super.InitWidgets();
25 
26  // Get widget component
27  Widget wEditbox = m_wRoot.FindAnyWidget(WIDGET_EDITBOX);
28  if (wEditbox)
29  {
30  m_Editbox = SCR_EditBoxComponent.Cast(wEditbox.FindHandler(SCR_EditBoxComponent));
31  }
32 
33  m_wWarningMessage = m_wRoot.FindAnyWidget(WIDGET_WARNING);
34  if (m_wWarningMessage)
35  m_wTxtWarningMessage = TextWidget.Cast(m_wWarningMessage.FindAnyWidget(WIDGET_TEXT_WARNING));
36  }
37 
38  //----------------------------------------------------------------------------------------
39  override protected void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
40  {
41  super.OnMenuOpen();
42 
43  if (m_Editbox)
44  {
45  GetGame().GetWorkspace().SetFocusedWidget(m_Editbox.GetRootWidget());
46  m_Editbox.m_OnTextChange.Insert(OnTextChange);
47  m_Editbox.m_OnWriteModeLeave.Insert(OnWriteModeLeave);
48  }
49  }
50 
51  //----------------------------------------------------------------------------------------
52  protected void OnWriteModeLeave(string text)
53  {
54  m_OnWriteModeLeave.Invoke(m_Editbox.GetValue());
55  }
56 
57  //----------------------------------------------------------------------------------------
58  protected void OnTextChange(string text)
59  {
60  m_OnTextChange.Invoke(text);
61  }
62 
63  //-------------------------------------
64  // Public functions
65  //-------------------------------------
66 
67  //----------------------------------------------------------------------------------------
68  void DisplayWarningMessage(bool display)
69  {
70  if (m_wWarningMessage)
71  m_wWarningMessage.SetVisible(display);
72  }
73 
74  //----------------------------------------------------------------------------------------
75  void SetWarningMessage(string message)
76  {
77  if (!m_wWarningMessage)
78  return;
79 
80  m_wWarningMessage.SetVisible(!message.IsEmpty());
81 
82  if (m_wTxtWarningMessage)
83  m_wTxtWarningMessage.SetText(message);
84  }
85 
86  //-------------------------------------
87  // Get and set
88  //-------------------------------------
89 
90  //----------------------------------------------------------------------------------------
91  SCR_EditBoxComponent GetEditbox()
92  {
93  return m_Editbox;
94  }
95 };
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_EditboxDialogUi
Configurable editbox dialog base.
Definition: SCR_EditboxDialogUI.c:3
ScriptInvokerString
ScriptInvokerBase< ScriptInvokerStringMethod > ScriptInvokerString
Definition: SCR_ScriptInvokerHelper.c:75
SCR_ConfigurableDialogUiPreset
Configuration for a dialog.
Definition: SCR_ConfigurableDialogUI.c:809
SCR_ConfigurableDialogUi
Definition: SCR_ConfigurableDialogUI.c:13
SCR_EditBoxComponent
Definition: SCR_EditBoxComponent.c:8