18
18
#include " UIDragDropReferenceList.h"
19
19
#include " xrUICore/EditBox/UIEditBox.h"
20
20
21
- CUIStatic* UIHelper::CreateStatic (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
21
+ CUIStatic* UIHelper::CreateStatic (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
22
22
{
23
+ // If it's not critical element, then don't crash if it doesn't exist
24
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
25
+ return nullptr ;
26
+
23
27
auto ui = new CUIStatic ();
24
28
if (parent)
25
29
{
@@ -30,8 +34,12 @@ CUIStatic* UIHelper::CreateStatic(CUIXml& xml, LPCSTR ui_path, CUIWindow* parent
30
34
return ui;
31
35
}
32
36
33
- CUITextWnd* UIHelper::CreateTextWnd (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
37
+ CUITextWnd* UIHelper::CreateTextWnd (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
34
38
{
39
+ // If it's not critical element, then don't crash if it doesn't exist
40
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
41
+ return nullptr ;
42
+
35
43
auto ui = new CUITextWnd ();
36
44
if (parent)
37
45
{
@@ -42,8 +50,12 @@ CUITextWnd* UIHelper::CreateTextWnd(CUIXml& xml, LPCSTR ui_path, CUIWindow* pare
42
50
return ui;
43
51
}
44
52
45
- CUIEditBox* UIHelper::CreateEditBox (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
53
+ CUIEditBox* UIHelper::CreateEditBox (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
46
54
{
55
+ // If it's not critical element, then don't crash if it doesn't exist
56
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
57
+ return nullptr ;
58
+
47
59
auto ui = new CUIEditBox ();
48
60
if (parent)
49
61
{
@@ -54,17 +66,25 @@ CUIEditBox* UIHelper::CreateEditBox(CUIXml& xml, LPCSTR ui_path, CUIWindow* pare
54
66
return ui;
55
67
}
56
68
57
- CUIProgressBar* UIHelper::CreateProgressBar (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
69
+ CUIProgressBar* UIHelper::CreateProgressBar (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
58
70
{
71
+ // If it's not critical element, then don't crash if it doesn't exist
72
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
73
+ return nullptr ;
74
+
59
75
auto ui = new CUIProgressBar ();
60
76
parent->AttachChild (ui);
61
77
ui->SetAutoDelete (true );
62
78
CUIXmlInit::InitProgressBar (xml, ui_path, 0 , ui);
63
79
return ui;
64
80
}
65
81
66
- CUIFrameLineWnd* UIHelper::CreateFrameLine (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
82
+ CUIFrameLineWnd* UIHelper::CreateFrameLine (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
67
83
{
84
+ // If it's not critical element, then don't crash if it doesn't exist
85
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
86
+ return nullptr ;
87
+
68
88
auto ui = new CUIFrameLineWnd ();
69
89
if (parent)
70
90
{
@@ -75,8 +95,12 @@ CUIFrameLineWnd* UIHelper::CreateFrameLine(CUIXml& xml, LPCSTR ui_path, CUIWindo
75
95
return ui;
76
96
}
77
97
78
- CUIFrameWindow* UIHelper::CreateFrameWindow (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
98
+ CUIFrameWindow* UIHelper::CreateFrameWindow (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
79
99
{
100
+ // If it's not critical element, then don't crash if it doesn't exist
101
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
102
+ return nullptr ;
103
+
80
104
auto ui = new CUIFrameWindow ();
81
105
if (parent)
82
106
{
@@ -87,43 +111,63 @@ CUIFrameWindow* UIHelper::CreateFrameWindow(CUIXml& xml, LPCSTR ui_path, CUIWind
87
111
return ui;
88
112
}
89
113
90
- CUI3tButton* UIHelper::Create3tButton (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
114
+ CUI3tButton* UIHelper::Create3tButton (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
91
115
{
116
+ // If it's not critical element, then don't crash if it doesn't exist
117
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
118
+ return nullptr ;
119
+
92
120
auto ui = new CUI3tButton ();
93
121
parent->AttachChild (ui);
94
122
ui->SetAutoDelete (true );
95
123
CUIXmlInit::Init3tButton (xml, ui_path, 0 , ui);
96
124
return ui;
97
125
}
98
126
99
- CUICheckButton* UIHelper::CreateCheck (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
127
+ CUICheckButton* UIHelper::CreateCheck (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
100
128
{
129
+ // If it's not critical element, then don't crash if it doesn't exist
130
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
131
+ return nullptr ;
132
+
101
133
auto ui = new CUICheckButton ();
102
134
parent->AttachChild (ui);
103
135
ui->SetAutoDelete (true );
104
136
CUIXmlInit::InitCheck (xml, ui_path, 0 , ui);
105
137
return ui;
106
138
}
107
139
108
- UIHint* UIHelper::CreateHint (CUIXml& xml, LPCSTR ui_path)
140
+ UIHint* UIHelper::CreateHint (CUIXml& xml, LPCSTR ui_path /* , CUIWindow* parent */ , bool critical )
109
141
{
142
+ // If it's not critical element, then don't crash if it doesn't exist
143
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
144
+ return nullptr ;
145
+
110
146
auto ui = new UIHint ();
111
147
ui->SetAutoDelete (true );
112
148
ui->init_from_xml (xml, ui_path);
113
149
return ui;
114
150
}
115
151
116
- CUIDragDropListEx* UIHelper::CreateDragDropListEx (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
152
+ CUIDragDropListEx* UIHelper::CreateDragDropListEx (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
117
153
{
154
+ // If it's not critical element, then don't crash if it doesn't exist
155
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
156
+ return nullptr ;
157
+
118
158
auto ui = new CUIDragDropListEx ();
119
159
parent->AttachChild (ui);
120
160
ui->SetAutoDelete (true );
121
161
CUIXmlInit::InitDragDropListEx (xml, ui_path, 0 , ui);
122
162
return ui;
123
163
}
124
164
125
- CUIDragDropReferenceList* UIHelper::CreateDragDropReferenceList (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
165
+ CUIDragDropReferenceList* UIHelper::CreateDragDropReferenceList (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
126
166
{
167
+ // If it's not critical element, then don't crash if it doesn't exist
168
+ if (!critical && !xml.NavigateToNode (ui_path, 0 ))
169
+ return nullptr ;
170
+
127
171
auto ui = new CUIDragDropReferenceList ();
128
172
parent->AttachChild (ui);
129
173
ui->SetAutoDelete (true );
0 commit comments