Splash should show up properly now.
This commit is contained in:
@@ -141,7 +141,7 @@ void RageSurfaceUtils::CopySurface( const RageSurface *src, RageSurface *dest )
|
||||
Blit( src, dest, -1, -1 );
|
||||
}
|
||||
|
||||
bool RageSurfaceUtils::ConvertSurface( RageSurface *src, RageSurface *&dst,
|
||||
bool RageSurfaceUtils::ConvertSurface( const RageSurface *src, RageSurface *&dst,
|
||||
int width, int height, int bpp,
|
||||
uint32_t R, uint32_t G, uint32_t B, uint32_t A )
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace RageSurfaceUtils
|
||||
void GetBitsPerChannel( const RageSurfaceFormat *fmt, uint32_t bits[4] );
|
||||
|
||||
void CopySurface( const RageSurface *src, RageSurface *dest );
|
||||
bool ConvertSurface( RageSurface *src, RageSurface *&dst,
|
||||
bool ConvertSurface( const RageSurface *src, RageSurface *&dst,
|
||||
int width, int height, int bpp, uint32_t R, uint32_t G, uint32_t B, uint32_t A );
|
||||
void ConvertSurface( RageSurface *&image,
|
||||
int width, int height, int bpp, uint32_t R, uint32_t G, uint32_t B, uint32_t A );
|
||||
|
||||
+8
-5
@@ -1093,11 +1093,14 @@ int main(int argc, char* argv[])
|
||||
/* 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") );
|
||||
RageSurface *pSurface = RageSurfaceUtils::LoadFile( THEME->GetPathG( "Common", "window icon" ), sError );
|
||||
if( pSurface != NULL )
|
||||
pLoadingWindow->SetIcon( pSurface );
|
||||
delete pSurface;
|
||||
pSurface = RageSurfaceUtils::LoadFile( THEME->GetPathG("Common","splash"), sError );
|
||||
if( pSurface != NULL )
|
||||
pLoadingWindow->SetSplash( pSurface );
|
||||
delete pSurface;
|
||||
}
|
||||
|
||||
if( PREFSMAN->m_iSoundWriteAhead )
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
virtual void SetText( RString str ) = 0;
|
||||
virtual void SetIcon( const RageSurface *pIcon ) { }
|
||||
virtual void SetSplash( const RString sPath ) { }
|
||||
virtual void SetSplash( const RageSurface *pSplash ) { }
|
||||
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; }
|
||||
|
||||
@@ -90,9 +90,9 @@ void LoadingWindow_Gtk::SetIcon( const RageSurface *pIcon )
|
||||
//Module_SetIcon( pIcon );
|
||||
}
|
||||
|
||||
void LoadingWindow_Gtk::SetSplash( const RString str )
|
||||
void LoadingWindow_Gtk::SetSplash( const RageSurface *pSplash )
|
||||
{
|
||||
Module_SetSplash( FILEMAN->ResolvePath(str) );
|
||||
Module_SetSplash( pSplash );
|
||||
}
|
||||
|
||||
void LoadingWindow_Gtk::SetProgress( const int progress )
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
~LoadingWindow_Gtk();
|
||||
void SetText( RString str );
|
||||
void SetIcon( const RageSurface *pIcon );
|
||||
void SetSplash( const RString str );
|
||||
void SetSplash( const RageSurface *pSplash );
|
||||
void SetProgress( const int progress );
|
||||
void SetTotalWork( const int totalWork );
|
||||
void SetIndeterminate( bool indeterminate );
|
||||
|
||||
@@ -26,7 +26,7 @@ extern "C" const char *Init( int *argc, char ***argv )
|
||||
gtk_window_set_position( GTK_WINDOW(window), GTK_WIN_POS_CENTER );
|
||||
gtk_widget_set_size_request(window,468,-1);
|
||||
gtk_window_set_deletable( GTK_WINDOW(window), FALSE );
|
||||
gtk_window_set_policy(GTK_WINDOW(window),FALSE,FALSE,TRUE);
|
||||
gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
|
||||
gtk_window_set_role( GTK_WINDOW(window), "sm-startup" );
|
||||
//gtk_window_set_icon( GTK_WINDOW(window), );
|
||||
gtk_widget_realize(window);
|
||||
@@ -54,7 +54,7 @@ extern "C" const char *Init( int *argc, char ***argv )
|
||||
|
||||
extern "C" void Shutdown()
|
||||
{
|
||||
gtk_widget_hide_all(window);
|
||||
gtk_widget_hide(window);
|
||||
g_signal_emit_by_name (G_OBJECT (window), "destroy");
|
||||
while( gtk_events_pending() )
|
||||
gtk_main_iteration_do(FALSE);
|
||||
@@ -66,6 +66,27 @@ extern "C" void SetText( const char *s )
|
||||
gtk_widget_show(label);
|
||||
gtk_main_iteration_do(FALSE);
|
||||
}
|
||||
|
||||
void DeletePixels( guchar *pixels, gpointer data )
|
||||
{
|
||||
delete[] (uint8_t *)pixels;
|
||||
}
|
||||
|
||||
GdkPixbuf *MakePixbuf( const RageSurface *pSrc )
|
||||
{
|
||||
RageSurface *pSurface;
|
||||
if( !RageSurfaceUtils::ConvertSurface( pSrc, pSurface, pSrc->w, pSrc->h, 32,
|
||||
0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
GdkPixbuf *pBuf = gdk_pixbuf_new_from_data( pSurface->pixels, GDK_COLORSPACE_RGB,
|
||||
true, 8, pSurface->w, pSurface->h , pSurface->pitch, DeletePixels, NULL);
|
||||
if( pBuf != NULL )
|
||||
pSurface->pixels_owned = false;
|
||||
delete pSurface;
|
||||
return pBuf;
|
||||
}
|
||||
/*
|
||||
extern "C" void SetIcon( const RageSurface *pSrcImg )
|
||||
{
|
||||
@@ -94,9 +115,15 @@ extern "C" void SetIcon( const RageSurface *pSrcImg )
|
||||
gtk_main_iteration_do(FALSE);
|
||||
}
|
||||
*/
|
||||
extern "C" void SetSplash( const char *s )
|
||||
|
||||
extern "C" void SetSplash( const RageSurface *pSplash )
|
||||
{
|
||||
gtk_image_set_from_file(GTK_IMAGE(splash), s);
|
||||
GdkPixbuf *pBuf = MakePixbuf( pSplash );
|
||||
if( pBuf != NULL )
|
||||
{
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(splash), pBuf);
|
||||
g_object_unref(pBuf);
|
||||
}
|
||||
gtk_main_iteration_do(FALSE);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ typedef const char *(*INIT)(int *argc, char ***argv);
|
||||
typedef void (*SHUTDOWN)();
|
||||
typedef void (*SETTEXT)( const char *s );
|
||||
//typedef void (*SETICON)( const RageSurface *pSrcImg );
|
||||
typedef void (*SETSPLASH)( const char *s );
|
||||
typedef void (*SETSPLASH)( const RageSurface *pSplash );
|
||||
typedef void (*SETPROGRESS)( int progress, int totalWork );
|
||||
typedef void (*SETINDETERMINATE)( bool indeterminate );
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public:
|
||||
LoadingWindow_MacOSX();
|
||||
~LoadingWindow_MacOSX();
|
||||
void SetText( RString str );
|
||||
void SetSplash( const RString path ) {}
|
||||
void SetSplash( const RageSurface *pSplash ) {}
|
||||
void SetProgress( const int progress );
|
||||
void SetTotalWork( const int totalWork );
|
||||
void SetIndeterminate( bool indeterminate );
|
||||
|
||||
@@ -7,7 +7,7 @@ class LoadingWindow_Null: public LoadingWindow
|
||||
{
|
||||
public:
|
||||
void SetText( RString str ) { }
|
||||
void SetSplash( const RString str ) { }
|
||||
void SetSplash( const RageSurface *pSplash ) { }
|
||||
};
|
||||
#define USE_LOADING_WINDOW_NULL
|
||||
|
||||
|
||||
@@ -20,9 +20,28 @@
|
||||
static HBITMAP g_hBitmap = NULL;
|
||||
|
||||
/* Load a RageSurface into a GDI surface. */
|
||||
static HBITMAP LoadWin32Surface( RageSurface *&s )
|
||||
static HBITMAP LoadWin32Surface( const RageSurface *pSplash, HWND hwnd )
|
||||
{
|
||||
RageSurfaceUtils::ConvertSurface( s, s->w, s->h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0 );
|
||||
RageSurface *s;
|
||||
if( !RageSurfaceUtils::ConvertSurface( pSplash, s,
|
||||
pSplash->w, pSplash->h, 32,
|
||||
0xFF000000, 0x00FF0000, 0x0000FF00, 0 ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Resize the splash image to fit the dialog. Stretch to fit horizontally,
|
||||
* maintaining aspect ratio. */
|
||||
{
|
||||
RECT r;
|
||||
GetClientRect( hWnd, &r );
|
||||
|
||||
int iWidth = r.right;
|
||||
float fRatio = (float) iWidth / s->w;
|
||||
int iHeight = lrintf( s->h * fRatio );
|
||||
|
||||
RageSurfaceUtils::Zoom( s, iWidth, iHeight );
|
||||
}
|
||||
|
||||
HDC hScreen = GetDC(NULL);
|
||||
ASSERT_M( hScreen != NULL, werr_ssprintf(GetLastError(), "hScreen") );
|
||||
@@ -50,34 +69,10 @@ static HBITMAP LoadWin32Surface( RageSurface *&s )
|
||||
|
||||
ReleaseDC( NULL, hScreen );
|
||||
|
||||
delete s;
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd )
|
||||
{
|
||||
RString error;
|
||||
RageSurface *pSurface = RageSurfaceUtils::LoadFile( sFile, error );
|
||||
if( pSurface == NULL )
|
||||
return NULL;
|
||||
|
||||
/* Resize the splash image to fit the dialog. Stretch to fit horizontally,
|
||||
* maintaining aspect ratio. */
|
||||
{
|
||||
RECT r;
|
||||
GetClientRect( hWnd, &r );
|
||||
|
||||
int iWidth = r.right;
|
||||
float fRatio = (float) iWidth / pSurface->w;
|
||||
int iHeight = lrintf( pSurface->h * fRatio );
|
||||
|
||||
RageSurfaceUtils::Zoom( pSurface, iWidth, iHeight );
|
||||
}
|
||||
|
||||
HBITMAP ret = LoadWin32Surface( pSurface );
|
||||
delete pSurface;
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch( msg )
|
||||
@@ -118,7 +113,7 @@ void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon )
|
||||
SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon );
|
||||
}
|
||||
|
||||
void LoadingWindow_Win32::SetSplash( const RString sPath )
|
||||
void LoadingWindow_Win32::SetSplash( const RageSurface *pSplash )
|
||||
{
|
||||
if( g_hBitmap != NULL )
|
||||
{
|
||||
@@ -126,7 +121,7 @@ void LoadingWindow_Win32::SetSplash( const RString sPath )
|
||||
g_hBitmap = NULL;
|
||||
}
|
||||
|
||||
g_hBitmap = LoadWin32Surface( sPath, hwnd );
|
||||
g_hBitmap = LoadWin32Surface( pSplash, hwnd );
|
||||
if( g_hBitmap != NULL )
|
||||
{
|
||||
SendDlgItemMessage(
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
void Paint();
|
||||
void SetText( RString sText );
|
||||
void SetIcon( const RageSurface *pIcon );
|
||||
void SetSplash( const RString sPath );
|
||||
void SetSplash( const RageSurface *pSplash );
|
||||
void SetProgress( const int progress );
|
||||
void SetTotalWork( const int totalWork );
|
||||
void SetIndeterminate( bool indeterminate );
|
||||
|
||||
Reference in New Issue
Block a user