3 protected bool m_PlayerPosRefreshBlocked;
4 protected static float DEBUG_MAP_ZOOM = 1;
6 protected ButtonWidget m_CopySoundset;
7 protected ButtonWidget m_PlaySoundset;
8 protected ButtonWidget m_PlaySoundsetLooped;
9 protected ButtonWidget m_StopSoundset;
12 protected TextListboxWidget m_SoundsTextListbox;
15 protected ref
Timer m_RefreshFilterTimer =
new Timer();
24 m_MouseCurPos =
TextWidget.Cast(root.FindAnyWidget(
"MapSoundsPos"));
25 m_MapDistWidget =
TextWidget.Cast(root.FindAnyWidget(
"MapSoundsDistance"));
26 m_MapHeadingWidget =
TextWidget.Cast(root.FindAnyWidget(
"MapHeadingSounds"));
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"));
34 m_SoundFilter =
EditBoxWidget.Cast(root.FindAnyWidget(
"SoundsFilter"));
35 m_SoundsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget(
"SoundsList"));
44 m_DebugMapWidget.SetScale(DEBUG_MAP_ZOOM);
52 DEBUG_MAP_ZOOM = m_DebugMapWidget.GetScale();
55 override bool OnChange(
Widget w,
int x,
int y,
bool finished)
57 super.OnChange(w,
x,
y, finished);
59 if (w == m_SoundFilter)
61 m_RefreshFilterTimer.Run(0.85,
this,
"ChangeFilterSound",
null,
false);
76 worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
78 if (GetMapPos() != playerPos)
79 worldPos = GetMapPos();
80 worldPos[1] =
GetGame().SurfaceY(worldPos[0], worldPos[2]);
84 m_MouseCurPos.SetText(
"Mouse: "+ MiscGameplayFunctions.TruncateToS(worldPos[0]) +
", "+ MiscGameplayFunctions.TruncateToS(worldPos[1]) +
", "+ MiscGameplayFunctions.TruncateToS(worldPos[2]));
88 float dst = (worldPos - playerPos).Length();
90 m_MapDistWidget.SetText(
"Distance: " + MiscGameplayFunctions.TruncateToS(dst));
92 if (m_MapHeadingWidget)
95 float heading =
Math3D.AngleFromPosition(playerPos, playerCamDir, worldPos) *
Math.RAD2DEG;
96 m_MapHeadingWidget.SetText(
"Heading:" +heading.ToString());
100 protected void PrepareFilters(
string filter, out
TStringArray filters)
107 filter.Split(
" ", rawFilters);
109 foreach (
int i,
string f:rawFilters)
117 protected void ChangeFilter(
TStringArray classes, TextListboxWidget widget,
EditBoxWidget filterWidget,
int categoryMask = -1,
bool ignoreScope =
false)
122 PrepareFilters(filterWidget.GetText(),filters);
128 for (
int i = 0; i < classes.Count(); i++)
130 string config_path = classes.Get(i);
132 int objects_count =
GetGame().ConfigGetChildrenCount(config_path);
133 for (
int j = 0; j < objects_count; j++)
137 GetGame().ConfigGetChildName(config_path, j, child_name);
139 if (!filters.Count())
145 foreach (
int indx,
string filter:filters)
147 string child_name_lower = child_name;
148 child_name_lower.ToLower();
150 if (child_name_lower.Contains(filter))
158 itemsArray.Insert(child_name);
165 foreach (
string it:itemsArray)
167 widget.AddItem(it, NULL, 0);
177 foreach (
string f:filters)
183 foreach (
string itm: arr2)
185 int row = widget.AddItem(itm, NULL, 0);
194 override void Update(
float timeslice)
196 super.Update(timeslice);
199 m_DebugMapWidget.ClearUserMarks();
205 vector playerPos = player.GetWorldPosition();
206 m_DebugMapWidget.AddUserMark(playerPos,
"You",
COLOR_RED,
"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
208 if (playerPos != GetMapPos())
209 m_DebugMapWidget.AddUserMark(GetMapPos(),
"Source",
COLOR_GREEN,
"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
214 protected void HandleKeys()
219 int selected_row_index = m_SoundsTextListbox.GetSelectedRow();
223 if (selected_row_index != -1)
226 m_SoundsTextListbox.GetItemText(selected_row_index, 0, soundSetName);
228 m_SoundSet =
SEffectManager.PlaySoundEnviroment(soundSetName, GetMapPos());
229 m_SoundSet.SetAutodestroy(
true);
234 protected void SetMapPos(
vector pos)
239 protected vector GetMapPos()
244 override bool OnMouseButtonDown(
Widget w,
int x,
int y,
int button)
246 super.OnMouseButtonDown(w,
x,
y,button);
248 if (w == m_DebugMapWidget)
252 m_PlayerPosRefreshBlocked =
true;
255 vector mousePos, worldPos;
256 mousePos[0] = mouseX;
257 mousePos[1] = mouseY;
258 worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
259 worldPos[1] =
GetGame().SurfaceY(worldPos[0], worldPos[2]);
271 override bool OnClick(
Widget w,
int x,
int y,
int button)
273 super.OnClick(w,
x,
y,button);
275 if (w == m_CopySoundset)
277 AddItemToClipboard(m_SoundsTextListbox);
280 else if (w == m_PlaySoundset || w == m_PlaySoundsetLooped)
282 int selected_row_index = m_SoundsTextListbox.GetSelectedRow();
286 if (selected_row_index != -1)
288 m_SoundsTextListbox.GetItemText(selected_row_index, 0, soundSetName);
290 bool looped = (w == m_PlaySoundsetLooped);
291 m_SoundSet =
SEffectManager.PlaySoundEnviroment(soundSetName, GetMapPos(), 0, 0, looped);
296 else if (w == m_StopSoundset)
302 else if (w == m_SoundFilter)
317 protected void ChangeFilterSound()
320 ChangeFilter(GetSoundClasses(), m_SoundsTextListbox, m_SoundFilter, 0,
true);