Пример #1
0
void TerrainTraversal::PushPos(const Vec2i &pos)
{
	if (IsVisited(pos) == false) {
		m_queue.push(PosNode(pos, pos));
		Set(pos, 1);
	}
}
Пример #2
0
void TerrainTraversal::PushNeighboor(const Vec2i &pos)
{
	const Vec2i offsets[] = {Vec2i(0, -1), Vec2i(-1, 0), Vec2i(1, 0), Vec2i(0, 1),
							 Vec2i(-1, -1), Vec2i(1, -1), Vec2i(-1, 1), Vec2i(1, 1)
							};

	for (int i = 0; i != 8; ++i) {
		const Vec2i newPos = pos + offsets[i];

		if (IsVisited(newPos) == false) {
			m_queue.push(PosNode(newPos, pos));
			Set(newPos, Get(pos) + 1);
		}
	}
}
Пример #3
0
void emTestPanel::Paint(const emPainter & painter, emColor canvasColor)
{
	const emString * pstr;
	emColor fgCol;
	emString str;
	double h;
	double xy[128*2];
	int i;

	if (IsFocused()) fgCol=emColor(255,136,136);
	else if (IsInFocusedPath()) fgCol=emColor(187,136,136);
	else if (IsVisited()) fgCol=emColor(255,255,136);
	else if (IsInVisitedPath()) fgCol=emColor(187,187,136);
	else fgCol=emColor(136,136,136);

	h=GetHeight();
	painter.PaintRect(0,0,1,h,BgColor,canvasColor);
	painter.PaintRectOutline(0.01,0.01,1.0-0.02,h-0.02,0.02,fgCol,BgColor);

	painter.PaintTextBoxed(
		0.02,0.02,0.49,0.07,
		"Test Panel",
		0.1,
		fgCol,
		BgColor,
		EM_ALIGN_TOP_LEFT
	);

	str="State:";
	if (IsFocused()) str+=" Focused";
	if (IsInFocusedPath()) str+=" InFocusedPath";
	if (IsVisited()) str+=" Visited";
	if (IsInVisitedPath()) str+=" InVisitedPath";
	if (IsViewFocused()) str+=" ViewFocused";
	painter.PaintTextBoxed(0.05,0.4,0.9,0.05,str,0.05,fgCol,BgColor,EM_ALIGN_LEFT);

	str=emString::Format(
		"Pri=%f MemLim=%lu",
		GetUpdatePriority(),
		(unsigned long)GetMemoryLimit()
	);
	painter.PaintTextBoxed(0.05,0.45,0.9,0.1,str,0.1,fgCol,BgColor,EM_ALIGN_LEFT);

	for (pstr=InputLog.GetFirst(), i=0; pstr; pstr=InputLog.GetNext(pstr), i++) {
		painter.PaintText(
			0.05,
			0.57+i*0.008,
			pstr->Get(),
			0.008,
			1.0,
			0x8888BBFF,
			BgColor
		);
	}

	painter.PaintTextBoxed(
		0.25,0.8,0.05,0.05,
		"Text Test\n"
		"\t<-tab\n"
		"tab->\t<-tab",
		0.1,
		fgCol,
		BgColor,
		EM_ALIGN_CENTER,
		EM_ALIGN_LEFT,
		0.2,
		true,
		0.1
	);
	painter.PaintRect(0.25,0.8,0.05,0.05,emColor(255,0,0,32));

	xy[0]=0.7; xy[1]=0.6;
	xy[2]=0.6; xy[3]=0.7;
	xy[4]=0.8; xy[5]=0.8;
	painter.PaintPolygon(xy,3,fgCol,BgColor);

	xy[ 0]=0.90; xy[ 1]=0.90;
	xy[ 2]=0.94; xy[ 3]=0.90;
	xy[ 4]=0.94; xy[ 5]=0.94;
	xy[ 6]=0.90; xy[ 7]=0.94;
	xy[ 8]=0.90; xy[ 9]=0.90;
	xy[10]=0.91; xy[11]=0.91;
	xy[12]=0.93; xy[13]=0.91;
	xy[14]=0.93; xy[15]=0.93;
	xy[16]=0.91; xy[17]=0.93;
	xy[18]=0.91; xy[19]=0.91;
	painter.PaintPolygon(xy,10,emColor(255,255,255,128),BgColor);

	xy[ 0]=0.80; xy[ 1]=0.90;
	xy[ 2]=0.84; xy[ 3]=0.90;
	xy[ 4]=0.84; xy[ 5]=0.94;
	xy[ 6]=0.80; xy[ 7]=0.94;
	xy[ 8]=0.80; xy[ 9]=0.90;
	xy[10]=0.81; xy[11]=0.91;
	xy[12]=0.81; xy[13]=0.93;
	xy[14]=0.83; xy[15]=0.93;
	xy[16]=0.83; xy[17]=0.91;
	xy[18]=0.81; xy[19]=0.91;
	painter.PaintPolygon(xy,10,emColor(255,255,255),BgColor);

	for (i=0; i<64; i++) {
		xy[i*2]=sin(M_PI*i/32.0)*0.05+0.65;
		xy[i*2+1]=cos(M_PI*i/32.0)*0.05+0.85;
	}
	painter.PaintPolygon(xy,64,emColor(255,255,0),BgColor);

	for (i=0; i<64; i++) {
		xy[i*2]=sin(M_PI*i/32.0)*0.05+0.55;
		xy[i*2+1]=cos(M_PI*i/32.0)*0.05+0.85;
	}
	emPainter(
		painter,
		0.51*painter.GetScaleX()+painter.GetOriginX(),
		0.81*painter.GetScaleY()+painter.GetOriginY(),
		0.59*painter.GetScaleX()+painter.GetOriginX(),
		0.89*painter.GetScaleY()+painter.GetOriginY()
	).PaintPolygon(xy,64,emColor(0,255,0),BgColor);

	for (i=0; i<64; i++) {
		xy[i*2]=sin(M_PI*i/32.0)*0.06+0.6;
		xy[i*2+1]=cos(M_PI*i/32.0)*0.04+0.86;
	}
	painter.PaintPolygon(xy,64,emColor(255,0,0,92));

	xy[0]=0.6;  xy[1]=0.9;
	xy[2]=0.5;  xy[3]=0.92;
	xy[4]=0.65; xy[5]=0.95;
	painter.PaintPolygon(xy,3,emColor(187,255,255),BgColor);

	xy[0]=0.6;  xy[1]=0.96;
	xy[2]=0.5;  xy[3]=0.92;
	xy[4]=0.65; xy[5]=0.95;
	painter.PaintPolygon(xy,3,emColor(255,0,0),BgColor);

	xy[0]=0.45; xy[1]=0.9;
	xy[2]=0.35; xy[3]=0.92;
	xy[4]=0.5;  xy[5]=0.95;
	painter.PaintPolygon(xy,3,emColor(187,255,255));

	xy[0]=0.45; xy[1]=0.96;
	xy[2]=0.35; xy[3]=0.92;
	xy[4]=0.5;  xy[5]=0.95;
	painter.PaintPolygon(xy,3,emColor(255,0,0));

	xy[0]=0.6;   xy[1]=0.6;
	xy[2]=0.602; xy[3]=0.6;
	xy[4]=0.502; xy[5]=0.7;
	painter.PaintPolygon(xy,3,emColor(187,136,255,192));

	xy[0]=0.7;   xy[1]=0.55;
	xy[2]=0.702; xy[3]=0.55;
	xy[4]=0.802; xy[5]=0.9;
	xy[6]=0.8;   xy[7]=0.9;
	painter.PaintPolygon(xy,4,emColor(136,187,255,192));

	xy[0]=0.8; xy[1]=0.55;
	xy[2]=0.9; xy[3]=0.55;
	xy[4]=0.8; xy[5]=0.8;
	xy[6]=0.9; xy[7]=0.8;
	painter.PaintPolygon(xy,4,emColor(136,187,255,192));

	painter.PaintEllipse(0.05,0.80,0.01,0.01,0xFFFFFFFF,BgColor);
	painter.PaintEllipse(0.06,0.80,0.02,0.01,0xFFFFFFFF,BgColor);
	painter.PaintEllipse(0.09,0.80,0.005,0.01,0xFFFFFFFF,BgColor);
	painter.PaintEllipse(0.10,0.80,0.01,0.01,45,350,0xFFFFFFFF,BgColor);
	painter.PaintEllipse(0.11,0.80,0.02,0.01,45,-350,0xFFFFFFFF,BgColor);
	painter.PaintEllipse(0.13,0.80,0.005,0.01,245,50,0xFFFFFFFF,BgColor);
	painter.PaintEllipse(0.14,0.80,0.01,0.01,245,-50,0xFFFFFFFF,BgColor);

	painter.PaintRectOutline(0.05,0.82,0.01,0.01,0.001,0xFFFFFFFF,BgColor);
	painter.PaintRectOutline(0.07,0.82,0.02,0.01,0.001,0xFFFFFFFF,BgColor);
	painter.PaintRectOutline(0.10,0.82,0.01,0.01,0.008,0xFFFFFFFF,BgColor);
	painter.PaintRectOutline(0.13,0.82,0.01,0.01,0.011,0xFFFFFFFF,BgColor);

	painter.PaintRoundRect(0.05,0.84,0.01,0.01,0.001,0.001,0xFFFFFFFF,BgColor);
	painter.PaintRoundRect(0.07,0.84,0.02,0.01,0.001,0.002,0xFFFFFFFF,BgColor);
	painter.PaintRoundRect(0.10,0.84,0.01,0.01,0.003,0.002,0xFFFFFFFF,BgColor);
	painter.PaintRoundRect(0.13,0.84,0.01,0.01,0.001,0.011,0xFFFFFFFF,BgColor);
	painter.PaintRoundRect(0.15,0.84,0.01,0.01,0.000,0.00,0xFFFFFFFF,BgColor);

	painter.PaintEllipseOutline(0.05,0.86,0.01,0.01,0.003,0xFFFFFFFF,BgColor);
	painter.PaintEllipseOutline(0.065,0.86,0.02,0.01,0.001,0xFFFFFFFF,BgColor);
	painter.PaintEllipseOutline(0.09,0.86,0.005,0.01,0.0001,0xFFFFFFFF,BgColor);
	painter.PaintEllipseOutline(0.10,0.86,0.01,0.01,90,225,0.001,0xFFFFFFFF,BgColor);
	painter.PaintEllipseOutline(0.11,0.86,0.02,0.01,45,-350,0.0001,0xFFFFFFFF,BgColor);
	painter.PaintEllipseOutline(0.13,0.86,0.005,0.01,245,50,0.001,0xFFFFFFFF,BgColor);
	painter.PaintEllipseOutline(0.14,0.86,0.01,0.01,245,-50,0.001,0xFFFFFFFF,BgColor);

	painter.PaintRoundRectOutline(0.05,0.88,0.01,0.01,0.001,0.001,0.001,0xFFFFFFFF,BgColor);
	painter.PaintRoundRectOutline(0.07,0.88,0.02,0.01,0.001,0.002,0.001,0xFFFFFFFF,BgColor);
	painter.PaintRoundRectOutline(0.10,0.88,0.01,0.01,0.003,0.002,0.003,0xFFFFFFFF,BgColor);
	painter.PaintRoundRectOutline(0.13,0.88,0.01,0.01,0.001,0.011,0.0001,0xFFFFFFFF,BgColor);
	painter.PaintRoundRectOutline(0.15,0.88,0.01,0.01,-0.0004,-0.0004,0.001,0xFFFFFFFF,BgColor);


	painter.PaintLine(0.050,0.90,0.060,0.91,0.0005,emPainter::LC_FLAT,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.051,0.90,0.061,0.91,0.0005,emPainter::LC_SQUARE,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.052,0.90,0.062,0.91,0.0005,emPainter::LC_ROUND,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.053,0.90,0.063,0.91,0.0005,emPainter::LC_FLAT,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.054,0.90,0.064,0.91,0.0005,emPainter::LC_ROUND,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.055,0.90,0.065,0.91,0.0005,emPainter::LC_SQUARE,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.056,0.90,0.066,0.91,0.0005,emPainter::LC_ROUND,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.057,0.90,0.067,0.91,0.0005,emPainter::LC_SQUARE,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.058,0.90,0.068,0.91,0.0005,emPainter::LC_FLAT,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);

	painter.PaintLine(0.070,0.90,0.070,0.91,0.0005,emPainter::LC_FLAT,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.071,0.90,0.071,0.91,0.0005,emPainter::LC_SQUARE,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.072,0.90,0.072,0.91,0.0005,emPainter::LC_ROUND,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.073,0.90,0.073,0.91,0.0005,emPainter::LC_FLAT,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.074,0.90,0.074,0.91,0.0005,emPainter::LC_ROUND,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.075,0.90,0.075,0.91,0.0005,emPainter::LC_SQUARE,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.076,0.90,0.076,0.91,0.0005,emPainter::LC_ROUND,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.077,0.90,0.077,0.91,0.0005,emPainter::LC_SQUARE,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.078,0.90,0.078,0.91,0.0005,emPainter::LC_FLAT,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);

	painter.PaintLine(0.080,0.90,0.080,0.90,0.0005,emPainter::LC_FLAT,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.081,0.90,0.081,0.90,0.0005,emPainter::LC_SQUARE,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.082,0.90,0.082,0.90,0.0005,emPainter::LC_ROUND,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.083,0.90,0.083,0.90,0.0005,emPainter::LC_FLAT,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.084,0.90,0.084,0.90,0.0005,emPainter::LC_ROUND,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.085,0.90,0.085,0.90,0.0005,emPainter::LC_SQUARE,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.086,0.90,0.086,0.90,0.0005,emPainter::LC_ROUND,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.087,0.90,0.087,0.90,0.0005,emPainter::LC_SQUARE,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.088,0.90,0.088,0.90,0.0005,emPainter::LC_FLAT,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);

	painter.PaintLine(0.090,0.91,0.100,0.90,0.0005,emPainter::LC_FLAT,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.091,0.91,0.101,0.90,0.0005,emPainter::LC_SQUARE,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.092,0.91,0.102,0.90,0.0005,emPainter::LC_ROUND,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.093,0.91,0.103,0.90,0.0005,emPainter::LC_FLAT,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.094,0.91,0.104,0.90,0.0005,emPainter::LC_ROUND,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.095,0.91,0.105,0.90,0.0005,emPainter::LC_SQUARE,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.096,0.91,0.106,0.90,0.0005,emPainter::LC_ROUND,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.097,0.91,0.107,0.90,0.0005,emPainter::LC_SQUARE,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.098,0.91,0.108,0.90,0.0005,emPainter::LC_FLAT,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);

	painter.PaintLine(0.130,0.90,0.110,0.91,0.0002,emPainter::LC_FLAT,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.131,0.90,0.111,0.91,0.0002,emPainter::LC_SQUARE,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.132,0.90,0.112,0.91,0.0002,emPainter::LC_ROUND,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.133,0.90,0.113,0.91,0.0002,emPainter::LC_FLAT,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.134,0.90,0.114,0.91,0.0002,emPainter::LC_ROUND,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.135,0.90,0.115,0.91,0.0002,emPainter::LC_SQUARE,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.136,0.90,0.116,0.91,0.0002,emPainter::LC_ROUND,emPainter::LC_FLAT,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.137,0.90,0.117,0.91,0.0002,emPainter::LC_SQUARE,emPainter::LC_ROUND,0xFFFFFFFF,BgColor);
	painter.PaintLine(0.138,0.90,0.118,0.91,0.0002,emPainter::LC_FLAT,emPainter::LC_SQUARE,0xFFFFFFFF,BgColor);

	xy[0]=0.06; xy[1]=0.80;
	xy[2]=0.10; xy[3]=0.85;
	xy[4]=0.08; xy[5]=0.91;
	painter.PaintPolygonOutline(xy,3,0.0002,emColor(255,0,0));
}
Пример #4
0
bool IsVisited(char *nav)
{
	int n = FindNav(nav);

	return IsVisited(n);
}