DayZ 1.24
Loading...
Searching...
No Matches
ScriptConsoleSoundsTab.c
Go to the documentation of this file.
2{
4 protected static float DEBUG_MAP_ZOOM = 1;
5 protected vector m_MapPos;
10
13
14 protected static EffectSound m_SoundSet;
16
21
23 {
24 m_MouseCurPos = TextWidget.Cast(root.FindAnyWidget("MapSoundsPos"));
25 m_MapDistWidget = TextWidget.Cast(root.FindAnyWidget("MapSoundsDistance"));
26 m_MapHeadingWidget = TextWidget.Cast(root.FindAnyWidget("MapHeadingSounds"));
27
28 m_CopySoundset = ButtonWidget.Cast(root.FindAnyWidget("SoundsetCopy"));
29 m_PlaySoundset = ButtonWidget.Cast(root.FindAnyWidget("PlaySoundset"));
30 m_PlaySoundsetLooped = ButtonWidget.Cast(root.FindAnyWidget("PlaySoundsetLooped"));
31 m_StopSoundset = ButtonWidget.Cast(root.FindAnyWidget("StopSoundset"));
32 m_DebugMapWidget = MapWidget.Cast(root.FindAnyWidget("MapSounds"));
33
34 m_SoundFilter = EditBoxWidget.Cast(root.FindAnyWidget("SoundsFilter"));
35 m_SoundsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("SoundsList"));
36
37 m_SoundFilter.SetText(m_ConfigDebugProfile.GetSoundsetFilter());
38
39
41
42 if (GetGame().GetPlayer())
43 {
45 m_DebugMapWidget.SetMapPos(GetGame().GetPlayer().GetWorldPosition());
46 SetMapPos(GetGame().GetPlayer().GetWorldPosition());
47 }
48 }
49
54
55 override bool OnChange(Widget w, int x, int y, bool finished)
56 {
57 super.OnChange(w, x, y, finished);
58
59 if (w == m_SoundFilter)
60 {
61 m_RefreshFilterTimer.Run(0.85, this, "ChangeFilterSound", null, false);
62 return true;
63 }
64 return false;
65 }
66
68 {
69 if (!GetGame().GetPlayer())
70 return;
71 int x, y;
72 GetMousePos(x, y);
74 mousePos[0] = x;
75 mousePos[1] = y;
77 vector playerPos = GetGame().GetPlayer().GetWorldPosition();
78 if (GetMapPos() != playerPos)
80 worldPos[1] = GetGame().SurfaceY(worldPos[0], worldPos[2]);
81
82 if (m_MouseCurPos)
83 m_MouseCurPos.SetText("Mouse: " + MiscGameplayFunctions.TruncateToS(worldPos[0]) + ", " + MiscGameplayFunctions.TruncateToS(worldPos[1]) + ", " + MiscGameplayFunctions.TruncateToS(worldPos[2]));
85 {
86 float dst = (worldPos - playerPos).Length();
87
88 m_MapDistWidget.SetText("Distance: " + MiscGameplayFunctions.TruncateToS(dst));
89 }
91 {
92 vector playerCamDir = GetGame().GetCurrentCameraDirection();
94 m_MapHeadingWidget.SetText("Heading:" + heading.ToString());
95 }
96 }
97
99 {
100 filter.Trim();
101 filter.ToLower();
102
103 filters = new TStringArray;
105 filter.Split(" ", rawFilters);
106
107 foreach (int i, string f: rawFilters)
108 filters.Insert(f);
109
110 }
111
112 // this is a 95% of the code of the function of the same name inside ScriptConsole.c
114 {
115 widget.ClearItems();
116
119
121
123
124 for (int i = 0; i < classes.Count(); i++)
125 {
126 string config_path = classes.Get(i);
127
128 int objects_count = GetGame().ConfigGetChildrenCount(config_path);
129 for (int j = 0; j < objects_count; j++)
130 {
131 string child_name;
132 bool add = false;
133 GetGame().ConfigGetChildName(config_path, j, child_name);
134
135 if (!filters.Count())
136 add = true;
137 else
138 {
139 foreach (int indx, string filter: filters)
140 {
142 child_name_lower.ToLower();
143
144 if (child_name_lower.Contains(filter))
145 {
146 add = true;
147 break;
148 }
149 }
150 }
151 if (add)
152 itemsArray.Insert(child_name);
153 }
154 }
155
156 if (itemsArray)
157 {
158 itemsArray.Sort();
159 foreach (string it: itemsArray)
160 widget.AddItem(it, NULL, 0);
161 }
162
163 if (filters)
164 {
165 /*
166 if (m_FilterOrderReversed)
167 filters.Invert();
168 */
169 foreach (string f: filters)
170 {
172 if (arr2)
173 {
174 arr2.Sort();
175 foreach (string itm: arr2)
176 int row = widget.AddItem(itm, NULL, 0);
177 }
178 }
179 }
180
181
182 }
183
184 override void Update(float timeslice)
185 {
186 super.Update(timeslice);
187
188 HandleKeys();
190
192
193 if (player)
194 {
195 vector playerPos = player.GetWorldPosition();
196 m_DebugMapWidget.AddUserMark(playerPos, "You", COLOR_RED, "\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
197
198 if (playerPos != GetMapPos())
199 m_DebugMapWidget.AddUserMark(GetMapPos(), "Source", COLOR_GREEN, "\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
200 }
202 }
203
204 protected void HandleKeys()
205 {
206 bool playRequested = KeyState(KeyCode.KC_P) != 0;
207 if (playRequested)
208 {
209 int selected_row_index = m_SoundsTextListbox.GetSelectedRow();
210
211 if (m_SoundSet)
212 m_SoundSet.Stop();
213 if (selected_row_index != -1)
214 {
215 string soundSetName;
217
219 m_SoundSet.SetAutodestroy(true);
220 }
221 }
222 }
223
224 protected void SetMapPos(vector pos)
225 {
226 m_MapPos = pos;
227 }
228
229 protected vector GetMapPos()
230 {
231 return m_MapPos;
232 }
233
234 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
235 {
236 super.OnMouseButtonDown(w, x, y, button);
237
238 if (w == m_DebugMapWidget)
239 {
240 if (button == 0)
241 {
243 int mouseX, mouseY;
246 mousePos[0] = mouseX;
247 mousePos[1] = mouseY;
249 worldPos[1] = GetGame().SurfaceY(worldPos[0], worldPos[2]);
250
252 }
253 else if (button == 1 && GetGame().GetPlayer())
254 SetMapPos(GetGame().GetPlayer().GetWorldPosition());
255 }
256 return true;
257 }
258
259 override bool OnClick(Widget w, int x, int y, int button)
260 {
261 super.OnClick(w, x, y, button);
262
263 if (w == m_CopySoundset)
264 {
266 return true;
267 }
268 else if (w == m_PlaySoundset || w == m_PlaySoundsetLooped)
269 {
270 int selected_row_index = m_SoundsTextListbox.GetSelectedRow();
271 string soundSetName;
272 if (m_SoundSet)
273 m_SoundSet.Stop();
274 if (selected_row_index != -1)
275 {
277
278 bool looped = (w == m_PlaySoundsetLooped);
280
281 }
282 return true;
283 }
284 else if (w == m_StopSoundset)
285 {
286 if (m_SoundSet)
287 m_SoundSet.Stop();
288 return true;
289 }
290 else if (w == m_SoundFilter)
291 {
293 return true;
294 }
295
296 return false;
297 }
298
299
301 {
302 return {CFG_SOUND_SETS};
303 }
304
305 protected void ChangeFilterSound()
306 {
307 m_ConfigDebugProfile.SetSoundsetFilter(m_SoundFilter.GetText());
309 }
310
311}
Icon x
Icon y
PlayerBase GetPlayer()
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
proto native void SetScale(float scale)
proto native float GetScale()
proto native void SetMapPos(vector worldPos)
proto native vector ScreenToMap(vector screenPos)
proto native void ClearUserMarks()
proto native void AddUserMark(vector pos, string text, int color, string texturePath)
Definition EnMath.c:7
Manager class for managing Effect (EffectParticle, EffectSound)
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.
override bool OnChange(Widget w, int x, int y, bool finished)
void ~ScriptConsoleSoundsTab(Widget root)
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
void ChangeFilter(TStringArray classes, TextListboxWidget widget, EditBoxWidget filterWidget, int categoryMask=-1, bool ignoreScope=false)
override bool OnClick(Widget w, int x, int y, int button)
TextListboxWidget m_SoundsTextListbox
override void Update(float timeslice)
void PrepareFilters(string filter, out TStringArray filters)
void ScriptConsoleSoundsTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
PluginConfigDebugProfile m_ConfigDebugProfile
void AddItemToClipboard(TextListboxWidget text_listbox_widget)
proto native CGame GetGame()
const int COLOR_RED
Definition constants.c:64
const int COLOR_GREEN
Definition constants.c:65
array< string > TStringArray
Definition EnScript.c:666
KeyCode
Definition 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
Definition EnMath.c:16
const string CFG_SOUND_SETS
Definition constants.c:217
proto void GetMousePos(out int x, out int y)