DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ScriptConsoleEnfScriptTab.c
См. документацию.
2{
4 protected int m_EnscriptHistoryRow;
8 protected PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory;
9 protected PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer;
10 protected MultilineEditBoxWidget m_EnfScriptEdit;
11 protected ButtonWidget m_EnfScriptRun;
12 protected ButtonWidget m_EnfScriptClear;
13 protected TextListboxWidget m_ScriptOutputListbox;
14 protected bool m_AllowScriptOutput;
15 protected int m_RunColor;
16
18
19 void ScriptConsoleEnfScriptTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
20 {
21 m_Instance = this;
22 m_ModuleLocalEnscriptHistory = PluginLocalEnscriptHistory.Cast(GetPlugin(PluginLocalEnscriptHistory));
23 m_ModuleLocalEnscriptHistoryServer = PluginLocalEnscriptHistoryServer.Cast(GetPlugin(PluginLocalEnscriptHistoryServer));
26 m_EnfScriptEdit = MultilineEditBoxWidget.Cast(root.FindAnyWidget("MultilineEditBoxWidget0"));
27 m_EnfScriptRun = ButtonWidget.Cast(root.FindAnyWidget("RunButton"));
28 m_EnfScriptClear = ButtonWidget.Cast(root.FindAnyWidget("ClearButton"));
29 m_ScriptOutputListbox = TextListboxWidget.Cast(root.FindAnyWidget("ScriptOutputListbox"));
30 m_RunColor = m_EnfScriptRun.GetColor();
31 }
32
34 {
35 m_Instance = null;
36 }
37
38 override void OnSelected()
39 {
40 int index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
41 if (m_EnscriptConsoleHistory.IsValidIndex(index))
42 {
43 string text = m_EnscriptConsoleHistory.Get(index);
44 m_EnfScriptEdit.SetText(text);
45 }
47 }
48
49 static void PrintS(string message)
50 {
51 Print(message);
52 if (m_Instance)
53 m_Instance.Add(message);
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)
89 m_ScriptOutputHistory.Insert(message);
90 m_ScriptOutputListbox.AddItem(String(message), NULL, 0);
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
105 protected void ReloadScriptOutput()
106 {
107 m_ScriptOutputListbox.ClearItems();
108 m_AllowScriptOutput = true;
109 foreach ( string s: m_ScriptOutputHistory)
110 {
111 Add(s, true);
112 }
113 m_AllowScriptOutput = false;
114 }
115
117 {
118
120 }
121
123 {
125 }
126
127 protected void RunEnscript()
128 {
129 #ifdef DEVELOPER
130 string code;
131 m_EnfScriptEdit.GetText(code);
132 string codeNoReplace = code;
134 m_AllowScriptOutput = true;
135 code.Replace("Print(","ScriptConsoleEnfScriptTab.PrintS(");
136 code.Replace("Print (","ScriptConsoleEnfScriptTab.PrintS(");
137 bool success = GetGame().ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
138 m_AllowScriptOutput = false;
139 ColorRunButton(success);
140
141 m_EnscriptConsoleHistory.Insert(codeNoReplace);
142 m_ModuleLocalEnscriptHistory.AddNewLine(codeNoReplace);
143 #endif
144 }
145
146 protected void ColorRunButton(bool success)
147 {
148 if (success)
149 {
150 m_EnfScriptRun.SetColor(ARGB(255,0,255,0));
151 }
152 else
153 {
154 m_EnfScriptRun.SetColor(ARGB(255,255,0,0));
155 }
157 }
158
159 protected void ResetRunButtonColor()
160 {
161 m_EnfScriptRun.SetColor(m_RunColor);
162 }
163
164 protected void RunEnscriptServer()
165 {
166 string code;
167 m_EnfScriptEdit.GetText(code);
169 m_ModuleLocalEnscriptHistoryServer.AddNewLine(code);
171 GetGame().RPCSingleParam(GetGame().GetPlayer(), ERPCs.DEV_RPC_SERVER_SCRIPT, CachedObjectsParams.PARAM1_STRING, true, GetGame().GetPlayer().GetIdentity());
172 }
173
174 protected void EnscriptHistoryBack()
175 {
176 int history_index;
177 if (m_EnfScriptEdit)
178 {
180 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
181 if (history_index > -1)
182 {
183 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
184 }
186 }
187 }
188
189
190 protected void EnscriptHistoryForward()
191 {
192 if (m_EnfScriptEdit)
193 {
194 int history_index;
196 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
197 if (history_index < m_EnscriptConsoleHistory.Count())
198 {
199 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
200 }
202 }
203 }
204
205 override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
206 {
207 super.OnRPCEx(rpc_type, ctx);
208 #ifdef DIAG_DEVELOPER
209 switch (rpc_type)
210 {
211 case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
212 {
214 {
216 }
217 break;
218 }
219 }
220 #endif
221 }
222
223 override bool OnClick(Widget w, int x, int y, int button)
224 {
225 super.OnClick(w,x,y,button);
226 if (w == m_EnfScriptRun)
227 {
228 RunEnscript();
229 return true;
230 }
231 else if (w == m_EnfScriptClear)
232 {
233 m_ScriptOutputListbox.ClearItems();
234 m_ScriptOutputHistory.Clear();
235 return true;
236 }
237
238 return false;
239 }
240
241 override bool OnChange(Widget w, int x, int y, bool finished)
242 {
243 super.OnChange(w, x, y, finished);
244 return false;
245 }
246
247
248 override void Show(bool show, ScriptConsoleTabBase selectedHandler)
249 {
250 if (!show && (selectedHandler.Type() == ScriptConsoleEnfScriptTab || selectedHandler.Type() == ScriptConsoleEnfScriptServerTab))
251 {
252 //do nothing
253 }
254 else
255 {
256 m_Root.Show(show);
257 m_Root.Enable(show);
258 }
259 }
260
261}
262
263class ScriptConsoleEnfScriptServerTab : ScriptConsoleEnfScriptTab
264{
265 override void OnSelected()
268 if (m_EnscriptConsoleHistoryServer.IsValidIndex(index))
270 string text = m_EnscriptConsoleHistoryServer.Get(index);
271 m_EnfScriptEdit.SetText(text);
276 override protected void EnscriptHistoryBack()
278 int history_index;
279 if (m_EnfScriptEdit)
283 if (history_index > -1)
284 {
285 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
286 }
288 }
289 }
290
291 override protected void EnscriptHistoryForward()
292 {
293 if (m_EnfScriptEdit)
294 {
295 int history_index;
299 if (history_index < m_EnscriptConsoleHistoryServer.Count())
300 {
301 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
302 }
304 }
305 }
306
307 override bool OnClick(Widget w, int x, int y, int button)
308 {
309 if (w == m_EnfScriptRun)
310 {
312 return true;
313 }
314 else if (w == m_EnfScriptClear)
315 {
316 m_ScriptOutputListbox.ClearItems();
317 m_ScriptOutputHistory.Clear();
318 return true;
320
321 return false;
322 }
323
ERPCs
Определения ERPCs.c:2
Empty
Определения Hand_States.c:14
Icon x
Icon y
PlayerBase GetPlayer()
Определения ModifierBase.c:51
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
PlayerBase _player
Определения QuickBarBase.c:18
ref TStringArray m_EnscriptConsoleHistoryServer
Определения ScriptConsoleEnfScriptTab.c:270
int m_EnscriptHistoryRowServer
Определения ScriptConsoleEnfScriptTab.c:268
ButtonWidget m_EnfScriptClear
Определения ScriptConsoleEnfScriptTab.c:275
TextListboxWidget m_ScriptOutputListbox
Определения ScriptConsoleEnfScriptTab.c:276
static ref TStringArray m_ScriptOutputHistory
Определения ScriptConsoleEnfScriptTab.c:280
ButtonWidget m_EnfScriptRun
Определения ScriptConsoleEnfScriptTab.c:274
MultilineEditBoxWidget m_EnfScriptEdit
Определения ScriptConsoleEnfScriptTab.c:273
proto native void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native bool ExecuteEnforceScript(string expression, string mainFnName)
Delevoper only: Executes Enforce Script expression, if there is an error, is printed into the script ...
static ref Param1< bool > PARAM1_BOOL
Определения UtilityClasses.c:12
static ref Param1< string > PARAM1_STRING
Определения UtilityClasses.c:14
static void ClearLogs()
Определения Debug.c:557
Определения Debug.c:2
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
static void PrintS(bool message)
Определения ScriptConsoleEnfScriptTab.c:56
override bool OnChange(Widget w, int x, int y, bool finished)
Определения ScriptConsoleEnfScriptTab.c:241
override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
Определения ScriptConsoleEnfScriptTab.c:205
PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer
Определения ScriptConsoleEnfScriptTab.c:9
static void PrintS(string message)
Определения ScriptConsoleEnfScriptTab.c:49
static ScriptConsoleEnfScriptTab m_Instance
Определения ScriptConsoleEnfScriptTab.c:3
static void PrintS(float message)
Определения ScriptConsoleEnfScriptTab.c:66
void ~ScriptConsoleEnfScriptTab()
Определения ScriptConsoleEnfScriptTab.c:33
void Clear(bool clearFile=false)
Определения ScriptConsoleEnfScriptTab.c:96
static ref TStringArray m_ScriptOutputHistory
Определения ScriptConsoleEnfScriptTab.c:17
MultilineEditBoxWidget m_EnfScriptEdit
Определения ScriptConsoleEnfScriptTab.c:10
override void OnSelected()
Определения ScriptConsoleEnfScriptTab.c:38
void ColorRunButton(bool success)
Определения ScriptConsoleEnfScriptTab.c:146
ref TStringArray m_EnscriptConsoleHistoryServer
Определения ScriptConsoleEnfScriptTab.c:7
ref TStringArray m_EnscriptConsoleHistory
Определения ScriptConsoleEnfScriptTab.c:6
ButtonWidget m_EnfScriptClear
Определения ScriptConsoleEnfScriptTab.c:12
override bool OnClick(Widget w, int x, int y, int button)
Определения ScriptConsoleEnfScriptTab.c:223
void ScriptConsoleEnfScriptTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleEnfScriptTab.c:19
void Add(string message, bool isReload=false)
Определения ScriptConsoleEnfScriptTab.c:82
ButtonWidget m_EnfScriptRun
Определения ScriptConsoleEnfScriptTab.c:11
TextListboxWidget m_ScriptOutputListbox
Определения ScriptConsoleEnfScriptTab.c:13
static void PrintS(vector message)
Определения ScriptConsoleEnfScriptTab.c:71
PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory
Определения ScriptConsoleEnfScriptTab.c:8
static void PrintS(Object message)
Определения ScriptConsoleEnfScriptTab.c:76
override void Show(bool show, ScriptConsoleTabBase selectedHandler)
Определения ScriptConsoleEnfScriptTab.c:248
static void PrintS(int message)
Определения ScriptConsoleEnfScriptTab.c:61
void ScriptConsoleTabBase(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleTabBase.c:14
Widget m_Root
Определения ScriptConsoleTabBase.c:7
proto bool Read(void value_in)
Определения EnWidgets.c:190
string ToString()
Определения EnConvert.c:3
proto string ToString(bool simple=true)
proto string ToString(bool beautify=true)
Vector to string.
Определения EnConvert.c:106
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
array< string > TStringArray
Определения EnScript.c:685
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
Определения EnScript.c:339
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8
WorkspaceWidget Widget
Defined in code.
int ARGB(int a, int r, int g, int b)
Определения proto.c:322