pretty much equivalent to 23b02ce-adf0feb. [Chris Danford; some other cleanup by AJ]

This commit is contained in:
AJ Kelly
2010-06-12 14:37:20 -05:00
parent 4c44d9f3b6
commit cd2a78e09a
8 changed files with 113 additions and 73 deletions
+11 -1
View File
@@ -9,9 +9,19 @@ Not all changes are documented, for various reasons.
supported but exist anyways.) supported but exist anyways.)
_____________________________________________________________________________ _____________________________________________________________________________
20100612
--------
* sm4svn r28359-r28364. [Chris Danford]
Notable commit logs:
* r28359: "fix BackgroundChange color values being written with commas.
Commas are a reserved character that seprate values in a tag.
Caret was used to separate RGBA values in a color in this case and
NotesLoaderSM already handles that."
* r28361: "normalize colors in BGCHANGES to HTML colors, to fix weird escaping"
20100610 20100610
-------- --------
* Allow Rave and Battle to work again. * Fix Rave/Battle crashes, allowing it to work again.
* Chris Danford changed galopin's code for detecting pump mats. * Chris Danford changed galopin's code for detecting pump mats.
* [Actor] add basezoom, basezoomz, GetBaseZoomY(), GetBaseZoomZ(), and * [Actor] add basezoom, basezoomz, GetBaseZoomY(), GetBaseZoomZ(), and
GetGlow() Lua bindings GetGlow() Lua bindings
+4 -4
View File
@@ -168,8 +168,8 @@ void BackgroundImpl::Init()
if( !USE_STATIC_BG ) if( !USE_STATIC_BG )
{ {
m_StaticBackgroundDef.m_sColor1 = "0,0,0,0"; m_StaticBackgroundDef.m_sColor1 = "#00000000";
m_StaticBackgroundDef.m_sColor2 = "0,0,0,0"; m_StaticBackgroundDef.m_sColor2 = "#00000000";
} }
// load transitions // load transitions
@@ -343,8 +343,8 @@ bool BackgroundImpl::Layer::CreateBackground( const Song *pSong, const Backgroun
ASSERT( !sEffect.empty() ); ASSERT( !sEffect.empty() );
// Set Lua color globals // Set Lua color globals
LuaThreadVariable sColor1( "Color1", bd.m_sColor1.empty() ? RString("1,1,1,1") : bd.m_sColor1 ); LuaThreadVariable sColor1( "Color1", bd.m_sColor1.empty() ? RString("#FFFFFFFF") : bd.m_sColor1 );
LuaThreadVariable sColor2( "Color2", bd.m_sColor2.empty() ? RString("1,1,1,1") : bd.m_sColor2 ); LuaThreadVariable sColor2( "Color2", bd.m_sColor2.empty() ? RString("#FFFFFFFF") : bd.m_sColor2 );
// Resolve the effect file. // Resolve the effect file.
RString sEffectFile; RString sEffectFile;
+9 -13
View File
@@ -275,9 +275,7 @@ void BackgroundUtil::GetGlobalRandomMovies(
return; return;
} }
//
// Search for the most appropriate background // Search for the most appropriate background
//
{ {
set<RString> ssFileNameWhitelist; set<RString> ssFileNameWhitelist;
if( bTryInsideOfSongGroupAndGenreFirst && pSong && !pSong->m_sGenre.empty() ) if( bTryInsideOfSongGroupAndGenreFirst && pSong && !pSong->m_sGenre.empty() )
@@ -300,20 +298,18 @@ void BackgroundUtil::GetGlobalRandomMovies(
if( !ssFileNameWhitelist.empty() ) if( !ssFileNameWhitelist.empty() )
{ {
vector<RString> vsFiltered = vsPathsOut; vector<RString> vsMatches;
for( unsigned i=0; i<vsPathsOut.size(); i++ ) FOREACH_CONST( RString, vsPathsOut, s )
{ {
RString sBasename = Basename( vsPathsOut[i] ); RString sBasename = Basename( *s );
bool bFound = ssFileNameWhitelist.find(sBasename) != ssFileNameWhitelist.end(); bool bFound = ssFileNameWhitelist.find(sBasename) != ssFileNameWhitelist.end();
if( !bFound ) if( bFound )
{ vsMatches.push_back(*s);
vsPathsOut.erase( vsPathsOut.begin()+i );
i--;
} }
} // If we found any that match the whitelist, use only them.
// If we filtered every movie out then this was a bad whitelist, so ignore the whitelist. // If none match the whitelist, ignore the whitelist..
if( !vsFiltered.empty() ) if( !vsMatches.empty() )
vsPathsOut = vsFiltered; vsPathsOut = vsMatches;
} }
if( !vsPathsOut.empty() ) if( !vsPathsOut.empty() )
+40 -24
View File
@@ -24,7 +24,8 @@ static void LoadFromSMTokens(
Steps &out Steps &out
) )
{ {
out.SetSavedToDisk( true ); // we're loading from disk, so this is by definintion already saved // we're loading from disk, so this is by definition already saved:
out.SetSavedToDisk( true );
Trim( sStepsType ); Trim( sStepsType );
Trim( sDescription ); Trim( sDescription );
@@ -38,14 +39,18 @@ static void LoadFromSMTokens(
out.SetDescription( sDescription ); out.SetDescription( sDescription );
out.SetDifficulty( DwiCompatibleStringToDifficulty(sDifficulty) ); out.SetDifficulty( DwiCompatibleStringToDifficulty(sDifficulty) );
// HACK: We used to store SMANIAC as Difficulty_Hard with special description. // Handle hacks that originated back when StepMania didn't have
// Now, it has its own Difficulty_Challenge // Difficulty_Challenge. (At least v1.64, possibly v3.0 final...)
if( out.GetDifficulty() == Difficulty_Hard )
{
// HACK: SMANIAC used to be Difficulty_Hard with a special description.
if( sDescription.CompareNoCase("smaniac") == 0 ) if( sDescription.CompareNoCase("smaniac") == 0 )
out.SetDifficulty( Difficulty_Challenge ); out.SetDifficulty( Difficulty_Challenge );
// HACK: We used to store CHALLENGE as Difficulty_Hard with special description.
// Now, it has its own Difficulty_Challenge // HACK: CHALLENGE used to be Difficulty_Hard with a special description.
if( sDescription.CompareNoCase("challenge") == 0 ) if( sDescription.CompareNoCase("challenge") == 0 )
out.SetDifficulty( Difficulty_Challenge ); out.SetDifficulty( Difficulty_Challenge );
}
out.SetMeter( atoi(sMeter) ); out.SetMeter( atoi(sMeter) );
vector<RString> saValues; vector<RString> saValues;
@@ -88,9 +93,10 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
out.m_fBeat0OffsetInSeconds = 0; out.m_fBeat0OffsetInSeconds = 0;
out.m_BPMSegments.clear(); out.m_BPMSegments.clear();
out.m_StopSegments.clear(); out.m_StopSegments.clear();
//out.m_WarpSegments.clear(); out.m_WarpSegments.clear();
//vector<WarpSegment> arrayWarpsFromNegativeBPMs; vector<WarpSegment> arrayWarpsFromNegativeBPMs;
//vector<WarpSegment> arrayWarpsFromNegativeStops;
for( unsigned i=0; i<msd.GetNumValues(); i++ ) for( unsigned i=0; i<msd.GetNumValues(); i++ )
{ {
@@ -121,13 +127,25 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
const float fFreezeBeat = StringToFloat( arrayFreezeValues[0] ); const float fFreezeBeat = StringToFloat( arrayFreezeValues[0] );
const float fFreezeSeconds = StringToFloat( arrayFreezeValues[1] ); const float fFreezeSeconds = StringToFloat( arrayFreezeValues[1] );
StopSegment new_seg( BeatToNoteRow(fFreezeBeat), fFreezeSeconds ); StopSegment new_seg( BeatToNoteRow(fFreezeBeat), fFreezeSeconds );
if(fFreezeSeconds > 0.0f)
{
// LOG->Trace( "Adding a freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds ); // LOG->Trace( "Adding a freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds );
out.AddStopSegment( new_seg ); out.AddStopSegment( new_seg );
} }
else
{
// negative stops (hi JS!) -aj
if( PREFSMAN->m_bQuirksMode )
{
// LOG->Trace( "Adding a negative freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds );
out.AddStopSegment( new_seg );
}
else
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid stop at beat %f, length %f.", fFreezeBeat, fFreezeSeconds );
}
}
} }
else if( sValueName=="DELAYS" ) else if( sValueName=="DELAYS" )
{ {
@@ -153,7 +171,10 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
// LOG->Trace( "Adding a delay segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds ); // LOG->Trace( "Adding a delay segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds );
if(fFreezeSeconds > 0.0f)
out.AddStopSegment( new_seg ); out.AddStopSegment( new_seg );
else
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid delay at beat %f, length %f.", fFreezeBeat, fFreezeSeconds );
} }
} }
@@ -178,7 +199,6 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
const float fNewBPM = StringToFloat( arrayBPMChangeValues[1] ); const float fNewBPM = StringToFloat( arrayBPMChangeValues[1] );
// convert negative BPMs into Warp segments // convert negative BPMs into Warp segments
/*
if( fNewBPM < 0.0f ) if( fNewBPM < 0.0f )
{ {
vector<RString> arrayNextBPMChangeValues; vector<RString> arrayNextBPMChangeValues;
@@ -194,7 +214,6 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
float fWarpToBeat = fNextPositiveBeat + fDeltaBeat; float fWarpToBeat = fNextPositiveBeat + fDeltaBeat;
WarpSegment wsTemp(BeatToNoteRow(fBeat),BeatToNoteRow(fWarpToBeat)); WarpSegment wsTemp(BeatToNoteRow(fBeat),BeatToNoteRow(fWarpToBeat));
arrayWarpsFromNegativeBPMs.push_back(wsTemp); arrayWarpsFromNegativeBPMs.push_back(wsTemp);
*/
/* /*
LOG->Trace( ssprintf("==NotesLoSM negbpm==\nfnextposbeat = %f, fnextposbpm = %f,\nfdelta = %f, fwarpto = %f", LOG->Trace( ssprintf("==NotesLoSM negbpm==\nfnextposbeat = %f, fnextposbpm = %f,\nfdelta = %f, fwarpto = %f",
fNextPositiveBeat, fNextPositiveBeat,
@@ -217,24 +236,20 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
fDeltaBeat,(fNextPositiveBPM/60.0f),abs(fNewBPM/60.0f),BeatToNoteRow(fNextPositiveBeat),BeatToNoteRow(fBeat)) fDeltaBeat,(fNextPositiveBPM/60.0f),abs(fNewBPM/60.0f),BeatToNoteRow(fNextPositiveBeat),BeatToNoteRow(fBeat))
); );
*/ */
/*
} }
else else
{ {
// last BPM is a negative one? ugh. -aj (MAX_NOTE_ROW exists btw) // last BPM is a negative one? ugh. -aj (MAX_NOTE_ROW exists btw)
} }
} }
*/
if( PREFSMAN->m_bQuirksMode ) if(fNewBPM > 0.0f)
{
// in quirks mode, accept all BPMs, not just positives.
// xxx: make this work for decent simfiles only? (lol) -aj
out.AddBPMSegment( BPMSegment(BeatToNoteRow(fBeat), fNewBPM) ); out.AddBPMSegment( BPMSegment(BeatToNoteRow(fBeat), fNewBPM) );
}
else else
{ {
if( fNewBPM > 0.0f ) out.m_bHasNegativeBpms = true;
// only add Negative BPMs in quirks mode -aj
if( PREFSMAN->m_bQuirksMode )
out.AddBPMSegment( BPMSegment(BeatToNoteRow(fBeat), fNewBPM) ); out.AddBPMSegment( BPMSegment(BeatToNoteRow(fBeat), fNewBPM) );
else else
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid BPM change at beat %f, BPM %f.", fBeat, fNewBPM ); LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid BPM change at beat %f, BPM %f.", fBeat, fNewBPM );
@@ -323,12 +338,12 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
} }
} }
} }
*/
// We should not support files that contain both Negative BPMs & Warps. // We should not support files that contain both Negative BPMs & Warps.
// If Warps have been populated from Negative BPMs, then go through that // If Warps have been populated from Negative BPMs, then go through that
// instead of using the data in the Warps tag. This should be above, // instead of using the data in the Warps tag. This should be above,
// but it breaks compiling so... // but it breaks compiling so...
{
if(arrayWarpsFromNegativeBPMs.size() > 0) if(arrayWarpsFromNegativeBPMs.size() > 0)
{ {
// zomg we already have some warps... // zomg we already have some warps...
@@ -338,8 +353,6 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
} }
// sorting will need to take place somewhere. // sorting will need to take place somewhere.
} }
}
*/
} }
} }
@@ -356,10 +369,12 @@ bool LoadFromBGChangesString( BackgroundChange &change, const RString &sBGChange
case 11: case 11:
change.m_def.m_sColor2 = aBGChangeValues[10]; change.m_def.m_sColor2 = aBGChangeValues[10];
change.m_def.m_sColor2.Replace( '^', ',' ); change.m_def.m_sColor2.Replace( '^', ',' );
change.m_def.m_sColor2 = RageColor::NormalizeColorString( change.m_def.m_sColor2 );
// fall through // fall through
case 10: case 10:
change.m_def.m_sColor1 = aBGChangeValues[9]; change.m_def.m_sColor1 = aBGChangeValues[9];
change.m_def.m_sColor1.Replace( '^', ',' ); change.m_def.m_sColor1.Replace( '^', ',' );
change.m_def.m_sColor1 = RageColor::NormalizeColorString( change.m_def.m_sColor1 );
// fall through // fall through
case 9: case 9:
change.m_sTransition = aBGChangeValues[8]; change.m_sTransition = aBGChangeValues[8];
@@ -564,8 +579,9 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
out.m_SelectionDisplay = out.SHOW_ALWAYS; out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if(!stricmp(sParams[1],"NO")) else if(!stricmp(sParams[1],"NO"))
out.m_SelectionDisplay = out.SHOW_NEVER; out.m_SelectionDisplay = out.SHOW_NEVER;
// handle ROULETTE from 3.9. todo: re-implement. // ROULETTE from 3.9. It was removed since UnlockManager can serve
// (Why was it removed?) // the same purpose somehow. This, of course, assumes you're using
// unlocks. -aj
else if(!stricmp(sParams[1],"ROULETTE")) else if(!stricmp(sParams[1],"ROULETTE"))
out.m_SelectionDisplay = out.SHOW_ALWAYS; out.m_SelectionDisplay = out.SHOW_ALWAYS;
/* The following two cases are just fixes to make sure simfiles that /* The following two cases are just fixes to make sure simfiles that
+3 -11
View File
@@ -16,14 +16,6 @@
#include "Song.h" #include "Song.h"
#include "Steps.h" #include "Steps.h"
static RString EscapeBackgroundColor( const RString color )
{
// Comma separates values in a background change. Caret separates RGBA values in a color value, and NotesLoaderSM switches them to commas on load.
RString c = color;
c.Replace(",", "^");
return c;
}
static RString BackgroundChangeToString( const BackgroundChange &bgc ) static RString BackgroundChangeToString( const BackgroundChange &bgc )
{ {
// TODO: Technically we need to double-escape the filename (because it might contain '=') and then // TODO: Technically we need to double-escape the filename (because it might contain '=') and then
@@ -39,15 +31,15 @@ static RString BackgroundChangeToString( const BackgroundChange &bgc )
bgc.m_def.m_sEffect.c_str(), bgc.m_def.m_sEffect.c_str(),
bgc.m_def.m_sFile2.c_str(), bgc.m_def.m_sFile2.c_str(),
bgc.m_sTransition.c_str(), bgc.m_sTransition.c_str(),
SmEscape(EscapeBackgroundColor(bgc.m_def.m_sColor1)).c_str(), SmEscape(RageColor::NormalizeColorString(bgc.m_def.m_sColor1)).c_str(),
SmEscape(EscapeBackgroundColor(bgc.m_def.m_sColor2)).c_str() SmEscape(RageColor::NormalizeColorString(bgc.m_def.m_sColor2)).c_str()
); );
return s; return s;
} }
static void WriteGlobalTags( RageFile &f, const Song &out ) static void WriteGlobalTags( RageFile &f, const Song &out )
{ {
//f.PutLine( ssprintf( "#SMVERSION:;", SmEscape(RString("ssc-v1.0_b2")).c_str() ) ); //f.PutLine( ssprintf( "#SMVERSION:;", SmEscape(RString("ssc-v1.0")).c_str() ) );
f.PutLine( ssprintf( "#TITLE:%s;", SmEscape(out.m_sMainTitle).c_str() ) ); f.PutLine( ssprintf( "#TITLE:%s;", SmEscape(out.m_sMainTitle).c_str() ) );
f.PutLine( ssprintf( "#SUBTITLE:%s;", SmEscape(out.m_sSubTitle).c_str() ) ); f.PutLine( ssprintf( "#SUBTITLE:%s;", SmEscape(out.m_sSubTitle).c_str() ) );
f.PutLine( ssprintf( "#ARTIST:%s;", SmEscape(out.m_sArtist).c_str() ) ); f.PutLine( ssprintf( "#ARTIST:%s;", SmEscape(out.m_sArtist).c_str() ) );
+23
View File
@@ -51,6 +51,29 @@ void RageColor::FromStackCompat( lua_State *L, int iPos )
} }
} }
RString RageColor::ToString() const
{
int iR = clamp( (int) lrintf(r * 255), 0, 255 );
int iG = clamp( (int) lrintf(g * 255), 0, 255 );
int iB = clamp( (int) lrintf(b * 255), 0, 255 );
int iA = clamp( (int) lrintf(a * 255), 0, 255 );
if( iA == 255 )
return ssprintf( "#%02X%02X%02X", iR, iG, iB );
else
return ssprintf( "#%02X%02X%02X%02X", iR, iG, iB, iA );
}
RString RageColor::NormalizeColorString( RString sColor )
{
if( sColor.empty() )
return "";
RageColor c;
if( !c.FromString(sColor) )
return "";
return c.ToString();
}
namespace LuaHelpers namespace LuaHelpers
{ {
template<> bool FromStack<RageColor>( lua_State *L, RageColor &Object, int iOffset ) template<> bool FromStack<RageColor>( lua_State *L, RageColor &Object, int iOffset )
+3
View File
@@ -243,6 +243,9 @@ public:
return false; return false;
} }
RString ToString() const;
static RString NormalizeColorString( RString sColor );
void PushTable( lua_State *L ) const; void PushTable( lua_State *L ) const;
void FromStack( lua_State *L, int iPos ); void FromStack( lua_State *L, int iPos );
void FromStackCompat( lua_State *L, int iPos ); void FromStackCompat( lua_State *L, int iPos );
+2 -2
View File
@@ -594,8 +594,8 @@ static MenuDef g_BackgroundChange(
MenuRowDef( ScreenEdit::rate, "Rate", true, EditMode_Full, true, false, 10, "0%","10%","20%","30%","40%","50%","60%","70%","80%","90%","100%","120%","140%","160%","180%","200%","220%","240%","260%","280%","300%","350%","400%" ), MenuRowDef( ScreenEdit::rate, "Rate", true, EditMode_Full, true, false, 10, "0%","10%","20%","30%","40%","50%","60%","70%","80%","90%","100%","120%","140%","160%","180%","200%","220%","240%","260%","280%","300%","350%","400%" ),
MenuRowDef( ScreenEdit::transition, "Force Transition", true, EditMode_Full, true, false, 0, NULL ), MenuRowDef( ScreenEdit::transition, "Force Transition", true, EditMode_Full, true, false, 0, NULL ),
MenuRowDef( ScreenEdit::effect, "Force Effect", true, EditMode_Full, true, false, 0, NULL ), MenuRowDef( ScreenEdit::effect, "Force Effect", true, EditMode_Full, true, false, 0, NULL ),
MenuRowDef( ScreenEdit::color1, "Force Color 1", true, EditMode_Full, true, false, 0, "-","1,1,1,1","0.5,0.5,0.5,1","1,1,1,0.5","0,0,0,1","1,0,0,1","0,1,0,1","0,0,1,1","1,1,0,1","0,1,1,1","1,0,1,1" ), MenuRowDef( ScreenEdit::color1, "Force Color 1", true, EditMode_Full, true, false, 0, "-","#FFFFFF","#808080","#FFFFFF80","#000000","#FF0000","#00FF00","#0000FF","#FFFF00","#00FFFF","#FF00FF" ),
MenuRowDef( ScreenEdit::color2, "Force Color 2", true, EditMode_Full, true, false, 0, "-","1,1,1,1","0.5,0.5,0.5,1","1,1,1,0.5","0,0,0,1","1,0,0,1","0,1,0,1","0,0,1,1","1,1,0,1","0,1,1,1","1,0,1,1" ), MenuRowDef( ScreenEdit::color2, "Force Color 2", true, EditMode_Full, true, false, 0, "-","#FFFFFF","#808080","#FFFFFF80","#000000","#FF0000","#00FF00","#0000FF","#FFFF00","#00FFFF","#FF00FF" ),
MenuRowDef( ScreenEdit::file1_type, "File1 Type", true, EditMode_Full, true, true, 0, "Song BGAnimation", "Song Movie", "Song Bitmap", "Global BGAnimation", "Global Movie", "Global Movie from Song Group", "Global Movie from Song Group and Genre", "Dynamic Random", "Baked Random", "None" ), MenuRowDef( ScreenEdit::file1_type, "File1 Type", true, EditMode_Full, true, true, 0, "Song BGAnimation", "Song Movie", "Song Bitmap", "Global BGAnimation", "Global Movie", "Global Movie from Song Group", "Global Movie from Song Group and Genre", "Dynamic Random", "Baked Random", "None" ),
MenuRowDef( ScreenEdit::file1_song_bganimation, "File1 Song BGAnimation", EnabledIfSet1SongBGAnimation, EditMode_Full, true, false, 0, NULL ), MenuRowDef( ScreenEdit::file1_song_bganimation, "File1 Song BGAnimation", EnabledIfSet1SongBGAnimation, EditMode_Full, true, false, 0, NULL ),
MenuRowDef( ScreenEdit::file1_song_movie, "File1 Song Movie", EnabledIfSet1SongMovie, EditMode_Full, true, false, 0, NULL ), MenuRowDef( ScreenEdit::file1_song_movie, "File1 Song Movie", EnabledIfSet1SongMovie, EditMode_Full, true, false, 0, NULL ),