diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index 7f8fbf1c0..76b3f3d9f 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -2141,13 +2141,18 @@ DefineEngineFunction( gotoWebPage, void, ( const char* address ),, //----------------------------------------------------------------------------- -DefineEngineFunction( displaySplashWindow, bool, (const char* path), ("art/gui/splash.bmp"), +DefineEngineFunction( displaySplashWindow, bool, (const char* path), (""), "Display a startup splash window suitable for showing while the engine still starts up.\n\n" "@note This is currently only implemented on Windows.\n\n" "@param path relative path to splash screen image to display.\n" "@return True if the splash window could be successfully initialized.\n\n" "@ingroup Platform" ) { + if (path == "") + { + path = Con::getVariable("$Core::splashWindowImage"); + } + return Platform::displaySplashWindow(path); } diff --git a/Engine/source/windowManager/sdl/sdlSplashScreen.cpp b/Engine/source/windowManager/sdl/sdlSplashScreen.cpp index bf0931a9c..1cf2440af 100644 --- a/Engine/source/windowManager/sdl/sdlSplashScreen.cpp +++ b/Engine/source/windowManager/sdl/sdlSplashScreen.cpp @@ -22,7 +22,7 @@ #include "platform/platform.h" #include "console/console.h" - +#include "gfx/bitmap/gBitmap.h" #include "SDL.h" #include "windowManager/sdl/sdlWindow.h" @@ -36,7 +36,52 @@ bool Platform::displaySplashWindow( String path ) if(path.isEmpty()) return false; - gSplashImage = SDL_LoadBMP(path); + Torque::Path iconPath = Torque::Path(path); + + if (iconPath.getExtension() == String("bmp")) + { + Con::errorf("Unable to use bmp format images for the splash screen. Please use a different format."); + return false; + } + + Resource img = GBitmap::load(iconPath); + if (img != NULL) + { + U32 pitch; + U32 width = img->getWidth(); + bool hasAlpha = img->getHasTransparency(); + U32 depth; + + if (hasAlpha) + { + pitch = 4 * width; + depth = 32; + } + else + { + pitch = 3 * width; + depth = 24; + } + + Uint32 rmask, gmask, bmask, amask; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + { + S32 shift = hasAlpha ? 8 : 0; + rmask = 0xff000000 >> shift; + gmask = 0x00ff0000 >> shift; + bmask = 0x0000ff00 >> shift; + amask = 0x000000ff >> shift; + } + else + { + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = hasAlpha ? 0xff000000 : 0; + } + + gSplashImage = SDL_CreateRGBSurfaceFrom(img->getAddress(0, 0), img->getWidth(), img->getHeight(), depth, pitch, rmask, gmask, bmask, amask); + } //now the pop-up window if (gSplashImage) diff --git a/Engine/source/windowManager/sdl/sdlWindowMgr.cpp b/Engine/source/windowManager/sdl/sdlWindowMgr.cpp index 9dbe1708d..489377082 100644 --- a/Engine/source/windowManager/sdl/sdlWindowMgr.cpp +++ b/Engine/source/windowManager/sdl/sdlWindowMgr.cpp @@ -24,6 +24,7 @@ #include "gfx/gfxDevice.h" #include "core/util/journal/process.h" #include "core/strings/unicode.h" +#include "gfx/bitmap/gBitmap.h" #include "SDL.h" @@ -165,6 +166,59 @@ PlatformWindow *PlatformWindowManagerSDL::createWindow(GFXDevice *device, const window->mOwningManager = this; mWindowMap[ window->mWindowId ] = window; + //Now, fetch our window icon, if any + Torque::Path iconPath = Torque::Path(Con::getVariable( "$Core::windowIcon" )); + + if (iconPath.getExtension() == String("bmp")) + { + Con::errorf("Unable to use bmp format images for the window icon. Please use a different format."); + } + else + { + Resource img = GBitmap::load(iconPath); + if (img != NULL) + { + U32 pitch; + U32 width = img->getWidth(); + bool hasAlpha = img->getHasTransparency(); + U32 depth; + + if (hasAlpha) + { + pitch = 4 * width; + depth = 32; + } + else + { + pitch = 3 * width; + depth = 24; + } + + Uint32 rmask, gmask, bmask, amask; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + { + S32 shift = hasAlpha ? 8 : 0; + rmask = 0xff000000 >> shift; + gmask = 0x00ff0000 >> shift; + bmask = 0x0000ff00 >> shift; + amask = 0x000000ff >> shift; + } + else + { + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = hasAlpha ? 0xff000000 : 0; + } + + SDL_Surface* iconSurface = SDL_CreateRGBSurfaceFrom(img->getAddress(0, 0), img->getWidth(), img->getHeight(), depth, pitch, rmask, gmask, bmask, amask); + + SDL_SetWindowIcon(window->mWindowHandle, iconSurface); + + SDL_FreeSurface(iconSurface); + } + } + if(device) { window->mDevice = device; diff --git a/Templates/Empty/game/art/gui/splash.bmp b/Templates/Empty/game/art/gui/splash.bmp deleted file mode 100644 index 47cb47f97..000000000 Binary files a/Templates/Empty/game/art/gui/splash.bmp and /dev/null differ diff --git a/Templates/Empty/game/art/gui/splash.png b/Templates/Empty/game/art/gui/splash.png new file mode 100644 index 000000000..333df9eb3 Binary files /dev/null and b/Templates/Empty/game/art/gui/splash.png differ diff --git a/Templates/Empty/game/core/torque.png b/Templates/Empty/game/core/torque.png new file mode 100644 index 000000000..1023f2bb6 Binary files /dev/null and b/Templates/Empty/game/core/torque.png differ diff --git a/Templates/Empty/game/main.cs b/Templates/Empty/game/main.cs index 22a3ab2ff..44b333b87 100644 --- a/Templates/Empty/game/main.cs +++ b/Templates/Empty/game/main.cs @@ -28,6 +28,8 @@ $defaultGame = "scripts"; // Set profile directory $Pref::Video::ProfilePath = "core/profile"; +$Core::windowIcon = "core/torque.png"; +$Core::splashWindowImage = "art/gui/splash.png"; function createCanvas(%windowTitle) { diff --git a/Templates/Full/game/art/gui/splash.bmp b/Templates/Full/game/art/gui/splash.bmp deleted file mode 100644 index 47cb47f97..000000000 Binary files a/Templates/Full/game/art/gui/splash.bmp and /dev/null differ diff --git a/Templates/Full/game/art/gui/splash.png b/Templates/Full/game/art/gui/splash.png new file mode 100644 index 000000000..333df9eb3 Binary files /dev/null and b/Templates/Full/game/art/gui/splash.png differ diff --git a/Templates/Full/game/core/torque.png b/Templates/Full/game/core/torque.png new file mode 100644 index 000000000..1023f2bb6 Binary files /dev/null and b/Templates/Full/game/core/torque.png differ diff --git a/Templates/Full/game/main.cs b/Templates/Full/game/main.cs index 2a261201d..65aae6d7f 100644 --- a/Templates/Full/game/main.cs +++ b/Templates/Full/game/main.cs @@ -28,6 +28,8 @@ $defaultGame = "scripts"; // Set profile directory $Pref::Video::ProfilePath = "core/profile"; +$Core::windowIcon = "core/torque.png"; +$Core::splashWindowImage = "art/gui/splash.png"; function createCanvas(%windowTitle) {