Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
scriptconsoleoutputtab.c
Go to the documentation of this file.
2 {
3  protected TextListboxWidget m_ClientLogListbox;
4  protected ButtonWidget m_ClientLogClearButton;
5  protected CheckBoxWidget m_ClientLogScrollCheckbox;
6 
7  void ScriptConsoleOutputTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
8  {
9  m_ClientLogListbox = TextListboxWidget.Cast(root.FindAnyWidget("TextListbox"));
10  m_ClientLogClearButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonClear"));
11  m_ClientLogScrollCheckbox = CheckBoxWidget.Cast(root.FindAnyWidget("CheckBoxAutoScroll"));
12  ReloadOutput();
13  }
14 
16  {
17  }
18 
19  override bool OnClick(Widget w, int x, int y, int button)
20  {
21  super.OnClick(w,x,y,button);
22 
23  if (w == m_ClientLogClearButton)
24  {
25  Clear(true);
26  return true;
27  }
28  return false;
29  }
30 
31  override bool OnChange(Widget w, int x, int y, bool finished)
32  {
33  super.OnChange(w, x, y, finished);
34  return false;
35  }
36 
37 
38  protected void Clear(bool clearFile = false)
39  {
40  if(clearFile)
41  Debug.ClearLogs();
42  m_ClientLogListbox.ClearItems();
43  }
44 
45  protected void Add(string message, bool isReload = false)
46  {
47  if (m_ClientLogListbox)
48  {
49  m_ClientLogListbox.AddItem(String(message), NULL, 0);
50 
51  if (m_ClientLogScrollCheckbox.IsChecked())
52  {
53  m_ClientLogListbox.EnsureVisible(m_ClientLogListbox.GetNumItems());
54  }
55  }
56  }
57 
58  protected void ReloadOutput()
59  {
60  Clear();
61  FileHandle file_index = OpenFile(Debug.GetFileName(), FileMode.READ);
62 
63  if ( file_index )
64  {
65  string line_content;
66  while ( FGets( file_index, line_content ) != -1 )
67  {
68  Add(line_content, true);
69  }
70 
71  CloseFile(file_index);
72  }
73  }
74 
75 }
CloseFile
proto void CloseFile(FileHandle file)
Close the File.
OpenFile
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
ScriptConsoleOutputTab
Definition: scriptconsoleoutputtab.c:1
String
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
Definition: enscript.c:339
y
Icon y
FileMode
FileMode
Definition: ensystem.c:382
FGets
proto int FGets(FileHandle file, string var)
Get line from file, every next call of this function returns next line.
x
Icon x
Debug
Definition: debug.c:13
FileHandle
int[] FileHandle
Definition: ensystem.c:390
Widget
Definition: enwidgets.c:189
ScriptConsoleTabBase
Definition: scriptconsoletabbase.c:1