1818#include " UIDragDropReferenceList.h"
1919#include " xrUICore/EditBox/UIEditBox.h"
2020
21- CUIStatic* UIHelper::CreateStatic (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
21+ CUIStatic* UIHelper::CreateStatic (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
2222{
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+
2327 auto ui = new CUIStatic ();
2428 if (parent)
2529 {
@@ -30,8 +34,12 @@ CUIStatic* UIHelper::CreateStatic(CUIXml& xml, LPCSTR ui_path, CUIWindow* parent
3034 return ui;
3135}
3236
33- CUITextWnd* UIHelper::CreateTextWnd (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
37+ CUITextWnd* UIHelper::CreateTextWnd (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
3438{
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+
3543 auto ui = new CUITextWnd ();
3644 if (parent)
3745 {
@@ -42,8 +50,12 @@ CUITextWnd* UIHelper::CreateTextWnd(CUIXml& xml, LPCSTR ui_path, CUIWindow* pare
4250 return ui;
4351}
4452
45- CUIEditBox* UIHelper::CreateEditBox (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
53+ CUIEditBox* UIHelper::CreateEditBox (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
4654{
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+
4759 auto ui = new CUIEditBox ();
4860 if (parent)
4961 {
@@ -54,17 +66,25 @@ CUIEditBox* UIHelper::CreateEditBox(CUIXml& xml, LPCSTR ui_path, CUIWindow* pare
5466 return ui;
5567}
5668
57- CUIProgressBar* UIHelper::CreateProgressBar (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
69+ CUIProgressBar* UIHelper::CreateProgressBar (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
5870{
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+
5975 auto ui = new CUIProgressBar ();
6076 parent->AttachChild (ui);
6177 ui->SetAutoDelete (true );
6278 CUIXmlInit::InitProgressBar (xml, ui_path, 0 , ui);
6379 return ui;
6480}
6581
66- CUIFrameLineWnd* UIHelper::CreateFrameLine (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
82+ CUIFrameLineWnd* UIHelper::CreateFrameLine (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
6783{
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+
6888 auto ui = new CUIFrameLineWnd ();
6989 if (parent)
7090 {
@@ -75,8 +95,12 @@ CUIFrameLineWnd* UIHelper::CreateFrameLine(CUIXml& xml, LPCSTR ui_path, CUIWindo
7595 return ui;
7696}
7797
78- CUIFrameWindow* UIHelper::CreateFrameWindow (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
98+ CUIFrameWindow* UIHelper::CreateFrameWindow (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
7999{
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+
80104 auto ui = new CUIFrameWindow ();
81105 if (parent)
82106 {
@@ -87,43 +111,63 @@ CUIFrameWindow* UIHelper::CreateFrameWindow(CUIXml& xml, LPCSTR ui_path, CUIWind
87111 return ui;
88112}
89113
90- CUI3tButton* UIHelper::Create3tButton (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
114+ CUI3tButton* UIHelper::Create3tButton (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
91115{
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+
92120 auto ui = new CUI3tButton ();
93121 parent->AttachChild (ui);
94122 ui->SetAutoDelete (true );
95123 CUIXmlInit::Init3tButton (xml, ui_path, 0 , ui);
96124 return ui;
97125}
98126
99- CUICheckButton* UIHelper::CreateCheck (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
127+ CUICheckButton* UIHelper::CreateCheck (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
100128{
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+
101133 auto ui = new CUICheckButton ();
102134 parent->AttachChild (ui);
103135 ui->SetAutoDelete (true );
104136 CUIXmlInit::InitCheck (xml, ui_path, 0 , ui);
105137 return ui;
106138}
107139
108- UIHint* UIHelper::CreateHint (CUIXml& xml, LPCSTR ui_path)
140+ UIHint* UIHelper::CreateHint (CUIXml& xml, LPCSTR ui_path /* , CUIWindow* parent */ , bool critical )
109141{
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+
110146 auto ui = new UIHint ();
111147 ui->SetAutoDelete (true );
112148 ui->init_from_xml (xml, ui_path);
113149 return ui;
114150}
115151
116- CUIDragDropListEx* UIHelper::CreateDragDropListEx (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
152+ CUIDragDropListEx* UIHelper::CreateDragDropListEx (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
117153{
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+
118158 auto ui = new CUIDragDropListEx ();
119159 parent->AttachChild (ui);
120160 ui->SetAutoDelete (true );
121161 CUIXmlInit::InitDragDropListEx (xml, ui_path, 0 , ui);
122162 return ui;
123163}
124164
125- CUIDragDropReferenceList* UIHelper::CreateDragDropReferenceList (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent)
165+ CUIDragDropReferenceList* UIHelper::CreateDragDropReferenceList (CUIXml& xml, LPCSTR ui_path, CUIWindow* parent, bool critical )
126166{
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+
127171 auto ui = new CUIDragDropReferenceList ();
128172 parent->AttachChild (ui);
129173 ui->SetAutoDelete (true );
0 commit comments