Fixes the splash screen so that it displays until the game has actually done initial setup and can display GUI elements. This prevents the ugly blank window just sitting there while the GUI loads.

This commit is contained in:
Areloch 2014-07-15 17:44:19 -05:00
parent 8390c4159f
commit c2da67d473
11 changed files with 74 additions and 6 deletions

View file

@ -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, (),,

View file

@ -2683,3 +2683,21 @@ 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();
}

View file

@ -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.

View file

@ -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)
///

View file

@ -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)=0;
private:
/// Process command line arguments from StandardMainLoop. This is done to
/// allow web plugin functionality, where we are passed platform-specific

View file

@ -121,6 +121,13 @@ void CloseSplashWindow(HINSTANCE hinst)
}
bool Platform::closeSplashWindow()
{
CloseSplashWindow(GetModuleHandle(NULL));
return true;
}
bool Platform::displaySplashWindow( String path )
{
if(path.isEmpty())

View file

@ -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;

View file

@ -54,6 +54,8 @@ Win32WindowManager::Win32WindowManager()
mOffscreenRender = false;
mDisplayWindow = false;
buildMonitorsList();
}
@ -263,11 +265,10 @@ 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 );
// Bind the window to the specified device.
if(device)

View file

@ -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

View file

@ -29,6 +29,12 @@ function loadStartup()
// The index of the current splash screen
$StartupIdx = 0;
// 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();
// A list of the splash screens and logos
// to cycle through. Note that they have to
// be in consecutive numerical order

View file

@ -29,6 +29,12 @@ function loadStartup()
// The index of the current splash screen
$StartupIdx = 0;
// 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();
// A list of the splash screens and logos
// to cycle through. Note that they have to
// be in consecutive numerical order