All pastes #432861 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-10 14:05 UTC
rendered paste body
string PickPicture()
{
	string name;
	
	vector<string> bmps=CFileHandler::FindFiles("bitmaps/loadpictures/", team.side + "_*.bmp");
	vector<string> jpgs=CFileHandler::FindFiles("bitmaps/loadpictures/", team.side + "_*.jpg");
	
	int num=bmps.size()+jpgs.size();
	if(num==0)
	{
		bmps=CFileHandler::FindFiles("bitmaps/loadpictures/", "*.bmp");
		jpgs=CFileHandler::FindFiles("bitmaps/loadpictures/", "*.jpg");
		num=bmps.size()+jpgs.size();
		if (num == 0) return name;
	}

	int selected = gu->usRandInt() % num;

	if(selected<bmps.size())
		name=bmps[selected];
	else
		name=jpgs[selected-bmps.size()];
		
	return name;
}

//LoadStartPicture(PickPicture());

void LoadStartPicture(string name)
{
	if (name == NULL) return;

	CBitmap bm;
	if (!bm.Load(name))
		throw content_error("Could not load startpicture from file " + name);

	/* HACK Really big load pictures made a GLU choke. */
	if (bm.xsize > gu->viewSizeX || bm.ysize > gu->viewSizeY)
	{
		bm = bm.CreateRescaled(gu->viewSizeX, gu->viewSizeY);
	}

	startupTexture=bm.CreateTexture(false);
}