2003-02-20 02:29:44 +00:00
|
|
|
#include "global.h"
|
2002-11-18 21:37:58 +00:00
|
|
|
|
2003-02-20 02:29:44 +00:00
|
|
|
#include "SDL_utils.h"
|
2004-05-18 06:31:42 +00:00
|
|
|
#include "RageSurface_Load_XPM.h"
|
2004-01-17 05:21:24 +00:00
|
|
|
#include "SDL_video.h"
|
2003-05-25 20:19:01 +00:00
|
|
|
#include "SDL_rotozoom.h"
|
2002-11-18 21:37:58 +00:00
|
|
|
#include "LoadingWindow_SDL.h"
|
|
|
|
|
#include "loading.xpm"
|
2003-05-25 20:19:01 +00:00
|
|
|
#include "StepMania.xpm" /* icon */
|
2002-11-18 21:37:58 +00:00
|
|
|
|
2004-05-15 22:16:39 +00:00
|
|
|
/* XXX: What is all this Xbox junk doing in LoadingWindow_SDL? */
|
|
|
|
|
|
2002-11-18 21:37:58 +00:00
|
|
|
LoadingWindow_SDL::LoadingWindow_SDL()
|
|
|
|
|
{
|
2004-01-03 09:31:44 +00:00
|
|
|
/* There's no consistent way to hint SDL that we want a centered
|
|
|
|
|
* window. X11 way: */
|
|
|
|
|
#if defined(unix)
|
|
|
|
|
static char center[]="SDL_VIDEO_CENTERED=1";
|
|
|
|
|
putenv( center );
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-11-18 21:37:58 +00:00
|
|
|
/* Initialize the SDL library */
|
|
|
|
|
if( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 )
|
2003-07-27 02:18:05 +00:00
|
|
|
RageException::Throw( "Couldn't initialize SDL: %s", SDL_GetError() );
|
2002-11-18 21:37:58 +00:00
|
|
|
|
2003-05-25 20:19:01 +00:00
|
|
|
/* Set window title and icon */
|
2003-06-16 20:54:10 +00:00
|
|
|
SDL_WM_SetCaption("Loading StepMania", "");
|
2003-05-25 20:19:01 +00:00
|
|
|
|
2004-05-18 06:31:42 +00:00
|
|
|
CString error;
|
|
|
|
|
SDL_Surface *srf = RageSurface_Load_XPM( icon, error );
|
|
|
|
|
|
2004-05-17 04:52:08 +00:00
|
|
|
Uint32 color;
|
|
|
|
|
if( mySDL_MapRGBExact( srf->format, 0xFF, 0, 0xFF, color ) )
|
|
|
|
|
mySDL_AddColorKey( srf, color );
|
2003-05-25 20:19:01 +00:00
|
|
|
|
2003-06-25 02:31:33 +00:00
|
|
|
#if !defined(DARWIN) || !DARWIN
|
|
|
|
|
/* Windows icons are 32x32 and SDL can't resize them for us, which
|
2003-05-25 20:19:01 +00:00
|
|
|
* causes mask corruption. (Actually, the above icon *is* 32x32;
|
|
|
|
|
* this is here just in case it changes.) */
|
|
|
|
|
ConvertSDLSurface(srf, srf->w, srf->h,
|
|
|
|
|
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
|
|
|
|
zoomSurface(srf, 32, 32);
|
|
|
|
|
|
|
|
|
|
SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
|
|
|
|
|
SDL_WM_SetIcon(srf, NULL /* derive from alpha */);
|
|
|
|
|
SDL_FreeSurface(srf);
|
2003-06-25 02:31:33 +00:00
|
|
|
#endif
|
2003-05-25 20:19:01 +00:00
|
|
|
|
|
|
|
|
|
2004-05-18 06:31:42 +00:00
|
|
|
/* Load the BMP - we need its dimensions */
|
|
|
|
|
SDL_Surface *image = RageSurface_Load_XPM( loading, error );
|
2002-11-18 21:37:58 +00:00
|
|
|
if( image == NULL )
|
2003-07-27 02:18:05 +00:00
|
|
|
RageException::Throw("Couldn't load loading.bmp: %s",SDL_GetError());
|
2002-11-18 21:37:58 +00:00
|
|
|
|
2003-11-13 00:39:36 +00:00
|
|
|
|
2003-05-25 20:19:01 +00:00
|
|
|
/* Initialize the window */
|
2002-11-18 21:37:58 +00:00
|
|
|
loading_screen = SDL_SetVideoMode(image->w, image->h, 16, SDL_SWSURFACE|SDL_ANYFORMAT|SDL_NOFRAME);
|
|
|
|
|
if( loading_screen == NULL )
|
2003-07-27 02:18:05 +00:00
|
|
|
RageException::Throw( "Couldn't initialize loading window: %s", SDL_GetError() );
|
2002-11-18 21:37:58 +00:00
|
|
|
|
2003-11-13 00:39:36 +00:00
|
|
|
#ifdef _XBOX
|
|
|
|
|
SDL_XBOX_SetScreenPosition( 70, 48 ) ;
|
|
|
|
|
SDL_XBOX_SetScreenStretch( -150, -300 ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( FAILED ( XFONT_OpenDefaultFont( &m_pConsoleTTF ) ) )
|
|
|
|
|
{
|
|
|
|
|
m_pConsoleTTF = 0 ;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_pConsoleTTF->SetTextHeight( 24 );
|
|
|
|
|
|
|
|
|
|
// Change Font Style - XFONT_NORMAL, XFONT_BOLD,
|
|
|
|
|
// XFONT_ITALICS, XFONT_BOLDITALICS
|
|
|
|
|
m_pConsoleTTF->SetTextStyle( XFONT_NORMAL );
|
|
|
|
|
|
|
|
|
|
// Anti-Alias the font -- 0 for no anti-alias, 2 for some, 4 for MAX!
|
|
|
|
|
m_pConsoleTTF->SetTextAntialiasLevel( 2 );
|
|
|
|
|
m_pConsoleTTF->SetTextColor( 0xFFFFFFFF ) ;
|
|
|
|
|
m_pConsoleTTF->SetBkColor( 0x00000000 ) ;
|
|
|
|
|
m_pConsoleTTF->SetBkMode(XFONT_OPAQUE) ;
|
|
|
|
|
|
|
|
|
|
SetText( CString("Loading Songs" ) ) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-11-18 21:37:58 +00:00
|
|
|
SDL_BlitSurface(image, NULL, loading_screen, NULL);
|
|
|
|
|
|
|
|
|
|
SDL_FreeSurface(image);
|
2003-11-13 00:39:36 +00:00
|
|
|
|
|
|
|
|
SDL_UpdateRect(loading_screen, 0,0,0,0);
|
|
|
|
|
SDL_UpdateRect(loading_screen, 0,0,0,0);
|
2002-11-18 21:37:58 +00:00
|
|
|
}
|
|
|
|
|
|
2003-11-13 00:39:36 +00:00
|
|
|
#ifdef _XBOX
|
|
|
|
|
void LoadingWindow_SDL::SetText(CString str)
|
|
|
|
|
{
|
|
|
|
|
m_cstrText = str ;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-11-18 21:37:58 +00:00
|
|
|
LoadingWindow_SDL::~LoadingWindow_SDL()
|
|
|
|
|
{
|
|
|
|
|
SDL_QuitSubSystem( SDL_INIT_VIDEO );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LoadingWindow_SDL::Paint()
|
|
|
|
|
{
|
2003-11-13 00:39:36 +00:00
|
|
|
#ifdef _XBOX
|
|
|
|
|
LPDIRECT3DSURFACE8 m_primarySurface;
|
|
|
|
|
int x,y ;
|
|
|
|
|
unsigned int val ;
|
|
|
|
|
if ( m_pConsoleTTF )
|
|
|
|
|
{
|
|
|
|
|
WCHAR msg[1000] ;
|
|
|
|
|
swprintf( msg, L"%S", m_cstrText.c_str() ) ;
|
|
|
|
|
|
|
|
|
|
if ( m_pConsoleTTF->GetTextExtent( msg, -1, &val ) != S_OK )
|
|
|
|
|
{
|
|
|
|
|
val = 100 ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x = (640-val)/2 ;
|
|
|
|
|
y = 350 ;
|
|
|
|
|
|
|
|
|
|
D3D__pDevice->GetRenderTarget( &m_primarySurface ) ;
|
|
|
|
|
m_pConsoleTTF->TextOut( m_primarySurface, L" ", -1, (float)0, (float)y ) ;
|
|
|
|
|
m_pConsoleTTF->TextOut( m_primarySurface, msg, wcslen(msg), (float)x, (float)y ) ;
|
|
|
|
|
m_primarySurface->Release() ;
|
|
|
|
|
D3D__pDevice->Present(NULL, NULL, NULL, NULL) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
2002-11-18 21:37:58 +00:00
|
|
|
SDL_UpdateRect(loading_screen, 0,0,0,0);
|
2003-11-13 00:39:36 +00:00
|
|
|
#endif
|
2002-11-18 21:37:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2004-05-15 22:16:39 +00:00
|
|
|
* (c) 2001-2004 Chris Danford, Glenn Maynard
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
2002-11-18 21:37:58 +00:00
|
|
|
*/
|