DayZ 1.27
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 void ScriptConsoleSoundsTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
43 {
44 m_MouseCurPos = TextWidget.Cast(root.FindAnyWidget("MapSoundsPos"));
45 m_MapDistWidget = TextWidget.Cast(root.FindAnyWidget("MapSoundsDistance"));
46 m_MapHeadingWidget = TextWidget.Cast(root.FindAnyWidget("MapHeadingSounds"));
47
48 m_SetETSoundButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundButton"));
49 m_SetETSoundWeaponButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundWeaponButton"));
50 m_SetETSoundAttachmentButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundAttachmentButton"));
51 m_SetETSoundVoiceButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundVoiceButton"));
52 m_PlaySoundEventButton = ButtonWidget.Cast(root.FindAnyWidget("ETSoundPlayButton"));
53 m_SoundEventIDBox = EditBoxWidget.Cast(root.FindAnyWidget("SoundIDEditBox"));
54 m_CheckBoxShoulderAtt = CheckBoxWidget.Cast(root.FindAnyWidget("CheckBoxShoulderAtt"));
55 m_CheckBoxBodyAtt = CheckBoxWidget.Cast(root.FindAnyWidget("CheckBoxBodyAtt"));
56 m_CheckBoxBackAtt = CheckBoxWidget.Cast(root.FindAnyWidget("CheckBoxBackAtt"));
57 m_BBackgroundSound = ImageWidget.Cast(root.FindAnyWidget("SoundEventType"));
58 m_BBackgroundSoundWeapon = ImageWidget.Cast(root.FindAnyWidget("SoundEventType0"));
59 m_BBackgroundSoundAttachment = ImageWidget.Cast(root.FindAnyWidget("SoundEventType1"));
60 m_BBackgroundSoundVoice = ImageWidget.Cast(root.FindAnyWidget("SoundEventType2"));
61
62 m_CopySoundset = ButtonWidget.Cast(root.FindAnyWidget("SoundsetCopy"));
63 m_PlaySoundset = ButtonWidget.Cast(root.FindAnyWidget("PlaySoundset"));
64 m_PlaySoundsetLooped = ButtonWidget.Cast(root.FindAnyWidget("PlaySoundsetLooped"));
65 m_StopSoundset = ButtonWidget.Cast(root.FindAnyWidget("StopSoundset"));
66 m_DebugMapWidget = MapWidget.Cast(root.FindAnyWidget("MapSounds"));
67
68 m_SoundFilter = EditBoxWidget.Cast(root.FindAnyWidget("SoundsFilter"));
69 m_SoundsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("SoundsList"));
70
71 m_SoundFilter.SetText(m_ConfigDebugProfile.GetSoundsetFilter());
72
73
75
76 if (GetGame().GetPlayer())
77 {
79 m_DebugMapWidget.SetMapPos(GetGame().GetPlayer().GetWorldPosition());
80 SetMapPos(GetGame().GetPlayer().GetWorldPosition());
81 }
82
83 // reopen update
84 m_SoundEventIDBox.SetText(m_SelectedID.ToString());
85
86 if (m_SelectedSoundEventType == "Sound")
88 else if (m_SelectedSoundEventType == "SoundWeapon")
90 else if (m_SelectedSoundEventType == "SoundAttachment")
92 else if (m_SelectedSoundEventType == "SoundVoice")
94
95 string lastSelection = m_SelectedAttachments;
96 if (lastSelection.Contains("shoulder"))
97 m_CheckBoxShoulderAtt.SetChecked(true);
98 if (lastSelection.Contains("body"))
99 m_CheckBoxBodyAtt.SetChecked(true);
100 if (lastSelection.Contains("back"))
101 m_CheckBoxBackAtt.SetChecked(true);
102
103 }
104
106 {
107 DEBUG_MAP_ZOOM = m_DebugMapWidget.GetScale();
108 }
109
110 override bool OnChange(Widget w, int x, int y, bool finished)
111 {
112 super.OnChange(w, x, y, finished);
113
114 if (w == m_SoundFilter)
115 {
116 m_RefreshFilterTimer.Run(0.85, this, "ChangeFilterSound", null, false);
117 return true;
118 }
119 return false;
120 }
121
123 {
124 if(!GetGame().GetPlayer())
125 return;
126 int x,y;
127 GetMousePos(x,y);
128 vector mousePos, worldPos;
129 mousePos[0] = x;
130 mousePos[1] = y;
131 worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
132 vector playerPos = GetGame().GetPlayer().GetWorldPosition();
133 if (GetMapPos() != playerPos)
134 worldPos = GetMapPos();
135 worldPos[1] = GetGame().SurfaceY(worldPos[0], worldPos[2]);
136
137 if (m_MouseCurPos)
138 {
139 m_MouseCurPos.SetText("Mouse: "+ MiscGameplayFunctions.TruncateToS(worldPos[0]) +", "+ MiscGameplayFunctions.TruncateToS(worldPos[1]) +", "+ MiscGameplayFunctions.TruncateToS(worldPos[2]));
140 }
142 {
143 float dst = (worldPos - playerPos).Length();
144
145 m_MapDistWidget.SetText("Distance: " + MiscGameplayFunctions.TruncateToS(dst));
146 }
148 {
149 vector playerCamDir = GetGame().GetCurrentCameraDirection();
150 float heading = Math3D.AngleFromPosition(playerPos, playerCamDir, worldPos) * Math.RAD2DEG;
151 m_MapHeadingWidget.SetText("Heading:" +heading.ToString());
152 }
153 }
154
155 protected void PrepareFilters(string filter, out TStringArray filters)
156 {
157 filter.Trim();
158 filter.ToLower();
159
160 filters = new TStringArray;
161 TStringArray rawFilters = new TStringArray;
162 filter.Split(" ", rawFilters);
163
164 foreach (int i, string f:rawFilters)
165 {
166 filters.Insert(f);
167
168 }
169 }
170
171 // this is a 95% of the code of the function of the same name inside ScriptConsole.c
172 protected void ChangeFilter(TStringArray classes, TextListboxWidget widget, EditBoxWidget filterWidget, int categoryMask = -1, bool ignoreScope = false)
173 {
174 widget.ClearItems();
175
176 TStringArray filters;
177 PrepareFilters(filterWidget.GetText(),filters);
178
180
181 TStringArray itemsArray = TStringArray();
182
183 for (int i = 0; i < classes.Count(); i++)
184 {
185 string config_path = classes.Get(i);
186
187 int objects_count = GetGame().ConfigGetChildrenCount(config_path);
188 for (int j = 0; j < objects_count; j++)
189 {
190 string child_name;
191 bool add = false;
192 GetGame().ConfigGetChildName(config_path, j, child_name);
193
194 if (!filters.Count())
195 {
196 add = true;
197 }
198 else
199 {
200 foreach (int indx, string filter:filters)
201 {
202 string child_name_lower = child_name;
203 child_name_lower.ToLower();
204
205 if (child_name_lower.Contains(filter))
206 {
207 add = true;
208 break;
209 }
210 }
211 }
212 if (add)
213 itemsArray.Insert(child_name);
214 }
215 }
216
217 if (itemsArray)
218 {
219 itemsArray.Sort();
220 foreach (string it:itemsArray)
221 {
222 widget.AddItem(it, NULL, 0);
223 }
224 }
225
226 if (filters)
227 {
228 /*
229 if (m_FilterOrderReversed)
230 filters.Invert();
231 */
232 foreach (string f:filters)
233 {
234 TStringArray arr2 = itemsByFilters.Get(f);
235 if (arr2)
236 {
237 arr2.Sort();
238 foreach (string itm: arr2)
239 {
240 int row = widget.AddItem(itm, NULL, 0);
241 }
242 }
243 }
244 }
245
246
247 }
248
249 override void Update(float timeslice)
250 {
251 super.Update(timeslice);
252
253 HandleKeys();
254 m_DebugMapWidget.ClearUserMarks();
255
256 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
257
258 if (player)
259 {
260 vector playerPos = player.GetWorldPosition();
261 m_DebugMapWidget.AddUserMark(playerPos,"You", COLOR_RED,"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
262
263 if (playerPos != GetMapPos())
264 m_DebugMapWidget.AddUserMark(GetMapPos(),"Source", COLOR_GREEN,"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
265 }
267 }
268
269 protected void HandleKeys()
270 {
271 bool playRequested = KeyState(KeyCode.KC_P) != 0;
272 if (playRequested)
273 {
274 int selected_row_index = m_SoundsTextListbox.GetSelectedRow();
275
276 if (m_SoundSet)
277 m_SoundSet.Stop();
278 if (selected_row_index != -1)
279 {
280 string soundSetName;
281 m_SoundsTextListbox.GetItemText(selected_row_index, 0, soundSetName);
282
284 m_SoundSet.SetAutodestroy(true);
285 }
286 }
287 }
288
289 protected void SetMapPos(vector pos)
290 {
291 m_MapPos = pos;
292 }
293
294 protected vector GetMapPos()
295 {
296 return m_MapPos;
297 }
298
299 protected void PlaySoundEvent()
300 {
301 m_SelectedID = m_SoundEventIDBox.GetText().ToInt();
302 if (m_SelectedID == 0)
303 return;
304
306
307 if (m_SelectedSoundEventType == "SoundAttachment")
309 else
310 player.OnSoundEvent(m_SelectedSoundEventType, string.Empty, m_SoundEventIDBox.GetText().ToInt());
311 }
312
314 {
315 string attachments = string.Empty;
316 if (m_CheckBoxShoulderAtt.IsChecked())
317 attachments += "shoulder,";
318 if (m_CheckBoxBodyAtt.IsChecked())
319 attachments += "body,";
320 if (m_CheckBoxBackAtt.IsChecked())
321 attachments += "back";
322
323 m_SelectedAttachments = attachments;
324 }
325
326 protected void UpdateSelectedColor(ImageWidget buttonBackground)
327 {
329 m_SelectedBackground.SetColor(0xFF141414);
330
331 buttonBackground.SetColor(COLOR_RED);
332
333 m_SelectedBackground = buttonBackground;
334 }
335
336 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
337 {
338 super.OnMouseButtonDown(w,x,y,button);
339
340 if (w == m_DebugMapWidget)
341 {
342 if (button == 0)
343 {
345 int mouseX, mouseY;
346 GetMousePos(mouseX,mouseY);
347 vector mousePos, worldPos;
348 mousePos[0] = mouseX;
349 mousePos[1] = mouseY;
350 worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
351 worldPos[1] = GetGame().SurfaceY(worldPos[0], worldPos[2]);
352
353 SetMapPos(worldPos);
354 }
355 else if (button == 1 && GetGame().GetPlayer())
356 {
357 SetMapPos(GetGame().GetPlayer().GetWorldPosition());
358 }
359 }
360 return true;
361 }
362
363 override bool OnClick(Widget w, int x, int y, int button)
364 {
365 super.OnClick(w,x,y,button);
366
367 if (w == m_CopySoundset)
368 {
370 return true;
371 }
372 else if (w == m_PlaySoundset || w == m_PlaySoundsetLooped)
373 {
374 int selected_row_index = m_SoundsTextListbox.GetSelectedRow();
375 string soundSetName;
376 if (m_SoundSet)
377 m_SoundSet.Stop();
378 if (selected_row_index != -1)
379 {
380 m_SoundsTextListbox.GetItemText(selected_row_index, 0, soundSetName);
381
382 bool looped = (w == m_PlaySoundsetLooped);
383 m_SoundSet = SEffectManager.PlaySoundEnviroment(soundSetName, GetMapPos(), 0, 0, looped);
384
385 }
386 return true;
387 }
388 else if (w == m_StopSoundset)
389 {
390 if (m_SoundSet)
391 m_SoundSet.Stop();
392 return true;
393 }
394 else if (w == m_SoundFilter)
395 {
397 return true;
398 }
399 else if (w == m_SetETSoundButton)
400 {
401 m_SelectedSoundEventType = "Sound";
403 return true;
404 }
405 else if (w == m_SetETSoundWeaponButton)
406 {
407 m_SelectedSoundEventType = "SoundWeapon";
409 return true;
410 }
411 else if (w == m_SetETSoundAttachmentButton)
412 {
413 m_SelectedSoundEventType = "SoundAttachment";
415 return true;
416 }
417 else if (w == m_SetETSoundVoiceButton)
418 {
419 m_SelectedSoundEventType = "SoundVoice";
421 return true;
422 }
423 else if (w == m_PlaySoundEventButton)
424 {
426 return true;
427 }
428 else if (w == m_CheckBoxShoulderAtt || w == m_CheckBoxBodyAtt || w == m_CheckBoxBackAtt)
429 {
431 return true;
432 }
433
434 return false;
435 }
436
437 override bool OnDoubleClick(Widget w, int x, int y, int button)
438 {
439 super.OnDoubleClick(w, x, y, button);
440
441 if (w == m_SoundEventIDBox || w == m_SoundFilter)
442 {
443 EditBoxWidget.Cast(w).SetText("");
444 return true;
445 }
446
447 return false;
448 }
449
451 {
452 return {CFG_SOUND_SETS};
453 }
454
455 protected void ChangeFilterSound()
456 {
457 m_ConfigDebugProfile.SetSoundsetFilter(m_SoundFilter.GetText());
459 }
460
461}
map
Определения ControlsXboxNew.c:4
Empty
Определения Hand_States.c:14
Icon x
Icon y
PlayerBase GetPlayer()
Определения ModifierBase.c:51
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float SurfaceY(float x, float z)
proto native DayZPlayer GetPlayer()
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native vector GetCurrentCameraDirection()
Определения 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:228
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
void PlaySoundEvent()
Определения ScriptConsoleSoundsTab.c:299
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:110
ImageWidget m_BBackgroundSoundVoice
Определения ScriptConsoleSoundsTab.c:35
MapWidget m_DebugMapWidget
Определения ScriptConsoleSoundsTab.c:27
ButtonWidget m_PlaySoundsetLooped
Определения ScriptConsoleSoundsTab.c:17
void UpdateAttachmentSelection()
Определения ScriptConsoleSoundsTab.c:313
ButtonWidget m_SetETSoundVoiceButton
Определения ScriptConsoleSoundsTab.c:13
static int m_SelectedID
Определения ScriptConsoleSoundsTab.c:6
vector GetMapPos()
Определения ScriptConsoleSoundsTab.c:294
ButtonWidget m_PlaySoundEventButton
Определения ScriptConsoleSoundsTab.c:14
void ~ScriptConsoleSoundsTab(Widget root)
Определения ScriptConsoleSoundsTab.c:105
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:336
void ChangeFilter(TStringArray classes, TextListboxWidget widget, EditBoxWidget filterWidget, int categoryMask=-1, bool ignoreScope=false)
Определения ScriptConsoleSoundsTab.c:172
ImageWidget m_BBackgroundSound
Определения ScriptConsoleSoundsTab.c:32
void ChangeFilterSound()
Определения ScriptConsoleSoundsTab.c:455
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:122
ImageWidget m_BBackgroundSoundWeapon
Определения ScriptConsoleSoundsTab.c:33
void UpdateSelectedColor(ImageWidget buttonBackground)
Определения ScriptConsoleSoundsTab.c:326
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:363
ImageWidget m_SelectedBackground
Определения ScriptConsoleSoundsTab.c:36
void SetMapPos(vector pos)
Определения ScriptConsoleSoundsTab.c:289
CheckBoxWidget m_CheckBoxShoulderAtt
Определения ScriptConsoleSoundsTab.c:38
TextListboxWidget m_SoundsTextListbox
Определения ScriptConsoleSoundsTab.c:22
TStringArray GetSoundClasses()
Определения ScriptConsoleSoundsTab.c:450
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:249
static float DEBUG_MAP_ZOOM
Определения ScriptConsoleSoundsTab.c:4
override bool OnDoubleClick(Widget w, int x, int y, int button)
Определения ScriptConsoleSoundsTab.c:437
bool m_PlayerPosRefreshBlocked
Определения ScriptConsoleSoundsTab.c:3
void PrepareFilters(string filter, out TStringArray filters)
Определения ScriptConsoleSoundsTab.c:155
void ScriptConsoleSoundsTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleSoundsTab.c:42
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 ScriptConsoleTabBase(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleTabBase.c:14
void AddItemToClipboard(TextListboxWidget text_listbox_widget)
Определения ScriptConsoleTabBase.c:90
Определения EnWidgets.c:220
Определения DayZPlayerImplement.c:63
Определения EnWidgets.c:190
proto string ToString(bool simple=true)
Определения EnConvert.c:106
proto native CGame GetGame()
const int COLOR_RED
Определения constants.c:64
const int COLOR_GREEN
Определения constants.c:65
array< string > TStringArray
Определения EnScript.c:685
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
Определения constants.c:228
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.