[LoadingWindow] Added the ability for themes to have custom splash banners. (Currently Windows-only.)

This commit is contained in:
AJ Kelly
2011-07-19 19:40:44 -05:00
parent 0c1a33cbe3
commit b1f4bb151d
9 changed files with 40 additions and 55 deletions
+5
View File
@@ -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
Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

+4 -47
View File
@@ -69,8 +69,7 @@
#include "Profile.h"
#if defined(WIN32)
#include <windows.h>
#include "archutils/Win32/AppInstance.h" // used by SetWindowsHookEx -Aldo
#include <windows.h>
#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
+1
View File
@@ -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; }
@@ -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 );
@@ -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 );
@@ -7,6 +7,7 @@ class LoadingWindow_Null: public LoadingWindow
{
public:
void SetText( RString str ) { }
void SetSplash( RString str ) { }
};
#define USE_LOADING_WINDOW_NULL
+26 -8
View File
@@ -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);
@@ -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 );