/* Find an announcer directory with sounds in it. First search sFolderName, * then all aliases above. Ignore directories that are empty, since we might * have "select difficulty intro" with sounds and an empty "ScreenSelectDifficulty * intro". */ RString AnnouncerManager::GetPathTo( RString sAnnouncerName, RString sFolderName ) { if(sAnnouncerName == "") return RString(); /* announcer disabled */ const RString AnnouncerPath = GetAnnouncerDirFromName(sAnnouncerName); if( !DirectoryIsEmpty(AnnouncerPath+sFolderName+"/") ) return AnnouncerPath+sFolderName+"/"; /* Search for the announcer folder in the list of aliases. */ int i; for(i = 0; aliases[i][0] != NULL; ++i) { if(!sFolderName.EqualsNoCase(aliases[i][0])) continue; /* no match */ if( !DirectoryIsEmpty(AnnouncerPath+aliases[i][1]+"/") ) return AnnouncerPath+aliases[i][1]+"/"; } /* 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'.", 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(); }
void BGAnimationLayer::LoadFromNode( const XNode* pNode ) { { bool bCond; if( pNode->GetAttrValue("Condition", bCond) && !bCond ) return; } bool bStretch = false; { RString type = "sprite"; pNode->GetAttrValue( "Type", type ); type.MakeLower(); /* The preferred way of stretching a sprite to fit the screen is "Type=sprite" * and "stretch=1". "type=1" is for backwards-compatibility. */ pNode->GetAttrValue( "Stretch", bStretch ); // Check for string match first, then do integer match. // "if(StringType(type)==0)" was matching against all string matches. // -Chris if( type.EqualsNoCase("sprite") ) { m_Type = TYPE_SPRITE; } else if( type.EqualsNoCase("particles") ) { m_Type = TYPE_PARTICLES; } else if( type.EqualsNoCase("tiles") ) { m_Type = TYPE_TILES; } else if( StringToInt(type) == 1 ) { m_Type = TYPE_SPRITE; bStretch = true; } else if( StringToInt(type) == 2 ) { m_Type = TYPE_PARTICLES; } else if( StringToInt(type) == 3 ) { m_Type = TYPE_TILES; } else { m_Type = TYPE_SPRITE; } } pNode->GetAttrValue( "FOV", m_fFOV ); pNode->GetAttrValue( "Lighting", m_bLighting ); pNode->GetAttrValue( "TexCoordVelocityX", m_fTexCoordVelocityX ); pNode->GetAttrValue( "TexCoordVelocityY", m_fTexCoordVelocityY ); // compat: pNode->GetAttrValue( "StretchTexCoordVelocityX", m_fTexCoordVelocityX ); pNode->GetAttrValue( "StretchTexCoordVelocityY", m_fTexCoordVelocityY ); // particle and tile stuff float fZoomMin = 1; float fZoomMax = 1; pNode->GetAttrValue( "ZoomMin", fZoomMin ); pNode->GetAttrValue( "ZoomMax", fZoomMax ); float fVelocityXMin = 10, fVelocityXMax = 10; float fVelocityYMin = 0, fVelocityYMax = 0; float fVelocityZMin = 0, fVelocityZMax = 0; float fOverrideSpeed = 0; // 0 means don't override speed pNode->GetAttrValue( "VelocityXMin", fVelocityXMin ); pNode->GetAttrValue( "VelocityXMax", fVelocityXMax ); pNode->GetAttrValue( "VelocityYMin", fVelocityYMin ); pNode->GetAttrValue( "VelocityYMax", fVelocityYMax ); pNode->GetAttrValue( "VelocityZMin", fVelocityZMin ); pNode->GetAttrValue( "VelocityZMax", fVelocityZMax ); pNode->GetAttrValue( "OverrideSpeed", fOverrideSpeed ); int iNumParticles = 10; pNode->GetAttrValue( "NumParticles", iNumParticles ); pNode->GetAttrValue( "ParticlesBounce", m_bParticlesBounce ); pNode->GetAttrValue( "TilesStartX", m_fTilesStartX ); pNode->GetAttrValue( "TilesStartY", m_fTilesStartY ); pNode->GetAttrValue( "TilesSpacingX", m_fTilesSpacingX ); pNode->GetAttrValue( "TilesSpacingY", m_fTilesSpacingY ); pNode->GetAttrValue( "TileVelocityX", m_fTileVelocityX ); pNode->GetAttrValue( "TileVelocityY", m_fTileVelocityY ); switch( m_Type ) { case TYPE_SPRITE: { Actor* pActor = ActorUtil::LoadFromNode( pNode, this ); this->AddChild( pActor ); if( bStretch ) pActor->StretchTo( FullScreenRectF ); } break; case TYPE_PARTICLES: { RString sFile; ActorUtil::GetAttrPath( pNode, "File", sFile ); FixSlashesInPlace( sFile ); CollapsePath( sFile ); for( int i=0; i<iNumParticles; i++ ) { Actor* pActor = ActorUtil::MakeActor( sFile, this ); if( pActor == NULL ) continue; this->AddChild( pActor ); pActor->SetXY( randomf(float(FullScreenRectF.left),float(FullScreenRectF.right)), randomf(float(FullScreenRectF.top),float(FullScreenRectF.bottom)) ); pActor->SetZoom( randomf(fZoomMin,fZoomMax) ); m_vParticleVelocity.push_back( RageVector3( randomf(fVelocityXMin,fVelocityXMax), randomf(fVelocityYMin,fVelocityYMax), randomf(fVelocityZMin,fVelocityZMax) ) ); if( fOverrideSpeed != 0 ) { RageVec3Normalize( &m_vParticleVelocity[i], &m_vParticleVelocity[i] ); m_vParticleVelocity[i] *= fOverrideSpeed; } } } break; case TYPE_TILES: { RString sFile; ActorUtil::GetAttrPath( pNode, "File", sFile ); FixSlashesInPlace( sFile ); CollapsePath( sFile ); AutoActor s; s.Load( sFile ); if( m_fTilesSpacingX == -1 ) m_fTilesSpacingX = s->GetUnzoomedWidth(); if( m_fTilesSpacingY == -1 ) m_fTilesSpacingY = s->GetUnzoomedHeight(); m_iNumTilesWide = 2+(int)(SCREEN_WIDTH /m_fTilesSpacingX); m_iNumTilesHigh = 2+(int)(SCREEN_HEIGHT/m_fTilesSpacingY); unsigned NumSprites = m_iNumTilesWide * m_iNumTilesHigh; for( unsigned i=0; i<NumSprites; i++ ) { Actor* pSprite = ActorUtil::MakeActor( sFile, this ); if( pSprite == NULL ) continue; this->AddChild( pSprite ); pSprite->SetTextureWrapping( true ); // gets rid of some "cracks" pSprite->SetZoom( randomf(fZoomMin,fZoomMax) ); } } break; default: FAIL_M(ssprintf("Unrecognized layer type: %i", m_Type)); } bool bStartOnRandomFrame = false; pNode->GetAttrValue( "StartOnRandomFrame", bStartOnRandomFrame ); if( bStartOnRandomFrame ) { for( unsigned i=0; i<m_SubActors.size(); i++ ) m_SubActors[i]->SetState( RandomInt(m_SubActors[i]->GetNumStates()) ); } }
static bool EqualsNoCase( const RString &s1, const RString &s2 ) { return s1.EqualsNoCase(s2); }