当前位置: 首页>>代码示例>>C++>>正文


C++ KeyValues类代码示例

本文整理汇总了C++中KeyValues的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues类的具体用法?C++ KeyValues怎么用?C++ KeyValues使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了KeyValues类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: autodelete

//=============================================================================
void FoundPublicGames::OnCommand( const char *command )
{
	if( V_strcmp( command, "CreateGame" ) == 0 )
	{
		if ( !CanCreateGame() )
		{
			CBaseModPanel::GetSingleton().PlayUISound( UISOUND_INVALID );
			return;
		}

		KeyValues *pSettings = KeyValues::FromString(
			"settings",
			" system { "
			" network LIVE "
			" access friends "
			" } "
			" game { "
			" mode = "
			" campaign = "
			" mission = "
			" } "
			" options { "
			" action create "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		char const *szGameMode = "campaign";
		pSettings->SetString( "game/mode", szGameMode );
		pSettings->SetString( "game/campaign", "jacob" );
		pSettings->SetString( "game/mission", "asi-jac1-landingbay_01" );

		if ( !CUIGameData::Get()->SignedInToLive() )
		{
			pSettings->SetString( "system/network", "lan" );
			pSettings->SetString( "system/access", "public" );
		}

		if ( StringHasPrefix( szGameMode, "team" ) )
		{
			pSettings->SetString( "system/netflag", "teamlobby" );
		}
		else if ( !Q_stricmp( "custommatch", m_pDataSettings->GetString( "options/action", "" ) ) )
		{
			pSettings->SetString( "system/access", "public" );
		}

		// TCR: We need to respect the default difficulty
		pSettings->SetString( "game/difficulty", GameModeGetDefaultDifficulty( szGameMode ) );

		CBaseModPanel::GetSingleton().PlayUISound( UISOUND_ACCEPT );
		CBaseModPanel::GetSingleton().CloseAllWindows();
		CBaseModPanel::GetSingleton().OpenWindow( WT_GAMESETTINGS, NULL, true, pSettings );
	}
	else if ( !Q_stricmp( command, "StartCustomMatchSearch" ) )
	{
		if ( CheckAndDisplayErrorIfNotLoggedIn() ||
			CUIGameData::Get()->CheckAndDisplayErrorIfNotSignedInToLive( this ) )
		{
			CBaseModPanel::GetSingleton().PlayUISound( UISOUND_DENY );
			return;
		}

		KeyValues *pSettings = NULL;
		bool bDefaultSettings = true;
		if ( FoundGameListItem* gameListItem = static_cast<FoundGameListItem*>( m_GplGames->GetSelectedPanelItem() ) )
		{
			pSettings = gameListItem->GetFullInfo().mpGameDetails;
		}

		if ( !pSettings )
		{
			pSettings = new KeyValues( "settings" );
		}
		else
		{
			pSettings = pSettings->MakeCopy();
			bDefaultSettings = false;
		}

		// Take ownership of allocated/copied keyvalues
		KeyValues::AutoDelete autodelete( pSettings );
		char const *szGameMode = m_pDataSettings->GetString( "game/mode", "campaign" );

		pSettings->SetString( "system/network", "LIVE" );
		pSettings->SetString( "system/access", "public" );
		pSettings->SetString( "game/mode", szGameMode );
		pSettings->SetString( "options/action", "custommatch" );

		// TCR: We need to respect the default difficulty
		if ( bDefaultSettings && GameModeHasDifficulty( szGameMode ) )
			pSettings->SetString( "game/difficulty", GameModeGetDefaultDifficulty( szGameMode ) );

		CBaseModPanel::GetSingleton().PlayUISound( UISOUND_ACCEPT );
		CBaseModPanel::GetSingleton().CloseAllWindows();
		CBaseModPanel::GetSingleton().OpenWindow( WT_GAMESETTINGS, NULL, true, pSettings );
	}
	else if ( char const *filterDifficulty = StringAfterPrefix( command, "filter_difficulty_" ) )
	{
//.........这里部分代码省略.........
开发者ID:Randdalf,项目名称:bliink,代码行数:101,代码来源:vfoundpublicgames.cpp

示例2: sizeof

//-----------------------------------------------------------------------------
// Purpose: Checks to see if any text has changed
//-----------------------------------------------------------------------------
void BuildModeDialog::OnTextChanged( Panel *panel )
{
	if (panel == m_pFileSelectionCombo)
	{
		// reload file if it's changed
		char newFile[512];
		m_pFileSelectionCombo->GetText(newFile, sizeof(newFile));

		if (stricmp(newFile, m_pBuildGroup->GetResourceName()) != 0)
		{
			// file has changed, reload
			SetActiveControl(NULL);
			m_pBuildGroup->ChangeControlSettingsFile(newFile);
		}
		return;
	}

	if (panel == m_pAddNewControlCombo)
	{
		char buf[40];
		m_pAddNewControlCombo->GetText(buf, 40);
		if (stricmp(buf, "None") != 0)
		{	
			OnNewControl(buf);
			// reset box back to None
			m_pAddNewControlCombo->ActivateItemByRow( 0 );
		}
	}

	if ( panel == m_pEditableChildren )
	{
		KeyValues *kv = m_pEditableChildren->GetActiveItemUserData();
		if ( kv )
		{
			EditablePanel *ep = reinterpret_cast< EditablePanel * >( kv->GetPtr( "ptr" ) );
			if ( ep )
			{
				ep->ActivateBuildMode();
			}
		}
	}

	if ( panel == m_pEditableParents )
	{
		KeyValues *kv = m_pEditableParents->GetActiveItemUserData();
		if ( kv )
		{
			EditablePanel *ep = reinterpret_cast< EditablePanel * >( kv->GetPtr( "ptr" ) );
			if ( ep )
			{
				ep->ActivateBuildMode();
			}
		}
	}

	if (m_pCurrentPanel && m_pCurrentPanel->IsBuildModeEditable())
	{
		m_pApplyButton->SetEnabled(true);
	}
	
	if (_autoUpdate) 
	{
		ApplyDataToControls();
	}
}
开发者ID:BSVino,项目名称:source-shader-editor,代码行数:68,代码来源:buildmodedialog.cpp

示例3: UpdateControlData

//-----------------------------------------------------------------------------
// Purpose: Applies the current settings to the build controls
//-----------------------------------------------------------------------------
void BuildModeDialog::ApplyDataToControls()
{
	// don't apply if the panel is not editable
	if ( !m_pCurrentPanel->IsBuildModeEditable())
	{
		UpdateControlData( m_pCurrentPanel );
		return; // return success, since we are behaving as expected.
	}

	char fieldName[512];
	if (m_pPanelList->m_PanelList[0].m_EditPanel)
	{
		m_pPanelList->m_PanelList[0].m_EditPanel->GetText(fieldName, sizeof(fieldName));
	}
	else
	{
		m_pPanelList->m_PanelList[0].m_EditButton->GetText(fieldName, sizeof(fieldName));
	}

	// check to see if any buildgroup panels have this name
	Panel *panel = m_pBuildGroup->FieldNameTaken(fieldName);
	if (panel)
	{
		if (panel != m_pCurrentPanel)// make sure name is taken by some other panel not this one
		{
			char messageString[255];
			Q_snprintf(messageString, sizeof( messageString ), "Fieldname is not unique: %s\nRename it and try again.", fieldName);
			MessageBox *errorBox = new MessageBox("Cannot Apply", messageString);
			errorBox->DoModal();
			UpdateControlData(m_pCurrentPanel);
			m_pApplyButton->SetEnabled(false);
			return;
		}
	}

	// create a section to store settings
	// m_pPanelList->m_pResourceData->getSection( m_pCurrentPanel->GetName(), true );
	KeyValues *dat = new KeyValues( m_pCurrentPanel->GetName() );

	// loop through the textedit filling in settings
	for ( int i = 0; i < m_pPanelList->m_PanelList.Count(); i++ )
	{
		const char *name = m_pPanelList->m_PanelList[i].m_szName;
		char buf[512];
		if (m_pPanelList->m_PanelList[i].m_EditPanel)
		{
			m_pPanelList->m_PanelList[i].m_EditPanel->GetText(buf, sizeof(buf));
		}
		else
		{
			m_pPanelList->m_PanelList[i].m_EditButton->GetText(buf, sizeof(buf));
		}

		switch (m_pPanelList->m_PanelList[i].m_iType)
		{
		case TYPE_CORNER:
		case TYPE_AUTORESIZE:
			// the integer value is assumed to be the first part of the string for these items
			dat->SetInt(name, atoi(buf));
			break;

		default:
			dat->SetString(name, buf);
			break;
		}
	}

	// dat is built, hand it back to the control
	m_pCurrentPanel->ApplySettings( dat );

	if ( m_pBuildGroup->GetContextPanel() )
	{
		m_pBuildGroup->GetContextPanel()->Repaint();
	}

	m_pApplyButton->SetEnabled(false);
	m_pSaveButton->SetEnabled(true);
}
开发者ID:BSVino,项目名称:source-shader-editor,代码行数:81,代码来源:buildmodedialog.cpp

示例4:

bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show)
{
	KeyValues *SubKey = NULL;
	int count = 0;
	cell_t players[] = {client};

#if SOURCE_ENGINE == SE_DOTA
	CUserMsg_VGUIMenu *pMsg;
	if ((pMsg = (CUserMsg_VGUIMenu *)g_UserMsgs.StartProtobufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL)
	{
		return false;
	}
#elif SOURCE_ENGINE == SE_CSGO
	CCSUsrMsg_VGUIMenu *pMsg;
	if ((pMsg = (CCSUsrMsg_VGUIMenu *)g_UserMsgs.StartProtobufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL)
	{
		return false;
	}
#else
	bf_write *pBitBuf = NULL;
	if ((pBitBuf = g_UserMsgs.StartBitBufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL)
	{
		return false;
	}
#endif

	if (data)
	{
		SubKey = data->GetFirstSubKey();
		while (SubKey)
		{
			count++;
			SubKey = SubKey->GetNextKey();
		}
		SubKey = data->GetFirstSubKey();
	}

#if SOURCE_ENGINE == SE_DOTA
	pMsg->set_name(name);
	pMsg->set_show(show);

	while (SubKey)
	{
		CUserMsg_VGUIMenu_Keys *key = pMsg->add_keys();
		key->set_name(SubKey->GetName());
		key->set_value(SubKey->GetString());
		SubKey = SubKey->GetNextKey();
	}
#elif SOURCE_ENGINE == SE_CSGO
	pMsg->set_name(name);
	pMsg->set_show(show);

	while (SubKey)
	{
		CCSUsrMsg_VGUIMenu_Subkey *key = pMsg->add_subkeys();
		key->set_name(SubKey->GetName());
		key->set_str(SubKey->GetString());
		SubKey = SubKey->GetNextKey();
	}
#else
	pBitBuf->WriteString(name);
	pBitBuf->WriteByte((show) ? 1 : 0);
	pBitBuf->WriteByte(count);
	while (SubKey)
	{
		pBitBuf->WriteString(SubKey->GetName());
		pBitBuf->WriteString(SubKey->GetString());
		SubKey = SubKey->GetNextKey();
	}
#endif

	g_UserMsgs.EndMessage();

	return true;
}
开发者ID:angryzor,项目名称:sourcemod-v8,代码行数:75,代码来源:HalfLife2.cpp

示例5: OnPlayerStats

void CLeaderboardsStats::OnPlayerStats(KeyValues* kv)
{
    KeyValues *pData = kv->FindKey("data");
    KeyValues *pErr = kv->FindKey("error");
    if (pData)
    {
        // int mtotal = -1; // MOM_TODO

        // int grank = -1; // MOM_TODO
        // int gtotal = -1; // MOM_TODO


        KeyValues *pMapRank = pData->FindKey("mapRank");
        if (pMapRank)
        {
            int iMapRank = pMapRank->GetInt("rank", -1);
            if (iMapRank == -1)
                pMapRank->SetWString("mRank", g_pVGuiLocalize->Find("MOM_NotApplicable"));
            else
                pMapRank->SetInt("mRank", iMapRank);

            const auto iRankXP = pMapRank->GetInt("rankXP", -1);
            if (iRankXP == -1)
                pMapRank->SetWString("rankXP", g_pVGuiLocalize->Find("MOM_NotApplicable"));
            else
                pMapRank->SetInt("rankXP", iRankXP);

            pMapRank->SetWString("time", g_pVGuiLocalize->Find("MOM_NotApplicable"));
            KeyValues *pRun = pMapRank->FindKey("run");
            if (pRun)
            {
                float seconds = pRun->GetFloat("time");
                if (seconds > 0.0f)
                {
                    char sPersonalBestTime[BUFSIZETIME];
                    MomUtil::FormatTime(seconds, sPersonalBestTime);
                    pMapRank->SetString("time", sPersonalBestTime);
                }
            }
        }

        KeyValues *pUserStats = pData->FindKey("stats");
        if (pUserStats)
        {
            // MOM_TODO: fill in these
            // grank = static_cast<int>(pExperience->GetFloat("rank"));
            // gtotal = static_cast<int>(pExperience->GetFloat("total"));

            m_pPlayerLevel->SetText(CConstructLocalizedString(g_pVGuiLocalize->Find("MOM_Level"), pUserStats));
            m_pPlayerCosXP->SetText(CConstructLocalizedString(g_pVGuiLocalize->Find("MOM_CosXP"), pUserStats));
            m_pMapsCompleted->SetText(CConstructLocalizedString(g_pVGuiLocalize->Find("MOM_MapsCompleted"), pUserStats));
            m_pRunsSubmitted->SetText(CConstructLocalizedString(g_pVGuiLocalize->Find("MOM_RunsSubmitted"), pUserStats));
            m_pTotalJumps->SetText(CConstructLocalizedString(g_pVGuiLocalize->Find("MOM_TotalJumps"), pUserStats));
            m_pTotalStrafes->SetText(CConstructLocalizedString(g_pVGuiLocalize->Find("MOM_TotalStrafes"), pUserStats));
        }

        m_pPlayerMapRank->SetText(CConstructLocalizedString(g_pVGuiLocalize->Find("MOM_MapRank"), pMapRank));
        m_pPlayerRankXP->SetText(CConstructLocalizedString(g_pVGuiLocalize->Find("MOM_RankXP"), pMapRank));
        m_pPlayerPersonalBest->SetText(CConstructLocalizedString(g_pVGuiLocalize->Find("MOM_PersonalBestTime"), pMapRank));

        /*if (grank > -1 && gtotal > -1)
        {
            char p_sGlobalRank[BUFSIZELOCL];
            char p_sLocalized[BUFSIZELOCL];
            LOCALIZE_TOKEN(p_wcGlobalRank, "MOM_GlobalRank", p_sGlobalRank);
            Q_snprintf(p_sLocalized, BUFSIZELOCL, "%s: %i/%i", p_sGlobalRank, grank, gtotal);
            m_pPlayerGlobalRank->SetText(p_sLocalized);
        }*/
    }
    else if (pErr)
    {
        // MOM_TODO: Handle errors
    }
}
开发者ID:bonjorno7,项目名称:GAME,代码行数:74,代码来源:LeaderboardsStats.cpp

示例6: CFmtStr

//=============================================================================
void CustomCampaigns::OnItemSelected( const char* panelName )
{
	CustomCampaignListItem *pSelectedItem = static_cast< CustomCampaignListItem * >( m_GplCustomCampaigns->GetSelectedPanelItem() );
	if ( !pSelectedItem )
		return;

	KeyValues *pAllMissions = g_pMatchExtSwarm->GetAllMissions();
	if ( !pAllMissions )
		return;

	char const *szGameMode = m_pDataSettings->GetString( "game/mode", "campaign" );

	KeyValues *pMission = pAllMissions->FindKey( pSelectedItem->GetCampaignContext() );
	KeyValues *pFirstChapter = pAllMissions->FindKey( CFmtStr( "%s/modes/%s/1", pSelectedItem->GetCampaignContext(), szGameMode ) );
	if ( !pFirstChapter || !pMission )
		return;

	const char *missionImage = pFirstChapter->GetString( "image" );
	const char *missionDesc = pMission->GetString( "description" );
	const char *campaignAuthor = pMission->GetString( "author" );
	const char *campaignWebsite = pMission->GetString( "website" );

	wchar_t finalString[MAX_PATH] = L"";
	wchar_t convertedString[MAX_PATH] = L"";

	if( m_lblAuthor )
	{
		if ( campaignAuthor )
		{
			const wchar_t * authorFormat = g_pVGuiLocalize->Find( "#L4D360UI_CustomCampaign_Author" );
			g_pVGuiLocalize->ConvertANSIToUnicode( campaignAuthor, convertedString, sizeof( convertedString ) );
			if ( authorFormat )
			{
				g_pVGuiLocalize->ConstructString( finalString, sizeof( finalString ), authorFormat, 1, convertedString );
				m_lblAuthor->SetText( finalString );
			}
			m_lblAuthor->SetVisible( true );
		}
		else
		{
			m_lblAuthor->SetVisible( false );
		}
	}

	if( m_lblWebsite )
	{
		if ( campaignWebsite )
		{
			const wchar_t * websiteFormat = g_pVGuiLocalize->Find( "#L4D360UI_CustomCampaign_Website" );
			g_pVGuiLocalize->ConvertANSIToUnicode( campaignWebsite, convertedString, sizeof( convertedString ) );
			if ( websiteFormat )
			{
				g_pVGuiLocalize->ConstructString( finalString, sizeof( finalString ), websiteFormat, 1, convertedString );
				m_lblWebsite->SetText( finalString );
			}
			m_lblWebsite->SetVisible( true );
		}
		else
		{
			m_lblWebsite->SetVisible( false );
		}
	}

	if( m_lblDescription )
	{
		if ( missionDesc )
		{
			m_lblDescription->SetText( missionDesc );
			m_lblDescription->SetVisible( true );
		}
		else
		{
			m_lblDescription->SetVisible( false );
		}
	}

	if ( m_imgLevelImage )
	{
		m_imgLevelImage->SetVisible( true );
		if( missionImage )
		{
			m_imgLevelImage->SetImage( missionImage );
		}
		else
		{
			m_imgLevelImage->SetImage( "swarm/MissionPics/addonMissionPic" );
		}
	}
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:90,代码来源:vcustomcampaigns.cpp

示例7: Q_GetFileExtension

bool CEngineSprite::Init( const char *pName )
{
	m_hAVIMaterial = AVIMATERIAL_INVALID;
	m_hBIKMaterial = BIKMATERIAL_INVALID;
	m_width = m_height = m_numFrames = 1;

	const char *pExt = Q_GetFileExtension( pName );
	bool bIsAVI = pExt && !Q_stricmp( pExt, "avi" );
#if !defined( _X360 ) || defined( BINK_ENABLED_FOR_X360 )
	bool bIsBIK = pExt && !Q_stricmp( pExt, "bik" );
#endif
	if ( bIsAVI && IsPC() )
	{
		m_hAVIMaterial = avi->CreateAVIMaterial( pName, pName, "GAME" );
		if ( m_hAVIMaterial == AVIMATERIAL_INVALID )
			return false;

		IMaterial *pMaterial = avi->GetMaterial( m_hAVIMaterial );
		avi->GetFrameSize( m_hAVIMaterial, &m_width, &m_height );
		m_numFrames = avi->GetFrameCount( m_hAVIMaterial );
		for ( int i = 0; i < kRenderModeCount; ++i )
		{
			m_material[i] = pMaterial;
			pMaterial->IncrementReferenceCount();
		}
	}
#if !defined( _X360 ) || defined( BINK_ENABLED_FOR_X360 )
	else if ( bIsBIK )
	{
		m_hBIKMaterial = bik->CreateMaterial( pName, pName, "GAME" );
		if ( m_hBIKMaterial == BIKMATERIAL_INVALID )
			return false;

		IMaterial *pMaterial = bik->GetMaterial( m_hBIKMaterial );
		bik->GetFrameSize( m_hBIKMaterial, &m_width, &m_height );
		m_numFrames = bik->GetFrameCount( m_hBIKMaterial );
		for ( int i = 0; i < kRenderModeCount; ++i )
		{
			m_material[i] = pMaterial;
			pMaterial->IncrementReferenceCount();
		}
	}
#endif
	else
	{
		char pTemp[MAX_PATH];
		char pMaterialName[MAX_PATH];
		char pMaterialPath[MAX_PATH];
		Q_StripExtension( pName, pTemp, sizeof(pTemp) );
		Q_strlower( pTemp );
		Q_FixSlashes( pTemp, '/' );

		// Check to see if this is a UNC-specified material name
		bool bIsUNC = pTemp[0] == '/' && pTemp[1] == '/' && pTemp[2] != '/';
		if ( !bIsUNC )
		{
			Q_strncpy( pMaterialName, "materials/", sizeof(pMaterialName) );
			Q_strncat( pMaterialName, pTemp, sizeof(pMaterialName), COPY_ALL_CHARACTERS );
		}
		else
		{
			Q_strncpy( pMaterialName, pTemp, sizeof(pMaterialName) );
		}
		Q_strncpy( pMaterialPath, pMaterialName, sizeof(pMaterialPath) );
		Q_SetExtension( pMaterialPath, ".vmt", sizeof(pMaterialPath) );

		for ( int i = 0; i < kRenderModeCount; ++i )
		{	
			m_material[i] = NULL;
		}

		KeyValues *kv = new KeyValues( "vmt" );
		if ( !kv->LoadFromFile( g_pFullFileSystem, pMaterialPath, "GAME" ) )
		{
			Warning( "Unable to load sprite material %s!\n", pMaterialPath );
			return false;
		}

		for ( int i = 0; i < kRenderModeCount; ++i )
		{	
			if ( i == kRenderNone || i == kRenderEnvironmental )
			{
				continue;
			}

			// strip possible materials/
			Q_snprintf( pMaterialPath, sizeof(pMaterialPath), "%s_rendermode_%d", pMaterialName + ( bIsUNC ? 0 : 10 ), i );
			KeyValues *pMaterialKV = kv->MakeCopy();
			pMaterialKV->SetInt( "$spriteRenderMode", i );
			m_material[i] = g_pMaterialSystem->FindProceduralMaterial( pMaterialPath, TEXTURE_GROUP_CLIENT_EFFECTS, pMaterialKV );
			m_material[i]->IncrementReferenceCount();	
		}

		kv->deleteThis();

		m_width = m_material[0]->GetMappingWidth();
		m_height = m_material[0]->GetMappingHeight();
		m_numFrames = m_material[0]->GetNumAnimationFrames();
	}

//.........这里部分代码省略.........
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:101,代码来源:spritemodel.cpp

示例8: KeyValues

bool CMapLayout::SaveMapLayout( const char *filename )
{
	KeyValues *pLayoutKeys = new KeyValues( "Layout" );

	if ( m_pGenerationOptions )
	{
		pLayoutKeys->AddSubKey( m_pGenerationOptions->MakeCopy() );
	}

	KeyValues *pMiscKeys = new KeyValues( "mapmisc" );
	pMiscKeys->SetInt( "PlayerStartX", m_iPlayerStartTileX );
	pMiscKeys->SetInt( "PlayerStartY", m_iPlayerStartTileY );
	pLayoutKeys->AddSubKey( pMiscKeys );
	
	// save out each room
	int iRooms = m_PlacedRooms.Count();
	for (int i=0;i<iRooms;i++)
	{
		CRoom *pRoom = m_PlacedRooms[i];
		if (!pRoom)
			continue;

		pLayoutKeys->AddSubKey( pRoom->GetKeyValuesCopy() );
	}
	// save out logical rooms
	iRooms = m_LogicalRooms.Count();
	for (int i=0;i<iRooms;i++)
	{
		KeyValues *pRoomKeys = new KeyValues( "logical_room" );
		if ( m_LogicalRooms[i]->m_pLevelTheme )
		{
			pRoomKeys->SetString( "theme", m_LogicalRooms[i]->m_pLevelTheme->m_szName );
		}
		pRoomKeys->SetString( "template", m_LogicalRooms[i]->GetFullName() );
		pLayoutKeys->AddSubKey( pRoomKeys );
	}

	for ( int i = 0; i < m_InstanceSpawns.Count(); ++ i )
	{
		KeyValues *pNewInstanceSpawn = new KeyValues( "instance_spawn" );
		m_InstanceSpawns[i].SaveToKeyValues( pNewInstanceSpawn );
		pLayoutKeys->AddSubKey( pNewInstanceSpawn );
	}
	for ( int i = 0; i < m_Encounters.Count(); ++ i )
	{
		KeyValues *pEncounterKeys = new KeyValues( "npc_encounter" );
		m_Encounters[i]->SaveToKeyValues( pEncounterKeys );
		pLayoutKeys->AddSubKey( pEncounterKeys );
	}

	CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
	for ( KeyValues *pKey = pLayoutKeys->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey() )
	{
		pKey->RecursiveSaveToFile( buf, 0 );			
	}
	pLayoutKeys->deleteThis();
	if ( !g_pFullFileSystem->WriteFile( filename, "GAME", buf ) )
	{
		Log_Warning( LOG_TilegenLayoutSystem, "Failed to SaveToFile %s\n", filename );
		return false;
	}

	return true;
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:64,代码来源:MapLayout.cpp

示例9: InitFixedSpawns

void CASWMissionChooserNPCs::InitFixedSpawns( CLayoutSystem *pLayoutSystem, CMapLayout *pLayout )
{
	// init the spawn set for this mission
	KeyValues *pGenerationOptions = pLayout->GetGenerationOptions();
	if ( !pGenerationOptions )
	{
		Warning( "Error placed fixed alien spawns, no generation options in this layout." );
		return;
	}

	bool bChosenSpawnSet = false;
	const char *szNamedSpawnSet = pGenerationOptions->GetString( "AlienSpawnSet" );
	if ( szNamedSpawnSet && szNamedSpawnSet[0] )
	{
		bChosenSpawnSet = SpawnSelection()->SetCurrentSpawnSet( szNamedSpawnSet );
	}

	if ( !bChosenSpawnSet )
	{
		SpawnSelection()->SetCurrentSpawnSet( pGenerationOptions->GetInt( "Difficulty", 5 ) );
	}

	// if we have any rooms with the alien encounter tag, then just use those for fixed spawn locations
	bool bAlienEncounterTag = false;
	int iRooms = pLayout->m_PlacedRooms.Count();
	for ( int i = 0; i < iRooms; i++ )
	{
		CRoom *pRoom = pLayout->m_PlacedRooms[i];
		if ( pRoom && pRoom->m_pRoomTemplate && pRoom->m_pRoomTemplate->HasTag( "AlienEncounter" ) )
		{
			bAlienEncounterTag = true;

			CASW_Encounter *pEncounter = new CASW_Encounter();

			// pick a random spot in this room
			Vector vecWorldMins, vecWorldMaxs;
			pRoom->GetWorldBounds( &vecWorldMins, &vecWorldMaxs );
			Vector vecPos = vecWorldMins + pLayoutSystem->GetRandomFloat( 0, 1 ) * ( vecWorldMaxs - vecWorldMins );
			vecPos.z = 0;
			pEncounter->SetEncounterPosition( vecPos );
			pEncounter->SetEncounterRadius( pLayoutSystem->GetRandomFloat( asw_encounter_radius_min.GetFloat(), asw_encounter_radius_max.GetFloat() ) );

			// add spawn defs
			// TODO: more spawns in bigger rooms? or rooms with higher weights?
			int iSpawnsPerEncounter = pLayoutSystem->GetRandomInt( CurrentSpawnSet()->GetMinSpawnsPerEncounter(), CurrentSpawnSet()->GetMaxSpawnsPerEncounter() );
			for ( int i = 0; i < iSpawnsPerEncounter; i++ )
			{
				CASW_Spawn_Definition* pSpawnDef = CurrentSpawnSet()->GetSpawnDef( ASW_NPC_SPAWN_TYPE_FIXED );
				if ( !pSpawnDef )
					continue;
				pEncounter->AddSpawnDef( pSpawnDef );
			}

			pLayout->m_Encounters.AddToTail( pEncounter );
		}
	}

	if ( bAlienEncounterTag )
	{
		pLayout->MarkEncounterRooms();
		return;
	}

	// find area of the mission
	int iTotalArea = 0;
	for ( int i = 0; i < iRooms; i++ )
	{
		CRoom *pRoom = pLayout->m_PlacedRooms[i];
		iTotalArea += ( pRoom->m_pRoomTemplate->GetTilesX() * ASW_TILE_SIZE ) * ( pRoom->m_pRoomTemplate->GetTilesY() * ASW_TILE_SIZE );
	}

	// decide how many encounters we want
	int iEncounters = pLayoutSystem->GetRandomInt( CurrentSpawnSet()->GetMinEncounters(), CurrentSpawnSet()->GetMaxEncounters() );

	// distance between encounters
	//float flMinDistance = asw_encounters_distance_min.GetFloat();

	// randomly pick rooms for the encounters to be in, using the room weights
	CUtlVector<CRoom*> candidates;
	float flTotalWeight = 0;
	for ( int i = 0; i < iRooms; i++ )
	{
		CRoom *pRoom = pLayout->m_PlacedRooms[i];
		if ( pRoom->GetSpawnWeight() > 0
				&& !pRoom->m_pRoomTemplate->IsEscapeRoom() 
				&& !pRoom->m_pRoomTemplate->IsStartRoom() 
				&& !pRoom->m_pRoomTemplate->IsBorderRoom() )
		{
			flTotalWeight += pRoom->GetSpawnWeight();
			candidates.AddToTail( pRoom );
		}
	}

	for ( int e = 0; e < iEncounters; e++ )
	{
		float flChosen = pLayoutSystem->GetRandomFloat( 0, flTotalWeight );
		CRoom *pChosenRoom = NULL;
		for ( int i = 0; i < candidates.Count(); i++ )
		{
			CRoom *pRoom = candidates[i];
//.........这里部分代码省略.........
开发者ID:Randdalf,项目名称:bliink,代码行数:101,代码来源:asw_npcs.cpp

示例10: GetLocalPlayerIndex

//-----------------------------------------------------------------------------
// Purpose: Updates the player list
//-----------------------------------------------------------------------------
void CTFDeathMatchScoreBoardDialog::UpdatePlayerList()
{
	int iSelectedPlayerIndex = GetLocalPlayerIndex();

	// Save off which player we had selected
	SectionedListPanel *pList = GetSelectedPlayerList();

	if ( pList )
	{
		int itemID = pList->GetSelectedItem();

		if ( itemID >= 0 )
		{
			KeyValues *pInfo = pList->GetItemData( itemID );
			if ( pInfo )
			{
				iSelectedPlayerIndex = pInfo->GetInt( "playerIndex" );
			}
		}
	}	

	m_pPlayerListRed->RemoveAll();

	C_TF_PlayerResource *tf_PR = dynamic_cast<C_TF_PlayerResource *>( g_PR );
	if ( !tf_PR )
		return;
	C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
	if ( !pLocalPlayer )
		return;

	int localteam = pLocalPlayer->GetTeamNumber();

	bool bMadeSelection = false;

	for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ )
	{
		if( g_PR->IsConnected( playerIndex ) )
		{
			SectionedListPanel *pPlayerList = NULL;
			switch ( g_PR->GetTeam( playerIndex ) )
			{
			case TF_TEAM_RED:
				pPlayerList = m_pPlayerListRed;
				break;
			}
			if ( null == pPlayerList )
				continue;			

			const char *szName = tf_PR->GetPlayerName(playerIndex);
			int score = tf_PR->GetTotalScore(playerIndex);
			int kills = tf_PR->GetPlayerScore(playerIndex);
			int deaths = tf_PR->GetDeaths(playerIndex);
			int streak = tf_PR->GetKillstreak(playerIndex);

			KeyValues *pKeyValues = new KeyValues( "data" );

			pKeyValues->SetInt( "playerIndex", playerIndex );
			pKeyValues->SetString( "name", szName );
			pKeyValues->SetInt("score", score);
			pKeyValues->SetInt("kills", kills);
			pKeyValues->SetInt("deaths", deaths);
			pKeyValues->SetInt("streak", streak);

			// can only see class information if we're on the same team
			if ( !AreEnemyTeams( g_PR->GetTeam( playerIndex ), localteam ) && !( localteam == TEAM_UNASSIGNED ) )
			{
				// class name
				if( g_PR->IsConnected( playerIndex ) )
				{
					int iClass = tf_PR->GetPlayerClass( playerIndex );
					if ( GetLocalPlayerIndex() == playerIndex && !tf_PR->IsAlive( playerIndex ) ) 
					{
						// If this is local player and he is dead, show desired class (which he will spawn as) rather than current class.
						C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
						int iDesiredClass = pPlayer->m_Shared.GetDesiredPlayerClassIndex();
						// use desired class unless it's random -- if random, his future class is not decided until moment of spawn
						if ( TF_CLASS_RANDOM != iDesiredClass )
						{
							iClass = iDesiredClass;
						}
					} 
					else 
					{
						// for non-local players, show the current class
						iClass = tf_PR->GetPlayerClass( playerIndex );
					}
				}				
			}
			else
			{
				C_TFPlayer *pPlayerOther = ToTFPlayer( UTIL_PlayerByIndex( playerIndex ) );

				if ( pPlayerOther && pPlayerOther->m_Shared.IsPlayerDominated( pLocalPlayer->entindex() ) )
				{
					// if local player is dominated by this player, show a nemesis icon
					pKeyValues->SetInt( "nemesis", m_iImageNemesis );
				}
//.........这里部分代码省略.........
开发者ID:Navton,项目名称:TF2Classic,代码行数:101,代码来源:tf_deathmatchscoreboard.cpp

示例11: KeyValues

void CASW_EquipmentList::LoadEquipmentList()
{
	m_iNumRegular = 0;
	m_iNumExtra = 0;

	KeyValues *kv = new KeyValues("Equipment");
	// load equipment
	if (kv->LoadFromFile(filesystem, "resource/Equipment.res"))
	{		
		int iNumEquip = 0;
		KeyValues *pKeys = kv;
		while ( pKeys )
		{
			for (KeyValues *details = pKeys->GetFirstSubKey(); details; details = details->GetNextKey())
			{			
				if ( FStrEq( details->GetName(), "Regular" ) )
				{
					//Msg("adding regular equip %s\n", MAKE_STRING( details->GetString() ));
					CASW_EquipItem* equip = new CASW_EquipItem();
					equip->m_EquipClass = MAKE_STRING( details->GetString() );
					equip->m_iItemIndex = iNumEquip;
					equip->m_bSelectableInBriefing = true;
					m_Regular.AddToTail(equip);	
					m_iNumRegular++;
					iNumEquip++;
				}
				else if ( FStrEq( details->GetName(), "Extra" ) )
				{
					//Msg("adding extra equip %s\n", MAKE_STRING( details->GetString() ));
					CASW_EquipItem* equip = new CASW_EquipItem();
					equip->m_EquipClass = MAKE_STRING( details->GetString() );
					equip->m_iItemIndex = iNumEquip;
					equip->m_bSelectableInBriefing = true;
					m_Extra.AddToTail(equip);
					m_iNumExtra++;
					iNumEquip++;							
				}
				// hidden equip
				else if ( FStrEq( details->GetName(), "RegularOther" ) )
				{
					//Msg("adding regular equip %s\n", MAKE_STRING( details->GetString() ));
					CASW_EquipItem* equip = new CASW_EquipItem();
					equip->m_EquipClass = MAKE_STRING( details->GetString() );
					equip->m_iItemIndex = iNumEquip;
					equip->m_bSelectableInBriefing = true;
					m_Regular.AddToTail(equip);	
					iNumEquip++;
				}
				else if ( FStrEq( details->GetName(), "ExtraOther" ) )
				{
					//Msg("adding extra equip %s\n", MAKE_STRING( details->GetString() ));
					CASW_EquipItem* equip = new CASW_EquipItem();
					equip->m_EquipClass = MAKE_STRING( details->GetString() );
					equip->m_iItemIndex = iNumEquip;
					equip->m_bSelectableInBriefing = false;
					m_Extra.AddToTail(equip);
					iNumEquip++;							
				}
			}
			pKeys = pKeys->GetNextKey();
		}							
	}	
}
开发者ID:jtanx,项目名称:ch1ckenscoop,代码行数:63,代码来源:asw_equipment_list.cpp

示例12: RecordBloodSprite

//-----------------------------------------------------------------------------
// Recording 
//-----------------------------------------------------------------------------
static inline void RecordBloodSprite( const Vector &start, const Vector &direction, 
	int r, int g, int b, int a, int nSprayModelIndex, int nDropModelIndex, int size )
{
	if ( !ToolsEnabled() )
		return;

	if ( clienttools->IsInRecordingMode() )
	{
		Color clr( r, g, b, a );

		const model_t* pSprayModel = (nSprayModelIndex != 0) ? modelinfo->GetModel( nSprayModelIndex ) : NULL;
		const model_t* pDropModel = (nDropModelIndex != 0) ? modelinfo->GetModel( nDropModelIndex ) : NULL;
		const char *pSprayModelName = pSprayModel ? modelinfo->GetModelName( pSprayModel ) : "";
		const char *pDropModelName = pDropModel ? modelinfo->GetModelName( pDropModel ) : "";

		KeyValues *msg = new KeyValues( "TempEntity" );

 		msg->SetInt( "te", TE_BLOOD_SPRITE );
 		msg->SetString( "name", "TE_BloodSprite" );
		msg->SetFloat( "time", gpGlobals->curtime );
		msg->SetFloat( "originx", start.x );
		msg->SetFloat( "originy", start.y );
		msg->SetFloat( "originz", start.z );
		msg->SetFloat( "directionx", direction.x );
		msg->SetFloat( "directiony", direction.y );
		msg->SetFloat( "directionz", direction.z );
		msg->SetColor( "color", clr );
  		msg->SetString( "spraymodel", pSprayModelName );
 		msg->SetString( "dropmodel", pDropModelName );
		msg->SetInt( "size", size );

		ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
		msg->deleteThis();
	}
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:38,代码来源:c_te_bloodsprite.cpp

示例13: Select

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CEditorSystem::DoSelect( CHL2WarsPlayer *pPlayer )
{
#ifndef CLIENT_DLL
	// Sync from client
	return;
#endif // CLIENT_DLL

	Vector vPos = pPlayer->Weapon_ShootPosition();
	const Vector &vMouseAim = pPlayer->GetMouseAim();
	const Vector &vCamOffset = pPlayer->GetCameraOffset();

	Vector vStartPos, vEndPos;
	vStartPos = vPos + vCamOffset;
	vEndPos = vStartPos + (vMouseAim *  MAX_TRACE_LENGTH);

	//NDebugOverlay::Line( vStartPos, vEndPos, 0, 255, 0, true, 4.0f );

	Ray_t pickerRay;
	pickerRay.Init( vStartPos, vEndPos );

	CWarsFlora *pBest = NULL;
	float fBestDistance = 0;

#ifdef CLIENT_DLL
	for( CBaseEntity *pEntity = ClientEntityList().FirstBaseEntity(); pEntity; pEntity = ClientEntityList().NextBaseEntity( pEntity ) )
#else
	for( CBaseEntity *pEntity = gEntList.FirstEnt(); pEntity != NULL; pEntity = gEntList.NextEnt( pEntity ) )
#endif // CLIENT_DLL
	{
		CWarsFlora *pFlora = dynamic_cast<CWarsFlora *>( pEntity );
		if( pFlora )
		{
			// Prefer testing against hitboxes
			// If no hitboxes available, use the bounding box
			trace_t trace;
			bool bTestedHitBoxes = pFlora->TestHitboxes( pickerRay, MASK_SOLID, trace );
			if( bTestedHitBoxes )
			{
				if( trace.DidHit() )
				{
					float fDistance = trace.endpos.DistTo( vStartPos );
					if( !pBest || fDistance < fBestDistance )
					{
						pBest = pFlora;
						fBestDistance = fDistance;
					}
				}
			}
			else
			{
				CBaseTrace trace2;
				if ( IntersectRayWithBox( pickerRay,
					pFlora->GetAbsOrigin() + pFlora->CollisionProp()->OBBMins(), pFlora->GetAbsOrigin() + pFlora->CollisionProp()->OBBMaxs(),
					0.5f, &trace2 ) )
				{
					float fDistance = trace2.endpos.DistTo( vStartPos );
					if( !pBest || fDistance < fBestDistance )
					{
						pBest = pFlora;
						fBestDistance = fDistance;
					}
				}
			}
		}
	}

	if( pBest )
	{
		if( !IsSelected( pBest ) )
		{
			Select( pBest );

			KeyValues *pOperation = new KeyValues( "data" );
			pOperation->SetString("operation", "select");
			KeyValues *pFloraKey = new KeyValues( "flora", "uuid", pBest->GetFloraUUID() );
			pFloraKey->SetBool(  "select", true );
			pOperation->AddSubKey( pFloraKey );
			warseditorstorage->QueueServerCommand( pOperation );
		}
		else
		{
			Deselect( pBest );

			KeyValues *pOperation = new KeyValues( "data" );
			pOperation->SetString("operation", "select");
			KeyValues *pFloraKey = new KeyValues( "flora", "uuid", pBest->GetFloraUUID() );
			pFloraKey->SetBool(  "select", false );
			pOperation->AddSubKey( pFloraKey );
			warseditorstorage->QueueServerCommand( pOperation );
		}
		//NDebugOverlay::Box( pBest->GetAbsOrigin(), -Vector(8, 8, 8), Vector(8, 8, 8), 0, 255, 0, 255, 5.0f);
	}
}
开发者ID:detoxhby,项目名称:lambdawars,代码行数:96,代码来源:editorsystem.cpp

示例14: HOOK_HUD_MESSAGE

//-----------------------------------------------------------------------------
// Purpose: This is called every time the DLL is loaded
//-----------------------------------------------------------------------------
void CHud::Init( void )
{
	HOOK_HUD_MESSAGE( gHUD, ResetHUD );
	
#if 1
	HOOK_HUD_MESSAGE( gHUD, SendAudio );
#endif

	InitFonts();

	// Create all the Hud elements
	CHudElementHelper::CreateAllElements();

	gLCD.Init();

	// Initialize all created elements
	for ( int i = 0; i < m_HudList.Size(); i++ )
	{
		m_HudList[i]->Init();
	}

	m_bHudTexturesLoaded = false;

	KeyValues *kv = new KeyValues( "layout" );
	if ( kv )
	{
		if ( kv->LoadFromFile( filesystem, "scripts/HudLayout.res" ) )
		{
			int numelements = m_HudList.Size();

			for ( int i = 0; i < numelements; i++ )
			{
				CHudElement *element = m_HudList[i];

				vgui::Panel *pPanel = dynamic_cast<vgui::Panel*>(element);
				if ( !pPanel )
				{
					Msg( "Non-vgui hud element %s\n", m_HudList[i]->GetName() );
					continue;
				}

				KeyValues *key = kv->FindKey( pPanel->GetName(), false );
				if ( !key )
				{
					Msg( "Hud element '%s' doesn't have an entry '%s' in scripts/HudLayout.res\n", m_HudList[i]->GetName(), pPanel->GetName() );
				}

				// Note:  When a panel is parented to the module root, it's "parent" is returned as NULL.
				if ( !element->IsParentedToClientDLLRootPanel() && 
					 !pPanel->GetParent() )
				{
					DevMsg( "Hud element '%s'/'%s' doesn't have a parent\n", m_HudList[i]->GetName(), pPanel->GetName() );
				}
			}
		}

		kv->deleteThis();
	}

	if ( m_bHudTexturesLoaded )
		return;

	m_bHudTexturesLoaded = true;
	CUtlDict< CHudTexture *, int >	textureList;

	// check to see if we have sprites for this res; if not, step down
	LoadHudTextures( textureList, "scripts/hud_textures", NULL );
	LoadHudTextures( textureList, "scripts/mod_textures", NULL );

	int c = textureList.Count();
	for ( int index = 0; index < c; index++ )
	{
		CHudTexture* tex = textureList[ index ];
		AddSearchableHudIconToList( *tex );
	}

	FreeHudTextureList( textureList );

	HudIcons().Init();
}
开发者ID:SCell555,项目名称:source-sdk-2013,代码行数:83,代码来源:hud.cpp

示例15: LoadHudTextures

void LoadHudTextures( CUtlDict< CHudTexture *, int >& list, const char *szFilenameWithoutExtension, const unsigned char *pICEKey )
{
	KeyValues *pTemp, *pTextureSection;

	KeyValues *pKeyValuesData = ReadEncryptedKVFile( filesystem, szFilenameWithoutExtension, pICEKey );
	if ( pKeyValuesData )
	{
		CUtlVector<HudTextureFileRef> hudTextureFileRefs;

		// By default, add a default entry mapping "file" to no prefix. This will allow earlier-version files
		// to work with no modification.
		hudTextureFileRefs.AddToTail( HudTextureFileRef( "file", "" ) );

		// Read "*file"-to-prefix mapping.
		KeyValues *pTextureFileRefs = pKeyValuesData->FindKey( "TextureFileRefs" );
		if ( pTextureFileRefs )
		{
			pTemp = pTextureFileRefs->GetFirstSubKey();
			while ( pTemp )
			{
				hudTextureFileRefs.AddToTail( HudTextureFileRef( pTemp->GetName(), pTemp->GetString( "prefix", "" ) ) );
				pTemp = pTemp->GetNextKey();
			}
		}

		// Read our individual HUD texture data blocks.
		pTextureSection = pKeyValuesData->FindKey( "TextureData" );
		if ( pTextureSection  )
		{
			// Read the sprite data
			pTemp = pTextureSection->GetFirstSubKey();
			while ( pTemp )
			{
				if ( pTemp->GetString( "font", NULL ) )
				{
					CHudTexture *tex = new CHudTexture();

					// Key Name is the sprite name
					Q_strncpy( tex->szShortName, pTemp->GetName(), sizeof( tex->szShortName ) );

					// it's a font-based icon
					tex->bRenderUsingFont = true;
					tex->cCharacterInFont = *(pTemp->GetString("character", ""));
					Q_strncpy( tex->szTextureFile, pTemp->GetString( "font" ), sizeof( tex->szTextureFile ) );

					list.Insert( tex->szShortName, tex );
				}
				else
				{
					int iTexLeft	= pTemp->GetInt( "x", 0 ),
						iTexTop		= pTemp->GetInt( "y", 0 ),
						iTexRight	= pTemp->GetInt( "width", 0 )	+ iTexLeft,
						iTexBottom	= pTemp->GetInt( "height", 0 )	+ iTexTop;

					for ( int i = 0; i < hudTextureFileRefs.Size(); i++ )
					{
						const char *cszFilename = pTemp->GetString( hudTextureFileRefs[i].m_fileKeySymbol, NULL );
						if ( cszFilename )
						{
							CHudTexture *tex = new CHudTexture();

							tex->bRenderUsingFont = false;
							tex->rc.left	= iTexLeft;
							tex->rc.top		= iTexTop;
							tex->rc.right	= iTexRight;
							tex->rc.bottom	= iTexBottom;

							Q_strncpy( tex->szShortName, hudTextureFileRefs[i].m_cszHudTexturePrefix, sizeof( tex->szShortName ) );
							Q_strncpy( tex->szShortName + hudTextureFileRefs[i].m_uiPrefixLength, pTemp->GetName(), sizeof( tex->szShortName ) - hudTextureFileRefs[i].m_uiPrefixLength );
							Q_strncpy( tex->szTextureFile, cszFilename, sizeof( tex->szTextureFile ) );

							list.Insert( tex->szShortName, tex );
						}
					}
				}

				pTemp = pTemp->GetNextKey();
			}
		}
	}

	// Failed for some reason. Delete the Key data and abort.
	pKeyValuesData->deleteThis();
}
开发者ID:SCell555,项目名称:source-sdk-2013,代码行数:84,代码来源:hud.cpp


注:本文中的KeyValues类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。