コード例 #1
0
ファイル: Widget.cpp プロジェクト: McManning/fro_client
void Widget::Render()
{
	Image* scr = Screen::Instance();

	if (mBorderColor.a != 0) //default will have a zero alpha
		scr->DrawRound(GetScreenPosition(), 0, mBorderColor);

	for (int i = 0;  i < mChildren.size(); i++)
	{
		if (mChildren.at(i)->mVisible)
			mChildren.at(i)->Render();	
	}
}
コード例 #2
0
ファイル: TerrainTest.cpp プロジェクト: McManning/fro_client
void TerrainTest::Render()
{
	Image* scr = Screen::Instance();
	if (!grid)
		return;
	
	color c;
	tile* t;
	tile* tt;
	for (int y = 0; y < height; y++)
	{
		for (int x = 0; x < width; x++)
		{
			t = GetTile(x, y);
			c.r = c.g = c.b = t->height * 25;
			
			scr->DrawRect( rect(x*TILE_SIZE, y*TILE_SIZE, TILE_SIZE, TILE_SIZE), c, true);

			if (m_bDisplayTypeMap)
			{
				//Mark tile types
				c = color();
				switch (GetTileType(x, y))
				{
					case TILE_SOUTHEDGE:
						c.r = 255; 
						break;
					case TILE_WESTEDGE:
						c.g = 255;
						break;
					case TILE_EASTEDGE:
						c.b = 255;
						break;
					case TILE_NORTHEDGE:
						c.r = c.g = 255;
						break;
					case TILE_SWEDGE:
						c.r = 128;
						break;
					case TILE_SEEDGE:
						c.g = 128;
						break;
					case TILE_NWEDGE:
						c.b = 128;
						break;
					case TILE_NEEDGE:
						c.r = c.g = 128;
						break;
					case TILE_SWBEND:
						c.g = c.b = 255;
						break;
					case TILE_SEBEND:
						c.g = c.b = 128;
						break;
					case TILE_NEBEND:
						c.r = c.b = 255;
						break;
					case TILE_NWBEND:
						c.r = c.b = 128;
						break;
					default: break;	
				}
			
				if (!isDefaultColor(c))
					scr->DrawRound( x*TILE_SIZE, y*TILE_SIZE, TILE_SIZE, TILE_SIZE, TILE_SIZE/2, c);	
			}
			
			//Render edge lines for all tiles that have too drastic a height difference between them
			tt = GetTile(x, y-1);
			if (tt)
			{
				if (tt->height > t->height+1)
					scr->DrawLine(x*TILE_SIZE, y*TILE_SIZE, x*TILE_SIZE+16, y*TILE_SIZE, color(255), 2);
				else if (tt->height+1 < t->height)
					scr->DrawLine(x*TILE_SIZE, y*TILE_SIZE, x*TILE_SIZE+16, y*TILE_SIZE, color(0,255), 2);
			}
			
			tt = GetTile(x, y+1);
			if (tt)
			{
				if (tt->height > t->height+1)
					scr->DrawLine(x*TILE_SIZE, y*TILE_SIZE+14, x*TILE_SIZE+16, y*TILE_SIZE+14, color(255), 2);
				else if (tt->height+1 < t->height)
					scr->DrawLine(x*TILE_SIZE, y*TILE_SIZE+14, x*TILE_SIZE+16, y*TILE_SIZE+14, color(0,255), 2);
			}
			
			tt = GetTile(x+1, y);
			if (tt)
			{
				if (tt->height > t->height+1)
					scr->DrawLine(x*TILE_SIZE+14, y*TILE_SIZE, x*TILE_SIZE+14, y*TILE_SIZE+14, color(255), 2);
				else if (tt->height+1 < t->height)
					scr->DrawLine(x*TILE_SIZE+14, y*TILE_SIZE, x*TILE_SIZE+14, y*TILE_SIZE+14, color(0,255), 2);
			}
			
			tt = GetTile(x-1, y);
			if (tt)
			{
				if (tt->height > t->height+1)
					scr->DrawLine(x*TILE_SIZE, y*TILE_SIZE, x*TILE_SIZE, y*TILE_SIZE+14, color(255), 2);
				else if (tt->height+1 < t->height)
					scr->DrawLine(x*TILE_SIZE, y*TILE_SIZE, x*TILE_SIZE, y*TILE_SIZE+14, color(0,255), 2);	
			}
			
			
		}
	}
	
	string msg = "m_bDisplayTypeMap: " + its(m_bDisplayTypeMap) + " (T) \\c900 m_iUpperHeight: " + its(m_iUpperHeight) + " (+Q -A). \\c090 m_iLowerHeight: " 
				+  its(m_iLowerHeight) + " (+W -S). \\c009 N to clear all";
	gui->mFont->Render(scr, 5, 5, msg, color(255,255,255));
	
	msg = "\\c090Green \\c999and \\c900red \\c999lines mark gradients too steep (Algorithm failure).";
	gui->mFont->Render(scr, 5, scr->Height() - 40, msg, color());
}