コード例 #1
0
void
nsXMLEventsManager::ContentAppended(nsIDocument* aDocument,
                                    nsIContent* aContainer,
                                    PRInt32 aNewIndexInContainer)
{
  AddListeners(aDocument);
}
コード例 #2
0
void
nsXMLEventsManager::ContentInserted(nsIDocument* aDocument,
                                    nsIContent* aContainer,
                                    nsIContent* aChild,
                                    PRInt32 aIndexInContainer)
{
  AddListeners(aDocument);
}
コード例 #3
0
void
nsXMLEventsManager::AttributeChanged(nsIDocument* aDocument,
                                     nsIContent* aContent,
                                     PRInt32 aNameSpaceID,
                                     nsIAtom* aAttribute,
                                     PRInt32 aModType,
                                     PRUint32 aStateMask)
{
  if (aNameSpaceID == kNameSpaceID_XMLEvents &&
      (aAttribute == nsGkAtoms::event ||
       aAttribute == nsGkAtoms::handler ||
       aAttribute == nsGkAtoms::target ||
       aAttribute == nsGkAtoms::observer ||
       aAttribute == nsGkAtoms::phase ||
       aAttribute == nsGkAtoms::propagate)) {
    RemoveListener(aContent);
    AddXMLEventsContent(aContent);
    nsXMLEventsListener::InitXMLEventsListener(aDocument, this, aContent);
  }
  else {
    if (aContent->NodeInfo()->Equals(nsGkAtoms::listener,
                                     kNameSpaceID_XMLEvents)) {
      RemoveListener(aContent);
      AddXMLEventsContent(aContent);
      nsXMLEventsListener::InitXMLEventsListener(aDocument, this, aContent);
    }
    else if (aContent->GetIDAttributeName() == aAttribute) {
      if (aModType == nsIDOMMutationEvent::REMOVAL)
        mListeners.Enumerate(EnumAndSetIncomplete, aContent);
      else if (aModType == nsIDOMMutationEvent::MODIFICATION) {
        //Remove possible listener
        mListeners.Enumerate(EnumAndSetIncomplete, aContent);
        //Add new listeners
        AddListeners(aDocument);
      }
      else {
        //If we are adding the ID attribute, we must check whether we can 
        //add new listeners
        AddListeners(aDocument);
      }
    }
  }
}
コード例 #4
0
//Logic from CASW_Random_Missions::BuildAndLaunchRandomLevel
void MOD_Level_Builder::BuildMapFromLayoutFile( const char *szMissionRuleFile, const char *szOutputLayoutFile, const char *szThemeName, bool bCompileLevel)
{
	if (IsBuildingLevel())
	{
		Msg("mod_level_builder is already building a level!\n");
		return;
	}
	
	Msg("Building Map.  MR File: [%s], Layout File: [%s], Theme: [%s]\n\n", 
		szMissionRuleFile, szOutputLayoutFile, szThemeName);

	/*Code taken from TileGenDialog.cpp*/
	KeyValues *pGenerationOptions = new KeyValues("EmptyOptions");
	pGenerationOptions->Clear();
	pGenerationOptions->LoadFromFile(g_pFullFileSystem, szMissionRuleFile, GAME_DIRECTORY);	

	CLayoutSystem *pLayoutSystem = new CLayoutSystem();

	CTilegenMissionPreprocessor *pMissionPreprocessor = new CTilegenMissionPreprocessor();

	CASW_KeyValuesDatabase *pRulesDatabase = new CASW_KeyValuesDatabase();
	pRulesDatabase->LoadFiles( "tilegen/rules/" );
	for ( int i = 0; i < pRulesDatabase->GetFileCount(); ++ i )
	{
		pMissionPreprocessor->ParseAndStripRules( pRulesDatabase->GetFile( i ) );
	}
	
	if (pMissionPreprocessor->SubstituteRules(pGenerationOptions) )
	{
		KeyValues *pMissionSettings = pGenerationOptions->FindKey( "mission_settings" ); 

		if ( pMissionSettings == NULL )
		{
			Warning("Mission is missing a Global Options Block!\n");
			return;
		}

		// Copy the filename key over
		pMissionSettings->SetString( "Filename", pGenerationOptions->GetString( "Filename", "invalid_filename" ) );
					
		AddListeners( pLayoutSystem );
		if ( !pLayoutSystem->LoadFromKeyValues( pGenerationOptions ) )
		{
			Warning("Failed to load mission from pre-processed key-values.");			
			return;
		}		

		int safteyCounter = 0;
		CMapLayout *pMapLayout = NULL;
		while (pMapLayout == NULL)
		{
			pMapLayout = GenerateMapLayout(pLayoutSystem, pMissionSettings);
			safteyCounter++;
			if (safteyCounter > 10)
			{
				Warning("MOD_Level_Builder failed generating a layout from layout file [%s]", szMissionRuleFile);
				return;
			}				
		}
			
		

		char* fullPath = (char*)malloc(sizeof(char)*1024);
		strcat(fullPath, g_gamedir);
		strcat(fullPath, szOutputLayoutFile);

		Q_strcpy(pMapLayout->m_szFilename, fullPath);	

		Msg("Saving layout file to [%s]", fullPath);
		if (!pMapLayout->SaveMapLayout( fullPath ))
		{
			Warning("Failed to save Layout file to [%s]", fullPath);
			return;
		}

		if (bCompileLevel)
			CompileLevel(szOutputLayoutFile);
	}
	else
	{
		Warning("Failed Initializting Mission Preprocessor\n");
		return;
	}		
}
コード例 #5
0
void CASW_Map_Builder::Update( float flEngineTime )
{
	if ( m_bRunningProcess )
	{
		ProcessExecution();
	}
	else if ( m_iBuildStage == STAGE_MAP_BUILD_SCHEDULED )
	{
		if ( m_flStartProcessingTime < flEngineTime )
		{
			BuildMap();
		}
	}
	else if ( m_iBuildStage == STAGE_VBSP2 )
	{
		UpdateVBSP2Progress();
	}
	else if ( m_iBuildStage == STAGE_GENERATE )
	{
		if ( m_flStartProcessingTime < flEngineTime )
		{
			if ( !m_bStartedGeneration )
			{
				delete m_pGeneratedMapLayout;
				delete m_pLayoutSystem;
				m_pLayoutSystem = new CLayoutSystem();
				AddListeners( m_pLayoutSystem );
				m_pGeneratedMapLayout = new CMapLayout( m_pMissionSettings->MakeCopy() );

				if ( !m_pLayoutSystem->LoadFromKeyValues( m_pMissionDefinition ) )
				{
					Log_Warning( LOG_TilegenLayoutSystem, "Failed to load mission from key values definition.\n" );
					m_iBuildStage = STAGE_NONE;
					return;
				}
				m_pLayoutSystem->BeginGeneration( m_pGeneratedMapLayout );
				m_bStartedGeneration = true;
			}
			else
			{
				if ( m_pLayoutSystem->IsGenerating() )
				{
					m_pLayoutSystem->ExecuteIteration();

					// If an error occurred and this map is randomly generated, try again and hope we get a successful layout this time.
					if ( m_pLayoutSystem->GenerationErrorOccurred() )
					{
						if ( m_nLevelGenerationRetryCount < tilegen_retry_count.GetInt() && m_pLayoutSystem->IsRandomlyGenerated() )
						{
							// Error generating layout
							Log_Msg( LOG_TilegenGeneral, "Retrying layout generation...\n" );
							m_pGeneratedMapLayout->Clear();
							m_pLayoutSystem->BeginGeneration( m_pGeneratedMapLayout );
							++ m_nLevelGenerationRetryCount;
						}
						else
						{
							Log_Warning( LOG_TilegenGeneral, "Failed to generate valid map layout after %d tries...\n", tilegen_retry_count.GetInt() );
							m_iBuildStage = STAGE_NONE;
						}
					}
				}
				else
				{
					Log_Msg( LOG_TilegenGeneral, "Map layout generated\n" );
					m_iBuildStage = STAGE_NONE;
					
					char layoutFilename[MAX_PATH];
					Q_snprintf( layoutFilename, MAX_PATH, "maps\\%s", m_szLayoutName );
					m_pGeneratedMapLayout->SaveMapLayout( layoutFilename );

					delete m_pGeneratedMapLayout;
					m_pGeneratedMapLayout = NULL;

					BuildMap();
				}
			}
		}
	}
}
コード例 #6
0
void 
nsXMLEventsManager::EndLoad(nsIDocument* aDocument)
{
  AddListeners(aDocument);
}