DayZ 1.30
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 override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
20 {
21 super.InitializeTab(root, console, button, parent);
22
23 m_Instance = this;
24 m_ModuleLocalEnscriptHistory = PluginLocalEnscriptHistory.Cast(GetPlugin(PluginLocalEnscriptHistory));
25 m_ModuleLocalEnscriptHistoryServer = PluginLocalEnscriptHistoryServer.Cast(GetPlugin(PluginLocalEnscriptHistoryServer));
28 m_EnfScriptEdit = MultilineEditBoxWidget.Cast(root.FindAnyWidget("MultilineEditBoxWidget0"));
29 m_EnfScriptRun = ButtonWidget.Cast(root.FindAnyWidget("RunButton"));
30 m_EnfScriptClear = ButtonWidget.Cast(root.FindAnyWidget("ClearButton"));
31 m_ScriptOutputListbox = TextListboxWidget.Cast(root.FindAnyWidget("ScriptOutputListbox"));
32 m_RunColor = m_EnfScriptRun.GetColor();
33 }
34
36 {
37 m_Instance = null;
38 }
39
40 override void OnSelected()
41 {
42 int index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
43 if (m_EnscriptConsoleHistory.IsValidIndex(index))
44 {
45 string text = m_EnscriptConsoleHistory.Get(index);
46 m_EnfScriptEdit.SetText(text);
47 }
49 }
50
51 static void PrintS(string message)
52 {
53 Print(message);
54 if (m_Instance)
55 m_Instance.Add(message);
56 }
57
58 static void PrintS(bool message)
59 {
60 PrintS(message.ToString());
61 }
62
63 static void PrintS(int message)
64 {
65 PrintS(message.ToString());
66 }
67
68 static void PrintS(float message)
69 {
70 PrintS(message.ToString());
71 }
72
73 static void PrintS(vector message)
74 {
75 PrintS(message.ToString());
76 }
77
78 static void PrintS(Object message)
79 {
80 PrintS(message.ToString());
81 }
82
83
84 void Add(string message, bool isReload = false)
85 {
86 if (message != string.Empty)
87 {
89 {
90 if (!isReload)
91 m_ScriptOutputHistory.Insert(message);
92 m_ScriptOutputListbox.AddItem(String(message), NULL, 0);
93 m_ScriptOutputListbox.EnsureVisible(m_ScriptOutputListbox.GetNumItems());
94 }
95 }
96 }
97
98 protected void Clear(bool clearFile = false)
99 {
100 if(clearFile)
102 m_ScriptOutputListbox.ClearItems();
103 }
104
105
106
107 protected void ReloadScriptOutput()
108 {
109 m_ScriptOutputListbox.ClearItems();
110 m_AllowScriptOutput = true;
111 foreach ( string s: m_ScriptOutputHistory)
112 {
113 Add(s, true);
114 }
115 m_AllowScriptOutput = false;
116 }
117
119 {
120
122 }
123
125 {
127 }
128
129 protected void RunEnscript()
130 {
131 #ifdef DEVELOPER
132 string code;
133 m_EnfScriptEdit.GetText(code);
134 string codeNoReplace = code;
135 _player = PlayerBase.Cast(g_Game.GetPlayer());
136 m_AllowScriptOutput = true;
137 code.Replace("Print(","ScriptConsoleEnfScriptTab.PrintS(");
138 code.Replace("Print (","ScriptConsoleEnfScriptTab.PrintS(");
139 bool success = g_Game.ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
140 m_AllowScriptOutput = false;
141 ColorRunButton(success);
142
143 m_EnscriptConsoleHistory.Insert(codeNoReplace);
144 m_ModuleLocalEnscriptHistory.AddNewLine(codeNoReplace);
145 #endif
146 }
147
148 protected void ColorRunButton(bool success)
149 {
150 if (success)
151 {
152 m_EnfScriptRun.SetColor(ARGB(255,0,255,0));
153 }
154 else
155 {
156 m_EnfScriptRun.SetColor(ARGB(255,255,0,0));
157 }
158 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ResetRunButtonColor,600);
159 }
160
161 protected void ResetRunButtonColor()
162 {
163 m_EnfScriptRun.SetColor(m_RunColor);
164 }
165
166 protected void RunEnscriptServer()
167 {
168 string code;
169 m_EnfScriptEdit.GetText(code);
171 m_ModuleLocalEnscriptHistoryServer.AddNewLine(code);
173 g_Game.RPCSingleParam(g_Game.GetPlayer(), ERPCs.DEV_RPC_SERVER_SCRIPT, CachedObjectsParams.PARAM1_STRING, true, g_Game.GetPlayer().GetIdentity());
174 }
175
176 protected void EnscriptHistoryBack()
177 {
178 int history_index;
179 if (m_EnfScriptEdit)
180 {
182 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
183 if (history_index > -1)
184 {
185 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
186 }
188 }
189 }
190
191
192 protected void EnscriptHistoryForward()
193 {
194 if (m_EnfScriptEdit)
195 {
196 int history_index;
198 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
199 if (history_index < m_EnscriptConsoleHistory.Count())
200 {
201 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
202 }
204 }
205 }
206
207 override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
208 {
209 super.OnRPCEx(rpc_type, ctx);
210 #ifdef DIAG_DEVELOPER
211 switch (rpc_type)
212 {
213 case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
214 {
216 {
218 }
219 break;
220 }
221 }
222 #endif
223 }
224
225 override bool OnClick(Widget w, int x, int y, int button)
226 {
227 super.OnClick(w,x,y,button);
228 if (w == m_EnfScriptRun)
229 {
230 RunEnscript();
231 return true;
232 }
233 else if (w == m_EnfScriptClear)
234 {
235 m_ScriptOutputListbox.ClearItems();
236 m_ScriptOutputHistory.Clear();
237 return true;
238 }
239
240 return false;
241 }
242
243 override bool OnChange(Widget w, int x, int y, bool finished)
244 {
245 super.OnChange(w, x, y, finished);
246 return false;
247 }
248
249
250 override void Show(bool show, ScriptConsoleTabBase selectedHandler)
251 {
252 if (!show && (selectedHandler.Type() == ScriptConsoleEnfScriptTab || selectedHandler.Type() == ScriptConsoleEnfScriptServerTab))
253 {
254 //do nothing
255 }
256 else
257 {
258 m_Root.Show(show);
259 m_Root.Enable(show);
260 }
261 }
262
263}
264
265class ScriptConsoleEnfScriptServerTab : ScriptConsoleEnfScriptTab
266{
267 override void OnSelected()
272 if (m_EnscriptConsoleHistoryServer.IsValidIndex(index))
274 string text = m_EnscriptConsoleHistoryServer.Get(index);
275 m_EnfScriptEdit.SetText(text);
280 override protected void EnscriptHistoryBack()
281 {
282 int history_index;
283 if (m_EnfScriptEdit)
287 if (history_index > -1)
288 {
289 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
290 }
292 }
293 }
294
295 override protected void EnscriptHistoryForward()
296 {
297 if (m_EnfScriptEdit)
298 {
299 int history_index;
303 if (history_index < m_EnscriptConsoleHistoryServer.Count())
304 {
305 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
306 }
308 }
309 }
310
311 override bool OnClick(Widget w, int x, int y, int button)
312 {
313 if (w == m_EnfScriptRun)
314 {
316 return true;
317 }
318 else if (w == m_EnfScriptClear)
319 {
320 m_ScriptOutputListbox.ClearItems();
321 m_ScriptOutputHistory.Clear();
322 return true;
324
325 return false;
326 }
327}
DayZGame g_Game
Определения DayZGame.c:4074
ERPCs
Определения ERPCs.c:2
Empty
Определения Hand_States.c:14
Icon x
Icon y
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
PlayerBase _player
Определения QuickBarBase.c:18
void ScriptConsole()
Определения ScriptConsole.c:114
ref TStringArray m_EnscriptConsoleHistoryServer
Определения ScriptConsoleEnfScriptTab.c:272
int m_EnscriptHistoryRowServer
Определения ScriptConsoleEnfScriptTab.c:270
ButtonWidget m_EnfScriptClear
Определения ScriptConsoleEnfScriptTab.c:277
TextListboxWidget m_ScriptOutputListbox
Определения ScriptConsoleEnfScriptTab.c:278
static ref TStringArray m_ScriptOutputHistory
Определения ScriptConsoleEnfScriptTab.c:282
ButtonWidget m_EnfScriptRun
Определения ScriptConsoleEnfScriptTab.c:276
MultilineEditBoxWidget m_EnfScriptEdit
Определения ScriptConsoleEnfScriptTab.c:275
static ref Param1< bool > PARAM1_BOOL
Определения UtilityClasses.c:12
static ref Param1< string > PARAM1_STRING
Определения UtilityClasses.c:14
static void ClearLogs()
Определения 3_Game/DayZ/tools/Debug.c:666
Определения 3_Game/DayZ/tools/Debug.c:2
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
static void PrintS(bool message)
Определения ScriptConsoleEnfScriptTab.c:58
override bool OnChange(Widget w, int x, int y, bool finished)
Определения ScriptConsoleEnfScriptTab.c:243
override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
Определения ScriptConsoleEnfScriptTab.c:207
PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer
Определения ScriptConsoleEnfScriptTab.c:9
static void PrintS(string message)
Определения ScriptConsoleEnfScriptTab.c:51
static ScriptConsoleEnfScriptTab m_Instance
Определения ScriptConsoleEnfScriptTab.c:3
static void PrintS(float message)
Определения ScriptConsoleEnfScriptTab.c:68
void ~ScriptConsoleEnfScriptTab()
Определения ScriptConsoleEnfScriptTab.c:35
void Clear(bool clearFile=false)
Определения ScriptConsoleEnfScriptTab.c:98
static ref TStringArray m_ScriptOutputHistory
Определения ScriptConsoleEnfScriptTab.c:17
override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleEnfScriptTab.c:19
MultilineEditBoxWidget m_EnfScriptEdit
Определения ScriptConsoleEnfScriptTab.c:10
override void OnSelected()
Определения ScriptConsoleEnfScriptTab.c:40
void ColorRunButton(bool success)
Определения ScriptConsoleEnfScriptTab.c:148
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:225
void Add(string message, bool isReload=false)
Определения ScriptConsoleEnfScriptTab.c:84
ButtonWidget m_EnfScriptRun
Определения ScriptConsoleEnfScriptTab.c:11
TextListboxWidget m_ScriptOutputListbox
Определения ScriptConsoleEnfScriptTab.c:13
static void PrintS(vector message)
Определения ScriptConsoleEnfScriptTab.c:73
PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory
Определения ScriptConsoleEnfScriptTab.c:8
static void PrintS(Object message)
Определения ScriptConsoleEnfScriptTab.c:78
override void Show(bool show, ScriptConsoleTabBase selectedHandler)
Определения ScriptConsoleEnfScriptTab.c:250
static void PrintS(int message)
Определения ScriptConsoleEnfScriptTab.c:63
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:119
Serializer ParamsReadContext
Определения gameplay.c:15
proto void Print(void var)
Prints content of variable to console/log.
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
Определения EnScript.c:339
class array< Class T > TStringArray
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native void SetFocus(Widget w)
WorkspaceWidget Widget
Defined in code.
int ARGB(int a, int r, int g, int b)
Определения proto.c:322