3 TextListboxWidget m_WgtValues;
5 ref array<ref Widget> m_StatWidgets =
new array<ref Widget>;
6 ref map <ref SliderWidget, string> m_SliderWidgets =
new map<ref SliderWidget, string>;
7 ref array<ref TextWidget> m_StatValues =
new array<ref TextWidget>;
8 ref map<ref EditBoxWidget, string> m_StatValuesInput =
new map<ref EditBoxWidget, string>;
10 bool m_ChangingSlider;
15 void HudDebugWinCharStats(Widget widget_root)
25 void ~HudDebugWinCharStats()
69 PlayerBase player = PlayerBase.Cast(
g_Game.GetPlayer() );
71 PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast(
GetPlugin( PluginDeveloperSync ) );
76 ref Param1<bool> params =
new Param1<bool>( state );
79 player.RPCSingleParam(
ERPCs.DEV_STATS_UPDATE, params,
true );
88 developer_sync.EnableUpdate( state,
ERPCs.DEV_STATS_UPDATE, player );
106 PluginDeveloperSync developerSync = PluginDeveloperSync.Cast(
GetPlugin(PluginDeveloperSync));
111 if ( developerSync.m_PlayerStatsSynced.Count() > 0 )
113 foreach (SyncedValue syncedValue : developerSync.m_PlayerStatsSynced)
115 string name = syncedValue.GetName();
116 string value = syncedValue.GetValue().ToString();
118 AddValue(
name, value);
129 PluginDeveloperSync developerSync = PluginDeveloperSync.Cast(
GetPlugin( PluginDeveloperSync ) );
130 if ( developerSync.m_PlayerStatsSynced.Count() > 0 )
132 foreach (
int i, SyncedValue syncedValue : developerSync.m_PlayerStatsSynced)
134 string statName = syncedValue.GetName();
135 float valueNormalized = syncedValue.GetValueNorm();
136 float value = syncedValue.GetValue();
138 if ( statName ==
"BloodType" )
143 name = value.ToString();
144 name +=
"("+BloodTypes.GetBloodTypeName(Math.Round(value), type, positive)+
")";
145 m_StatValues.Get(i).SetText(
name);
149 if (statName ==
"HeatBuffer")
151 float heatBufferNormalized = Math.Round(Math.Lerp(-1, 1, valueNormalized) * 1000) * 0.001;
152 m_StatValues.Get(i).SetText(
string.Format(
"%1 (%2)", heatBufferNormalized.ToString(), value.ToString()));
155 m_StatValues.Get(i).SetText(value.ToString());
159 if (!m_ChangingSlider)
160 m_SliderWidgets.GetKeyByValue(statName).SetCurrent(valueNormalized * 100);
166 void AddValue(
string title,
string value)
168 Widget widget =
g_Game.GetWorkspace().CreateWidgets(
"gui/layouts/debug/day_z_hud_debug_stat.layout",
m_WgtPanel );
170 TextWidget tw = TextWidget.Cast(widget.FindAnyWidget(
"StatName"));
172 m_StatWidgets.Insert(widget);
174 TextWidget tw_output = TextWidget.Cast(widget.FindAnyWidget(
"OutputValue"));
175 m_StatValues.Insert(tw_output);
177 EditBoxWidget ebw_input = EditBoxWidget.Cast(widget.FindAnyWidget(
"InputValue"));
178 m_StatValuesInput.Insert(ebw_input, title );
180 SliderWidget sw = SliderWidget.Cast(widget.FindAnyWidget(
"StatSlider"));
181 m_SliderWidgets.Insert(sw,title );
183 AutoHeightSpacer WgtModifiersContent_panel_script;
184 m_WgtPanel.GetScript( WgtModifiersContent_panel_script );
185 WgtModifiersContent_panel_script.
Update();
190 m_StatWidgets.Clear();
195 TextListboxWidget wgt = TextListboxWidget.Cast(
m_WgtPanel);
200 bool OnClick( Widget w,
int x,
int y,
int button )
202 if ( w.GetName() ==
"ResetStats" )
211 bool OnChange(Widget w,
int x,
int y,
bool finished)
213 if ( m_StatValuesInput.Contains(EditBoxWidget.Cast(w)) && finished )
215 EditBoxWidget ebw = EditBoxWidget.Cast(w);
216 RPCChangeStat(m_StatValuesInput.Get(EditBoxWidget.Cast(w)), ebw.GetText().ToFloat());
219 if (m_SliderWidgets.Contains(SliderWidget.Cast(w)))
221 m_ChangingSlider =
true;
222 string stat_name = m_SliderWidgets.Get(SliderWidget.Cast(w));
223 SliderWidget sw = SliderWidget.Cast(w);
224 PlayerBase player = PlayerBase.Cast(
g_Game.GetPlayer());
225 for (
int i = 0; i < player.m_PlayerStats.GetPCO().
Get().
Count(); i++ )
227 string label = player.m_PlayerStats.GetPCO().Get().Get( i ).GetLabel();
228 if(label == stat_name)
230 float stat_min = player.m_PlayerStats.GetPCO().Get().Get( i ).GetMin();
231 float stat_max = player.m_PlayerStats.GetPCO().Get().Get( i ).GetMax();
232 float current_value_norm = sw.GetCurrent() / 100;
233 float current_value_abs = stat_min + (stat_max - stat_min) * current_value_norm;
235 RPCChangeStat(label, current_value_abs);
240 m_ChangingSlider =
false;
249 PlayerBase player = PlayerBase.Cast(
g_Game.GetPlayer() );
253 ref Param1<bool> params =
new Param1<bool>(
false );
256 player.RPCSingleParam(
ERPCs.DEV_RPC_STATS_RESET, params,
true );
260 void RPCChangeStat(
string stat,
float value)
262 PlayerBase player = PlayerBase.Cast(
g_Game.GetPlayer() );
266 ref Param2<string, float> params =
new Param2<string, float>( stat, value );
269 player.RPCSingleParam(
ERPCs.DEV_RPC_STAT_SET, params,
true );
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void FitWindowByContent(TextListboxWidget wgt)
void SetUpdate(bool state)
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
override bool OnChange(Widget w, int x, int y, bool finished)
PluginBase GetPlugin(typename plugin_type)