Files
itgmania212121/stepmania/src/ScreenSaveSync.cpp
T

169 lines
5.0 KiB
C++
Raw Normal View History

2005-05-19 23:29:39 +00:00
#include "global.h"
#include "ScreenSaveSync.h"
#include "GameState.h"
#include "song.h"
#include "PrefsManager.h"
2005-12-22 03:10:04 +00:00
#include "LocalizedString.h"
2005-05-19 23:29:39 +00:00
2005-12-21 09:56:16 +00:00
static LocalizedString EARLIER ("ScreenSaveSync","earlier");
static LocalizedString LATER ("ScreenSaveSync","later");
static LocalizedString CHANGED_GLOBAL_OFFSET ("ScreenSaveSync","You have changed the Global Offset from %+.3f to %+.3f (change of %+.3f, making the notes %s).");
static LocalizedString CHANGED_SONG_OFFSET ("ScreenSaveSync","You have changed the Song Offset from %+.3f to %+.3f (change of %+.3f, making the notes %s).");
static LocalizedString CHANGED_BPM ("ScreenSaveSync","The BPM segment number #%d changed from %+.3f BPS to %+.3f BPS (change of %+.3f).");
static LocalizedString CHANGED_STOP ("ScreenSaveSync","The stop segment #%d changed from %+.3f seconds to %+.3f seconds (change of %+.3f).");
static LocalizedString CHANGED_TIMING_OF ("ScreenSaveSync","You have changed the timing of");
static LocalizedString WOULD_YOU_LIKE_TO_SAVE ("ScreenSaveSync","Would you like to save these changes?");
static LocalizedString CHOOSING_NO_WILL_DISCARD ("ScreenSaveSync","Choosing NO will discard your changes.");
2005-05-19 23:29:39 +00:00
static CString GetPromptText()
{
CString s;
{
float fOld = GAMESTATE->m_fGlobalOffsetSecondsOriginal;
float fNew = PREFSMAN->m_fGlobalOffsetSeconds;
float fDelta = fNew - fOld;
if( fabs(fDelta) > 0.00001 )
{
s += ssprintf(
2005-12-21 09:56:16 +00:00
CHANGED_GLOBAL_OFFSET.GetValue()+"\n\n",
2005-05-19 23:29:39 +00:00
fOld,
fNew,
fDelta,
2005-12-21 09:56:16 +00:00
(fDelta > 0 ? EARLIER:LATER).GetValue().c_str() );
2005-05-19 23:29:39 +00:00
}
}
vector<CString> vsSongChanges;
2005-05-19 23:29:39 +00:00
{
float fOld = GAMESTATE->m_pTimingDataOriginal->m_fBeat0OffsetInSeconds;
float fNew = GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds;
float fDelta = fNew - fOld;
if( fabs(fDelta) > 0.00001 )
{
vsSongChanges.push_back( ssprintf(
2005-12-21 09:56:16 +00:00
CHANGED_SONG_OFFSET.GetValue()+"\n\n",
2005-05-19 23:29:39 +00:00
fOld,
fNew,
fDelta,
2005-12-21 09:56:16 +00:00
(fDelta > 0 ? EARLIER:LATER).GetValue().c_str() ) );
2005-05-19 23:29:39 +00:00
}
}
2005-05-20 01:16:46 +00:00
for( unsigned i=0; i<GAMESTATE->m_pCurSong->m_Timing.m_BPMSegments.size(); i++ )
2005-05-19 23:29:39 +00:00
{
float fOld = GAMESTATE->m_pTimingDataOriginal->m_BPMSegments[i].m_fBPS;
float fNew = GAMESTATE->m_pCurSong->m_Timing.m_BPMSegments[i].m_fBPS;
float fDelta = fNew - fOld;
if( fabs(fDelta) > 0.00001 )
{
vsSongChanges.push_back( ssprintf(
2005-12-21 09:56:16 +00:00
CHANGED_BPM.GetValue()+"\n\n",
i+1,
2005-05-19 23:29:39 +00:00
fOld,
fNew,
fDelta ) );
2005-05-19 23:29:39 +00:00
}
}
2005-05-20 01:16:46 +00:00
for( unsigned i=0; i<GAMESTATE->m_pCurSong->m_Timing.m_StopSegments.size(); i++ )
2005-05-19 23:29:39 +00:00
{
float fOld = GAMESTATE->m_pTimingDataOriginal->m_StopSegments[i].m_fStopSeconds;
float fNew = GAMESTATE->m_pCurSong->m_Timing.m_StopSegments[i].m_fStopSeconds;
float fDelta = fNew - fOld;
if( fabs(fDelta) > 0.00001 )
{
vsSongChanges.push_back( ssprintf(
2005-12-21 09:56:16 +00:00
CHANGED_STOP.GetValue()+"\n\n",
i+1,
2005-05-19 23:29:39 +00:00
fOld,
fNew,
fDelta ) );
2005-05-19 23:29:39 +00:00
}
}
if( !vsSongChanges.empty() )
{
s += ssprintf(
2005-12-21 09:56:16 +00:00
CHANGED_TIMING_OF.GetValue()+"\n"
"%s:\n"
"\n",
GAMESTATE->m_pCurSong->GetDisplayFullTitle().c_str() );
s += join( "\n", vsSongChanges );
}
2005-12-21 09:56:16 +00:00
s +="\n\n"+
WOULD_YOU_LIKE_TO_SAVE.GetValue()+"\n"+
CHOOSING_NO_WILL_DISCARD.GetValue();
2005-05-19 23:29:39 +00:00
return s;
}
static void SaveSyncChanges( void* pThrowAway )
{
GAMESTATE->SaveSyncChanges();
}
static void RevertSyncChanges( void* pThrowAway )
{
GAMESTATE->RevertSyncChanges();
}
2006-01-15 19:04:34 +00:00
REGISTER_SCREEN_CLASS_NEW( ScreenSaveSync );
void ScreenSaveSync::Init()
{
2006-01-15 19:04:34 +00:00
ScreenPrompt::Init();
ScreenPrompt::SetPromptSettings(
GetPromptText(),
PROMPT_YES_NO,
ANSWER_YES,
SaveSyncChanges,
RevertSyncChanges,
NULL );
}
void ScreenSaveSync::PromptSaveSync()
{
ScreenPrompt::Prompt(
SM_None,
2005-05-19 23:29:39 +00:00
GetPromptText(),
PROMPT_YES_NO,
ANSWER_YES,
SaveSyncChanges,
RevertSyncChanges,
NULL );
2005-05-19 23:29:39 +00:00
}
/*
* (c) 2001-2005 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.
*/