DayZ 1.24
Loading...
Searching...
No Matches
ScriptConsoleEnfScriptTab.c
Go to the documentation of this file.
2{
4 protected int m_EnscriptHistoryRow;
14 protected bool m_AllowScriptOutput;
15 protected int m_RunColor;
16
18
32
37
38 override void OnSelected()
39 {
41 if (m_EnscriptConsoleHistory.IsValidIndex(index))
42 {
44 m_EnfScriptEdit.SetText(text);
45 }
47 }
48
49 static void PrintS(string message)
50 {
52 if (m_Instance)
54 }
55
56 static void PrintS(bool message)
57 {
58 PrintS(message.ToString());
59 }
60
61 static void PrintS(int message)
62 {
63 PrintS(message.ToString());
64 }
65
66 static void PrintS(float message)
67 {
68 PrintS(message.ToString());
69 }
70
71 static void PrintS(vector message)
72 {
73 PrintS(message.ToString());
74 }
75
76 static void PrintS(Object message)
77 {
78 PrintS(message.ToString());
79 }
80
81
82 void Add(string message, bool isReload = false)
83 {
84 if (message != string.Empty)
85 {
87 {
88 if (!isReload)
91 m_ScriptOutputListbox.EnsureVisible(m_ScriptOutputListbox.GetNumItems());
92 }
93 }
94 }
95
96 protected void Clear(bool clearFile = false)
97 {
98 if (clearFile)
100 m_ScriptOutputListbox.ClearItems();
101 }
102
103
104 protected void ReloadScriptOutput()
105 {
106 m_ScriptOutputListbox.ClearItems();
107 m_AllowScriptOutput = true;
108 foreach (string s: m_ScriptOutputHistory)
109 Add(s, true);
110 m_AllowScriptOutput = false;
111 }
112
114 {
115
117 }
118
120 {
122 }
123
124 protected void RunEnscript()
125 {
126#ifdef DEVELOPER
127 string code;
128 m_EnfScriptEdit.GetText(code);
129 string codeNoReplace = code;
131 m_AllowScriptOutput = true;
132 code.Replace("Print(", "ScriptConsoleEnfScriptTab.PrintS(");
133 code.Replace("Print (", "ScriptConsoleEnfScriptTab.PrintS(");
134 bool success = GetGame().ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
135 m_AllowScriptOutput = false;
137
140#endif
141 }
142
143 protected void ColorRunButton(bool success)
144 {
145 if (success)
146 m_EnfScriptRun.SetColor(ARGB(255, 0, 255, 0));
147 else
148 m_EnfScriptRun.SetColor(ARGB(255, 255, 0, 0));
149 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ResetRunButtonColor, 600);
150 }
151
152 protected void ResetRunButtonColor()
153 {
154 m_EnfScriptRun.SetColor(m_RunColor);
155 }
156
157 protected void RunEnscriptServer()
158 {
159 string code;
160 m_EnfScriptEdit.GetText(code);
164 GetGame().RPCSingleParam(GetGame().GetPlayer(), ERPCs.DEV_RPC_SERVER_SCRIPT, CachedObjectsParams.PARAM1_STRING, true, GetGame().GetPlayer().GetIdentity());
165 }
166
167 protected void EnscriptHistoryBack()
168 {
169 int history_index;
170 if (m_EnfScriptEdit)
171 {
174 if (history_index > -1)
177 }
178 }
179
180
193
195 {
196 super.OnRPCEx(rpc_type, ctx);
197#ifdef DIAG_DEVELOPER
198 switch (rpc_type)
199 {
200 case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
201 {
204 break;
205 }
206 }
207#endif
208 }
209
210 override bool OnClick(Widget w, int x, int y, int button)
211 {
212 super.OnClick(w, x, y, button);
213 if (w == m_EnfScriptRun)
214 {
215 RunEnscript();
216 return true;
217 }
218 else if (w == m_EnfScriptClear)
219 {
220 m_ScriptOutputListbox.ClearItems();
221 m_ScriptOutputHistory.Clear();
222 return true;
223 }
224
225 return false;
226 }
227
228 override bool OnChange(Widget w, int x, int y, bool finished)
229 {
230 super.OnChange(w, x, y, finished);
231 return false;
232 }
233
234
235 override void Show(bool show, ScriptConsoleTabBase selectedHandler)
236 {
238 {
239 //do nothing
240 }
241 else
242 {
243 m_Root.Show(show);
244 m_Root.Enable(show);
245 }
246 }
247
248}
249
251{
252 override void OnSelected()
263 override protected void EnscriptHistoryBack()
266 if (m_EnfScriptEdit)
270 if (history_index > -1)
273 }
274 }
275
276 override protected void EnscriptHistoryForward()
277 {
278 if (m_EnfScriptEdit)
279 {
280 int history_index;
281
287 }
288 }
289
290 override bool OnClick(Widget w, int x, int y, int button)
291 {
292 if (w == m_EnfScriptRun)
293 {
295 return true;
296 }
297 else if (w == m_EnfScriptClear)
298 {
300 m_ScriptOutputHistory.Clear();
301 return true;
302 }
303
304 return false;
305 }
307}
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition DayZGame.c:144
ERPCs
Definition ERPCs.c:2
Empty
Definition Hand_States.c:14
Icon x
Icon y
PlayerBase GetPlayer()
PluginBase GetPlugin(typename plugin_type)
PlayerBase _player
ref TStringArray m_EnscriptConsoleHistoryServer
int m_EnscriptHistoryRowServer
ButtonWidget m_EnfScriptClear
ScriptConsoleEnfScriptTab ScriptConsoleTabBase OnSelected()
TextListboxWidget m_ScriptOutputListbox
static ref TStringArray m_ScriptOutputHistory
void RunEnscriptServer()
void ReloadScriptOutput()
ButtonWidget m_EnfScriptRun
void EnscriptHistoryBack()
MultilineEditBoxWidget m_EnfScriptEdit
void EnscriptHistoryForward()
static ref Param1< bool > PARAM1_BOOL
static ref Param1< string > PARAM1_STRING
Definition Debug.c:14
static void ClearLogs()
Definition Debug.c:638
static void PrintS(bool message)
override bool OnChange(Widget w, int x, int y, bool finished)
override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer
static void PrintS(string message)
static ScriptConsoleEnfScriptTab m_Instance
static void PrintS(float message)
void Clear(bool clearFile=false)
static ref TStringArray m_ScriptOutputHistory
MultilineEditBoxWidget m_EnfScriptEdit
ref TStringArray m_EnscriptConsoleHistoryServer
override bool OnClick(Widget w, int x, int y, int button)
void ScriptConsoleEnfScriptTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
void Add(string message, bool isReload=false)
static void PrintS(vector message)
PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory
static void PrintS(Object message)
override void Show(bool show, ScriptConsoleTabBase selectedHandler)
static void PrintS(int message)
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
array< string > TStringArray
Definition EnScript.c:666
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
Definition EnScript.c:338
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
int ARGB(int a, int r, int g, int b)
Definition proto.c:322