Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
huddebugwinhorticulture.c
Go to the documentation of this file.
2{
3 protected EditBoxWidget m_FullMaturityEditBox;
4 protected EditBoxWidget m_SpoilEditBox;
5 protected EditBoxWidget m_SpoilRemoveEditBox;
6 protected EditBoxWidget m_DryRemoveEditBox;
7 protected EditBoxWidget m_SetAllEditBox;
8 protected EditBoxWidget m_SpeedEditBox;
9 protected ButtonWidget m_ButtonUpdate;
10 protected ButtonWidget m_ButtonUpdateTarget;
11 protected ButtonWidget m_ButtonReset;
12 protected ButtonWidget m_ButtonSetAll;
13 protected ButtonWidget m_ButtonSpeed;
14
15 protected PluginDeveloperSync m_DevSyncPlugin;
16
17 void HudDebugWinHorticulture(Widget widget_root)
18 {
19 m_WgtRoot = widget_root;
20 }
21
22 override int GetType()
23 {
24 return HudDebug.HUD_WIN_HORTICULTURE;
25 }
26
27 override void Show()
28 {
29 super.Show();
30
31 if (!m_DevSyncPlugin)
32 m_DevSyncPlugin = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) );
33 }
34
36 bool OnClick( Widget w, int x, int y, int button )
37 {
38 if (!w)
39 return false;
40
41 if (!m_ButtonUpdate)
42 {
43 m_ButtonUpdate = ButtonWidget.Cast(m_WgtRoot.FindAnyWidget("ButtonUpdate"));
44 m_ButtonUpdateTarget = ButtonWidget.Cast(m_WgtRoot.FindAnyWidget("ButtonUpdateTarget"));
45 m_ButtonReset = ButtonWidget.Cast(m_WgtRoot.FindAnyWidget("ButtonReset"));
46 m_ButtonSetAll = ButtonWidget.Cast(m_WgtRoot.FindAnyWidget("ButtonSetAll"));
47 m_ButtonSpeed = ButtonWidget.Cast(m_WgtRoot.FindAnyWidget("ButtonSpeed"));
48 m_SetAllEditBox = EditBoxWidget.Cast(m_WgtRoot.FindAnyWidget("SetAllEBox"));
49 m_FullMaturityEditBox = EditBoxWidget.Cast(m_WgtRoot.FindAnyWidget("FullMaturityEBox"));
50 m_SpoilEditBox = EditBoxWidget.Cast(m_WgtRoot.FindAnyWidget("SpoilEBox"));
51 m_SpoilRemoveEditBox = EditBoxWidget.Cast(m_WgtRoot.FindAnyWidget("SpoilRemoveEBox"));
52 m_DryRemoveEditBox = EditBoxWidget.Cast(m_WgtRoot.FindAnyWidget("DryRemoveEBox"));
53 m_SpeedEditBox = EditBoxWidget.Cast(m_WgtRoot.FindAnyWidget("SpeedEBox"));
54 }
55
56 if (w == m_ButtonUpdate)
57 {
58 SendRPCUpdate(false);
59 return true;
60 }
61
62 if (w == m_ButtonUpdateTarget)
63 {
64 SendRPCUpdate(true);
65 return true;
66 }
67
68 if (w == m_ButtonSpeed)
69 {
70 float speedMult = m_SpeedEditBox.GetText().ToFloat();
71 SendRPCSpeed(speedMult);
72 return true;
73 }
74
75 if (w == m_ButtonSetAll)
76 {
77 int setAll = m_SetAllEditBox.GetText().ToInt();
78 m_FullMaturityEditBox.SetText(setAll.ToString());
79 m_SpoilEditBox.SetText(setAll.ToString());
80 m_SpoilRemoveEditBox.SetText(setAll.ToString());
81 m_DryRemoveEditBox.SetText(setAll.ToString());
82
83 return true;
84 }
85
86 if (w == m_ButtonReset)
87 {
88 m_FullMaturityEditBox.SetText("0");
89 m_SpoilEditBox.SetText("0");
90 m_SpoilRemoveEditBox.SetText("0");
91 m_DryRemoveEditBox.SetText("0");
92 m_SpeedEditBox.SetText("1");
93 SendRPCUpdate(false);
94 SendRPCSpeed(1);
95
96 return true;
97 }
98
99 return false;
100 }
101
102 protected void SendRPCSpeed(float multiplier)
103 {
104 multiplier = Math.Clamp(multiplier, 0.1, 1000);
105 Param1<float> param = new Param1<float>(multiplier);
106
107 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
108
109 if (!GetGame().IsMultiplayer())
110 PlantBase.DebugSetTickSpeedMultiplier(multiplier);
111 else
112 player.RPCSingleParam(ERPCs.DEV_RPC_HORTICULTURE_SPEED, param, true);
113 }
114
115 protected void SendRPCUpdate(bool isTarget)
116 {
117 int slotID = -1;
118 GardenBase garden;
119 int maturity = m_FullMaturityEditBox.GetText().ToInt();
120 int spoil = m_SpoilEditBox.GetText().ToInt();
121 int spoilRemove = m_SpoilRemoveEditBox.GetText().ToInt();
122 int dryRemove = m_DryRemoveEditBox.GetText().ToInt();
123
124 Param6<int, GardenBase, int, int, int, int> params;
125 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
126
127 if (isTarget && player && player.GetActionManager())
128 {
129 ActionTarget at = player.GetActionManager().FindActionTarget();
130 if (at)
131 garden = GardenBase.Cast(at.GetObject());
132
133 if (garden)
134 {
135 array<string> selections = new array<string>;
136 garden.GetActionComponentNameList(at.GetComponentIndex(), selections);
137
138 for (int s = 0; s < selections.Count(); s++)
139 {
140 string selection = selections[s];
141 Slot slot = garden.GetSlotBySelection( selection );
142 if (slot && slot.GetPlant())
143 {
144 slotID = slot.GetSlotIndex();
145 }
146 }
147 }
148 }
149
150 params = new Param6<int, GardenBase, int, int, int, int>(slotID, garden, maturity, spoil, spoilRemove, dryRemove);
151
152 if (!GetGame().IsMultiplayer())
153 {
154 if (slotID != -1 && garden)
155 {
156 Slot gSlot = garden.GetSlotByIndex(slotID);
157 if (gSlot && gSlot.GetPlant())
158 gSlot.GetPlant().DebugSetTimes(maturity, spoil, spoilRemove, dryRemove);
159 }
160 else
161 PlantBase.DebugSetGlobalTimes(params.param3, params.param4, params.param5, params.param6);
162 }
163 else if (player)
164 player.RPCSingleParam(ERPCs.DEV_RPC_HORTICULTURE_UPDATE, params, true);
165 }
166}
void SendRPCSpeed(float multiplier)
bool OnClick(Widget w, int x, int y, int button)
Called from HudDebug.c.
void HudDebugWinHorticulture(Widget widget_root)
PluginDeveloperSync m_DevSyncPlugin
Definition enmath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
ERPCs
Definition erpcs.c:2
proto native CGame GetGame()
void HudDebug()
Definition huddebug.c:108
Widget m_WgtRoot
Definition huddebug.c:94
Icon x
Icon y
PlayerBase GetPlayer()
PluginBase GetPlugin(typename plugin_type)