Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
sceneeditormenu.c
Go to the documentation of this file.
1 class SceneEditorMenu extends UIScriptedMenu
2 {
3 //---------------------------------------------------------------------------------
4 // >> Public Scope
5  static const int POPUP_ID_SCENE_MANAGER = 0;
6  static const int POPUP_ID_SCENE_SETTINGS = 1;
7  static const int POPUP_ID_SCENE_NEW = 2;
8  static const int POPUP_ID_SCENE_RENAME = 3;
9  static const int POPUP_ID_SCENE_DELETE = 4;
10  static const int POPUP_ID_NOTIFY = 5;
11  static const int POPUP_ID_EDITOR_SETTINGS = 6;
12  static const int POPUP_ID_INIT_SCRIPT = 7;
13  static const int POPUP_ID_POSITION_MANAGER = 8;
14  static const int POPUP_ID_PRESET_NEW = 9;
15  static const int POPUP_ID_PRESET_RENAME = 10;
16  static const int POPUP_ID_CONFIGS = 11;
17  const string CONST_DEFAULT_PRESET_PREFIX = "[Default]";
18 
19  // Render specific Preset Items
20  void RenderPresets()
21  {
22  m_PresetsTextListbox.ClearItems();
23 
24  int i;
25  TBoolArray preset_params;
26 
27  // load fixed presets list
28  TStringArray presets_array = m_ConfigDebugProfileFixed.GetPresets();
29  for ( i = 0; i < presets_array.Count(); i++ )
30  {
31  m_PresetsTextListbox.AddItem( "["+presets_array.Get(i)+"]", new PresetParams ( presets_array.Get(i), true, false), 0);
32  }
33 
34  // load custom presets list
35  TStringArray custom_presets_array = m_ConfigDebugProfile.GetPresets();
36  for ( i = 0; i < custom_presets_array.Count(); i++ )
37  {
38  m_PresetsTextListbox.AddItem( custom_presets_array.Get(i), new PresetParams ( custom_presets_array.Get(i),false, false), 0);
39  }
40 
41  string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
42  if ( default_preset != "" )
43  {
44  // if is fixed
45  int index = GetPresetIndexByName( default_preset );
46  if ( IsPresetFixed( default_preset) )
47  {
48  default_preset = "[" + default_preset + "]";
49  }
50  PresetParams preset_params_array;
51  if( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
52  {
53  m_PresetsTextListbox.GetItemData( index, 0, preset_params_array );
54  m_PresetsTextListbox.SetItem( index, default_preset + CONST_DEFAULT_PRESET_PREFIX, preset_params_array, 0 );
55  }
56  }
57  }
58 
59  bool IsPresetFixed( string preset_name )
60  {
61  int preset_index = GetPresetIndexByName( preset_name);
62  PresetParams item_params_array;
63  if ( preset_index > -1 && preset_index < m_PresetsTextListbox.GetNumItems() )
64  {
65  m_PresetsTextListbox.GetItemData( preset_index, 0, item_params_array );
66  return item_params_array.param2;
67  }
68  return false;
69  }
70 
71  int GetPresetIndexByName( string preset_name )
72  {
73  int i;
74  for ( i = 0; i < m_PresetsTextListbox.GetNumItems(); i++ )
75  {
76  PresetParams item_params_array;
77  m_PresetsTextListbox.GetItemData( i, 0, item_params_array );
78 
79  if ( item_params_array.param1 == preset_name )
80  {
81  return i;
82  }
83  }
84  return -1;
85  }
86 
87  void NewPreset( string preset_name )
88  {
89  m_ConfigDebugProfile.PresetAdd( preset_name );
90  RefreshLists();
91  }
92 
93  void DeletePreset()
94  {
95  if ( GetCurrentPresetIndex() != -1 )
96  {
97  bool result = m_ConfigDebugProfile.PresetRemove( GetCurrentPresetName() );
98  RefreshLists();
99  }
100  }
101 
102  void SetDefaultPreset( int preset_index )
103  {
104  // remove previous default parameter
105  string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
106  if ( default_preset != "" )
107  {
108  int index = GetPresetIndexByName( default_preset );
109  // if is fixed
110  if ( IsPresetFixed( default_preset) )
111  {
112  default_preset = "[" + default_preset + "]";
113  }
114  PresetParams prev_preset_params_array;
115  if( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
116  {
117  m_PresetsTextListbox.GetItemData( index, 0, prev_preset_params_array );
118  prev_preset_params_array.param3 = false; // remove DEFAULT
119  m_PresetsTextListbox.SetItem( index, default_preset, prev_preset_params_array, 0 );
120  }
121  }
122 
123  // set preset on preset_index to default
124  // if is fixed
125  string preset_name = GetCurrentPresetName();
126  if ( IsPresetFixed( preset_name) )
127  {
128  preset_name = "[" + preset_name + "]";
129  }
130  // set new default preset
131  PresetParams preset_params_array;
132  index = GetCurrentPresetIndex();
133  if ( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
134  {
135  m_PresetsTextListbox.GetItemData( index, 0, preset_params_array );
136  preset_params_array.param3 = true; // DEFAULT
137  m_PresetsTextListbox.SetItem( index, preset_name + CONST_DEFAULT_PRESET_PREFIX, preset_params_array, 0 );
138  }
139  // store preset
140  m_ConfigDebugProfile.SetDefaultPreset( GetCurrentPresetName() );
141  }
142 
143  void RefreshLists()
144  {
145  RenderPresets();
146  RenderPresetItems();
147  }
148 
149  void RenamePreset( string new_preset_name )
150  {
151  if ( GetCurrentPresetIndex() != -1 )
152  {
153  bool result = m_ConfigDebugProfile.PresetRename( GetCurrentPresetName(), new_preset_name );
154  RefreshLists();
155  }
156  }
157 
158  // Render specific Preset Items
159  void RenderPresetItems()
160  {
161  // load preset items list
162  int i;
163  m_PresetItemsTextListbox.ClearItems();
164  if ( GetCurrentPresetIndex() != -1 )
165  {
166  bool isFixed = IsCurrentPresetFixed();
167  TStringArray preset_array = new TStringArray;
168 
169  if ( isFixed )
170  {
171  m_ConfigDebugProfileFixed.GetPresetItems( GetCurrentPresetName(), preset_array );
172  }
173  else
174  {
175  m_ConfigDebugProfile.GetPresetItems( GetCurrentPresetName(), preset_array );
176  }
177 
178  if ( preset_array )
179  {
180  for ( i = 0; i < preset_array.Count(); i++)
181  {
182  m_PresetItemsTextListbox.AddItem( preset_array.Get(i), NULL, 0);
183  }
184  }
185  }
186  }
187 
188  string GetCurrentPresetName()
189  {
190  int index = GetCurrentPresetIndex();
191  // load preset items list
192  if ( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
193  {
194  PresetParams item_params_array;
195  m_PresetsTextListbox.GetItemData( index, 0, item_params_array );
196  return item_params_array.param1;
197  }
198  return "";
199  }
200 
201  string GetCurrentItemName()
202  {
203  if ( GetCurrentItemIndex() != -1 )
204  {
205  string item_name;
206  m_PresetItemsTextListbox.GetItemText( GetCurrentItemIndex(), 0, item_name );
207  return item_name;
208  }
209  return "";
210  }
211 
212  string GetCurrentObjectName()
213  {
214  int selected_row_index = m_ClWgtLbxClassesList.GetSelectedRow();
215  if ( selected_row_index != -1 )
216  {
217  string item_name;
218  m_ClWgtLbxClassesList.GetItemText( selected_row_index, 0, item_name );
219  return item_name;
220  }
221  return "";
222  }
223 
224  int GetCurrentPresetIndex()
225  {
226  return m_PresetsTextListbox.GetSelectedRow();
227  }
228 
229  int GetCurrentItemIndex()
230  {
231  return m_PresetItemsTextListbox.GetSelectedRow();
232  }
233 
234  bool IsCurrentPresetFixed()
235  {
236  int index = GetCurrentPresetIndex();
237  if ( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
238  {
239  PresetParams item_params_array;
240  m_PresetsTextListbox.GetItemData( index, 0, item_params_array );
241  return item_params_array.param2;
242  }
243  return -1;
244  }
245 
246  void AddItemToPreset()
247  {
248  int selected_row_index = m_ClWgtLbxClassesList.GetSelectedRow();
249  if ( selected_row_index != -1 && GetCurrentPresetIndex() != -1 )
250  {
251  string item_name;
252  m_ClWgtLbxClassesList.GetItemText( selected_row_index, 0, item_name );
253  m_ConfigDebugProfile.ItemAddToPreset( GetCurrentPresetName(), item_name);
254  RenderPresetItems();
255  }
256  }
257 
258  void RemoveItemFromPreset()
259  {
260  if ( GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 )
261  {
262  m_ConfigDebugProfile.ItemRemoveFromPreset( GetCurrentPresetName(), GetCurrentItemIndex() );
263  RenderPresetItems();
264  }
265  }
266 
268  void SetPreset( bool clear_inventory, string preset_name)
269  {
270  int i;
271  if ( GetCurrentPresetIndex() != -1 )
272  {
273  bool is_preset_fixed = IsCurrentPresetFixed();
274  TStringArray preset_array = new TStringArray;
275 
276  if ( is_preset_fixed )
277  {
278  m_ConfigDebugProfileFixed.GetPresetItems( preset_name, preset_array );
279  }
280  else
281  {
282  m_ConfigDebugProfile.GetPresetItems( preset_name, preset_array );
283  }
284 
285  PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
286  if ( clear_inventory )
287  {
288  m_Developer.ClearInventory(player);
289  }
290 
291  for ( i = 0; i < preset_array.Count(); i++)
292  {
293  float health = -1;
294  int quantity = -1;
295  if ( is_preset_fixed )
296  {
297  health = m_ConfigDebugProfileFixed.GetItemHealth( preset_name, i );
298  quantity = m_ConfigDebugProfileFixed.GetItemQuantity( preset_name, i );
299  }
300  else
301  {
302  health = m_ConfigDebugProfile.GetItemHealth( preset_name, i );
303  quantity = m_ConfigDebugProfile.GetItemQuantity( preset_name, i );
304  }
305 
306  m_Developer.SpawnEntityInPlayerInventory(player, preset_array.Get(i), health, quantity);
307  }
308  }
309  }
310 
311  void ItemMoveUp()
312  {
313  int new_index = GetCurrentItemIndex() - 1;
314  if ( GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 && new_index > -1)
315  {
316  m_ConfigDebugProfile.SwapItem( GetCurrentPresetName(), GetCurrentItemIndex(), new_index );
317  RenderPresetItems();
318  m_PresetItemsTextListbox.SelectRow (new_index);
319  }
320  }
321 
322  void ItemMoveDown()
323  {
324  int new_index = GetCurrentItemIndex() + 1;
325  if ( GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 && new_index < m_PresetItemsTextListbox.GetNumItems() )
326  {
327  m_ConfigDebugProfile.SwapItem( GetCurrentPresetName(), GetCurrentItemIndex(), new_index );
328  RenderPresetItems();
329  m_PresetItemsTextListbox.SelectRow (new_index);
330  }
331  }
332 
333  void SaveProfileSpawnDistance()
334  {
335  if ( m_ConfigDebugProfile && m_SpawnDistanceEditBox )
336  {
337  m_ConfigDebugProfile.SetSpawnDistance( m_SpawnDistanceEditBox.GetText().ToFloat() );
338  }
339  }
340 
341  // Overrided Parent Functions
342  //============================================
343  // UseMouse (override)
344  //============================================
345  override bool UseMouse()
346  {
347  return true;
348  }
349 
350  //============================================
351  // UseKeyboard (override)
352  //============================================
353  override bool UseKeyboard()
354  {
355  return true;
356  }
357 
358  // System Events
359  //============================================
360  // SceneEditorMenu
361  //============================================
362  void SceneEditorMenu()
363  {
364  m_ModuleSceneManager = PluginSceneManager.Cast( GetPlugin(PluginSceneManager) );
365  m_ModuleSceneManager.OnUIEditorOpened();
366 
367  m_Popups = new map<int, ref UIPopupScript>;
368  m_SlObjectsList = new map<int, SceneObject>;
369  m_OpenedPopups = new TIntArray;
370  m_ClClassesList = new TStringArray;
371  }
372 
373  //============================================
374  // ~SceneEditorMenu
375  //============================================
376  void ~SceneEditorMenu()
377  {
378  PopupCloseAll();
379 
380  if ( IsModuleExist(PluginSceneManager) )
381  {
382  m_ModuleSceneManager.OnUIEditorClosed();
383  m_ModuleSceneManager = NULL;
384  }
385 
386  m_NotifyFadeTimer.Stop();
387  }
388 
389  //============================================
390  // Init
391  //============================================
392  override Widget Init()
393  {
394  // Create Main layout menu
395  layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/scene_editor/day_z_scene_editor.layout");
396  m_WgtPnlWrapper = layoutRoot.FindAnyWidget("pnl_presets_wrapper_outer");
397  m_SlWgtLoadedScene = TextWidget.Cast( layoutRoot.FindAnyWidget("txt_left_label_loaded_scene") );
398  // Find ListTextBoxWidget for objects list
399  m_SlWgtLbxObjectsList = TextListboxWidget.Cast(layoutRoot.FindAnyWidget("txtlist_left_items") );
400  // Find Edit Box for shearching in object list
401  m_SlWgtEbxFilter = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("edit_left_search_item") );
402  // Find Select Button for selecting in object list
403  m_SlWgtSelect = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_left_select") );
404  m_SlWgtFocus = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_left_focus") );
405  // Find Popup main panel
406  m_WgtPopupsMain = layoutRoot.FindAnyWidget("pnl_popups");
407  // Find Poups backgroudn
408  m_WgtPopupsBg = layoutRoot.FindAnyWidget("pnl_popup_bg");
409  // Find Edit Box for shearching in class list
410  m_ClWgtEbxFilter = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("edit_left_search_class") );
411  // Find ListTextBoxWidget for class list
412  m_ClWgtLbxClassesList = TextListboxWidget.Cast(layoutRoot.FindAnyWidget("txtlist_left_classes") );
413  // Find Buttons
414  m_WgtBtnSceneManager = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_scene_manager") );
415  m_WgtBtnPositionManager = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_position_manager") );
416  m_WgtBtnSceneSettings = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_settings") );
417  m_ClWgtButtonAddAtt = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_left_cl_add_attachment") );
418  m_WgtBtnSceneSave = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_save_scene") );
419  m_WgtBtnEditorSettings = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_editor_settings") );
420  m_WgtBtnEditInitScript = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_right_prop_pos_iscr_value") );
421  m_WgtBtnDeleteRuler = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_delete_ruler") );
422  m_WgtBtnLeftPresets = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_left_presets") );
423 
424  // Find Widgets for properties
425  m_PrWgtClassName = TextWidget.Cast(layoutRoot.FindAnyWidget("txt_right_prop_class_value") );
426  m_PrWgtPoxX = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_x_value") );
427  m_PrWgtPoxY = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_y_value") );
428  m_PrWgtPoxZ = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_z_value") );
429  m_PrWgtDir = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_dir_value") );
430  m_PrWgtDmg = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_hlt_value") );
431  m_PrWgtAttRoot = layoutRoot.FindAnyWidget("pnl_right_inspector_attachments");
432  m_PrWgtAttTitle = layoutRoot.FindAnyWidget("pnl_att_title");
433  m_PrWidgetsAttachments = new array<ref UIPropertyAttachment>;
434 
435  // Notify
436  m_NotifyWgtPanel = layoutRoot.FindAnyWidget("pnl_notify");
437  m_NotifyWgtPanel.SetAlpha(0.0);
438  m_NotifyFadeTimer = new WidgetFadeTimer;
439 
440  // Register Poups
441  m_Popups.Insert(POPUP_ID_SCENE_MANAGER, new UIPopupScriptSceneManager(layoutRoot.FindAnyWidget("pnl_popup_scene_manager")));
442  m_Popups.Insert(POPUP_ID_POSITION_MANAGER, new UIPopupScriptPositionManager(layoutRoot.FindAnyWidget("pnl_popup_position_manager")));
443  m_Popups.Insert(POPUP_ID_SCENE_SETTINGS, new UIPopupScriptSceneSettings(layoutRoot.FindAnyWidget("pnl_popup_settings")) );
444  m_Popups.Insert(POPUP_ID_SCENE_NEW, new UIPopupScriptSceneNew(layoutRoot.FindAnyWidget("pnl_popup_scene_new")) );
445  m_Popups.Insert(POPUP_ID_SCENE_RENAME, new UIPopupScriptSceneRename(layoutRoot.FindAnyWidget("pnl_popup_scene_rename")) );
446  m_Popups.Insert(POPUP_ID_SCENE_DELETE, new UIPopupScriptSceneDelete(layoutRoot.FindAnyWidget("pnl_popup_scene_delete")) );
447  m_Popups.Insert(POPUP_ID_NOTIFY, new UIPopupScriptNotify(layoutRoot.FindAnyWidget("pnl_popup_notify")) );
448  m_Popups.Insert(POPUP_ID_EDITOR_SETTINGS, new UIPopupScriptEditorSettings(layoutRoot.FindAnyWidget("pnl_popup_editor_settings")));
449  m_Popups.Insert(POPUP_ID_INIT_SCRIPT, new UIPopupScriptInitScript(layoutRoot.FindAnyWidget("pnl_popup_init_script")));
450  m_Popups.Insert(POPUP_ID_PRESET_NEW, new UIPopupScriptPresetNew(layoutRoot.FindAnyWidget("pnl_popup_preset_new")));
451  m_Popups.Insert(POPUP_ID_PRESET_RENAME, new UIPopupScriptPresetRename(layoutRoot.FindAnyWidget("pnl_popup_preset_rename")));
452  m_Popups.Insert(POPUP_ID_CONFIGS, new UIPopupScriptConfigs(layoutRoot.FindAnyWidget("pnl_popup_configs")));
453 
454  m_PresetsTextListbox = TextListboxWidget.Cast( layoutRoot.FindAnyWidget("pnl_presets") );
455  m_PresetItemsTextListbox = TextListboxWidget.Cast( layoutRoot.FindAnyWidget("pnl_preset_items") );
456  m_ConfigDebugProfileFixed = PluginConfigDebugProfileFixed.Cast( GetPlugin(PluginConfigDebugProfileFixed) );
458  m_PresetAddItemtButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_add_to_preset") );
459  m_PresetRemoveItemButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_remove_from_preset") );
460  m_SpawnOnGroundButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_spawn_on_ground") );
461  m_SpawnInInventoryButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_spawn_in_inventory") );
462  m_SpawnAsAttachmentButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_spawn_as_attachment") );
463  m_UpButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_up") );
464  m_DownButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_down") );
465  m_Developer = PluginDeveloper.Cast( GetPlugin(PluginDeveloper) );
466  m_QuantityEditBox = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("txt_quantity_value") );
467  m_DamageEditBox = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("txt_damage_value") );
468  m_SpawnDistanceEditBox = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("txt_distance_value") );
469  m_PresetNewButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_new") );
470  m_PresetDeleteButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_delete") );
471  m_PresetRenameButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_rename") );
472  m_PresetSetDefaultButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_default") );
473  m_CopyToClipboardButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_copy_to_clipboard") );
474  m_ConfigsButton = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("btn_top_configs") );
475  m_SpawnDistanceEditBox.SetText( m_ConfigDebugProfile.GetSpawnDistance().ToString() );
476 
477  RenderPresets();
478 
479  UpdateListObjects();
480  UpdateListClasses();
481 
482  PopupHideAll();
483 
484  return layoutRoot;
485  }
486 
487  override bool OnDoubleClick( Widget w, int x, int y, int button )
488  {
489  if( w == m_PresetItemsTextListbox || w == m_PresetsTextListbox || w == m_ClWgtLbxClassesList )
490  {
491  SaveProfileSpawnDistance();
492 
493  //float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
494  if ( m_SelectedObjectIsPreset )
495  {
496  SetPreset( true, m_SelectedObject);
497  return true;
498  }
499  else
500  {
501  float health = -1;
502  int quantity = -1;
503  if(GetCurrentItemIndex() != -1)
504  {
505  health = m_ConfigDebugProfile.GetItemHealth( GetCurrentPresetName(), GetCurrentItemIndex() );
506  quantity = m_ConfigDebugProfile.GetItemQuantity( GetCurrentPresetName(), GetCurrentItemIndex() );
507  }
508  m_Developer.SpawnEntityInPlayerInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_SelectedObject, health, quantity);
509  return true;
510  }
511  }
512  return false;
513  }
514  //============================================
515  // OnClick
516  //============================================
517  override bool OnClick(Widget w, int x, int y, int button)
518  {
519  super.OnClick(w, x, y, button);
520 
521  int row_index;
522 
523  if ( w == m_WgtBtnSceneManager )
524  {
525  PopupOpen(POPUP_ID_SCENE_MANAGER, Param.Cast( NULL ) );
526 
527  return true;
528  }
529  else if( w == m_ConfigsButton )
530  {
531  PopupOpen( POPUP_ID_CONFIGS, NULL );
532  return true;
533  }
534  else if( w == m_PresetsTextListbox )
535  {
536  RenderPresetItems();
537  m_SelectedObjectIsPreset = true;
538  m_SelectedObject = GetCurrentPresetName();
539  return true;
540  }
541  else if ( w == m_PresetSetDefaultButton )
542  {
543  if ( GetCurrentPresetName() != "" )
544  {
545  SetDefaultPreset( GetCurrentPresetIndex() );
546  }
547  return true;
548  }
549  else if ( w == m_PresetNewButton )
550  {
551  PopupOpen( POPUP_ID_PRESET_NEW, NULL );
552  RefreshLists();
553  return true;
554  }
555  else if ( w == m_PresetRenameButton )
556  {
557  PopupOpen( POPUP_ID_PRESET_RENAME, NULL );
558  return true;
559  }
560  else if( w == m_CopyToClipboardButton )
561  {
562  GetGame().CopyToClipboard( m_SelectedObject );
563  return true;
564  }
565  else if ( w == m_PresetDeleteButton )
566  {
567  if ( GetCurrentPresetName() != "" )
568  {
569  DeletePreset();
570  }
571  return true;
572  }
573  else if( w == m_SpawnOnGroundButton || w == m_SpawnAsAttachmentButton || w == m_SpawnInInventoryButton )
574  {
575  SaveProfileSpawnDistance();
576 
577  float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
578  float health = -1;
579  int quantity = -1;
580  if( GetCurrentItemIndex() != -1 )
581  {
582  health = m_ConfigDebugProfile.GetItemHealth( GetCurrentPresetName(), GetCurrentItemIndex() );
583  quantity = m_ConfigDebugProfile.GetItemQuantity( GetCurrentPresetName(), GetCurrentItemIndex() );
584  }
585 
586  switch ( w )
587  {
588  case m_SpawnOnGroundButton:
589  {
590  if ( m_SelectedObjectIsPreset )
591  {
592  // SpawnPresetOnGround
593  ;//SetPreset( true, m_SelectedObject, spawn_type, distance );
594  }
595  else
596  m_Developer.SpawnEntityOnCursorDir( PlayerBase.Cast( GetGame().GetPlayer() ), m_SelectedObject, quantity, distance, health );
597  break;
598  }
599 
600  case m_SpawnAsAttachmentButton:
601  {
602  Man player = GetGame().GetPlayer();
603 
604  vector rayStart = GetGame().GetCurrentCameraPosition();
605  vector rayEnd = rayStart + GetGame().GetCurrentCameraDirection() * 1.5;
606  vector hitPos;
607  vector hitNormal;
608  int hitComponentIndex;
609  ref set<Object> hitObjects = new set<Object>;
610  DayZPhysics.RaycastRV(rayStart, rayEnd, hitPos, hitNormal, hitComponentIndex, hitObjects, NULL, player);
611 
612  Object target = NULL;
613  if( hitObjects.Count() )
614  target = hitObjects.Get(0);
615 
616  if ( target != NULL && target.IsInherited(EntityAI) )
617  {
618  EntityAI att_parent = EntityAI.Cast( target );
619  m_Developer.SpawnEntityAsAttachment( PlayerBase.Cast( player ), att_parent, m_SelectedObject, health, quantity);
620  }
621  else
622  {
623  m_Developer.SpawnEntityAsAttachment( PlayerBase.Cast( player ), player, m_SelectedObject, health, quantity);
624  }
625  break;
626  }
627 
628  case m_SpawnInInventoryButton:
629  {
630  m_Developer.SpawnEntityInPlayerInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_SelectedObject, health, quantity);
631  break;
632  }
633  }
634  return true;
635  }
636  else if( w == m_PresetItemsTextListbox )
637  {
638  m_SelectedObjectIsPreset = false;
639  m_SelectedObject = GetCurrentItemName();
640 
641  if( GetCurrentItemIndex() != -1 )
642  {
643  float item_health = m_ConfigDebugProfile.GetItemHealth( GetCurrentPresetName(), GetCurrentItemIndex() );
644  int item_quantity = m_ConfigDebugProfile.GetItemQuantity( GetCurrentPresetName(), GetCurrentItemIndex() );
645 
646  m_DamageEditBox.SetText( item_health.ToString() );
647  m_QuantityEditBox.SetText( item_quantity.ToString() );
648  }
649 
650  return true;
651  }
652  else if( w == m_UpButton )
653  {
654  ItemMoveUp();
655  return true;
656  }
657  else if( w == m_DownButton )
658  {
659  ItemMoveDown();
660  return true;
661  }
662  else if( w == m_WgtBtnLeftPresets )
663  {
664  if( m_WgtPnlWrapper.IsVisible() )
665  {
666  m_WgtPnlWrapper.Show(false);
667  m_WgtBtnLeftPresets.SetText("Presets >>");
668  }
669  else
670  {
671  m_WgtPnlWrapper.Show(true);
672  m_WgtBtnLeftPresets.SetText("Presets <<");
673  }
674 
675  return true;
676  }
677  else if ( w == m_PresetAddItemtButton )
678  {
679  AddItemToPreset();
680  return true;
681  }
682  else if ( w == m_PresetRemoveItemButton )
683  {
684  RemoveItemFromPreset();
685  return true;
686  }
687  else if ( w == m_WgtBtnPositionManager )
688  {
689  m_PopupScriptPositionManager = UIPopupScriptPositionManager.Cast( PopupOpen( POPUP_ID_POSITION_MANAGER, Param.Cast( NULL ) ) );
690  return true;
691  }
692  else if ( w == m_WgtBtnSceneSettings )
693  {
694  PopupOpen(POPUP_ID_SCENE_SETTINGS, NULL);
695  return true;
696  }
697  else if ( w == m_SlWgtSelect )
698  {
699  row_index = m_SlWgtLbxObjectsList.GetSelectedRow();
700 
701  if ( m_SlObjectsList.Count() > 0 && m_SlObjectsList.Count() > row_index )
702  {
703  m_ModuleSceneManager.SelectObject(m_SlObjectsList.GetElement(row_index));
704  }
705 
706  return true;
707  }
708  else if ( w == m_SlWgtFocus )
709  {
710  m_ModuleSceneManager.SelectedObjectFocus();
711 
712  return true;
713  }
714  else if ( w == m_WgtBtnSceneSave )
715  {
716  m_ModuleSceneManager.SceneSave();
717 
718  return true;
719  }
720  else if ( w == m_WgtBtnEditorSettings )
721  {
722  PopupOpen(POPUP_ID_EDITOR_SETTINGS, NULL);
723 
724  return true;
725  }
726  else if ( w == m_WgtBtnEditInitScript )
727  {
728  Param2<int, SceneObject> param = new Param2<int, SceneObject>( m_ModuleSceneManager.GetSelectedSceneObjectIndex(), m_ModuleSceneManager.GetSelectedSceneObject() );
729  PopupOpen(POPUP_ID_INIT_SCRIPT, param);
730 
731  return true;
732  }
733  else if ( w == m_WgtBtnDeleteRuler )
734  {
735  m_ModuleSceneManager.RulerDelete();
736 
737  return true;
738  }
739 
740  bool ret = ComponentsOnClick(w, x, y, button);
741 
742  return ret;
743  }
744 
745  //============================================
746  // OnChange
747  //============================================
748  override bool OnChange(Widget w, int x, int y, bool finished)
749  {
750  super.OnChange(w, x, y, finished);
751 
752  if (w == m_ClWgtEbxFilter)
753  {
754  UpdateListClasses();
755  return true;
756  }
757  else if (w == m_SlWgtEbxFilter)
758  {
759  UpdateListObjects();
760  return true;
761  }
762  else if ( w == m_PrWgtPoxX && finished )
763  {
764  m_ModuleSceneManager.SelectedObjectSetPosX(m_PrWgtPoxX.GetText().ToFloat());
765  }
766  else if ( w == m_PrWgtPoxY && finished )
767  {
768  m_ModuleSceneManager.SelectedObjectSetPosY(m_PrWgtPoxY.GetText().ToFloat());
769  }
770  else if ( w == m_PrWgtPoxZ && finished )
771  {
772  m_ModuleSceneManager.SelectedObjectSetPosZ(m_PrWgtPoxZ.GetText().ToFloat());
773  }
774  else if ( w == m_PrWgtDir && finished )
775  {
776  m_ModuleSceneManager.SelectedObjectSetRot(m_PrWgtDir.GetText().ToFloat());
777  return true;
778  }
779  else if ( w == m_PrWgtDmg && finished )
780  {
781  m_ModuleSceneManager.SelectedObjectSetDamage(m_PrWgtDmg.GetText().ToFloat());
782  return true;
783  }
784  else if ( w == m_QuantityEditBox )
785  {
786  m_ConfigDebugProfile.SetItemQuantity( GetCurrentPresetName(), GetCurrentItemIndex(), m_QuantityEditBox.GetText().ToInt() );
787  return true;
788  }
789  else if ( w == m_DamageEditBox )
790  {
791  m_ConfigDebugProfile.SetItemHealth( GetCurrentPresetName(), GetCurrentItemIndex(), m_DamageEditBox.GetText().ToFloat() );
792  return true;
793  }
794 
795  bool ret = ComponentsOnChange(w, x, y, finished);
796 
797  return false;
798  }
799 
800  override void OnShow()
801  {
802  GetGame().GetMission().AddActiveInputExcludes({"menu"});
803  }
804 
805  override void OnHide()
806  {
807  GetGame().GetMission().RemoveActiveInputExcludes({"menu"},true);
808  }
809 
810  //============================================
811  // OnMouseWheel
812  //============================================
813  override bool OnMouseWheel(Widget w, int x, int y, int wheel)
814  {
815  super.OnMouseWheel(w, x, y, wheel);
816 
817  m_ModuleSceneManager.OnMouseWheel(wheel);
818  return true;
819  }
820 
821  //============================================
822  // OnItemSelected
823  //============================================
824  override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
825  {
826 
827  super.OnItemSelected(w, x, y, row, column, oldRow, oldColumn);
828 
829  if ( w == m_ClWgtLbxClassesList )
830  {
831  string selected_class_name;
832  m_ClWgtLbxClassesList.GetItemText( m_ClWgtLbxClassesList.GetSelectedRow(), 0, selected_class_name );
833  m_ModuleSceneManager.SelectClassName(selected_class_name);
834 
835  SceneObject obj_selected = m_ModuleSceneManager.GetSelectedSceneObject();
836  m_SelectedObject = GetCurrentObjectName();
837  m_SelectedObjectIsPreset = false;
838  }
839  else if ( w == m_SlWgtLbxObjectsList )
840  {
841  int row_index = m_SlWgtLbxObjectsList.GetSelectedRow();
842 
843  if ( m_SlObjectsList && row_index > -1 && m_SlObjectsList.Count() > 0 && m_SlObjectsList.Count() > row_index )
844  {
845  m_ModuleSceneManager.SelectObject(m_SlObjectsList.GetElement(row_index));
846  }
847  }
848 
849  if( m_PopupScriptPositionManager != NULL )
850  {
851  m_PopupScriptPositionManager.OnItemSelected(w, x, y, row, column, oldRow, oldColumn);
852  }
853 
854  return true;
855  }
856 
857  // Scripted Events
858  //============================================
859  // PopupOpen
860  //============================================
861  UIPopupScript PopupOpen(int popup_id, Param param)
862  {
863  // Open background image (black transparent) under popups
864  if ( m_OpenedPopups.Count() == 0 )
865  {
866  m_WgtPopupsMain.Show(true);
867  m_WgtPopupsBg.Show(true);
868  }
869  else
870  {
871  int popup_curr_id = m_OpenedPopups.Get(m_OpenedPopups.Count() - 1);
872  m_Popups.Get(popup_curr_id).Show(false);
873  }
874 
875  m_OpenedPopups.Insert(popup_id);
876 
877  UIPopupScript popup = m_Popups.Get(popup_id);
878 
879  popup.Show(true);
880  popup.OnOpen(param);
881 
882  return popup;
883  }
884 
885  //============================================
886  // PopupBack
887  //============================================
888  UIPopupScript PopupBack()
889  {
890  if ( m_OpenedPopups.Count() > 0 )
891  {
892  int popup_curr_id = m_OpenedPopups.Get(m_OpenedPopups.Count() - 1);
893 
894  m_Popups.Get(popup_curr_id).Show(false);
895  m_Popups.Get(popup_curr_id).OnClose();
896 
897  m_OpenedPopups.Remove(m_OpenedPopups.Count() - 1);
898 
899  if ( m_OpenedPopups.Count() > 0 )
900  {
901  int ppp_id = m_OpenedPopups.Get(m_OpenedPopups.Count() - 1);
902  m_Popups.Get(ppp_id).Show(true);
903  m_Popups.Get(ppp_id).OnOpen(NULL);
904 
905  return m_Popups.Get(ppp_id);
906  }
907  }
908 
909  m_WgtPopupsMain.Show(false);
910  m_WgtPopupsBg.Show(false);
911 
912  return NULL;
913  }
914 
915  //============================================
916  // PopupCloseAll
917  //============================================
918  void PopupCloseAll()
919  {
920  if ( m_OpenedPopups.Count() > 0 )
921  {
922  int popup_curr_id = m_OpenedPopups.Get(m_OpenedPopups.Count() - 1);
923 
924  m_Popups.Get(popup_curr_id).Show(false);
925  m_Popups.Get(popup_curr_id).OnClose();
926 
927  m_OpenedPopups.Clear();
928  }
929  }
930 
931 
932 
933  //============================================
934  // ToggleVisibility (Show/Hide of editor)
935  //============================================
936  void ToggleVisibility()
937  {
938  m_WgtRoot.Show( m_ModuleSceneManager.IsOpened() );
939  }
940 
941  //============================================
942  // Refresh
943  //============================================
944  override void Refresh()
945  {
946  UpdateListObjects();
947 
948  string class_name = "n/a";
949  string pos_x = "n/a";
950  string pos_y = "n/a";
951  string pos_z = "n/a";
952  string rot = "n/a";
953  string hlt = "n/a";
954 
955  // Clear attachments
956  for ( int i = 0; i < m_PrWidgetsAttachments.Count(); ++i )
957  {
958  m_PrWidgetsAttachments.Get(i).Hide();
959  }
960 
961  if ( m_ModuleSceneManager.GetSelectedSceneObject() )
962  {
963  SceneObject obj = m_ModuleSceneManager.GetSelectedSceneObject();
964  vector v = obj.GetPosition();
965 
966  class_name = obj.GetTypeName();
967  pos_x = v[0].ToString();
968  pos_y = v[1].ToString();
969  pos_z = v[2].ToString();
970  rot = obj.GetRotation().ToString();
971  hlt = obj.GetHealth().ToString();
972 
973  ref TStringArray attachments_slots = obj.GetConfigAttachments();
974 
975  float prop_h = 0.03;
976  float prop_count = attachments_slots.Count();
977  float prop_root_h = prop_h * (prop_count + 1);
978  float line_h = 1.0 / (prop_count + 1);
979 
980  m_PrWgtAttRoot.SetSize(1, prop_root_h);
981  m_PrWgtAttTitle.SetSize(1, line_h);
982 
983 
984  EntityAI e = m_ModuleSceneManager.GetSelectedSceneObject().GetObject();
985 
986  map<string, ref TStringArray> attachments_in_slots = GetItemNamesForSlots(attachments_slots);
987 
988 
989  for ( int j = 0; j < attachments_in_slots.Count(); ++j )
990  {
991  TStringArray attachments_in_slot = attachments_in_slots.GetElement(j);
992 
993  UIPropertyAttachment ui_prop = GetFreeUIPropertyAttchament();
994 
995  ui_prop.Show(m_ModuleSceneManager.GetSelectedSceneObject().GetObject(), attachments_in_slots.GetKey(j), attachments_in_slot);
996  ui_prop.SetPos( 0, (1 + j) * line_h );
997  ui_prop.SetSize( 1, line_h );
998  }
999 
1000  m_WgtBtnEditInitScript.Enable( true );
1001  }
1002  else
1003  {
1004  m_WgtBtnEditInitScript.Enable( false );
1005  }
1006 
1007  m_PrWgtClassName.SetText(class_name);
1008  m_PrWgtPoxX.SetText(pos_x);
1009  m_PrWgtPoxY.SetText(pos_y);
1010  m_PrWgtPoxZ.SetText(pos_z);
1011  m_PrWgtDir.SetText(rot);
1012  m_PrWgtDmg.SetText(hlt);
1013 
1014  m_SlWgtLoadedScene.SetText("Loaded Scene: "+m_ModuleSceneManager.SceneGetName());
1015 
1016  //Ruler
1017  if ( m_ModuleSceneManager.IsRulerActivated() )
1018  {
1019  m_WgtBtnDeleteRuler.SetColor( 0xFF5DE028 );
1020  }
1021  else
1022  {
1023  m_WgtBtnDeleteRuler.SetColor( 0xFFFFFFFF );
1024  }
1025 
1026  }
1027 
1028  void SceneEditorCommand( Param params )
1029  {
1030  Param2<int, Param> p = Param2<int, Param>.Cast( params );
1031  int cmd_id = p.param1;
1032 
1033  switch ( cmd_id )
1034  {
1035  case PluginSceneManager.SCENE_EDITOR_CMD_REFRESH:
1036  Refresh();
1037  break;
1038 
1039  case PluginSceneManager.SCENE_EDITOR_CMD_SAVE:
1040  m_NotifyWgtPanel.SetAlpha(1.0);
1041  m_NotifyFadeTimer.FadeOut(m_NotifyWgtPanel, 2, true);
1042  break;
1043  }
1044  }
1045 
1046 
1047 //---------------------------------------------------------------------------------
1048 // >> Protected Scope
1049  protected Widget m_WgtRoot;
1050  protected PluginSceneManager m_ModuleSceneManager;
1051 
1052 //---------------------------------------------------------------------------------
1053 // >> protected Scope
1054 
1055  // Top Panel
1056  protected ButtonWidget m_WgtBtnSceneManager;
1057  protected ButtonWidget m_WgtBtnSceneSettings;
1058  protected ButtonWidget m_WgtBtnSceneSave;
1059  protected ButtonWidget m_WgtBtnEditorSettings;
1060  protected ButtonWidget m_WgtBtnDeleteRuler;
1061 
1062  // Popups
1063  protected Widget m_WgtPopupsMain;
1064  protected Widget m_WgtPopupsBg;
1065  protected ref TIntArray m_OpenedPopups;
1066  protected ref map<int, ref UIPopupScript> m_Popups;
1067 
1068  // Scene Object List
1069  protected TextWidget m_SlWgtLoadedScene;
1070  protected string m_SlSelectedClass;
1071  protected ref map<int, SceneObject> m_SlObjectsList;
1072  protected TextListboxWidget m_SlWgtLbxObjectsList;
1073  protected EditBoxWidget m_SlWgtEbxFilter;
1074  protected ButtonWidget m_SlWgtSelect;
1075  protected ButtonWidget m_SlWgtFocus;
1076 
1077  // Config Class List
1078  protected string m_ClSelectedClass;
1079  protected ref TStringArray m_ClClassesList;
1080  protected EditBoxWidget m_ClWgtEbxFilter;
1081  protected TextListboxWidget m_ClWgtLbxClassesList;
1082  protected ButtonWidget m_ClWgtButtonAddAtt;
1083 
1084  // Properties
1085  protected TextWidget m_PrWgtClassName;
1086  protected EditBoxWidget m_PrWgtPoxX;
1087  protected EditBoxWidget m_PrWgtPoxY;
1088  protected EditBoxWidget m_PrWgtPoxZ;
1089  protected EditBoxWidget m_PrWgtDir;
1090  protected EditBoxWidget m_PrWgtDmg;
1091  protected ButtonWidget m_WgtBtnEditInitScript;
1092  protected Widget m_PrWgtAttRoot;
1093  protected Widget m_PrWgtAttTitle;
1094 
1095  protected ref array<ref UIPropertyAttachment> m_PrWidgetsAttachments;
1096 
1097  // Notify
1098  protected ref WidgetFadeTimer m_NotifyFadeTimer;
1099  protected Widget m_NotifyWgtPanel;
1100 
1101  //Other
1102  protected TextListboxWidget m_PresetsTextListbox;
1103  protected TextListboxWidget m_PresetItemsTextListbox;
1104  protected ButtonWidget m_PresetAddItemtButton;
1105  protected ButtonWidget m_PresetRemoveItemButton;
1106  protected ButtonWidget m_SpawnOnGroundButton;
1107  protected ButtonWidget m_SpawnInInventoryButton;
1108  protected ButtonWidget m_SpawnAsAttachmentButton;
1109  protected ButtonWidget m_UpButton;
1110  protected ButtonWidget m_DownButton;
1111  protected ButtonWidget m_PresetNewButton;
1112  protected ButtonWidget m_PresetDeleteButton;
1113  protected ButtonWidget m_PresetRenameButton;
1114  protected ButtonWidget m_PresetSetDefaultButton;
1115  protected ButtonWidget m_CopyToClipboardButton;
1116  protected EditBoxWidget m_DamageEditBox;
1117  protected EditBoxWidget m_QuantityEditBox;
1118  protected EditBoxWidget m_SpawnDistanceEditBox;
1119  protected EditBoxWidget m_ConfigsButton;
1120  protected Widget m_WgtPnlWrapper;
1121  protected ButtonWidget m_WgtBtnLeftPresets;
1122  protected ButtonWidget m_WgtBtnPositionManager;
1123 
1124  protected string m_SelectedObject;
1125  protected bool m_SelectedObjectIsPreset;
1126  protected PluginDeveloper m_Developer;
1127  protected UIPopupScriptPositionManager m_PopupScriptPositionManager;
1128  protected PluginConfigDebugProfileFixed m_ConfigDebugProfileFixed;
1130 
1131  //---- Functions
1132  protected void RefreshByLocalProfile();
1133 
1134  //--------------------------------------------
1135  // UpdateListObjects
1136  //--------------------------------------------
1137  private void UpdateListObjects()
1138  {
1139  m_SlObjectsList = GetFiltredSceneObjects(m_SlWgtEbxFilter.GetText(), m_SlObjectsList);
1140 
1141  m_SlWgtLbxObjectsList.ClearItems();
1142 
1143  int row = -1;
1144  SceneObject selected_object = m_ModuleSceneManager.GetSelectedSceneObject();
1145 
1146  for ( int i = 0; i < m_SlObjectsList.Count(); ++i )
1147  {
1148  SceneObject scene_obj = m_SlObjectsList.GetElement(i);
1149 
1150  if ( selected_object != NULL && selected_object == scene_obj )
1151  {
1152  row = i;
1153  }
1154 
1155  m_SlWgtLbxObjectsList.AddItem(scene_obj.GetTypeName(), NULL, 0);
1156  }
1157 
1158  m_SlWgtLbxObjectsList.SelectRow(row);
1159  }
1160 
1161  //--------------------------------------------
1162  // UpdateListClasses
1163  //--------------------------------------------
1164  protected void UpdateListClasses()
1165  {
1166  m_ClClassesList = GetFiltredConfigClasses(m_ClWgtEbxFilter.GetText(), m_ClClassesList);
1167 
1168  m_ClWgtLbxClassesList.ClearItems();
1169 
1170  for ( int i = 0; i < m_ClClassesList.Count(); ++i )
1171  {
1172  m_ClWgtLbxClassesList.AddItem(m_ClClassesList.Get(i), NULL, 0);
1173  }
1174  }
1175 
1176  //--------------------------------------------
1177  // GetFiltredSceneObjects
1178  //--------------------------------------------
1179  protected map<int, SceneObject> GetFiltredSceneObjects( string search_string, map<int, SceneObject> array_ret )
1180  {
1181  array<ref SceneObject> scene_objects = m_ModuleSceneManager.GetSceneObjectsAll();
1182 
1183  search_string.ToLower();
1184 
1185  array_ret.Clear();
1186 
1187  if( scene_objects != NULL )
1188  {
1189  for ( int i=0; i < scene_objects.Count(); ++i )
1190  {
1191  SceneObject sc_obj = scene_objects.Get(i);
1192 
1193  string obj_name = sc_obj.GetTypeName();
1194 
1195  obj_name.ToLower();
1196 
1197  if ( obj_name.Contains(search_string))
1198  {
1199  array_ret.Insert(i, sc_obj);
1200  }
1201  }
1202  }
1203 
1204  return array_ret;
1205  }
1206 
1207  //--------------------------------------------
1208  // GetFiltredConfigClasses
1209  //--------------------------------------------
1210  TStringArray GetFiltredConfigClasses( string search_string, TStringArray array_ret )
1211  {
1212  TStringArray searching_in = new TStringArray;
1213  searching_in.Insert(CFG_VEHICLESPATH);
1214  searching_in.Insert(CFG_WEAPONSPATH);
1215  searching_in.Insert(CFG_MAGAZINESPATH);
1216 
1217  array_ret.Clear();
1218 
1219  search_string.ToLower();
1220 
1221  for ( int s = 0; s < searching_in.Count(); ++s )
1222  {
1223  string config_path = searching_in.Get(s);
1224 
1225  int objects_count = g_Game.ConfigGetChildrenCount(config_path);
1226  for (int i = 0; i < objects_count; i++)
1227  {
1228  string childName;
1229  g_Game.ConfigGetChildName(config_path, i, childName);
1230 
1231  int scope = g_Game.ConfigGetInt(config_path + " " + childName + " scope");
1232  if ( scope == 0 )
1233  {
1234  continue;
1235  }
1236 
1237  string nchName = childName;
1238  nchName.ToLower();
1239 
1240  if ( nchName.Contains(search_string))
1241  {
1242  array_ret.Insert(childName);
1243  }
1244  }
1245  }
1246 
1247  return array_ret;
1248  }
1249 
1250  //--------------------------------------------
1251  // PopupClose
1252  //--------------------------------------------
1253  private void PopupClose(int popup_id)
1254  {
1255  }
1256 
1257  //--------------------------------------------
1258  // PopupCloseAll
1259  //--------------------------------------------
1260  private void PopupHideAll()
1261  {
1262  for ( int i = 0; i < m_Popups.Count(); ++i )
1263  {
1264  m_Popups.Get(i).Show(false);
1265  }
1266 
1267  m_WgtPopupsMain.Show(false);
1268  m_WgtPopupsBg.Show(false);
1269  }
1270 
1271  //--------------------------------------------
1272  // ComponentsOnClick
1273  //--------------------------------------------
1274  private bool ComponentsOnClick(Widget w, int x, int y, int button)
1275  {
1276  for ( int i = 0; i < m_Popups.Count(); ++i )
1277  {
1278  if ( m_Popups.Get(i).OnClick(w, x, y, button) )
1279  {
1280  return true;
1281  }
1282  }
1283 
1284  for ( int j = 0; j < m_PrWidgetsAttachments.Count(); ++j )
1285  {
1286  if ( m_PrWidgetsAttachments.Get(j).OnClick(w, x, y, button) )
1287  {
1288  return true;
1289  }
1290  }
1291 
1292  return false;
1293  }
1294 
1295  //--------------------------------------------
1296  // ComponentsOnChange
1297  //--------------------------------------------
1298  private bool ComponentsOnChange(Widget w, int x, int y, bool finished)
1299  {
1300  for ( int i = 0; i < m_Popups.Count(); ++i )
1301  {
1302  if ( m_Popups.Get(i).OnChange(w, x, y, finished) )
1303  {
1304  return true;
1305  }
1306  }
1307 
1308  return false;
1309  }
1310 
1311  //--------------------------------------------
1312  // GetFreeUIPropertyAttchament
1313  //--------------------------------------------
1314  UIPropertyAttachment GetFreeUIPropertyAttchament()
1315  {
1316  for ( int i = 0; i < m_PrWidgetsAttachments.Count(); ++i )
1317  {
1318  UIPropertyAttachment ui_comp = m_PrWidgetsAttachments.Get(i);
1319 
1320  if ( !ui_comp.IsVisible() )
1321  {
1322  return ui_comp;
1323  }
1324  }
1325 
1326  UIPropertyAttachment ui_prop = new UIPropertyAttachment(m_PrWgtAttRoot);
1327  m_PrWidgetsAttachments.Insert(ui_prop);
1328 
1329  return ui_prop;
1330  }
1331 
1332  //--------------------------------------------
1333  // GetItemNamesForSlots
1334  //--------------------------------------------
1335  private map<string, ref TStringArray> GetItemNamesForSlots(TStringArray slots)
1336  {
1337  TStringArray searching_in = new TStringArray;
1338  searching_in.Insert(CFG_VEHICLESPATH);
1339  searching_in.Insert(CFG_WEAPONSPATH);
1340  searching_in.Insert(CFG_MAGAZINESPATH);
1341 
1343 
1344  for ( int m = 0; m < slots.Count(); ++m )
1345  {
1346  array_ret.Insert(slots.Get(m), new TStringArray);
1347  }
1348 
1349  TStringArray inv_slots = new TStringArray;
1350  string inv_slot;
1351  string childName;
1352 
1353  for ( int s = 0; s < searching_in.Count(); ++s )
1354  {
1355  string config_path = searching_in.Get(s);
1356 
1357  int objects_count = g_Game.ConfigGetChildrenCount(config_path);
1358  for (int i = 0; i < objects_count; i++)
1359  {
1360  g_Game.ConfigGetChildName(config_path, i, childName);
1361 
1362  g_Game.ConfigGetTextArray(config_path + " " + childName + " inventorySlot", inv_slots);
1363 
1364  if ( inv_slots.Count() > 0 )
1365  {
1366  for ( int j = 0; j < inv_slots.Count(); ++j )
1367  {
1368  inv_slot = "";
1369  inv_slot = inv_slots.Get(j);
1370 
1371  for ( int k = 0; k < slots.Count(); ++k )
1372  {
1373  string finding_slot_type = slots.Get(k);
1374 
1375  if ( inv_slot == finding_slot_type )
1376  {
1377  array_ret.Get(finding_slot_type).Insert(childName);
1378  }
1379  }
1380  }
1381  }
1382  else
1383  {
1384  inv_slot = "";
1385  g_Game.ConfigGetText(config_path + " " + childName + " inventorySlot", inv_slot);
1386 
1387  if ( inv_slot != "" )
1388  {
1389  for ( int l = 0; l < slots.Count(); ++l )
1390  {
1391  string finding_slot_type_2 = slots.Get(l);
1392 
1393  if ( inv_slot == finding_slot_type_2 )
1394  {
1395  array_ret.Get(finding_slot_type_2).Insert(childName);
1396  }
1397  }
1398  }
1399  }
1400  }
1401  }
1402 
1403  return array_ret;
1404  }
1405 }
Param2
Definition: ppeconstants.c:66
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
m_WgtRoot
Widget m_WgtRoot
Definition: huddebug.c:92
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
RefreshByLocalProfile
void RefreshByLocalProfile()
Definition: huddebug.c:279
PluginConfigDebugProfile
Definition: pluginconfigdebugprofilefixed.c:1
TStringArray
array< string > TStringArray
Definition: enscript.c:685
EditBoxWidget
Definition: enwidgets.c:353
IsModuleExist
bool IsModuleExist(typename plugin_type)
Definition: pluginmanager.c:339
OnHide
override void OnHide()
Definition: inventorymenu.c:141
y
Icon y
UIPropertyAttachment
Definition: uipropertyattachment.c:1
SceneObject
Definition: sceneobject.c:1
Refresh
void Refresh()
Definition: sizetochild.c:108
Param3
Definition: entityai.c:95
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
TIntArray
array< int > TIntArray
Definition: enscript.c:687
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
vector
Definition: enconvert.c:105
OnDoubleClick
override bool OnDoubleClick(Widget w, int x, int y, int button)
Definition: missionloader.c:84
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
TextWidget
Definition: enwidgets.c:219
CFG_VEHICLESPATH
const string CFG_VEHICLESPATH
Definition: constants.c:209
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
Object
Definition: objecttyped.c:1
class_name
class OptionSelectorMultistate extends OptionSelector class_name
UIPopupScript
Definition: uipopupscriptconfigs.c:1
CFG_MAGAZINESPATH
const string CFG_MAGAZINESPATH
Definition: constants.c:211
CFG_WEAPONSPATH
const string CFG_WEAPONSPATH
Definition: constants.c:210
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
x
Icon x
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
m_ConfigDebugProfile
PluginConfigDebugProfile m_ConfigDebugProfile
Definition: pluginitemdiagnostic.c:58
DayZPhysics
Definition: dayzphysics.c:123
OnChange
bool OnChange(Widget w, int x, int y, bool finished)
Definition: huddebug.c:336
OnShow
override void OnShow()
Definition: controlsxbox.c:349
Widget
Definition: enwidgets.c:189
OnClick
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition: dayzgame.c:146
m_SelectedObject
protected Widget m_SelectedObject
Definition: radialmenu.c:16
EntityAI
Definition: building.c:5