Merge pull request #613 from dguzek/OSX-Loading-Splash
fix LoadingWindow splash image for OS X
This commit is contained in:
@@ -9,7 +9,7 @@ public:
|
||||
LoadingWindow_MacOSX();
|
||||
~LoadingWindow_MacOSX();
|
||||
void SetText( RString str );
|
||||
void SetSplash( const RageSurface *pSplash ) {}
|
||||
void SetSplash( const RageSurface *pSplash );
|
||||
void SetProgress( const int progress );
|
||||
void SetTotalWork( const int totalWork );
|
||||
void SetIndeterminate( bool indeterminate );
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#import "LoadingWindow_MacOSX.h"
|
||||
#import "RageUtil.h"
|
||||
#import "RageFile.h"
|
||||
#include "ThemeManager.h"
|
||||
|
||||
@interface LoadingWindowHelper : NSObject
|
||||
{
|
||||
@@ -79,9 +80,11 @@
|
||||
|
||||
// Set subviews.
|
||||
[view addSubview:m_Text];
|
||||
[view addSubview:iView];
|
||||
[m_Text release];
|
||||
|
||||
[view addSubview:iView];
|
||||
[iView release];
|
||||
|
||||
[view addSubview:m_ProgressIndicator];
|
||||
|
||||
// Display the window.
|
||||
@@ -107,35 +110,7 @@
|
||||
|
||||
static LoadingWindowHelper *g_Helper = nil;
|
||||
|
||||
LoadingWindow_MacOSX::LoadingWindow_MacOSX()
|
||||
{
|
||||
RageFile f;
|
||||
RString data;
|
||||
|
||||
vector<RString> vs;
|
||||
GetDirListing( "Data/splash*.png", vs, false, true );
|
||||
if( vs.empty() || !f.Open(vs[0]) )
|
||||
return;
|
||||
f.Read( data );
|
||||
if( data.empty() )
|
||||
return;
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSImage *image = nil;
|
||||
NSData *d = [[NSData alloc] initWithBytes:data.data() length:data.length()];
|
||||
image = [[NSImage alloc] initWithData:d];
|
||||
[d release];
|
||||
if( !image )
|
||||
{
|
||||
[pool release];
|
||||
return;
|
||||
}
|
||||
|
||||
g_Helper = [[LoadingWindowHelper alloc] init];
|
||||
g_Helper->m_Pool = pool;
|
||||
[g_Helper performSelectorOnMainThread:@selector(setupWindow:) withObject:image waitUntilDone:YES];
|
||||
[image release];
|
||||
}
|
||||
LoadingWindow_MacOSX::LoadingWindow_MacOSX() {}
|
||||
|
||||
LoadingWindow_MacOSX::~LoadingWindow_MacOSX()
|
||||
{
|
||||
@@ -157,6 +132,45 @@ void LoadingWindow_MacOSX::SetText( RString str )
|
||||
[s release];
|
||||
}
|
||||
|
||||
void LoadingWindow_MacOSX::SetSplash( const RageSurface *pSplash )
|
||||
{
|
||||
RageFile f;
|
||||
RString data;
|
||||
vector<RString> vs;
|
||||
|
||||
// Try to load a custom splash from the current theme, first.
|
||||
GetDirListing( THEME->GetPathG( "Common", "splash"), vs, false, true );
|
||||
|
||||
// if no Common splash file was found in the theme...
|
||||
if( vs.empty() || !f.Open(vs[0]) )
|
||||
{
|
||||
// then try the stock splash.png from ./Data/
|
||||
GetDirListing( "Data/splash*.png", vs, false, true );
|
||||
}
|
||||
|
||||
if( vs.empty() || !f.Open(vs[0]) )
|
||||
return;
|
||||
f.Read( data );
|
||||
if( data.empty() )
|
||||
return;
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSImage *image = nil;
|
||||
NSData *d = [[NSData alloc] initWithBytes:data.data() length:data.length()];
|
||||
image = [[NSImage alloc] initWithData:d];
|
||||
[d release];
|
||||
if( !image )
|
||||
{
|
||||
[pool release];
|
||||
return;
|
||||
}
|
||||
|
||||
g_Helper = [[LoadingWindowHelper alloc] init];
|
||||
g_Helper->m_Pool = pool;
|
||||
[g_Helper performSelectorOnMainThread:@selector(setupWindow:) withObject:image waitUntilDone:NO];
|
||||
[image release];
|
||||
}
|
||||
|
||||
void LoadingWindow_MacOSX::SetProgress( const int progress )
|
||||
{
|
||||
[g_Helper performSelectorOnMainThread:@selector(setProgress:) withObject:[NSNumber numberWithDouble:(double)progress] waitUntilDone:NO];
|
||||
|
||||
Reference in New Issue
Block a user