Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
23 
25 {
26  protected Widget m_WgtAgents;
29  //============================================
30  // HudDebugWinCharAgents
31  //============================================
32  void HudDebugWinCharAgents( Widget widget_root )
33  {
34  m_WgtRoot = widget_root;
35  //m_WgtAgents = TextListboxWidget.Cast( m_WgtRoot.FindAnyWidget( "txl_CharAgents_Values" ) );
36  m_WgtAgents = m_WgtRoot.FindAnyWidget( "AgentList" );
37 
38  //FitWindowByContent( m_WgtAgents );
39  }
40 
42  {
43  SetUpdate( false );
44  }
45 
46  //============================================
47  // GetWinType
48  //============================================
49  override int GetType()
50  {
51  return HudDebug.HUD_WIN_CHAR_AGENTS;
52  }
53 
54  //============================================
55  // Update
56  //============================================
57  override void SetUpdate( bool state )
58  {
59  //Disable update on server (PluginDeveloperSync)
60  PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
61  PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) );
62 
63  //if client, send RPC
64  if ( GetGame().IsClient() )
65  {
66  ref Param1<bool> params = new Param1<bool>( state );
67  if ( player )
68  {
69  player.RPCSingleParam( ERPCs.DEV_AGENTS_UPDATE, params, true );
70  SetRPCSent();
71  }
72  }
73  //else set directly
74  else
75  {
76  if ( developer_sync )
77  {
78  developer_sync.EnableUpdate( state, ERPCs.DEV_AGENTS_UPDATE, player );
79  }
80  }
81  }
82 
83  override void Update()
84  {
85  super.Update();
86 
87  //Print("Update()");
88 
89  //refresh notifiers
90  SetAgents();
91  }
92 
93  //============================================
94  // Show / Hide
95  //============================================
96  override void Show()
97  {
98  super.Show();
99 
100  //Print("Show()");
101 
102  SetUpdate( true );
103  }
104 
105  override void Hide()
106  {
107  super.Hide();
108 
109  //Print("Hide()");
110 
111  SetUpdate( false );
112  }
113 
114  void SetAgents()
115  {
116  PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) );
117 
118  //clear window
119  ClearAgents();
120 
121  //set agents
122  if ( developer_sync.m_PlayerAgentsSynced.Count() > 0 )
123  {
124  for ( int i = 0; i < developer_sync.m_PlayerAgentsSynced.Count(); i++ )
125  {
126  AddAgent( developer_sync.m_PlayerAgentsSynced.Get( i ).GetName(), developer_sync.m_PlayerAgentsSynced.Get( i ).GetValue(), developer_sync.m_PlayerAgentsSynced.Get( i ).GetID() );
127  }
128  }
129 
130  //fit to screen
131  //FitWindow();
132  }
133 
134  /*
135  void AddAgent( string title, string value )
136  {
137  int index = m_WgtAgents.AddItem( title, NULL, 0 );
138  m_WgtAgents.SetItem( index, value, NULL, 1 );
139  }
140  */
141  bool OnClick( Widget w, int x, int y, int button )
142  {
143  //Button activate
144  DebugAgentData data;
145  if ( w.GetName() == "ButtonAgentActivate" )
146  {
147  data = m_AgentWidgetData.Get( w );
148  DebugGrowAgentsRequest(data.GetID(), true);
149  //Print("activate" + data.GetID().ToString());
150  return true;
151  }
152  //Button deactivate
153  else if ( w.GetName() == "ButtonAgentDeactivate" )
154  {
155  data = m_AgentWidgetData.Get( w );
156  DebugGrowAgentsRequest(data.GetID(), false);
157  //Print("deactivate" + data.GetID().ToString());
158  return true;
159  }
160  else if ( w.GetName() == "ResetAgents" )
161  {
163  return true;
164  }
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 
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 )
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 
194 
195  DebugAgentData data = new DebugAgentData( "", id );
196  m_AgentWidgetData.Insert(btn, data);
197 
198  Widget activate_button = widget.FindAnyWidget( "ButtonAgentActivate" );
199  m_AgentWidgetData.Insert( activate_button, data );
200 
201  TextWidget count_widget = TextWidget.Cast(widget.FindAnyWidget( "TextWidgetAgentCount" ));
202  m_AgentWidgetData.Insert( count_widget, data );
203  count_widget.SetText(value);
204 
205  //Deactivate button
206  Widget deactivate_button = widget.FindAnyWidget( "ButtonAgentDeactivate" );
207  m_AgentWidgetData.Insert( deactivate_button, data );
208 
209  btn.SetText(title);
210  m_AgentWidgets.Insert(widget);
211 
212  AutoHeightSpacer WgtModifiersContent_panel_script;
213  m_WgtAgents.GetScript( WgtModifiersContent_panel_script );
214  WgtModifiersContent_panel_script.Update();
215  }
216 
217  void ClearAgents()
218  {
219  m_AgentWidgetData.Clear();
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 }
GetGame
proto native CGame GetGame()
m_WgtRoot
Widget m_WgtRoot
Definition: huddebug.c:92
SetAgents
void SetAgents()
Definition: huddebugwincharagents.c:114
AutoHeightSpacer
Definition: autoheightspacer.c:2
FitWindow
void FitWindow()
Definition: huddebugwincharagents.c:228
SetUpdate
override void SetUpdate(bool state)
Definition: huddebugwincharagents.c:57
DebugGrowAgentsRequest
void DebugGrowAgentsRequest(int agent_id, bool should_grow)
Definition: huddebugwincharagents.c:170
m_Name
string m_Name
Definition: bioslobbyservice.c:35
y
Icon y
HudDebugWinBase
Definition: huddebugwinbase.c:1
~HudDebugWinCharAgents
void ~HudDebugWinCharAgents()
Definition: huddebugwincharagents.c:41
AddAgent
void AddAgent(string title, string value, int id)
Definition: huddebugwincharagents.c:189
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
DebugAgentData
Definition: huddebugwincharagents.c:1
TextWidget
Definition: enwidgets.c:219
OnClick
bool OnClick(Widget w, int x, int y, int button)
Definition: huddebugwincharagents.c:141
ClearAgents
void ClearAgents()
Definition: huddebugwincharagents.c:217
array< ref Widget >
Update
override void Update()
Definition: huddebugwincharagents.c:83
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
x
Icon x
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
HudDebug
void HudDebug()
Definition: huddebug.c:104
m_AgentWidgetData
protected ref map< Widget, ref DebugAgentData > m_AgentWidgetData
Definition: huddebugwincharagents.c:28
ERPCs
ERPCs
Definition: erpcs.c:1
Widget
Definition: enwidgets.c:189
m_WgtAgents
class DebugAgentData m_WgtAgents
Hide
override void Hide()
Definition: huddebugwincharagents.c:105
Show
override void Show()
Definition: huddebugwincharagents.c:96
m_ID
protected int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition: effect.c:49
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
HudDebugWinCharAgents
void HudDebugWinCharAgents(Widget widget_root)
Definition: huddebugwincharagents.c:32
m_AgentWidgets
protected ref array< ref Widget > m_AgentWidgets
Definition: huddebugwincharagents.c:27
DebugRemoveAgentsRequest
void DebugRemoveAgentsRequest()
Definition: huddebugwincharagents.c:182