Пример #1
0
std::string sign::getText(Simulation *sim)
{
	char buff[256];
	char signText[256];
	sprintf(signText, "%s", text.substr(0, 255).c_str());

	if(signText[0] && signText[0] == '{')
	{
		if (!strcmp(signText,"{p}"))
		{
			float pressure = 0.0f;
			if (x>=0 && x<XRES && y>=0 && y<YRES)
				pressure = sim->pv[y/CELL][x/CELL];
			sprintf(buff, "Pressure: %3.2f", pressure);  //...pressure
		}
		else if (!strcmp(signText,"{aheat}"))
		{
			float aheat = 0.0f;
			if (x>=0 && x<XRES && y>=0 && y<YRES)
				aheat = sim->hv[y/CELL][x/CELL];
			sprintf(buff, "%3.2f", aheat-273.15);
		}
		else if (!strcmp(signText,"{t}"))
		{
			if (x>=0 && x<XRES && y>=0 && y<YRES && sim->pmap[y][x])
				sprintf(buff, "Temp: %4.2f", sim->parts[ID(sim->pmap[y][x])].temp-273.15);  //...temperature
			else
				sprintf(buff, "Temp: 0.00");  //...temperature
		}
		else
		{
			int pos = splitsign(signText);
			if (pos)
			{
				strcpy(buff, signText+pos+1);
				buff[strlen(signText)-pos-2]=0;
			}
			else
				strcpy(buff, signText);
		}
	}
	else
	{
		strcpy(buff, signText);
	}

	return std::string(buff);
}
Пример #2
0
void SignWindow::DoDraw()
{
	for(std::vector<sign>::iterator iter = sim->signs.begin(), end = sim->signs.end(); iter != end; ++iter)
	{
		sign & currentSign = *iter;
		int x, y, w, h, dx, dy;
		char type = 0;
		Graphics * g = ui::Engine::Ref().g;
		std::string text = currentSign.getText(sim);
		splitsign(currentSign.text.c_str(), &type);
		currentSign.pos(text, x, y, w, h);
		g->clearrect(x, y, w+1, h);
		g->drawrect(x, y, w+1, h, 192, 192, 192, 255);
		if (!type)
			g->drawtext(x+3, y+3, text, 255, 255, 255, 255);
		else if(type == 'b')
			g->drawtext(x+3, y+3, text, 211, 211, 40, 255);
		else
			g->drawtext(x+3, y+3, text, 0, 191, 255, 255);

		x = currentSign.x;
		y = currentSign.y;
		dx = 1 - currentSign.ju;
		dy = (currentSign.y > 18) ? -1 : 1;
#ifdef OGLR
		glBegin(GL_LINES);
		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
		glVertex2i(x, y);
		glVertex2i(x+(dx*4), y+(dy*4));
		glEnd();
#else
		for (int j=0; j<4; j++)
		{
			g->blendpixel(x, y, 192, 192, 192, 255);
			x+=dx;
			y+=dy;
		}
#endif
	}
	if(!signMoving)
	{
		ui::Window::DoDraw();
	}
}
Пример #3
0
String sign::getText(Simulation *sim)
{
	if (text[0] && text[0] == '{')
	{
		if (text == "{p}")
		{
			float pressure = 0.0f;
			if (x >= 0 && x < XRES && y >= 0 && y < YRES)
				pressure = sim->pv[y/CELL][x/CELL];
			return String::Build("Pressure: ", Format::Precision(Format::ShowPoint(pressure), 2));
		}
		else if (text == "{aheat}")
		{
			float aheat = 0.0f;
			if (x >= 0 && x < XRES && y >= 0 && y < YRES)
				aheat = sim->hv[y/CELL][x/CELL];
			return String::Build(Format::Precision(Format::ShowPoint(aheat - 273.15f), 2));
		}
		else if (text == "{t}")
		{
			if (x >= 0 && x < XRES && y >= 0 && y < YRES && sim->pmap[y][x])
				return String::Build("Temp: ", Format::Precision(Format::ShowPoint(sim->parts[ID(sim->pmap[y][x])].temp - 273.15f), 2));
			else
				return String::Build("Temp: ", Format::Precision(Format::ShowPoint(0), 2));
		}
		else
		{
			int pos = splitsign(text);
			if (pos)
				return text.Between(pos + 1, text.size() - 1);
			else
				return text;
		}
	}
	else
	{
		return text;
	}
}