// ----------------------------------------------------------------------------------- static void drawStatBars(void) { UDWORD index; bool bMoreBars; UDWORD x,y; UDWORD width,height; if(!bDispStarted) { bDispStarted = true; dispST = gameTime2; audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5); } fillUpStats(); pie_UniTransBoxFill(16 + D_W, MT_Y_POS - 16, pie_GetVideoBufferWidth() - D_W - 16, MT_Y_POS + 256+16, WZCOL_SCORE_BOX); iV_Box(16 + D_W, MT_Y_POS - 16, pie_GetVideoBufferWidth() - D_W - 16, MT_Y_POS + 256+16, WZCOL_SCORE_BOX_BORDER); iV_DrawText( _("Unit Losses"), LC_X + D_W, 80 + 16 + D_H ); iV_DrawText( _("Structure Losses"), LC_X + D_W, 140 + 16 + D_H ); iV_DrawText( _("Force Information"), LC_X + D_W, 200 + 16 + D_H ); index = 0; bMoreBars = true; while(bMoreBars) { /* Is it time to display this bar? */ if( infoBars[index].bActive) { /* Has it been queued before? */ if(infoBars[index].bQueued == false) { /* Don't do this next time...! */ infoBars[index].bQueued = true; /* Play a sound */ // audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5); } x = infoBars[index].topX+D_W; y = infoBars[index].topY+D_H; width = infoBars[index].width; height = infoBars[index].height; iV_Box(x, y, x + width, y + height, WZCOL_BLACK); /* Draw the background border box */ pie_BoxFill(x - 1, y - 1, x + width + 1, y + height + 1, WZCOL_MENU_BACKGROUND); /* Draw the interior grey */ pie_BoxFill(x, y, x + width, y + height, WZCOL_MENU_SCORES_INTERIOR); if( ((gameTime2 - dispST) > infoBars[index].queTime) ) { /* Now draw amount filled */ const float mul = (gameTime2 - dispST < BAR_CRAWL_TIME) ? (float)(gameTime2 - dispST) / (float)BAR_CRAWL_TIME : 1.f; const float length = (float)infoBars[index].percent / 100.f * (float)infoBars[index].width * mul; if((int)length > 4) { /* Black shadow */ pie_BoxFill(x + 1, y + 3, x + length - 1, y + height - 1, WZCOL_MENU_SHADOW); /* Solid coloured bit */ pie_BoxFill(x + 1, y + 2, x + length - 4, y + height - 4, getColour(index)); } } /* Now render the text by the bar */ sprintf(text, getDescription((MR_STRING)infoBars[index].stringID), infoBars[index].number); iV_DrawText(text, x + width + 16, y + 12); /* If we're beyond STAT_ROOKIE, then we're on rankings */ if(index>=STAT_GREEN && index <= STAT_ACE) { iV_DrawImage(IntImages,(UWORD)(IMAGE_LEV_0 + (index - STAT_GREEN)),x-8,y+2); } } /* Move onto the next bar */ index++; if(infoBars[index].topX == 0 && infoBars[index].topY == 0) { bMoreBars = false; } } dispAdditionalInfo(); }
void scoreDataToScreen(WIDGET *psWidget, ScoreDataToScreenCache& cache) { int index, x, y, width, height; bool bMoreBars; if (!bDispStarted) { bDispStarted = true; dispST = realTime; audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5); } fillUpStats(); pie_UniTransBoxFill(16 + D_W, MT_Y_POS - 16, pie_GetVideoBufferWidth() - D_W - 16, MT_Y_POS + 256 + 16, WZCOL_SCORE_BOX); iV_Box(16 + D_W, MT_Y_POS - 16, pie_GetVideoBufferWidth() - D_W - 16, MT_Y_POS + 256 + 16, WZCOL_SCORE_BOX_BORDER); cache.wzLabelText_UnitLosses.setText(_("Unit Losses"), font_regular); cache.wzLabelText_UnitLosses.render(LC_X + D_W, 80 + 16 + D_H, WZCOL_FORM_TEXT); cache.wzLabelText_StructureLosses.setText(_("Structure Losses"), font_regular); cache.wzLabelText_StructureLosses.render(LC_X + D_W, 140 + 16 + D_H, WZCOL_FORM_TEXT); cache.wzLabelText_ForceInformation.setText(_("Force Information"), font_regular); cache.wzLabelText_ForceInformation.render(LC_X + D_W, 200 + 16 + D_H, WZCOL_FORM_TEXT); index = 0; bMoreBars = true; while (bMoreBars) { /* Is it time to display this bar? */ if (infoBars[index].bActive) { /* Has it been queued before? */ if (infoBars[index].bQueued == false) { /* Don't do this next time...! */ infoBars[index].bQueued = true; /* Play a sound */ audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5); } x = infoBars[index].topX + D_W; y = infoBars[index].topY + D_H; width = infoBars[index].width; height = infoBars[index].height; iV_Box(x, y, x + width, y + height, WZCOL_BLACK); /* Draw the background border box */ pie_BoxFill(x - 1, y - 1, x + width + 1, y + height + 1, WZCOL_MENU_BACKGROUND); /* Draw the interior grey */ pie_BoxFill(x, y, x + width, y + height, WZCOL_MENU_SCORES_INTERIOR); if (((realTime - dispST) > infoBars[index].queTime)) { /* Now draw amount filled */ const float mul = (realTime - dispST < BAR_CRAWL_TIME) ? (float)(realTime - dispST) / (float)BAR_CRAWL_TIME : 1.f; const float length = (float)infoBars[index].percent / 100.f * (float)infoBars[index].width * mul; if ((int)length > 4) { /* Black shadow */ pie_BoxFill(x + 1, y + 3, x + length - 1, y + height - 1, WZCOL_MENU_SHADOW); /* Solid coloured bit */ pie_BoxFill(x + 1, y + 2, x + length - 4, y + height - 4, getColour(index)); } } /* Now render the text by the bar */ sprintf(text, getDescription((MR_STRING)infoBars[index].stringID), infoBars[index].number); if (index >= cache.wzInfoBarText.size()) { cache.wzInfoBarText.resize(index + 1); } cache.wzInfoBarText[index].setText(text, font_regular); cache.wzInfoBarText[index].render(x + width + 16, y + 12, WZCOL_FORM_TEXT); /* If we're beyond STAT_ROOKIE, then we're on rankings */ if (index >= STAT_GREEN && index <= STAT_ACE) { iV_DrawImage(IntImages, (UWORD)(IMAGE_LEV_0 + (index - STAT_GREEN)), x - 8, y + 2); } } /* Move onto the next bar */ index++; if ((index > STAT_ACE) || (infoBars[index].topX == 0 && infoBars[index].topY == 0)) { bMoreBars = false; } } /* We now need to display the mission time, game time, average unit experience level an number of artefacts found */ /* Firstly, top of the screen, number of artefacts found */ sprintf(text, _("ARTIFACTS RECOVERED: %d"), missionData.artefactsFound); cache.wzInfoText_ArtifactsFound.setText(text, font_regular); cache.wzInfoText_ArtifactsFound.render((pie_GetVideoBufferWidth() - cache.wzInfoText_ArtifactsFound.width()) / 2, 300 + D_H, WZCOL_FORM_TEXT); /* Get the mission result time in a string - and write it out */ getAsciiTime((char *)&text2, gameTime - missionData.missionStarted); sprintf(text, _("Mission Time - %s"), text2); cache.wzInfoText_MissionTime.setText(text, font_regular); cache.wzInfoText_MissionTime.render((pie_GetVideoBufferWidth() - cache.wzInfoText_MissionTime.width()) / 2, 320 + D_H, WZCOL_FORM_TEXT); /* Write out total game time so far */ getAsciiTime((char *)&text2, gameTime); sprintf(text, _("Total Game Time - %s"), text2); cache.wzInfoText_TotalGameTime.setText(text, font_regular); cache.wzInfoText_TotalGameTime.render((pie_GetVideoBufferWidth() - cache.wzInfoText_TotalGameTime.width()) / 2, 340 + D_H, WZCOL_FORM_TEXT); if (Cheated) { // A quick way to flash the text PIELIGHT cheatedTextColor = ((realTime / 250) % 2) ? WZCOL_RED : WZCOL_YELLOW; sprintf(text, "%s", _("You cheated!")); cache.wzInfoText_Cheated.setText(text, font_regular); cache.wzInfoText_Cheated.render((pie_GetVideoBufferWidth() - cache.wzInfoText_Cheated.width()) / 2, 360 + D_H, cheatedTextColor); } }