Missed old commit: Use image in Data/splash.png, fall back on internal splash if it's missing.

This commit is contained in:
Steve Checkoway
2005-12-12 10:02:22 +00:00
parent d62b517636
commit 6aab1a354c
2 changed files with 20 additions and 7 deletions
@@ -4,18 +4,27 @@
#define LOADING_WINDOW_COCOA_H
#include "LoadingWindow.h"
#include "RageFile.h"
extern "C"
{
extern void MakeNewCocoaWindow();
extern void MakeNewCocoaWindow( const void *data, unsigned length );
extern void DisposeOfCocoaWindow();
extern void SetCocoaWindowText(const char *s);
extern void SetCocoaWindowText( const char *s );
}
class LoadingWindow_Cocoa : public LoadingWindow
{
public:
LoadingWindow_Cocoa() { MakeNewCocoaWindow(); }
LoadingWindow_Cocoa()
{
RageFile f;
CString data;
f.Open( "Data/splash.png" );
f.Read( data );
MakeNewCocoaWindow( data.data(), data.length() );
}
~LoadingWindow_Cocoa() { DisposeOfCocoaWindow(); }
void Paint() { } /* Not needed but pure virtual*/
@@ -4,11 +4,15 @@
static NSWindow *window;
static NSTextView *text;
void MakeNewCocoaWindow()
void MakeNewCocoaWindow( const void *data, unsigned length )
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSImage *image = [NSImage imageNamed:@"splash"];
NSImageView *iView;
NSData *d = [NSData dataWithBytes:data length:length];
NSImage *image = [[[NSImage alloc] initWithData:d] autorelease];
if( !image )
image = [NSImage imageNamed:@"splash.png"];
NSView *view;
NSSize size = [image size];
NSRect textRect, viewRect, windowRect;
@@ -23,7 +27,7 @@ void MakeNewCocoaWindow()
[text setAlignment:NSCenterTextAlignment];
viewRect = NSMakeRect(0, height, size.width, height);
iView = [[[NSImageView alloc] initWithFrame:viewRect] autorelease];
NSImageView *iView = [[[NSImageView alloc] initWithFrame:viewRect] autorelease];
[iView setImage:image];
[iView setImageFrameStyle:NSImageFrameNone];