DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ DrawConnectingLines()

void DrawConnectingLines ( int index)
protected

См. определение в файле ControlsXbox.c строка 41

42 {
45
46 map<string, ref array<int>> button_marker_groups_unflitred = new map<string, ref array<int>>;
47 map<string, ref array<int>> button_marker_groups = new map<string, ref array<int>>;
48
49 float text_widget_pos_x, text_widget_pos_y;
50 float text_widget_width, text_widget_height;
51 float dot_pos_x, dot_pos_y;
52 float dot_width, dot_height;
53 float draw_pos_x, draw_pos_y;
54
55 CanvasWidget canvas_widget = CanvasWidget.Cast(layoutRoot.FindAnyWidget("CanvasWidget_" + index));
56 canvas_widget.Clear();
57 control_mapping_info = GetControlMappingInfo();
58
59 for (int i = 0; i < m_TabScript.GetTabCount(); i++)
60 {
61 tab_array.Insert(new array<ref JsonControlMappingInfo>);
62 for (int j = 0; j < 20; j++)
63 {
64 tab_array[i].Insert(null);
65 }
66 }
67
68 // insert json info to array by index, so it is sorted
69 for (i = 0; i < control_mapping_info.Count(); i++)
70 {
71 JsonControlMappingInfo info = control_mapping_info.Get(i);
72 tab_array[info.m_TabID][info.m_TextWidgetID] = info;
73 }
74
75 // create group of buttons which are connected together with line
76 for (int l = 0; l < control_mapping_info.Count(); l++)
77 {
78 JsonControlMappingInfo info1 = control_mapping_info[l];
79 string button_name = info1.m_ButtonName;
80 int text_widget_id = info1.m_TextWidgetID;
81 if (info1.m_TabID != index)
82 {
83 continue;
84 }
85 if (!button_marker_groups_unflitred.Contains(button_name))
86 {
87 button_marker_groups_unflitred.Insert(button_name, new ref array<int>);
88 button_marker_groups_unflitred.Get(button_name).Insert(text_widget_id);
89 }
90 else
91 {
92 button_marker_groups_unflitred.Get(button_name).Insert(text_widget_id);
93 }
94 }
95
96 // we want groups which are bigger than 1
97 for (l = 0; l < button_marker_groups_unflitred.Count(); l++)
98 {
99 if (button_marker_groups_unflitred.GetElement(l).Count() > 1)
100 {
101 string key = button_marker_groups_unflitred.GetKey(l);
102 button_marker_groups.Insert(button_marker_groups_unflitred.GetKey(l), button_marker_groups_unflitred.Get(key));
103 }
104 }
105
106 Widget controls_image;
107 // hide all button markers
108 #ifdef PLATFORM_XBOX
109 controls_image = layoutRoot.FindAnyWidget("XboxControlsImage");
110 #else
111 #ifdef PLATFORM_PS4
112 controls_image = layoutRoot.FindAnyWidget("PSControlsImage");
113 #endif
114 #endif
115
116 Widget child = controls_image.GetChildren();
117 child.Show(false);
118 while (child.GetSibling())
119 {
120 child = child.GetSibling();
121 child.Show(false);
122 }
123
124 Widget panel_widget;
125 Widget button_marker_widget;
126
127 for (l = 0; l < tab_array[index].Count(); l++)
128 {
129 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + l);
130 if (tab_array[index][l] != null)
131 {
132 TextWidget text_widget = TextWidget.Cast(panel_widget.FindAnyWidget("TextWidget" + l));
133
134 string key_prefix;
135 #ifdef PLATFORM_XBOX
136 key_prefix = "xb_button_marker_";
137 #else
138 #ifdef PLATFORM_PS4
139 key_prefix = "ps_button_marker_";
140 #endif
141 #endif
142
143 button_marker_widget = layoutRoot.FindAnyWidget(key_prefix + tab_array[index][l].m_ButtonName);
144 text_widget.SetText(tab_array[index][l].m_InfoText);
145 panel_widget.Show(true);
146 button_marker_widget.Show(true);
147 panel_widget.Update();
148 if (!button_marker_groups.Contains(tab_array[index][l].m_ButtonName))
149 {
150 panel_widget.GetScreenPos(text_widget_pos_x, text_widget_pos_y);
151 panel_widget.GetScreenSize(text_widget_width,text_widget_height);
152
153 button_marker_widget.GetScreenPos(dot_pos_x, dot_pos_y);
154 button_marker_widget.GetScreenSize(dot_width, dot_height);
155
156 draw_pos_y = text_widget_pos_y + text_widget_height / 2;
157 if (l < 10)
158 {
159 draw_pos_x = text_widget_pos_x + text_widget_width - 1;
160 }
161 else
162 {
163 draw_pos_x = text_widget_pos_x;
164 }
165 canvas_widget.DrawLine(draw_pos_x, draw_pos_y, dot_pos_x+dot_width/2, draw_pos_y, 2, ARGBF(0.6, 1, 1, 1));
166 canvas_widget.DrawLine(dot_pos_x+dot_width/2, draw_pos_y, dot_pos_x+dot_width/2, dot_pos_y+dot_height/2, 2, ARGBF(0.6, 1, 1, 1));
167 }
168 }
169 else
170 {
171 panel_widget.Show(false);
172 }
173 panel_widget.Update();
174 }
175
176 // draw connecting lines
177 for (l = 0; l < button_marker_groups.Count(); l++)
178 {
179 text_widget_pos_x = 0;
180 text_widget_pos_y = 0;
181 text_widget_width = 0;
182 text_widget_height = 0;
183 float group_point_x = 0, group_point_y = 0;
184 float first_x = 0, first_y = 0;
185
186 ref array<int> element = button_marker_groups.GetElement(l);
187 string key_name = button_marker_groups.GetKey(l);
188 #ifdef PLATFORM_XBOX
189 key_prefix = "xb_button_marker_";
190 #else
191 #ifdef PLATFORM_PS4
192 key_prefix = "ps_button_marker_";
193 #endif
194 #endif
195 button_marker_widget = layoutRoot.FindAnyWidget(key_prefix + key_name);
196
197 for (int g = 0; g < element.Count(); g++)
198 {
199 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[g]);
200
201 panel_widget.GetScreenPos(text_widget_pos_x, text_widget_pos_y);
202 panel_widget.GetScreenSize(text_widget_width, text_widget_height);
203
204 if (g == 0)
205 {
206 if (element[0] < 10)
207 {
208 first_x = text_widget_pos_x + text_widget_width +50;
209 }
210 else
211 {
212 first_x = text_widget_pos_x - 50;
213 }
214
215 first_y = text_widget_pos_y + text_widget_height/2;
216 }
217
218 group_point_x += text_widget_pos_x;
219 group_point_y += text_widget_pos_y;
220 if (element[0] < 10)
221 {
222 canvas_widget.DrawLine(text_widget_pos_x + text_widget_width - 1, text_widget_pos_y + text_widget_height/2, text_widget_pos_x + text_widget_width +50, text_widget_pos_y + text_widget_height/2, 2, ARGBF(0.6, 1, 1, 1));
223 }
224 else
225 {
226 canvas_widget.DrawLine(text_widget_pos_x, text_widget_pos_y + text_widget_height/2, text_widget_pos_x - 50, text_widget_pos_y + text_widget_height/2, 2, ARGBF(0.6, 1, 1, 1));
227 }
228 }
229 if (element[0] < 10)
230 {
231 group_point_x = group_point_x/element.Count() + text_widget_width + 50;
232 }
233 else
234 {
235 group_point_x = group_point_x/element.Count() - 50;
236 }
237
238 if (element.Count() % 2 == 0)
239 {
240 group_point_y = ((text_widget_pos_y + text_widget_height/2) - first_y) / 2 + first_y;
241 }
242 else
243 {
244 float text_widget_pos_x_center, text_widget_pos_y_center;
245 float text_widget_width_center, text_widget_height_center;
246
247 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[1]);
248
249 panel_widget.GetScreenPos(text_widget_pos_x_center, text_widget_pos_y_center);
250 panel_widget.GetScreenSize(text_widget_width_center, text_widget_height_center);
251
252 group_point_y = text_widget_pos_y_center + text_widget_height_center / 2;
253 }
254
255 button_marker_widget.GetScreenPos(dot_pos_x, dot_pos_y);
256 button_marker_widget.GetScreenSize(dot_width, dot_height);
257
258 canvas_widget.DrawLine(group_point_x, group_point_y, dot_pos_x+dot_width/2, group_point_y, 2, ARGBF(0.6, 1, 1, 1));
259 canvas_widget.DrawLine(dot_pos_x+dot_width/2, group_point_y, dot_pos_x+dot_width/2, dot_pos_y, 2, ARGBF(0.6, 1, 1, 1));
260
261 if (element[0] < 10)
262 {
263 canvas_widget.DrawLine(first_x, first_y, text_widget_pos_x + text_widget_width +50, text_widget_pos_y + text_widget_height/2, 2, ARGBF(0.6, 1, 1, 1));
264 }
265 else
266 {
267 canvas_widget.DrawLine(first_x, first_y, text_widget_pos_x - 50, text_widget_pos_y + text_widget_height/2, 2, ARGBF(0.6, 1, 1, 1));
268 }
269 }
270 }
TabberUI m_TabScript
Определения ControlsXbox.c:21
array< ref JsonControlMappingInfo > GetControlMappingInfo()
Определения ControlsXbox.c:272
map
Определения ControlsXboxNew.c:4
int m_TabID
Определения ControlsXbox.c:7
int m_TextWidgetID
Определения ControlsXbox.c:8
string m_ButtonName
Определения ControlsXbox.c:9
Определения EnWidgets.c:220
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native void DrawLine(float x1, float y1, float x2, float y2, float width, int color)
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Определения proto.c:332

Перекрестные ссылки ARGBF(), Widget::DrawLine(), UIScriptedMenu::GetControlMappingInfo(), JsonControlMappingInfo::m_ButtonName, JsonControlMappingInfo::m_TabID, m_TabScript и JsonControlMappingInfo::m_TextWidgetID.

Используется в Init().