Layer* OpBackground::DoCreateBackgroundLayer(UndoableOperation * pOp, Spread * pSpread) { ERROR2IF(pOp == NULL || pSpread == NULL,FALSE,"OpBackground::DoCreateBackgroundLayer Bad params error!"); // Search for our special page background layer Layer* pFoundLayer = pSpread->FindFirstPageBackgroundLayer(); // If we have found it then return this to the caller as we don't want // more than one present! if (pFoundLayer != NULL) return pFoundLayer; // We didn't find a page background layer so go and create a new one Layer* pNewLayer = CreateBackgroundLayer(); if (pNewLayer != NULL) { // If we insert the new layer as the FIRSTCHILD then this will be like the guidelayer // and behind the page. If we insert as the last child then we will be at the front of // the stacking order. We need to insert ourselves as the node after the last page node Page *pLastPage = pSpread->FindLastPageInSpread(); // Insert the new layer as the next node after the last page. if (pLastPage && pOp->DoInsertNewNode(pNewLayer, pLastPage, NEXT, FALSE,FALSE,FALSE,FALSE)) { pNewLayer->EnsureUniqueLayerID(); BROADCAST_TO_ALL(SpreadMsg(pSpread, SpreadMsg::LAYERCHANGES)); } else { delete pNewLayer; pNewLayer = NULL; } } return pNewLayer; }
bool GGameScene::CreateScene(GStageInfo* pStageInfo) { mpStageInfo = pStageInfo; if( CreateBackgroundLayer( pStageInfo->GetBackgroundFileName() ) == false ) return false; if( CreateInterfaceLayer( pStageInfo->GetInterfaceFileName() ) == false ) return false; GStageInfo::GCastlePositions castlePos; pStageInfo->GetForcesCastlePosition( castlePos ); mpsForcesCastle = GCastleForces::CreateCastle( mLayers[LAYER_INTERFACE], mLayers[LAYER_BACKGROUND] ,pStageInfo, pStageInfo->GetForcesCastleFiles(), &castlePos ); pStageInfo->GetEnemyCastlePosition( castlePos ); mpsEnemyCastle = GCastleEnemy::CreateCastle( mLayers[LAYER_INTERFACE], mLayers[LAYER_BACKGROUND] ,pStageInfo, pStageInfo->GetEnemyCastleFiles(), &castlePos ); return true; }