DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ScriptConsoleMenuElement.c
См. документацию.
2{
3 protected Widget m_Root;
4 protected ButtonWidget m_ContextButton;
6 protected GridSpacerWidget m_ContextSubGrid;
7
8 protected int m_Id;
9 protected bool m_IsSelected;
12
13 void ScriptConsoleMenuElement(int id, Widget parent, string name, ScriptConsole scriptConsole)
14 {
15 m_Root = g_Game.GetWorkspace().CreateWidgets("gui/layouts/script_console/script_console_menu_element.layout", parent);
16 m_ContextButton = ButtonWidget.Cast(m_Root.FindAnyWidget("ContextButton"));
17 m_ContextSubGrid = GridSpacerWidget.Cast(m_Root.FindAnyWidget("ContextSubGrid"));
18 m_ButtonText = TextWidget.Cast(m_Root.FindAnyWidget("ButtonText"));
19
20 m_ButtonText.SetText(name);
21
22 m_Id = id;
23 m_ScriptConsole = scriptConsole;
24 m_Root.SetHandler(this);
25 }
26
28 {
29 return m_Root;
30 }
31
32 ButtonWidget GetButton()
33 {
34 return m_ContextButton;
35 }
36
37 GridSpacerWidget GetGrid()
38 {
39 return m_ContextSubGrid;
40 }
41
42 void HideGrid()
43 {
44 m_ContextSubGrid.Show(false);
45 }
46
48 {
49 m_ContextSubElements.Insert(subElement);
50 }
51
53 {
54 return m_ContextSubElements.Count();
55 }
56
58 {
60 {
61 if (w == subElement.GetButton())
62 return true;
63 }
64
65 return false;
66 }
67
68 void Select()
69 {
70 m_ContextButton.SetState(true);
71 m_ContextButton.SetColor(ARGB(200, 255, 255, 255));
72 m_ButtonText.SetColor(ARGB(255, 52, 152, 219));
73 m_IsSelected = true;
74 }
75
76 void Deselect()
77 {
78 m_ContextButton.SetState(false);
79 m_ContextButton.SetColor(ARGB(255, 100, 100, 100));
80 m_ButtonText.SetColor(ARGB(255, 255, 255, 255));
81 m_IsSelected = false;
82 }
83
84 void SetTextAlignment(EInputDeviceType pInputDeviceType)
85 {
86 if (pInputDeviceType == EInputDeviceType.CONTROLLER)
87 {
88 m_ButtonText.SetFlags(WidgetFlags.CENTER);
89 m_ButtonText.SetFlags(WidgetFlags.VCENTER);
90 }
91 else
92 {
93 m_ButtonText.ClearFlags(WidgetFlags.CENTER);
94 m_ButtonText.ClearFlags(WidgetFlags.VCENTER);
95 }
96 }
97
98 protected bool IsChildOfWidget(Widget child, Widget parent)
99 {
100 if (!child || !parent)
101 return false;
102
103 Widget currentParent = child.GetParent();
104 while (currentParent)
105 {
106 if (currentParent == parent)
107 return true;
108 currentParent = currentParent.GetParent();
109 }
110 return false;
111 }
112
113 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
114 {
115 super.OnMouseLeave(w, enterW, x, y);
116
117 if (w == m_ContextButton)
118 {
119 if (!m_IsSelected)
120 {
121 m_ButtonText.SetColor(ARGB(255, 255, 255, 255));
122 }
123 else
124 {
125 m_ButtonText.SetColor(ARGB(255, 52, 152, 219));
126 }
127
128 if (!IsSubElementButton(enterW) && enterW != m_ContextSubGrid && !IsChildOfWidget(enterW, m_ContextSubGrid))
129 {
130 m_ContextSubGrid.Show(false);
131 }
132
133 return true;
134 }
135
136 return false;
137 }
138
139 override bool OnMouseEnter(Widget w, int x, int y)
140 {
141 super.OnMouseEnter(w, x, y);
142
143 if (w == m_ContextButton)
144 {
145 if (!m_IsSelected)
146 m_ButtonText.SetColor(ARGB(255, 0, 0, 0));
147
148 if (m_ContextSubElements.Count())
149 m_ContextSubGrid.Show(true);
150 }
151
152 return false;
153 }
154
155 override bool OnClick(Widget w, int x, int y, int button)
156 {
157 super.OnClick(w, x, y, button);
158
159 if (w == m_ContextButton)
160 {
161 m_ScriptConsole.SelectTabByID(m_Id);
162 return true;
163 }
164
165 return false;
166 }
167}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Определения DayZGame.c:4074
Icon x
Icon y
void ScriptConsole()
Определения ScriptConsole.c:114
TextWidget m_ButtonText
Определения ScriptConsoleMenuElement.c:5
void SetTextAlignment(EInputDeviceType pInputDeviceType)
Определения ScriptConsoleMenuElement.c:84
bool IsChildOfWidget(Widget child, Widget parent)
Определения ScriptConsoleMenuElement.c:98
ButtonWidget GetButton()
Определения ScriptConsoleMenuElement.c:32
override bool OnClick(Widget w, int x, int y, int button)
Определения ScriptConsoleMenuElement.c:155
GridSpacerWidget GetGrid()
Определения ScriptConsoleMenuElement.c:37
void AddSubElement(ScriptConsoleMenuElement subElement)
Определения ScriptConsoleMenuElement.c:47
ButtonWidget m_ContextButton
Определения ScriptConsoleMenuElement.c:4
void ScriptConsoleMenuElement(int id, Widget parent, string name, ScriptConsole scriptConsole)
Определения ScriptConsoleMenuElement.c:13
bool IsSubElementButton(Widget w)
Определения ScriptConsoleMenuElement.c:57
ref array< ref ScriptConsoleMenuElement > m_ContextSubElements
Определения ScriptConsoleMenuElement.c:10
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения ScriptConsoleMenuElement.c:113
GridSpacerWidget m_ContextSubGrid
Определения ScriptConsoleMenuElement.c:6
override bool OnMouseEnter(Widget w, int x, int y)
Определения ScriptConsoleMenuElement.c:139
ScriptConsole m_ScriptConsole
Определения ScriptConsoleMenuElement.c:11
Deprecated.
Определения EnWidgets.c:657
Определения EnWidgets.c:220
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
WidgetFlags
Определения EnWidgets.c:58
EInputDeviceType
Определения input.c:3
int ARGB(int a, int r, int g, int b)
Определения proto.c:322