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