예제 #1
0
void ModelsDataSource::UpdateModelsList( void )
{
	// clear the list
	modelsList.clear();

	// scan for directories, storing results in temporary list
	ModelsList tempList;
	getFileList( tempList, "models/players", "/" );

	// now scan for proper models:
	// we need the main model file, animation config and default skin
	for( ModelsList::const_iterator it = tempList.begin(); it != tempList.end(); ++it ) {
		size_t i;
		static const std::string mustHaveFiles[] = { "tris.iqm", "animation.cfg", "default.skin" };
		static const size_t numMustHaveFiles = sizeof( mustHaveFiles ) / sizeof( mustHaveFiles[0] );

		std::string basePath = std::string( "models/players/" ) + *it + "/";
		for( i = 0; i < numMustHaveFiles; i++ ) {
			std::string filePath = basePath + mustHaveFiles[i];
			if( trap::FS_FOpenFile( filePath.c_str(), NULL, FS_READ ) < 0 ) {
				break;
			}
		}

		// we didn't find all files we need, ignore
		if( i != numMustHaveFiles ) {
			continue;
		}

		modelsList.push_back( *it );
	}

	NotifyRowAdd( TABLE_NAME, 0, modelsList.size() );
}
예제 #2
0
void HighScores::SubmitScore(const Rocket::Core::String& name, const Rocket::Core::Colourb& colour, int wave, int score, int alien_kills[])
{
	for (size_t i = 0; i < NUM_SCORES; i++)
	{
		if (score > scores[i].score)
		{
			// Push down all the other scores.
			for (size_t j = NUM_SCORES - 1; j > i; j--)
			{
				scores[j] = scores[j - 1];
			}

			// Insert our new score.
			scores[i].name = name;
			scores[i].colour = colour;
			scores[i].wave = wave;
			scores[i].score = score;

			for (int j = 0; j < NUM_ALIEN_TYPES; j++)
			{
				scores[i].alien_kills[j] = alien_kills[j];
			}

			NotifyRowAdd("scores", i, 1);

			return;
		}
	}
}
예제 #3
0
void VideoDataSource::updateVideoModeList( void )
{
	qboolean qwideScreen;
	char resolution[64];
	int i, width, height;

	// lists must be clear before
	modesList.clear();

	// native desktop resolution
	modesList.push_back( Mode( toString( -2 ), "desktop" ) );

    for( i = 0; trap::VID_GetModeInfo( &width, &height, &qwideScreen, i ); i++ ) ;
	for( i = 0; trap::VID_GetModeInfo( &width, &height, &qwideScreen, i ); i++ )
    {
		Q_snprintfz( resolution, sizeof( resolution ), "%s%i x %i", ( qwideScreen ? "W " : "" ), width, height );

		// save resolution and index
		Mode m( toString( i ), resolution );
		modesList.push_back( m );
    }

	// custom resolution
	modesList.push_back( Mode( toString( -1 ), "custom" ) );

	// notify updates
	int size = modesList.size();
	for( int i = 0; i < size; i++ )
		NotifyRowAdd( TABLE_NAME, i, 1 );
}
예제 #4
0
void DemosDataSource::UpdateFrame( void ) {
	for( DemoPathList::iterator it = demoPaths.begin(); it != demoPaths.end(); ++it ) {
		int firstRowAdded, numRowsAdded;

		if( it->second.UpdateFrame( &firstRowAdded, &numRowsAdded ) ) {
			// notify add
			NotifyRowAdd( it->first, firstRowAdded, numRowsAdded );
		}
	}
}
예제 #5
0
void ConsoleBuffer::InternalAddMessage(eventMessage eventMessageParam) {
    bool maxRows = false;

    if (messages.size() == BUFFER_SIZE) {
        messages.pop_front();
        maxRows = true;
    }

    messages.push_back(eventMessageParam);

    // Send the row removal message (if necessary).
    if (maxRows) {
        NotifyRowRemove("console", 0, 1);
    }

    // Then send the rows added message.
    NotifyRowAdd("console", messages.size() - 1, 1);

    return;
}
예제 #6
0
void HighScores::SubmitScore(const Rocket::Core::String& name, const Rocket::Core::Colourb& colour, int wave, int score, bool name_required)
{
	for (int i = 0; i < NUM_SCORES; i++)
	{
		if (score > scores[i].score)
		{
			// If we've already got the maximum number of scores, then we have
			// to send a NotifyRowRemove message as we're going to delete the last
			// row from the data source.
			bool max_rows = scores[NUM_SCORES - 1].score != -1;

			// Push down all the other scores.
			for (int j = NUM_SCORES - 1; j > i; j--)
			{
				scores[j] = scores[j - 1];
			}

			// Insert our new score.
			scores[i].name = name;
			scores[i].colour = colour;
			scores[i].wave = wave;
			scores[i].score = score;
			scores[i].name_required = name_required;

			// Send the row removal message (if necessary).
			if (max_rows)
			{
				NotifyRowRemove("scores", NUM_SCORES - 1, 1);
			}

			// Then send the rows added message.
			NotifyRowAdd("scores", i, 1);

			return;
		}
	}
}