Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
huddebugwincharagents.c
Go to the documentation of this file.
2{
3 string m_Name;
4 int m_ID;
5
6 void DebugAgentData( string name, int id )
7 {
8 m_Name = name;
9 m_ID = id;
10 }
11
12 string GetName()
13 {
14 return m_Name;
15 }
16
17 int GetID()
18 {
19 return m_ID;
20 }
21
22 float GetTemporaryResistance()
23 {
24
25 }
26}
27
28
29class HudDebugWinCharAgents extends HudDebugWinBase
30{
31 protected Widget m_WgtAgents;
34
35 private AutoHeightSpacer WgtModifiersContentPanelScript;
36 //============================================
37 // HudDebugWinCharAgents
38 //============================================
39 void HudDebugWinCharAgents( Widget widget_root )
40 {
41 m_WgtRoot = widget_root;
42 //m_WgtAgents = TextListboxWidget.Cast( m_WgtRoot.FindAnyWidget( "txl_CharAgents_Values" ) );
43 m_WgtAgents = m_WgtRoot.FindAnyWidget( "AgentList" );
44
45 //FitWindowByContent( m_WgtAgents );
46
47 m_WgtAgents.GetScript(WgtModifiersContentPanelScript);
48 }
49
50 void ~HudDebugWinCharAgents()
51 {
52 SetUpdate( false );
53 }
54
55 //============================================
56 // GetWinType
57 //============================================
58 override int GetType()
59 {
60 return HudDebug.HUD_WIN_CHAR_AGENTS;
61 }
62
63 //============================================
64 // Update
65 //============================================
66 override void SetUpdate( bool state )
67 {
68 //Disable update on server (PluginDeveloperSync)
69 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
70 PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) );
71
72 //if client, send RPC
73 if ( GetGame().IsClient() )
74 {
75 ref Param1<bool> params = new Param1<bool>( state );
76 if ( player )
77 {
78 player.RPCSingleParam( ERPCs.DEV_AGENTS_UPDATE, params, true );
79 SetRPCSent();
80 }
81 }
82 //else set directly
83 else
84 {
85 if ( developer_sync )
86 {
87 developer_sync.EnableUpdate( state, ERPCs.DEV_AGENTS_UPDATE, player );
88 }
89 }
90 }
91
92 override void Update()
93 {
94 super.Update();
95
96 //Print("Update()");
97
98 //refresh notifiers
99 SetAgents();
100 }
101
102 //============================================
103 // Show / Hide
104 //============================================
105 override void Show()
106 {
107 super.Show();
108
109 //Print("Show()");
110
111 SetUpdate( true );
112 }
113
114 override void Hide()
115 {
116 super.Hide();
117
118 //Print("Hide()");
119
120 SetUpdate( false );
121 }
122
123 void SetAgents()
124 {
125 PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) );
126
127 //clear window
128 ClearAgents();
129
130 //set agents
131 if ( developer_sync.m_PlayerAgentsSynced.Count() > 0 )
132 {
133 for ( int i = 0; i < developer_sync.m_PlayerAgentsSynced.Count(); i++ )
134 {
135 SyncedValueAgent syncedValue = SyncedValueAgent.Cast(developer_sync.m_PlayerAgentsSynced.Get(i));
136 AddAgent(
137 syncedValue.GetName(),
138 syncedValue.GetValue(),
139 syncedValue.GetID(),
140 syncedValue.GetTemporaryResistanceTime(),
141 );
142 }
143 }
144 }
145
146 bool OnClick( Widget w, int x, int y, int button )
147 {
148 DebugAgentData data;
149 if (w.GetName() == "ButtonAgentActivate")
150 {
151 data = m_AgentWidgetData.Get(w);
152 DebugGrowAgentsRequest(data.GetID(), true);
153 return true;
154 }
155 else if (w.GetName() == "ButtonAgentDeactivate")
156 {
157 data = m_AgentWidgetData.Get(w);
158 DebugGrowAgentsRequest(data.GetID(), false);
159 return true;
160 }
161 else if (w.GetName() == "ResetAgents")
162 {
163 DebugRemoveAgentsRequest();
164 return true;
165 }
166
167 return false;
168 }
169
170 void DebugGrowAgentsRequest(int agent_id, bool should_grow)
171 {
172 if(!should_grow)//id is minus value to mark killing instead of growing
173 {
174 agent_id *= -1;
175 }
176
177 ref Param1<int> p1 = new Param1<int>( agent_id );
178 Man man = GetGame().GetPlayer();
179 man.RPCSingleParam(ERPCs.DEV_AGENT_GROW, p1, true, man.GetIdentity());
180 }
181
182 void DebugRemoveAgentsRequest()
183 {
184 ref Param1<bool> p1 = new Param1<bool>( false );
185 Man man = GetGame().GetPlayer();
186 man.RPCSingleParam(ERPCs.DEV_RPC_AGENT_RESET, p1, true, man.GetIdentity());
187 }
188
189 void AddAgent(string title, string value, int id, float temporaryResistance)
190 {
191 Widget widget = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_hud_debug_agent.layout", m_WgtAgents);
192 ButtonWidget btn = ButtonWidget.Cast( widget.FindAnyWidget( "TextAgentName" ) );
193 TextWidget countWidget = TextWidget.Cast(widget.FindAnyWidget("TextWidgetAgentCount"));
194 TextWidget tempResistanceWidget = TextWidget.Cast(widget.FindAnyWidget("TextWidgetAgentTempResistanceTime"));
195 Widget activateButton = widget.FindAnyWidget("ButtonAgentActivate");
196 Widget deactivateButton = widget.FindAnyWidget("ButtonAgentDeactivate");
197
198 countWidget.SetText(value);
199 btn.SetText(title);
200 if (temporaryResistance > 0.0)
201 tempResistanceWidget.SetText(string.Format("(R-%1s)", Math.Round(temporaryResistance).ToString()));
202 else
203 tempResistanceWidget.SetText("");
204
205 DebugAgentData data = new DebugAgentData("", id);
206 m_AgentWidgets.Insert(widget);
207 m_AgentWidgetData.Insert(btn, data);
208 m_AgentWidgetData.Insert(activateButton, data);
209 m_AgentWidgetData.Insert(countWidget, data);
210 m_AgentWidgetData.Insert(tempResistanceWidget, data);
211 m_AgentWidgetData.Insert(deactivateButton, data);
212
213 WgtModifiersContentPanelScript.Update();
214 }
215
216 void ClearAgents()
217 {
218 m_AgentWidgetData.Clear();
219
220 for (int i = 0; i < m_AgentWidgets.Count(); i++)
221 {
222 delete m_AgentWidgets.Get(i);
223 }
224
225 m_AgentWidgets.Clear();
226 }
227
228 void FitWindow()
229 {
230 FitWindowByContent( TextListboxWidget.Cast(m_WgtAgents) );
231 }
232}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void FitWindowByContent(TextListboxWidget wgt)
void SetUpdate(bool state)
Definition enmath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition dayzgame.c:151
int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition effect.c:51
ERPCs
Definition erpcs.c:2
proto native CGame GetGame()
void HudDebug()
Definition huddebug.c:108
Widget m_WgtRoot
Definition huddebug.c:94
ref map< Widget, ref DebugAgentData > m_AgentWidgetData
ref array< ref Widget > m_AgentWidgets
class DebugAgentData m_WgtAgents
Icon x
Icon y
PlayerBase GetPlayer()
PluginBase GetPlugin(typename plugin_type)
class SyncedValue m_Name
void SyncedValueAgent(string name, string value, int id, float temporaryResistance)