DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ScriptConsoleSoundsTab.c
См. документацию.
2{
4 protected static float DEBUG_MAP_ZOOM = 1;
5 protected vector m_MapPos;
6 protected static int m_SelectedID;
7 protected static string m_SelectedSoundEventType;
8 protected static string m_SelectedAttachments;
9
10 protected ButtonWidget m_SetETSoundButton;
11 protected ButtonWidget m_SetETSoundWeaponButton;
12 protected ButtonWidget m_SetETSoundAttachmentButton;
13 protected ButtonWidget m_SetETSoundVoiceButton;
14 protected ButtonWidget m_PlaySoundEventButton;
15 protected ButtonWidget m_CopySoundset;
16 protected ButtonWidget m_PlaySoundset;
17 protected ButtonWidget m_PlaySoundsetLooped;
18 protected ButtonWidget m_StopSoundset;
19
22 protected TextListboxWidget m_SoundsTextListbox;
23
24 protected static EffectSound m_SoundSet;
25 protected ref Timer m_RefreshFilterTimer = new Timer();
26
31
32 protected ImageWidget m_BBackgroundSound;
33 protected ImageWidget m_BBackgroundSoundWeapon;
34 protected ImageWidget m_BBackgroundSoundAttachment;
35 protected ImageWidget m_BBackgroundSoundVoice;
36 protected ImageWidget m_SelectedBackground;
37
38 protected CheckBoxWidget m_CheckBoxShoulderAtt;
39 protected CheckBoxWidget m_CheckBoxBodyAtt;
40 protected CheckBoxWidget m_CheckBoxBackAtt;
41
42 override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
43 {
44 super.InitializeTab(root, console, button, parent);
45
46 m_MouseCurPos = TextWidget.Cast(root.FindAnyWidget("MapSoundsPos"));
47 m_MapDistWidget = TextWidget.Cast(root.FindAnyWidget("MapSoundsDistance"));
48 m_MapHeadingWidget = TextWidget.Cast(root.FindAnyWidget("MapHeadingSounds"));
49
50 m_SetETSoundButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundButton"));
51 m_SetETSoundWeaponButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundWeaponButton"));
52 m_SetETSoundAttachmentButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundAttachmentButton"));
53 m_SetETSoundVoiceButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundVoiceButton"));
54 m_PlaySoundEventButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundPlayButton"));
55 m_SoundEventIDBox = EditBoxWidget.Cast(root.FindAnyWidget("SoundIDEditBox"));
56 m_CheckBoxShoulderAtt = CheckBoxWidget.Cast(root.FindAnyWidget("CheckBoxShoulderAtt"));
57 m_CheckBoxBodyAtt = CheckBoxWidget.Cast(root.FindAnyWidget("CheckBoxBodyAtt"));
58 m_CheckBoxBackAtt = CheckBoxWidget.Cast(root.FindAnyWidget("CheckBoxBackAtt"));
59 m_BBackgroundSound = ImageWidget.Cast(root.FindAnyWidget("SoundEventType"));
60 m_BBackgroundSoundWeapon = ImageWidget.Cast(root.FindAnyWidget("SoundEventType0"));
61 m_BBackgroundSoundAttachment = ImageWidget.Cast(root.FindAnyWidget("SoundEventType1"));
62 m_BBackgroundSoundVoice = ImageWidget.Cast(root.FindAnyWidget("SoundEventType2"));
63
64 m_CopySoundset = ButtonWidget.Cast(root.FindAnyWidget("SoundsetCopy"));
65 m_PlaySoundset = ButtonWidget.Cast(root.FindAnyWidget("PlaySoundset"));
66 m_PlaySoundsetLooped = ButtonWidget.Cast(root.FindAnyWidget("PlaySoundsetLooped"));
67 m_StopSoundset = ButtonWidget.Cast(root.FindAnyWidget("StopSoundset"));
68 m_DebugMapWidget = MapWidget.Cast(root.FindAnyWidget("MapSounds"));
69
70 m_SoundFilter = EditBoxWidget.Cast(root.FindAnyWidget("SoundsFilter"));
71 m_SoundsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("SoundsList"));
72
73 m_SoundFilter.SetText(m_ConfigDebugProfile.GetSoundsetFilter());
74
75
77
78 if (g_Game.GetPlayer())
79 {
81 m_DebugMapWidget.SetMapPos(g_Game.GetPlayer().GetWorldPosition());
82 SetMapPos(g_Game.GetPlayer().GetWorldPosition());
83 }
84
85 // reopen update
86 m_SoundEventIDBox.SetText(m_SelectedID.ToString());
87
88 if (m_SelectedSoundEventType == "Sound")
90 else if (m_SelectedSoundEventType == "SoundWeapon")
92 else if (m_SelectedSoundEventType == "SoundAttachment")
94 else if (m_SelectedSoundEventType == "SoundVoice")
96
97 string lastSelection = m_SelectedAttachments;
98 if (lastSelection.Contains("shoulder"))
99 m_CheckBoxShoulderAtt.SetChecked(true);
100 if (lastSelection.Contains("body"))
101 m_CheckBoxBodyAtt.SetChecked(true);
102 if (lastSelection.Contains("back"))
103 m_CheckBoxBackAtt.SetChecked(true);
104
105 }
106
108 {
109 DEBUG_MAP_ZOOM = m_DebugMapWidget.GetScale();
110 }
111
112 override bool OnChange(Widget w, int x, int y, bool finished)
113 {
114 super.OnChange(w, x, y, finished);
115
116 if (w == m_SoundFilter)
117 {
118 m_RefreshFilterTimer.Run(0.85, this, "ChangeFilterSound", null, false);
119 return true;
120 }
121 return false;
122 }
123
125 {
126 if(!g_Game.GetPlayer())
127 return;
128 int x,y;
129 GetMousePos(x,y);
130 vector mousePos, worldPos;
131 mousePos[0] = x;
132 mousePos[1] = y;
133 worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
134 vector playerPos = g_Game.GetPlayer().GetWorldPosition();
135 if (GetMapPos() != playerPos)
136 worldPos = GetMapPos();
137 worldPos[1] = g_Game.SurfaceY(worldPos[0], worldPos[2]);
138
139 if (m_MouseCurPos)
140 {
141 m_MouseCurPos.SetText("Mouse: "+ MiscGameplayFunctions.TruncateToS(worldPos[0]) +", "+ MiscGameplayFunctions.TruncateToS(worldPos[1]) +", "+ MiscGameplayFunctions.TruncateToS(worldPos[2]));
142 }
143 if (m_MapDistWidget && g_Game.GetPlayer())
144 {
145 float dst = (worldPos - playerPos).Length();
146
147 m_MapDistWidget.SetText("Distance: " + MiscGameplayFunctions.TruncateToS(dst));
148 }
150 {
151 vector playerCamDir = g_Game.GetCurrentCameraDirection();
152 float heading = Math3D.AngleFromPosition(playerPos, playerCamDir, worldPos) * Math.RAD2DEG;
153 m_MapHeadingWidget.SetText("Heading:" +heading.ToString());
154 }
155 }
156
157 protected void PrepareFilters(string filter, out TStringArray filters)
158 {
159 filter.Trim();
160 filter.ToLower();
161
162 filters = new TStringArray;
163 TStringArray rawFilters = new TStringArray;
164 filter.Split(" ", rawFilters);
165
166 foreach (int i, string f:rawFilters)
167 {
168 filters.Insert(f);
169
170 }
171 }
172
173 // this is a 95% of the code of the function of the same name inside ScriptConsole.c
174 protected void ChangeFilter(TStringArray classes, TextListboxWidget widget, EditBoxWidget filterWidget, int categoryMask = -1, bool ignoreScope = false)
175 {
176 widget.ClearItems();
177
178 TStringArray filters;
179 PrepareFilters(filterWidget.GetText(),filters);
180
182
183 TStringArray itemsArray = TStringArray();
184
185 for (int i = 0; i < classes.Count(); i++)
186 {
187 string config_path = classes.Get(i);
188
189 int objects_count = g_Game.ConfigGetChildrenCount(config_path);
190 for (int j = 0; j < objects_count; j++)
191 {
192 string child_name;
193 bool add = false;
194 g_Game.ConfigGetChildName(config_path, j, child_name);
195
196 if (!filters.Count())
197 {
198 add = true;
199 }
200 else
201 {
202 foreach (int indx, string filter:filters)
203 {
204 string child_name_lower = child_name;
205 child_name_lower.ToLower();
206
207 if (child_name_lower.Contains(filter))
208 {
209 add = true;
210 break;
211 }
212 }
213 }
214 if (add)
215 itemsArray.Insert(child_name);
216 }
217 }
218
219 if (itemsArray)
220 {
221 itemsArray.Sort();
222 foreach (string it:itemsArray)
223 {
224 widget.AddItem(it, NULL, 0);
225 }
226 }
227
228 if (filters)
229 {
230 /*
231 if (m_FilterOrderReversed)
232 filters.Invert();
233 */
234 foreach (string f:filters)
235 {
236 TStringArray arr2 = itemsByFilters.Get(f);
237 if (arr2)
238 {
239 arr2.Sort();
240 foreach (string itm: arr2)
241 {
242 int row = widget.AddItem(itm, NULL, 0);
243 }
244 }
245 }
246 }
247
248
249 }
250
251 override void Update(float timeslice)
252 {
253 super.Update(timeslice);
254
255 HandleKeys();
256 m_DebugMapWidget.ClearUserMarks();
257
258 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
259
260 if (player)
261 {
262 vector playerPos = player.GetWorldPosition();
263 m_DebugMapWidget.AddUserMark(playerPos,"You", COLOR_RED,"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
264
265 if (playerPos != GetMapPos())
266 m_DebugMapWidget.AddUserMark(GetMapPos(),"Source", COLOR_GREEN,"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
267 }
269 }
270
271 protected void HandleKeys()
272 {
273 bool playRequested = KeyState(KeyCode.KC_P) != 0;
274 if (playRequested)
275 {
276 int selected_row_index = m_SoundsTextListbox.GetSelectedRow();
277
278 if (m_SoundSet)
279 m_SoundSet.Stop();
280 if (selected_row_index != -1)
281 {
282 string soundSetName;
283 m_SoundsTextListbox.GetItemText(selected_row_index, 0, soundSetName);
284
286 m_SoundSet.SetAutodestroy(true);
287 }
288 }
289 }
290
291 protected void SetMapPos(vector pos)
292 {
293 m_MapPos = pos;
294 }
295
296 protected vector GetMapPos()
297 {
298 return m_MapPos;
299 }
300
301 protected void PlaySoundEvent()
302 {
303 m_SelectedID = m_SoundEventIDBox.GetText().ToInt();
304 if (m_SelectedID == 0)
305 return;
306
307 DayZPlayerImplement player = DayZPlayerImplement.Cast(g_Game.GetPlayer());
308
309 if (m_SelectedSoundEventType == "SoundAttachment")
311 else
312 player.OnSoundEvent(m_SelectedSoundEventType, string.Empty, m_SoundEventIDBox.GetText().ToInt());
313 }
314
316 {
317 string attachments = string.Empty;
318 if (m_CheckBoxShoulderAtt.IsChecked())
319 attachments += "shoulder,";
320 if (m_CheckBoxBodyAtt.IsChecked())
321 attachments += "body,";
322 if (m_CheckBoxBackAtt.IsChecked())
323 attachments += "back";
324
325 m_SelectedAttachments = attachments;
326 }
327
328 protected void UpdateSelectedColor(ImageWidget buttonBackground)
329 {
331 m_SelectedBackground.SetColor(0xFF141414);
332
333 buttonBackground.SetColor(COLOR_RED);
334
335 m_SelectedBackground = buttonBackground;
336 }
337
338 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
339 {
340 super.OnMouseButtonDown(w,x,y,button);
341
342 if (w == m_DebugMapWidget)
343 {
344 if (button == 0)
345 {
347 int mouseX, mouseY;
348 GetMousePos(mouseX,mouseY);
349 vector mousePos, worldPos;
350 mousePos[0] = mouseX;
351 mousePos[1] = mouseY;
352 worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
353 worldPos[1] = g_Game.SurfaceY(worldPos[0], worldPos[2]);
354
355 SetMapPos(worldPos);
356 }
357 else if (button == 1 && g_Game.GetPlayer())
358 {
359 SetMapPos(g_Game.GetPlayer().GetWorldPosition());
360 }
361 }
362 return true;
363 }
364
365 override bool OnClick(Widget w, int x, int y, int button)
366 {
367 super.OnClick(w,x,y,button);
368
369 if (w == m_CopySoundset)
370 {
372 return true;
373 }
374 else if (w == m_PlaySoundset || w == m_PlaySoundsetLooped)
375 {
376 int selected_row_index = m_SoundsTextListbox.GetSelectedRow();
377 string soundSetName;
378 if (m_SoundSet)
379 m_SoundSet.Stop();
380 if (selected_row_index != -1)
381 {
382 m_SoundsTextListbox.GetItemText(selected_row_index, 0, soundSetName);
383
384 bool looped = (w == m_PlaySoundsetLooped);
385 m_SoundSet = SEffectManager.PlaySoundEnviroment(soundSetName, GetMapPos(), 0, 0, looped);
386
387 }
388 return true;
389 }
390 else if (w == m_StopSoundset)
391 {
392 if (m_SoundSet)
393 m_SoundSet.Stop();
394 return true;
395 }
396 else if (w == m_SoundFilter)
397 {
399 return true;
400 }
401 else if (w == m_SetETSoundButton)
402 {
403 m_SelectedSoundEventType = "Sound";
405 return true;
406 }
407 else if (w == m_SetETSoundWeaponButton)
408 {
409 m_SelectedSoundEventType = "SoundWeapon";
411 return true;
412 }
413 else if (w == m_SetETSoundAttachmentButton)
414 {
415 m_SelectedSoundEventType = "SoundAttachment";
417 return true;
418 }
419 else if (w == m_SetETSoundVoiceButton)
420 {
421 m_SelectedSoundEventType = "SoundVoice";
423 return true;
424 }
425 else if (w == m_PlaySoundEventButton)
426 {
428 return true;
429 }
430 else if (w == m_CheckBoxShoulderAtt || w == m_CheckBoxBodyAtt || w == m_CheckBoxBackAtt)
431 {
433 return true;
434 }
435
436 return false;
437 }
438
439 override bool OnDoubleClick(Widget w, int x, int y, int button)
440 {
441 super.OnDoubleClick(w, x, y, button);
442
443 if (w == m_SoundEventIDBox || w == m_SoundFilter)
444 {
445 EditBoxWidget.Cast(w).SetText("");
446 return true;
447 }
448
449 return false;
450 }
451
453 {
454 return {CFG_SOUND_SETS};
455 }
456
457 protected void ChangeFilterSound()
458 {
459 m_ConfigDebugProfile.SetSoundsetFilter(m_SoundFilter.GetText());
461 }
462
463 override void OnSelected()
464 {
466 }
467}
DayZGame g_Game
Определения DayZGame.c:4074
Empty
Определения Hand_States.c:14
Icon x
Icon y
void ScriptConsole()
Определения ScriptConsole.c:114
Определения ManBase.c:2
Определения EnWidgets.c:354
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения gameplay.c:323
Определения EnMath3D.c:28
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
static EffectSound PlaySoundEnviroment(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound, updating environment variables.
Определения EffectManager.c:237
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
void PlaySoundEvent()
Определения ScriptConsoleSoundsTab.c:301
TextWidget m_MapHeadingWidget
Определения ScriptConsoleSoundsTab.c:30
ref Timer m_RefreshFilterTimer
Определения ScriptConsoleSoundsTab.c:25
TextWidget m_MouseCurPos
Определения ScriptConsoleSoundsTab.c:29
override bool OnChange(Widget w, int x, int y, bool finished)
Определения ScriptConsoleSoundsTab.c:112
ImageWidget m_BBackgroundSoundVoice
Определения ScriptConsoleSoundsTab.c:35
MapWidget m_DebugMapWidget
Определения ScriptConsoleSoundsTab.c:27
ButtonWidget m_PlaySoundsetLooped
Определения ScriptConsoleSoundsTab.c:17
void UpdateAttachmentSelection()
Определения ScriptConsoleSoundsTab.c:315
ButtonWidget m_SetETSoundVoiceButton
Определения ScriptConsoleSoundsTab.c:13
static int m_SelectedID
Определения ScriptConsoleSoundsTab.c:6
vector GetMapPos()
Определения ScriptConsoleSoundsTab.c:296
ButtonWidget m_PlaySoundEventButton
Определения ScriptConsoleSoundsTab.c:14
override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleSoundsTab.c:42
void ~ScriptConsoleSoundsTab(Widget root)
Определения ScriptConsoleSoundsTab.c:107
ButtonWidget m_SetETSoundButton
Определения ScriptConsoleSoundsTab.c:10
ButtonWidget m_CopySoundset
Определения ScriptConsoleSoundsTab.c:15
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
Определения ScriptConsoleSoundsTab.c:338
void ChangeFilter(TStringArray classes, TextListboxWidget widget, EditBoxWidget filterWidget, int categoryMask=-1, bool ignoreScope=false)
Определения ScriptConsoleSoundsTab.c:174
ImageWidget m_BBackgroundSound
Определения ScriptConsoleSoundsTab.c:32
void ChangeFilterSound()
Определения ScriptConsoleSoundsTab.c:457
EditBoxWidget m_SoundEventIDBox
Определения ScriptConsoleSoundsTab.c:20
static EffectSound m_SoundSet
Определения ScriptConsoleSoundsTab.c:24
CheckBoxWidget m_CheckBoxBodyAtt
Определения ScriptConsoleSoundsTab.c:39
EditBoxWidget m_SoundFilter
Определения ScriptConsoleSoundsTab.c:21
void UpdateMousePos()
Определения ScriptConsoleSoundsTab.c:124
ImageWidget m_BBackgroundSoundWeapon
Определения ScriptConsoleSoundsTab.c:33
void UpdateSelectedColor(ImageWidget buttonBackground)
Определения ScriptConsoleSoundsTab.c:328
static string m_SelectedSoundEventType
Определения ScriptConsoleSoundsTab.c:7
ButtonWidget m_SetETSoundWeaponButton
Определения ScriptConsoleSoundsTab.c:11
CheckBoxWidget m_CheckBoxBackAtt
Определения ScriptConsoleSoundsTab.c:40
override bool OnClick(Widget w, int x, int y, int button)
Определения ScriptConsoleSoundsTab.c:365
ImageWidget m_SelectedBackground
Определения ScriptConsoleSoundsTab.c:36
void SetMapPos(vector pos)
Определения ScriptConsoleSoundsTab.c:291
CheckBoxWidget m_CheckBoxShoulderAtt
Определения ScriptConsoleSoundsTab.c:38
TextListboxWidget m_SoundsTextListbox
Определения ScriptConsoleSoundsTab.c:22
TStringArray GetSoundClasses()
Определения ScriptConsoleSoundsTab.c:452
override void OnSelected()
Определения ScriptConsoleSoundsTab.c:463
ButtonWidget m_StopSoundset
Определения ScriptConsoleSoundsTab.c:18
static string m_SelectedAttachments
Определения ScriptConsoleSoundsTab.c:8
TextWidget m_MapDistWidget
Определения ScriptConsoleSoundsTab.c:28
override void Update(float timeslice)
Определения ScriptConsoleSoundsTab.c:251
static float DEBUG_MAP_ZOOM
Определения ScriptConsoleSoundsTab.c:4
override bool OnDoubleClick(Widget w, int x, int y, int button)
Определения ScriptConsoleSoundsTab.c:439
bool m_PlayerPosRefreshBlocked
Определения ScriptConsoleSoundsTab.c:3
void PrepareFilters(string filter, out TStringArray filters)
Определения ScriptConsoleSoundsTab.c:157
ButtonWidget m_PlaySoundset
Определения ScriptConsoleSoundsTab.c:16
ImageWidget m_BBackgroundSoundAttachment
Определения ScriptConsoleSoundsTab.c:34
ButtonWidget m_SetETSoundAttachmentButton
Определения ScriptConsoleSoundsTab.c:12
PluginConfigDebugProfile m_ConfigDebugProfile
Определения ScriptConsoleTabBase.c:11
void AddItemToClipboard(TextListboxWidget text_listbox_widget)
Определения ScriptConsoleTabBase.c:87
Определения EnWidgets.c:220
Определения DayZPlayerImplement.c:39
Определения EnWidgets.c:190
proto string ToString(bool simple=true)
Определения Transport.c:70
Определения EnConvert.c:119
const int COLOR_RED
Определения 1_Core/DayZ/constants.c:64
const int COLOR_GREEN
Определения 1_Core/DayZ/constants.c:65
class array< Class T > TStringArray
KeyCode
Определения EnSystem.c:157
proto native int KeyState(KeyCode key)
static proto float AngleFromPosition(vector origin, vector originDir, vector target)
Angle that a target is from the direction of an origin.
static const float RAD2DEG
Определения EnMath.c:16
const string CFG_SOUND_SETS
Определения 3_Game/DayZ/constants.c:236
proto void GetMousePos(out int x, out int y)
proto string Trim()
Returns trimmed string with removed leading and trailing whitespaces.
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
Определения EnString.c:396
proto int ToLower()
Changes string to lowercase. Returns length.
proto native void SetFocus(Widget w)