DayZ 1.24
Loading...
Searching...
No Matches
PluginItemDiagnostic.c
Go to the documentation of this file.
2{
4 override bool OnMouseEnter(Widget w, int x, int y)
5 {
6 if (ButtonWidget.Cast(w))
7 {
8 GetGame().GetMission().AddActiveInputExcludes({"menu"});
9 }
10 return true;
11
12 }
13
14 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
15 {
16 if (ButtonWidget.Cast(w))
17 {
18 GetGame().GetMission().RemoveActiveInputExcludes({"menu"}, true);
19 }
20
21 return true;
22 }
23
24 override bool OnClick(Widget w, int x, int y, int button)
25 {
26 return m_Owner.OnClick(w, x, y, button);
27 }
28
29 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
30 {
31 return m_Owner.OnMouseButtonDown(w, x, y, button);
32 }
33 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
34 {
35 return m_Owner.OnMouseButtonUp(w, x, y, button);
36 }
37}
38
39
40class PluginItemDiagnostic extends PluginDeveloper
41{
43
44
52 bool m_IsActive = false;
58
61
70
75
77
80
81
83 {
84
85#ifndef NO_GUI
87 ShowWidgets(false);
88#endif
89 }
90
92 {
94 if (m_ItemLine)
95 {
96 m_ItemLine.Destroy();
98 }
99 }
100
101 override void OnInit()
102 {
105 {
106 vector pos = m_ConfigDebugProfile.GetItemDebugPos();
107 if (m_DebugRootWidget && pos != vector.Zero)
108 {
109 float wx = pos[0];
110 float wy = pos[1];
111 m_DebugRootWidget.SetPos(wx, wy);
112 }
113 }
114 }
115
116 bool OnMouseButtonDown(Widget w, int x, int y, int button)
117 {
118 if (button == 0)
119 SetDragging(true);
120 if (button == 1)
121 {
122 if (m_Entity)
123 {
124 float xx, yy;
125 m_DebugRootWidget.GetPos(xx, yy);
126 ContextMenu.DisplayContextMenu(x - xx, y - yy, EntityAI.Cast(m_Entity), m_DebugRootWidget, this);
127 }
128 }
129 return true;
130 }
131
132 bool OnMouseButtonUp(Widget w, int x, int y, int button)
133 {
134 if (button == 0)
135 SetDragging(false);
136 return true;
137 }
138
140 {
141 if (enable && !m_IsDragging)
143 else if (!enable && m_IsDragging)
146 }
147
149 {
150 int mx, my;
151 float wx, wy;
152 GetMousePos(mx, my);
153 m_DebugRootWidget.GetScreenPos(wx, wy);
154 m_DraggingOffset[0] = wx - mx;
155 m_DraggingOffset[1] = wy - my;
156 }
157
159 {
161 {
162 float wx, wy;
163 m_DebugRootWidget.GetScreenPos(wx, wy);
164 m_ConfigDebugProfile.SetItemDebugPos(Vector(wx, wy, 0));
165 }
166 }
167
168
169 bool OnClick(Widget w, int x, int y, int button)
170 {
171 SetDragging(false);
172
173 if (w == m_CloseButton)
174 {
176 return true;
177 }
178 return true;
179 }
180
182 {
183 if (!myTimer1)
184 {
185 myTimer1 = new Timer();
186 myTimer1.Run(1, this, "Tick", NULL, true);
187 }
188
189 if (m_ObserversMap.Contains(player))
191 else
192 m_ObserversMap.Insert(player, item);
193#ifdef DEVELOPER
195#endif
196 }
197
202
203
204 bool IsActive()
205 {
206 return m_IsActive;
207 }
208
209 void OnScriptMenuOpened(bool opened/*1 - opened , 0 - closed*/)
210 {
212 }
213
214
215 void ShowWidgets(bool show)
216 {
217
218 m_IsActive = show;
219
221 m_DebugRootWidget.Show(show);
222 }
223
225 {
226#ifdef DIAG_DEVELOPER
228 player.GetActionManager().OnInstantAction(ActionDebug, new Param2<EntityAI, int>(ent, actionId));
229#endif
230 }
231
233 {
234 GetGame().GetInput().ResetGameFocus();
235 GetGame().GetUIManager().ShowUICursor(false);
236 if (GetGame().GetUIManager())
237 {
238 if (GetGame().GetUIManager().IsDialogVisible())
239 GetGame().GetUIManager().CloseDialog();
240
241 }
242 }
243
245 {
246 if (m_IsActive)
247 {
249 GetGame().RPCSingleParam(player, ERPCs.RPC_ITEM_DIAG_CLOSE, null, true);
250 ShowWidgets(false);
251 ClearWidgets();
252
253 GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(ReleaseFocus, 100);
254 //m_IsActive = false;
255 SetDragging(false);
256 }
257 else
258 {
259 ShowWidgets(true);
260 //m_IsActive = true;
261 }
262
263 }
264
266 {
267 m_DebugAgentListWidget.ClearItems();
268 m_DebugOutputServer.SetText("");
269 m_DebugOutputClient.SetText("");
272 m_ClassNameWidget.SetText("");
273 }
274
275 void Tick()
276 {
277 for (int i = 0; i < m_ObserversMap.Count(); i++)
278 {
279 Object item = m_ObserversMap.GetElement(i);
281
282 if (item && player)
283 {
286 }
287 else
288 {
289 Debug.LogError("PluginItemDiagnostic: dead debug record, removing record");
290 m_ObserversMap.RemoveElement(i);
291 }
292 }
293
294 }
295
297 {
298 m_Properties.Clear();
299 }
300
301
308
310 {
312 m_Properties.InsertAt(p1, 0);
313 GetGame().RPC(player, ERPCs.RPC_ITEM_DIAG, m_Properties, true, player.GetIdentity());
314
315 if (!GetGame().IsMultiplayer())
316 m_Entity = item;
317
318 }
319
320 void StopWatchRequest(PlayerBase player)//called from player after an RPC call
321 {
322 if (m_ObserversMap.Contains(player))
323 m_ObserversMap.Remove(player);
324 }
325
327 {
328
329 if (!GetGame().IsMultiplayer())
331 else
333
335
336
337#ifdef DEVELOPER
339#endif
340 if (!IsActive())
341 ShowWidgets(true);
342
347 if (item)
348 {
349 ctx.Read(CachedObjectsParams.PARAM1_INT);//hardcoded to index 1
351
352 ctx.Read(CachedObjectsParams.PARAM1_INT);//hardcoded to index 2
354
356
359
362 }
363 if (EntityAI.Cast(entity))
365 if (GetDayZGame().IsInventoryOpen() || GetGame().GetUIManager().FindMenu(MENU_SCRIPTCONSOLE))
366 m_DebugRootWidget.SetSort(-1);
367 else
368 m_DebugRootWidget.SetSort(10);
369 m_DebugRootWidget.Show(true);
370
371
372 }
373
375 {
376 for (int i = 0; i < count; i++)
377 {
379
380 ctx.Read(p2);
381 /*
382 string name = CachedObjectsParams.PARAM2_STRING_FLOAT.param1;
383 float value = CachedObjectsParams.PARAM2_STRING_FLOAT.param2;
384 PrintString(name+","+value.ToString());
385 */
386 params.Insert(p2);
387 }
388 //PrintString("----------------------------------------------------");
389 }
390
392 {
394 m_EventHandler.m_Owner = this;
395
397 m_DebugRootWidget = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/debug_item.layout");
398
400
401 m_FrameWidget = m_DebugRootWidget.FindAnyWidget("FrameWidget0");
402 m_DebugAgentListWidget = TextListboxWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_Agents"));
403 m_DebugOutputServer = TextWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugOutputServer"));
404 m_DebugOutputClient = TextWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugOutputClient"));
405 m_DebugFloatsProperListWidget = TextListboxWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_FloatsProper"));
406 m_ItemPreviewWidget = ItemPreviewWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_ItemPreview"));
407 m_ClassNameWidget = TextWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_ClassName"));
408 m_DistanceWidget = TextWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_Distance"));
409
410 m_DebugButtonWidget1 = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugButton1"));
411 m_DebugButtonWidget2 = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugButton2"));
412 m_DebugButtonWidget3 = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugButton3"));
413 m_DebugButtonWidget4 = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugButton4"));
414
415 m_CloseButton = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("CloseButton"));
416 }
417
418 override void OnUpdate(float delta_time)
419 {
420 super.OnUpdate(delta_time);
421
422 if (!m_Entity || !m_IsActive)
423 {
424
425 if (m_ItemLine)
426 {
427 m_ItemLine.Destroy();
429 }
430 return;
431 }
432
434
435
436 if (m_IsDragging)
437 {
438 int x, y;
439 GetMousePos(x, y);
441 }
442 vector pts[2];
443 pts[0] = GetGame().GetPlayer().GetPosition();
444 pts[1] = m_Entity.GetPosition();
445 if (m_ItemLine)
446 {
447 m_ItemLine.Destroy();
449
450 }
451 m_ItemLine = Shape.CreateLines(COLOR_BLUE, ShapeFlags.TRANSP | ShapeFlags.NOOUTLINE | ShapeFlags.NOZBUFFER, pts, 2);
452 m_DistanceWidget.SetText(vector.Distance(pts[0], pts[1]).ToString() + "m.");
453 }
454
456 {
457 m_ClassNameWidget.SetText(item.GetType());
460 //UpdateFloatWidget();
464 m_DebugOutputClient.SetText(item.GetDebugText());
465
466 /*
467 string button1, button2, button3, button4;
468 item.GetDebugButtonNames(button1, button2, button3, button4);
469 m_DebugButtonWidget1.SetText(button1);
470 m_DebugButtonWidget2.SetText(button2);
471 m_DebugButtonWidget3.SetText(button3);
472 m_DebugButtonWidget4.SetText(button4);
473 */
474
475
476 }
477
479 {
480 m_Agents.Clear();
481 for (int i = 0; i < agents_count; i++)
482 {
484 {
486 m_Agents.Insert(agent);
487 }
488 }
489 }
490
491
493 {
494 m_DebugAgentListWidget.ClearItems();
495 for (int i = 0; i < m_Agents.Count(); i++)
496 {
497 string agent = m_Agents.Get(i);
498 m_DebugAgentListWidget.AddItem(agent, NULL, 0);
499 }
500 }
501
502
520
521
522 void PrintOut()
523 {
524 Debug.LogArrayString(m_Agents, "ItemDebug");
525 Debug.Log("----------------------", "ItemDebug");
526 }
527
528 //-------------------------
529 // QUERY FOR DEBUG PROPERTIES
530 //-------------------------
532 {
533 if (!entity)
534 return;
536
537 if (!client)
538 {
539 // -------- DEBUG OUTPUT ------
540 Param1<string> debug_output = new Param1<string>(entity.GetDebugText());
541 properties.Insert(debug_output);
542 if (!item)
543 return;
544 // -------- AGENTS ------------
547 properties.InsertAt(agents_count, 1); // hard coded index 1 !!
548 }
549 if (!item)
550 return;
551 // ------ INDIVIDUAL VARS------
552 int number_of_items = 0;
553 Param2<string, float> quantity = new Param2<string, float>("quantity", item.GetQuantity());
554 properties.Insert(quantity);
556 //-----------------------------
557 Param2<string, float> liquid_type = new Param2<string, float>("liquid_type", item.GetLiquidType());
558 properties.Insert(liquid_type);
560 //-----------------------------
561 Param2<string, float> wetness = new Param2<string, float>("wetness", item.GetWet());
562 properties.Insert(wetness);
564 //-----------------------------
565 Param2<string, float> temperature = new Param2<string, float>("temperature", item.GetTemperature());
566 properties.Insert(temperature);
568 //-----------------------------
569 Param2<string, float> energy = new Param2<string, float>("energy", item.GetEnergy());
570 properties.Insert(energy);
572 //-----------------------------
574 if (!client)
575 health = new Param2<string, float>("health", item.GetHealth("", ""));
576 else
577 health = new Param2<string, float>("NO SYNC", 0);
578 properties.Insert(health);
580 //-----------------------------
581 int r, g, b, a;
582 item.GetColor(r, g, b, a);
584 properties.Insert(p2r);
587 properties.Insert(p2g);
590 properties.Insert(p2b);
593 properties.Insert(p2a);
595 //-----------------------------
596 if (!client)
597 {
599 properties.InsertAt(item_count, 2);
600 }
601 }
602
604 {
605 if (!item)
606 return 0;
607 int agents = item.GetAgents();
608 if (agents == 0) return 0;
609 int num_of_agents = 0;
611 PluginTransmissionAgents.BuildAgentArray(agents, agents_aray);
612 int agents_count = agents_aray.Count();
613
614 for (int i = 0; i < agents_count; i++)
615 {
616 //PluginTransmissionAgents mta = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
617 string agent_name = PluginTransmissionAgents.GetNameByID(agents_aray.Get(i));
619 properties.Insert(param1);
621 }
622
623 return num_of_agents;
624 }
625}
626
void OnInit()
Definition AIBehaviour.c:49
EntityAI m_Entity
Definition ActionDebug.c:11
int m_Agents
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame GetDayZGame()
Definition DayZGame.c:3530
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition DayZGame.c:144
void SendRPC()
void OnRPC(ParamsReadContext ctx)
ERPCs
Definition ERPCs.c:2
Icon x
Icon y
bool m_IsActive
PlayerBase GetPlayer()
bool IsActive()
enum ProcessDirectDamageFlags m_Owner
void ShowWidgets(bool show)
void ToggleDebugWindowEvent()
void RegisterDebugItem(ItemBase item, PlayerBase player)
void ReleaseFocus()
void UpdateNumericalVarsWidget(array< ref Param > vars_server, array< ref Param > vars_client)
Widget m_DebugRootWidget
void PrintOut()
void GeneratePropertiesObject(EntityAI item)
void GetLocalProperties(EntityAI entity, array< ref Param > properties, bool client=false)
TextWidget m_ClassNameWidget
void OnDraggingStart()
ButtonWidget m_CloseButton
void ClearWidgets()
ButtonWidget m_DebugButtonWidget3
PluginConfigDebugProfile m_ConfigDebugProfile
TextListboxWidget m_DebugFloatsProperListWidget
TextListboxWidget m_DebugClientVarsWidget
void SetDragging(bool enable)
bool m_ScriptMenuOpened
void FillServerFinalVars(int count, ParamsReadContext ctx, array< ref Param > params)
void OnSelectAction(EntityAI ent, int actionId)
TextWidget m_DebugOutputClient
ButtonWidget m_DebugButtonWidget4
Shape m_ItemLine
ButtonWidget m_DebugButtonWidget1
ref map< PlayerBase, Object > m_ObserversMap
ItemPreviewWidget m_ItemPreviewWidget
void InitializeWidgets()
void PluginItemDiagnostic()
int FillWithAgents(ItemBase item, array< ref Param > properties)
TextListboxWidget m_DebugAgentListWidget
void UpdateAgentWidget()
void OnScriptMenuOpened(bool opened)
ref map< string, float > m_Floats
ref PluginItemDiagnosticEventHandler m_EventHandler
bool m_IsDragging
void FillAgentArray(ParamsReadContext ctx, int agents_count)
Object GetWatchedItem(PlayerBase player)
void StopWatchRequest(PlayerBase player)
string m_NoteClient
TextWidget m_DebugOutputServer
ref map< string, float > m_VarsNumbersFinalServer
void ClearProperties()
ButtonWidget m_DebugButtonWidget2
void DisplayAll(EntityAI item, array< ref Param > vars_server, array< ref Param > vars_client, string debug_text_server)
void OnDraggingEnd()
Widget m_FrameWidget
vector m_DraggingOffset
void ~PluginItemDiagnostic()
ref array< ref Param > m_Properties
ref Timer myTimer1
bool OnMouseButtonDown(Widget w, int x, int y, int button)
ref map< string, float > m_VarsFinalClient
PluginBase GetPlugin(typename plugin_type)
ref TextWidget m_DistanceWidget[MAX_SIMULTANIOUS_PLAYERS]
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition RadialMenu.c:640
void Tick()
static ref Param1< int > PARAM1_INT
static ref Param1< string > PARAM1_STRING
Definition Debug.c:14
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
Definition Debug.c:341
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 void LogArrayString(array< string > arr=NULL, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:367
proto native void SetItem(EntityAI object)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
map: item x vector(index, width, height)
Definition EnWidgets.c:651
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnClick(Widget w, int x, int y, int button)
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
static const vector Zero
Definition EnConvert.c:110
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
const int COLOR_BLUE
Definition constants.c:66
ShapeFlags
Definition EnDebug.c:126
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
const int MENU_SCRIPTCONSOLE
Definition constants.c:175
proto void GetMousePos(out int x, out int y)
proto native void OnUpdate()
Definition tools.c:333
const int CALL_CATEGORY_GUI
Definition tools.c:9