DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
HudDebugWinCharAgents.c
См. документацию.
1class HudDebugWinCharAgentsEntry extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
4 protected ButtonWidget m_ActivateButton;
5 protected ButtonWidget m_DeactivateButton;
7 protected int m_ID;
8
9 void HudDebugWinCharAgentsEntry(HudDebugWinCharAgents hudDebugAgents, Widget parent, string title, string value, int id, float temporaryResistance)
10 {
11 m_HudDebugAgents = hudDebugAgents;
12 m_ID = id;
13
14 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_hud_debug_agent.layout", parent);
15
16 TextWidget txt = TextWidget.Cast(m_Root.FindAnyWidget("TextAgentName"));
17 TextWidget countWidget = TextWidget.Cast(m_Root.FindAnyWidget("TextWidgetAgentCount"));
18 TextWidget tempResistanceWidget = TextWidget.Cast(m_Root.FindAnyWidget("TextWidgetAgentTempResistanceTime"));
19 m_ActivateButton = ButtonWidget.Cast(m_Root.FindAnyWidget("ButtonAgentActivate"));
20 m_DeactivateButton = ButtonWidget.Cast(m_Root.FindAnyWidget("ButtonAgentDeactivate"));
21
22 countWidget.SetText(value);
23 txt.SetText(title);
24 if (temporaryResistance > 0.0)
25 tempResistanceWidget.SetText(string.Format("(R-%1s)", Math.Round(temporaryResistance).ToString()));
26 else
27 tempResistanceWidget.SetText("");
28
29 m_Root.SetHandler(this);
30 }
31
33 {
34 m_Root.Unlink();
35 delete m_Root;
36 }
37
38 void DebugGrowAgentsRequest(int agentId, bool shouldGrow)
39 {
40 if(!shouldGrow)//id is minus value to mark killing instead of growing
41 {
42 agentId *= -1;
43 }
44
45 Param1<int> p1 = new Param1<int>(agentId);
46 Man man = GetGame().GetPlayer();
47 man.RPCSingleParam(ERPCs.DEV_AGENT_GROW, p1, true, man.GetIdentity());
48 }
49
50 override bool OnClick(Widget w, int x, int y, int button)
51 {
52 super.OnClick(w, x, y, button);
53
54 if (w == m_ActivateButton)
55 {
57 return true;
58 }
59 else if (w == m_DeactivateButton)
60 {
62 return true;
63 }
64
65 return false;
66 }
67}
68
70{
71 protected const float AGENTS_UPDATE_TIME = 0.500;
72
73 protected GridSpacerWidget m_WgtAgents;
76
77 protected float m_UpdateAgentsTimer;
78
79 void HudDebugWinCharAgents(Widget widget_root)
80 {
81 m_WgtRoot = widget_root;
82 m_WgtAgents = GridSpacerWidget.Cast(m_WgtRoot.FindAnyWidget("AgentList"));
83 m_WgtHeader = m_WgtRoot.FindAnyWidget("header_CharacterAgents");
84
85 OnInit();
86 }
87
88 void OnInit()
89 {
92 {
93 vector pos = m_ConfigDebugProfile.GetCharacterAgentsPos();
94 if (m_WgtRoot && pos != vector.Zero)
95 {
96 float wx = pos[0];
97 float wy = pos[1];
98 m_WgtRoot.SetPos(wx, wy);
99 }
100 }
101 }
102
104 {
105 SetUpdate(false);
106 }
107
108 override int GetType()
109 {
110 return HudDebug.HUD_WIN_CHAR_AGENTS;
111 }
112
113 override void SetUpdate(bool state)
114 {
115 //Disable update on server (PluginDeveloperSync)
116 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
117 PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
118
119 //if client, send RPC
120 if ( g_Game.IsClient() )
121 {
122 Param1<bool> params = new Param1<bool>(state);
123 if (player)
124 {
125 player.RPCSingleParam(ERPCs.DEV_AGENTS_UPDATE, params, true);
126 SetRPCSent();
127 }
128 }
129 //else set directly
130 else
131 {
132 if (developer_sync)
133 {
134 developer_sync.EnableUpdate(state, ERPCs.DEV_AGENTS_UPDATE, player);
135 }
136 }
137 }
138
139 override void Update(float timeslice)
140 {
141 super.Update(timeslice);
142
143 if (m_IsDragging)
144 {
145 int x,y;
146 GetMousePos(x,y);
147 m_WgtRoot.SetPos(x + m_DraggingOffset[0], y + m_DraggingOffset[1]);
148 }
149 else
150 {
151 m_UpdateAgentsTimer += timeslice;
153 {
155 SetAgents();
156 }
157 }
158 }
159
160 override void Show()
161 {
162 super.Show();
163
164 SetUpdate(true);
165 }
166
167 override void Hide()
168 {
169 super.Hide();
170
171 SetUpdate(false);
172 }
173
175 {
176 PluginDeveloperSync developerSync = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
177
178 //clear window
179 ClearAgents();
180
181 //set agents
182 int agentsCount = developerSync.m_PlayerAgentsSynced.Count();
183 if (agentsCount > 0)
184 {
185 foreach (SyncedValueAgent agent : developerSync.m_PlayerAgentsSynced)
186 {
187 AddAgent(agent.GetName(), agent.GetValue(), agent.GetID(), agent.GetTemporaryResistanceTime());
188 }
189 }
190 }
191
192 bool OnClick(Widget w, int x, int y, int button)
193 {
194 SetDragging(false);
195
196 if (w.GetName() == "ResetAgents")
197 {
199 return true;
200 }
201
202 return false;
203 }
204
206 {
207 Param1<bool> p1 = new Param1<bool>(false);
208 Man man = g_Game.GetPlayer();
209 man.RPCSingleParam(ERPCs.DEV_RPC_AGENT_RESET, p1, true, man.GetIdentity());
210 }
211
212 void AddAgent(string title, string value, int id, float temporaryResistance)
213 {
214 HudDebugWinCharAgentsEntry agentEntry = new HudDebugWinCharAgentsEntry(this, m_WgtAgents, title, value, id, temporaryResistance);
215 m_AgentEntries.Insert(agentEntry);
216 }
217
219 {
220 for (int i = 0; i < m_AgentEntries.Count(); i++)
221 {
222 HudDebugWinCharAgentsEntry entry = m_AgentEntries[i];
223 entry.DestroyEntry();
224 delete entry;
225 }
226
227 m_AgentEntries.Clear();
228 }
229
230 bool OnMouseButtonDown(Widget w, int x, int y, int button)
231 {
232 if (button == 0 && (w == m_WgtRoot || w == m_WgtHeader))
233 {
234 SetDragging(true);
235 return true;
236 }
237
238 return false;
239 }
240
241 bool OnMouseButtonUp(Widget w, int x, int y, int button)
242 {
243 if (button == 0 && m_IsDragging)
244 {
245 SetDragging(false);
246 return true;
247 }
248
249 return false;
250 }
251
252 override void OnDraggingEnd()
253 {
254 float wx, wy;
255 m_WgtRoot.GetScreenPos(wx,wy);
257 {
258 m_ConfigDebugProfile.SetCharacterAgentsPos(Vector(wx,wy,0));
259 }
260 }
261}
DayZGame g_Game
Определения DayZGame.c:4074
ERPCs
Определения ERPCs.c:2
void HudDebug()
Определения HudDebug.c:93
Widget m_WgtRoot
Определения HudDebug.c:80
void HudDebugWinCharAgents(Widget widget_root)
Определения HudDebugWinCharAgents.c:79
void ClearAgents()
Определения HudDebugWinCharAgents.c:218
void ~HudDebugWinCharAgents()
Определения HudDebugWinCharAgents.c:103
class HudDebugWinCharAgentsEntry extends ScriptedWidgetEventHandler AGENTS_UPDATE_TIME
void SetAgents()
Определения HudDebugWinCharAgents.c:174
float m_UpdateAgentsTimer
Определения HudDebugWinCharAgents.c:77
GridSpacerWidget m_WgtAgents
Определения HudDebugWinCharAgents.c:73
Widget m_WgtHeader
Определения HudDebugWinCharAgents.c:74
void AddAgent(string title, string value, int id, float temporaryResistance)
Определения HudDebugWinCharAgents.c:212
ref array< ref HudDebugWinCharAgentsEntry > m_AgentEntries
Определения HudDebugWinCharAgents.c:75
void DebugRemoveAgentsRequest()
Определения HudDebugWinCharAgents.c:205
Icon x
Icon y
PluginConfigDebugProfile m_ConfigDebugProfile
Определения PluginItemDiagnostic.c:58
bool m_IsDragging
Определения PluginItemDiagnostic.c:57
vector m_DraggingOffset
Определения PluginItemDiagnostic.c:72
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
Widget m_Root
Определения SizeToChild.c:91
void SyncedValueAgent(string name, string value, int id, float temporaryResistance)
Определения SyncedValue.c:111
bool OnMouseButtonUp(Widget w, int x, int y, int button)
Определения HudDebugWinCharStats.c:285
void SetDragging(bool enable)
Определения HudDebugWinBase.c:100
void Show()
Определения HudDebugWinBase.c:52
void SetRPCSent()
Определения HudDebugWinBase.c:43
bool OnClick(Widget w, int x, int y, int button)
Определения HudDebugWinCharStats.c:201
void Hide()
Определения HudDebugWinBase.c:61
void OnDraggingEnd()
void SetUpdate(bool state)
void OnInit()
Определения HudDebugWinCharStats.c:25
int GetType()
Определения HudDebugWinBase.c:22
bool OnMouseButtonDown(Widget w, int x, int y, int button)
Определения HudDebugWinCharStats.c:274
Определения HudDebugWinBase.c:2
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
void HudDebugWinCharAgentsEntry(HudDebugWinCharAgents hudDebugAgents, Widget parent, string title, string value, int id, float temporaryResistance)
Определения HudDebugWinCharAgents.c:9
Widget m_Root
Определения SizeToChild.c:9
ButtonWidget m_ActivateButton
Определения HudDebugWinCharAgents.c:4
override bool OnClick(Widget w, int x, int y, int button)
Определения HudDebugWinCharAgents.c:50
void DebugGrowAgentsRequest(int agentId, bool shouldGrow)
Определения HudDebugWinCharAgents.c:38
ButtonWidget m_DeactivateButton
Определения HudDebugWinCharAgents.c:5
HudDebugWinCharAgents m_HudDebugAgents
Определения HudDebugWinCharAgents.c:6
Deprecated.
Определения EnWidgets.c:657
Определения EnWidgets.c:220
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString(bool simple=true)
static const vector Zero
Определения EnConvert.c:123
Определения EnConvert.c:119
DayZGame GetGame()
Определения gameplay.c:636
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Round(float f)
Returns mathematical round of value.
proto void GetMousePos(out int x, out int y)
proto native volatile void Update()
Определения PlayerSoundManager.c:125
WorkspaceWidget Widget
Defined in code.