From 413538170e0862a613f727624580c9ac9f273603 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sat, 2 Feb 2013 00:27:03 -0500 Subject: [PATCH] Add the header......wait. Did this file change new lines AGAIN?!? OY. --- src/AnnouncerManager.cpp | 491 ++++++++++++++++++++------------------- 1 file changed, 246 insertions(+), 245 deletions(-) diff --git a/src/AnnouncerManager.cpp b/src/AnnouncerManager.cpp index ee20dc427e..88ef40dc27 100644 --- a/src/AnnouncerManager.cpp +++ b/src/AnnouncerManager.cpp @@ -1,245 +1,246 @@ -#include "global.h" -#include "AnnouncerManager.h" -#include "RageLog.h" -#include "RageUtil.h" -#include "RageFile.h" - -AnnouncerManager* ANNOUNCER = NULL; // global object accessable from anywhere in the program - - -const RString EMPTY_ANNOUNCER_NAME = "Empty"; -const RString ANNOUNCERS_DIR = "Announcers/"; - -AnnouncerManager::AnnouncerManager() -{ - // Register with Lua. - { - Lua *L = LUA->Get(); - lua_pushstring( L, "ANNOUNCER" ); - this->PushSelf( L ); - lua_settable( L, LUA_GLOBALSINDEX ); - LUA->Release( L ); - } -} - -AnnouncerManager::~AnnouncerManager() -{ - // Unregister with Lua. - LUA->UnsetGlobal( "ANNOUNCER" ); -} - -void AnnouncerManager::GetAnnouncerNames( vector& AddTo ) -{ - GetDirListing( ANNOUNCERS_DIR+"*", AddTo, true ); - - StripCvsAndSvn( AddTo ); - StripMacResourceForks( AddTo ); - - // strip out the empty announcer folder - for( int i=AddTo.size()-1; i>=0; i-- ) - if( !stricmp( AddTo[i], EMPTY_ANNOUNCER_NAME ) ) - AddTo.erase(AddTo.begin()+i, AddTo.begin()+i+1 ); -} - -bool AnnouncerManager::DoesAnnouncerExist( RString sAnnouncerName ) -{ - if( sAnnouncerName == "" ) - return true; - - vector asAnnouncerNames; - GetAnnouncerNames( asAnnouncerNames ); - for( unsigned i=0; iTrace( "The announcer in '%s' is missing the folder '%s'.", - AnnouncerPath.c_str(), sFolderName.c_str() ); -// MessageBeep( MB_OK ); - RageFile temp; - temp.Open( AnnouncerPath+sFolderName + "/announcer files go here.txt", RageFile::WRITE ); -#endif - - return RString(); -} - -RString AnnouncerManager::GetPathTo( RString sFolderName ) -{ - return GetPathTo(m_sCurAnnouncerName, sFolderName); -} - -bool AnnouncerManager::HasSoundsFor( RString sFolderName ) -{ - return !DirectoryIsEmpty( GetPathTo(sFolderName) ); -} - -void AnnouncerManager::NextAnnouncer() -{ - vector as; - GetAnnouncerNames( as ); - if( as.size()==0 ) - return; - - if( m_sCurAnnouncerName == "" ) - SwitchAnnouncer( as[0] ); - else - { - unsigned i; - for( i=0; i -{ -public: - static int DoesAnnouncerExist( T* p, lua_State *L ) { lua_pushboolean(L, p->DoesAnnouncerExist( SArg(1) )); return 1; } - static int GetAnnouncerNames( T* p, lua_State *L ) - { - vector vAnnouncers; - p->GetAnnouncerNames( vAnnouncers ); - LuaHelpers::CreateTableFromArray(vAnnouncers, L); - return 1; - } - static int GetCurrentAnnouncer( T* p, lua_State *L ) - { - RString s = p->GetCurAnnouncerName(); - if( s.empty() ) - return 0; - lua_pushstring(L, s ); - return 1; - } - static int SetCurrentAnnouncer( T* p, lua_State *L ) - { - RString s = SArg(1); - // only bother switching if the announcer exists. -aj - if(p->DoesAnnouncerExist(s)) - p->SwitchAnnouncer(s); - return 0; - } - - LunaAnnouncerManager() - { - ADD_METHOD( DoesAnnouncerExist ); - ADD_METHOD( GetAnnouncerNames ); - ADD_METHOD( GetCurrentAnnouncer ); - ADD_METHOD( SetCurrentAnnouncer ); - } -}; - -LUA_REGISTER_CLASS( AnnouncerManager ) -// lua end - -/* - * (c) 2001-2004 Chris Danford - * 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. - */ +#include "global.h" +#include "AnnouncerManager.h" +#include "RageLog.h" +#include "RageUtil.h" +#include "RageFile.h" +#include + +AnnouncerManager* ANNOUNCER = NULL; // global object accessable from anywhere in the program + + +const RString EMPTY_ANNOUNCER_NAME = "Empty"; +const RString ANNOUNCERS_DIR = "Announcers/"; + +AnnouncerManager::AnnouncerManager() +{ + // Register with Lua. + { + Lua *L = LUA->Get(); + lua_pushstring( L, "ANNOUNCER" ); + this->PushSelf( L ); + lua_settable( L, LUA_GLOBALSINDEX ); + LUA->Release( L ); + } +} + +AnnouncerManager::~AnnouncerManager() +{ + // Unregister with Lua. + LUA->UnsetGlobal( "ANNOUNCER" ); +} + +void AnnouncerManager::GetAnnouncerNames( vector& AddTo ) +{ + GetDirListing( ANNOUNCERS_DIR+"*", AddTo, true ); + + StripCvsAndSvn( AddTo ); + StripMacResourceForks( AddTo ); + + // strip out the empty announcer folder + for( int i=AddTo.size()-1; i>=0; i-- ) + if( !stricmp( AddTo[i], EMPTY_ANNOUNCER_NAME ) ) + AddTo.erase(AddTo.begin()+i, AddTo.begin()+i+1 ); +} + +bool AnnouncerManager::DoesAnnouncerExist( RString sAnnouncerName ) +{ + if( sAnnouncerName == "" ) + return true; + + vector asAnnouncerNames; + GetAnnouncerNames( asAnnouncerNames ); + for( unsigned i=0; iTrace( "The announcer in '%s' is missing the folder '%s'.", + AnnouncerPath.c_str(), sFolderName.c_str() ); +// MessageBeep( MB_OK ); + RageFile temp; + temp.Open( AnnouncerPath+sFolderName + "/announcer files go here.txt", RageFile::WRITE ); +#endif + + return RString(); +} + +RString AnnouncerManager::GetPathTo( RString sFolderName ) +{ + return GetPathTo(m_sCurAnnouncerName, sFolderName); +} + +bool AnnouncerManager::HasSoundsFor( RString sFolderName ) +{ + return !DirectoryIsEmpty( GetPathTo(sFolderName) ); +} + +void AnnouncerManager::NextAnnouncer() +{ + vector as; + GetAnnouncerNames( as ); + if( as.size()==0 ) + return; + + if( m_sCurAnnouncerName == "" ) + SwitchAnnouncer( as[0] ); + else + { + unsigned i; + for( i=0; i +{ +public: + static int DoesAnnouncerExist( T* p, lua_State *L ) { lua_pushboolean(L, p->DoesAnnouncerExist( SArg(1) )); return 1; } + static int GetAnnouncerNames( T* p, lua_State *L ) + { + vector vAnnouncers; + p->GetAnnouncerNames( vAnnouncers ); + LuaHelpers::CreateTableFromArray(vAnnouncers, L); + return 1; + } + static int GetCurrentAnnouncer( T* p, lua_State *L ) + { + RString s = p->GetCurAnnouncerName(); + if( s.empty() ) + return 0; + lua_pushstring(L, s ); + return 1; + } + static int SetCurrentAnnouncer( T* p, lua_State *L ) + { + RString s = SArg(1); + // only bother switching if the announcer exists. -aj + if(p->DoesAnnouncerExist(s)) + p->SwitchAnnouncer(s); + return 0; + } + + LunaAnnouncerManager() + { + ADD_METHOD( DoesAnnouncerExist ); + ADD_METHOD( GetAnnouncerNames ); + ADD_METHOD( GetCurrentAnnouncer ); + ADD_METHOD( SetCurrentAnnouncer ); + } +}; + +LUA_REGISTER_CLASS( AnnouncerManager ) +// lua end + +/* + * (c) 2001-2004 Chris Danford + * 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. + */