void PlayerAI::InitFromDisk() { IniFile ini; ini.ReadFile( AI_PATH ); for( int i=0; i<NUM_SKILL_LEVELS; i++ ) { CString sKey = ssprintf("Skill%d", i); XNode* pNode = ini.GetChild(sKey); if( pNode == NULL ) RageException::Throw( "AI.ini: '%s' doesn't exist.", sKey.c_str() ); TapScoreDistribution& dist = g_Distributions[i]; dist.fPercent[TNS_NONE] = 0; pNode->GetAttrValue( "MissWeight", dist.fPercent[TNS_MISS] ); pNode->GetAttrValue( "BooWeight", dist.fPercent[TNS_BOO] ); pNode->GetAttrValue( "GoodWeight", dist.fPercent[TNS_GOOD] ); pNode->GetAttrValue( "GreatWeight", dist.fPercent[TNS_GREAT] ); pNode->GetAttrValue( "PerfectWeight", dist.fPercent[TNS_PERFECT] ); pNode->GetAttrValue( "MarvelousWeight", dist.fPercent[TNS_MARVELOUS] ); float fSum = 0; for( int j=0; j<NUM_TAP_NOTE_SCORES; j++ ) fSum += dist.fPercent[j]; for( int j=0; j<NUM_TAP_NOTE_SCORES; j++ ) dist.fPercent[j] /= fSum; } }
bool PropertySet::XMLLoad(XNode *pBackupNode) { XNode *pPropertiesNode = pBackupNode->GetChild(_T("Properties")); if (!pPropertiesNode) return true; for (int i = 0; i < pPropertiesNode->GetChildCount(); i++) { XNode *pPropertyNode = pPropertiesNode->GetChild(i); String sName = pPropertyNode->name; String sStringValue = pPropertyNode->GetAttrValue(_T("StringValue")); int iLongValue = _ttoi(pPropertyNode->GetAttrValue(_T("LongValue"))); std::shared_ptr<Property> pProperty = GetProperty_(sName); if (pProperty) { pProperty->SetStringValue(sStringValue); pProperty->SetLongValue(iLongValue); } } return true; }
void Transition::Load( CString sBGAniDir ) { if( IsADirectory(sBGAniDir) && sBGAniDir.Right(1) != "/" ) sBGAniDir += "/"; this->RemoveAllChildren(); m_sprTransition.Load( sBGAniDir ); m_sprTransition->PlayCommand( "On" ); this->AddChild( m_sprTransition ); m_fLengthSeconds = m_sprTransition->GetTweenTimeLeft(); m_State = waiting; // load sound from file specified by ini, or use the first sound in the directory if( IsADirectory(sBGAniDir) ) { IniFile ini; ini.ReadFile( sBGAniDir+"/BGAnimation.ini" ); CString sSoundFileName; if( ini.GetValue("BGAnimation","Sound", sSoundFileName) ) { FixSlashesInPlace( sSoundFileName ); CString sPath = sBGAniDir+sSoundFileName; CollapsePath( sPath ); m_sound.Load( sPath ); } else { m_sound.Load( sBGAniDir ); } } else if( GetExtension(sBGAniDir).CompareNoCase("xml") == 0 ) { CString sSoundFile; XNode xml; xml.LoadFromFile( sBGAniDir ); if( xml.GetAttrValue( "Sound", sSoundFile ) ) m_sound.Load( Dirname(sBGAniDir) + sSoundFile ); } }
Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor ) { ASSERT( _pNode != NULL ); XNode node = *_pNode; // Remove this in favor of using conditionals in Lua. -Chris // There are a number of themes out there that depend on this (including // sm-ssc default). Probably for the best to leave this in. -aj { bool bCond; if( node.GetAttrValue("Condition", bCond) && !bCond ) return NULL; } RString sClass; bool bHasClass = node.GetAttrValue( "Class", sClass ); if( !bHasClass ) bHasClass = node.GetAttrValue( "Type", sClass ); bool bLegacy = (node.GetAttr( "_LegacyXml" ) != NULL); if( !bHasClass && bLegacy ) sClass = GetLegacyActorClass( &node ); map<RString,CreateActorFn>::iterator iter = g_pmapRegistrees->find( sClass ); if( iter == g_pmapRegistrees->end() ) { RString sFile; if (bLegacy && node.GetAttrValue("File", sFile) && sFile != "") { RString sPath; // Handle absolute paths correctly if (sFile.Left(1) == "/") sPath = sFile; else sPath = Dirname(GetSourcePath(&node)) + sFile; if (ResolvePath(sPath, GetWhere(&node))) { Actor *pNewActor = MakeActor(sPath, pParentActor); if (pNewActor == NULL) return NULL; if (pParentActor) pNewActor->SetParent(pParentActor); pNewActor->LoadFromNode(&node); return pNewActor; } } // sClass is invalid RString sError = ssprintf( "%s: invalid Class \"%s\"", ActorUtil::GetWhere(&node).c_str(), sClass.c_str() ); LuaHelpers::ReportScriptError(sError); return new Actor; // Return a dummy object so that we don't crash in AutoActor later. } const CreateActorFn &pfn = iter->second; Actor *pRet = pfn(); if( pParentActor ) pRet->SetParent( pParentActor ); pRet->LoadFromNode( &node ); return pRet; }
void BackgroundImpl::Init() { if( m_bInitted ) return; m_bInitted = true; m_bDangerAllWasVisible = false; m_StaticBackgroundDef = BackgroundDef(); if( !USE_STATIC_BG ) { m_StaticBackgroundDef.m_sColor1 = "#00000000"; m_StaticBackgroundDef.m_sColor2 = "#00000000"; } // load transitions { ASSERT( m_mapNameToTransition.empty() ); vector<RString> vsPaths, vsNames; BackgroundUtil::GetBackgroundTransitions( "", vsPaths, vsNames ); for( unsigned i=0; i<vsPaths.size(); i++ ) { const RString &sPath = vsPaths[i]; const RString &sName = vsNames[i]; XNode xml; XmlFileUtil::LoadFromFileShowErrors(xml, sPath); ASSERT( xml.GetName() == "BackgroundTransition" ); BackgroundTransition &bgt = m_mapNameToTransition[sName]; RString sCmdLeaves; bool bSuccess = xml.GetAttrValue( "LeavesCommand", sCmdLeaves ); ASSERT( bSuccess ); bgt.cmdLeaves = ActorUtil::ParseActorCommands( sCmdLeaves ); RString sCmdRoot; bSuccess = xml.GetAttrValue( "RootCommand", sCmdRoot ); ASSERT( bSuccess ); bgt.cmdRoot = ActorUtil::ParseActorCommands( sCmdRoot ); } } bool bOneOrMoreChars = false; bool bShowingBeginnerHelper = false; FOREACH_HumanPlayer( p ) { bOneOrMoreChars = true; // Disable dancing characters if Beginner Helper will be showing. if( PREFSMAN->m_bShowBeginnerHelper && BeginnerHelper::CanUse() && GAMESTATE->m_pCurSteps[p] && GAMESTATE->m_pCurSteps[p]->GetDifficulty() == Difficulty_Beginner ) bShowingBeginnerHelper = true; } if( bOneOrMoreChars && !bShowingBeginnerHelper && SHOW_DANCING_CHARACTERS ) m_pDancingCharacters = new DancingCharacters; RageColor c = GetBrightnessColor(0); m_quadBorderLeft.StretchTo( RectF(SCREEN_LEFT,SCREEN_TOP,LEFT_EDGE,SCREEN_BOTTOM) ); m_quadBorderLeft.SetDiffuse( c ); m_quadBorderTop.StretchTo( RectF(LEFT_EDGE,SCREEN_TOP,RIGHT_EDGE,TOP_EDGE) ); m_quadBorderTop.SetDiffuse( c ); m_quadBorderRight.StretchTo( RectF(RIGHT_EDGE,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) ); m_quadBorderRight.SetDiffuse( c ); m_quadBorderBottom.StretchTo( RectF(LEFT_EDGE,BOTTOM_EDGE,RIGHT_EDGE,SCREEN_BOTTOM) ); m_quadBorderBottom.SetDiffuse( c ); this->AddChild( &m_quadBorderLeft ); this->AddChild( &m_quadBorderTop ); this->AddChild( &m_quadBorderRight ); this->AddChild( &m_quadBorderBottom ); this->AddChild( &m_Brightness ); }