DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ScriptConsoleItemsTab.c
См. документацию.
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;
14 protected static ref array<Shape> m_DebugShapes = new array<Shape>;
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;
25 protected ref Timer m_RefreshFilterTimer = new Timer();
26 protected PluginDeveloper m_Developer;
27 protected bool m_FilterOrderReversed;
28 protected string m_SelectedObject;
29 protected string m_FilterTextPrev;
30 //Widgets
31 protected CheckBoxWidget m_CategoryMergeType;
32 protected CheckBoxWidget m_ItemPreviewCheckbox;
33 protected CheckBoxWidget m_ShowProtected;
34 protected CheckBoxWidget m_ClearInventory;
35 protected TextListboxWidget m_ObjectsTextListbox;
36 protected TextListboxWidget m_PresetsTextListbox;
37 protected TextListboxWidget m_PresetItemsTextListbox;
38 protected ButtonWidget m_DrawInWorld;
39 protected ButtonWidget m_DrawInWorldClear;
40 protected ButtonWidget m_PresetNewButton;
41 protected ButtonWidget m_PresetDeleteButton;
42 protected ButtonWidget m_PresetRenameButton;
43 protected ButtonWidget m_PresetSetDefaultButton;
44 protected ButtonWidget m_PresetAddItemtButton;
45 protected ButtonWidget m_ItemNameCopy;
46 protected ButtonWidget m_PresetRemoveItemButton;
47 protected ButtonWidget m_ItemMoveUpButton;
48 protected ButtonWidget m_ItemMoveDownButton;
49 protected ButtonWidget m_FilterOrderButton;
50 protected ButtonWidget m_SpawnInInvButton;
51 protected ButtonWidget m_SpawnGroundButton;
52 protected ButtonWidget m_SpawnGroundPatternGrid;
53 protected ButtonWidget m_SpawnOnTarget;
54 protected ButtonWidget m_SpawnOnCursor;
55 protected ButtonWidget m_SpawnInHands;
56 protected ButtonWidget m_SpawnBatchButton;
57 protected ButtonWidget m_ListActions;
58 protected MultilineEditBoxWidget m_ObjectFilter;
68 protected CheckBoxWidget m_WithPhysicsCheckbox;
69 protected ButtonWidget m_ReloadShapeButton;
75 protected ImageWidget m_FilterOrderImage;
76
77
78 void ScriptConsoleItemsTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
79 {
80 m_Developer = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
81
82 m_DrawInWorld = ButtonWidget.Cast(root.FindAnyWidget("ButtonDrawItem"));
83 m_DrawInWorldClear = ButtonWidget.Cast(root.FindAnyWidget("ButtonDrawItemClear"));
84
85 m_CategoryMergeType = CheckBoxWidget.Cast(root.FindAnyWidget("CategoryMergeType"));
86 m_ItemPreviewCheckbox = CheckBoxWidget.Cast(root.FindAnyWidget("ItemPreviewCheckbox"));
87 m_ReloadShapeButton = ButtonWidget.Cast(root.FindAnyWidget("ReloadShapeButton"));
88 m_ShowProtected = CheckBoxWidget.Cast(root.FindAnyWidget("ShowProtectedCheckbox"));
89 m_FilterOrderImage = ImageWidget.Cast(root.FindAnyWidget("ObjectFilterSortPic"));
90 m_ClearInventory = CheckBoxWidget.Cast(root.FindAnyWidget("ForceClearCheckbox"));
91 m_DrawDistanceWidget = EditBoxWidget.Cast(root.FindAnyWidget("DrawItemDistance"));
92 m_ObjectFilter = MultilineEditBoxWidget.Cast(root.FindAnyWidget("ObjectFilter"));
93 m_SpawnDistanceEditBox = EditBoxWidget.Cast(root.FindAnyWidget("SpawnDistance"));
94 m_SelectedObjectText = TextWidget.Cast(root.FindAnyWidget("SelectedObject"));
95 m_SelectedObjectLocalized = TextWidget.Cast(root.FindAnyWidget("SelectedObjectLocalized"));
96 m_ObjectsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("ObjectsList"));
97 m_PresetsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("PresetList"));
98 m_PresetItemsTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("PresetItemsList"));
99 m_PresetNewButton = ButtonWidget.Cast(root.FindAnyWidget("NewPresetButton"));
100 m_PresetDeleteButton = ButtonWidget.Cast(root.FindAnyWidget("DeletePresetButton"));
101 m_PresetRenameButton = ButtonWidget.Cast(root.FindAnyWidget("RenamePresetButton"));
102 m_PresetSetDefaultButton = ButtonWidget.Cast(root.FindAnyWidget("SetDefaultPresetButton"));
103 m_PresetAddItemtButton = ButtonWidget.Cast(root.FindAnyWidget("AddToPresetButton"));
104 m_ItemNameCopy = ButtonWidget.Cast(root.FindAnyWidget("ItemNameCopy"));
105 m_PresetRemoveItemButton = ButtonWidget.Cast(root.FindAnyWidget("RemoveFromPresetButton"));
106 m_ItemMoveUpButton = ButtonWidget.Cast(root.FindAnyWidget("ItemMoveUpButton"));
107 m_ItemMoveDownButton = ButtonWidget.Cast(root.FindAnyWidget("ItemMoveDownButton"));
108 m_ItemPreviewWidget = ItemPreviewWidget.Cast(root.FindAnyWidget("ItemPreviewWidget"));
109
110 m_QuantityEditBox = EditBoxWidget.Cast(root.FindAnyWidget("QuantityValue"));
111 m_DamageEditBox = EditBoxWidget.Cast(root.FindAnyWidget("DamageValue"));
112 m_ItemDamageLabel = TextWidget.Cast(root.FindAnyWidget("DamageLabel"));
113 m_ItemQuantityLabel = TextWidget.Cast(root.FindAnyWidget("QuantityLabel"));
114 m_WithPhysicsCheckbox = CheckBoxWidget.Cast(root.FindAnyWidget("WithPhysicsCheckbox"));
115
116 m_SpawnInInvButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnInInv"));
117 m_SpawnGroundButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnInGround"));
118 m_SpawnOnTarget = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnInTarget"));
119 m_SpawnOnCursor = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnCursor"));
120 m_SpawnInHands = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnHands"));
121 m_SpawnBatchButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonSpawnBatch"));
122
123 string text;
124 m_SpawnInInvButton.GetText(text);
126 m_SpawnGroundButton.GetText(text);
128 m_SpawnOnTarget.GetText(text);
130 m_SpawnOnCursor.GetText(text);
132 m_SpawnInHands.GetText(text);
134 m_SpawnBatchButton.GetText(text);
136
137 m_ListActions = ButtonWidget.Cast(root.FindAnyWidget("ListActions"));
138
139
140 m_RectSpawnColumn = EditBoxWidget.Cast(root.FindAnyWidget("RectangleColumnValue"));
141 m_RectSpawnRow = EditBoxWidget.Cast(root.FindAnyWidget("RectangleRowValue"));
142 m_BatchSpawnQuantity = EditBoxWidget.Cast(root.FindAnyWidget("BatchCount"));
143
144 m_RectSpawnColumnStep = EditBoxWidget.Cast(root.FindAnyWidget("RectangleStepXValue"));
145 m_RectSpawnRowStep = EditBoxWidget.Cast(root.FindAnyWidget("RectangleStepYValue"));
146
147 m_FilterOrderButton = ButtonWidget.Cast(root.FindAnyWidget("ObjectFilterSortButton"));
148 Init();
149 }
150
152 {
153 ITEMS_SELECTED_ROW = m_ObjectsTextListbox.GetSelectedRow();
156
157 m_PresetsTextListbox.ClearItems();
158
159 if (m_PreviewEntity)
160 {
161 m_PreviewEntity.Delete();
162 }
163
165
167 {
168 m_ConfigDebugProfile.SetItemCategoryFlag(m_CategoryMask);
169 }
170
171 m_ItemQuantity = m_QuantityEditBox.GetText().ToFloat();
173 }
174
175
176
177 protected void Init()
178 {
179 m_RefreshFilterTimer.Run(0.85, this, "ChangeFilterItems", null, true);
180 m_PresetDeleteButton.Show(false);
181 m_PresetRenameButton.Show(false);
182 m_DrawDistanceWidget.SetText(DRAW_DISTANCE.ToString());
183
184 m_QuantityEditBox.SetText(m_ItemQuantity.ToString());
186
188 {
189 string txt = (m_ConfigDebugProfile.GetItemSearch());
190 m_ObjectFilter.SetText(m_ConfigDebugProfile.GetItemSearch());
191 m_SpawnDistanceEditBox.SetText(m_ConfigDebugProfile.GetSpawnDistance().ToString());
192
193
194 SetFilterOrder(m_ConfigDebugProfile.GetFilterOrderReversed());
195 //m_ConfigDebugProfile.SetItemCategoryFlag(m_CategoryMask);
196
197 m_BatchSpawnQuantity.SetText(m_ConfigDebugProfile.GetBatchSpawnQuantity().ToString());
198
199 m_CategoryMask = m_ConfigDebugProfile.GetItemCategoryFlag();
201 {
202 m_ItemPreviewCheckbox.SetChecked(m_ConfigDebugProfile.GetShowItemPreview());
203 }
204
205 array<ref CfgParam> params = m_ConfigDebugProfile.GetBatchSpawnRectangle();
206
207 m_RectSpawnRow.SetText(CfgParamInt.Cast(params.Get(0)).GetValue().ToString());
208 m_RectSpawnColumn.SetText(CfgParamInt.Cast(params.Get(1)).GetValue().ToString());
209 m_RectSpawnRowStep.SetText(CfgParamFloat.Cast(params.Get(2)).GetValue().ToString());
210 m_RectSpawnColumnStep.SetText(CfgParamFloat.Cast(params.Get(3)).GetValue().ToString());
211 }
212
213
214 if (m_ObjectsScope == 1)
215 m_ShowProtected.SetChecked(true);
216 else
217 m_ShowProtected.SetChecked(false);
218
219 int counter = 0;
220 foreach (string name: m_CategoryButtonsNames)
221 {
222 string widget_name = "ItemCategory" + counter;
223
224 CheckBoxWidget btw = CheckBoxWidget.Cast(m_ParentRoot.FindAnyWidget(widget_name));
225 if (btw)
226 {
227 btw.SetText(name);
228 m_CategoryButtonsWidgets.Insert(btw);
229 int bit = 1 << counter;
230 if (bit & m_CategoryMask)
231 {
232 btw.SetChecked(true);
233 btw.SetTextColor(ARGB(255, 255, 0, 0));
234 }
235 }
236 counter++;
237 }
238
240 {
243
244 m_SelectedObjectText.SetText("Object : " + GetCurrentItemName());
247 }
248
249 ChangeFilterItems(true);
250
252 //RenderPresetItems();
253
254 m_MissionGameplay = MissionGameplay.Cast(GetGame().GetMission());
255
256 if (!m_SelectedObjectIsPreset == 1 && ITEMS_SELECTED_ROW < m_ObjectsTextListbox.GetNumItems() && m_ObjectsTextListbox.GetNumItems() > 0 && ITEMS_SELECTED_ROW > -1)
257 {
260
261
263
264
267 m_PresetItemsTextListbox.SelectRow(-1);
269 }
270
271 if (m_PresetsTextListbox.GetNumItems() >= 0)
272 {
276 SelectPreset();
277 else
279 }
280
281 if (m_ObjectsScope == 1)
282 m_ShowProtected.SetChecked(true);
283 else
284 m_ShowProtected.SetChecked(false);
285
286
287 m_CategoryMergeType.SetChecked(m_ConfigDebugProfile.GetMergeType());
288
291 }
292
293 static void DrawItems(string type, float distance = 0)
294 {
295 if (!distance)
296 {
297 distance = DRAW_DISTANCE;
298 }
299 array<Object> objects = new array<Object>;
301
302 GetGame().GetObjectsAtPosition(GetGame().GetPlayer().GetPosition(), distance, objects, proxies);
303 int i = 0;
304 foreach (Object o: objects)
305 {
306 if (o.IsKindOf(type))
307 {
308 i++;
309 ScriptConsole.m_MarkedEntities.Insert(new MapMarker(o.GetPosition(),"",COLOR_RED,eMapMarkerTypes.MARKERTYPE_MAP_BORDER_CROSS));
310 Shape shape = Shape.CreateSphere(COLOR_RED, ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE|ShapeFlags.NOZBUFFER, o.GetPosition() + "0 30 0", 1);
311 vector lines[2];
312 lines[0] = o.GetPosition();
313 lines[1] = o.GetPosition() + "0 30 0";
314 Shape line = Shape.CreateLines(COLOR_RED, ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE|ShapeFlags.NOZBUFFER, lines, 2);
315 m_DebugShapes.Insert(shape);
316 m_DebugShapes.Insert(line);
317 }
318 }
319
321 //GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLaterByName(this, "DrawItemsClear", 5000);
322 Debug.Log(string.Format("found %1 instances of type %1", i, type));
323 }
324
325
326 static void DrawItemsClear()
327 {
328 ScriptConsole.m_MarkedEntities.Clear();
329 foreach (Shape s: m_DebugShapes)
330 {
331 s.Destroy();
332 }
333 m_DebugShapes.Clear();
334 }
335
337 static string GetLastSelectedObject()
338 {
340 }
341
342 override bool OnKeyDown(Widget w, int x, int y, int key)
343 {
344 if (key == KeyCode.KC_D && m_SelectedObject != "")
345 {
347 return true;
348 }
349 else
350 return super.OnKeyDown(w, x, y, key);
351 }
352
353 void SelectObject(bool hide_presets = true)
354 {
355 if (hide_presets)
356 m_PresetItemsTextListbox.SelectRow(-1);
361
364 }
365
366
368 {
369 m_ObjectsTextListbox.SelectRow(-1);
374 m_SelectedObjectText.SetText("Preset : " + m_SelectedObject);
376
377 TStringArray command_array = new TStringArray;
378
379 m_ConfigDebugProfileFixed.GetPresetItems(m_SelectedObject, command_array, "cmd");
380
381 bool clear = !IsPresetFixed(m_SelectedObject);
382 if (command_array.IsValidIndex(0))
383 {
384 string first_line = command_array.Get(0);
385 first_line.ToLower();
386 clear = (first_line == "clear_inv");
387 }
388
389 m_ClearInventory.SetChecked(clear);
390 }
391
393 {
394 return m_PresetsTextListbox.GetSelectedRow();
395 }
396
398 {
399 return m_PresetItemsTextListbox.GetSelectedRow();
400 }
401
403 {
404 int index = GetCurrentPresetIndex();
405 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
406 {
407 PresetParams item_params_array;
408 m_PresetsTextListbox.GetItemData(index, 0, item_params_array);
409 return item_params_array.param2;
410 }
411 return false;
412 }
413
414 bool IsPresetFixed(string preset_name)
415 {
416 int preset_index = GetPresetIndexByName(preset_name);
417 PresetParams item_params_array;
418 if (preset_index > -1 && preset_index < m_PresetsTextListbox.GetNumItems())
419 {
420 m_PresetsTextListbox.GetItemData(preset_index, 0, item_params_array);
421 return item_params_array.param2;
422 }
423 return false;
424 }
425
426 int GetPresetIndexByName(string preset_name)
427 {
428 int i;
429 for (i = 0; i < m_PresetsTextListbox.GetNumItems(); i++)
430 {
431 PresetParams item_params_array;
432 m_PresetsTextListbox.GetItemData(i, 0, item_params_array);
433
434 if (item_params_array.param1 == preset_name)
435 {
436 return i;
437 }
438 }
439 return -1;
440 }
441
443 {
445 {
447
448 string preset_name = GetCurrentPresetName();
449 int item_index = GetCurrentItemIndex();
450
451 m_ItemMoveUpButton.Show(true);
452 m_ItemMoveDownButton.Show(true);
453
454 m_ItemDamageLabel.Show(true);
455 m_ItemQuantityLabel.Show(true);
456
457 if (preset_name != "" && item_index > -1)
458 {
459 m_DamageEditBox.Show(true);
460 m_QuantityEditBox.Show(true);
461 m_WithPhysicsCheckbox.Show(true);
462
463 float item_health= m_ConfigDebugProfile.GetItemHealth(GetCurrentPresetName(), GetCurrentItemIndex());
464 int item_quantity = m_ConfigDebugProfile.GetItemQuantity(GetCurrentPresetName(), GetCurrentItemIndex());
465 bool item_with_physics = m_ConfigDebugProfile.GetItemWithPhysics(GetCurrentPresetName(), GetCurrentItemIndex());
466
467 // damage
468 m_DamageEditBox.SetText(item_health.ToString());
469
470 // quantity
471 m_QuantityEditBox.SetText(item_quantity.ToString());
472
473 // with physics
474 m_WithPhysicsCheckbox.SetChecked(item_with_physics);
475 }
476 else
477 {
478 m_DamageEditBox.Show(false);
479 m_QuantityEditBox.Show(false);
480 m_WithPhysicsCheckbox.Show(false);
481
482 }
483 }
484 }
485
487 {
488 m_ItemMoveUpButton.Show(false);
489 m_ItemMoveDownButton.Show(false);
490 }
491
493 {
494 int object_row = m_ObjectsTextListbox.GetSelectedRow();
495 if (object_row >-1 && GetCurrentPresetIndex() >-1 && !IsCurrentPresetFixed())
496 {
497 m_PresetAddItemtButton.Show(true);
498 }
499 else
500 {
501 m_PresetAddItemtButton.Show(false);
502 }
503
505 {
506 m_PresetRemoveItemButton.Show(true);
507 }
508 else
509 {
510 m_PresetRemoveItemButton.Show(false);
511 }
512
513 if (object_row > -1)
514 {
515 m_ItemNameCopy.Show(true);
516 }
517 else
518 {
519 m_ItemNameCopy.Show(false);
520 }
521
522 }
523
525 {
526 int new_index = GetCurrentItemIndex() - 1;
527 if (GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 && new_index > -1)
528 {
531 m_PresetItemsTextListbox.SelectRow (new_index);
532 }
533 }
534
536 {
537 int new_index = GetCurrentItemIndex() + 1;
538 if (GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 && new_index < m_PresetItemsTextListbox.GetNumItems())
539 {
542 m_PresetItemsTextListbox.SelectRow (new_index);
543 }
544 }
545
546
548 {
550 {
551 m_ConfigDebugProfile.SetSpawnDistance(m_SpawnDistanceEditBox.GetText().ToFloat());
552 }
553 }
554
555 void RenamePreset(string new_preset_name)
556 {
557 if (new_preset_name && GetCurrentPresetIndex() != -1)
558 {
559 bool result = m_ConfigDebugProfile.PresetRename(GetCurrentPresetName(), new_preset_name);
560 RefreshLists();
561 }
562 }
563
564
565 void SpawnPreset(EntityAI target, bool clear_inventory, string preset_name, InventoryLocationType location = InventoryLocationType.ATTACHMENT, float distance = 0)
566 {
567 // spawn preset items into inventory
568 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
569 if (GetCurrentPresetIndex() != -1)
570 {
571 bool is_preset_fixed = IsCurrentPresetFixed();
572 TStringArray preset_array = new TStringArray;
573
574 if (is_preset_fixed)
575 {
576 m_ConfigDebugProfileFixed.GetPresetItems(preset_name, preset_array);
577
578 }
579 else
580 {
581 m_ConfigDebugProfile.GetPresetItems(preset_name, preset_array);
582 }
583
584 if (clear_inventory)
585 {
586 m_Developer.ClearInventory(target);
587 }
588
589 for (int i = 0; i < preset_array.Count(); i++)
590 {
591 float health = -1;
592 int quantity = 1;
593 bool with_physics = false;
594 if (is_preset_fixed)
595 {
596 health = m_ConfigDebugProfileFixed.GetItemHealth(preset_name, i);
597 quantity = m_ConfigDebugProfileFixed.GetItemQuantity(preset_name, i);
598 with_physics = m_ConfigDebugProfileFixed.GetItemWithPhysics(preset_name, i);
599 }
600 else
601 {
602 health = m_ConfigDebugProfile.GetItemHealth(preset_name, i);
603 quantity = m_ConfigDebugProfile.GetItemQuantity(preset_name, i);
604 with_physics = m_ConfigDebugProfile.GetItemWithPhysics(preset_name, i);
605 }
606 if (location == InventoryLocationType.ATTACHMENT)
607 EntityAI ent = m_Developer.SpawnEntityInInventory(target, preset_array.Get(i), -1, quantity, false, preset_name);
608 //m_Developer.SpawnEntityAsAttachment(player, target, preset_array.Get(i), -1, quantity, false, preset_name);
609 else if (location == InventoryLocationType.GROUND)
610 {
611 m_Developer.SpawnEntityOnCursorDir(player, preset_array.Get(i), quantity, distance, health, false, preset_name, with_physics);
612 }
613 }
614 if (GetGame().IsMultiplayer())
615 {
616 ScriptRPC rpc = new ScriptRPC();
617 rpc.Write(preset_name);
618 rpc.Write(target);
619 rpc.Send(player, ERPCs.DEV_RPC_SPAWN_PRESET, true, player.GetIdentity());
620 }
621 else
622 {
623 PluginDeveloper plugin = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
624 plugin.HandlePresetSpawn(player,preset_name,target);
625 }
626 }
627 }
628
629 void SetDefaultPreset(int preset_index)
630 {
631 // remove previous default parameter
632 string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
633 if (default_preset != "")
634 {
635 int index = GetPresetIndexByName(default_preset);
636 // if is fixed
637 if (IsPresetFixed(default_preset))
638 {
639 default_preset = "[" + default_preset + "]";
640 }
641 PresetParams prev_preset_params_array;
642 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
643 {
644 m_PresetsTextListbox.GetItemData(index, 0, prev_preset_params_array);
645 prev_preset_params_array.param3 = false; // remove DEFAULT
646 m_PresetsTextListbox.SetItem(index, default_preset, prev_preset_params_array, 0);
647 }
648 }
649
650 // set preset on preset_index to default
651 // if is fixed
652 string preset_name = GetCurrentPresetName();
653 if (IsPresetFixed(preset_name))
654 {
655 preset_name = "[" + preset_name + "]";
656 }
657 // set new default preset
658 PresetParams preset_params_array;
659 index = GetCurrentPresetIndex();
660 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
661 {
662 m_PresetsTextListbox.GetItemData(index, 0, preset_params_array);
663 preset_params_array.param3 = true; // DEFAULT
664 m_PresetsTextListbox.SetItem(index, preset_name + CONST_DEFAULT_PRESET_PREFIX, preset_params_array, 0);
665 }
666 // store preset
667 m_ConfigDebugProfile.SetDefaultPreset(GetCurrentPresetName());
668 }
669
670 void SetObject(string object)
671 {
672 m_SelectedObject = object;
673
674 if (m_ConfigDebugProfile && m_ConfigDebugProfile.GetShowItemPreview())
675 {
676 SetPreviewObject(object);
677 }
678
679 }
680
681 void SetPreviewObject(string object)
682 {
683 #ifdef DEVELOPER
684 if (m_PreviewEntity)
685 {
686 m_PreviewEntity.Delete();
687 }
688
689 m_SelectedObjectLocalized.SetText("");
690
691 if (!GetGame().IsKindOf(object, "DZ_LightAI") && !GetGame().IsKindOf(object, "Man"))
692 {
693 DayZGame.m_IsPreviewSpawn = true;
695 m_PreviewEntity = EntityAI.Cast(GetGame().CreateObjectEx(object, "0 0 0", ECE_LOCAL | ECE_CREATEPHYSICS | ECE_TRACE));
696 DayZGame.m_IsPreviewSpawn = false;
697 if (m_PreviewEntity)
698 {
699 dBodyDestroy(m_PreviewEntity);//prevents cars from acting up when spawned this way(we only want the preview pic, no physics required)
700 m_PreviewEntity.DisableSimulation(true);
702 m_PreviewEntity.SetAllowDamage(false);
703
704 m_SelectedObjectLocalized.SetText(m_PreviewEntity.GetDisplayName());
705 }
706 }
707 #endif
708 }
709
711 {
712 int selected_row_index = m_ObjectsTextListbox.GetSelectedRow();
713 if (selected_row_index != -1 && GetCurrentPresetIndex() != -1)
714 {
715 string item_name;
716 m_ObjectsTextListbox.GetItemText(selected_row_index, 0, item_name);
717 m_ConfigDebugProfile.ItemAddToPreset(GetCurrentPresetName(), item_name);
719 }
720 }
721
723 {
724 bool show = true;
726 {
727 show = false;
728 }
729 m_PresetDeleteButton.Show(show);
730 m_PresetRenameButton.Show(show);
731
733
734 }
735/*
736 void AddItemToClipboard(TextListboxWidget text_listbox_widget)
737 {
738 int selected_row_index = text_listbox_widget.GetSelectedRow();
739 if (selected_row_index != -1)
740 {
741 string item_name;
742 text_listbox_widget.GetItemText(selected_row_index, 0, item_name);
743 GetGame().CopyToClipboard(item_name);
744 }
745 }*/
746
748 {
749 if (GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1)
750 {
753 }
754 }
755
757 {
758 int index = GetCurrentPresetIndex();
759 // load preset items list
760 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
761 {
762 PresetParams item_params_array;
763 m_PresetsTextListbox.GetItemData(index, 0, item_params_array);
764 return item_params_array.param1;
765 }
766 return "";
767 }
768
770 {
771 if (GetCurrentItemIndex() != -1)
772 {
773 string item_name;
774 m_PresetItemsTextListbox.GetItemText(GetCurrentItemIndex(), 0, item_name);
775 return item_name;
776 }
777 return "";
778 }
779
781 {
782 int selected_row_index = m_ObjectsTextListbox.GetSelectedRow();
783 if (selected_row_index != -1)
784 {
785 string item_name;
786 m_ObjectsTextListbox.GetItemText(selected_row_index, 0, item_name);
787 return item_name;
788 }
789 return "";
790 }
791
793 {
796 }
797
798 // Render specific Preset Items
800 {
801 m_PresetsTextListbox.ClearItems();
802
803 int i;
804 TBoolArray preset_params;
805
806 // load custom presets list
807 TStringArray custom_presets_array = m_ConfigDebugProfile.GetPresets();
808 for (i = custom_presets_array.Count() - 1; i >= 0; i--)
809 {
810 m_PresetsTextListbox.AddItem(custom_presets_array.Get(i), new PresetParams (custom_presets_array.Get(i),false, false), 0);
811 }
812
813 // load fixed presets list
814 TStringArray presets_array = m_ConfigDebugProfileFixed.GetPresets();
815 for (i = 0; i < presets_array.Count(); i++)
816 {
817 m_PresetsTextListbox.AddItem("["+presets_array.Get(i)+"]", new PresetParams (presets_array.Get(i), true, false), 0);
818 }
819 string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
820 if (default_preset != "")
821 {
822 // if is fixed
823 int index = GetPresetIndexByName(default_preset);
824 if (IsPresetFixed(default_preset))
825 {
826 default_preset = "[" + default_preset + "]";
827 }
828 PresetParams preset_params_array;
829 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
830 {
831 m_PresetsTextListbox.GetItemData(index, 0, preset_params_array);
832 m_PresetsTextListbox.SetItem(index, default_preset + CONST_DEFAULT_PRESET_PREFIX, preset_params_array, 0);
833 }
834 }
835 }
836
837 // Render specific Preset Items
839 {
840 // load preset items list
841 int i;
842 m_PresetItemsTextListbox.ClearItems();
843 if (GetCurrentPresetIndex() != -1)
844 {
845 bool isFixed = IsCurrentPresetFixed();
846 TStringArray preset_array = new TStringArray;
847
848 if (isFixed)
849 {
850 m_ConfigDebugProfileFixed.GetPresetItems(GetCurrentPresetName(), preset_array);
851 }
852 else
853 {
854 m_ConfigDebugProfile.GetPresetItems(GetCurrentPresetName(), preset_array);
855 }
856
857 if (preset_array)
858 {
859 for (i = 0; i < preset_array.Count(); i++)
860 {
861 m_PresetItemsTextListbox.AddItem(preset_array.Get(i), NULL, 0);
862 }
863 }
864 }
865 }
866
867 void NewPreset(string preset_name)
868 {
869 m_ConfigDebugProfile.PresetAdd(preset_name);
870 RefreshLists();
871 }
872
874 {
875 if (GetCurrentPresetIndex() != -1)
876 {
877 bool result = m_ConfigDebugProfile.PresetRemove(GetCurrentPresetName());
878 RefreshLists();
879 }
880 }
881
882 int GetFilterColor(string color)
883 {
884 switch (color)
885 {
886 case "r":
887 return ARGB(255,255,0,0);
888 case "g":
889 return ARGB(255,0,255,0);
890 case "b":
891 return ARGB(255,130,130,255);
892 case "y":
893 return ARGB(255,255,255,0);
894 case "o":
895 return ARGB(255,255,169,0);
896 }
897 return -1;//white
898 }
899
900 void PrepareFilters(string filter, out TStringArray filters, out TIntArray colors)
901 {
902 filter.Trim();
903 filter.ToLower();
904
905 filters = new TStringArray;
906 TStringArray rawFilters = new TStringArray;
907 filter.Split(" ", rawFilters);
908
909 colors = new TIntArray;
910
911
912 foreach (int i, string f:rawFilters)
913 {
914 int color = -1;
915 if (f.IndexOf(":") == 1)//detect color prefix
916 {
917 string clr = f.Substring(0, 1);
918 f = f.Substring(2, f.Length() - 2);//crop off color prefix
919 color = GetFilterColor(clr);
920 }
921 else//autocolor
922 {
923 if (i%2 == 1)
924 {
925 color = ARGB(200,255,255,255);
926 }
927 }
928 filters.Insert(f);
929 colors.Insert(color);
930 }
931 }
932
933
934 void ChangeFilter(TStringArray classes, TextListboxWidget widget, MultilineEditBoxWidget filterWidget, int categoryMask = -1, bool ignoreScope = false)
935 {
936 widget.ClearItems();
937
938 TStringArray filters;
939 TIntArray filterColors;
940
941 string widgetText;
942 filterWidget.GetText(widgetText);
943 PrepareFilters(widgetText, filters, filterColors);
944
945 map<string,int> itemsAndColors = new map<string,int>();
947
948 TStringArray itemsArray = TStringArray();
949
950 for (int i = 0; i < classes.Count(); i++)
951 {
952 string config_path = classes.Get(i);
953
954 int objects_count = GetGame().ConfigGetChildrenCount(config_path);
955 for (int j = 0; j < objects_count; j++)
956 {
957 string child_name;
958
959 GetGame().ConfigGetChildName(config_path, j, child_name);
960
961 int scope = GetGame().ConfigGetInt(config_path + " " + child_name + " scope");
962
963 if (scope >= m_ObjectsScope || ignoreScope)
964 {
965 int category_bit = GetGame().ConfigGetInt(config_path + " " + child_name + " debug_ItemCategory") - 1;
966 category_bit = (1 << category_bit);
967
968 bool display = false;
969 int color = 0;
970 if (category_bit & categoryMask)
971 {
972 display = true;
973 }
974 else if ((!m_ConfigDebugProfile.GetMergeType() || categoryMask == 0) && filters.Count() > 0)
975 {
976 string child_name_lower = child_name;
977 child_name_lower.ToLower();
978
979 foreach (int indx, string filter:filters)
980 {
981 if (child_name_lower.Contains(filter))
982 {
983 display = false;
984 color = filterColors.Get(indx);
985 TStringArray arr = itemsByFilters.Get(filter);
986 if (!arr)
987 {
988 arr = new TStringArray();
989 itemsByFilters.Set(filter, arr);
990 }
991 arr.Insert(child_name);
992 itemsAndColors.Insert(child_name,color);
993 break;
994 }
995 }
996 }
997 else if (categoryMask == 0)
998 {
999 display = true;
1000 }
1001
1002 if (display)
1003 {
1004 itemsArray.Insert(child_name);
1005
1006 }
1007 }
1008 }
1009 }
1010
1011 if (itemsArray)
1012 {
1013 itemsArray.Sort();
1014 foreach (string it:itemsArray)
1015 {
1016 widget.AddItem(it, NULL, 0);
1017 }
1018 }
1019
1020 if (filters)
1021 {
1023 filters.Invert();
1024
1025 foreach (string f:filters)
1026 {
1027 TStringArray arr2 = itemsByFilters.Get(f);
1028 if (arr2)
1029 {
1030 arr2.Sort();
1031 foreach (string itm: arr2)
1032 {
1033 int row = widget.AddItem(itm, NULL, 0);
1034 int clr = itemsAndColors.Get(itm);
1035 if (clr)
1036 {
1037 widget.SetItemColor(row, 0, clr);
1038 }
1039 }
1040 }
1041 }
1042 }
1043
1044
1045 }
1046
1047
1048 void SetFilterOrder(bool reversed)
1049 {
1050 m_FilterOrderReversed = reversed;
1051 if (reversed)
1052 m_FilterOrderImage.SetRotation(0,0,180,true);
1053 else
1054 m_FilterOrderImage.SetRotation(0,0,0,true);
1055 ChangeFilterItems(true);
1057 {
1058 m_ConfigDebugProfile.SetFilterOrderReversed(reversed);
1059 }
1060 }
1061
1062 override bool OnChange(Widget w, int x, int y, bool finished)
1063 {
1064 super.OnChange(w, x, y, finished);
1065 if (w == m_ShowProtected)
1066 {
1067 if (m_ShowProtected.IsChecked())
1068 {
1069 m_ObjectsScope = 1;
1070 }
1071 else
1072 {
1073 m_ObjectsScope = 2;
1074 }
1075 ChangeFilterItems(true);
1076 return true;
1077 }
1078 else if (w == m_ClearInventory)
1079 {
1080 CLEAR_IVN = m_ClearInventory.IsChecked();
1081 return true;
1082 }
1083 else if (m_CategoryButtonsWidgets.Find(w) >= 0)
1084 {
1085
1086 int pos = m_CategoryButtonsWidgets.Find(w);
1087 int bit = Math.Pow(2,pos);
1088 CheckBoxWidget cbw = CheckBoxWidget.Cast(w);
1089 if (cbw.IsChecked())
1090 {
1092 cbw.SetTextColor(ARGB(255, 255, 0, 0));
1093 }
1094 else
1095 {
1096 m_CategoryMask = (m_CategoryMask & ~bit);
1097 cbw.SetTextColor(ARGB(255, 255, 255,255));
1098 }
1099
1100 ChangeFilterItems(true);
1101 return true;
1102 }
1103
1104 /*
1105 if (w == m_ObjectFilter)
1106 {
1107 m_RefreshFilterTimer.Run(0.85, this, "ChangeFilterItems", null, false);
1108 return true;
1109 }*/
1110 if (w == m_QuantityEditBox && (GetCurrentItemIndex() >= 0 || GetCurrentPresetName() != ""))
1111 {
1112 m_ConfigDebugProfile.SetItemQuantity(GetCurrentPresetName(), GetCurrentItemIndex(), m_QuantityEditBox.GetText().ToFloat());
1113 return true;
1114 }
1115 else if (w == m_DrawDistanceWidget)
1116 {
1117 DRAW_DISTANCE = m_DrawDistanceWidget.GetText().ToFloat();
1118 return true;
1119 }
1120 else if (w == m_DamageEditBox && (GetCurrentItemIndex() >= 0 || GetCurrentPresetName() != ""))
1121 {
1122 m_ConfigDebugProfile.SetItemHealth(GetCurrentPresetName(), GetCurrentItemIndex(), m_DamageEditBox.GetText().ToFloat());
1123 return true;
1124 }
1125 else if (w == m_WithPhysicsCheckbox && (GetCurrentItemIndex() >= 0 || GetCurrentPresetName() != ""))
1126 {
1128 return true;
1129 }
1130 else if (w == m_BatchSpawnQuantity)
1131 {
1132 m_ConfigDebugProfile.SetBatchSpawnQuantity(m_BatchSpawnQuantity.GetText().ToInt());
1133 return true;
1134 }
1135 else if ((w == m_RectSpawnRow || w == m_RectSpawnColumn || w == m_RectSpawnRowStep || w == m_RectSpawnColumnStep))
1136 {
1137 if (w == m_RectSpawnRow || w == m_RectSpawnColumn)
1138 {
1139 int rowQ = m_RectSpawnRow.GetText().ToInt();
1140 int columnQ = m_RectSpawnColumn.GetText().ToInt();
1141 int result = columnQ * rowQ;
1142 m_BatchSpawnQuantity.SetText(result.ToString());
1143 m_ConfigDebugProfile.SetBatchSpawnQuantity(m_BatchSpawnQuantity.GetText().ToInt());
1144 }
1145
1147 {
1148 m_ConfigDebugProfile.SetBatchSpawnRectangle(m_RectSpawnRow.GetText().ToInt(),m_RectSpawnColumn.GetText().ToInt(), m_RectSpawnRowStep.GetText().ToFloat(),m_RectSpawnColumnStep.GetText().ToFloat());
1149 }
1150 return true;
1151 }
1152 return false;
1153 }
1154
1155 override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
1156 {
1157 super.OnItemSelected(w, x, y, row, column, oldRow, oldColumn);
1159 {
1160 if (m_PresetsTextListbox.GetSelectedRow() != -1)
1161 {
1162 SelectPreset();
1163 return true;
1164 }
1165 }
1166 else if (w == m_PresetItemsTextListbox)
1167 {
1168 if (m_PresetItemsTextListbox.GetSelectedRow() != -1)
1169 {
1175 }
1176 return true;
1177 }
1178 else if (w == m_ObjectsTextListbox)
1179 {
1180 SelectObject(false);
1181 return true;
1182 }
1183 return false;
1184 }
1185
1186
1187 override bool OnClick(Widget w, int x, int y, int button)
1188 {
1189 super.OnClick(w,x,y,button);
1190 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
1191 int objects_row_index;
1192 if (w == m_CategoryMergeType)
1193 {
1195 {
1196 m_ConfigDebugProfile.SetMergeType(m_CategoryMergeType.IsChecked());
1197 }
1198 ChangeFilterItems(true);
1199 // Refresh UI by new settings
1200 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
1201 return true;
1202 }
1203 else if (w == m_ObjectFilter)
1204 {
1205 ChangeFilterItems(true);
1206 return true;
1207 }
1208 else if (w == m_ItemPreviewCheckbox)
1209 {
1211 {
1212 m_ConfigDebugProfile.SetShowItemPreview(m_ItemPreviewCheckbox.IsChecked());
1213 if (!m_ItemPreviewCheckbox.IsChecked())
1214 {
1215 m_ItemPreviewWidget.SetItem(null);
1216 }
1217 }
1218 }
1219 else if (w == m_SpawnInInvButton || w == m_SpawnGroundButton || w == m_SpawnOnTarget || w == m_SpawnOnCursor || w == m_SpawnInHands)
1220 {
1222
1223 objects_row_index = m_ObjectsTextListbox.GetSelectedRow();
1224
1226 vector rayEnd = rayStart + GetGame().GetCurrentCameraDirection() * 50;
1227 vector hitPos;
1228 vector hitNormal;
1229 int hitComponentIndex;
1230 set<Object> hitObjects = new set<Object>;
1231 //DayZPhysics.RaycastRV(rayStart, rayEnd, hitPos, hitNormal, hitComponentIndex, hitObjects, NULL, player,);
1232 DayZPhysics.RaycastRV(rayStart, rayEnd, hitPos, hitNormal, hitComponentIndex, hitObjects, NULL, player, false, false, ObjIntersectView, 0.3);
1233
1234 EntityAI target;
1235 if (hitObjects.Count())
1236 target = EntityAI.Cast(hitObjects.Get(0));
1237
1238 if (m_SelectedObject != "")
1239 {
1240 // @NOTE: duplicate code in PluginDeveloper.c
1241 float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
1242
1243
1244 if (m_SelectedObjectIsPreset == 1)
1245 {
1246 //------------ PRESETS -------------
1247 switch (w)
1248 {
1249 case m_SpawnOnTarget:
1250 {
1251 if (target && target.IsInherited(EntityAI))
1252 {
1253 EntityAI att_parent = EntityAI.Cast(target) ;
1255 }
1256 break;
1257 }
1259 {
1260 SpawnPreset(player, false, m_SelectedObject, InventoryLocationType.GROUND, distance);
1261 break;
1262 }
1263 default:
1264 {
1266 break;
1267 }
1268 }
1269 }
1270 else
1271 {
1272 //------------SINGLE ITEMS ------------
1273
1274
1275 float health = m_DamageEditBox.GetText().ToFloat() * MiscGameplayFunctions.GetTypeMaxGlobalHealth(m_SelectedObject);
1276 float quantity = m_QuantityEditBox.GetText().ToFloat();
1277 bool withPhysics = m_WithPhysicsCheckbox.IsChecked();
1278
1279 bool spawnOnCrossHair = DeveloperFreeCamera.IsFreeCameraEnabled() || w == m_SpawnOnCursor;
1280
1281
1282 switch (w)
1283 {
1285 {
1286 m_Developer.SpawnEntityOnCursorDir(player, m_SelectedObject, quantity, distance, health, m_IsShiftDown, "", withPhysics);
1287 break;
1288 }
1289
1290 case m_SpawnOnTarget:
1291 {
1292 if (target && target.IsInherited(EntityAI))
1293 m_Developer.SpawnEntityInInventory(target, m_SelectedObject, health, quantity, m_IsShiftDown);
1294 break;
1295 }
1296
1297 case m_SpawnInInvButton:
1298 {
1299 m_Developer.SpawnEntityInPlayerInventory(player, m_SelectedObject, -1, quantity, m_IsShiftDown);
1300 break;
1301 }
1302 case m_SpawnInHands:
1303 {
1304 m_Developer.SpawnEntityInPlayerInventory(player, m_SelectedObject, -1, quantity, m_IsShiftDown,"", FindInventoryLocationType.HANDS);
1305 break;
1306 }
1307 case m_SpawnOnCursor:
1309 {
1310 if (spawnOnCrossHair)
1311 {
1312 m_Developer.SpawnItemOnCrosshair(player, m_SelectedObject, health, quantity, 40, true, m_IsShiftDown, withPhysics );
1313 }
1314 else
1315 {
1316 m_Developer.SpawnEntityOnCursorDir(player, m_SelectedObject, quantity, distance, health, m_IsShiftDown, "", withPhysics);
1317 }
1318 break;
1319 }
1320 }
1321 }
1322 }
1323 return true;
1324 }
1325 else if (w == m_FilterOrderButton)
1326 {
1328 return true;
1329 }
1330 else if (w == m_PresetsTextListbox)
1331 {
1332 SelectPreset();
1333 return true;
1334 }
1335 else if (w == m_PresetItemsTextListbox)
1336 {
1337 m_ObjectsTextListbox.SelectRow(-1);
1340 m_SelectedObjectText.SetText("Object : " + GetCurrentItemName());
1343
1344 return true;
1345 }
1346 else if (w == m_PresetSetDefaultButton)
1347 {
1348 if (GetCurrentPresetName()!= "")
1349 {
1351 }
1352 return true;
1353 }
1354 else if (w == m_PresetNewButton)
1355 {
1356 g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE_DIALOG_PRESET_NAME, m_ScriptConsole);
1357 return true;
1358 }
1359 else if (w == m_PresetDeleteButton)
1360 {
1361 if (GetCurrentPresetName()!= "")
1362 {
1363 DeletePreset();
1364 }
1365 return true;
1366 }
1367 else if (w == m_PresetRenameButton)
1368 {
1369 if (GetCurrentPresetName()!= "")
1370 {
1371 g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE_DIALOG_PRESET_RENAME, m_ScriptConsole);
1372 }
1373 return true;
1374 }
1375 else if (w == m_PresetAddItemtButton)
1376 {
1378 return true;
1379 }
1380 else if (w == m_ItemNameCopy)
1381 {
1383 return true;
1384 }
1385 else if (w == m_PresetRemoveItemButton)
1386 {
1388 return true;
1389 }
1390 else if (w == m_ItemMoveUpButton)
1391 {
1392 ItemMoveUp();
1393 return true;
1394 }
1395 else if (w == m_ItemMoveDownButton)
1396 {
1397 ItemMoveDown();
1398 return true;
1399 }
1400 else if (w == m_SpawnBatchButton)
1401 {
1402 int count = m_BatchSpawnQuantity.GetText().ToInt();
1403 int rows = m_RectSpawnRow.GetText().ToInt();
1404 int columns = m_RectSpawnColumn.GetText().ToInt();
1405 float rowStep = m_RectSpawnRowStep.GetText().ToFloat();
1406 float columnStep = m_RectSpawnColumnStep.GetText().ToFloat();
1407 m_Developer.SpawnEntityOnGroundPatternGrid(player, m_SelectedObject,count, m_DamageEditBox.GetText().ToFloat(), 1, rows, columns, rowStep, columnStep, m_IsShiftDown, m_WithPhysicsCheckbox.IsChecked());
1408 return true;
1409 }
1410 else if (w == m_ReloadShapeButton)
1411 {
1412#ifdef DEVELOPER
1413 Object obj = m_ItemPreviewWidget.GetItem();
1414 if (obj)
1415 {
1416 GetGame().ReloadShape(obj);
1417 }
1418#endif
1419 }
1420 else if (w == m_ListActions)
1421 {
1422 if (!m_PreviewEntity)
1423 return false;
1424
1425 return ListItemRelatedActions();
1426 }
1427 else if (w == m_ObjectsTextListbox)
1428 {
1429 SelectObject();
1430 return true;
1431 }
1432 else if (w == m_DrawInWorld)
1433 {
1435 return true;
1436
1437 }
1438 else if (w == m_DrawInWorldClear)
1439 {
1441 return true;
1442 }
1443
1444 return false;
1445 }
1446
1447 override bool OnDoubleClick(Widget w, int x, int y, int button)
1448 {
1449 super.OnDoubleClick(w, x, y, button);
1450
1451 int i;
1452 int objects_row_index;
1453 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
1454
1455 if (w == m_ObjectsTextListbox)
1456 {
1457 //select item
1458 m_PresetItemsTextListbox.SelectRow(-1);
1461 m_SelectedObjectText.SetText("Object : " + GetCurrentObjectName());
1462
1466
1467 //spawn item
1469
1470 objects_row_index = m_ObjectsTextListbox.GetSelectedRow();
1471
1473 vector rayEnd = rayStart + GetGame().GetCurrentCameraDirection() * 1.5;
1474 vector hitPos;
1475 vector hitNormal;
1476 int hitComponentIndex;
1477 set<Object> hitObjects = new set<Object>;
1478 DayZPhysics.RaycastRV(rayStart, rayEnd, hitPos, hitNormal, hitComponentIndex, hitObjects, NULL, player);
1479
1480 Object target = NULL;
1481 if (hitObjects.Count())
1482 target = hitObjects.Get(0);
1483
1484 if (m_SelectedObject != "")
1485 {
1486 float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
1487
1488 if (button == 0) //LMB
1489 {
1490 m_Developer.SpawnEntityOnCursorDir(player, m_SelectedObject, 1, distance);
1491 return true;
1492 }
1493 else if (button == 1) //RMB
1494 {
1495 if (GetGame().IsMultiplayer())
1496 {
1497 m_Developer.SpawnEntityInPlayerInventory(player, m_SelectedObject, -1, -1);
1498 }
1499 else
1500 {
1501 EntityAI spawned_entity = m_Developer.SpawnEntityOnCursorDir(player, m_SelectedObject, -1, distance);
1502 player.LocalTakeEntityToHands(spawned_entity);
1503 }
1504 return true;
1505 }
1506 else if (button == 2) //MMB
1507 {
1508 m_Developer.SpawnEntityOnCursorDir(player, m_SelectedObject, 1, distance,-1, true);
1509 return true;
1510 }
1511 }
1512
1513 }
1514 else if (w == m_QuantityEditBox)
1515 {
1516 m_QuantityEditBox.SetText("1.0");
1517 return true;
1518 }
1519 return false;
1520 }
1521
1522 override void Update(float timeslice)
1523 {
1524 super.Update(timeslice);
1525
1527 }
1528
1529 void SetTextSpawnButton(ButtonWidget w, bool special, string suffix = " Special")
1530 {
1531 string text = m_SpawnButtonsOriginalText.Get(w);
1532 if (special)
1533 text += suffix;
1534 w.SetText(text);
1535 }
1536
1546
1551
1552 protected string PreprocessFilterText(MultilineEditBoxWidget w)
1553 {
1554 string widgetText;
1555 w.GetText(widgetText);
1556
1557 if (widgetText.Contains(","))
1558 {
1559 widgetText.Replace(","," ");
1560 w.SetLine(0,widgetText);
1561 }
1562 return widgetText;
1563 }
1564
1565 void ChangeFilterItems(bool forced = false)
1566 {
1567 string widgetText = PreprocessFilterText(m_ObjectFilter);
1568 if (widgetText == m_FilterTextPrev && !forced)
1569 return;
1570
1571 m_FilterTextPrev = widgetText;
1572 string txt = m_ConfigDebugProfile.GetItemSearch();
1573
1574 m_ConfigDebugProfile.SetItemSearch(widgetText);
1576 }
1577
1579 {
1580 string message = "";
1581
1582 array<ActionBase_Basic> interactActions = new array<ActionBase_Basic>();
1583 m_PreviewEntity.GetActions(InteractActionInput, interactActions);
1584 if (interactActions)
1585 {
1586 message += "\n== Interact (F)\n\n";
1587 foreach (ActionBase_Basic iaction : interactActions)
1588 {
1589 if (iaction.Type() == ActionWorldCraft)
1590 continue;
1591
1592 ActionBase ia = ActionBase.Cast(iaction);
1593 message += string.Format("%1 <%2>\n", Widget.TranslateString(ia.GetText()), ia.ClassName());
1594 }
1595 }
1596
1597 array<ActionBase_Basic> continuousInteractActions = new array<ActionBase_Basic>();
1598 m_PreviewEntity.GetActions(ContinuousInteractActionInput, continuousInteractActions);
1599 if (continuousInteractActions)
1600 {
1601 message += "\n== Continuous Interact (F hold)\n\n";
1602 foreach (ActionBase_Basic ciaction : continuousInteractActions)
1603 {
1604 if (ciaction.Type() == ActionWorldCraft)
1605 continue;
1606
1607 ActionBase cia = ActionBase.Cast(ciaction);
1608 message += string.Format("%1 <%2>\n", Widget.TranslateString(cia.GetText()), cia.ClassName());
1609 }
1610 }
1611
1613 m_PreviewEntity.GetActions(DefaultActionInput, singleActions);
1614 if (singleActions)
1615 {
1616 message += "\n== Single (LMB)\n\n";
1617 foreach (ActionBase_Basic saction : singleActions)
1618 {
1619 if (saction.Type() == ActionWorldCraft)
1620 continue;
1621
1622 ActionBase sa = ActionBase.Cast(saction);
1623 message += string.Format("%1 <%2>\n", Widget.TranslateString(sa.GetText()), sa.ClassName());
1624 }
1625 }
1626
1627 array<ActionBase_Basic> continuousActions = new array<ActionBase_Basic>();
1628 m_PreviewEntity.GetActions(ContinuousDefaultActionInput, continuousActions);
1629 if (continuousActions)
1630 {
1631 ActionBase_Basic craftingAction;
1632 message += "\n== Continuous (LMB hold)\n\n";
1633 foreach (ActionBase_Basic caction : continuousActions)
1634 {
1635 if (caction.Type() != ActionWorldCraft)
1636 {
1637 ActionBase ca = ActionBase.Cast(caction);
1638 message += string.Format("%1 <%2>\n", Widget.TranslateString(ca.GetText()), ca.ClassName());
1639 }
1640 else
1641 {
1642 craftingAction = caction;
1643 }
1644 }
1645 message += "\n== Crafting recipes \n\n";
1646 if (craftingAction)
1647 {
1648 PluginRecipesManager pluginRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
1649 array<RecipeBase> recipes = pluginRecipesManager.GetRecipesForItem(m_PreviewEntity.GetType());
1650 foreach (RecipeBase recipe : recipes)
1651 {
1652 if (recipe.IsItemInRecipe("Inventory_Base"))
1653 continue;
1654
1655 message += string.Format("%1 <%2>\n", Widget.TranslateString(recipe.GetName()), recipe.Type());
1656 }
1657 }
1658 }
1659
1660 ScriptConsoleUniversalInfoDialog infoDialog = ScriptConsoleUniversalInfoDialog.Cast(g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE_UNIVERSAL_INFO_DIALOG, m_ScriptConsole));
1661 infoDialog.SetLabel(string.Format("%1 related actions", m_PreviewEntity.GetType()));
1662 infoDialog.SetContent(message);
1663
1664 return true;
1665 }
1666}
void ContinuousDefaultActionInput(PlayerBase player)
Определения ActionInput.c:607
const int ECE_LOCAL
Определения CentralEconomy.c:24
const int ECE_TRACE
Определения CentralEconomy.c:10
const int ECE_CREATEPHYSICS
Определения CentralEconomy.c:16
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:3868
ERPCs
Определения ERPCs.c:2
Icon x
Icon y
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
PlayerBase GetPlayer()
Определения ModifierBase.c:51
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
Param3< string, bool, bool > PresetParams
Определения ScriptConsoleItemsTab.c:1
string GetText()
Определения ActionBase.c:298
Определения ActionBase.c:53
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native void GetObjectsAtPosition(vector pos, float radius, out array< Object > objects, out array< CargoBase > proxyCargos)
Returns list of all objects in circle "radius" around position "pos".
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto native vector GetCurrentCameraPosition()
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native vector GetCurrentCameraDirection()
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.
Определения DayZPhysics.c:124
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.
Определения Debug.c:122
Определения Debug.c:2
static bool IsFreeCameraEnabled()
Определения DeveloperFreeCamera.c:23
Определения EnWidgets.c:354
Определения Building.c:6
Определения gameplay.c:277
Определения InventoryItem.c:1163
Определения EnMath.c:7
Определения ObjectTyped.c:2
Определения EntityAI.c:95
Определения PlayerBaseClient.c:2
Определения RecipeBase.c:6
ButtonWidget m_DrawInWorldClear
Определения ScriptConsoleItemsTab.c:39
ref array< string > m_CategoryButtonsNames
Определения ScriptConsoleItemsTab.c:21
void SpawnPreset(EntityAI target, bool clear_inventory, string preset_name, InventoryLocationType location=InventoryLocationType.ATTACHMENT, float distance=0)
Определения ScriptConsoleItemsTab.c:565
TextWidget m_ItemQuantityLabel
Определения ScriptConsoleItemsTab.c:71
ButtonWidget m_SpawnOnCursor
Определения ScriptConsoleItemsTab.c:54
void PrepareFilters(string filter, out TStringArray filters, out TIntArray colors)
Определения ScriptConsoleItemsTab.c:900
ButtonWidget m_PresetSetDefaultButton
Определения ScriptConsoleItemsTab.c:43
CheckBoxWidget m_WithPhysicsCheckbox
Определения ScriptConsoleItemsTab.c:68
ButtonWidget m_SpawnGroundPatternGrid
Определения ScriptConsoleItemsTab.c:52
ref map< Widget, string > m_SpawnButtonsOriginalText
Определения ScriptConsoleItemsTab.c:22
void ItemMoveDown()
Определения ScriptConsoleItemsTab.c:535
CheckBoxWidget m_ClearInventory
Определения ScriptConsoleItemsTab.c:34
EditBoxWidget m_QuantityEditBox
Определения ScriptConsoleItemsTab.c:65
void ShowItemButtons()
Определения ScriptConsoleItemsTab.c:442
void ShowPresetButtons()
Определения ScriptConsoleItemsTab.c:722
void RenderPresets()
Определения ScriptConsoleItemsTab.c:799
TextListboxWidget m_PresetItemsTextListbox
Определения ScriptConsoleItemsTab.c:37
string m_SelectedObject
Определения ScriptConsoleItemsTab.c:28
static int m_ObjectsScope
Определения ScriptConsoleItemsTab.c:11
ButtonWidget m_DrawInWorld
Определения ScriptConsoleItemsTab.c:38
CheckBoxWidget m_ShowProtected
Определения ScriptConsoleItemsTab.c:33
static string GetLastSelectedObject()
Определения ScriptConsoleItemsTab.c:337
MissionGameplay m_MissionGameplay
Определения ScriptConsoleItemsTab.c:24
MultilineEditBoxWidget m_ObjectFilter
Определения ScriptConsoleItemsTab.c:58
CheckBoxWidget m_ItemPreviewCheckbox
Определения ScriptConsoleItemsTab.c:32
void SelectObject(bool hide_presets=true)
Определения ScriptConsoleItemsTab.c:353
void ItemMoveUp()
Определения ScriptConsoleItemsTab.c:524
ButtonWidget m_ReloadShapeButton
Определения ScriptConsoleItemsTab.c:69
int GetCurrentItemIndex()
Определения ScriptConsoleItemsTab.c:397
void ShowItemTransferButtons()
Определения ScriptConsoleItemsTab.c:492
override bool OnKeyDown(Widget w, int x, int y, int key)
Определения ScriptConsoleItemsTab.c:342
ButtonWidget m_PresetRemoveItemButton
Определения ScriptConsoleItemsTab.c:46
void RefreshLists()
Определения ScriptConsoleItemsTab.c:792
void NewPreset(string preset_name)
Определения ScriptConsoleItemsTab.c:867
CheckBoxWidget m_CategoryMergeType
Определения ScriptConsoleItemsTab.c:31
ButtonWidget m_ItemMoveUpButton
Определения ScriptConsoleItemsTab.c:47
static bool m_WithPhysics
Определения ScriptConsoleItemsTab.c:17
static void DrawItemsClear()
Определения ScriptConsoleItemsTab.c:326
static int ITEMS_SELECTED_ROW
Определения ScriptConsoleItemsTab.c:6
TextWidget m_SelectedObjectText
Определения ScriptConsoleItemsTab.c:72
EditBoxWidget m_DamageEditBox
Определения ScriptConsoleItemsTab.c:66
void SetDefaultPreset(int preset_index)
Определения ScriptConsoleItemsTab.c:629
ButtonWidget m_SpawnInHands
Определения ScriptConsoleItemsTab.c:55
ButtonWidget m_PresetDeleteButton
Определения ScriptConsoleItemsTab.c:41
string GetCurrentItemName()
Определения ScriptConsoleItemsTab.c:769
override bool OnDoubleClick(Widget w, int x, int y, int button)
Определения ScriptConsoleItemsTab.c:1447
static float m_ItemQuantity
Определения ScriptConsoleItemsTab.c:16
EditBoxWidget m_BatchSpawnQuantity
Определения ScriptConsoleItemsTab.c:67
static EntityAI m_PreviewEntity
Определения ScriptConsoleItemsTab.c:15
EditBoxWidget m_DrawDistanceWidget
Определения ScriptConsoleItemsTab.c:64
ButtonWidget m_SpawnOnTarget
Определения ScriptConsoleItemsTab.c:53
ButtonWidget m_PresetNewButton
Определения ScriptConsoleItemsTab.c:40
bool ListItemRelatedActions()
Определения ScriptConsoleItemsTab.c:1578
string GetCurrentObjectName()
Определения ScriptConsoleItemsTab.c:780
void AddItemToPreset()
Определения ScriptConsoleItemsTab.c:710
override bool OnChange(Widget w, int x, int y, bool finished)
Определения ScriptConsoleItemsTab.c:1062
bool IsCurrentPresetFixed()
Определения ScriptConsoleItemsTab.c:402
void ~ScriptConsoleItemsTab()
Определения ScriptConsoleItemsTab.c:151
ButtonWidget m_SpawnGroundButton
Определения ScriptConsoleItemsTab.c:51
int GetPresetIndexByName(string preset_name)
Определения ScriptConsoleItemsTab.c:426
static ref array< Shape > m_DebugShapes
Определения ScriptConsoleItemsTab.c:14
ButtonWidget m_ItemNameCopy
Определения ScriptConsoleItemsTab.c:45
ButtonWidget m_FilterOrderButton
Определения ScriptConsoleItemsTab.c:49
EditBoxWidget m_RectSpawnRow
Определения ScriptConsoleItemsTab.c:60
void UpdateButtonNames()
Определения ScriptConsoleItemsTab.c:1537
ImageWidget m_FilterOrderImage
Определения ScriptConsoleItemsTab.c:75
bool m_FilterOrderReversed
Определения ScriptConsoleItemsTab.c:27
TextListboxWidget m_ObjectsTextListbox
Определения ScriptConsoleItemsTab.c:35
PluginDeveloper m_Developer
Определения ScriptConsoleItemsTab.c:26
string PreprocessFilterText(MultilineEditBoxWidget w)
Определения ScriptConsoleItemsTab.c:1552
ItemPreviewWidget m_ItemPreviewWidget
Определения ScriptConsoleItemsTab.c:74
void ChangeFilter(TStringArray classes, TextListboxWidget widget, MultilineEditBoxWidget filterWidget, int categoryMask=-1, bool ignoreScope=false)
Определения ScriptConsoleItemsTab.c:934
void RenderPresetItems()
Определения ScriptConsoleItemsTab.c:838
static void DrawItems(string type, float distance=0)
Определения ScriptConsoleItemsTab.c:293
ButtonWidget m_ListActions
Определения ScriptConsoleItemsTab.c:57
EditBoxWidget m_RectSpawnRowStep
Определения ScriptConsoleItemsTab.c:62
EditBoxWidget m_RectSpawnColumnStep
Определения ScriptConsoleItemsTab.c:63
TextListboxWidget m_PresetsTextListbox
Определения ScriptConsoleItemsTab.c:36
void HideItemButtons()
Определения ScriptConsoleItemsTab.c:486
int GetCurrentPresetIndex()
Определения ScriptConsoleItemsTab.c:392
static bool CLEAR_IVN
Определения ScriptConsoleItemsTab.c:10
void RenamePreset(string new_preset_name)
Определения ScriptConsoleItemsTab.c:555
const string CONST_DEFAULT_PRESET_PREFIX
Определения ScriptConsoleItemsTab.c:5
void SetTextSpawnButton(ButtonWidget w, bool special, string suffix=" Special")
Определения ScriptConsoleItemsTab.c:1529
ButtonWidget m_PresetRenameButton
Определения ScriptConsoleItemsTab.c:42
bool IsPresetFixed(string preset_name)
Определения ScriptConsoleItemsTab.c:414
override bool OnClick(Widget w, int x, int y, int button)
Определения ScriptConsoleItemsTab.c:1187
ButtonWidget m_ItemMoveDownButton
Определения ScriptConsoleItemsTab.c:48
void SetPreviewObject(string object)
Определения ScriptConsoleItemsTab.c:681
static int PRESETS_SELECTED_ROW
Определения ScriptConsoleItemsTab.c:7
ref array< Widget > m_CategoryButtonsWidgets
Определения ScriptConsoleItemsTab.c:20
static float DRAW_DISTANCE
Определения ScriptConsoleItemsTab.c:9
void ScriptConsoleItemsTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleItemsTab.c:78
ref Timer m_RefreshFilterTimer
Определения ScriptConsoleItemsTab.c:25
static string m_LastSelectedObject
Определения ScriptConsoleItemsTab.c:12
void SelectPreset()
Определения ScriptConsoleItemsTab.c:367
string m_FilterTextPrev
Определения ScriptConsoleItemsTab.c:29
static int ITEMS_IN_PRESET_SELECTED_ROW
Определения ScriptConsoleItemsTab.c:8
string GetCurrentPresetName()
Определения ScriptConsoleItemsTab.c:756
TextWidget m_ItemDamageLabel
Определения ScriptConsoleItemsTab.c:70
EditBoxWidget m_RectSpawnColumn
Определения ScriptConsoleItemsTab.c:61
ButtonWidget m_PresetAddItemtButton
Определения ScriptConsoleItemsTab.c:44
int GetFilterColor(string color)
Определения ScriptConsoleItemsTab.c:882
override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
Определения ScriptConsoleItemsTab.c:1155
void RemoveItemFromPreset()
Определения ScriptConsoleItemsTab.c:747
TStringArray GetItemsClasses()
Определения ScriptConsoleItemsTab.c:1547
EditBoxWidget m_SpawnDistanceEditBox
Определения ScriptConsoleItemsTab.c:59
void DeletePreset()
Определения ScriptConsoleItemsTab.c:873
void SetObject(string object)
Определения ScriptConsoleItemsTab.c:670
void SaveProfileSpawnDistance()
Определения ScriptConsoleItemsTab.c:547
void ChangeFilterItems(bool forced=false)
Определения ScriptConsoleItemsTab.c:1565
void SetFilterOrder(bool reversed)
Определения ScriptConsoleItemsTab.c:1048
TextWidget m_SelectedObjectLocalized
Определения ScriptConsoleItemsTab.c:73
ButtonWidget m_SpawnBatchButton
Определения ScriptConsoleItemsTab.c:56
ButtonWidget m_SpawnInInvButton
Определения ScriptConsoleItemsTab.c:50
override void Update(float timeslice)
Определения ScriptConsoleItemsTab.c:1522
static int m_SelectedObjectIsPreset
Определения ScriptConsoleItemsTab.c:13
bool m_IsShiftDown
Определения ScriptConsoleTabBase.c:5
PluginConfigDebugProfile m_ConfigDebugProfile
Определения ScriptConsoleTabBase.c:11
void ScriptConsoleTabBase(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleTabBase.c:14
void AddItemToClipboard(TextListboxWidget text_listbox_widget)
Определения ScriptConsoleTabBase.c:90
ScriptConsole m_ScriptConsole
Определения ScriptConsoleTabBase.c:9
PluginConfigDebugProfileFixed m_ConfigDebugProfileFixed
Определения ScriptConsoleTabBase.c:12
Widget m_ParentRoot
Определения ScriptConsoleTabBase.c:6
proto native void Send(Object target, int rpc_type, bool guaranteed, PlayerIdentity recipient=NULL)
Initiate remote procedure call. When called on client, RPC is evaluated on server; When called on ser...
Определения gameplay.c:105
proto bool Write(void value_out)
Определения EnWidgets.c:220
Определения DayZPlayerImplement.c:63
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString(bool simple=true)
Определения EnConvert.c:106
proto native CGame GetGame()
const int COLOR_RED
Определения constants.c:64
ShapeFlags
Определения EnDebug.c:126
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
array< string > TStringArray
Определения EnScript.c:685
array< int > TIntArray
Определения EnScript.c:687
array< bool > TBoolArray
Определения EnScript.c:688
KeyCode
Определения EnSystem.c:157
static proto float Pow(float v, float power)
Return power of v ^ power.
const string CFG_AMMO
Определения constants.c:223
const string CFG_VEHICLESPATH
Определения constants.c:220
const int MENU_SCRIPTCONSOLE_UNIVERSAL_INFO_DIALOG
Определения constants.c:213
const int MENU_SCRIPTCONSOLE_DIALOG_PRESET_NAME
Определения constants.c:187
const int MENU_SCRIPTCONSOLE_DIALOG_PRESET_RENAME
Определения constants.c:188
const string CFG_WEAPONSPATH
Определения constants.c:221
const string CFG_MAGAZINESPATH
Определения constants.c:222
proto native void dBodyDestroy(notnull IEntity ent)
Destroys attached physics body.
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.
proto string Trim()
Returns trimmed string with removed leading and trailing whitespaces.
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
Определения EnString.c:396
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
proto int ToLower()
Changes string to lowercase. Returns length.
int ARGB(int a, int r, int g, int b)
Определения proto.c:322