DayZ 1.24
Loading...
Searching...
No Matches
ScriptConsoleItemsTab.c
Go to the documentation of this file.
1typedef Param3<string, bool, bool> PresetParams;// param1 - ??, param2 - ??, param3 - ??
2
4{
5 protected const string CONST_DEFAULT_PRESET_PREFIX = "[Default]";
6 protected static int ITEMS_SELECTED_ROW = -1;
7 protected static int PRESETS_SELECTED_ROW = 0;
8 protected static int ITEMS_IN_PRESET_SELECTED_ROW;
9 protected static float DRAW_DISTANCE = 1000;
10 protected static bool CLEAR_IVN;
11 protected static int m_ObjectsScope = 2;
12 protected static string m_LastSelectedObject;
13 protected static int m_SelectedObjectIsPreset = -1;
15 protected static EntityAI m_PreviewEntity;
16 protected static float m_ItemQuantity = 1;
17 protected static bool m_WithPhysics = false;
18
19
21 protected ref array<string> m_CategoryButtonsNames = {"FIREARMS", "MELEE", "ATTACHMENTS", "MAGAZINES", "AMMO", "FOOD", "MEDICAL", "CARS", "BACKPACKS", "B-BUILDING"};
23 protected int m_CategoryMask;
24 protected MissionGameplay m_MissionGameplay;
26 protected PluginDeveloper m_Developer;
27 protected bool m_FilterOrderReversed;
28 protected string m_SelectedObject;
29 protected bool m_IsShiftDown;
30 protected string m_FilterTextPrev;
31 //Widgets
75
76
78 {
79 m_Developer = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
80
81 m_DrawInWorld = ButtonWidget.Cast(root.FindAnyWidget("ButtonDrawItem"));
82 m_DrawInWorldClear = ButtonWidget.Cast(root.FindAnyWidget("ButtonDrawItemClear"));
83
84 m_CategoryMergeType = CheckBoxWidget.Cast(root.FindAnyWidget("CategoryMergeType"));
85 m_ItemPreviewCheckbox = CheckBoxWidget.Cast(root.FindAnyWidget("ItemPreviewCheckbox"));
86 m_ShowProtected = CheckBoxWidget.Cast(root.FindAnyWidget("ShowProtectedCheckbox"));
87 m_FilterOrderImage = ImageWidget.Cast(root.FindAnyWidget("ObjectFilterSortPic"));
88 m_ClearInventory = CheckBoxWidget.Cast(root.FindAnyWidget("ForceClearCheckbox"));
89 m_DrawDistanceWidget = EditBoxWidget.Cast(root.FindAnyWidget("DrawItemDistance"));
90 m_ObjectFilter = MultilineEditBoxWidget.Cast(root.FindAnyWidget("ObjectFilter"));
91 m_SpawnDistanceEditBox = EditBoxWidget.Cast(root.FindAnyWidget("SpawnDistance"));
92 m_SelectedObjectText = TextWidget.Cast(root.FindAnyWidget("SelectedObject"));
93 m_ObjectsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("ObjectsList"));
94 m_PresetsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("PresetList"));
95 m_PresetItemsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("PresetItemsList"));
96 m_PresetNewButton = ButtonWidget.Cast(root.FindAnyWidget("NewPresetButton"));
97 m_PresetDeleteButton = ButtonWidget.Cast(root.FindAnyWidget("DeletePresetButton"));
98 m_PresetRenameButton = ButtonWidget.Cast(root.FindAnyWidget("RenamePresetButton"));
99 m_PresetSetDefaultButton = ButtonWidget.Cast(root.FindAnyWidget("SetDefaultPresetButton"));
100 m_PresetAddItemtButton = ButtonWidget.Cast(root.FindAnyWidget("AddToPresetButton"));
101 m_ItemNameCopy = ButtonWidget.Cast(root.FindAnyWidget("ItemNameCopy"));
102 m_PresetRemoveItemButton = ButtonWidget.Cast(root.FindAnyWidget("RemoveFromPresetButton"));
103 m_ItemMoveUpButton = ButtonWidget.Cast(root.FindAnyWidget("ItemMoveUpButton"));
104 m_ItemMoveDownButton = ButtonWidget.Cast(root.FindAnyWidget("ItemMoveDownButton"));
105 m_ItemPreviewWidget = ItemPreviewWidget.Cast(root.FindAnyWidget("ItemPreviewWidget"));
106
107 m_QuantityEditBox = EditBoxWidget.Cast(root.FindAnyWidget("QuantityValue"));
108 m_DamageEditBox = EditBoxWidget.Cast(root.FindAnyWidget("DamageValue"));
109 m_ItemDamageLabel = TextWidget.Cast(root.FindAnyWidget("DamageLabel"));
110 m_ItemQuantityLabel = TextWidget.Cast(root.FindAnyWidget("QuantityLabel"));
111 m_WithPhysicsCheckbox = CheckBoxWidget.Cast(root.FindAnyWidget("WithPhysicsCheckbox"));
112
113 m_SpawnInInvButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnInInv"));
114 m_SpawnGroundButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnInGround"));
115 m_SpawnOnTarget = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnInTarget"));
116 m_SpawnOnCursor = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnCursor"));
117 m_SpawnInHands = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnHands"));
118 m_SpawnBatchButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnBatch"));
119
120 string text;
121 m_SpawnInInvButton.GetText(text);
123 m_SpawnGroundButton.GetText(text);
125 m_SpawnOnTarget.GetText(text);
127 m_SpawnOnCursor.GetText(text);
129 m_SpawnInHands.GetText(text);
131 m_SpawnBatchButton.GetText(text);
133
134 m_ListActions = ButtonWidget.Cast(root.FindAnyWidget("ListActions"));
135
136
137 m_RectSpawnColumn = EditBoxWidget.Cast(root.FindAnyWidget("RectangleColumnValue"));
138 m_RectSpawnRow = EditBoxWidget.Cast(root.FindAnyWidget("RectangleRowValue"));
139 m_BatchSpawnQuantity = EditBoxWidget.Cast(root.FindAnyWidget("BatchCount"));
140
141 m_RectSpawnColumnStep = EditBoxWidget.Cast(root.FindAnyWidget("RectangleStepXValue"));
142 m_RectSpawnRowStep = EditBoxWidget.Cast(root.FindAnyWidget("RectangleStepYValue"));
143
144 m_FilterOrderButton = ButtonWidget.Cast(root.FindAnyWidget("ObjectFilterSortButton"));
145 Init();
146 }
147
149 {
150 ITEMS_SELECTED_ROW = m_ObjectsTextListbox.GetSelectedRow();
153
154 m_PresetsTextListbox.ClearItems();
155
156 if (m_PreviewEntity)
157 m_PreviewEntity.Delete();
158
160
162 m_ConfigDebugProfile.SetItemCategoryFlag(m_CategoryMask);
163
164 m_ItemQuantity = m_QuantityEditBox.GetText().ToFloat();
166 }
167
168
169 protected void Init()
170 {
171 m_RefreshFilterTimer.Run(0.85, this, "ChangeFilterItems", null, true);
172 m_PresetDeleteButton.Show(false);
173 m_PresetRenameButton.Show(false);
174 m_DrawDistanceWidget.SetText(DRAW_DISTANCE.ToString());
175
176 m_QuantityEditBox.SetText(m_ItemQuantity.ToString());
178
180 {
181 string txt = (m_ConfigDebugProfile.GetItemSearch());
182 m_ObjectFilter.SetText(m_ConfigDebugProfile.GetItemSearch());
183 m_SpawnDistanceEditBox.SetText(m_ConfigDebugProfile.GetSpawnDistance().ToString());
184
185
186 SetFilterOrder(m_ConfigDebugProfile.GetFilterOrderReversed());
187 //m_ConfigDebugProfile.SetItemCategoryFlag(m_CategoryMask);
188
189 m_BatchSpawnQuantity.SetText(m_ConfigDebugProfile.GetBatchSpawnQuantity().ToString());
190
191 m_CategoryMask = m_ConfigDebugProfile.GetItemCategoryFlag();
193 m_ItemPreviewCheckbox.SetChecked(m_ConfigDebugProfile.GetShowItemPreview());
194
195 array<ref CfgParam> params = m_ConfigDebugProfile.GetBatchSpawnRectangle();
196
197 m_RectSpawnRow.SetText(CfgParamInt.Cast(params.Get(0)).GetValue().ToString());
198 m_RectSpawnColumn.SetText(CfgParamInt.Cast(params.Get(1)).GetValue().ToString());
199 m_RectSpawnRowStep.SetText(CfgParamFloat.Cast(params.Get(2)).GetValue().ToString());
200 m_RectSpawnColumnStep.SetText(CfgParamFloat.Cast(params.Get(3)).GetValue().ToString());
201 }
202
203
204 if (m_ObjectsScope == 1)
205 m_ShowProtected.SetChecked(true);
206 else
207 m_ShowProtected.SetChecked(false);
208
209 int counter = 0;
210 foreach (string name: m_CategoryButtonsNames)
211 {
212 string widget_name = "ItemCategory" + counter;
213
215 if (btw)
216 {
217 btw.SetText(name);
219 int bit = 1 << counter;
220 if (bit & m_CategoryMask)
221 {
222 btw.SetChecked(true);
223 btw.SetTextColor(ARGB(255, 255, 0, 0));
224 }
225 }
226 counter++;
227 }
228
230 {
233
234 m_SelectedObjectText.SetText("Object : " + GetCurrentItemName());
237 }
238
239 ChangeFilterItems(true);
240
242 //RenderPresetItems();
243
244 m_MissionGameplay = MissionGameplay.Cast(GetGame().GetMission());
245
246 if (!m_SelectedObjectIsPreset == 1 && ITEMS_SELECTED_ROW < m_ObjectsTextListbox.GetNumItems() && m_ObjectsTextListbox.GetNumItems() > 0 && ITEMS_SELECTED_ROW > -1)
247 {
250
251
253
254
257 m_PresetItemsTextListbox.SelectRow(-1);
259 }
260
261 if (m_PresetsTextListbox.GetNumItems() >= 0)
262 {
266 SelectPreset();
267 else
269 }
270
271 if (m_ObjectsScope == 1)
272 m_ShowProtected.SetChecked(true);
273 else
274 m_ShowProtected.SetChecked(false);
275
276
277 m_CategoryMergeType.SetChecked(m_ConfigDebugProfile.GetMergeType());
278
281 }
282
283 static void DrawItems(string type, float distance = 0)
284 {
285 if (!distance)
289
290 GetGame().GetObjectsAtPosition(GetGame().GetPlayer().GetPosition(), distance, objects, proxies);
291 int i = 0;
292 foreach (Object o: objects)
293 {
294 if (o.IsKindOf(type))
295 {
296 i++;
297 ScriptConsole.m_MarkedEntities.Insert(new MapMarker(o.GetPosition(), "", COLOR_RED, eMapMarkerTypes.MARKERTYPE_MAP_BORDER_CROSS));
298 Shape shape = Shape.CreateSphere(COLOR_RED, ShapeFlags.TRANSP | ShapeFlags.NOOUTLINE | ShapeFlags.NOZBUFFER, o.GetPosition() + "0 30 0", 1);
299 vector lines[2];
300 lines[0] = o.GetPosition();
301 lines[1] = o.GetPosition() + "0 30 0";
302 Shape line = Shape.CreateLines(COLOR_RED, ShapeFlags.TRANSP | ShapeFlags.NOOUTLINE | ShapeFlags.NOZBUFFER, lines, 2);
303 m_DebugShapes.Insert(shape);
304 m_DebugShapes.Insert(line);
305 }
306 }
307
309 //GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLaterByName(this, "DrawItemsClear", 5000);
310 Debug.Log(string.Format("found %1 instances of type %1", i, type));
311 }
312
313
314 static void DrawItemsClear()
315 {
316 ScriptConsole.m_MarkedEntities.Clear();
317 foreach (Shape s: m_DebugShapes)
318 s.Destroy();
319 m_DebugShapes.Clear();
320 }
321
323 static string GetLastSelectedObject()
324 {
326 }
327
328 override bool OnKeyDown(Widget w, int x, int y, int key)
329 {
330 if (key == KeyCode.KC_D && m_SelectedObject != "")
331 {
333 return true;
334 }
335 else
336 return super.OnKeyDown(w, x, y, key);
337 }
338
351
352
354 {
355 m_ObjectsTextListbox.SelectRow(-1);
360 m_SelectedObjectText.SetText("Preset : " + m_SelectedObject);
362
364
366
368 if (command_array.IsValidIndex(0))
369 {
370 string first_line = command_array.Get(0);
371 first_line.ToLower();
372 clear = (first_line == "clear_inv");
373 }
374
375 m_ClearInventory.SetChecked(clear);
376 }
377
379 {
380 return m_PresetsTextListbox.GetSelectedRow();
381 }
382
384 {
385 return m_PresetItemsTextListbox.GetSelectedRow();
386 }
387
389 {
391 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
392 {
395 return item_params_array.param2;
396 }
397 return false;
398 }
399
401 {
404 if (preset_index > -1 && preset_index < m_PresetsTextListbox.GetNumItems())
405 {
407 return item_params_array.param2;
408 }
409 return false;
410 }
411
413 {
414 int i;
415 for (i = 0; i < m_PresetsTextListbox.GetNumItems(); i++)
416 {
419
420 if (item_params_array.param1 == preset_name)
421 return i;
422 }
423 return -1;
424 }
425
427 {
429 {
431
434
435 m_ItemMoveUpButton.Show(true);
436 m_ItemMoveDownButton.Show(true);
437
438 m_ItemDamageLabel.Show(true);
439 m_ItemQuantityLabel.Show(true);
440
441 if (preset_name != "" && item_index > -1)
442 {
443 m_DamageEditBox.Show(true);
444 m_QuantityEditBox.Show(true);
445 m_WithPhysicsCheckbox.Show(true);
446
450
451 // damage
452 m_DamageEditBox.SetText(item_health.ToString());
453
454 // quantity
455 m_QuantityEditBox.SetText(item_quantity.ToString());
456
457 // with physics
459 }
460 else
461 {
462 m_DamageEditBox.Show(false);
463 m_QuantityEditBox.Show(false);
464 m_WithPhysicsCheckbox.Show(false);
465
466 }
467 }
468 }
469
471 {
472 m_ItemMoveUpButton.Show(false);
473 m_ItemMoveDownButton.Show(false);
474 }
475
477 {
478 int object_row = m_ObjectsTextListbox.GetSelectedRow();
480 m_PresetAddItemtButton.Show(true);
481 else
482 m_PresetAddItemtButton.Show(false);
483
485 m_PresetRemoveItemButton.Show(true);
486 else
487 m_PresetRemoveItemButton.Show(false);
488
489 if (object_row > -1)
490 m_ItemNameCopy.Show(true);
491 else
492 m_ItemNameCopy.Show(false);
493
494 }
495
497 {
498 int new_index = GetCurrentItemIndex() - 1;
499 if (GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 && new_index > -1)
500 {
504 }
505 }
506
517
518
520 {
522 m_ConfigDebugProfile.SetSpawnDistance(m_SpawnDistanceEditBox.GetText().ToFloat());
523 }
524
526 {
528 {
530 RefreshLists();
531 }
532 }
533
534
536 {
537 // spawn preset items into inventory
539 if (GetCurrentPresetIndex() != -1)
540 {
543
544 if (is_preset_fixed)
546
547 else
549
550 if (clear_inventory)
551 m_Developer.ClearInventory(target);
552
553 for (int i = 0; i < preset_array.Count(); i++)
554 {
555 float health = -1;
556 int quantity = 1;
557 bool with_physics = false;
558 if (is_preset_fixed)
559 {
563 }
564 else
565 {
566 health = m_ConfigDebugProfile.GetItemHealth(preset_name, i);
567 quantity = m_ConfigDebugProfile.GetItemQuantity(preset_name, i);
568 with_physics = m_ConfigDebugProfile.GetItemWithPhysics(preset_name, i);
569 }
570 if (location == InventoryLocationType.ATTACHMENT)
571 EntityAI ent = m_Developer.SpawnEntityInInventory(target, preset_array.Get(i), -1, quantity, false, preset_name);
572 //m_Developer.SpawnEntityAsAttachment(player, target, preset_array.Get(i), -1, quantity, false, preset_name);
573 else if (location == InventoryLocationType.GROUND)
574 m_Developer.SpawnEntityOnCursorDir(player, preset_array.Get(i), quantity, distance, health, false, preset_name, with_physics);
575 }
576 if (GetGame().IsMultiplayer())
577 {
578 ScriptRPC rpc = new ScriptRPC();
579 rpc.Write(preset_name);
580 rpc.Write(target);
581 rpc.Send(player, ERPCs.DEV_RPC_SPAWN_PRESET, true, player.GetIdentity());
582 }
583 else
584 {
585 PluginDeveloper plugin = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
586 plugin.HandlePresetSpawn(player, preset_name, target);
587 }
588 }
589 }
590
592 {
593 // remove previous default parameter
594 string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
595 if (default_preset != "")
596 {
598 // if is fixed
600 default_preset = "[" + default_preset + "]";
602 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
603 {
605 prev_preset_params_array.param3 = false; // remove DEFAULT
607 }
608 }
609
610 // set preset on preset_index to default
611 // if is fixed
614 preset_name = "[" + preset_name + "]";
615 // set new default preset
618 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
619 {
621 preset_params_array.param3 = true; // DEFAULT
623 }
624 // store preset
625 m_ConfigDebugProfile.SetDefaultPreset(GetCurrentPresetName());
626 }
627
628 void SetObject(string object)
629 {
631
632 if (m_ConfigDebugProfile && m_ConfigDebugProfile.GetShowItemPreview())
633 SetPreviewObject(object);
634
635 }
636
637 void SetPreviewObject(string object)
638 {
639#ifdef DEVELOPER
640 if (m_PreviewEntity)
641 m_PreviewEntity.Delete();
642
643 if (!GetGame().IsKindOf(object, "DZ_LightAI") && !GetGame().IsKindOf(object, "Man"))
644 {
645 DayZGame.m_IsPreviewSpawn = true;
647 m_PreviewEntity = EntityAI.Cast(GetGame().CreateObjectEx(object, "0 0 0", ECE_LOCAL | ECE_CREATEPHYSICS | ECE_TRACE));
648 DayZGame.m_IsPreviewSpawn = false;
649 if (m_PreviewEntity)
650 {
651 dBodyDestroy(m_PreviewEntity);//prevents cars from acting up when spawned this way(we only want the preview pic, no physics required)
652 m_PreviewEntity.DisableSimulation(true);
654 m_PreviewEntity.SetAllowDamage(false);
655 }
656 }
657#endif
658 }
659
661 {
662 int selected_row_index = m_ObjectsTextListbox.GetSelectedRow();
663 if (selected_row_index != -1 && GetCurrentPresetIndex() != -1)
664 {
665 string item_name;
669 }
670 }
671
673 {
674 bool show = true;
676 show = false;
677 m_PresetDeleteButton.Show(show);
678 m_PresetRenameButton.Show(show);
679
681
682 }
683 /*
684 void AddItemToClipboard(TextListboxWidget text_listbox_widget)
685 {
686 int selected_row_index = text_listbox_widget.GetSelectedRow();
687 if (selected_row_index != -1)
688 {
689 string item_name;
690 text_listbox_widget.GetItemText(selected_row_index, 0, item_name);
691 GetGame().CopyToClipboard(item_name);
692 }
693 }*/
694
696 {
697 if (GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1)
698 {
701 }
702 }
703
705 {
707 // load preset items list
708 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
709 {
712 return item_params_array.param1;
713 }
714 return "";
715 }
716
718 {
719 if (GetCurrentItemIndex() != -1)
720 {
721 string item_name;
723 return item_name;
724 }
725 return "";
726 }
727
729 {
730 int selected_row_index = m_ObjectsTextListbox.GetSelectedRow();
731 if (selected_row_index != -1)
732 {
733 string item_name;
735 return item_name;
736 }
737 return "";
738 }
739
741 {
744 }
745
746 // Render specific Preset Items
748 {
749 m_PresetsTextListbox.ClearItems();
750
751 int i;
753
754 // load custom presets list
756 for (i = custom_presets_array.Count() - 1; i >= 0; i--)
757 m_PresetsTextListbox.AddItem(custom_presets_array.Get(i), new PresetParams(custom_presets_array.Get(i), false, false), 0);
758
759 // load fixed presets list
761 for (i = 0; i < presets_array.Count(); i++)
762 m_PresetsTextListbox.AddItem("[" + presets_array.Get(i) + "]", new PresetParams(presets_array.Get(i), true, false), 0);
763 string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
764 if (default_preset != "")
765 {
766 // if is fixed
769 default_preset = "[" + default_preset + "]";
771 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
772 {
775 }
776 }
777 }
778
779 // Render specific Preset Items
781 {
782 // load preset items list
783 int i;
784 m_PresetItemsTextListbox.ClearItems();
785 if (GetCurrentPresetIndex() != -1)
786 {
789
790 if (isFixed)
792 else
794
795 if (preset_array)
796 {
797 for (i = 0; i < preset_array.Count(); i++)
799 }
800 }
801 }
802
804 {
806 RefreshLists();
807 }
808
810 {
811 if (GetCurrentPresetIndex() != -1)
812 {
813 bool result = m_ConfigDebugProfile.PresetRemove(GetCurrentPresetName());
814 RefreshLists();
815 }
816 }
817
819 {
820 switch (color)
821 {
822 case "r":
823 return ARGB(255, 255, 0, 0);
824 case "g":
825 return ARGB(255, 0, 255, 0);
826 case "b":
827 return ARGB(255, 130, 130, 255);
828 case "y":
829 return ARGB(255, 255, 255, 0);
830 case "o":
831 return ARGB(255, 255, 169, 0);
832 }
833 return -1;//white
834 }
835
837 {
838 filter.Trim();
839 filter.ToLower();
840
841 filters = new TStringArray;
843 filter.Split(" ", rawFilters);
844
845 colors = new TIntArray;
846
847
848 foreach (int i, string f: rawFilters)
849 {
850 int color = -1;
851 if (f.IndexOf(":") == 1)//detect color prefix
852 {
853 string clr = f.Substring(0, 1);
854 f = f.Substring(2, f.Length() - 2);//crop off color prefix
856 }
857 else//autocolor
858 {
859 if (i % 2 == 1)
860 color = ARGB(200, 255, 255, 255);
861 }
862 filters.Insert(f);
863 colors.Insert(color);
864 }
865 }
866
867
869 {
870 widget.ClearItems();
871
874
875 string widgetText;
876 filterWidget.GetText(widgetText);
878
881
883
884 for (int i = 0; i < classes.Count(); i++)
885 {
886 string config_path = classes.Get(i);
887
888 int objects_count = GetGame().ConfigGetChildrenCount(config_path);
889 for (int j = 0; j < objects_count; j++)
890 {
891 string child_name;
892
893 GetGame().ConfigGetChildName(config_path, j, child_name);
894
895 int scope = GetGame().ConfigGetInt(config_path + " " + child_name + " scope");
896
898 {
899 int category_bit = GetGame().ConfigGetInt(config_path + " " + child_name + " debug_ItemCategory") - 1;
900 category_bit = (1 << category_bit);
901
902 bool display = false;
903 int color = 0;
905 display = true;
906 else if ((!m_ConfigDebugProfile.GetMergeType() || categoryMask == 0) && filters.Count() > 0)
907 {
909 child_name_lower.ToLower();
910
911 foreach (int indx, string filter: filters)
912 {
913 if (child_name_lower.Contains(filter))
914 {
915 display = false;
916 color = filterColors.Get(indx);
918 if (!arr)
919 {
920 arr = new TStringArray();
922 }
923 arr.Insert(child_name);
925 break;
926 }
927 }
928 }
929 else if (categoryMask == 0)
930 display = true;
931
932 if (display)
933 itemsArray.Insert(child_name);
934
935 }
936 }
937 }
938
939 if (itemsArray)
940 {
941 itemsArray.Sort();
942 foreach (string it: itemsArray)
943 widget.AddItem(it, NULL, 0);
944 }
945
946 if (filters)
947 {
949 filters.Invert();
950
951 foreach (string f: filters)
952 {
954 if (arr2)
955 {
956 arr2.Sort();
957 foreach (string itm: arr2)
958 {
959 int row = widget.AddItem(itm, NULL, 0);
960 int clr = itemsAndColors.Get(itm);
961 if (clr)
962 widget.SetItemColor(row, 0, clr);
963 }
964 }
965 }
966 }
967
968
969 }
970
971
973 {
975 if (reversed)
976 m_FilterOrderImage.SetRotation(0, 0, 180, true);
977 else
978 m_FilterOrderImage.SetRotation(0, 0, 0, true);
979 ChangeFilterItems(true);
981 m_ConfigDebugProfile.SetFilterOrderReversed(reversed);
982 }
983
984 override bool OnChange(Widget w, int x, int y, bool finished)
985 {
986 super.OnChange(w, x, y, finished);
987 if (w == m_ShowProtected)
988 {
989 if (m_ShowProtected.IsChecked())
990 m_ObjectsScope = 1;
991 else
992 m_ObjectsScope = 2;
993 ChangeFilterItems(true);
994 return true;
995 }
996 else if (w == m_ClearInventory)
997 {
998 CLEAR_IVN = m_ClearInventory.IsChecked();
999 return true;
1000 }
1001 else if (m_CategoryButtonsWidgets.Find(w) >= 0)
1002 {
1003
1004 int pos = m_CategoryButtonsWidgets.Find(w);
1005 int bit = Math.Pow(2, pos);
1007 if (cbw.IsChecked())
1008 {
1010 cbw.SetTextColor(ARGB(255, 255, 0, 0));
1011 }
1012 else
1013 {
1015 cbw.SetTextColor(ARGB(255, 255, 255, 255));
1016 }
1017
1018 ChangeFilterItems(true);
1019 return true;
1020 }
1021
1022 /*
1023 if (w == m_ObjectFilter)
1024 {
1025 m_RefreshFilterTimer.Run(0.85, this, "ChangeFilterItems", null, false);
1026 return true;
1027 }*/
1028 if (w == m_QuantityEditBox && (GetCurrentItemIndex() >= 0 || GetCurrentPresetName() != ""))
1029 {
1030 m_ConfigDebugProfile.SetItemQuantity(GetCurrentPresetName(), GetCurrentItemIndex(), m_QuantityEditBox.GetText().ToFloat());
1031 return true;
1032 }
1033 else if (w == m_DrawDistanceWidget)
1034 {
1035 DRAW_DISTANCE = m_DrawDistanceWidget.GetText().ToFloat();
1036 return true;
1037 }
1038 else if (w == m_DamageEditBox && (GetCurrentItemIndex() >= 0 || GetCurrentPresetName() != ""))
1039 {
1040 m_ConfigDebugProfile.SetItemHealth(GetCurrentPresetName(), GetCurrentItemIndex(), m_DamageEditBox.GetText().ToFloat());
1041 return true;
1042 }
1043 else if (w == m_WithPhysicsCheckbox && (GetCurrentItemIndex() >= 0 || GetCurrentPresetName() != ""))
1044 {
1046 return true;
1047 }
1048 else if (w == m_BatchSpawnQuantity)
1049 {
1050 m_ConfigDebugProfile.SetBatchSpawnQuantity(m_BatchSpawnQuantity.GetText().ToInt());
1051 return true;
1052 }
1054 {
1055 if (w == m_RectSpawnRow || w == m_RectSpawnColumn)
1056 {
1057 int rowQ = m_RectSpawnRow.GetText().ToInt();
1058 int columnQ = m_RectSpawnColumn.GetText().ToInt();
1059 int result = columnQ * rowQ;
1060 m_BatchSpawnQuantity.SetText(result.ToString());
1061 m_ConfigDebugProfile.SetBatchSpawnQuantity(m_BatchSpawnQuantity.GetText().ToInt());
1062 }
1063
1065 m_ConfigDebugProfile.SetBatchSpawnRectangle(m_RectSpawnRow.GetText().ToInt(), m_RectSpawnColumn.GetText().ToInt(), m_RectSpawnRowStep.GetText().ToFloat(), m_RectSpawnColumnStep.GetText().ToFloat());
1066 return true;
1067 }
1068 return false;
1069 }
1070
1071 override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
1072 {
1073 super.OnItemSelected(w, x, y, row, column, oldRow, oldColumn);
1075 {
1076 if (m_PresetsTextListbox.GetSelectedRow() != -1)
1077 {
1078 SelectPreset();
1079 return true;
1080 }
1081 }
1082 else if (w == m_PresetItemsTextListbox)
1083 {
1084 if (m_PresetItemsTextListbox.GetSelectedRow() != -1)
1085 {
1091 }
1092 return true;
1093 }
1094 else if (w == m_ObjectsTextListbox)
1095 {
1096 SelectObject(false);
1097 return true;
1098 }
1099 return false;
1100 }
1101
1102
1103 override bool OnClick(Widget w, int x, int y, int button)
1104 {
1105 super.OnClick(w, x, y, button);
1108 if (w == m_CategoryMergeType)
1109 {
1111 m_ConfigDebugProfile.SetMergeType(m_CategoryMergeType.IsChecked());
1112 ChangeFilterItems(true);
1113 // Refresh UI by new settings
1114 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
1115 return true;
1116 }
1117 else if (w == m_ObjectFilter)
1118 {
1119 ChangeFilterItems(true);
1120 return true;
1121 }
1122 else if (w == m_ItemPreviewCheckbox)
1123 {
1125 {
1126 m_ConfigDebugProfile.SetShowItemPreview(m_ItemPreviewCheckbox.IsChecked());
1127 if (!m_ItemPreviewCheckbox.IsChecked())
1129 }
1130 }
1132 {
1134
1135 objects_row_index = m_ObjectsTextListbox.GetSelectedRow();
1136
1137 vector rayStart = GetGame().GetCurrentCameraPosition();
1138 vector rayEnd = rayStart + GetGame().GetCurrentCameraDirection() * 50;
1139 vector hitPos;
1143 //DayZPhysics.RaycastRV(rayStart, rayEnd, hitPos, hitNormal, hitComponentIndex, hitObjects, NULL, player,);
1145
1147 if (hitObjects.Count())
1148 target = EntityAI.Cast(hitObjects.Get(0));
1149
1150 if (m_SelectedObject != "")
1151 {
1152 // @NOTE: duplicate code in PluginDeveloper.c
1153 float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
1154
1155
1156 if (m_SelectedObjectIsPreset == 1)
1157 {
1158 //------------ PRESETS -------------
1159 switch (w)
1160 {
1161 case m_SpawnOnTarget:
1162 {
1163 if (target && target.IsInherited(EntityAI))
1164 {
1167 }
1168 break;
1169 }
1171 {
1173 break;
1174 }
1175 default:
1176 {
1178 break;
1179 }
1180 }
1181 }
1182 else
1183 {
1184 //------------SINGLE ITEMS ------------
1185
1186
1187 float health = m_DamageEditBox.GetText().ToFloat() * MiscGameplayFunctions.GetTypeMaxGlobalHealth(m_SelectedObject);
1188 float quantity = m_QuantityEditBox.GetText().ToFloat();
1189 bool withPhysics = m_WithPhysicsCheckbox.IsChecked();
1190
1192
1193
1194 switch (w)
1195 {
1197 {
1199 break;
1200 }
1201
1202 case m_SpawnOnTarget:
1203 {
1204 if (target && target.IsInherited(EntityAI))
1205 m_Developer.SpawnEntityInInventory(target, m_SelectedObject, health, quantity, m_IsShiftDown);
1206 break;
1207 }
1208
1209 case m_SpawnInInvButton:
1210 {
1211 m_Developer.SpawnEntityInPlayerInventory(player, m_SelectedObject, -1, quantity, m_IsShiftDown);
1212 break;
1213 }
1214 case m_SpawnInHands:
1215 {
1216 m_Developer.SpawnEntityInPlayerInventory(player, m_SelectedObject, -1, quantity, m_IsShiftDown, "", FindInventoryLocationType.HANDS);
1217 break;
1218 }
1219 case m_SpawnOnCursor:
1221 {
1222 if (spawnOnCrossHair)
1223 m_Developer.SpawnItemOnCrosshair(player, m_SelectedObject, health, quantity, 40, true, m_IsShiftDown, withPhysics);
1224 else
1226 break;
1227 }
1228 }
1229 }
1230 }
1231 return true;
1232 }
1233 else if (w == m_FilterOrderButton)
1234 {
1236 return true;
1237 }
1238 else if (w == m_PresetsTextListbox)
1239 {
1240 SelectPreset();
1241 return true;
1242 }
1243 else if (w == m_PresetItemsTextListbox)
1244 {
1245 m_ObjectsTextListbox.SelectRow(-1);
1248 m_SelectedObjectText.SetText("Object : " + GetCurrentItemName());
1251
1252 return true;
1253 }
1254 else if (w == m_PresetSetDefaultButton)
1255 {
1256 if (GetCurrentPresetName() != "")
1258 return true;
1259 }
1260 else if (w == m_PresetNewButton)
1261 {
1262 g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE_DIALOG_PRESET_NAME, m_ScriptConsole);
1263 return true;
1264 }
1265 else if (w == m_PresetDeleteButton)
1266 {
1267 if (GetCurrentPresetName() != "")
1268 DeletePreset();
1269 return true;
1270 }
1271 else if (w == m_PresetRenameButton)
1272 {
1273 if (GetCurrentPresetName() != "")
1274 g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE_DIALOG_PRESET_RENAME, m_ScriptConsole);
1275 return true;
1276 }
1277 else if (w == m_PresetAddItemtButton)
1278 {
1280 return true;
1281 }
1282 else if (w == m_ItemNameCopy)
1283 {
1285 return true;
1286 }
1287 else if (w == m_PresetRemoveItemButton)
1288 {
1290 return true;
1291 }
1292 else if (w == m_ItemMoveUpButton)
1293 {
1294 ItemMoveUp();
1295 return true;
1296 }
1297 else if (w == m_ItemMoveDownButton)
1298 {
1299 ItemMoveDown();
1300 return true;
1301 }
1302 else if (w == m_SpawnBatchButton)
1303 {
1304 int count = m_BatchSpawnQuantity.GetText().ToInt();
1305 int rows = m_RectSpawnRow.GetText().ToInt();
1306 int columns = m_RectSpawnColumn.GetText().ToInt();
1307 float rowStep = m_RectSpawnRowStep.GetText().ToFloat();
1308 float columnStep = m_RectSpawnColumnStep.GetText().ToFloat();
1309 m_Developer.SpawnEntityOnGroundPatternGrid(player, m_SelectedObject, count, m_DamageEditBox.GetText().ToFloat(), 1, rows, columns, rowStep, columnStep, m_IsShiftDown, m_WithPhysicsCheckbox.IsChecked());
1310 return true;
1311 }
1312 else if (w == m_ListActions)
1313 {
1314 if (!m_PreviewEntity)
1315 return false;
1316
1317 return ListItemRelatedActions();
1318 }
1319 else if (w == m_ObjectsTextListbox)
1320 {
1321 SelectObject();
1322 return true;
1323 }
1324 else if (w == m_DrawInWorld)
1325 {
1327 return true;
1328
1329 }
1330 else if (w == m_DrawInWorldClear)
1331 {
1333 return true;
1334 }
1335
1336 return false;
1337 }
1338
1339 override bool OnDoubleClick(Widget w, int x, int y, int button)
1340 {
1341 super.OnDoubleClick(w, x, y, button);
1342
1343 int i;
1346
1347 if (w == m_ObjectsTextListbox)
1348 {
1349 //select item
1350 m_PresetItemsTextListbox.SelectRow(-1);
1353 m_SelectedObjectText.SetText("Object : " + GetCurrentObjectName());
1354
1358
1359 //spawn item
1361
1362 objects_row_index = m_ObjectsTextListbox.GetSelectedRow();
1363
1364 vector rayStart = GetGame().GetCurrentCameraPosition();
1365 vector rayEnd = rayStart + GetGame().GetCurrentCameraDirection() * 1.5;
1366 vector hitPos;
1371
1372 Object target = NULL;
1373 if (hitObjects.Count())
1374 target = hitObjects.Get(0);
1375
1376 if (m_SelectedObject != "")
1377 {
1378 float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
1379
1380 if (button == 0) //LMB
1381 {
1382 m_Developer.SpawnEntityOnCursorDir(player, m_SelectedObject, 1, distance);
1383 return true;
1384 }
1385 else if (button == 1) //RMB
1386 {
1387 if (GetGame().IsMultiplayer())
1388 m_Developer.SpawnEntityInPlayerInventory(player, m_SelectedObject, -1, -1);
1389 else
1390 {
1391 EntityAI spawned_entity = m_Developer.SpawnEntityOnCursorDir(player, m_SelectedObject, -1, distance);
1392 player.LocalTakeEntityToHands(spawned_entity);
1393 }
1394 return true;
1395 }
1396 else if (button == 2) //MMB
1397 {
1398 m_Developer.SpawnEntityOnCursorDir(player, m_SelectedObject, 1, distance, -1, true);
1399 return true;
1400 }
1401 }
1402
1403 }
1404 else if (w == m_QuantityEditBox)
1405 {
1406 m_QuantityEditBox.SetText("1.0");
1407 return true;
1408 }
1409 return false;
1410 }
1411
1412 override void Update(float timeslice)
1413 {
1414 m_IsShiftDown = KeyState(KeyCode.KC_LSHIFT) || KeyState(KeyCode.KC_RSHIFT);
1415
1417
1418 super.Update(timeslice);
1419 }
1420
1421 void SetTextSpawnButton(ButtonWidget w, bool special, string suffix = " Special")
1422 {
1423 string text = m_SpawnButtonsOriginalText.Get(w);
1424 if (special)
1425 text += suffix;
1426 w.SetText(text);
1427 }
1428
1438
1443
1445 {
1446 string widgetText;
1447 w.GetText(widgetText);
1448
1449 if (widgetText.Contains(","))
1450 {
1451 widgetText.Replace(",", " ");
1452 w.SetLine(0, widgetText);
1453 }
1454 return widgetText;
1455 }
1456
1457 void ChangeFilterItems(bool forced = false)
1458 {
1461 return;
1462
1464 string txt = m_ConfigDebugProfile.GetItemSearch();
1465
1466 m_ConfigDebugProfile.SetItemSearch(widgetText);
1468 }
1469
1471 {
1472 string message = "";
1473
1476 if (interactActions)
1477 {
1478 message += "\n== Interact (F)\n\n";
1480 {
1481 if (iaction.Type() == ActionWorldCraft)
1482 continue;
1483
1484 ActionBase ia = ActionBase.Cast(iaction);
1485 message += string.Format("%1 <%2>\n", Widget.TranslateString(ia.GetText()), ia.ClassName());
1486 }
1487 }
1488
1492 {
1493 message += "\n== Continuous Interact (F hold)\n\n";
1495 {
1496 if (ciaction.Type() == ActionWorldCraft)
1497 continue;
1498
1499 ActionBase cia = ActionBase.Cast(ciaction);
1500 message += string.Format("%1 <%2>\n", Widget.TranslateString(cia.GetText()), cia.ClassName());
1501 }
1502 }
1503
1506 if (singleActions)
1507 {
1508 message += "\n== Single (LMB)\n\n";
1510 {
1511 if (saction.Type() == ActionWorldCraft)
1512 continue;
1513
1514 ActionBase sa = ActionBase.Cast(saction);
1515 message += string.Format("%1 <%2>\n", Widget.TranslateString(sa.GetText()), sa.ClassName());
1516 }
1517 }
1518
1520 m_PreviewEntity.GetActions(ContinuousDefaultActionInput, continuousActions);
1522 {
1524 message += "\n== Continuous (LMB hold)\n\n";
1526 {
1527 if (caction.Type() != ActionWorldCraft)
1528 {
1529 ActionBase ca = ActionBase.Cast(caction);
1530 message += string.Format("%1 <%2>\n", Widget.TranslateString(ca.GetText()), ca.ClassName());
1531 }
1532 else
1534 }
1535 message += "\n== Crafting recipes \n\n";
1536 if (craftingAction)
1537 {
1538 PluginRecipesManager pluginRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
1539 array<RecipeBase> recipes = pluginRecipesManager.GetRecipesForItem(m_PreviewEntity.GetType());
1540 foreach (RecipeBase recipe : recipes)
1541 {
1542 if (recipe.IsItemInRecipe("Inventory_Base"))
1543 continue;
1544
1545 message += string.Format("%1 <%2>\n", Widget.TranslateString(recipe.GetName()), recipe.Type());
1546 }
1547 }
1548 }
1549
1550 ScriptConsoleUniversalInfoDialog infoDialog = ScriptConsoleUniversalInfoDialog.Cast(g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE_UNIVERSAL_INFO_DIALOG, m_ScriptConsole));
1551 infoDialog.SetLabel(string.Format("%1 related actions", m_PreviewEntity.GetType()));
1552 infoDialog.SetContent(message);
1553
1554 return true;
1555 }
1556}
const int ECE_LOCAL
const int ECE_TRACE
const int ECE_CREATEPHYSICS
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
ERPCs
Definition ERPCs.c:2
Icon x
Icon y
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location
PlayerBase GetPlayer()
PluginBase GetPlugin(typename plugin_type)
Param3< string, bool, bool > PresetParams
class JsonUndergroundAreaTriggerData GetPosition
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.
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
static bool IsFreeCameraEnabled()
proto native void SetItem(EntityAI object)
Definition EnMath.c:7
ref array< string > m_CategoryButtonsNames
void SpawnPreset(EntityAI target, bool clear_inventory, string preset_name, InventoryLocationType location=InventoryLocationType.ATTACHMENT, float distance=0)
void PrepareFilters(string filter, out TStringArray filters, out TIntArray colors)
CheckBoxWidget m_WithPhysicsCheckbox
ref map< Widget, string > m_SpawnButtonsOriginalText
TextListboxWidget m_PresetItemsTextListbox
static string GetLastSelectedObject()
MissionGameplay m_MissionGameplay
MultilineEditBoxWidget m_ObjectFilter
CheckBoxWidget m_ItemPreviewCheckbox
void SelectObject(bool hide_presets=true)
override bool OnKeyDown(Widget w, int x, int y, int key)
void NewPreset(string preset_name)
void SetDefaultPreset(int preset_index)
override bool OnDoubleClick(Widget w, int x, int y, int button)
override bool OnChange(Widget w, int x, int y, bool finished)
int GetPresetIndexByName(string preset_name)
static ref array< Shape > m_DebugShapes
TextListboxWidget m_ObjectsTextListbox
string PreprocessFilterText(MultilineEditBoxWidget w)
ItemPreviewWidget m_ItemPreviewWidget
void ChangeFilter(TStringArray classes, TextListboxWidget widget, MultilineEditBoxWidget filterWidget, int categoryMask=-1, bool ignoreScope=false)
static void DrawItems(string type, float distance=0)
TextListboxWidget m_PresetsTextListbox
void RenamePreset(string new_preset_name)
const string CONST_DEFAULT_PRESET_PREFIX
void SetTextSpawnButton(ButtonWidget w, bool special, string suffix=" Special")
bool IsPresetFixed(string preset_name)
override bool OnClick(Widget w, int x, int y, int button)
void SetPreviewObject(string object)
ref array< Widget > m_CategoryButtonsWidgets
void ScriptConsoleItemsTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
int GetFilterColor(string color)
override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
void SetObject(string object)
void ChangeFilterItems(bool forced=false)
void SetFilterOrder(bool reversed)
override void Update(float timeslice)
PluginConfigDebugProfile m_ConfigDebugProfile
void AddItemToClipboard(TextListboxWidget text_listbox_widget)
PluginConfigDebugProfileFixed m_ConfigDebugProfileFixed
proto native CGame GetGame()
const int COLOR_RED
Definition constants.c:64
ShapeFlags
Definition EnDebug.c:126
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
array< string > TStringArray
Definition EnScript.c:666
array< int > TIntArray
Definition EnScript.c:668
KeyCode
Definition EnSystem.c:157
proto native int KeyState(KeyCode key)
static proto float Pow(float v, float power)
Return power of v ^ power.
const string CFG_AMMO
Definition constants.c:212
const string CFG_VEHICLESPATH
Definition constants.c:209
const int MENU_SCRIPTCONSOLE_UNIVERSAL_INFO_DIALOG
Definition constants.c:203
const int MENU_SCRIPTCONSOLE_DIALOG_PRESET_NAME
Definition constants.c:177
const int MENU_SCRIPTCONSOLE_DIALOG_PRESET_RENAME
Definition constants.c:178
const string CFG_WEAPONSPATH
Definition constants.c:210
const string CFG_MAGAZINESPATH
Definition constants.c:211
proto native void dBodyDestroy(notnull IEntity ent)
Destroys attached physics body.
int ARGB(int a, int r, int g, int b)
Definition proto.c:322