void psMainWidget::HandleMessage( MsgEntry* message )
{
    if(message->GetType() != MSGTYPE_SYSTEM)
        return;

    psSystemMessage mesg(message);

    //Don't proceed if the message is disabled and it's not a server admin
    //or gm message
    if(!GetMesgOption(mesg.type) &&
        mesg.msgline.Find("server admin") == (size_t)-1 &&
         mesg.msgline.Find("gm warning") == (size_t)-1)
        return;

    int color = -1;

    if(mesg.type == MSG_ERROR)
        color = graphics2D->FindRGB(255,0,0);
    else if(mesg.type == MSG_INFO_SERVER)
        color = graphics2D->FindRGB(255,0,0);
    else if(mesg.type == MSG_RESULT)
        color = graphics2D->FindRGB(255,255,0);
    else if(mesg.type == MSG_OK)
        color = graphics2D->FindRGB(0,255,0);
    else if(mesg.type == MSG_ACK)
        color = graphics2D->FindRGB(0,0,255);

    if(color != -1)
        PrintOnScreen(mesg.msgline,color);
}
Beispiel #2
0
void PFonts::PrintFile2Screen(float x, float y, float z, const char * filename,
								   int width, int hieght, int textSpacing)
{
	float y2 =0;  //variables to base height data for paragraph.
	
	
	y2 = y;

	const char * Buffer;
	std::string tempBuffer;

	if(z<-1)
	{
		z=-1;
	}

	if(z>1)
	{
		z=1;
	}

	std::ifstream stream;
	stream.open(filename);

	if(stream.is_open())
	{
		while(! stream.eof())
		{
			if(y2>=0)
			{
				getline(stream,tempBuffer);  //read line from file into tempBuffer
				Buffer = tempBuffer.c_str(); //convert string in tempbuffer to char * to store in Buffer

				
					PrintOnScreen(x,y2,z,width,hieght,Buffer,NULL); //print the text to the screen
				

				y2  = y2 - textSpacing; //move text spacing for next line
			}

			else
			{
				break;
			}
		}

		
	}

	else
	{
		MessageBox(NULL,"Could not open file to print on the screen", " File Reading Error", MB_OK);
	}

	if(stream.is_open())
	{
	
		stream.close();
	}
}