diff --git a/src/xrEngine/main.cpp b/src/xrEngine/main.cpp
index acb6827208f..a45890d7a44 100644
--- a/src/xrEngine/main.cpp
+++ b/src/xrEngine/main.cpp
@@ -18,13 +18,13 @@
#include "Text_Console.h"
#include "xrSASH.h"
#include "xr_ioc_cmd.h"
+#include "splash.h"
#ifdef MASTER_GOLD
#define NO_MULTI_INSTANCES
#endif
// global variables
-ENGINE_API CApplication* pApp = nullptr;
ENGINE_API CInifile* pGameIni = nullptr;
ENGINE_API bool g_bBenchmark = false;
string512 g_sBenchmarkName;
@@ -34,8 +34,6 @@ ENGINE_API string_path g_sLaunchWorkingFolder;
namespace
{
-HWND logoWindow = nullptr;
-
void RunBenchmark(pcstr name);
}
@@ -166,6 +164,7 @@ ENGINE_API void Startup()
{
execUserScript();
InitSound();
+
// ...command line for auto start
pcstr startArgs = strstr(Core.Params, "-start ");
if (startArgs)
@@ -173,6 +172,7 @@ ENGINE_API void Startup()
pcstr loadArgs = strstr(Core.Params, "-load ");
if (loadArgs)
Console->Execute(loadArgs + 1);
+
// Initialize APP
Device.Create();
LALib.OnCreate();
@@ -183,12 +183,8 @@ ENGINE_API void Startup()
g_SpatialSpacePhysic = new ISpatial_DB("Spatial phys");
// Show main window and destroy splash
+ splash::hide();
ShowWindow(Device.m_hWnd, SW_SHOWNORMAL);
- if (logoWindow != nullptr)
- {
- DestroyWindow(logoWindow);
- logoWindow = nullptr;
- }
// Main cycle
Memory.mem_usage();
@@ -212,39 +208,8 @@ ENGINE_API void Startup()
destroySound();
}
-static INT_PTR CALLBACK LogoWndProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
-{
- switch (msg)
- {
- case WM_DESTROY: break;
- case WM_CLOSE: DestroyWindow(hw); break;
- case WM_COMMAND:
- if (LOWORD(wp) == IDCANCEL)
- DestroyWindow(hw);
- break;
- default: return false;
- }
- return true;
-}
-
ENGINE_API int RunApplication(pcstr commandLine)
{
- if (strstr(commandLine, "-nosplash") == 0)
- {
- logoWindow = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_STARTUP), nullptr, LogoWndProc);
- const HWND logoPicture = GetDlgItem(logoWindow, IDC_STATIC_LOGO);
- RECT logoRect;
- GetWindowRect(logoPicture, &logoRect);
-#ifndef DEBUG
- HWND prevWindow = (strstr(commandLine, "-splashnotop") == NULL) ? HWND_TOPMOST : HWND_NOTOPMOST;
-#else
- const HWND prevWindow = HWND_NOTOPMOST;
-#endif
- SetWindowPos(logoWindow, prevWindow, 0, 0, logoRect.right - logoRect.left, logoRect.bottom - logoRect.top,
- SWP_NOMOVE | SWP_SHOWWINDOW);
- UpdateWindow(logoWindow);
- }
-
if (!IsDebuggerPresent())
{
u32 heapFragmentation = 2;
diff --git a/src/xrEngine/splash.cpp b/src/xrEngine/splash.cpp
new file mode 100644
index 00000000000..99a92b431e4
--- /dev/null
+++ b/src/xrEngine/splash.cpp
@@ -0,0 +1,47 @@
+#include "stdafx.h"
+#include "xr_3da/resource.h"
+#include "splash.h"
+
+HWND logoWindow = nullptr;
+
+static INT_PTR CALLBACK LogoWndProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
+{
+ switch (msg)
+ {
+ case WM_DESTROY: break;
+ case WM_CLOSE: DestroyWindow(hw); break;
+ case WM_COMMAND:
+ if (LOWORD(wp) == IDCANCEL)
+ DestroyWindow(hw);
+ break;
+ default: return false;
+ }
+ return true;
+}
+
+namespace splash
+{
+void show(const bool topmost)
+{
+ if (logoWindow)
+ return;
+
+ logoWindow = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_STARTUP), nullptr, LogoWndProc);
+ const HWND logoPicture = GetDlgItem(logoWindow, IDC_STATIC_LOGO);
+ RECT logoRect;
+ GetWindowRect(logoPicture, &logoRect);
+ const HWND prevWindow = topmost ? HWND_TOPMOST : HWND_NOTOPMOST;
+ SetWindowPos(logoWindow, prevWindow, 0, 0, logoRect.right - logoRect.left, logoRect.bottom - logoRect.top,
+ SWP_NOMOVE | SWP_SHOWWINDOW);
+ UpdateWindow(logoWindow);
+}
+
+void hide()
+{
+ if (logoWindow != nullptr)
+ {
+ DestroyWindow(logoWindow);
+ logoWindow = nullptr;
+ }
+}
+}
diff --git a/src/xrEngine/splash.h b/src/xrEngine/splash.h
new file mode 100644
index 00000000000..024108dea21
--- /dev/null
+++ b/src/xrEngine/splash.h
@@ -0,0 +1,7 @@
+#pragma once
+
+namespace splash
+{
+void ENGINE_API show(const bool topmost);
+void ENGINE_API hide();
+}
diff --git a/src/xrEngine/x_ray.cpp b/src/xrEngine/x_ray.cpp
index 3cc132a2782..764f0c7bab6 100644
--- a/src/xrEngine/x_ray.cpp
+++ b/src/xrEngine/x_ray.cpp
@@ -20,6 +20,7 @@
//---------------------------------------------------------------------
+ENGINE_API CApplication* pApp = nullptr;
extern CRenderDevice Device;
#ifdef MASTER_GOLD
diff --git a/src/xrEngine/xrEngine.vcxproj b/src/xrEngine/xrEngine.vcxproj
index e0c13e2e6de..7ebdad3620a 100644
--- a/src/xrEngine/xrEngine.vcxproj
+++ b/src/xrEngine/xrEngine.vcxproj
@@ -268,6 +268,7 @@
+
@@ -375,6 +376,7 @@
+
diff --git a/src/xrEngine/xrEngine.vcxproj.filters b/src/xrEngine/xrEngine.vcxproj.filters
index 28f17e26a43..7b279339359 100644
--- a/src/xrEngine/xrEngine.vcxproj.filters
+++ b/src/xrEngine/xrEngine.vcxproj.filters
@@ -556,6 +556,9 @@
General\Profiler
+
+ General
+
@@ -873,6 +876,9 @@
General\Profiler
+
+ General
+
diff --git a/src/xr_3da/entry_point.cpp b/src/xr_3da/entry_point.cpp
index d6199ef8787..61d6468f78e 100644
--- a/src/xr_3da/entry_point.cpp
+++ b/src/xr_3da/entry_point.cpp
@@ -3,9 +3,20 @@
#include "StickyKeyFilter.hpp"
#include "xrEngine/main.h"
+#include "xrEngine/splash.h"
int entry_point(pcstr commandLine)
{
+ if (strstr(commandLine, "-nosplash") == nullptr)
+ {
+#ifndef DEBUG
+ const bool topmost = strstr(commandLine, "-splashnotop") == nullptr ? true : false;
+#else
+ constexpr bool topmost = false;
+#endif
+ splash::show(topmost);
+ }
+
if (strstr(commandLine, "-dedicated"))
GEnv.isDedicatedServer = true;