From b7b3401b56138545d04207932e5380c12943e999 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Tue, 25 Sep 2018 19:11:17 +0500 Subject: [PATCH] xrGame/ui/UILoadingScreen: robust loading screen. It will exist even if there's no XML file for it. --- src/xrGame/ui/UILoadingScreen.cpp | 11 +++- src/xrGame/ui/UILoadingScreenHardcoded.h | 80 ++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/xrGame/ui/UILoadingScreenHardcoded.h diff --git a/src/xrGame/ui/UILoadingScreen.cpp b/src/xrGame/ui/UILoadingScreen.cpp index e2cb466bd27..09aeedf0414 100644 --- a/src/xrGame/ui/UILoadingScreen.cpp +++ b/src/xrGame/ui/UILoadingScreen.cpp @@ -9,6 +9,7 @@ #include "StdAfx.h" #include "UILoadingScreen.h" +#include "UILoadingScreenHardcoded.h" #include "xrEngine/x_ray.h" #include "xrEngine/GameFont.h" @@ -27,7 +28,15 @@ UILoadingScreen::UILoadingScreen() void UILoadingScreen::Initialize() { CUIXml uiXml; - uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_mm_loading_screen.xml"); + bool result = uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_mm_loading_screen.xml"); + + if (!result) // Robustness? Yes! + { + if (UI().is_widescreen()) + uiXml.Set(LoadingScreenXML16x9); + else + uiXml.Set(LoadingScreenXML); + } loadingProgressBackground = UIHelper::CreateStatic(uiXml, "loading_progress_background", this); loadingProgress = UIHelper::CreateProgressBar(uiXml, "loading_progress", this); diff --git a/src/xrGame/ui/UILoadingScreenHardcoded.h b/src/xrGame/ui/UILoadingScreenHardcoded.h new file mode 100644 index 00000000000..f5944158e0d --- /dev/null +++ b/src/xrGame/ui/UILoadingScreenHardcoded.h @@ -0,0 +1,80 @@ +#pragma once + +constexpr pcstr LoadingScreenXML = +"\ + \ + \ + ui_mm_loading_screen\ + \ + \ + \ + \ + \ + ui_mm_loading_progress_bar\ + \ + \ + \ + ui_mm_loading_progress_bar\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +"; + +constexpr pcstr LoadingScreenXML16x9 = +"\ + \ + \ + ui_mm_loading_screen\ + \ + \ + ui_mm_loading_left_widepanel\ + \ + \ + ui_mm_loading_right_widepanel\ + \ + \ + \ + \ + ui_mm_loading_progress_bar\ + \ + \ + \ + ui_mm_loading_progress_bar\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +";