コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: Called when the game dir combo box is changed
//-----------------------------------------------------------------------------
void CBaseGamesPage::OnTextChanged(Panel *panel, const char *text)
{
	if (!Q_stricmp(text, m_szComboAllText))
	{
		ComboBox *box = dynamic_cast<ComboBox *>(panel);
		if (box)
		{
			box->SetText("");
			text = "";
		}
	}

	// get filter settings from controls
	UpdateFilterSettings();

	// apply settings
	ApplyGameFilters();

	if ( m_bFiltersVisible && ( panel == m_pGameFilter || panel == m_pLocationFilter ) )
	{
		// if they changed games and/or region then cancel the refresh because the old list they are getting
		// will be for the wrong game, so stop and start a refresh
		StopRefresh(); 
		GetNewServerList(); 
	}
}
コード例 #2
0
ファイル: BaseMapsPage.cpp プロジェクト: Asunaya/game
//-----------------------------------------------------------------------------
// Purpose: Called when the game dir combo box is changed
//-----------------------------------------------------------------------------
void CBaseMapsPage::OnTextChanged(Panel *panel, const char *text)
{
    if (!Q_stricmp(text, m_szComboAllText))
    {
        ComboBox *box = dynamic_cast<ComboBox *>(panel);
        if (box)
        {
            box->SetText("");
            text = "";
        }
    }

    // get filter settings from controls
    UpdateFilterSettings();
    // apply settings
    ApplyGameFilters();

    if (m_bFiltersVisible && (panel == m_pGameModeFilter || panel == m_pDifficultyFilter || panel == m_pMapFilter
         || panel == m_pMapLayoutFilter))
    {
        // if they changed filter settings then cancel the refresh because the old list they are getting
        // will be for the wrong map or gametype, so stop and start a refresh
        StopRefresh();
        //If the filters have changed, we'll want to send a new request with the new data
        //MOM_TODO: uncomment this: StartRefresh()
    }
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: Called when the game dir combo box is changed
//-----------------------------------------------------------------------------
void CBaseGamesPage::OnTextChanged(Panel *panel, const char *text)
{
	if (!stricmp(text, "<All>"))
	{
		ComboBox *box = dynamic_cast<ComboBox *>(panel);
		if (box)
		{
			box->SetText("");
			text = "";
		}
	}

	// get filter settings from controls
	UpdateFilterSettings();

	// apply settings
	ApplyFilters();
}
コード例 #4
0
void CGECreateServer::PopulateControls( void )
{
	// Only populate on first load
	if ( !m_bFirstLoad )
		return;

	// Populate the map list
	ComboBox *maplist = dynamic_cast<ComboBox*>( FindChildByName("MapList") );
	if ( maplist )
	{
		// Clear the list first
		maplist->DeleteAllItems();
		
		FileFindHandle_t findHandle; // note: FileFINDHandle
		char file[32];

		maplist->AddItem( "#SERVER_RANDOM_MAP", new KeyValues(RANDOM_VALUE) );
		const char *pFilename = filesystem->FindFirstEx( "maps\\*.bsp", "MOD", &findHandle );
		while ( pFilename )
		{
			if ( stricmp(pFilename, "ge_transition.bsp") ) //They don't need to pick our dinky crash avoidance map.
			{
				// Add the map to the list
				Q_FileBase(pFilename, file, 32);
				maplist->AddItem(file, new KeyValues(file));
			}

			pFilename = filesystem->FindNext( findHandle );
		}

		filesystem->FindClose( findHandle );
		maplist->SetNumberOfEditLines( 10 );
		maplist->SetEditable( false );
		maplist->GetMenu()->ForceCalculateWidth();
		maplist->ActivateItemByRow( 0 );
	}

	// Populate the weapon list
	ComboBox *weaponlist = dynamic_cast<ComboBox*>( FindChildByName("WeaponList") );
	if ( weaponlist )
	{
		weaponlist->DeleteAllItems();

		// TAKEN DIRECTLY FROM ge_loadoutmanager.cpp
		// Parsing individually allows us to overwrite the default sets with custom ones
		// Multiple custom sets can be defined as needed (can even make sets per gameplay)
		if ( !GELoadoutParser.HasBeenParsed() )
		{
			GELoadoutParser.InitParser("scripts/loadouts/weapon_sets_default.X");
			GELoadoutParser.SetHasBeenParsed( false );
			GELoadoutParser.InitParser("scripts/loadouts/weapon_sets_custom*.X");
		}

		// Random loadout
		weaponlist->AddItem( "#SERVER_RANDOM_SET", new KeyValues("random_loadout") );
	
		FOR_EACH_DICT( m_WeaponSets, idx )
		{
			if (Q_strstr(m_WeaponSets.GetElementName(idx), "_mhide"))
				continue;

			int id = weaponlist->AddItem( m_WeaponSets.GetElementName(idx), NULL );
			weaponlist->GetMenu()->SetItemEnabled( id, false );

			for ( int k=m_WeaponSets[idx]->First(); k != m_WeaponSets[idx]->InvalidIndex(); k = m_WeaponSets[idx]->Next(k) )
				weaponlist->AddItem( m_WeaponSets[idx]->Element(k), new KeyValues(m_WeaponSets[idx]->GetElementName(k)) );
		}

		weaponlist->SetEditable( false );
		weaponlist->SetNumberOfEditLines( 15 );
		weaponlist->GetMenu()->ForceCalculateWidth();
		weaponlist->ActivateItemByRow( 0 );
	}

	// Populate the scenario list
	ComboBox *scenariolist = dynamic_cast<ComboBox*>( FindChildByName("ScenarioList") );
	if ( scenariolist )
	{
		// Clear the list first
		scenariolist->DeleteAllItems();

		FileFindHandle_t findHandle; // note: FileFINDHandle
		char file[32];

		scenariolist->AddItem( "#SERVER_RANDOM_SCENARIO", new KeyValues(RANDOM_VALUE) );
		const char *pFilename = filesystem->FindFirstEx( PYDIR, "MOD", &findHandle );
		while ( pFilename )
		{
			// Add the scenario to the list if not __init__
			if ( !Q_stristr( pFilename, "__init__") )
			{
				Q_FileBase( pFilename, file, 32 );
				scenariolist->AddItem( file, new KeyValues(file) );
			}

			pFilename = filesystem->FindNext( findHandle );
		}

		filesystem->FindClose( findHandle );
		scenariolist->SetEditable( false );
		scenariolist->SetNumberOfEditLines( 10 );
		scenariolist->GetMenu()->ForceCalculateWidth();
		scenariolist->ActivateItemByRow( 0 );
	}

	// Populate the bot difficulty list
	ComboBox *botdifflist = dynamic_cast<ComboBox*>( FindChildByName("BotLevel") );
	if ( botdifflist && botdifflist->GetItemCount() == 0 )
	{
		// Hard coded items (sorry!)
		botdifflist->AddItem( "#BOT_LEVEL_EASY", new KeyValues("1") );
		botdifflist->AddItem( "#BOT_LEVEL_MED", new KeyValues("3") );
		botdifflist->AddItem( "#BOT_LEVEL_HARD", new KeyValues("6") );
		botdifflist->AddItem( "#BOT_LEVEL_UBER", new KeyValues("9") );

		// Admin
		botdifflist->SetEditable( false );
		botdifflist->SetNumberOfEditLines( 4 );
		botdifflist->GetMenu()->ForceCalculateWidth();
		botdifflist->ActivateItemByRow( 0 );
	}

	// Populate the turbo mode list
	ComboBox *turbolist = dynamic_cast<ComboBox*>( FindChildByName("TurboMode") );
	if ( turbolist && turbolist->GetItemCount() == 0 )
	{
		// Hard coded items (sorry!)
		turbolist->AddItem( "#TURBO_MODE_NORM", new KeyValues("1.000000") );
		turbolist->AddItem( "#TURBO_MODE_FAST", new KeyValues("1.500000") );
		turbolist->AddItem( "#TURBO_MODE_LIGHT", new KeyValues("1.850000") );
		
		// Admin
		turbolist->SetEditable( false );
		turbolist->SetNumberOfEditLines( 3 );
		turbolist->GetMenu()->ForceCalculateWidth();
		turbolist->ActivateItemByRow( 0 );
	}

	// Load the default/saved values from our command map
	for ( KeyValues *kv = m_kvCmdMap->GetFirstTrueSubKey(); kv; kv = kv->GetNextTrueSubKey() )
	{
		// Get our value (or default)
		const char *value = (m_kvCmdValues->FindKey( kv->GetName() )) ? m_kvCmdValues->GetString( kv->GetName() ) : NULL;
		if ( !value )
			value = kv->GetString( "default", "" );

		if ( !Q_stricmp(kv->GetString("type"), "CHOICE") )
		{
			ComboBox *panel = dynamic_cast<ComboBox*>( FindChildByName(kv->GetName()) );
			if ( !panel )
				continue;

			// Search through all our items to find a matching value
			for ( int i=0; i < panel->GetItemCount(); i++ )
			{
				int id = panel->GetItemIDFromRow( i );
				KeyValues* userdata = panel->GetItemUserData( id );
				
				if ( userdata && !Q_stricmp(value, userdata->GetName()) )
				{
					panel->ActivateItem( id );
					break;
				}
			}
		}
		else if ( !Q_stricmp(kv->GetString("type"), "TEXT") )
		{
			TextEntry *panel = dynamic_cast<TextEntry*>( FindChildByName(kv->GetName()) );
			if ( !panel )
				continue;

			panel->SetText( value );
		}
		else if ( !Q_stricmp(kv->GetString("type"), "BOOL") )
		{
			CheckButton *panel = dynamic_cast<CheckButton*>( FindChildByName(kv->GetName()) );
			if ( !panel )
				continue;

			if ( !Q_stricmp(value, "1") )
				panel->SetSelected( true );
			else
				panel->SetSelected( false );
		}
	}

	m_bFirstLoad = false;
}