Exemplo n.º 1
0
/** Displays all the console messages */
void	displayConsoleMessages(void)
{
    // Check if we have any messages we want to show
    if (!getNumberConsoleMessages() && !bConsoleDropped && !InfoMessages.size())
    {
        return;
    }

    // scripts can disable the console
    if (!bConsoleDisplayEnabled && !InfoMessages.size())
    {
        return;
    }

    iV_SetFont(font_regular);

    pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON);
    pie_SetFogStatus(false);

    if (bConsoleDropped)
    {
        displayOldMessages(HistoryMode);
    }

    std::lock_guard<wz::mutex> lck(mtx);  // Don't iterate without a lock.
    if (InfoMessages.size())
    {
        auto i = InfoMessages.end() - 1;		// we can only show the last one...
        setConsoleTextColor(i->player);

        int tmp = pie_GetVideoBufferWidth();
        drawBlueBox(0, 0,tmp, 18);
        tmp -= iV_GetTextWidth(i->text.c_str());
        iV_DrawFormattedText(i->text.c_str(), tmp - 6, linePitch - 2, iV_GetTextWidth(i->text.c_str()), i->JustifyType);
    }
    int TextYpos = mainConsole.topY;
    // Draw the blue background for the text (only in game, not lobby)
    if (bTextBoxActive && GetGameMode() == GS_NORMAL)
    {
        iV_TransBoxFill(mainConsole.topX - CON_BORDER_WIDTH, mainConsole.topY - mainConsole.textDepth - CON_BORDER_HEIGHT,
                        mainConsole.topX + mainConsole.width, mainConsole.topY + (getNumberConsoleMessages() * linePitch) + CON_BORDER_HEIGHT - linePitch);
    }
    for (auto i = ActiveMessages.begin(); i != ActiveMessages.end(); ++i)
    {
        setConsoleTextColor(i->player);
        TextYpos = iV_DrawFormattedText(i->text.c_str(), mainConsole.topX, TextYpos, mainConsole.width, i->JustifyType);
    }
}
Exemplo n.º 2
0
/** Displays all the console messages */
void	displayConsoleMessages( void )
{
	CONSOLE_MESSAGE *psMessage;
	int linePitch;
	int boxDepth;
	int drop;
	int MesY;
	int clipDepth;
	unsigned int exceed, numProcessed;

	/* Are there any to display? */
	if(consoleMessages == NULL && !bConsoleDropped)
	{
		/* No point - so get out */
 		return;
	}

	/* Return if it's disabled */
	if(!bConsoleDisplayEnabled)
	{
		return;
	}

	/* Get the travel to the next line */
	linePitch = iV_GetTextLineSize();

	pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON);
	pie_SetFogStatus(false);

	drop = 0;
	if(bConsoleDropped)
	{
		drop = displayOldMessages();
	}
	if(consoleMessages==NULL)
	{
		return;
	}

	/* Do we want a box under it? */
	if(bTextBoxActive)
	{
		for (psMessage = consoleMessages, exceed = 0;
		     psMessage && consoleVisibleLines > 0 && exceed < 4; // ho ho ho!!!
		     psMessage = psMessage->psNext)
		{
			if (iV_GetTextWidth(psMessage->text) > mainConsole.width)
			{
				++exceed;
			}
		}

		/* How big a box is necessary? */
		boxDepth = (numActiveMessages> consoleVisibleLines ? consoleVisibleLines-1 : numActiveMessages-1);

		/* Add on the extra - hope it doesn't exceed two lines! */
		boxDepth += exceed;

		/* GET RID OF THE MAGIC NUMBERS BELOW */
		clipDepth = (mainConsole.topY+(boxDepth*linePitch)+CON_BORDER_HEIGHT+drop);
		if(clipDepth > (pie_GetVideoBufferHeight() - linePitch))
		{
			clipDepth = (pie_GetVideoBufferHeight() - linePitch);
		}

		iV_TransBoxFill(mainConsole.topX - CON_BORDER_WIDTH,mainConsole.topY-mainConsole.textDepth-CON_BORDER_HEIGHT+drop+1,
			mainConsole.topX+mainConsole.width ,clipDepth);
	}

	/* Stop when we've drawn enough or we're at the end */
	MesY = mainConsole.topY + drop;

	for (psMessage = consoleMessages, numProcessed = 0;
	     psMessage && numProcessed < consoleVisibleLines && MesY < (pie_GetVideoBufferHeight() - linePitch);
	     psMessage = psMessage->psNext)
	{

		/* Set text color depending on message type */
		setConsoleTextColor(psMessage->player);

 		/* Draw the text string */
		MesY = iV_DrawFormattedText(psMessage->text, mainConsole.topX, MesY,
									mainConsole.width, psMessage->JustifyType);

		/* Move on */
		++numProcessed;
	}
}