diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index f5c90194e..2dea93f44 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -1589,6 +1589,13 @@ DefineEngineFunction( displaySplashWindow, bool, (const char* path), ("art/gui/s return Platform::displaySplashWindow(path); } +DefineEngineFunction( closeSplashWindow, void, (),, + "Close our startup splash window.\n\n" + "@note This is currently only implemented on Windows.\n\n" + "@ingroup Platform" ) +{ + Platform::closeSplashWindow(); +} //----------------------------------------------------------------------------- DefineEngineFunction( getWebDeployment, bool, (),, diff --git a/Engine/source/gui/core/guiCanvas.cpp b/Engine/source/gui/core/guiCanvas.cpp index cbef4673c..ad5646fe6 100644 --- a/Engine/source/gui/core/guiCanvas.cpp +++ b/Engine/source/gui/core/guiCanvas.cpp @@ -121,7 +121,8 @@ GuiCanvas::GuiCanvas(): GuiControl(), mMiddleMouseLast(false), mRightMouseLast(false), mPlatformWindow(NULL), - mLastRenderMs(0) + mLastRenderMs(0), + mDisplayWindow(true) { setBounds(0, 0, 640, 480); mAwake = true; @@ -176,6 +177,8 @@ void GuiCanvas::initPersistFields() addGroup("Canvas Rendering"); addProtectedField( "numFences", TypeS32, Offset( mNumFences, GuiCanvas ), &setProtectedNumFences, &defaultProtectedGetFn, "The number of GFX fences to use." ); + + addField("displayWindow", TypeBool, Offset(mDisplayWindow, GuiCanvas), "Controls if the canvas window is rendered or not." ); endGroup("Canvas Rendering"); Parent::initPersistFields(); @@ -252,6 +255,19 @@ bool GuiCanvas::onAdd() // Make sure we're able to render. newDevice->setAllowRender( true ); + if(mDisplayWindow) + { + getPlatformWindow()->show(); + WindowManager->setDisplayWindow(true); + getPlatformWindow()->setDisplayWindow(true); + } + else + { + getPlatformWindow()->hide(); + WindowManager->setDisplayWindow(false); + getPlatformWindow()->setDisplayWindow(false); + } + // Propagate add to parents. // CodeReview - if GuiCanvas fails to add for whatever reason, what happens to // all the event registration above? @@ -2683,3 +2699,23 @@ ConsoleMethod( GuiCanvas, setVideoMode, void, 5, 8, // Store the new mode into a pref. Con::setVariable( "$pref::Video::mode", vm.toString() ); } + +ConsoleMethod( GuiCanvas, showWindow, void, 2, 2, "" ) +{ + if (!object->getPlatformWindow()) + return; + + object->getPlatformWindow()->show(); + WindowManager->setDisplayWindow(true); + object->getPlatformWindow()->setDisplayWindow(true); +} + +ConsoleMethod( GuiCanvas, hideWindow, void, 2, 2, "" ) +{ + if (!object->getPlatformWindow()) + return; + + object->getPlatformWindow()->hide(); + WindowManager->setDisplayWindow(false); + object->getPlatformWindow()->setDisplayWindow(false); +} \ No newline at end of file diff --git a/Engine/source/gui/core/guiCanvas.h b/Engine/source/gui/core/guiCanvas.h index 04af6d692..9d3ed8b10 100644 --- a/Engine/source/gui/core/guiCanvas.h +++ b/Engine/source/gui/core/guiCanvas.h @@ -108,6 +108,8 @@ protected: bool mClampTorqueCursor; bool mAlwaysHandleMouseButtons; + bool mDisplayWindow; + /// @} /// @name Mouse Input diff --git a/Engine/source/platform/platform.h b/Engine/source/platform/platform.h index 3b5a57358..d390eef5c 100644 --- a/Engine/source/platform/platform.h +++ b/Engine/source/platform/platform.h @@ -338,6 +338,9 @@ namespace Platform // display Splash Window bool displaySplashWindow( String path ); + // close Splash Window + bool closeSplashWindow(); + void openFolder( const char* path ); // Open file at the OS level, according to registered file-types. diff --git a/Engine/source/platformMac/macCocoaPlatform.mm b/Engine/source/platformMac/macCocoaPlatform.mm index 24b8808e9..286aa44e2 100644 --- a/Engine/source/platformMac/macCocoaPlatform.mm +++ b/Engine/source/platformMac/macCocoaPlatform.mm @@ -70,6 +70,11 @@ bool Platform::displaySplashWindow() return false; } +bool Platform::closeSplashWindow() +{ + return false; +} + #pragma mark ---- File IO ---- //----------------------------------------------------------------------------- bool dPathCopy(const char* source, const char* dest, bool nooverwrite) diff --git a/Engine/source/platformX86UNIX/x86UNIXStub.dedicated.cpp b/Engine/source/platformX86UNIX/x86UNIXStub.dedicated.cpp index 770fd0680..39948914b 100644 --- a/Engine/source/platformX86UNIX/x86UNIXStub.dedicated.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXStub.dedicated.cpp @@ -93,6 +93,7 @@ void Platform::openFile(const char *path) { } // window bool Platform::displaySplashWindow(String path) { return false; } +bool Platform::closeSplashWindow() { return false; } // font PlatformFont *createPlatformFont(const char *name, U32 size, U32 charset) { return NULL; } diff --git a/Engine/source/windowManager/platformWindow.h b/Engine/source/windowManager/platformWindow.h index 11d28d384..680e8b12b 100644 --- a/Engine/source/windowManager/platformWindow.h +++ b/Engine/source/windowManager/platformWindow.h @@ -89,6 +89,10 @@ protected: /// Offscreen Render bool mOffscreenRender; + /// This is set as part of the canvas being shown, and flags that the windows should render as normal from now on. + // Basically a flag that lets the window manager know that we've handled the splash screen, and to operate as normal. + bool mDisplayWindow; + /// Protected constructor so that the win PlatformWindow() { @@ -104,6 +108,7 @@ protected: mSuppressReset = false; mOffscreenRender = false; + mDisplayWindow = false; } public: @@ -180,6 +185,8 @@ public: /// This is called to poll the window as to it's idle state. virtual bool getOffscreenRender() { return mOffscreenRender; }; + /// Set whether this window is should display as normal + virtual void setDisplayWindow(bool val ) { mDisplayWindow = val; }; /// Set Focused State (Foreground) /// diff --git a/Engine/source/windowManager/platformWindowMgr.h b/Engine/source/windowManager/platformWindowMgr.h index b744af56b..41fcd8c9d 100644 --- a/Engine/source/windowManager/platformWindowMgr.h +++ b/Engine/source/windowManager/platformWindowMgr.h @@ -133,6 +133,9 @@ public: /// This method removes the curtain window. virtual void raiseCurtain()=0; + /// This method indicates to created windows to show as normal. + virtual void setDisplayWindow(bool set){} + private: /// Process command line arguments from StandardMainLoop. This is done to /// allow web plugin functionality, where we are passed platform-specific diff --git a/Engine/source/windowManager/win32/win32SplashScreen.cpp b/Engine/source/windowManager/win32/win32SplashScreen.cpp index 83189dac3..29542ef41 100644 --- a/Engine/source/windowManager/win32/win32SplashScreen.cpp +++ b/Engine/source/windowManager/win32/win32SplashScreen.cpp @@ -121,6 +121,13 @@ void CloseSplashWindow(HINSTANCE hinst) } +bool Platform::closeSplashWindow() +{ + CloseSplashWindow(GetModuleHandle(NULL)); + + return true; +} + bool Platform::displaySplashWindow( String path ) { if(path.isEmpty()) diff --git a/Engine/source/windowManager/win32/win32Window.cpp b/Engine/source/windowManager/win32/win32Window.cpp index 0cbb59433..3b95a223a 100644 --- a/Engine/source/windowManager/win32/win32Window.cpp +++ b/Engine/source/windowManager/win32/win32Window.cpp @@ -153,7 +153,9 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode ) { SetWindowLong( getHWND(), GWL_STYLE, WS_POPUP); SetWindowPos( getHWND(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - ShowWindow(getHWND(), SW_SHOWNORMAL); + + if(mDisplayWindow) + ShowWindow(getHWND(), SW_SHOWNORMAL); // Clear the menu bar from the window for full screen HMENU menu = GetMenu(getHWND()); @@ -216,7 +218,9 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode ) // We have to force Win32 to update the window frame and make the window // visible and no longer topmost - this code might be possible to simplify. SetWindowPos( getHWND(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - ShowWindow( getHWND(), SW_SHOWNORMAL); + + if(mDisplayWindow) + ShowWindow( getHWND(), SW_SHOWNORMAL); } mFullscreen = false; diff --git a/Engine/source/windowManager/win32/win32WindowMgr.cpp b/Engine/source/windowManager/win32/win32WindowMgr.cpp index 3777a01f6..d9e0cc22d 100644 --- a/Engine/source/windowManager/win32/win32WindowMgr.cpp +++ b/Engine/source/windowManager/win32/win32WindowMgr.cpp @@ -54,6 +54,8 @@ Win32WindowManager::Win32WindowManager() mOffscreenRender = false; + mDisplayWindow = false; + buildMonitorsList(); } @@ -263,11 +265,13 @@ PlatformWindow *Win32WindowManager::createWindow(GFXDevice *device, const GFXVid // If we're not rendering offscreen, make sure our window is shown and drawn to. - if (!mOffscreenRender) - ShowWindow( w32w->mWindowHandle, SW_SHOWDEFAULT ); + w32w->setDisplayWindow(mDisplayWindow); - // Close any splash screen we created - CloseSplashWindow(winState.appInstance); + if (!mOffscreenRender && mDisplayWindow) + { + ShowWindow( w32w->mWindowHandle, SW_SHOWDEFAULT ); + CloseSplashWindow(winState.appInstance); + } // Bind the window to the specified device. if(device) diff --git a/Engine/source/windowManager/win32/win32WindowMgr.h b/Engine/source/windowManager/win32/win32WindowMgr.h index be9cdaa42..5282d116b 100644 --- a/Engine/source/windowManager/win32/win32WindowMgr.h +++ b/Engine/source/windowManager/win32/win32WindowMgr.h @@ -56,6 +56,10 @@ class Win32WindowManager : public PlatformWindowManager // is intended for offscreen rendering bool mOffscreenRender; + /// This is set as part of the canvas being shown, and flags that the windows should render as normal from now on. + // Basically a flag that lets the window manager know that we've handled the splash screen, and to operate as normal. + bool mDisplayWindow; + /// Internal structure used when enumerating monitors struct MonitorInfo { HMONITOR monitorHandle; @@ -117,6 +121,8 @@ public: virtual void lowerCurtain(); virtual void raiseCurtain(); + + virtual void setDisplayWindow(bool set) { mDisplayWindow = set; } }; #endif \ No newline at end of file diff --git a/Templates/Empty/game/main.cs b/Templates/Empty/game/main.cs index bd1333e6a..5d26b7fca 100644 --- a/Templates/Empty/game/main.cs +++ b/Templates/Empty/game/main.cs @@ -38,7 +38,10 @@ function createCanvas(%windowTitle) } // Create the Canvas - %foo = new GuiCanvas(Canvas); + %foo = new GuiCanvas(Canvas) + { + displayWindow = false; + }; // Set the window title if (isObject(Canvas)) @@ -246,6 +249,15 @@ if ($displayHelp) { else { onStart(); echo("Engine initialized..."); + + if( !$isDedicated ) + { + // As we know at this point that the initial load is complete, + // we can hide any splash screen we have, and show the canvas. + // This keeps things looking nice, instead of having a blank window + closeSplashWindow(); + Canvas.showWindow(); + } // Auto-load on the 360 if( $platform $= "xenon" ) diff --git a/Templates/Empty/game/main.cs.in b/Templates/Empty/game/main.cs.in index db8436e7d..d3b5791ef 100644 --- a/Templates/Empty/game/main.cs.in +++ b/Templates/Empty/game/main.cs.in @@ -38,7 +38,10 @@ function createCanvas(%windowTitle) } // Create the Canvas - %foo = new GuiCanvas(Canvas); + %foo = new GuiCanvas(Canvas) + { + displayWindow = false; + }; // Set the window title if (isObject(Canvas)) @@ -246,6 +249,15 @@ if ($displayHelp) { else { onStart(); echo("Engine initialized..."); + + if( !$isDedicated ) + { + // As we know at this point that the initial load is complete, + // we can hide any splash screen we have, and show the canvas. + // This keeps things looking nice, instead of having a blank window + closeSplashWindow(); + Canvas.showWindow(); + } // Auto-load on the 360 if( $platform $= "xenon" ) diff --git a/Templates/Full/game/main.cs b/Templates/Full/game/main.cs index 11c7348d0..96794899a 100644 --- a/Templates/Full/game/main.cs +++ b/Templates/Full/game/main.cs @@ -38,7 +38,10 @@ function createCanvas(%windowTitle) } // Create the Canvas - %foo = new GuiCanvas(Canvas); + %foo = new GuiCanvas(Canvas) + { + displayWindow = false; + }; // Set the window title if (isObject(Canvas)) @@ -246,6 +249,15 @@ if ($displayHelp) { else { onStart(); echo("Engine initialized..."); + + if( !$isDedicated ) + { + // As we know at this point that the initial load is complete, + // we can hide any splash screen we have, and show the canvas. + // This keeps things looking nice, instead of having a blank window + closeSplashWindow(); + Canvas.showWindow(); + } // Auto-load on the 360 if( $platform $= "xenon" ) diff --git a/Templates/Full/game/main.cs.in b/Templates/Full/game/main.cs.in index db8436e7d..d3b5791ef 100644 --- a/Templates/Full/game/main.cs.in +++ b/Templates/Full/game/main.cs.in @@ -38,7 +38,10 @@ function createCanvas(%windowTitle) } // Create the Canvas - %foo = new GuiCanvas(Canvas); + %foo = new GuiCanvas(Canvas) + { + displayWindow = false; + }; // Set the window title if (isObject(Canvas)) @@ -246,6 +249,15 @@ if ($displayHelp) { else { onStart(); echo("Engine initialized..."); + + if( !$isDedicated ) + { + // As we know at this point that the initial load is complete, + // we can hide any splash screen we have, and show the canvas. + // This keeps things looking nice, instead of having a blank window + closeSplashWindow(); + Canvas.showWindow(); + } // Auto-load on the 360 if( $platform $= "xenon" )