Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
notemenu.c
Go to the documentation of this file.
1 class NoteMenu extends UIScriptedMenu
2 {
3  protected MultilineEditBoxWidget m_edit;
4  protected HtmlWidget m_html;
5  protected ButtonWidget m_confirm_button;
6  protected ItemBase m_Paper;
7  protected EntityAI m_Pen;
8  protected bool m_IsWriting;
9  //protected int m_Handwriting;
10  protected int m_SymbolCount;
11  protected string m_PenColor; //color in hex-code format, transferred as string. Could be transferred as int or array<int, bool>?
12 
13  void NoteMenu()
14  {
15  MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
16  if (mission)
17  {
18  IngameHud hud = IngameHud.Cast(mission.GetHud());
19  if (hud)
20  {
21  hud.ShowHudUI(false);
22  }
23  }
24  }
25 
26  void ~NoteMenu()
27  {
28  MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
29  if (mission)
30  {
31  IngameHud hud = IngameHud.Cast(mission.GetHud());
32  if (hud)
33  {
34  hud.ShowHudUI(true);
35  }
36  }
37  }
38 
39  override void InitNoteRead(string text = "")
40  {
41  m_IsWriting = false;
42 
43  if (m_edit)
44  {
45  m_edit.Show(false);
46  }
47 
48  if (m_html)
49  {
50  //TODO add text formating here. Just text string for now
51  if (text)
52  {
53  m_html.Show(true);
54  m_html.SetText(text);
55  m_SymbolCount = text.Length(); //string.LengthUtf8() ?
56  //m_html.SetText("<html><body><p>" + text + "</p></body></html>");
57  }
58  }
59  m_confirm_button.Show(false);
60  }
61 
62  override void InitNoteWrite(EntityAI paper, EntityAI pen, string text = "")
63  {
64  m_IsWriting = true;
65 
66  if (m_edit)
67  {
68  m_Paper = ItemBase.Cast(paper);
69  m_Pen = pen;
70  m_PenColor = m_Pen.ConfigGetString("writingColor");
71  if (m_PenColor == "")
72  {
73  m_PenColor = "#000000";
74  }
75  //m_Handwriting = handwriting;
76 
77  m_edit.Show(true);
78  m_edit.SetText(text);
79  }
80 
81  if (m_html)
82  {
83  m_html.Show(false);
84  }
85  m_confirm_button.Show(true);
86  }
87 
88  override Widget Init()
89  {
90  layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_inventory_note.layout");
91  m_edit = MultilineEditBoxWidget.Cast(layoutRoot.FindAnyWidget("EditWidget"));
92  m_html = HtmlWidget.Cast(layoutRoot.FindAnyWidget("HtmlWidget"));
93  m_confirm_button = ButtonWidget.Cast(layoutRoot.FindAnyWidgetById(IDC_OK));
94 
95  return layoutRoot;
96  }
97 
98  override bool OnClick(Widget w, int x, int y, int button)
99  {
100  super.OnClick(w, x, y, button);
101 
102  /* string txt;
103  m_edit.GetText(txt);
104  Print(m_edit.GetLinesCount());
105  Print(txt);
106  Print(txt.Length());*/
107 
108  switch (w.GetUserID())
109  {
110  case IDC_CANCEL:
111  Close();
112  return true;
113  case IDC_OK:
114  if (m_Paper && m_Pen && m_IsWriting)
115  {
116  string edit_text;
117  m_edit.GetText(edit_text);
118  edit_text = MiscGameplayFunctions.SanitizeString(edit_text);
119  // Print("edit_text: " + edit_text);
120  Param1<string> text = new Param1<string>(edit_text);
121  m_Paper.RPCSingleParam(ERPCs.RPC_WRITE_NOTE_CLIENT, text, true);
122  }
123  Close();
124  return true;
125  }
126 
127  return false;
128  }
129 
130  override void Update(float timeslice)
131  {
132  super.Update(timeslice);
133 
134  if (GetGame() && GetUApi().GetInputByID(UAUIBack).LocalPress())
135  {
136  Close();
137  }
138  }
139 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
mission
Mission mission
Definition: displaystatus.c:28
IDC_CANCEL
const int IDC_CANCEL
Definition: constants.c:128
Close
void Close()
y
Icon y
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
x
Icon x
IDC_OK
const int IDC_OK
Definition: constants.c:127
ERPCs
ERPCs
Definition: erpcs.c:1
Widget
Definition: enwidgets.c:189
GetUApi
proto native UAInputAPI GetUApi()
OnClick
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition: dayzgame.c:146
EntityAI
Definition: building.c:5