diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 6887ae8504..ce445d891e 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -8,6 +8,11 @@ ________________________________________________________________________________ StepMania 5.0 ????????? | 20110??? -------------------------------------------------------------------------------- +2011/07/19 +---------- +* [LoadingWindow] Added the ability for themes to have custom splash banners. + (Currently Windows-only.) [AJ] + 2011/07/17 ---------- * [Cache] No longer store #NOTES in the cache. This should speed things up diff --git a/Themes/_fallback/Graphics/Common splash.png b/Themes/_fallback/Graphics/Common splash.png new file mode 100644 index 0000000000..2c365a3306 Binary files /dev/null and b/Themes/_fallback/Graphics/Common splash.png differ diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 68bf9010ed..6d1c75ea19 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -69,8 +69,7 @@ #include "Profile.h" #if defined(WIN32) -#include -#include "archutils/Win32/AppInstance.h" // used by SetWindowsHookEx -Aldo +#include #endif void ShutdownGame(); @@ -935,32 +934,6 @@ static void ApplyLogPreferences() static LocalizedString COULDNT_OPEN_LOADING_WINDOW( "StepMania", "Couldn't open any loading windows." ); -#if defined(WIN32) -// Low Level hooks go here, I only added Windows Key, but letting the player choose which system shortcuts -// wants to get disabled via PREFSMAN would be nice -Aldo -LRESULT CALLBACK SpecialKeysHook(int code,WPARAM wparam,LPARAM lparam) -{ - if( HOOKS->AppHasFocus() ) // only disable system shortcuts when the game has focus - { - PKBDLLHOOKSTRUCT key = (PKBDLLHOOKSTRUCT)lparam; - - switch(wparam) - { - case WM_KEYDOWN: - case WM_KEYUP: - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - if(key->vkCode==VK_LWIN || key->vkCode==VK_RWIN) - { - return 1; - } - } - } - - return CallNextHookEx(0,code,wparam,lparam); -} -#endif - int main(int argc, char* argv[]) { RageThreadRegister thread( "Main thread" ); @@ -1074,13 +1047,14 @@ int main(int argc, char* argv[]) GAMESTATE->m_bDopefish = true; { - /* Now that THEME is loaded, load the icon for the current theme into - * the loading window. */ + /* Now that THEME is loaded, load the icon and splash for the current + * theme into the loading window. */ RString sError; RageSurface *pIcon = RageSurfaceUtils::LoadFile( THEME->GetPathG( "Common", "window icon" ), sError ); if( pIcon ) pLoadingWindow->SetIcon( pIcon ); delete pIcon; + pLoadingWindow->SetSplash( THEME->GetPathG("Common","splash") ); } if( PREFSMAN->m_iSoundWriteAhead ) @@ -1151,23 +1125,6 @@ int main(int argc, char* argv[]) StoreActualGraphicOptions(); LOG->Info( "%s", GetActualGraphicOptionsString().c_str() ); -#if defined(WIN32) - // Apply Low Level hooks just after creating the display, so we have a valid - // HINSTANCE, rather than a NULL one -Aldo - AppInstance inst; - HHOOK hook; - hook = SetWindowsHookEx( - WH_KEYBOARD_LL, - SpecialKeysHook, - inst.Get(), - 0 - ); - if(!hook) - { - LOG->Warn("SetWindowsHookEx: Could not create hook (Error %d).", GetLastError()); - } -#endif - SONGMAN->PreloadSongImages(); /* Input handlers can have dependences on the video system so diff --git a/src/arch/LoadingWindow/LoadingWindow.h b/src/arch/LoadingWindow/LoadingWindow.h index 4cc23cd097..ec92728e1f 100644 --- a/src/arch/LoadingWindow/LoadingWindow.h +++ b/src/arch/LoadingWindow/LoadingWindow.h @@ -13,6 +13,7 @@ public: virtual void SetText( RString str ) = 0; virtual void SetIcon( const RageSurface *pIcon ) { } + virtual void SetSplash( const RString sPath ) { } virtual void SetProgress( const int progress ) { m_progress=progress; } virtual void SetTotalWork( const int totalWork ) { m_totalWork=totalWork; } virtual void SetIndeterminate( bool indeterminate ) { m_indeterminate=indeterminate; } diff --git a/src/arch/LoadingWindow/LoadingWindow_Gtk.h b/src/arch/LoadingWindow/LoadingWindow_Gtk.h index 6abeb87b4d..3ccca35841 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Gtk.h +++ b/src/arch/LoadingWindow/LoadingWindow_Gtk.h @@ -12,6 +12,7 @@ public: RString Init(); ~LoadingWindow_Gtk(); void SetText( RString str ); + void SetSplash( const RString str ) {} void SetProgress( const int progress ); void SetTotalWork( const int totalWork ); void SetIndeterminate( bool indeterminate ); diff --git a/src/arch/LoadingWindow/LoadingWindow_MacOSX.h b/src/arch/LoadingWindow/LoadingWindow_MacOSX.h index 3a521a3170..37694a9a93 100644 --- a/src/arch/LoadingWindow/LoadingWindow_MacOSX.h +++ b/src/arch/LoadingWindow/LoadingWindow_MacOSX.h @@ -9,6 +9,7 @@ public: LoadingWindow_MacOSX(); ~LoadingWindow_MacOSX(); void SetText( RString str ); + void SetSplash( const RString path ) {} void SetProgress( const int progress ); void SetTotalWork( const int totalWork ); void SetIndeterminate( bool indeterminate ); diff --git a/src/arch/LoadingWindow/LoadingWindow_Null.h b/src/arch/LoadingWindow/LoadingWindow_Null.h index 1ca5d89341..4b470f80b2 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Null.h +++ b/src/arch/LoadingWindow/LoadingWindow_Null.h @@ -7,6 +7,7 @@ class LoadingWindow_Null: public LoadingWindow { public: void SetText( RString str ) { } + void SetSplash( RString str ) { } }; #define USE_LOADING_WINDOW_NULL diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index f152af9b2b..8412965205 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -20,8 +20,7 @@ static HBITMAP g_hBitmap = NULL; #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") - -/* Load a RageSurface into a GDI surface. */ +// Load a RageSurface into a GDI surface. static HBITMAP LoadWin32Surface( RageSurface *&s ) { RageSurfaceUtils::ConvertSurface( s, s->w, s->h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0 ); @@ -35,14 +34,14 @@ static HBITMAP LoadWin32Surface( RageSurface *&s ) HDC BitmapDC = CreateCompatibleDC( hScreen ); SelectObject( BitmapDC, bitmap ); - /* This is silly, but simple. We only do this once, on a small image. */ + // This is silly, but simple. We only do this once, on a small image. for( int y = 0; y < s->h; ++y ) { unsigned const char *line = ((unsigned char *) s->pixels) + (y * s->pitch); for( int x = 0; x < s->w; ++x ) { unsigned const char *data = line + (x*s->format->BytesPerPixel); - + SetPixelV( BitmapDC, x, y, RGB( data[3], data[2], data[1] ) ); } } @@ -62,7 +61,7 @@ static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd ) if( pSurface == NULL ) return NULL; - /* Resize the splash image to fit the dialog. Stretch to fit horizontally, + /* Resize the splash image to fit the dialog. Stretch to fit horizontally, * maintaining aspect ratio. */ { RECT r; @@ -82,7 +81,6 @@ static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd ) INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - LoadingWindow_Win32 *self; if(msg==WM_INITDIALOG) { @@ -136,7 +134,7 @@ INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wPara void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon ) { - if( m_hIcon != NULL ) + if( g_hBitmap != NULL ) DestroyIcon( m_hIcon ); m_hIcon = IconFromSurface( pIcon ); @@ -144,6 +142,26 @@ void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon ) SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon ); } +void LoadingWindow_Win32::SetSplash( const RString sPath ) +{ + if( g_hBitmap != NULL ) + { + DeleteObject( g_hBitmap ); + g_hBitmap = NULL; + } + + g_hBitmap = LoadWin32Surface( sPath, hwnd ); + if( g_hBitmap != NULL ) + { + SendDlgItemMessage( + hwnd, IDC_SPLASH, + STM_SETIMAGE, + (WPARAM) IMAGE_BITMAP, + (LPARAM) (HANDLE) g_hBitmap + ); + } +} + LoadingWindow_Win32::LoadingWindow_Win32() { INITCOMMONCONTROLSEX cceData; @@ -152,7 +170,7 @@ LoadingWindow_Win32::LoadingWindow_Win32() InitCommonControlsEx(&cceData); m_hIcon = NULL; - + runMessageLoop=true; guiReadyEvent=CreateEvent(NULL,FALSE,FALSE,NULL); diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.h b/src/arch/LoadingWindow/LoadingWindow_Win32.h index 3c45789779..3780c85178 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.h +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.h @@ -15,6 +15,7 @@ public: void SetText( RString sText ); void SetIcon( const RageSurface *pIcon ); + void SetSplash( const RString sPath ); void SetProgress( const int progress ); void SetTotalWork( const int totalWork ); void SetIndeterminate( bool indeterminate );