diff --git a/stepmania/src/ScreenOptionsToggleSongs.cpp b/stepmania/src/ScreenOptionsToggleSongs.cpp new file mode 100644 index 0000000000..2360c4eeaa --- /dev/null +++ b/stepmania/src/ScreenOptionsToggleSongs.cpp @@ -0,0 +1,91 @@ +#include "global.h" +#include "ScreenOptionsToggleSongs.h" +#include "OptionRowHandler.h" +#include "RageUtil.h" +#include "ScreenManager.h" +#include "song.h" +#include "SongManager.h" +#include "UnlockManager.h" + +REGISTER_SCREEN_CLASS( ScreenOptionsToggleSongs ); + +void ScreenOptionsToggleSongs::BeginScreen() +{ + m_apSongs.clear(); + + vector vHands; + + const vector &apAllSongs = SONGMAN->GetSongs(); + FOREACH_CONST( Song *, apAllSongs , s ) + { + Song *pSong = *s; + if( UNLOCKMAN->SongIsLocked(pSong) & ~LOCKED_DISABLED ) + continue; + + vHands.push_back( OptionRowHandlerUtil::MakeNull() ); + OptionRowDefinition &def = vHands.back()->m_Def; + + def.m_sName = pSong->GetTranslitFullTitle(); + def.m_bAllowThemeTitle = false; // not themable + def.m_sExplanationName = "Toggle Song"; + def.m_vsChoices.clear(); + def.m_vsChoices.push_back( "On" ); + def.m_vsChoices.push_back( "Off" ); + def.m_bAllowThemeItems = false; // already themed + + m_apSongs.push_back( pSong ); + } + + InitMenu( vHands ); + + ScreenOptions::BeginScreen(); +} + +void ScreenOptionsToggleSongs::ImportOptions( int iRow, const vector &vpns ) +{ + for( int i = 0; i < (int) m_apSongs.size(); ++i ) + { + OptionRow &row = *m_pRows[i]; + bool bEnable = m_apSongs[i]->GetEnabled(); + int iSelection = bEnable? 0:1; + row.SetOneSharedSelection( iSelection ); + } +} + +void ScreenOptionsToggleSongs::ExportOptions( int iRow, const vector &vpns ) +{ + for( int i = 0; i < (int) m_apSongs.size(); ++i ) + { + const OptionRow &row = *m_pRows[i]; + int iSelection = row.GetOneSharedSelection(); + bool bEnable = (iSelection == 0); + m_apSongs[i]->SetEnabled( bEnable ); + } + + SONGMAN->SaveEnabledSongsToPref(); +} + +/* + * (c) 2007 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. + */ diff --git a/stepmania/src/ScreenOptionsToggleSongs.h b/stepmania/src/ScreenOptionsToggleSongs.h new file mode 100644 index 0000000000..87221c454c --- /dev/null +++ b/stepmania/src/ScreenOptionsToggleSongs.h @@ -0,0 +1,44 @@ +#ifndef SCREEN_OPTIONS_TOGGLE_SONGS_H +#define SCREEN_OPTIONS_TOGGLE_SONGS_H + +#include "ScreenOptions.h" +#include "Song.h" + +class ScreenOptionsToggleSongs: public ScreenOptions +{ +public: + virtual void BeginScreen(); + +private: + virtual void ImportOptions( int row, const vector &vpns ); + virtual void ExportOptions( int row, const vector &vpns ); + + vector m_apSongs; +}; + +#endif + +/* + * (c) 2007 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. + */