DayZ 1.24
Loading...
Searching...
No Matches
NoteMenu.c
Go to the documentation of this file.
1class NoteMenu extends UIScriptedMenu
2{
4 protected HtmlWidget m_html;
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 hud.ShowHudUI(false);
21 }
22 }
23
24 void ~NoteMenu()
25 {
26 MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
27 if (mission)
28 {
29 IngameHud hud = IngameHud.Cast(mission.GetHud());
30 if (hud)
31 hud.ShowHudUI(true);
32 }
33 }
34
35 override void InitNoteRead(string text = "")
36 {
37 m_IsWriting = false;
38
39 if (m_edit)
40 m_edit.Show(false);
41
42 if (m_html)
43 {
44 //TODO add text formating here. Just text string for now
45 if (text)
46 {
47 m_html.Show(true);
48 m_html.SetText(text);
49 m_SymbolCount = text.Length(); //string.LengthUtf8() ?
50 //m_html.SetText("<html><body><p>" + text + "</p></body></html>");
51 }
52 }
53 m_confirm_button.Show(false);
54 }
55
56 override void InitNoteWrite(EntityAI paper, EntityAI pen, string text = "")
57 {
58 m_IsWriting = true;
59
60 if (m_edit)
61 {
62 m_Paper = ItemBase.Cast(paper);
63 m_Pen = pen;
64 m_PenColor = m_Pen.ConfigGetString("writingColor");
65 if (m_PenColor == "")
66 m_PenColor = "#000000";
67 //m_Handwriting = handwriting;
68
69 m_edit.Show(true);
70 m_edit.SetText(text);
71 }
72
73 if (m_html)
74 m_html.Show(false);
75 m_confirm_button.Show(true);
76 }
77
78 override Widget Init()
79 {
80 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_inventory_note.layout");
81 m_edit = MultilineEditBoxWidget.Cast(layoutRoot.FindAnyWidget("EditWidget"));
82 m_html = HtmlWidget.Cast(layoutRoot.FindAnyWidget("HtmlWidget"));
83 m_confirm_button = ButtonWidget.Cast(layoutRoot.FindAnyWidgetById(IDC_OK));
84
85 return layoutRoot;
86 }
87
88 override bool OnClick(Widget w, int x, int y, int button)
89 {
90 super.OnClick(w, x, y, button);
91
92 /* string txt;
93 m_edit.GetText(txt);
94 Print(m_edit.GetLinesCount());
95 Print(txt);
96 Print(txt.Length());*/
97
98 switch (w.GetUserID())
99 {
100 case IDC_CANCEL:
101 Close();
102 return true;
103 case IDC_OK:
104 if (m_Paper && m_Pen && m_IsWriting)
105 {
106 string edit_text;
107 m_edit.GetText(edit_text);
108 edit_text = MiscGameplayFunctions.SanitizeString(edit_text);
109 // Print("edit_text: " + edit_text);
111 m_Paper.RPCSingleParam(ERPCs.RPC_WRITE_NOTE_CLIENT, text, true);
112 }
113 Close();
114 return true;
115 }
116
117 return false;
118 }
119
120 override void Update(float timeslice)
121 {
122 super.Update(timeslice);
123
124 if (GetGame() && GetUApi().GetInputByID(UAUIBack).LocalPress())
125 Close();
126 }
127}
Mission mission
ERPCs
Definition ERPCs.c:2
Icon x
Icon y
void Close()
proto native UAInputAPI GetUApi()
Hud GetHud()
Definition gameplay.c:701
int m_SymbolCount
Definition NoteMenu.c:10
void NoteMenu()
Definition NoteMenu.c:13
override void Update(float timeslice)
Definition NoteMenu.c:120
ButtonWidget m_confirm_button
Definition NoteMenu.c:5
EntityAI m_Pen
Definition NoteMenu.c:7
void ~NoteMenu()
Definition NoteMenu.c:24
bool m_IsWriting
Definition NoteMenu.c:8
override void InitNoteRead(string text="")
Definition NoteMenu.c:35
MultilineEditBoxWidget m_edit
Definition NoteMenu.c:3
override Widget Init()
Definition NoteMenu.c:78
ItemBase m_Paper
Definition NoteMenu.c:6
override bool OnClick(Widget w, int x, int y, int button)
Definition NoteMenu.c:88
override void InitNoteWrite(EntityAI paper, EntityAI pen, string text="")
Definition NoteMenu.c:56
string m_PenColor
Definition NoteMenu.c:11
HtmlWidget m_html
Definition NoteMenu.c:4
proto native CGame GetGame()
const int IDC_CANCEL
Definition constants.c:128
const int IDC_OK
Definition constants.c:127