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;
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 bool m_IsShiftDown;
30 protected string m_FilterTextPrev;
32 protected CheckBoxWidget m_CategoryMergeType;
33 protected CheckBoxWidget m_ItemPreviewCheckbox;
34 protected CheckBoxWidget m_ShowProtected;
35 protected CheckBoxWidget m_ClearInventory;
36 protected TextListboxWidget m_ObjectsTextListbox;
37 protected TextListboxWidget m_PresetsTextListbox;
38 protected TextListboxWidget m_PresetItemsTextListbox;
39 protected ButtonWidget m_DrawInWorld;
40 protected ButtonWidget m_DrawInWorldClear;
41 protected ButtonWidget m_PresetNewButton;
42 protected ButtonWidget m_PresetDeleteButton;
43 protected ButtonWidget m_PresetRenameButton;
44 protected ButtonWidget m_PresetSetDefaultButton;
45 protected ButtonWidget m_PresetAddItemtButton;
46 protected ButtonWidget m_ItemNameCopy;
47 protected ButtonWidget m_PresetRemoveItemButton;
48 protected ButtonWidget m_ItemMoveUpButton;
49 protected ButtonWidget m_ItemMoveDownButton;
50 protected ButtonWidget m_FilterOrderButton;
51 protected ButtonWidget m_SpawnInInvButton;
52 protected ButtonWidget m_SpawnGroundButton;
53 protected ButtonWidget m_SpawnGroundPatternGrid;
54 protected ButtonWidget m_SpawnOnTarget;
55 protected ButtonWidget m_SpawnOnCursor;
56 protected ButtonWidget m_SpawnInHands;
57 protected ButtonWidget m_SpawnBatchButton;
58 protected ButtonWidget m_ListActions;
59 protected MultilineEditBoxWidget m_ObjectFilter;
69 protected CheckBoxWidget m_WithPhysicsCheckbox;
74 protected ImageWidget m_FilterOrderImage;
79 m_Developer = PluginDeveloper.Cast(
GetPlugin(PluginDeveloper));
81 m_DrawInWorld = ButtonWidget.Cast(root.FindAnyWidget(
"ButtonDrawItem"));
82 m_DrawInWorldClear = ButtonWidget.Cast(root.FindAnyWidget(
"ButtonDrawItemClear"));
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"));
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"));
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"));
121 m_SpawnInInvButton.GetText(text);
122 m_SpawnButtonsOriginalText.Insert(m_SpawnInInvButton, text);
123 m_SpawnGroundButton.GetText(text);
124 m_SpawnButtonsOriginalText.Insert(m_SpawnGroundButton, text);
125 m_SpawnOnTarget.GetText(text);
126 m_SpawnButtonsOriginalText.Insert(m_SpawnOnTarget, text);
127 m_SpawnOnCursor.GetText(text);
128 m_SpawnButtonsOriginalText.Insert(m_SpawnOnCursor, text);
129 m_SpawnInHands.GetText(text);
130 m_SpawnButtonsOriginalText.Insert(m_SpawnInHands, text);
131 m_SpawnBatchButton.GetText(text);
132 m_SpawnButtonsOriginalText.Insert(m_SpawnBatchButton, text);
134 m_ListActions = ButtonWidget.Cast(root.FindAnyWidget(
"ListActions"));
137 m_RectSpawnColumn =
EditBoxWidget.Cast(root.FindAnyWidget(
"RectangleColumnValue"));
138 m_RectSpawnRow =
EditBoxWidget.Cast(root.FindAnyWidget(
"RectangleRowValue"));
139 m_BatchSpawnQuantity =
EditBoxWidget.Cast(root.FindAnyWidget(
"BatchCount"));
141 m_RectSpawnColumnStep =
EditBoxWidget.Cast(root.FindAnyWidget(
"RectangleStepXValue"));
142 m_RectSpawnRowStep =
EditBoxWidget.Cast(root.FindAnyWidget(
"RectangleStepYValue"));
144 m_FilterOrderButton = ButtonWidget.Cast(root.FindAnyWidget(
"ObjectFilterSortButton"));
150 ITEMS_SELECTED_ROW = m_ObjectsTextListbox.GetSelectedRow();
151 PRESETS_SELECTED_ROW = m_PresetsTextListbox.GetSelectedRow();
152 ITEMS_IN_PRESET_SELECTED_ROW = m_PresetItemsTextListbox.GetSelectedRow();
154 m_PresetsTextListbox.ClearItems();
158 m_PreviewEntity.Delete();
161 m_RefreshFilterTimer.Stop();
168 m_ItemQuantity = m_QuantityEditBox.GetText().ToFloat();
169 m_WithPhysics = m_WithPhysicsCheckbox.IsChecked();
174 protected void Init()
176 m_RefreshFilterTimer.Run(0.85,
this,
"ChangeFilterItems",
null,
true);
177 m_PresetDeleteButton.Show(
false);
178 m_PresetRenameButton.Show(
false);
179 m_DrawDistanceWidget.SetText(DRAW_DISTANCE.ToString());
181 m_QuantityEditBox.SetText(m_ItemQuantity.ToString());
182 m_WithPhysicsCheckbox.SetChecked(m_WithPhysics);
197 if (m_ItemPreviewCheckbox)
204 m_RectSpawnRow.SetText(CfgParamInt.Cast(params.Get(0)).GetValue().ToString());
205 m_RectSpawnColumn.SetText(CfgParamInt.Cast(params.Get(1)).GetValue().ToString());
206 m_RectSpawnRowStep.SetText(CfgParamFloat.Cast(params.Get(2)).GetValue().ToString());
207 m_RectSpawnColumnStep.SetText(CfgParamFloat.Cast(params.Get(3)).GetValue().ToString());
211 if (m_ObjectsScope == 1)
212 m_ShowProtected.SetChecked(
true);
214 m_ShowProtected.SetChecked(
false);
217 foreach (
string name: m_CategoryButtonsNames)
219 string widget_name =
"ItemCategory" + counter;
221 CheckBoxWidget btw = CheckBoxWidget.Cast(m_ParentRoot.FindAnyWidget(widget_name));
225 m_CategoryButtonsWidgets.Insert(btw);
226 int bit = 1 << counter;
227 if (bit & m_CategoryMask)
229 btw.SetChecked(
true);
230 btw.SetTextColor(
ARGB(255, 255, 0, 0));
236 if (ITEMS_IN_PRESET_SELECTED_ROW <= m_PresetItemsTextListbox.GetNumItems() && m_PresetItemsTextListbox.GetNumItems() > 0 && ITEMS_IN_PRESET_SELECTED_ROW > -1)
238 m_PresetItemsTextListbox.SelectRow(ITEMS_IN_PRESET_SELECTED_ROW);
239 m_PresetItemsTextListbox.EnsureVisible(ITEMS_IN_PRESET_SELECTED_ROW);
241 m_SelectedObjectText.SetText(
"Object : " + GetCurrentItemName());
242 SetObject(GetCurrentItemName());
243 m_SelectedObjectIsPreset = 0;
246 ChangeFilterItems(
true);
251 m_MissionGameplay = MissionGameplay.Cast(
GetGame().GetMission());
253 if (!m_SelectedObjectIsPreset == 1 && ITEMS_SELECTED_ROW < m_ObjectsTextListbox.GetNumItems() && m_ObjectsTextListbox.GetNumItems() > 0 && ITEMS_SELECTED_ROW > -1)
255 m_ObjectsTextListbox.SelectRow(ITEMS_SELECTED_ROW);
256 m_ObjectsTextListbox.EnsureVisible(ITEMS_SELECTED_ROW);
259 m_SelectedObjectText.SetText(GetCurrentObjectName());
262 SetObject(GetCurrentObjectName());
264 m_PresetItemsTextListbox.SelectRow(-1);
265 m_SelectedObjectIsPreset = 0;
268 if (m_PresetsTextListbox.GetNumItems() >= 0)
270 m_PresetsTextListbox.SelectRow(PRESETS_SELECTED_ROW);
271 m_PresetsTextListbox.EnsureVisible(PRESETS_SELECTED_ROW);
272 if (m_SelectedObjectIsPreset == 1)
278 if (m_ObjectsScope == 1)
279 m_ShowProtected.SetChecked(
true);
281 m_ShowProtected.SetChecked(
false);
287 ShowItemTransferButtons();
290 static void DrawItems(
string type,
float distance = 0)
294 distance = DRAW_DISTANCE;
301 foreach (
Object o: objects)
303 if (o.IsKindOf(type))
306 ScriptConsole.m_MarkedEntities.Insert(
new MapMarker(o.GetPosition(),
"",
COLOR_RED,eMapMarkerTypes.MARKERTYPE_MAP_BORDER_CROSS));
309 lines[0] = o.GetPosition();
310 lines[1] = o.GetPosition() +
"0 30 0";
312 m_DebugShapes.Insert(shape);
313 m_DebugShapes.Insert(line);
319 Debug.Log(
string.Format(
"found %1 instances of type %1", i, type));
323 static void DrawItemsClear()
325 ScriptConsole.m_MarkedEntities.Clear();
326 foreach (
Shape s: m_DebugShapes)
330 m_DebugShapes.Clear();
334 static string GetLastSelectedObject()
336 return m_LastSelectedObject;
339 override bool OnKeyDown(
Widget w,
int x,
int y,
int key)
347 return super.OnKeyDown(w,
x,
y, key);
350 void SelectObject(
bool hide_presets =
true)
353 m_PresetItemsTextListbox.SelectRow(-1);
355 ShowItemTransferButtons();
356 m_SelectedObjectText.SetText(GetCurrentObjectName());
357 SetObject(GetCurrentObjectName());
360 m_SelectedObjectIsPreset = 0;
366 m_ObjectsTextListbox.SelectRow(-1);
369 ShowItemTransferButtons();
372 m_SelectedObjectIsPreset = 1;
376 m_ConfigDebugProfileFixed.GetPresetItems(
m_SelectedObject, command_array,
"cmd");
379 if (command_array.IsValidIndex(0))
381 string first_line = command_array.Get(0);
382 first_line.ToLower();
383 clear = (first_line ==
"clear_inv");
386 m_ClearInventory.SetChecked(clear);
389 int GetCurrentPresetIndex()
391 return m_PresetsTextListbox.GetSelectedRow();
394 int GetCurrentItemIndex()
396 return m_PresetItemsTextListbox.GetSelectedRow();
399 bool IsCurrentPresetFixed()
401 int index = GetCurrentPresetIndex();
402 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
405 m_PresetsTextListbox.GetItemData(index, 0, item_params_array);
406 return item_params_array.param2;
411 bool IsPresetFixed(
string preset_name)
413 int preset_index = GetPresetIndexByName(preset_name);
415 if (preset_index > -1 && preset_index < m_PresetsTextListbox.GetNumItems())
417 m_PresetsTextListbox.GetItemData(preset_index, 0, item_params_array);
418 return item_params_array.param2;
423 int GetPresetIndexByName(
string preset_name)
426 for (i = 0; i < m_PresetsTextListbox.GetNumItems(); i++)
429 m_PresetsTextListbox.GetItemData(i, 0, item_params_array);
431 if (item_params_array.param1 == preset_name)
439 void ShowItemButtons()
441 if (!IsCurrentPresetFixed())
443 ShowItemTransferButtons();
445 string preset_name = GetCurrentPresetName();
446 int item_index = GetCurrentItemIndex();
448 m_ItemMoveUpButton.Show(
true);
449 m_ItemMoveDownButton.Show(
true);
451 m_ItemDamageLabel.Show(
true);
452 m_ItemQuantityLabel.Show(
true);
454 if (preset_name !=
"" && item_index > -1)
456 m_DamageEditBox.Show(
true);
457 m_QuantityEditBox.Show(
true);
458 m_WithPhysicsCheckbox.Show(
true);
460 float item_health=
m_ConfigDebugProfile.GetItemHealth(GetCurrentPresetName(), GetCurrentItemIndex());
461 int item_quantity =
m_ConfigDebugProfile.GetItemQuantity(GetCurrentPresetName(), GetCurrentItemIndex());
462 bool item_with_physics =
m_ConfigDebugProfile.GetItemWithPhysics(GetCurrentPresetName(), GetCurrentItemIndex());
465 m_DamageEditBox.SetText(item_health.ToString());
468 m_QuantityEditBox.SetText(item_quantity.ToString());
471 m_WithPhysicsCheckbox.SetChecked(item_with_physics);
475 m_DamageEditBox.Show(
false);
476 m_QuantityEditBox.Show(
false);
477 m_WithPhysicsCheckbox.Show(
false);
483 void HideItemButtons()
485 m_ItemMoveUpButton.Show(
false);
486 m_ItemMoveDownButton.Show(
false);
489 void ShowItemTransferButtons()
491 int object_row = m_ObjectsTextListbox.GetSelectedRow();
492 if (object_row >-1 && GetCurrentPresetIndex() >-1 && !IsCurrentPresetFixed())
494 m_PresetAddItemtButton.Show(
true);
498 m_PresetAddItemtButton.Show(
false);
501 if (GetCurrentItemIndex() >-1 && GetCurrentPresetIndex() >-1 && !IsCurrentPresetFixed())
503 m_PresetRemoveItemButton.Show(
true);
507 m_PresetRemoveItemButton.Show(
false);
512 m_ItemNameCopy.Show(
true);
516 m_ItemNameCopy.Show(
false);
523 int new_index = GetCurrentItemIndex() - 1;
524 if (GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 && new_index > -1)
528 m_PresetItemsTextListbox.SelectRow (new_index);
534 int new_index = GetCurrentItemIndex() + 1;
535 if (GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 && new_index < m_PresetItemsTextListbox.GetNumItems())
539 m_PresetItemsTextListbox.SelectRow (new_index);
544 void SaveProfileSpawnDistance()
552 void RenamePreset(
string new_preset_name)
554 if (new_preset_name && GetCurrentPresetIndex() != -1)
566 if (GetCurrentPresetIndex() != -1)
568 bool is_preset_fixed = IsCurrentPresetFixed();
573 m_ConfigDebugProfileFixed.GetPresetItems(preset_name, preset_array);
583 m_Developer.ClearInventory(target);
586 for (
int i = 0; i < preset_array.Count(); i++)
590 bool with_physics =
false;
593 health = m_ConfigDebugProfileFixed.GetItemHealth(preset_name, i);
594 quantity = m_ConfigDebugProfileFixed.GetItemQuantity(preset_name, i);
595 with_physics = m_ConfigDebugProfileFixed.GetItemWithPhysics(preset_name, i);
604 EntityAI ent = m_Developer.SpawnEntityInInventory(target, preset_array.Get(i), -1, quantity,
false, preset_name);
608 m_Developer.SpawnEntityOnCursorDir(player, preset_array.Get(i), quantity, distance, health,
false, preset_name, with_physics);
614 rpc.Write(preset_name);
616 rpc.Send(player,
ERPCs.DEV_RPC_SPAWN_PRESET,
true, player.GetIdentity());
620 PluginDeveloper plugin = PluginDeveloper.Cast(
GetPlugin(PluginDeveloper));
621 plugin.HandlePresetSpawn(player,preset_name,target);
626 void SetDefaultPreset(
int preset_index)
630 if (default_preset !=
"")
632 int index = GetPresetIndexByName(default_preset);
634 if (IsPresetFixed(default_preset))
636 default_preset =
"[" + default_preset +
"]";
639 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
641 m_PresetsTextListbox.GetItemData(index, 0, prev_preset_params_array);
642 prev_preset_params_array.param3 =
false;
643 m_PresetsTextListbox.SetItem(index, default_preset, prev_preset_params_array, 0);
649 string preset_name = GetCurrentPresetName();
650 if (IsPresetFixed(preset_name))
652 preset_name =
"[" + preset_name +
"]";
656 index = GetCurrentPresetIndex();
657 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
659 m_PresetsTextListbox.GetItemData(index, 0, preset_params_array);
660 preset_params_array.param3 =
true;
661 m_PresetsTextListbox.SetItem(index, preset_name + CONST_DEFAULT_PRESET_PREFIX, preset_params_array, 0);
667 void SetObject(
string object)
673 SetPreviewObject(
object);
678 void SetPreviewObject(
string object)
683 m_PreviewEntity.Delete();
686 if (!
GetGame().IsKindOf(
object,
"DZ_LightAI") && !
GetGame().IsKindOf(
object,
"Man"))
688 DayZGame.m_IsPreviewSpawn =
true;
691 DayZGame.m_IsPreviewSpawn =
false;
695 m_PreviewEntity.DisableSimulation(
true);
697 m_PreviewEntity.SetAllowDamage(
false);
703 void AddItemToPreset()
705 int selected_row_index = m_ObjectsTextListbox.GetSelectedRow();
706 if (selected_row_index != -1 && GetCurrentPresetIndex() != -1)
709 m_ObjectsTextListbox.GetItemText(selected_row_index, 0, item_name);
715 void ShowPresetButtons()
718 if (IsCurrentPresetFixed())
722 m_PresetDeleteButton.Show(show);
723 m_PresetRenameButton.Show(show);
740 void RemoveItemFromPreset()
742 if (GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1)
749 string GetCurrentPresetName()
751 int index = GetCurrentPresetIndex();
753 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
756 m_PresetsTextListbox.GetItemData(index, 0, item_params_array);
757 return item_params_array.param1;
762 string GetCurrentItemName()
764 if (GetCurrentItemIndex() != -1)
767 m_PresetItemsTextListbox.GetItemText(GetCurrentItemIndex(), 0, item_name);
773 string GetCurrentObjectName()
775 int selected_row_index = m_ObjectsTextListbox.GetSelectedRow();
776 if (selected_row_index != -1)
779 m_ObjectsTextListbox.GetItemText(selected_row_index, 0, item_name);
794 m_PresetsTextListbox.ClearItems();
801 for (i = custom_presets_array.Count() - 1; i >= 0; i--)
803 m_PresetsTextListbox.AddItem(custom_presets_array.Get(i),
new PresetParams (custom_presets_array.Get(i),
false,
false), 0);
807 TStringArray presets_array = m_ConfigDebugProfileFixed.GetPresets();
808 for (i = 0; i < presets_array.Count(); i++)
810 m_PresetsTextListbox.AddItem(
"["+presets_array.Get(i)+
"]",
new PresetParams (presets_array.Get(i),
true,
false), 0);
813 if (default_preset !=
"")
816 int index = GetPresetIndexByName(default_preset);
817 if (IsPresetFixed(default_preset))
819 default_preset =
"[" + default_preset +
"]";
822 if (index > -1 && index < m_PresetsTextListbox.GetNumItems())
824 m_PresetsTextListbox.GetItemData(index, 0, preset_params_array);
825 m_PresetsTextListbox.SetItem(index, default_preset + CONST_DEFAULT_PRESET_PREFIX, preset_params_array, 0);
831 void RenderPresetItems()
835 m_PresetItemsTextListbox.ClearItems();
836 if (GetCurrentPresetIndex() != -1)
838 bool isFixed = IsCurrentPresetFixed();
843 m_ConfigDebugProfileFixed.GetPresetItems(GetCurrentPresetName(), preset_array);
852 for (i = 0; i < preset_array.Count(); i++)
854 m_PresetItemsTextListbox.AddItem(preset_array.Get(i), NULL, 0);
860 void NewPreset(
string preset_name)
868 if (GetCurrentPresetIndex() != -1)
875 int GetFilterColor(
string color)
880 return ARGB(255,255,0,0);
882 return ARGB(255,0,255,0);
884 return ARGB(255,130,130,255);
886 return ARGB(255,255,255,0);
888 return ARGB(255,255,169,0);
900 filter.Split(
" ", rawFilters);
905 foreach (
int i,
string f:rawFilters)
908 if (f.IndexOf(
":") == 1)
910 string clr = f.Substring(0, 1);
911 f = f.Substring(2, f.Length() - 2);
912 color = GetFilterColor(clr);
918 color =
ARGB(200,255,255,255);
922 colors.Insert(color);
927 void ChangeFilter(
TStringArray classes, TextListboxWidget widget, MultilineEditBoxWidget filterWidget,
int categoryMask = -1,
bool ignoreScope =
false)
935 filterWidget.GetText(widgetText);
936 PrepareFilters(widgetText, filters, filterColors);
943 for (
int i = 0; i < classes.Count(); i++)
945 string config_path = classes.Get(i);
947 int objects_count =
GetGame().ConfigGetChildrenCount(config_path);
948 for (
int j = 0; j < objects_count; j++)
952 GetGame().ConfigGetChildName(config_path, j, child_name);
954 int scope =
GetGame().ConfigGetInt(config_path +
" " + child_name +
" scope");
956 if (scope >= m_ObjectsScope || ignoreScope)
958 int category_bit =
GetGame().ConfigGetInt(config_path +
" " + child_name +
" debug_ItemCategory") - 1;
959 category_bit = (1 << category_bit);
961 bool display =
false;
963 if (category_bit & categoryMask)
969 string child_name_lower = child_name;
970 child_name_lower.ToLower();
972 foreach (
int indx,
string filter:filters)
974 if (child_name_lower.Contains(filter))
977 color = filterColors.Get(indx);
982 itemsByFilters.Set(filter, arr);
984 arr.Insert(child_name);
985 itemsAndColors.Insert(child_name,color);
990 else if (categoryMask == 0)
997 itemsArray.Insert(child_name);
1007 foreach (
string it:itemsArray)
1009 widget.AddItem(it, NULL, 0);
1015 if (m_FilterOrderReversed)
1018 foreach (
string f:filters)
1024 foreach (
string itm: arr2)
1026 int row = widget.AddItem(itm, NULL, 0);
1027 int clr = itemsAndColors.Get(itm);
1030 widget.SetItemColor(row, 0, clr);
1041 void SetFilterOrder(
bool reversed)
1043 m_FilterOrderReversed = reversed;
1045 m_FilterOrderImage.SetRotation(0,0,180,
true);
1047 m_FilterOrderImage.SetRotation(0,0,0,
true);
1048 ChangeFilterItems(
true);
1055 override bool OnChange(
Widget w,
int x,
int y,
bool finished)
1057 super.OnChange(w,
x,
y, finished);
1058 if (w == m_ShowProtected)
1060 if (m_ShowProtected.IsChecked())
1068 ChangeFilterItems(
true);
1071 else if (w == m_ClearInventory)
1073 CLEAR_IVN = m_ClearInventory.IsChecked();
1076 else if (m_CategoryButtonsWidgets.Find(w) >= 0)
1079 int pos = m_CategoryButtonsWidgets.Find(w);
1080 int bit =
Math.Pow(2,pos);
1081 CheckBoxWidget cbw = CheckBoxWidget.Cast(w);
1082 if (cbw.IsChecked())
1084 m_CategoryMask = m_CategoryMask | bit;
1085 cbw.SetTextColor(
ARGB(255, 255, 0, 0));
1089 m_CategoryMask = (m_CategoryMask & ~bit);
1090 cbw.SetTextColor(
ARGB(255, 255, 255,255));
1093 ChangeFilterItems(
true);
1103 if (w == m_QuantityEditBox && (GetCurrentItemIndex() >= 0 || GetCurrentPresetName() !=
""))
1105 m_ConfigDebugProfile.SetItemQuantity(GetCurrentPresetName(), GetCurrentItemIndex(), m_QuantityEditBox.GetText().ToFloat());
1108 else if (w == m_DrawDistanceWidget)
1110 DRAW_DISTANCE = m_DrawDistanceWidget.GetText().ToFloat();
1113 else if (w == m_DamageEditBox && (GetCurrentItemIndex() >= 0 || GetCurrentPresetName() !=
""))
1115 m_ConfigDebugProfile.SetItemHealth(GetCurrentPresetName(), GetCurrentItemIndex(), m_DamageEditBox.GetText().ToFloat());
1118 else if (w == m_WithPhysicsCheckbox && (GetCurrentItemIndex() >= 0 || GetCurrentPresetName() !=
""))
1120 m_ConfigDebugProfile.SetItemWithPhysics(GetCurrentPresetName(), GetCurrentItemIndex(), m_WithPhysicsCheckbox.IsChecked());
1123 else if (w == m_BatchSpawnQuantity)
1128 else if ((w == m_RectSpawnRow || w == m_RectSpawnColumn || w == m_RectSpawnRowStep || w == m_RectSpawnColumnStep))
1130 if (w == m_RectSpawnRow || w == m_RectSpawnColumn)
1132 int rowQ = m_RectSpawnRow.GetText().ToInt();
1133 int columnQ = m_RectSpawnColumn.GetText().ToInt();
1134 int result = columnQ * rowQ;
1135 m_BatchSpawnQuantity.SetText(result.ToString());
1141 m_ConfigDebugProfile.SetBatchSpawnRectangle(m_RectSpawnRow.GetText().ToInt(),m_RectSpawnColumn.GetText().ToInt(), m_RectSpawnRowStep.GetText().ToFloat(),m_RectSpawnColumnStep.GetText().ToFloat());
1148 override bool OnItemSelected(
Widget w,
int x,
int y,
int row,
int column,
int oldRow,
int oldColumn)
1150 super.OnItemSelected(w,
x,
y, row, column, oldRow, oldColumn);
1151 if (w == m_PresetsTextListbox && (m_SelectedObjectIsPreset == 1 || m_SelectedObjectIsPreset == -1))
1153 if (m_PresetsTextListbox.GetSelectedRow() != -1)
1159 else if (w == m_PresetItemsTextListbox)
1161 if (m_PresetItemsTextListbox.GetSelectedRow() != -1)
1164 ShowItemTransferButtons();
1165 m_SelectedObjectText.SetText(GetCurrentItemName());
1166 SetObject(GetCurrentItemName());
1167 m_SelectedObjectIsPreset = 0;
1171 else if (w == m_ObjectsTextListbox)
1173 SelectObject(
false);
1180 override bool OnClick(
Widget w,
int x,
int y,
int button)
1182 super.OnClick(w,
x,
y,button);
1184 int objects_row_index;
1185 if (w == m_CategoryMergeType)
1191 ChangeFilterItems(
true);
1193 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
1196 else if (w == m_ObjectFilter)
1198 ChangeFilterItems(
true);
1201 else if (w == m_ItemPreviewCheckbox)
1206 if (!m_ItemPreviewCheckbox.IsChecked())
1212 else if (w == m_SpawnInInvButton || w == m_SpawnGroundButton || w == m_SpawnOnTarget || w == m_SpawnOnCursor || w == m_SpawnInHands)
1214 SaveProfileSpawnDistance();
1216 objects_row_index = m_ObjectsTextListbox.GetSelectedRow();
1219 vector rayEnd = rayStart +
GetGame().GetCurrentCameraDirection() * 50;
1222 int hitComponentIndex;
1223 set<Object> hitObjects =
new set<Object>;
1225 DayZPhysics.RaycastRV(rayStart, rayEnd, hitPos, hitNormal, hitComponentIndex, hitObjects, NULL, player,
false,
false, ObjIntersectView, 0.3);
1228 if (hitObjects.Count())
1229 target =
EntityAI.Cast(hitObjects.Get(0));
1234 float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
1237 if (m_SelectedObjectIsPreset == 1)
1242 case m_SpawnOnTarget:
1244 if (target && target.IsInherited(
EntityAI))
1251 case m_SpawnGroundButton:
1268 float health = m_DamageEditBox.GetText().ToFloat() * MiscGameplayFunctions.GetTypeMaxGlobalHealth(
m_SelectedObject);
1269 float quantity = m_QuantityEditBox.GetText().ToFloat();
1270 bool withPhysics = m_WithPhysicsCheckbox.IsChecked();
1272 bool spawnOnCrossHair =
DeveloperFreeCamera.IsFreeCameraEnabled() || w == m_SpawnOnCursor;
1277 case m_SpawnGroundPatternGrid:
1279 m_Developer.SpawnEntityOnCursorDir(player,
m_SelectedObject, quantity, distance, health, m_IsShiftDown,
"", withPhysics);
1283 case m_SpawnOnTarget:
1285 if (target && target.IsInherited(
EntityAI))
1286 m_Developer.SpawnEntityInInventory(target,
m_SelectedObject, health, quantity, m_IsShiftDown);
1290 case m_SpawnInInvButton:
1292 m_Developer.SpawnEntityInPlayerInventory(player,
m_SelectedObject, -1, quantity, m_IsShiftDown);
1295 case m_SpawnInHands:
1300 case m_SpawnOnCursor:
1301 case m_SpawnGroundButton:
1303 if (spawnOnCrossHair)
1305 m_Developer.SpawnItemOnCrosshair(player,
m_SelectedObject, health, quantity, 40,
true, m_IsShiftDown, withPhysics );
1309 m_Developer.SpawnEntityOnCursorDir(player,
m_SelectedObject, quantity, distance, health, m_IsShiftDown,
"", withPhysics);
1318 else if (w == m_FilterOrderButton)
1320 SetFilterOrder(!m_FilterOrderReversed);
1323 else if (w == m_PresetsTextListbox)
1328 else if (w == m_PresetItemsTextListbox)
1330 m_ObjectsTextListbox.SelectRow(-1);
1332 ShowItemTransferButtons();
1333 m_SelectedObjectText.SetText(
"Object : " + GetCurrentItemName());
1334 SetObject(GetCurrentItemName());
1335 m_SelectedObjectIsPreset = 0;
1339 else if (w == m_PresetSetDefaultButton)
1341 if (GetCurrentPresetName()!=
"")
1343 SetDefaultPreset(GetCurrentPresetIndex());
1347 else if (w == m_PresetNewButton)
1352 else if (w == m_PresetDeleteButton)
1354 if (GetCurrentPresetName()!=
"")
1360 else if (w == m_PresetRenameButton)
1362 if (GetCurrentPresetName()!=
"")
1368 else if (w == m_PresetAddItemtButton)
1373 else if (w == m_ItemNameCopy)
1375 AddItemToClipboard(m_ObjectsTextListbox);
1378 else if (w == m_PresetRemoveItemButton)
1380 RemoveItemFromPreset();
1383 else if (w == m_ItemMoveUpButton)
1388 else if (w == m_ItemMoveDownButton)
1393 else if (w == m_SpawnBatchButton)
1395 int count = m_BatchSpawnQuantity.GetText().ToInt();
1396 int rows = m_RectSpawnRow.GetText().ToInt();
1397 int columns = m_RectSpawnColumn.GetText().ToInt();
1398 float rowStep = m_RectSpawnRowStep.GetText().ToFloat();
1399 float columnStep = m_RectSpawnColumnStep.GetText().ToFloat();
1400 m_Developer.SpawnEntityOnGroundPatternGrid(player,
m_SelectedObject,count, m_DamageEditBox.GetText().ToFloat(), 1, rows, columns, rowStep, columnStep, m_IsShiftDown, m_WithPhysicsCheckbox.IsChecked());
1403 else if (w == m_ListActions)
1405 if (!m_PreviewEntity)
1408 return ListItemRelatedActions();
1410 else if (w == m_ObjectsTextListbox)
1415 else if (w == m_DrawInWorld)
1421 else if (w == m_DrawInWorldClear)
1430 override bool OnDoubleClick(
Widget w,
int x,
int y,
int button)
1432 super.OnDoubleClick(w,
x,
y, button);
1435 int objects_row_index;
1438 if (w == m_ObjectsTextListbox)
1441 m_PresetItemsTextListbox.SelectRow(-1);
1443 ShowItemTransferButtons();
1444 m_SelectedObjectText.SetText(
"Object : " + GetCurrentObjectName());
1448 m_SelectedObjectIsPreset = 0;
1451 SaveProfileSpawnDistance();
1453 objects_row_index = m_ObjectsTextListbox.GetSelectedRow();
1456 vector rayEnd = rayStart +
GetGame().GetCurrentCameraDirection() * 1.5;
1459 int hitComponentIndex;
1460 set<Object> hitObjects =
new set<Object>;
1461 DayZPhysics.RaycastRV(rayStart, rayEnd, hitPos, hitNormal, hitComponentIndex, hitObjects, NULL, player);
1464 if (hitObjects.Count())
1465 target = hitObjects.Get(0);
1469 float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
1476 else if (button == 1)
1478 if (
GetGame().IsMultiplayer())
1480 m_Developer.SpawnEntityInPlayerInventory(player,
m_SelectedObject, -1, -1);
1485 player.LocalTakeEntityToHands(spawned_entity);
1489 else if (button == 2)
1491 m_Developer.SpawnEntityOnCursorDir(player,
m_SelectedObject, 1, distance,-1,
true);
1497 else if (w == m_QuantityEditBox)
1499 m_QuantityEditBox.SetText(
"1.0");
1505 override void Update(
float timeslice)
1509 UpdateButtonNames();
1511 super.Update(timeslice);
1514 void SetTextSpawnButton(ButtonWidget w,
bool special,
string suffix =
" Special")
1516 string text = m_SpawnButtonsOriginalText.Get(w);
1522 void UpdateButtonNames()
1524 SetTextSpawnButton(m_SpawnGroundButton, m_IsShiftDown);
1525 SetTextSpawnButton(m_SpawnInInvButton, m_IsShiftDown);
1526 SetTextSpawnButton(m_SpawnOnTarget, m_IsShiftDown);
1527 SetTextSpawnButton(m_SpawnOnCursor, m_IsShiftDown);
1528 SetTextSpawnButton(m_SpawnBatchButton, m_IsShiftDown);
1529 SetTextSpawnButton(m_SpawnInHands, m_IsShiftDown);
1537 protected string PreprocessFilterText(MultilineEditBoxWidget w)
1540 w.GetText(widgetText);
1542 if (widgetText.Contains(
","))
1544 widgetText.Replace(
",",
" ");
1545 w.SetLine(0,widgetText);
1550 void ChangeFilterItems(
bool forced =
false)
1552 string widgetText = PreprocessFilterText(m_ObjectFilter);
1553 if (widgetText == m_FilterTextPrev && !forced)
1556 m_FilterTextPrev = widgetText;
1560 ChangeFilter(GetItemsClasses(), m_ObjectsTextListbox,m_ObjectFilter, m_CategoryMask);
1563 private bool ListItemRelatedActions()
1565 string message =
"";
1569 if (interactActions)
1571 message +=
"\n== Interact (F)\n\n";
1578 message +=
string.Format(
"%1 <%2>\n",
Widget.TranslateString(ia.GetText()), ia.ClassName());
1584 if (continuousInteractActions)
1586 message +=
"\n== Continuous Interact (F hold)\n\n";
1593 message +=
string.Format(
"%1 <%2>\n",
Widget.TranslateString(cia.GetText()), cia.ClassName());
1601 message +=
"\n== Single (LMB)\n\n";
1608 message +=
string.Format(
"%1 <%2>\n",
Widget.TranslateString(sa.GetText()), sa.ClassName());
1614 if (continuousActions)
1617 message +=
"\n== Continuous (LMB hold)\n\n";
1623 message +=
string.Format(
"%1 <%2>\n",
Widget.TranslateString(ca.GetText()), ca.ClassName());
1627 craftingAction = caction;
1630 message +=
"\n== Crafting recipes \n\n";
1633 PluginRecipesManager pluginRecipesManager = PluginRecipesManager.Cast(
GetPlugin(PluginRecipesManager));
1634 array<RecipeBase> recipes = pluginRecipesManager.GetRecipesForItem(m_PreviewEntity.GetType());
1637 if (recipe.IsItemInRecipe(
"Inventory_Base"))
1640 message +=
string.Format(
"%1 <%2>\n",
Widget.TranslateString(recipe.GetName()), recipe.Type());
1646 infoDialog.SetLabel(
string.Format(
"%1 related actions", m_PreviewEntity.GetType()));
1647 infoDialog.SetContent(message);