From 278cb4c3f179b8a8529ec8302e85d6f40fbbfed2 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 22 Jul 2003 07:47:27 +0000 Subject: [PATCH] runs on Xbox --- stepmania/src/AnnouncerManager.cpp | 15 +- stepmania/src/BGAnimation.cpp | 4 +- stepmania/src/BGAnimationLayer.cpp | 24 ++- stepmania/src/Background.cpp | 1 + stepmania/src/BannerCache.cpp | 9 +- stepmania/src/Character.cpp | 13 +- stepmania/src/GameConstantsAndTypes.h | 6 +- stepmania/src/GameManager.cpp | 3 - stepmania/src/GameState.cpp | 4 +- stepmania/src/InputMapper.cpp | 95 +++++++----- stepmania/src/LyricsLoader.cpp | 4 +- stepmania/src/Model.cpp | 6 +- stepmania/src/NoteSkinManager.cpp | 7 +- stepmania/src/NotesLoaderKSF.cpp | 2 +- stepmania/src/NotesWriterDWI.cpp | 3 +- stepmania/src/PlayerAI.cpp | 4 +- stepmania/src/PrefsManager.cpp | 10 +- stepmania/src/RageBitmapTexture.cpp | 4 +- stepmania/src/RageDisplay_D3D.cpp | 73 +++++++-- stepmania/src/RageFile.cpp | 51 +++++++ stepmania/src/RageFile.h | 35 +++++ stepmania/src/RageInput.cpp | 5 +- stepmania/src/RageSoundManager.cpp | 5 +- stepmania/src/RageSoundReader_SDL_Sound.cpp | 24 +-- stepmania/src/RageSoundReader_Vorbisfile.cpp | 28 +++- stepmania/src/RageUtil.cpp | 14 +- stepmania/src/RageUtil.h | 5 +- stepmania/src/RageUtil_FileDB.cpp | 50 +++---- stepmania/src/RandomSample.cpp | 10 +- stepmania/src/SDL_utils.cpp | 31 ++-- stepmania/src/ScreenEdit.cpp | 1 + stepmania/src/Song.cpp | 36 ++--- stepmania/src/SongCacheIndex.cpp | 13 +- stepmania/src/SongManager.cpp | 139 ++++++++++-------- stepmania/src/SongManager.h | 5 + stepmania/src/Sprite.cpp | 4 +- stepmania/src/StepMania.cpp | 43 ++++-- stepmania/src/StepMania.h | 1 + stepmania/src/ThemeManager.cpp | 24 +-- stepmania/src/TitleSubstitution.cpp | 9 +- stepmania/src/Transition.cpp | 14 +- .../src/arch/ArchHooks/ArchHooks_Win32.cpp | 1 + .../arch/LowLevelWindow/LowLevelWindow_Null.h | 22 +++ .../src/arch/MovieTexture/MovieTexture.cpp | 2 +- stepmania/src/arch/Sound/DSoundHelpers.cpp | 2 +- .../src/arch/Sound/RageSoundDriver_DSound.cpp | 6 + stepmania/src/arch/arch.cpp | 7 +- stepmania/src/arch/arch.h | 21 ++- stepmania/src/arch/arch_darwin.h | 2 + stepmania/src/arch/arch_default.h | 8 +- stepmania/src/arch/arch_linux.h | 1 + stepmania/src/arch/arch_xbox.h | 6 +- stepmania/src/global.h | 37 +++-- 53 files changed, 631 insertions(+), 318 deletions(-) create mode 100644 stepmania/src/RageFile.cpp create mode 100644 stepmania/src/RageFile.h create mode 100644 stepmania/src/arch/LowLevelWindow/LowLevelWindow_Null.h diff --git a/stepmania/src/AnnouncerManager.cpp b/stepmania/src/AnnouncerManager.cpp index 4e490f3f66..2062640691 100644 --- a/stepmania/src/AnnouncerManager.cpp +++ b/stepmania/src/AnnouncerManager.cpp @@ -12,13 +12,14 @@ #include "AnnouncerManager.h" #include "RageLog.h" +#include "arch/arch.h" AnnouncerManager* ANNOUNCER = NULL; // global object accessable from anywhere in the program const CString EMPTY_ANNOUNCER_NAME = "Empty"; -const CString ANNOUNCERS_DIR = "Announcers/"; +const CString ANNOUNCERS_DIR = BASE_PATH "Announcers" SLASH; /* XXX: move to RageUtil when I feel like spending 20 minutes recompiling */ /* Return true if "dir" is empty or does not exist. */ @@ -69,7 +70,7 @@ bool AnnouncerManager::DoesAnnouncerExist( CString sAnnouncerName ) CString AnnouncerManager::GetAnnouncerDirFromName( CString sAnnouncerName ) { - return ANNOUNCERS_DIR + sAnnouncerName + "/"; + return ANNOUNCERS_DIR + sAnnouncerName + SLASH; } void AnnouncerManager::SwitchAnnouncer( CString sNewAnnouncerName ) @@ -115,8 +116,8 @@ CString AnnouncerManager::GetPathTo( CString sAnnouncerName, CString sFolderName const CString AnnouncerPath = GetAnnouncerDirFromName(sAnnouncerName); - if( !DirectoryIsEmpty(AnnouncerPath+sFolderName+"/") ) - return AnnouncerPath+sFolderName+"/"; + if( !DirectoryIsEmpty(AnnouncerPath+sFolderName+SLASH) ) + return AnnouncerPath+sFolderName+SLASH; /* Search for the announcer folder in the list of aliases. */ int i; @@ -125,14 +126,14 @@ CString AnnouncerManager::GetPathTo( CString sAnnouncerName, CString sFolderName if(sFolderName.CompareNoCase(aliases[i][0])) continue; /* no match */ - if( !DirectoryIsEmpty(AnnouncerPath+aliases[i][1]+"/") ) - return AnnouncerPath+aliases[i][1]+"/"; + if( !DirectoryIsEmpty(AnnouncerPath+aliases[i][1]+SLASH) ) + return AnnouncerPath+aliases[i][1]+SLASH; } /* No announcer directory matched. In debug, create the directory by * its preferred name. */ #ifdef DEBUG - LOG->Trace( "The announcer in \"%s\" is missing the folder '%s'.", + LOG->Trace( "The announcer in '%s' is missing the folder '%s'.", AnnouncerPath.c_str(), sFolderName.c_str() ); // MessageBeep( MB_OK ); CreateDirectories( AnnouncerPath+sFolderName ); diff --git a/stepmania/src/BGAnimation.cpp b/stepmania/src/BGAnimation.cpp index a6f28f292d..4649df0e50 100644 --- a/stepmania/src/BGAnimation.cpp +++ b/stepmania/src/BGAnimation.cpp @@ -52,8 +52,8 @@ void BGAnimation::LoadFromAniDir( CString sAniDir ) { Unload(); - if( !sAniDir.empty() && sAniDir.Right(1) != "/" ) - sAniDir += "/"; + if( !sAniDir.empty() && sAniDir.Right(1) != SLASH ) + sAniDir += SLASH; ASSERT( IsADirectory(sAniDir) ); diff --git a/stepmania/src/BGAnimationLayer.cpp b/stepmania/src/BGAnimationLayer.cpp index 88d432d9e4..ab543e486d 100644 --- a/stepmania/src/BGAnimationLayer.cpp +++ b/stepmania/src/BGAnimationLayer.cpp @@ -28,6 +28,7 @@ #include "ActorUtil.h" #include "arch/ArchHooks/ArchHooks.h" #include "RageTextureManager.h" +#include "RageFile.h" const float PARTICLE_SPEED = 300; @@ -409,7 +410,7 @@ void BGAnimationLayer::LoadFromAniLayerFile( CString sPath ) /* CString sDir, sFName, sExt; splitrelpath( sPath, sDir, sFName, sExt ); - CString sIniPath = sDir+"/"+sFName+".ini"; + CString sIniPath = sDir+SLASH+sFName+".ini"; IniFile ini; ini.SetPath( sIniPath ); if( ini.ReadFile() ) @@ -454,11 +455,12 @@ void BGAnimationLayer::LoadFromAniLayerFile( CString sPath ) } + void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer ) { Init(); - if( sAniDir.Right(1) != "/" ) - sAniDir += "/"; + if( sAniDir.Right(1) != SLASH ) + sAniDir += SLASH; ASSERT( IsADirectory(sAniDir) ); @@ -471,8 +473,12 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer ) CString sFile; ini.GetValue( sLayer, "File", sFile ); + FixSlashesInPlace( sFile ); CString sPath = sAniDir+sFile; + LOG->Trace( "old path is '%s'", sPath.c_str() ); + CollapsePath( sPath ); + LOG->Trace( "new path is '%s'", sPath.c_str() ); if( sFile.CompareNoCase("songbackground")==0 ) { @@ -506,17 +512,21 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer ) GetDirListing( sPath + "*", asElementPaths, false, true ); if(asElementPaths.size() == 0) { + CString sError = ssprintf("In the ini file for BGAnimation '%s', the specified File '%s' does not exist.", sAniDir.c_str(), sFile.c_str()); if( DISPLAY->IsWindowed() ) - HOOKS->MessageBoxOK( ssprintf("In the ini file for BGAnimation '%s', the specified File '%s' does not exist.", sAniDir.c_str(), sFile.c_str()) ); + HOOKS->MessageBoxOK( sError ); + LOG->Warn( sError ); return; } if(asElementPaths.size() > 1) { - if( DISPLAY->IsWindowed() ) - HOOKS->MessageBoxOK( ssprintf( + CString sError = ssprintf( "There is more than one file that matches " "'%s/%s'. Please remove all but one of these matches.", - sAniDir.c_str(), sFile.c_str() ) ); + sAniDir.c_str(), sFile.c_str() ); + if( DISPLAY->IsWindowed() ) + HOOKS->MessageBoxOK( sError ); + LOG->Warn( sError ); } sPath = asElementPaths[0]; } diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 7c49fb0fc4..a6f6d9640a 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -24,6 +24,7 @@ #include "NoteTypes.h" #include // for fmodf #include "DancingCharacters.h" +#include "arch/arch.h" const float FADE_SECONDS = 1.0f; diff --git a/stepmania/src/BannerCache.cpp b/stepmania/src/BannerCache.cpp index f8d8adf7e8..0757044f20 100644 --- a/stepmania/src/BannerCache.cpp +++ b/stepmania/src/BannerCache.cpp @@ -6,6 +6,7 @@ #include "global.h" +#include "arch/arch.h" #include "RageDisplay.h" #include "RageUtil.h" #include "RageLog.h" @@ -19,6 +20,8 @@ #include "Banner.h" +#define CACHE_DIR BASE_PATH "Cache" SLASH + /* Call CacheBanner to cache a banner by path. If the banner is already * cached, it'll be recreated. This is efficient if the banner hasn't changed, * but we still only do this in TidyUpData for songs. @@ -47,7 +50,7 @@ CString BannerCache::GetBannerCachePath( CString BannerPath ) { /* Use GetHashForString, not ForFile, since we don't want to spend time * checking the file size and date. */ - return ssprintf( "Cache/Banners/%u", GetHashForString(BannerPath) ); + return ssprintf( CACHE_DIR "Banners" SLASH "%u", GetHashForString(BannerPath) ); } void BannerCache::LoadBanner( CString BannerPath ) @@ -112,8 +115,8 @@ void BannerCache::UnloadAllBanners() BannerCache::BannerCache() { - CreateDirectories("Cache/Banners/"); - BannerData.SetPath( "Cache/banners.cache" ); + CreateDirectories( CACHE_DIR "Banners" SLASH ); + BannerData.SetPath( CACHE_DIR "banners.cache" ); BannerData.ReadFile(); // don't care if this fails } diff --git a/stepmania/src/Character.cpp b/stepmania/src/Character.cpp index 73e2a321c1..1e6d73da14 100644 --- a/stepmania/src/Character.cpp +++ b/stepmania/src/Character.cpp @@ -13,18 +13,19 @@ #include "Character.h" #include "IniFile.h" #include "RageUtil.h" +#include "arch/arch.h" bool Character::Load( CString sCharDir ) { // Save character directory - if( sCharDir.Right(1)!="/" ) - sCharDir += '/'; + if( sCharDir.Right(1)!=SLASH ) + sCharDir += SLASH; m_sCharDir = sCharDir; // Save character name vector as; - split( sCharDir, "/", as ); + split( sCharDir, SLASH, as ); m_sName = as.back(); // Save attacks @@ -52,9 +53,9 @@ CString GetRandomFileInDir( CString sDir ) CString Character::GetModelPath() { return m_sCharDir + "model.txt"; } -CString Character::GetRestAnimationPath() { return DerefRedir(GetRandomFileInDir(m_sCharDir + "Rest/")); } -CString Character::GetWarmUpAnimationPath() { return DerefRedir(GetRandomFileInDir(m_sCharDir + "WarmUp/")); } -CString Character::GetDanceAnimationPath() { return DerefRedir(GetRandomFileInDir(m_sCharDir + "Dance/")); } +CString Character::GetRestAnimationPath() { return DerefRedir(GetRandomFileInDir(m_sCharDir + "Rest" SLASH)); } +CString Character::GetWarmUpAnimationPath() { return DerefRedir(GetRandomFileInDir(m_sCharDir + "WarmUp" SLASH)); } +CString Character::GetDanceAnimationPath() { return DerefRedir(GetRandomFileInDir(m_sCharDir + "Dance" SLASH)); } CString Character::GetTakingABreakPath() { CStringArray as; diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index 000fb4b5d3..50c5cbc641 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -237,9 +237,9 @@ const int NUM_ATTACKS_PER_LEVEL = 3; const int ITEM_NONE = -1; -#define BG_ANIMS_DIR CString("BGAnimations/") -#define VISUALIZATIONS_DIR CString("Visualizations/") -#define RANDOMMOVIES_DIR CString("RandomMovies/") +#define BG_ANIMS_DIR CString(BASE_PATH "BGAnimations" SLASH) +#define VISUALIZATIONS_DIR CString(BASE_PATH "Visualizations" SLASH) +#define RANDOMMOVIES_DIR CString(BASE_PATH "RandomMovies" SLASH) diff --git a/stepmania/src/GameManager.cpp b/stepmania/src/GameManager.cpp index a9c15f21f0..f4ef94e675 100644 --- a/stepmania/src/GameManager.cpp +++ b/stepmania/src/GameManager.cpp @@ -25,9 +25,6 @@ GameManager* GAMEMAN = NULL; // global and accessable from anywhere in our program -const CString NOTESKIN_DIR = "NoteSkins/"; - - const int DANCE_COL_SPACING = 64; const int DANCE_6PANEL_VERSUS_COL_SPACING = 54; const int PUMP_COL_SPACING = 50; diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index e259b6b6a5..c6ebd8a461 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -27,10 +27,12 @@ #include "Character.h" #include "UnlockSystem.h" #include "AnnouncerManager.h" +#include "arch/arch.h" GameState* GAMESTATE = NULL; // global and accessable from anywhere in our program +#define CHARACTERS_DIR BASE_PATH "Characters" SLASH GameState::GameState() { @@ -163,7 +165,7 @@ void GameState::ReloadCharacters() m_pCurCharacters[p] = NULL; CStringArray as; - GetDirListing( "Characters/*", as, true, true ); + GetDirListing( CHARACTERS_DIR "*", as, true, true ); for( i=0; iWarn( "could not input mapping file \"Keymaps.ini\"." ); + LOG->Warn( "could not input mapping file '%s'.", KEYMAPS_PATH ); const IniFile::key *Key = ini.GetKey( GAMESTATE->GetCurrentGameDef()->m_szName ); @@ -247,7 +270,7 @@ void InputMapper::ReadMappingsFromDisk() void InputMapper::SaveMappingsToDisk() { IniFile ini; - ini.SetPath( "Data/Keymaps.ini" ); + ini.SetPath( KEYMAPS_PATH ); ini.ReadFile(); // erase the key so that we overwrite everything for this game diff --git a/stepmania/src/LyricsLoader.cpp b/stepmania/src/LyricsLoader.cpp index 0c186e0bf2..a9e5819d83 100644 --- a/stepmania/src/LyricsLoader.cpp +++ b/stepmania/src/LyricsLoader.cpp @@ -8,7 +8,7 @@ #include "RageUtil.h" #include "LyricsLoader.h" -#include +#include "RageFile.h" #include using namespace std; @@ -21,7 +21,7 @@ bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out ) { LOG->Trace( "LyricsLoader::LoadFromLRCFile(%s)", sPath.c_str() ); - ifstream input(sPath); + Rageifstream input(sPath); if(input.bad()) { LOG->Warn( "Error opening file '%s' for reading.", sPath.c_str() ); diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index 022a721cc9..854470d81c 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -16,7 +16,7 @@ #include "RageUtil.h" #include "RageTextureManager.h" #include "IniFile.h" - +#include "RageFile.h" const float FRAMES_PER_SECOND = 30; const CString DEFAULT_ANIMATION_NAME = "default"; @@ -77,7 +77,7 @@ bool Model::LoadMilkshapeAscii( CString sPath ) CString sDir, sThrowAway; splitrelpath( sPath, sDir, sThrowAway, sThrowAway ); - FILE *file = fopen (sPath, "rt"); + FILE *file = Ragefopen (sPath, "rt"); if (!file) RageException::Throw( "Model::LoadMilkshapeAscii Could not open '%s'.", sPath.c_str() ); @@ -438,7 +438,7 @@ bool Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath ) CString sDir, sThrowAway; splitrelpath( sPath, sDir, sThrowAway, sThrowAway ); - FILE *file = fopen (sPath, "rt"); + FILE *file = Ragefopen (sPath, "rt"); if (!file) RageException::Throw( "Model:: Could not open '%s'.", sPath.c_str() ); diff --git a/stepmania/src/NoteSkinManager.cpp b/stepmania/src/NoteSkinManager.cpp index 19a2c1ba65..4c15c596e9 100644 --- a/stepmania/src/NoteSkinManager.cpp +++ b/stepmania/src/NoteSkinManager.cpp @@ -19,13 +19,14 @@ #include "StyleDef.h" #include "RageUtil.h" #include "GameManager.h" +#include "arch/arch.h" NoteSkinManager* NOTESKIN = NULL; // global object accessable from anywhere in the program const CString BASE_NOTESKIN_NAME = "default"; -const CString NOTESKINS_DIR = "NoteSkins/"; +const CString NOTESKINS_DIR = BASE_PATH "NoteSkins" SLASH; NoteSkinManager::NoteSkinManager() { @@ -39,7 +40,7 @@ void NoteSkinManager::RefreshNoteSkinData( Game game ) { GameDef* pGameDef = GAMEMAN->GetGameDefForGame( game ); - CString sBaseSkinFolder = NOTESKINS_DIR + pGameDef->m_szName + "/"; + CString sBaseSkinFolder = NOTESKINS_DIR + pGameDef->m_szName + SLASH; CStringArray asNoteSkinNames; GetDirListing( sBaseSkinFolder + "*", asNoteSkinNames, true ); @@ -112,7 +113,7 @@ CString NoteSkinManager::GetNoteSkinDir( CString sSkinName ) { const GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); - return NOTESKINS_DIR + ssprintf("%s/%s/", pGameDef->m_szName, sSkinName.c_str()); + return NOTESKINS_DIR + pGameDef->m_szName + SLASH + sSkinName + SLASH; } CString NoteSkinManager::GetMetric( PlayerNumber pn, CString sButtonName, CString sValue ) // looks in GAMESTATE for the current Style diff --git a/stepmania/src/NotesLoaderKSF.cpp b/stepmania/src/NotesLoaderKSF.cpp index e578a4b7a6..c7b0a2fa21 100644 --- a/stepmania/src/NotesLoaderKSF.cpp +++ b/stepmania/src/NotesLoaderKSF.cpp @@ -303,7 +303,7 @@ bool KSFLoader::LoadGlobalData( const CString &sPath, Song &out ) /* Try to fill in missing bits of information from the pathname. */ { CStringArray asBits; - split( sPath, "/", asBits, true); + split( sPath, SLASH, asBits, true); ASSERT(asBits.size() > 1); LoadTags(asBits[asBits.size()-2], out); diff --git a/stepmania/src/NotesWriterDWI.cpp b/stepmania/src/NotesWriterDWI.cpp index c98342bab7..cdf3da2972 100644 --- a/stepmania/src/NotesWriterDWI.cpp +++ b/stepmania/src/NotesWriterDWI.cpp @@ -4,6 +4,7 @@ #include "NoteData.h" #include "RageUtil.h" #include "RageLog.h" +#include "RageFile.h" /* Output is an angle bracket expression without angle brackets, eg. "468". */ CString NotesWriterDWI::NotesToDWIString( const TapNote cNoteCols[6] ) @@ -321,7 +322,7 @@ bool NotesWriterDWI::WriteDWINotesTag( FILE* fp, const Notes &out ) bool NotesWriterDWI::Write( CString sPath, const Song &out ) { - FILE* fp = fopen( sPath, "w" ); + FILE* fp = Ragefopen( sPath, "w" ); if( fp == NULL ) RageException::Throw( "Error opening song file '%s' for writing.", sPath.c_str() ); diff --git a/stepmania/src/PlayerAI.cpp b/stepmania/src/PlayerAI.cpp index 3708f7c255..36283086cd 100644 --- a/stepmania/src/PlayerAI.cpp +++ b/stepmania/src/PlayerAI.cpp @@ -16,7 +16,9 @@ #include "RageException.h" #include "GameState.h" #include +#include "arch/arch.h" +#define AI_PATH BASE_PATH "Data" SLASH "AI.ini" struct TapScoreDistribution { @@ -44,7 +46,7 @@ TapScoreDistribution g_Distributions[NUM_SKILL_LEVELS]; void PlayerAI::InitFromDisk() { IniFile ini; - ini.SetPath( "Data/AI.ini" ); + ini.SetPath( AI_PATH ); ini.ReadFile(); for( int i=0; iGetCurrentGameDef()->m_szName; IniFile ini; - ini.SetPath( "Data/GamePrefs.ini" ); + ini.SetPath( GAMEPREFS_INI_PATH ); ini.ReadFile(); // it's OK if this fails CString sAnnouncer = sGameName, sTheme = sGameName, sNoteSkin = sGameName; @@ -378,7 +380,7 @@ void PrefsManager::SaveGamePrefsToDisk() CString sGameName = GAMESTATE->GetCurrentGameDef()->m_szName; IniFile ini; - ini.SetPath( "Data/GamePrefs.ini" ); + ini.SetPath( GAMEPREFS_INI_PATH ); ini.ReadFile(); // it's OK if this fails ini.SetValue( sGameName, "Announcer", ANNOUNCER->GetCurAnnouncerName() ); diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index 1a0d0899bb..68b17623e9 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -84,7 +84,6 @@ void RageBitmapTexture::Create() /* Load the image into an SDL surface. */ SDL_Surface *img = IMG_Load( GetID().filename ); - /* XXX: Wait, we don't want to throw for all images; in particular, we * want to tolerate corrupt/unknown background images. */ if(img == NULL) @@ -257,6 +256,7 @@ apply_color_key: // texturePixfmt = FMT_ALPHA8; // } + /* It's either not a paletted image, or we can't handle paletted textures. * Convert to the desired RGBA format, dithering if appropriate. */ if( actualID.bDither && @@ -286,7 +286,7 @@ apply_color_key: if( !DISPLAY->SupportsTextureFormat(pixfmt) ) pixfmt = FMT_RGBA4; } - + /* Convert the data to the destination format and dimensions * required by OpenGL if it's not in it already. */ diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index e0bbeffd41..46b384ce59 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -169,12 +169,21 @@ static const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = { 0x001F, 0x0000 }, }, { +#if defined _XBOX + /* A8B8G8R8 */ + 32, + { 0x00FF0000, + 0x0000FF00, + 0x000000FF, + 0xFF000000 } +#else /* B8G8R8 */ 24, { 0xFF0000, 0x00FF00, 0x0000FF, 0x000000 } +#endif }, { /* Paletted */ 8, @@ -194,10 +203,10 @@ static D3DFORMAT D3DFORMATS[NUM_PIX_FORMATS] = D3DFMT_A4R4G4B4, D3DFMT_A1R5G5B5, D3DFMT_X1R5G5B5, -#ifndef _XBOX - D3DFMT_R8G8B8, -#else +#if defined _XBOX D3DFMT_A8R8G8B8, +#else + D3DFMT_R8G8B8, #endif D3DFMT_P8, D3DFMT_UNKNOWN, /* no BGR */ @@ -258,6 +267,7 @@ RageDisplay_D3D::RageDisplay_D3D( VideoModeParams p ) * actually initialize the window. Do this after as many error conditions * as possible, because if we have to shut it down again we'll flash a window * briefly. */ +//#if defined _WINDOWS if(!SDL_WasInit(SDL_INIT_VIDEO)) { if( SDL_InitSubSystem(SDL_INIT_VIDEO) == -1 ) @@ -272,6 +282,7 @@ RageDisplay_D3D::RageDisplay_D3D( VideoModeParams p ) * of the SDL video system--it'll be reinitialized on us if we do this first. */ SDL_EventState(0xFF /*SDL_ALLEVENTS*/, SDL_IGNORE); SDL_EventState(SDL_VIDEORESIZE, SDL_ENABLE); +//#endif g_PaletteIndex.clear(); for( int i = 0; i < 256; ++i ) @@ -280,17 +291,21 @@ RageDisplay_D3D::RageDisplay_D3D( VideoModeParams p ) // Save the original desktop format. g_pd3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &g_DesktopMode ); +#if defined _WINDOWS // Create the SDL window int flags = SDL_RESIZABLE | SDL_SWSURFACE; SDL_Surface *screen = SDL_SetVideoMode(p.width, p.height, p.bpp, flags); if(!screen) RageException::Throw("SDL_SetVideoMode failed: %s", SDL_GetError()); +#endif SetVideoMode( p ); } catch(...) { // Clean up; ~RageDisplay will not be called. +#if defined _WINDOWS if( SDL_WasInit(SDL_INIT_VIDEO) ) SDL_QuitSubSystem(SDL_INIT_VIDEO); +#endif if( g_pd3d ) { @@ -311,6 +326,7 @@ RageDisplay_D3D::RageDisplay_D3D( VideoModeParams p ) void RageDisplay_D3D::Update(float fDeltaTime) { +#if defined _WINDOWS SDL_Event event; while(SDL_GetEvent(event, SDL_VIDEORESIZEMASK)) { @@ -325,6 +341,7 @@ void RageDisplay_D3D::Update(float fDeltaTime) break; } } +#endif } bool RageDisplay_D3D::IsSoftwareRenderer() @@ -336,8 +353,10 @@ RageDisplay_D3D::~RageDisplay_D3D() { LOG->Trace( "RageDisplay_D3D::~RageDisplay()" ); +#if defined _WINDOWS SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE); SDL_QuitSubSystem(SDL_INIT_VIDEO); +#endif g_pd3dDevice->Release(); g_pd3d->Release(); @@ -367,7 +386,9 @@ D3DFORMAT FindBackBufferType(bool bWindowed, int iBPP) } if( !bWindowed && iBPP != 16 && iBPP != 32 ) { +#if defined _WINDOWS SDL_QuitSubSystem(SDL_INIT_VIDEO); // exit out of full screen. The ~RageDisplay will not be called! +#endif throw RageException( ssprintf("Invalid BPP '%u' specified", iBPP) ); } @@ -400,7 +421,7 @@ D3DFORMAT FindBackBufferType(bool bWindowed, int iBPP) return (D3DFORMAT)-1; } -#ifndef _XBOX +#if defined _WINDOWS HWND GetHwnd() { SDL_SysWMinfo info; @@ -425,6 +446,7 @@ bool RageDisplay_D3D::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) if( FindBackBufferType( p.windowed, p.bpp ) == -1 ) // no possible back buffer formats return false; // failed to set mode +#if defined _WINDOWS /* Set SDL window title and icon -before- creating the window */ SDL_WM_SetCaption( p.sWindowTitle, "" ); mySDL_WM_SetIcon( p.sIconFile ); @@ -436,6 +458,7 @@ bool RageDisplay_D3D::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) // SDL window only if we're not fullscreen. SDL_ShowCursor( p.windowed ); +#endif ZeroMemory( &g_d3dpp, sizeof(g_d3dpp) ); g_d3dpp.BackBufferWidth = p.width; @@ -481,7 +504,9 @@ bool RageDisplay_D3D::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) &g_pd3dDevice ); if( FAILED(hr) ) { +#if defined _WINDOWS SDL_QuitSubSystem(SDL_INIT_VIDEO); // exit out of full screen. The ~RageDisplay will not be called! +#endif RageException::Throw( "CreateDevice failed: '%s'", GetErrorString(hr).c_str() ); } } @@ -491,13 +516,16 @@ bool RageDisplay_D3D::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) hr = g_pd3dDevice->Reset( &g_d3dpp ); if( FAILED(hr) ) { +#if defined _WINDOWS SDL_QuitSubSystem(SDL_INIT_VIDEO); // exit out of full screen. The ~RageDisplay will not be called! +#endif RageException::Throw( "g_pd3dDevice->Reset failed: '%s'", GetErrorString(hr).c_str() ); } } if( p.windowed ) { +#if defined _WINDOWS int flags = SDL_RESIZABLE | SDL_SWSURFACE; // Don't use SDL to change the video mode. This will cause a @@ -513,6 +541,7 @@ bool RageDisplay_D3D::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) SDL_QuitSubSystem(SDL_INIT_VIDEO); // exit out of full screen. The ~RageDisplay will not be called! RageException::Throw("SDL_SetVideoMode failed: %s", SDL_GetError()); } +#endif } ResolutionChanged(); @@ -572,6 +601,15 @@ void RageDisplay_D3D::EndFrame() bool RageDisplay_D3D::SupportsTextureFormat( PixelFormat pixfmt ) { +#if defined _XBOX + // Lazy... Xbox handles paletted textures completely differently + // than D3D and I don't want to add a bunch of code for it. Also, + // paletted textures result in worse cache efficiency (see "Xbox + // Palettized Texture Performance" in XDK). So, we'll force 32bit + // ARGB textures. -Chris + return pixfmt == FMT_RGBA8; +#endif + // Some cards (Savage) don't support alpha in palettes. // Don't allow paletted textures if this is the case. if( pixfmt == FMT_PAL && !(g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) ) @@ -969,12 +1007,28 @@ void RageDisplay_D3D::UpdateTexture( ASSERT( xoffset+width <= int(desc.Width) ); ASSERT( yoffset+height <= int(desc.Height) ); + // + // Copy bits + // +#if _XBOX + // Xbox textures need to be swizzled + XGSwizzleRect( + img->pixels, // pSource, + img->pitch, // Pitch, + NULL, // pRect, + lr.pBits, // pDest, + img->w, // Width, + img->h, // Height, + NULL, // pPoint, + img->format->BytesPerPixel ); //BytesPerPixel +#else int texpixfmt; for(texpixfmt = 0; texpixfmt < NUM_PIX_FORMATS; ++texpixfmt) if(D3DFORMATS[texpixfmt] == desc.Format) break; ASSERT( texpixfmt != NUM_PIX_FORMATS ); SDL_Surface *Texture = CreateSurfaceFromPixfmt(PixelFormat(texpixfmt), lr.pBits, width, height, lr.Pitch); + ASSERT( Texture ); SDL_Rect area; area.x = area.y = 0; area.w = (Uint16) width; @@ -985,17 +1039,8 @@ void RageDisplay_D3D::UpdateTexture( mySDL_BlitSurface( img, Texture, width, height, false ); SDL_FreeSurface( Texture ); - -#if 0 - // copy each row - int bytes_per_pixel = img->format->BytesPerPixel; - for( int y=rect.top; ypixels + y*img->pitch + rect.left*bytes_per_pixel; - char* dst = (char*)lr.pBits + y*lr.Pitch + rect.left*bytes_per_pixel; - memcpy( dst, src, (rect.right-rect.left)*bytes_per_pixel ); - } #endif + pTex->UnlockRect( 0 ); } diff --git a/stepmania/src/RageFile.cpp b/stepmania/src/RageFile.cpp new file mode 100644 index 0000000000..e5290af371 --- /dev/null +++ b/stepmania/src/RageFile.cpp @@ -0,0 +1,51 @@ +#include "global.h" +/* +----------------------------------------------------------------------------- + Class: RageFile + + Desc: See header. + + Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "RageFile.h" +#include "RageUtil.h" + + +void FixSlashesInPlace( CString &sPath ) +{ + sPath.Replace( "/", SLASH ); + sPath.Replace( "\\", SLASH ); +} + +CString FixSlashes( CString sPath ) +{ + sPath.Replace( "/", SLASH ); + sPath.Replace( "\\", SLASH ); + return sPath; +} + +void CollapsePath( CString &sPath ) +{ + CStringArray as; + split( sPath, SLASH, as ); + + for( unsigned i=0; i +using namespace std; // using "std::ifstream" causes problems below in VC6. Why?!? + +void FixSlashesInPlace( CString &sPath ); +CString FixSlashes( CString sPath ); + +void CollapsePath( CString &sPath ); + +FILE* Ragefopen( const char *szPath, const char *szMode ); + +// replacement for ifstream +class Rageifstream : public std::ifstream +{ +public: + Rageifstream() {}; + Rageifstream( const char *szPath ) : ifstream(FixSlashes(szPath)) {} + void open( const char *szPath ) { ifstream::open(FixSlashes(szPath)); } +}; + + +#endif diff --git a/stepmania/src/RageInput.cpp b/stepmania/src/RageInput.cpp index e98e1c258d..6c581fe143 100644 --- a/stepmania/src/RageInput.cpp +++ b/stepmania/src/RageInput.cpp @@ -27,8 +27,9 @@ RageInput::RageInput() /* If no input devices are loaded, the user won't be able to input anything. * That should never happen. */ - if(Devices.size() == 0) - RageException::Throw("No input devices were loaded. This shouldn't happen; please file a bug."); + /* Temporarily commented out until Xbox is working. -Chris */ +// if(Devices.size() == 0) +// RageException::Throw("No input devices were loaded. This shouldn't happen; please file a bug."); } RageInput::~RageInput() diff --git a/stepmania/src/RageSoundManager.cpp b/stepmania/src/RageSoundManager.cpp index 19fe30284b..f828b1f759 100644 --- a/stepmania/src/RageSoundManager.cpp +++ b/stepmania/src/RageSoundManager.cpp @@ -215,9 +215,8 @@ void RageSoundManager::PlayOnceFromDir( CString sDir ) return; // make sure there's a slash at the end of this path - sDir.Replace("\\", "/"); - if( sDir[sDir.GetLength()-1] != '/' ) - sDir += "/"; + if( sDir.Right(1) != SLASH ) + sDir += SLASH; CStringArray arraySoundFiles; GetDirListing( sDir + "*.mp3", arraySoundFiles ); diff --git a/stepmania/src/RageSoundReader_SDL_Sound.cpp b/stepmania/src/RageSoundReader_SDL_Sound.cpp index 22bc02e94b..9a350cbad6 100644 --- a/stepmania/src/RageSoundReader_SDL_Sound.cpp +++ b/stepmania/src/RageSoundReader_SDL_Sound.cpp @@ -6,19 +6,23 @@ * something wrong with my SDL_sound MAD wrapper ... */ -#ifdef WIN32 - -#ifdef DEBUG -#pragma comment(lib, "SDL_sound-1.0.0/lib/sdl_sound_static_d.lib") +#ifdef _XBOX +// #ifdef DEBUG +// #pragma comment(lib, "SDL_sound-1.0.0/lib/xbox_sdl_sound_static_d.lib") +// #else + #pragma comment(lib, "SDL_sound-1.0.0/lib/xbox_sdl_sound_static.lib") +// #endif #else -#pragma comment(lib, "SDL_sound-1.0.0/lib/sdl_sound_static.lib") + #ifdef DEBUG + #pragma comment(lib, "SDL_sound-1.0.0/lib/sdl_sound_static_d.lib") + #else + #pragma comment(lib, "SDL_sound-1.0.0/lib/sdl_sound_static.lib") + #endif + #pragma comment(lib, "SDL_sound-1.0.0/lib/ogg_static.lib") + #pragma comment(lib, "SDL_sound-1.0.0/lib/vorbis_static.lib") + #pragma comment(lib, "SDL_sound-1.0.0/lib/vorbisfile_static.lib") #endif -#pragma comment(lib, "SDL_sound-1.0.0/lib/ogg_static.lib") -#pragma comment(lib, "SDL_sound-1.0.0/lib/vorbis_static.lib") -#pragma comment(lib, "SDL_sound-1.0.0/lib/vorbisfile_static.lib") - -#endif #include "RageSoundReader_SDL_Sound.h" diff --git a/stepmania/src/RageSoundReader_Vorbisfile.cpp b/stepmania/src/RageSoundReader_Vorbisfile.cpp index e41786c8c0..8ffbce5937 100644 --- a/stepmania/src/RageSoundReader_Vorbisfile.cpp +++ b/stepmania/src/RageSoundReader_Vorbisfile.cpp @@ -5,10 +5,29 @@ #include "RageUtil.h" #include "SDL_utils.h" #include "RageSoundReader_Vorbisfile.h" + +#ifdef _XBOX +#include "vorbis/vorbisfile.h" +#else #include "tremor/ivorbisfile.h" +#endif + +#if defined _XBOX +#pragma comment(lib, "SDL_sound-1.0.0/lib/xbox_ogg_static.lib") +#pragma comment(lib, "SDL_sound-1.0.0/lib/xbox_vorbis_static.lib") +#pragma comment(lib, "SDL_sound-1.0.0/lib/xbox_vorbisfile_static.lib") +#elif defined _WINDOWS +#pragma comment(lib, "SDL_sound-1.0.0/lib/ogg_static.lib") +#pragma comment(lib, "SDL_sound-1.0.0/lib/vorbis_static.lib") +#pragma comment(lib, "SDL_sound-1.0.0/lib/vorbisfile_static.lib") +#endif #include -#include +#include "RageFile.h" + +/* What is this file, and why is it needed? Seems to compile on + * Win32 w/o it. -Chris */ +//#include const int channels = 2; @@ -21,7 +40,7 @@ bool RageSoundReader_Vorbisfile::Open(CString filename_) filename=filename_; vf = new OggVorbis_File; - FILE *f = fopen(filename, "r"); + FILE *f = Ragefopen(filename, "r"); if(f == NULL) { SetError(ssprintf("ogg fopen(%s) failed: %s", filename.c_str(), strerror(errno))); @@ -81,7 +100,12 @@ int RageSoundReader_Vorbisfile::Read(char *buf, unsigned len) char tmpbuf[4096]; int bstream; +#ifdef _XBOX // float vorbis decoder + int ret = ov_read(vf, tmpbuf, sizeof(tmpbuf), 0, 2, 1, &bstream); +#else // integer vorbis decoder int ret = ov_read(vf, tmpbuf, sizeof(tmpbuf), &bstream); +#endif + //int ret = 4096; //memset(tmpbuf, 0, sizeof(tmpbuf)); if(ret == OV_HOLE) diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 715bd9431d..d9b536a245 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -13,11 +13,12 @@ #include "RageUtil.h" #include "RageUtil_FileDB.h" #include "RageLog.h" +#include "arch/arch.h" #include #include #include -#include +#include "RageFile.h" #include #include #include @@ -298,12 +299,11 @@ bool CreateDirectories( CString Path ) { CStringArray parts; CString curpath; - Path.Replace("\\", "/"); - split(Path, "/", parts); + split(Path, SLASH, parts); for(unsigned i = 0; i < parts.size(); ++i) { - curpath += parts[i] + "/"; + curpath += parts[i] + SLASH; if(mkdir( curpath, 0755 )) continue; @@ -404,7 +404,7 @@ unsigned int GetHashForDirectory( CString sDir ) hash += GetHashForFile( sDir ); CStringArray arrayFiles; - GetDirListing( sDir+"/*", arrayFiles, false ); + GetDirListing( sDir+"*", arrayFiles, false ); for( unsigned i=0; iRelease(); (p)=NULL; } } -#define ZERO(x) memset(&x, 0, sizeof(x)) -#define COPY(a,b) { ASSERT(sizeof(a)==sizeof(b)); memcpy(&a, &b, sizeof(a)); } +#define ZERO(x) memset(&x, 0, sizeof(x)) +#define COPY(a,b) { ASSERT(sizeof(a)==sizeof(b)); memcpy(&a, &b, sizeof(a)); } +#define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0])) /* Common harmless mismatches. All min(T,T) and max(T,T) cases are handled * by the generic template we get from . */ diff --git a/stepmania/src/RageUtil_FileDB.cpp b/stepmania/src/RageUtil_FileDB.cpp index 4029a6c573..0bcb2d5401 100644 --- a/stepmania/src/RageUtil_FileDB.cpp +++ b/stepmania/src/RageUtil_FileDB.cpp @@ -9,19 +9,13 @@ #include #include #include +#include +#include "arch/arch.h" #if !defined(WIN32) #include #endif -static void GetCwd(CString &s) -{ - char buf[PATH_MAX]; - bool ret = getcwd(buf, PATH_MAX) != NULL; - ASSERT(ret); - - s = buf; -} struct File { istring name; @@ -59,19 +53,12 @@ void FileSet::LoadFromDir(const CString &dir) age.GetDeltaTime(); /* reset */ files.clear(); - CString oldpath; - GetCwd(oldpath); - if(chdir(dir) == -1) return; - #if defined(WIN32) WIN32_FIND_DATA fd; - HANDLE hFind = FindFirstFile( "*", &fd ); + HANDLE hFind = FindFirstFile( dir+SLASH "*", &fd ); if( hFind == INVALID_HANDLE_VALUE ) - { - chdir(oldpath); return; - } do { if(!strcmp(fd.cFileName, ".") || !strcmp(fd.cFileName, "..")) @@ -85,7 +72,7 @@ void FileSet::LoadFromDir(const CString &dir) } while( FindNextFile( hFind, &fd ) ); FindClose(hFind); #else - DIR *d = opendir("."); + DIR *d = opendir(dir+"/."); while(struct dirent *ent = readdir(d)) { @@ -116,7 +103,6 @@ void FileSet::LoadFromDir(const CString &dir) closedir(d); #endif - chdir(oldpath); } /* Search for "beginning*containing*ending". */ @@ -195,7 +181,7 @@ static void SplitPath( CString Path, CString &Dir, CString &Name ) Name = match[1]; } else { /* No slash. */ - Dir = "./"; + Dir = "." SLASH; Name = Path; } } @@ -261,18 +247,16 @@ bool FilenameDB::ResolvePath(CString &path) if(path == ".") return true; if(path == "") return true; - path.Replace("\\", "/"); - /* Split path into components. */ vector p; - split(path, "/", p, true); + split(path, SLASH, p, true); /* Resolve each component. Assume the first component is correct. XXX * don't do that! "Songs/" vs "songs/" */ CString ret = p[0]; for(unsigned i = 1; i < p.size(); ++i) { - ret += "/"; + ret += SLASH; vector lst; FileSet &fs = GetFileSet(ret.c_str()); @@ -282,14 +266,14 @@ bool FilenameDB::ResolvePath(CString &path) if(lst.empty()) return false; if(lst.size() > 1) - LOG->Warn("Ambiguous filenames \"%s\" and \"%s\"", + LOG->Warn("Ambiguous filenames '%s' and '%s'", lst[0].c_str(), lst[1].c_str()); ret += lst[0]; } - if(path[path.size()-1] == '/') - path = ret + "/"; + if(path.Right(1) == SLASH) + path = ret + SLASH; else path = ret; return true; @@ -335,8 +319,9 @@ void FilenameDB::GetFilesSimpleMatch(const CString &dir, const CString &fn, vect FileSet &FilenameDB::GetFileSet(CString dir, bool ResolveCase) { /* Normalize the path. */ - dir.Replace("\\", "/"); /* foo\bar -> foo/bar */ - dir.Replace("//", "/"); /* foo//bar -> foo/bar */ + dir.Replace("\\", SLASH); /* foo\bar -> foo/bar */ + dir.Replace("/", SLASH); /* foo//bar -> foo/bar */ + dir.Replace("//", SLASH); /* foo//bar -> foo/bar */ FileSet *ret; map::iterator i = dirs.find(dir.c_str()); @@ -381,6 +366,8 @@ FilenameDB FDB; void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bReturnPathToo ) { +// LOG->Trace( "GetDirListing( %s )", sPath.c_str() ); + /* If you want the CWD, use ".". */ ASSERT(!sPath.empty()); @@ -389,7 +376,7 @@ void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bRe * prepend "./" */ /* Strip off the last path element and use it as a mask. */ - unsigned pos = sPath.find_last_of("/\\"); + unsigned pos = sPath.find_last_of( SLASH ); CString fn; if(pos != sPath.npos) { @@ -414,6 +401,11 @@ void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bRe start++; } } + +// LOG->Trace( "dir is '%s'", sPath.c_str() ); +// LOG->Trace( "Found:" ); +// for( unsigned i=0; iTrace( AddTo[i] ); } bool ResolvePath(CString &path) { return FDB.ResolvePath(path); } diff --git a/stepmania/src/RandomSample.cpp b/stepmania/src/RandomSample.cpp index 6b83d13172..5bce2e1a09 100644 --- a/stepmania/src/RandomSample.cpp +++ b/stepmania/src/RandomSample.cpp @@ -52,20 +52,18 @@ bool RandomSample::LoadSoundDir( CString sDir, int iMaxToLoad ) if( sDir == "" ) return true; - sDir.Replace("\\", "/"); - #if 0 /* (don't want to do this just yet) */ /* If this is actually a directory, add a backslash to the filename, * so we'll look for eg. themes\Default\sounds\sDir\*.mp3. Otherwise, * don't, so we'll look for all of the files starting with sDir, * eg. themes\Default\sounds\sDir*.mp3. */ - if(IsADirectory(sDir) && sDir[sDir.GetLength()-1] != '/' ) - sDir += "/"; + if(IsADirectory(sDir) && sDir[sDir.GetLength()-1] != SLASH ) + sDir += SLASH; #else // make sure there's a slash at the end of this path - if( sDir[sDir.GetLength()-1] != '/' ) - sDir += "/"; + if( sDir.Right(1) != SLASH ) + sDir += SLASH; #endif CStringArray arraySoundFiles; diff --git a/stepmania/src/SDL_utils.cpp b/stepmania/src/SDL_utils.cpp index 0796197957..daf5ae85a3 100644 --- a/stepmania/src/SDL_utils.cpp +++ b/stepmania/src/SDL_utils.cpp @@ -12,21 +12,28 @@ #include "SDL.h" #include "SDL_utils.h" #include "SDL_endian.h" - -#if defined(WIN32) +#include "RageFile.h" /* Pull in all of our SDL libraries here. */ -#ifdef DEBUG -#pragma comment(lib, "SDL-1.2.5/lib/SDLd.lib") -#pragma comment(lib, "SDL_image-1.2/SDL_imaged.lib") -#else -#pragma comment(lib, "SDL-1.2.5/lib/SDL.lib") -#pragma comment(lib, "SDL_image-1.2/SDL_image.lib") +#ifdef _XBOX + #ifdef DEBUG + #pragma comment(lib, "SDLx-0.02/SDLxd.lib") + #pragma comment(lib, "SDL_image-1.2/xbox_SDL_imaged.lib") + #else + #pragma comment(lib, "SDLx-0.02/SDLx.lib") + #pragma comment(lib, "SDL_image-1.2/xbox_SDL_image.lib") + #endif +#elif defined _WINDOWS + #ifdef DEBUG + #pragma comment(lib, "SDL-1.2.5/lib/SDLd.lib") + #pragma comment(lib, "SDL_image-1.2/SDL_imaged.lib") + #else + #pragma comment(lib, "SDL-1.2.5/lib/SDL.lib") + #pragma comment(lib, "SDL_image-1.2/SDL_image.lib") + #endif #endif -#endif - Uint32 mySDL_Swap24(Uint32 x) { return SDL_Swap32(x) >> 8; // xx223344 -> 443322xx -> 00443322 @@ -598,7 +605,7 @@ struct SurfaceHeader /* Save and load SDL_Surfaces to disk. This avoids problems with bitmaps. */ bool mySDL_SaveSurface( SDL_Surface *img, CString file ) { - FILE *f = fopen(file.c_str(), "wb+"); + FILE *f = Ragefopen(file.c_str(), "wb+"); if(f == NULL) return false; @@ -636,7 +643,7 @@ bool mySDL_SaveSurface( SDL_Surface *img, CString file ) SDL_Surface *mySDL_LoadSurface( CString file ) { - FILE *f = fopen(file.c_str(), "rb"); + FILE *f = Ragefopen(file.c_str(), "rb"); if(f == NULL) return NULL; diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index c91bf3c717..2602a013ca 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -30,6 +30,7 @@ #include "Notes.h" #include #include "NoteFieldPositioning.h" +#include "arch/arch.h" const float RECORD_HOLD_SECONDS = 0.3f; diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index bb3a157cfa..f8d818e6b5 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -29,6 +29,8 @@ #include "BannerCache.h" #include "Sprite.h" #include "PrefsManager.h" +#include "arch/arch.h" +#include "RageFile.h" #include "NotesLoaderSM.h" #include "NotesLoaderDWI.h" @@ -42,6 +44,7 @@ #include "SDL.h" #include "SDL_image.h" +#define CACHE_DIR BASE_PATH "Cache" SLASH const int FILE_CACHE_VERSION = 126; // increment this when Song or Notes changes to invalidate cache @@ -292,7 +295,7 @@ float Song::GetElapsedTimeFromBeat( float fBeat ) const CString Song::GetCacheFilePath() const { - return ssprintf( "Cache/Songs/%u", GetHashForString(m_sSongDir) ); + return ssprintf( CACHE_DIR "Songs" SLASH "%u", GetHashForString(m_sSongDir) ); } /* Get a path to the SM containing data for this song. It might @@ -361,17 +364,16 @@ bool Song::LoadFromSongDir( CString sDir ) // LOG->Trace( "Song::LoadFromSongDir(%s)", sDir.c_str() ); ASSERT( sDir != "" ); - sDir.Replace("\\", "/"); // make sure there is a trailing slash at the end of sDir - if( sDir.Right(1) != "/" ) - sDir += "/"; + if( sDir.Right(1) != SLASH ) + sDir += SLASH; // save song dir m_sSongDir = sDir; // save group name CStringArray sDirectoryParts; - split( m_sSongDir, "/", sDirectoryParts, false ); + split( m_sSongDir, SLASH, sDirectoryParts, false ); m_sGroupName = sDirectoryParts[sDirectoryParts.size()-3]; // second from last item // @@ -534,9 +536,8 @@ void Song::TidyUpData() { /* Use the song directory name. */ CString SongDir = this->GetSongDir(); - SongDir.Replace("\\", "/"); vector parts; - split(SongDir, "/", parts); + split(SongDir, SLASH, parts); ASSERT(parts.size() > 0); NotesLoader::GetMainAndSubTitlesFromFullTitle( parts[parts.size()-1], m_sMainTitle, m_sSubTitle ); @@ -598,11 +599,11 @@ void Song::TidyUpData() LOG->Trace("Looking for images..."); /* Replace backslashes with slashes in all paths. */ - m_sMusicFile.Replace("\\", "/"); - m_sBannerFile.Replace("\\", "/"); - m_sBackgroundFile.Replace("\\", "/"); - m_sCDTitleFile.Replace("\\", "/"); - m_sLyricsFile.Replace("\\", "/"); + FixSlashes( m_sMusicFile ); + FixSlashes( m_sBannerFile ); + FixSlashes( m_sBackgroundFile ); + FixSlashes( m_sCDTitleFile ); + FixSlashes( m_sLyricsFile ); /* Many imported files contain erroneous whitespace before or after * filenames. Paths usually don't actually start or end with spaces, @@ -691,11 +692,12 @@ void Song::TidyUpData() if( HasCDTitle() && stricmp(m_sCDTitleFile, arrayImages[i])==0 ) continue; // skip - SDL_Surface *img = IMG_Load( m_sSongDir + arrayImages[i] ); + CString sPath = m_sSongDir + arrayImages[i]; + SDL_Surface *img = IMG_Load( sPath ); if( !img ) { - LOG->Trace("Couldn't load %s%s: %s", - m_sSongDir.c_str(), arrayImages[i].c_str(), SDL_GetError()); + LOG->Trace("Couldn't load '%s': %s", + sPath.c_str(), SDL_GetError()); continue; } @@ -1464,7 +1466,7 @@ CString Song::GetMusicPath() const /* The file has a path. If it was loaded from the m_DWIPath, it's relative * to that. */ if( PREFSMAN->m_DWIPath!="" && m_sSongDir.Left(PREFSMAN->m_DWIPath.GetLength()) == PREFSMAN->m_DWIPath ) - return PREFSMAN->m_DWIPath+"/"+m_sMusicFile; + return PREFSMAN->m_DWIPath+SLASH+m_sMusicFile; /* Otherwise, it's relative to the top of the SM directory (the CWD), so * return it directly. */ @@ -1487,7 +1489,7 @@ CString Song::GetCDTitlePath() const return m_sSongDir+m_sCDTitleFile; if( PREFSMAN->m_DWIPath!="" && m_sSongDir.Left(PREFSMAN->m_DWIPath.GetLength()) == PREFSMAN->m_DWIPath ) - return PREFSMAN->m_DWIPath+"/"+m_sCDTitleFile; + return PREFSMAN->m_DWIPath+SLASH+m_sCDTitleFile; return m_sCDTitleFile; } diff --git a/stepmania/src/SongCacheIndex.cpp b/stepmania/src/SongCacheIndex.cpp index 9608e506e0..40e1ba7bbd 100644 --- a/stepmania/src/SongCacheIndex.cpp +++ b/stepmania/src/SongCacheIndex.cpp @@ -7,13 +7,16 @@ #include "RageLog.h" #include "RageUtil.h" #include "song.h" +#include "arch/arch.h" + +#define CACHE_DIR BASE_PATH "Cache" SLASH SongCacheIndex *SONGINDEX; SongCacheIndex::SongCacheIndex() { - CreateDirectories( "Cache/Songs" ); - CacheIndex.SetPath( "Cache/index.cache" ); + CreateDirectories( CACHE_DIR "Songs" ); + CacheIndex.SetPath( CACHE_DIR "index.cache" ); ReadCacheIndex(); } @@ -48,9 +51,9 @@ void SongCacheIndex::ReadCacheIndex() return; /* OK */ LOG->Trace( "Cache format is out of date. Deleting all cache files." ); - EmptyDir( "Cache/" ); - EmptyDir( "Cache/Banners/" ); - EmptyDir( "Cache/Songs/" ); + EmptyDir( CACHE_DIR ); + EmptyDir( CACHE_DIR "Banners" SLASH ); + EmptyDir( CACHE_DIR "Songs" SLASH ); CacheIndex.Reset(); } diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 241d00d9a3..2f75955196 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -15,6 +15,7 @@ #include "RageLog.h" #include "NotesLoaderDWI.h" #include "BannerCache.h" +#include "arch/arch.h" #include "GameState.h" #include "PrefsManager.h" @@ -26,15 +27,16 @@ #include "ThemeManager.h" #include "GameManager.h" -#include +#include "RageFile.h" SongManager* SONGMAN = NULL; // global and accessable from anywhere in our program - -const CString CATEGORY_RANKING_FILE = "Data/CategoryRanking.dat"; -const CString COURSE_RANKING_FILE = "Data/CourseRanking.dat"; -const CString NOTES_SCORES_FILE[NUM_MEMORY_CARDS] = { "Data/Player1NotesScores.dat", "Data/Player2NotesScores.dat", "Data/MachineNotesScores.dat" }; -const CString COURSE_SCORES_FILE[NUM_MEMORY_CARDS] = { "Data/Player1CourseScores.dat", "Data/Player2CourseScores.dat", "Data/MachineCourseScores.dat" }; +#define SONGS_DIR BASE_PATH "Songs" SLASH +#define COURSES_DIR BASE_PATH "Courses" SLASH +const CString CATEGORY_RANKING_FILE = BASE_PATH "Data" SLASH "CategoryRanking.dat"; +const CString COURSE_RANKING_FILE = BASE_PATH "Data" SLASH "CourseRanking.dat"; +const CString NOTES_SCORES_FILE[NUM_MEMORY_CARDS] = { BASE_PATH "Data" SLASH "Player1NotesScores.dat", BASE_PATH "Data" SLASH "Player2NotesScores.dat", BASE_PATH "Data" SLASH "MachineNotesScores.dat" }; +const CString COURSE_SCORES_FILE[NUM_MEMORY_CARDS] = { BASE_PATH "Data" SLASH "Player1CourseScores.dat", BASE_PATH "Data" SLASH "Player2CourseScores.dat", BASE_PATH "Data" SLASH "MachineCourseScores.dat" }; const int CATEGORY_RANKING_VERSION = 1; const int COURSE_RANKING_VERSION = 1; const int NOTES_SCORES_VERSION = 2; @@ -80,13 +82,24 @@ SongManager::SongManager( LoadingWindow *ld ) SongManager::~SongManager() { SaveMachineScoresToDisk(); + FreeSongArray(); } +void SongManager::SaveMachineScoresToDisk() +{ + SaveCategoryRankingsToFile( CATEGORY_RANKING_FILE ); + SaveCourseRankingsToFile( COURSE_RANKING_FILE ); + for( int c=0; cm_asAdditionalSongFolders.size(); i++ ) LoadStepManiaSongDir( PREFSMAN->m_asAdditionalSongFolders[i], ld ); @@ -133,7 +146,7 @@ void SongManager::AddGroup( CString sDir, CString sGroupDirName ) CString sBannerPath; if( !arrayGroupBanners.empty() ) - sBannerPath = sDir+sGroupDirName+"/"+arrayGroupBanners[0] ; + sBannerPath = sDir+sGroupDirName+SLASH+arrayGroupBanners[0] ; else { // Look for a group banner in the parent folder @@ -155,7 +168,7 @@ void SongManager::LoadStepManiaSongDir( CString sDir, LoadingWindow *ld ) { /* Make sure sDir has a trailing slash. */ TrimRight( sDir, "/\\" ); - sDir += "/"; + sDir += SLASH; // Find all group directories in "Songs" folder CStringArray arrayGroupDirs; @@ -173,7 +186,7 @@ void SongManager::LoadStepManiaSongDir( CString sDir, LoadingWindow *ld ) // Find all Song folders in this group directory CStringArray arraySongDirs; - GetDirListing( sDir+sGroupDirName + "/*", arraySongDirs, true, true ); + GetDirListing( sDir+sGroupDirName + SLASH "*", arraySongDirs, true, true ); SortCStringArray( arraySongDirs ); unsigned j; @@ -239,7 +252,7 @@ void SongManager::ReloadSongArray() void SongManager::ReadNoteScoresFromFile( CString fn, int c ) { - ifstream f(fn); + Rageifstream f(fn); if( !f.good() ) return; CString line; @@ -302,7 +315,7 @@ void SongManager::ReadNoteScoresFromFile( CString fn, int c ) void SongManager::ReadCourseScoresFromFile( CString fn, int c ) { - FILE* fp = fopen( fn, "r" ); + FILE* fp = Ragefopen( fn, "r" ); if( !fp ) return; @@ -342,7 +355,7 @@ void SongManager::ReadCourseScoresFromFile( CString fn, int c ) void SongManager::ReadCategoryRankingsFromFile( CString fn ) { - FILE* fp = fopen( fn, "r" ); + FILE* fp = Ragefopen( fn, "r" ); if( !fp ) return; @@ -365,7 +378,7 @@ void SongManager::ReadCategoryRankingsFromFile( CString fn ) void SongManager::ReadCourseRankingsFromFile( CString fn ) { - FILE* fp = fopen( fn, "r" ); + FILE* fp = Ragefopen( fn, "r" ); if( !fp ) return; @@ -432,28 +445,31 @@ void SongManager::InitMachineScoresFromDisk() ReadCourseScoresFromFile( COURSE_SCORES_FILE[c], c ); } -void SongManager::SaveMachineScoresToDisk() + +void SongManager::SaveCategoryRankingsToFile( CString fn ) { // category ranking LOG->Trace("Writing category ranking"); - { - FILE* fp = fopen( CATEGORY_RANKING_FILE, "w" ); - if( fp ) - { - fprintf(fp,"%d\n",CATEGORY_RANKING_VERSION); - for( int i=0; iTrace("Writing course ranking"); { - FILE* fp = fopen( COURSE_RANKING_FILE, "w" ); + FILE* fp = Ragefopen( fn, "w" ); if( fp ) { @@ -482,11 +498,14 @@ void SongManager::SaveMachineScoresToDisk() } } +} + +void SongManager::SaveNoteScoresToFile( CString fn, int c ) +{ // notes scores LOG->Trace("Writing note scores"); - for( int c=0; cTrace("Writing course scores"); { - for( int c=0; cm_bIsAutogen ) - fprintf(fp, "%s\n", pCourse->m_sName.c_str()); - else - fprintf(fp, "%s\n", pCourse->m_sPath.c_str()); - - for( int nt=0; ntm_MemCardScores[c][nt].iNumTimesPlayed, - pCourse->m_MemCardScores[c][nt].iScore, - pCourse->m_MemCardScores[c][nt].fSurviveTime); - } - - fclose(fp); + if( pCourse->m_bIsAutogen ) + fprintf(fp, "%s\n", pCourse->m_sName.c_str()); + else + fprintf(fp, "%s\n", pCourse->m_sPath.c_str()); + + for( int nt=0; ntm_MemCardScores[c][nt].iNumTimesPlayed, + pCourse->m_MemCardScores[c][nt].iScore, + pCourse->m_MemCardScores[c][nt].fSurviveTime); } + + fclose(fp); } } } @@ -724,7 +743,7 @@ void SongManager::InitCoursesFromDisk() // Load courses from in Courses dir // CStringArray saCourseFiles; - GetDirListing( "Courses/*.crs", saCourseFiles, false, true ); + GetDirListing( COURSES_DIR "*.crs", saCourseFiles, false, true ); for( i=0; i &AddTo, bool bIncludeAutoge bool SongManager::GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredGroup, Song*& pSongOut, Notes*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out ) { - const CString sCourseSuffix = sPreferredGroup + "/" + (bExtra2 ? "extra2" : "extra1") + ".crs"; - CString sCoursePath = "Songs/" + sCourseSuffix; + const CString sCourseSuffix = sPreferredGroup + SLASH + (bExtra2 ? "extra2" : "extra1") + ".crs"; + CString sCoursePath = SONGS_DIR + sCourseSuffix; if( !DoesFileExist(sCoursePath) ) { /* try alternative song folders */ for( unsigned i=0; im_asAdditionalSongFolders.size(); i++ ) { - sCoursePath = PREFSMAN->m_asAdditionalSongFolders[i] + "/" + sCourseSuffix; + sCoursePath = PREFSMAN->m_asAdditionalSongFolders[i] + SLASH + sCourseSuffix; if( DoesFileExist(sCoursePath) ) break; } } if( !DoesFileExist(sCoursePath) && PREFSMAN->m_DWIPath.size() ) - sCoursePath = PREFSMAN->m_DWIPath + "/Songs/" + sCourseSuffix; + sCoursePath = PREFSMAN->m_DWIPath + SLASH "Songs" SLASH + sCourseSuffix; /* Couldn't find course in DWI path or alternative song folders */ if( !DoesFileExist(sCoursePath) ) diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index 83c059f130..31db49a6cc 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -122,6 +122,11 @@ protected: void ReadCourseRankingsFromFile( CString fn ); Song *FindSong( CString sGroup, CString sSong ); + void SaveNoteScoresToFile( CString fn, int c ); + void SaveCourseScoresToFile( CString fn, int c ); + void SaveCategoryRankingsToFile( CString fn ); + void SaveCourseRankingsToFile( CString fn ); + vector m_pSongs; // all songs that can be played vector m_pBestSongs; CStringArray m_arrayGroupNames; diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index 07b2a12ee4..54a02e76aa 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -48,7 +48,7 @@ Sprite::~Sprite() bool Sprite::LoadBG( RageTextureID ID ) { ID.iMipMaps = 1; - ID.bDither = true; +// ID.bDither = true; return Load(ID); } @@ -175,6 +175,8 @@ void Sprite::EnableAnimation( bool bEnable ) bool Sprite::LoadFromTexture( RageTextureID ID ) { + LOG->Trace( "Sprite::LoadFromTexture( %s )", ID.filename.c_str() ); + if( !m_pTexture || !(m_pTexture->GetID() == ID) ) { /* Load the texture if it's not already loaded. We still need diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 44dfddc8a9..ebd138f07f 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -50,16 +50,24 @@ #include "BannerCache.h" #include "UnlockSystem.h" #include "arch/ArchHooks/ArchHooks.h" +#include "RageFile.h" -#ifdef WIN32 - -#ifdef DEBUG -#pragma comment(lib, "SDL-1.2.5/lib/SDLmaind.lib") -#else -#pragma comment(lib, "SDL-1.2.5/lib/SDLmain.lib") +#if defined(_XBOX) + #ifdef DEBUG + #pragma comment(lib, "SDL-1.2.5/lib/xboxSDLmaind.lib") + #else + #pragma comment(lib, "SDL-1.2.5/lib/xboxSDLmain.lib") + #endif +#elif defined(_WINDOWS) + #ifdef DEBUG + #pragma comment(lib, "SDL-1.2.5/lib/SDLmaind.lib") + #else + #pragma comment(lib, "SDL-1.2.5/lib/SDLmain.lib") + #endif #endif +#ifdef _WINDOWS HWND g_hWndMain = NULL; #endif @@ -71,6 +79,7 @@ static bool g_bQuitting = false; static void ChangeToDirOfExecutable(const char *argv0) { +#ifndef _XBOX /* Make sure the current directory is the root program directory * We probably shouldn't do this; rather, we should know where things * are and use paths as needed, so we don't depend on the binary being @@ -84,6 +93,7 @@ static void ChangeToDirOfExecutable(const char *argv0) chdir( dir.c_str() ); } +#endif } void ApplyGraphicOptions() @@ -275,6 +285,8 @@ static void CheckSettings() static const CString D3DURL = "http://search.microsoft.com/gomsuri.asp?n=1&c=rp_BestBets&siteid=us&target=http://www.microsoft.com/downloads/details.aspx?FamilyID=a19bed22-0b25-4e5d-a584-6389d8a3dad0&displaylang=en"; +#define VIDEOCARDS_INI_PATH BASE_PATH "Data" SLASH "VideoCardDefaults.ini" + RageDisplay *CreateDisplay() { /* We never want to bother users with having to decide which API to use. @@ -301,10 +313,9 @@ RageDisplay *CreateDisplay() */ // Video card changed since last run -#if defined(WIN32) +#if defined(_WINDOWS) CString sVideoDriver = GetPrimaryVideoDriverName(); -#endif -#if !defined(WIN32) +#else CString sVideoDriver = "OpenGL"; #endif if( PREFSMAN->m_sVideoRenderers == "" || @@ -312,9 +323,9 @@ RageDisplay *CreateDisplay() { // Apply default graphic settings for this card IniFile ini; - ini.SetPath( "Data/VideoCardDefaults.ini" ); + ini.SetPath( VIDEOCARDS_INI_PATH ); if(!ini.ReadFile()) - RageException::Throw( "Couldn't read Data/VideoCardDefaults.ini." ); + RageException::Throw( "Couldn't read '%s'." VIDEOCARDS_INI_PATH ); IniFile::const_iterator i; for( i = ini.begin(); i != ini.end(); ++i ) @@ -339,10 +350,9 @@ RageDisplay *CreateDisplay() ini.GetValueB( sKey, "AntiAliasing", PREFSMAN->m_bAntiAliasing ); // Update last seen video card -#if defined(WIN32) +#if defined(_WINDOWS) PREFSMAN->m_sLastSeenVideoDriver = GetPrimaryVideoDriverName(); -#endif -#if !defined(WIN32) +#else PREFSMAN->m_sLastSeenVideoDriver = "OpenGL"; #endif @@ -425,6 +435,9 @@ static void RestoreAppPri() #endif } +#define UNLOCKS_PATH BASE_PATH "Data" SLASH "Unlocks.dat" + + int main(int argc, char* argv[]) { g_argc = argc; @@ -533,7 +546,7 @@ int main(int argc, char* argv[]) ResetGame(); /* Load the unlocks into memory */ - GAMESTATE->m_pUnlockingSys->LoadFromDATFile("Data/Unlocks.dat"); + GAMESTATE->m_pUnlockingSys->LoadFromDATFile( UNLOCKS_PATH ); /* Run the main loop. */ GameLoop(); diff --git a/stepmania/src/StepMania.h b/stepmania/src/StepMania.h index 30a6a7b934..90f9896a57 100644 --- a/stepmania/src/StepMania.h +++ b/stepmania/src/StepMania.h @@ -11,6 +11,7 @@ ----------------------------------------------------------------------------- */ +int SMmain(int argc, char* argv[]); void ApplyGraphicOptions(); void ExitGame(); void ResetGame(); diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index d6ce2d427e..4f3b346543 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -23,13 +23,15 @@ #include "FontCharAliases.h" #include "RageDisplay.h" #include "arch/ArchHooks/ArchHooks.h" +#include "arch/arch.h" +#include "RageFile.h" ThemeManager* THEME = NULL; // global object accessable from anywhere in the program const CString BASE_THEME_NAME = "default"; -const CString THEMES_DIR = "Themes/"; +const CString THEMES_DIR = BASE_PATH "Themes" SLASH; const CString ELEMENT_CATEGORY_STRING[NUM_ELEMENT_CATEGORIES] = { "BGAnimations", @@ -57,7 +59,7 @@ ThemeManager::~ThemeManager() void ThemeManager::GetThemeNames( CStringArray& AddTo ) { - GetDirListing( THEMES_DIR+"/*", AddTo, true ); + GetDirListing( THEMES_DIR + "*", AddTo, true ); // strip out the folder called "CVS" for( CStringArray::iterator i=AddTo.begin(); i != AddTo.end(); ++i ) @@ -104,7 +106,7 @@ void ThemeManager::SwitchTheme( CString sThemeName ) CString ThemeManager::GetThemeDirFromName( const CString &sThemeName ) { - return THEMES_DIR + sThemeName + "/"; + return THEMES_DIR + sThemeName + SLASH; } CString ThemeManager::GetPathTo( CString sThemeName, ElementCategory category, CString sFileName ) @@ -125,12 +127,12 @@ try_element_again: if( bLookingForSpecificFile ) { - GetDirListing( sThemeDir + sCategory+"/"+sFileName, asElementPaths, bDirsOnly, true ); + GetDirListing( sThemeDir + sCategory+SLASH+sFileName, asElementPaths, bDirsOnly, true ); } else // look for all files starting with sFileName that have types we can use { /* First, look for redirs. */ - GetDirListing( sThemeDir + sCategory+"/"+sFileName + ".redir", + GetDirListing( sThemeDir + sCategory + SLASH + sFileName + ".redir", asElementPaths, false, true ); static const char *masks[NUM_ELEMENT_CATEGORIES][12] = { @@ -143,7 +145,7 @@ try_element_again: const char **asset_masks = masks[category]; for( int i = 0; asset_masks[i]; ++i ) - GetDirListing( sThemeDir + sCategory+"/" + sFileName + asset_masks[i], + GetDirListing( sThemeDir + sCategory + SLASH + sFileName + asset_masks[i], asElementPaths, bDirsOnly, true ); if( category == Fonts ) Font::WeedFontNames(asElementPaths, sFileName); @@ -223,6 +225,7 @@ try_element_again: CString ThemeManager::GetPathTo( ElementCategory category, CString sFileName, bool bOptional ) { + // TODO: Use HOOKS->MessageBox() #if defined(DEBUG) && defined(WIN32) try_element_again: #endif @@ -230,6 +233,7 @@ try_element_again: CString ret = GetPathTo( m_sCurThemeName, category, sFileName); if( !ret.empty() ) // we found something return ret; + ret = GetPathTo( BASE_THEME_NAME, category, sFileName); if( !ret.empty() ) // we found something return ret; @@ -239,14 +243,14 @@ try_element_again: CString sCategory = ELEMENT_CATEGORY_STRING[category]; #if defined(DEBUG) && defined(WIN32) - CString sMessage = ssprintf("The theme element '%s/%s' is missing.",sCategory.c_str(),sFileName.c_str()); + CString sMessage = "The theme element '" + sCategory + SLASH + sFileName +"' is missing."; switch( MessageBox(NULL, sMessage, "ThemeManager", MB_RETRYCANCEL ) ) { case IDRETRY: FlushDirCache(); goto try_element_again; case IDCANCEL: - RageException::Throw( "Theme element '%s/%s' could not be found in '%s' or '%s'.", + RageException::Throw( "Theme element '%s" SLASH "%s' could not be found in '%s' or '%s'.", sCategory.c_str(), sFileName.c_str(), GetThemeDirFromName(m_sCurThemeName).c_str(), @@ -256,7 +260,7 @@ try_element_again: #endif LOG->Warn( - "Theme element '%s/%s' could not be found in '%s' or '%s'.", + "Theme element '%s" SLASH "%s' could not be found in '%s' or '%s'.", sCategory.c_str(), sFileName.c_str(), GetThemeDirFromName(m_sCurThemeName).c_str(), @@ -264,7 +268,7 @@ try_element_again: /* Err? */ if(sFileName == "_missing") - RageException::Throw("_missing element missing from %s/%s", GetThemeDirFromName(BASE_THEME_NAME).c_str(), sCategory.c_str() ); + RageException::Throw("'_missing' isn't present in '%s%s'", GetThemeDirFromName(BASE_THEME_NAME).c_str(), sCategory.c_str() ); return GetPathTo( category, "_missing" ); } diff --git a/stepmania/src/TitleSubstitution.cpp b/stepmania/src/TitleSubstitution.cpp index 9ca2bb8fd0..c2a16189f4 100644 --- a/stepmania/src/TitleSubstitution.cpp +++ b/stepmania/src/TitleSubstitution.cpp @@ -1,10 +1,13 @@ #include "global.h" #include "TitleSubstitution.h" +#include "arch/arch.h" #include "RageUtil.h" #include "FontCharAliases.h" -#include +#include "RageFile.h" + +#define TRANSLATION_PATH BASE_PATH "Data" SLASH "Translation.dat" struct TitleTrans { @@ -92,12 +95,12 @@ void TitleSubst::Subst(CString &title, CString &subtitle, CString &artist, TitleSubst::TitleSubst(const CString §ion) { - Load("data/Translation.dat", section); + Load( TRANSLATION_PATH, section); } void TitleSubst::Load(const CString &filename, const CString §ion) { - ifstream f; + Rageifstream f; f.open(filename); if(!f.good()) return; diff --git a/stepmania/src/Transition.cpp b/stepmania/src/Transition.cpp index 513c373703..d717055e25 100644 --- a/stepmania/src/Transition.cpp +++ b/stepmania/src/Transition.cpp @@ -14,6 +14,7 @@ #include "RageUtil.h" #include "ScreenManager.h" #include "IniFile.h" +#include "RageFile.h" Transition::Transition() @@ -24,8 +25,8 @@ Transition::Transition() void Transition::Load( CString sBGAniDir ) { - if( !sBGAniDir.empty() && sBGAniDir.Right(1) != "/" ) - sBGAniDir += "/"; + if( !sBGAniDir.empty() && sBGAniDir.Right(1) != SLASH ) + sBGAniDir += SLASH; m_BGAnimation.LoadFromAniDir( sBGAniDir ); @@ -39,9 +40,16 @@ void Transition::Load( CString sBGAniDir ) CString sSoundFileName; if( ini.GetValue("BGAnimation","Sound",sSoundFileName) ) - m_sound.Load( sBGAniDir+sSoundFileName ); + { + FixSlashesInPlace( sSoundFileName ); + CString sPath = sBGAniDir+sSoundFileName; + CollapsePath( sPath ); + m_sound.Load( sPath ); + } else + { m_sound.Load( sBGAniDir ); + } } diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp index 38c88fd78d..b67b65cc3f 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp @@ -114,4 +114,5 @@ ArchHooks::MessageBoxResult ArchHooks_Win32::MessageBoxAbortRetryIgnore( CString * Copyright (c) 2002-2003 by the person(s) listed below. All rights reserved. * * Glenn Maynard + * Chris Danford */ diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Null.h b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Null.h new file mode 100644 index 0000000000..de83a11580 --- /dev/null +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Null.h @@ -0,0 +1,22 @@ +#ifndef LOW_LEVEL_WINDOW_SDL_H +#define LOW_LEVEL_WINDOW_SDL_H + +#include "LowLevelWindow.h" + +class LowLevelWindow_Null: public LowLevelWindow +{ + RageDisplay::VideoModeParams CurrentParams; +public: + LowLevelWindow_Null() {}; + ~LowLevelWindow_Null() {}; + void *GetProcAddress(CString s) { return NULL; }; + bool TryVideoMode( RageDisplay::VideoModeParams p, bool &bNewDeviceOut ) { return false; }; + void SwapBuffers() {}; + void Update(float fDeltaTime) {}; + + RageDisplay::VideoModeParams GetVideoModeParams() const { return CurrentParams; } +}; +#undef ARCH_LOW_LEVEL_WINDOW +#define ARCH_LOW_LEVEL_WINDOW LowLevelWindow_Null + +#endif diff --git a/stepmania/src/arch/MovieTexture/MovieTexture.cpp b/stepmania/src/arch/MovieTexture/MovieTexture.cpp index d1cf422daa..91d2e8ea7c 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture.cpp @@ -13,7 +13,7 @@ #define DEFAULT_MOVIE_DRIVER_LIST "Null" #endif -#include +#include "RageFile.h" bool RageMovieTexture::GetFourCC( CString fn, CString &handler, CString &type ) { CString ignore, ext; diff --git a/stepmania/src/arch/Sound/DSoundHelpers.cpp b/stepmania/src/arch/Sound/DSoundHelpers.cpp index c95a9c85f8..034d16d7cd 100644 --- a/stepmania/src/arch/Sound/DSoundHelpers.cpp +++ b/stepmania/src/arch/Sound/DSoundHelpers.cpp @@ -9,7 +9,7 @@ #include #pragma comment(lib, "dsound.lib") -#pragma comment(lib, "dxguid.lib") +//#pragma comment(lib, "dxguid.lib") BOOL CALLBACK DSound::EnumCallback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext) { diff --git a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp index c9031768f0..ed333a9663 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp @@ -12,7 +12,11 @@ #include "RageUtil.h" #include "RageSound.h" #include "RageLog.h" + +#ifdef _WINDOWS #include "archutils/win32/tls.h" +#endif + #include "SDL.h" const int channels = 2; @@ -36,7 +40,9 @@ int RageSound_DSound::MixerThread_start(void *p) void RageSound_DSound::MixerThread() { +#ifdef _WINDOWS InitThreadData("Mixer thread"); +#endif VDCHECKPOINT; /* SOUNDMAN will be set once RageSoundManager's ctor returns and diff --git a/stepmania/src/arch/arch.cpp b/stepmania/src/arch/arch.cpp index 3c39579eda..46e312dca9 100644 --- a/stepmania/src/arch/arch.cpp +++ b/stepmania/src/arch/arch.cpp @@ -32,13 +32,10 @@ void MakeInputHandlers(vector &Add) { #if defined(_WINDOWS) Add.push_back(new InputHandler_DInput); -#else - Add.push_back(new InputHandler_SDL); -#endif - -#if defined(_WINDOWS) Add.push_back(new InputHandler_Win32_Pump); // Add.push_back(new InputHandler_Win32_Para); +#else + Add.push_back(new InputHandler_SDL); #endif } diff --git a/stepmania/src/arch/arch.h b/stepmania/src/arch/arch.h index 3a5e3a9d7a..2d484863a7 100644 --- a/stepmania/src/arch/arch.h +++ b/stepmania/src/arch/arch.h @@ -20,15 +20,26 @@ RageSoundDriver *MakeRageSoundDriver(CString drivers); /* Define the default list of sound drivers for each arch. It's * OK to list drivers that may not be available. */ #if defined(LINUX) -#define DEFAULT_SOUND_DRIVER_LIST "ALSA9,OSS,Null" + #define DEFAULT_SOUND_DRIVER_LIST "ALSA9,OSS,Null" #elif defined(DARWIN) -#define DEFAULT_SOUND_DRIVER_LIST "QT,QT1,Null" -#elif defined(WIN32) -#define DEFAULT_SOUND_DRIVER_LIST "DirectSound,DirectSound-sw,WaveOut" + #define DEFAULT_SOUND_DRIVER_LIST "QT,QT1,Null" +#elif defined(_WINDOWS) + #define DEFAULT_SOUND_DRIVER_LIST "DirectSound,DirectSound-sw,WaveOut" +#elif defined(_XBOX) + #define DEFAULT_SOUND_DRIVER_LIST "DirectSound" #else -#define DEFAULT_SOUND_DRIVER_LIST "Null" + #define DEFAULT_SOUND_DRIVER_LIST "Null" #endif + +/* Hack for Xbox: All paths must be absolute. */ +#if defined(_XBOX) + #define BASE_PATH "D:\\" +#else + #define BASE_PATH "" +#endif + + #endif /* diff --git a/stepmania/src/arch/arch_darwin.h b/stepmania/src/arch/arch_darwin.h index dbb1c1b959..ce9b4644f1 100644 --- a/stepmania/src/arch/arch_darwin.h +++ b/stepmania/src/arch/arch_darwin.h @@ -13,6 +13,8 @@ #include "Sound/RageSoundDriver_QT1.h" #include "Sound/RageSoundDriver_QT.h" #include "LoadingWindow/LoadingWindow_Cocoa.h" +#include "InputHandler/InputHandler_SDL.h" + #include "ArchHooks/ArchHooks_darwin.h" #endif diff --git a/stepmania/src/arch/arch_default.h b/stepmania/src/arch/arch_default.h index 03be5f4374..d94b537bb4 100644 --- a/stepmania/src/arch/arch_default.h +++ b/stepmania/src/arch/arch_default.h @@ -3,6 +3,8 @@ /* All driver types should have a default, portable implementation, provided * here. */ +/* None of these SDL implementations run on Xbox, so I've commented + * out use of this header and added the #includes to each arch_*.h */ /* Load default fallback drivers; some of these may be overridden by arch-specific drivers. */ #include "LoadingWindow/LoadingWindow_SDL.h" @@ -10,8 +12,10 @@ #include "ErrorDialog/ErrorDialog_null.h" #include "ArchHooks/ArchHooks_none.h" #include "Sound/RageSoundDriver_Null.h" -#include "LowLevelWindow/LowLevelWindow_SDL.h" -#include "InputHandler/InputHandler_SDL.h" +#include "LowLevelWindow/LowLevelWindow_Null.h" + +// not supported on Xbox +//#include "InputHandler/InputHandler_SDL.h" #endif diff --git a/stepmania/src/arch/arch_linux.h b/stepmania/src/arch/arch_linux.h index 5cf9936c22..26e62c02cf 100644 --- a/stepmania/src/arch/arch_linux.h +++ b/stepmania/src/arch/arch_linux.h @@ -12,6 +12,7 @@ #ifdef HAVE_GTK # include "LoadingWindow/LoadingWindow_Gtk.h" #endif +#include "InputHandler/InputHandler_SDL.h" #endif /* diff --git a/stepmania/src/arch/arch_xbox.h b/stepmania/src/arch/arch_xbox.h index decbed1967..c536363621 100644 --- a/stepmania/src/arch/arch_xbox.h +++ b/stepmania/src/arch/arch_xbox.h @@ -1,12 +1,12 @@ #ifndef XBOX_ARCH_H #define XBOX_ARCH_H -/* Load drivers for Win32. */ -#include "LoadingWindow/LoadingWindow_SDL.h" +/* Load drivers for Xbox. */ +#include "LoadingWindow/LoadingWindow_Null.h" #include "ErrorDialog/ErrorDialog_null.h" #include "ArchHooks/ArchHooks_none.h" -#include "InputHandler/InputHandler_DirectInput.h" +#include "InputHandler/InputHandler_SDL.h" #include "Sound/RageSoundDriver_DSound.h" diff --git a/stepmania/src/global.h b/stepmania/src/global.h index 32ea40611b..c56166a2a1 100644 --- a/stepmania/src/global.h +++ b/stepmania/src/global.h @@ -55,24 +55,25 @@ using namespace std; #undef ASSERT #endif -#if defined(WIN32) -/* Assertion that sets an optional message and brings up the crash handler, so - * we get a backtrace. This should probably be used instead of throwing an - * exception in most cases we expect never to happen (but not in cases that - * we do expect, such as DSound init failure.) */ -#include "archutils/win32/crash.h" -#define RAGE_ASSERT_M(COND, MESSAGE) { if(!(COND)) { VDCHECKPOINT_M(MESSAGE); *(char*)0=0; } } -#define RAGE_ASSERT(COND) RAGE_ASSERT_M((COND), "Assertion '" #COND "' failed") -#define ASSERT RAGE_ASSERT +#if defined(_WINDOWS) + /* Assertion that sets an optional message and brings up the crash handler, so + * we get a backtrace. This should probably be used instead of throwing an + * exception in most cases we expect never to happen (but not in cases that + * we do expect, such as DSound init failure.) */ + #include "archutils/win32/crash.h" + #define RAGE_ASSERT_M(COND, MESSAGE) { if(!(COND)) { VDCHECKPOINT_M(MESSAGE); *(char*)0=0; } } + #define RAGE_ASSERT(COND) RAGE_ASSERT_M((COND), "Assertion '" #COND "' failed") + #define ASSERT RAGE_ASSERT #else - -#include -/* TODO: do something useful and portable with RAGE_ASSERT*. */ -#define RAGE_ASSERT_M(COND, MESSAGE) ASSERT(COND) -#define RAGE_ASSERT(COND) RAGE_ASSERT_M((COND), "Assertion '" #COND "' failed") -#define ASSERT assert + #define VDCHECKPOINT (void*)(0) + #include + /* TODO: do something useful and portable with RAGE_ASSERT*. */ + #define RAGE_ASSERT_M(COND, MESSAGE) ASSERT(COND) + #define RAGE_ASSERT(COND) RAGE_ASSERT_M((COND), "Assertion '" #COND "' failed") + #define ASSERT assert #endif + #ifdef DEBUG #define DEBUG_ASSERT(x) ASSERT(x) #else @@ -137,6 +138,12 @@ inline float acosf(float x) { return float(acos(double(x))); } #include #endif +#if defined(_XBOX) + #define SLASH "\\" +#else + #define SLASH "/" +#endif + /* Don't include our own headers here, since they tend to change often. */ #endif