DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
HudDebugWinCharAgents.c
См. документацию.
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
23 {
24
25 }
26}
27
28
30{
34
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
48 }
49
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
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 {
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
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
214 }
215
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
229 {
230 FitWindowByContent( TextListboxWidget.Cast(m_WgtAgents) );
231 }
232}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
ERPCs
Определения ERPCs.c:2
void HudDebug()
Определения HudDebug.c:108
Widget m_WgtRoot
Определения HudDebug.c:94
ref map< Widget, ref DebugAgentData > m_AgentWidgetData
Определения HudDebugWinCharAgents.c:33
void HudDebugWinCharAgents(Widget widget_root)
Определения HudDebugWinCharAgents.c:39
void ClearAgents()
Определения HudDebugWinCharAgents.c:216
void ~HudDebugWinCharAgents()
Определения HudDebugWinCharAgents.c:50
void SetAgents()
Определения HudDebugWinCharAgents.c:123
ref array< ref Widget > m_AgentWidgets
Определения HudDebugWinCharAgents.c:32
void DebugGrowAgentsRequest(int agent_id, bool should_grow)
Определения HudDebugWinCharAgents.c:170
void AddAgent(string title, string value, int id, float temporaryResistance)
Определения HudDebugWinCharAgents.c:189
class DebugAgentData m_WgtAgents
AutoHeightSpacer WgtModifiersContentPanelScript
Определения HudDebugWinCharAgents.c:35
void DebugRemoveAgentsRequest()
Определения HudDebugWinCharAgents.c:182
Icon x
Icon y
PlayerBase GetPlayer()
Определения ModifierBase.c:51
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
void SyncedValueAgent(string name, string value, int id, float temporaryResistance)
Определения SyncedValue.c:111
proto native DayZPlayer GetPlayer()
proto native WorkspaceWidget GetWorkspace()
float GetTemporaryResistance()
Определения HudDebugWinCharAgents.c:22
string GetName()
Определения HudDebugWinCharAgents.c:12
int GetID()
Определения HudDebugWinCharAgents.c:17
string m_Name
Определения HudDebugWinCharAgents.c:3
int m_ID
Определения HudDebugWinCharAgents.c:4
void DebugAgentData(string name, int id)
Определения HudDebugWinCharAgents.c:6
void Show()
Определения HudDebugWinBase.c:48
void SetRPCSent()
Определения HudDebugWinBase.c:39
bool OnClick(Widget w, int x, int y, int button)
Определения HudDebugWinCharStats.c:200
void Hide()
Определения HudDebugWinBase.c:57
void FitWindow()
Определения HudDebugWinCharLevels.c:130
void FitWindowByContent(TextListboxWidget wgt)
Определения HudDebugWinBase.c:74
void SetUpdate(bool state)
int GetType()
Определения HudDebugWinBase.c:18
void Update()
Определения HudDebugWinBase.c:27
Определения HudDebugWinBase.c:2
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
Определения EnWidgets.c:220
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString(bool simple=true)
proto native CGame GetGame()
static proto float Round(float f)
Returns mathematical round of value.
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.