Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
notemenu.c
Go to the documentation of this file.
1class 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}
int m_SymbolCount
Definition notemenu.c:10
void NoteMenu()
Definition notemenu.c:13
override void Update(float timeslice)
Definition notemenu.c:130
ButtonWidget m_confirm_button
Definition notemenu.c:5
EntityAI m_Pen
Definition notemenu.c:7
void ~NoteMenu()
Definition notemenu.c:26
bool m_IsWriting
Definition notemenu.c:8
override void InitNoteRead(string text="")
Definition notemenu.c:39
MultilineEditBoxWidget m_edit
Definition notemenu.c:3
override Widget Init()
Definition notemenu.c:88
ItemBase m_Paper
Definition notemenu.c:6
override bool OnClick(Widget w, int x, int y, int button)
Definition notemenu.c:98
override void InitNoteWrite(EntityAI paper, EntityAI pen, string text="")
Definition notemenu.c:62
string m_PenColor
Definition notemenu.c:11
HtmlWidget m_html
Definition notemenu.c:4
Mission mission
ERPCs
Definition erpcs.c:2
proto native CGame GetGame()
const int IDC_CANCEL
Definition constants.c:136
const int IDC_OK
Definition constants.c:135
Icon x
Icon y
void Close()
proto native UAInputAPI GetUApi()