Beispiel #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);
    }
}
Beispiel #2
0
/**
 * Draws the text for the intelligence display window.
 */
static BOOL intDisplaySeqTextViewPage(VIEW_REPLAY *psViewReplay,
				      UDWORD x0, UDWORD y0,
				      UDWORD width, UDWORD height,
				      BOOL render,
				      size_t *cur_seq, size_t *cur_seqpage)
{
	UDWORD i, cur_y;
	UDWORD sequence;

	if (!psViewReplay)
	{
		return true;	/* nothing to do */
	}

	iV_SetFont(font_regular);

	iV_SetTextColour(WZCOL_TEXT_BRIGHT);

	cur_y = y0 + iV_GetTextLineSize()/2 + 2*TEXT_YINDENT;

	/* add each message */
	for (sequence = *cur_seq, i = *cur_seqpage; sequence < psViewReplay->numSeq; sequence++)
	{
		SEQ_DISPLAY *psSeqDisplay = &psViewReplay->pSeqList[sequence];
		for (; i < psSeqDisplay->numText; i++)
		{
			if (render)
			{
				cur_y = iV_DrawFormattedText(psSeqDisplay->ppTextMsg[i],
					    x0 + TEXT_XINDENT,
					    cur_y, width, false);
			}
			else
			{
				cur_y += iV_GetTextLineSize();
			}
			if (cur_y > y0 + height)
			{
				/* run out of room - need to make new tab */
				*cur_seq = sequence;
				*cur_seqpage = i;
				return false;
			}
		}
		i = 0;
	}

	return true;		/* done */
}
Beispiel #3
0
// Show global (mode=true) or team (mode=false) history messages
void displayOldMessages(bool mode)
{
	int startpos = 0;
	std::deque<CONSOLE_MESSAGE> *WhichMessages;

	if (mode)
	{
		WhichMessages = &TeamMessages;
	}
	else
	{
		WhichMessages = &HistoryMessages;
	}
	if (!WhichMessages->empty())
	{
		unsigned int count = WhichMessages->size();	// total number of messages
		if (count > NumDisplayLines)	// if we have more than we can display
		{
			startpos = count - NumDisplayLines;	// show last X lines
			startpos += updatepos;	// unless user wants to start at something else
			if (startpos < 0)		// don't underflow
			{
				startpos = 0;
				updatepos = (count - NumDisplayLines) * -1; // reset back to first entry
				count = NumDisplayLines;
			}
			else if (count + updatepos <= count)
			{
				count += updatepos;		// user may want something different
			}
			else
			{
				// reset all, we got overflow
				count = WhichMessages->size();
				updatepos = 0;
				startpos = count - NumDisplayLines;
			}
		}

		int nudgeright = 0;
		int TextYpos = historyConsole.topY + linePitch - 2;

		if (isSecondaryWindowUp())	// see if (build/research/...)window is up
		{
			nudgeright = RET_FORMWIDTH + 2; // move text over
		}
		// if user wants to add a bit more contrast to the text
		if (showBackgroundColor)
		{
			iV_TransBoxFill(historyConsole.topX + nudgeright - CON_BORDER_WIDTH, historyConsole.topY - historyConsole.textDepth - CON_BORDER_HEIGHT,
			                historyConsole.topX + historyConsole.width, historyConsole.topY + (NumDisplayLines * linePitch) + CON_BORDER_HEIGHT);
		}
		for (int i = startpos; i < count; ++i)
		{
			// Set text color depending on message type
			if (mode)
			{
				iV_SetTextColour(WZCOL_CONS_TEXT_USER_ALLY);
			}
			else
			{
				setConsoleTextColor((*WhichMessages)[i].player);
			}
			TextYpos = iV_DrawFormattedText((*WhichMessages)[i].text.c_str(),
			                                historyConsole.topX + nudgeright,
			                                TextYpos,
			                                historyConsole.width,
			                                (*WhichMessages)[i].JustifyType);
		}
	}
}
Beispiel #4
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;
	}
}
Beispiel #5
0
/** Display up to the last 8 messages.
	\return The number of messages actually shown */
static int displayOldMessages(void)
{
	int i;
	BOOL bGotIt;
	BOOL bQuit;
	int marker = 0;
	int linePitch;
	int MesY;
	unsigned int count = 0;

	/* Check there actually are any messages */
	int thisIndex = messageId;

	if(thisIndex)
	{
		bQuit = false;
		while(!bQuit)
		{
			for(i=0,bGotIt = false; i<MAX_CONSOLE_MESSAGES && !bGotIt; i++)
			{
				if (consoleStorage[i].id == thisIndex-1)
				{
					bGotIt = true;
					marker = i;
				}
			}
			/* We found an older one */
			if(bGotIt)
			{
				history[count++] = marker;
			}
			else
			{
				bQuit = true;	// count holds how many we got
			}
			if(thisIndex)
			{
			 	/* Look for an older one */
				thisIndex--;
			}
			else
			{
				bQuit = true;	// We've reached the big bang - there is nothing older...
			}
			/* History can only hold so many */
			if(count>=consoleDrop)
			{
				bQuit = true;
			}
		}
	}

	if(!count)
	{
		/* there are messages - just no old ones yet */
		return(0);
	}

	if(count)
	{
		/* Get the line pitch */
		linePitch = iV_GetTextLineSize();

		/* How big a box is necessary? */
		/* GET RID OF THE MAGIC NUMBERS BELOW */
		iV_TransBoxFill(mainConsole.topX - CON_BORDER_WIDTH,mainConsole.topY-mainConsole.textDepth-CON_BORDER_HEIGHT,
			mainConsole.topX+mainConsole.width ,mainConsole.topY+((count)*linePitch)+CON_BORDER_HEIGHT-linePitch);
	}
	/*
	if(count)
	{
		sprintf(buildData,"%s,%s",__TIME__,__DATE__);

		buildWidth = iV_GetTextWidth(buildData);

		iV_DrawText(buildData,((mainConsole.topX+mainConsole.width) - buildWidth - 16),
			mainConsole.topY);
	}
	*/
	MesY = mainConsole.topY;
	/* Render what we found */
	for(i=count-1; i>0; i--)
	{
		/* Set text color depending on message type */
		setConsoleTextColor(consoleStorage[history[i]].player);

		/* Draw the text string */
		MesY = iV_DrawFormattedText(consoleStorage[history[i]].text,
                                    mainConsole.topX,
                                    MesY,
                                    mainConsole.width,
                                    consoleStorage[history[i]].JustifyType);
	}

	/* Set text color depending on message type */
	setConsoleTextColor(consoleStorage[history[0]].player);

	/* Draw the top one */
	iV_DrawFormattedText(consoleStorage[history[0]].text,
	                     mainConsole.topX,
	                     MesY,
	                     mainConsole.width,
	                     consoleStorage[history[0]].JustifyType);

	/* Return how much to drop the existing console by... Fix this for lines>screenWIDTH */
	if(count)
	{
		return((count)*linePitch);
	}
	else
	{
		return(0);
	}
}