void drawRadar(void) { float pixSizeH, pixSizeV; ASSERT(radarBuffer, "No radar buffer allocated"); if (!radarBuffer) { return; } CalcRadarPixelSize(&pixSizeH, &pixSizeV); if (frameSkip <= 0) { bool filter = true; if (!rotateRadar) { filter = RadarZoom % 16 != 0; } DrawRadarTiles(); DrawRadarObjects(); pie_DownLoadRadar(radarBuffer, radarTexWidth, radarTexHeight, filter); frameSkip = RADAR_FRAME_SKIP; } frameSkip--; pie_SetRendMode(REND_ALPHA); pie_MatBegin(); pie_TRANSLATE(radarCenterX, radarCenterY, 0); if (rotateRadar) { // rotate the map pie_MatRotZ(player.r.y); DrawNorth(); } // draw the box at the dimensions of the map iV_TransBoxFill(-radarWidth/2.0 - 1, -radarHeight/2.0 - 1, radarWidth/2.0, radarHeight/2.0); pie_RenderRadar(-radarWidth/2.0 - 1, -radarHeight/2.0 - 1, radarWidth, radarHeight); pie_MatBegin(); pie_TRANSLATE(-radarWidth/2 - 1, -radarHeight/2 - 1, 0); DrawRadarExtras(0, 0, pixSizeH, pixSizeV); pie_MatEnd(); drawRadarBlips(-radarWidth/2.0 - 1, -radarHeight/2.0 - 1, pixSizeH, pixSizeV); pie_MatEnd(); }
/** 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); } }
// 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); } } }
void W_BUTTON::display(int xOffset, int yOffset) { int x0 = x() + xOffset; int y0 = y() + yOffset; int x1 = x0 + width(); int y1 = y0 + height(); bool haveText = !pText.isEmpty(); bool isDown = (state & (WBUT_DOWN | WBUT_LOCK | WBUT_CLICKLOCK)) != 0; bool isDisabled = (state & WBUT_DISABLE) != 0; bool isHighlight = (state & WBUT_HIGHLIGHT) != 0; // Display the button. if (!images.normal.isNull()) { iV_DrawImage(images.normal, x0, y0); if (isDown && !images.down.isNull()) { iV_DrawImage(images.down, x0, y0); } if (isDisabled && !images.disabled.isNull()) { iV_DrawImage(images.disabled, x0, y0); } if (isHighlight && !images.highlighted.isNull()) { iV_DrawImage(images.highlighted, x0, y0); } } else { iV_ShadowBox(x0, y0, x1, y1, 0, WZCOL_FORM_LIGHT, isDisabled ? WZCOL_FORM_LIGHT : WZCOL_FORM_DARK, WZCOL_FORM_BACKGROUND); if (isHighlight) { iV_Box(x0 + 2, y0 + 2, x1 - 3, y1 - 3, WZCOL_FORM_HILITE); } } if (haveText) { int fw = iV_GetTextWidth(pText.toUtf8().c_str(), FontID); int fx = x0 + (width() - fw) / 2; int fy = y0 + (height() - iV_GetTextLineSize(FontID)) / 2 - iV_GetTextAboveBase(FontID); if (isDisabled) { iV_SetTextColour(WZCOL_FORM_LIGHT); iV_DrawText(pText.toUtf8().c_str(), fx + 1, fy + 1, FontID); iV_SetTextColour(WZCOL_FORM_DISABLE); } else { iV_SetTextColour(WZCOL_FORM_TEXT); } iV_DrawText(pText.toUtf8().c_str(), fx, fy, FontID); } if (isDisabled && !images.normal.isNull() && images.disabled.isNull()) { // disabled, render something over it! iV_TransBoxFill(x0, y0, x0 + width(), y0 + height()); } }
// Render a window frame. // void RenderWindowFrame(FRAMETYPE frame, UDWORD x, UDWORD y, UDWORD Width, UDWORD Height, const glm::mat4 &modelViewProjectionMatrix) { SWORD WTopRight = 0; SWORD WTopLeft = 0; SWORD WBottomRight = 0; SWORD WBottomLeft = 0; SWORD HTopRight = 0; SWORD HTopLeft = 0; SWORD HBottomRight = 0; SWORD HBottomLeft = 0; UWORD RectI; const FRAMERECT *Rect; const IMAGEFRAME *Frame = (frame == FRAME_NORMAL) ? &FrameNormal : &FrameRadar; x += Frame->OffsetX0; y += Frame->OffsetY0; Width -= Frame->OffsetX1 + Frame->OffsetX0; Height -= Frame->OffsetY1 + Frame->OffsetY0; for (RectI = 0; RectI < 5; RectI++) { Rect = &Frame->FRect[RectI]; switch (Rect->Type) { case FR_FRAME: iV_TransBoxFill(x + Rect->TLXOffset, y + Rect->TLYOffset, x + Width - INCEND + Rect->BRXOffset, y + Height - INCEND + Rect->BRYOffset); break; case FR_LEFT: iV_TransBoxFill(x + Rect->TLXOffset, y + Rect->TLYOffset, x + Rect->BRXOffset, y + Height - INCEND + Rect->BRYOffset); break; case FR_RIGHT: iV_TransBoxFill(x + Width - INCEND + Rect->TLXOffset, y + Rect->TLYOffset, x + Width - INCEND + Rect->BRXOffset, y + Height - INCEND + Rect->BRYOffset); break; case FR_TOP: iV_TransBoxFill(x + Rect->TLXOffset, y + Rect->TLYOffset, x + Width - INCEND + Rect->BRXOffset, y + Rect->BRYOffset); break; case FR_BOTTOM: iV_TransBoxFill(x + Rect->TLXOffset, y + Height - INCEND + Rect->TLYOffset, x + Width - INCEND + Rect->BRXOffset, y + Height - INCEND + Rect->BRYOffset); break; case FR_IGNORE: break; // ignored } } if (Frame->TopLeft >= 0) { WTopLeft = (SWORD)iV_GetImageWidth(IntImages, Frame->TopLeft); HTopLeft = (SWORD)iV_GetImageHeight(IntImages, Frame->TopLeft); iV_DrawImage(IntImages, Frame->TopLeft, x, y); } if (Frame->TopRight >= 0) { WTopRight = (SWORD)iV_GetImageWidth(IntImages, Frame->TopRight); HTopRight = (SWORD)iV_GetImageHeight(IntImages, Frame->TopRight); iV_DrawImage(IntImages, Frame->TopRight, x + Width - WTopRight, y); } if (Frame->BottomRight >= 0) { WBottomRight = (SWORD)iV_GetImageWidth(IntImages, Frame->BottomRight); HBottomRight = (SWORD)iV_GetImageHeight(IntImages, Frame->BottomRight); iV_DrawImage(IntImages, Frame->BottomRight, x + Width - WBottomRight, y + Height - HBottomRight); } if (Frame->BottomLeft >= 0) { WBottomLeft = (SWORD)iV_GetImageWidth(IntImages, Frame->BottomLeft); HBottomLeft = (SWORD)iV_GetImageHeight(IntImages, Frame->BottomLeft); iV_DrawImage(IntImages, Frame->BottomLeft, x, y + Height - HBottomLeft); } if (Frame->TopEdge >= 0) { iV_DrawImageRepeatX(IntImages, Frame->TopEdge, x + iV_GetImageWidth(IntImages, Frame->TopLeft), y, Width - WTopLeft - WTopRight, modelViewProjectionMatrix); } if (Frame->BottomEdge >= 0) { iV_DrawImageRepeatX(IntImages, Frame->BottomEdge, x + WBottomLeft, y + Height - iV_GetImageHeight(IntImages, Frame->BottomEdge), Width - WBottomLeft - WBottomRight, modelViewProjectionMatrix); } if (Frame->LeftEdge >= 0) { iV_DrawImageRepeatY(IntImages, Frame->LeftEdge, x, y + HTopLeft, Height - HTopLeft - HBottomLeft, modelViewProjectionMatrix); } if (Frame->RightEdge >= 0) { iV_DrawImageRepeatY(IntImages, Frame->RightEdge, x + Width - iV_GetImageWidth(IntImages, Frame->RightEdge), y + HTopRight, Height - HTopRight - HBottomRight, modelViewProjectionMatrix); } }
/** 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; } }
/** 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); } }
// Render a window frame. // static void RenderWindow(FRAMETYPE frame, UDWORD x, UDWORD y, UDWORD Width, UDWORD Height, bool Opaque) { SWORD WTopRight = 0; SWORD WTopLeft = 0; SWORD WBottomRight = 0; SWORD WBottomLeft = 0; SWORD HTopRight = 0; SWORD HTopLeft = 0; SWORD HBottomRight = 0; SWORD HBottomLeft = 0; UWORD RectI; FRAMERECT *Rect; bool Masked = false; IMAGEFRAME *Frame; if (frame == 0) { Frame = &FrameNormal; } else { Frame = &FrameRadar; } x += Frame->OffsetX0; y += Frame->OffsetY0; Width -= Frame->OffsetX1+Frame->OffsetX0; Height -= Frame->OffsetY1+Frame->OffsetY0; for(RectI=0; RectI<5; RectI++) { Rect = &Frame->FRect[RectI]; switch(Rect->Type) { case FR_FRAME: if(Opaque==false) { if(Masked == false) { Width &= 0xfffc; // Software transboxfill needs to be a multiple of 4 pixels. Masked = true; } iV_TransBoxFill( x+Rect->TLXOffset, y+Rect->TLYOffset, x+Width-INCEND+Rect->BRXOffset, y+Height-INCEND+Rect->BRYOffset); } else { pie_BoxFill(x + Rect->TLXOffset, y + Rect->TLYOffset, x + Width - INCEND + Rect->BRXOffset, y + Height - INCEND + Rect->BRYOffset, psPalette[Rect->ColourIndex]); } break; case FR_LEFT: if(Opaque==false) { if(Masked == false) { Width &= 0xfffc; // Software transboxfill needs to be a multiple of 4 pixels. Masked = true; } iV_TransBoxFill( x+Rect->TLXOffset, y+Rect->TLYOffset, x+Rect->BRXOffset, y+Height-INCEND+Rect->BRYOffset); } else { pie_BoxFill(x + Rect->TLXOffset, y + Rect->TLYOffset, x + Rect->BRXOffset, y + Height - INCEND + Rect->BRYOffset, psPalette[Rect->ColourIndex]); } break; case FR_RIGHT: if(Opaque==false) { if(Masked == false) { Width &= 0xfffc; // Software transboxfill needs to be a multiple of 4 pixels. Masked = true; } iV_TransBoxFill( x+Width-INCEND+Rect->TLXOffset, y+Rect->TLYOffset, x+Width-INCEND+Rect->BRXOffset, y+Height-INCEND+Rect->BRYOffset); } else { pie_BoxFill(x + Width - INCEND + Rect->TLXOffset, y + Rect->TLYOffset, x + Width - INCEND + Rect->BRXOffset, y + Height - INCEND + Rect->BRYOffset, psPalette[Rect->ColourIndex]); } break; case FR_TOP: if(Opaque==false) { if(Masked == false) { Width &= 0xfffc; // Software transboxfill needs to be a multiple of 4 pixels. Masked = true; } iV_TransBoxFill( x+Rect->TLXOffset, y+Rect->TLYOffset, x+Width-INCEND+Rect->BRXOffset, y+Rect->BRYOffset); } else { pie_BoxFill(x + Rect->TLXOffset, y + Rect->TLYOffset, x + Width - INCEND + Rect->BRXOffset, y + Rect->BRYOffset, psPalette[Rect->ColourIndex]); } break; case FR_BOTTOM: if(Opaque==false) { if(Masked == false) { Width &= 0xfffc; // Software transboxfill needs to be a multiple of 4 pixels. Masked = true; } iV_TransBoxFill( x+Rect->TLXOffset, y+Height-INCEND+Rect->TLYOffset, x+Width-INCEND+Rect->BRXOffset, y+Height-INCEND+Rect->BRYOffset); } else { pie_BoxFill(x + Rect->TLXOffset, y + Height - INCEND + Rect->TLYOffset, x + Width - INCEND + Rect->BRXOffset, y + Height - INCEND + Rect->BRYOffset, psPalette[Rect->ColourIndex]); } break; case FR_IGNORE: break; // ignored } } if(Frame->TopLeft >= 0) { WTopLeft = (SWORD)iV_GetImageWidth(IntImages,Frame->TopLeft); HTopLeft = (SWORD)iV_GetImageHeight(IntImages,Frame->TopLeft); iV_DrawImage(IntImages,Frame->TopLeft,x,y); } if(Frame->TopRight >= 0) { WTopRight = (SWORD)iV_GetImageWidth(IntImages,Frame->TopRight); HTopRight = (SWORD)iV_GetImageHeight(IntImages,Frame->TopRight); iV_DrawImage(IntImages,Frame->TopRight,x+Width-WTopRight, y); } if(Frame->BottomRight >= 0) { WBottomRight = (SWORD)iV_GetImageWidth(IntImages,Frame->BottomRight); HBottomRight = (SWORD)iV_GetImageHeight(IntImages,Frame->BottomRight); iV_DrawImage(IntImages,Frame->BottomRight,x+Width-WBottomRight,y+Height-HBottomRight); } if(Frame->BottomLeft >= 0) { WBottomLeft = (SWORD)iV_GetImageWidth(IntImages,Frame->BottomLeft); HBottomLeft = (SWORD)iV_GetImageHeight(IntImages,Frame->BottomLeft); iV_DrawImage(IntImages,Frame->BottomLeft,x,y+Height-HBottomLeft); } if(Frame->TopEdge >= 0) { iV_DrawImageRect( IntImages, Frame->TopEdge, x + iV_GetImageWidth(IntImages, Frame->TopLeft), y, Width - WTopLeft - WTopRight, iV_GetImageHeight(IntImages, Frame->TopEdge) ); } if(Frame->BottomEdge >= 0) { iV_DrawImageRect( IntImages, Frame->BottomEdge, x + WBottomLeft, y + Height - iV_GetImageHeight(IntImages, Frame->BottomEdge), Width - WBottomLeft - WBottomRight, iV_GetImageHeight(IntImages, Frame->BottomEdge) ); } if(Frame->LeftEdge >= 0) { iV_DrawImageRect( IntImages, Frame->LeftEdge, x, y + HTopLeft, iV_GetImageWidth(IntImages, Frame->LeftEdge), Height - HTopLeft - HBottomLeft ); } if(Frame->RightEdge >= 0) { iV_DrawImageRect( IntImages, Frame->RightEdge, x + Width - iV_GetImageWidth(IntImages, Frame->RightEdge), y + HTopRight, iV_GetImageWidth(IntImages, Frame->RightEdge), Height - HTopRight - HBottomRight ); } }