static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset) { int x = xOffset + psWidget->x(); int y = yOffset + psWidget->y(); int w = psWidget->width(); int h = psWidget->height(); STRUCTURE_STATS *stat = asStructureStats + psWidget->UserData; Position position; Vector3i rotation; char str[20]; UDWORD scale,Radius; drawBlueBox(x,y,w,h); // draw image pie_SetGeometricOffset(x + 35, y + psWidget->height()/2 + 9); rotation.x = -15; rotation.y = ((realTime/45)%360) ; //45 rotation.z = 0; position.x = 0; position.y = 0; position.z = BUTTON_DEPTH*2;//getStructureStatSize(stat) * 38 * OBJECT_RADIUS; Radius = getStructureStatSizeMax(stat); if(Radius <= 128) { scale = SMALL_STRUCT_SCALE; } else if(Radius <= 256) { scale = MED_STRUCT_SCALE; } else { scale = LARGE_STRUCT_SCALE; } pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON); displayStructureStatButton(stat, &rotation, &position, true, scale); pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON); // draw name iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); iV_DrawText(_(getName(stat->pName)), x + 80, y + psWidget->height()/2 + 3); // draw limit ssprintf(str, "%d", ((W_SLIDER *)widgGetFromID(psWScreen, psWidget->id + 1))->pos); iV_DrawText(str, x + 270, y + psWidget->height()/2 + 3); return; }
static void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { char str[128]; UDWORD x = xOffset+psWidget->x; UDWORD y = yOffset+psWidget->y; UDWORD player = psWidget->UserData; //get the in game player number. Position position; Vector3i rotation; if( responsibleFor(player,0) ) { displayExtraGubbins(widgGetFromID(psWScreen,MULTIMENU_FORM)->height); } iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); if(isHumanPlayer(player) || (game.type == SKIRMISH && player<game.maxPlayers) ) { ssprintf(str, "%d: %s", NetPlay.players[player].position, getPlayerName(player)); if (isHumanPlayer(player)) { SetPlayerTextColor(alliances[selectedPlayer][player], player); } else { SetPlayerTextColor(alliances[selectedPlayer][player], player); } while(iV_GetTextWidth(str) >= (MULTIMENU_C0-MULTIMENU_C2-10) ) { str[strlen(str)-1]='\0'; } iV_DrawText(str, x+MULTIMENU_C2, y+MULTIMENU_FONT_OSET); //c3-7 alliance //manage buttons by showing or hiding them. gifts only in campaign, { if(game.alliance != NO_ALLIANCES) { if(alliances[selectedPlayer][player] == ALLIANCE_FORMED) { if(player != selectedPlayer && !giftsUp[player] ) { if (game.alliance != ALLIANCES_TEAMS) { widgReveal(psWScreen,MULTIMENU_GIFT_RAD+ player); widgReveal(psWScreen,MULTIMENU_GIFT_RES+ player); } widgReveal(psWScreen,MULTIMENU_GIFT_DRO+ player); widgReveal(psWScreen,MULTIMENU_GIFT_POW+ player); giftsUp[player] = true; } } else { if(player != selectedPlayer && giftsUp[player]) { if (game.alliance != ALLIANCES_TEAMS) { widgHide(psWScreen,MULTIMENU_GIFT_RAD+ player); widgHide(psWScreen,MULTIMENU_GIFT_RES+ player); } widgHide(psWScreen,MULTIMENU_GIFT_DRO+ player); widgHide(psWScreen,MULTIMENU_GIFT_POW+ player); giftsUp[player] = false; } } } } } if(isHumanPlayer(player)) { SetPlayerTextColor(alliances[selectedPlayer][player], player); // Let's use the real score for MP games if (NetPlay.bComms) { //c8:score, if (Cheated) { sprintf(str,"(cheated)"); } else { sprintf(str,"%d",getMultiStats(player).recentScore); } iV_DrawText(str, x+MULTIMENU_C8, y+MULTIMENU_FONT_OSET); //c9:kills, sprintf(str,"%d",getMultiStats(player).recentKills); iV_DrawText(str, x+MULTIMENU_C9, y+MULTIMENU_FONT_OSET); } else { // estimate of score for skirmish games sprintf(str,"%d",ingame.skScores[player][0]); iV_DrawText(str, x+MULTIMENU_C8, y+MULTIMENU_FONT_OSET); // estimated kills sprintf(str,"%d",ingame.skScores[player][1]); iV_DrawText(str, x+MULTIMENU_C9, y+MULTIMENU_FONT_OSET); } if(!getDebugMappingStatus()) { //only show player's units, and nobody elses. //c10:units if (myResponsibility(player)) { SetPlayerTextColor(alliances[selectedPlayer][player], player); sprintf(str, "%d", getNumDroids(player) + getNumTransporterDroids(player)); iV_DrawText(str, x+MULTIMENU_C10, y+MULTIMENU_FONT_OSET); } if (runningMultiplayer()) { //c11:ping if (player != selectedPlayer) { if (ingame.PingTimes[player] >= 2000) { sprintf(str,"???"); } else { sprintf(str, "%d", ingame.PingTimes[player]); } iV_DrawText(str, x+MULTIMENU_C11, y+MULTIMENU_FONT_OSET); } } else { int num; STRUCTURE *temp; // NOTE, This tallys up *all* the structures you have. Test out via 'start with no base'. for (num = 0, temp = apsStructLists[player]; temp != NULL;num++,temp = temp->psNext); //c11: Structures sprintf(str, "%d", num); iV_DrawText(str, x+MULTIMENU_C11, y+MULTIMENU_FONT_OSET); } } } else { SetPlayerTextColor(alliances[selectedPlayer][player], player); // Let's use the real score for MP games if (NetPlay.bComms) { //c8:score, if (Cheated) { sprintf(str,"(cheated)"); } else { sprintf(str,"%d",getMultiStats(player).recentScore); } iV_DrawText(str, x+MULTIMENU_C8, y+MULTIMENU_FONT_OSET); //c9:kills, sprintf(str,"%d",getMultiStats(player).recentKills); iV_DrawText(str, x+MULTIMENU_C9, y+MULTIMENU_FONT_OSET); } else { // estimate of score for skirmish games sprintf(str,"%d",ingame.skScores[player][0]); iV_DrawText(str, x+MULTIMENU_C8, y+MULTIMENU_FONT_OSET); // estimated kills sprintf(str,"%d",ingame.skScores[player][1]); iV_DrawText(str, x+MULTIMENU_C9, y+MULTIMENU_FONT_OSET); } } /* Display player power instead of number of played games * and number of units instead of ping when in debug mode */ if(getDebugMappingStatus()) //Won't pass this when in both release and multiplayer modes { //c10: Total number of player units in possession sprintf(str,"%d",getNumDroids(player) + getNumTransporterDroids(player)); iV_DrawText(str, x+MULTIMENU_C10, y+MULTIMENU_FONT_OSET); //c11: Player power sprintf(str, "%u", (int)getPower(player)); iV_DrawText(str, MULTIMENU_FORM_X+MULTIMENU_C11, y+MULTIMENU_FONT_OSET); } // a droid of theirs. if(apsDroidLists[player]) { pie_SetGeometricOffset( MULTIMENU_FORM_X+MULTIMENU_C1 ,y+MULTIMENU_PLAYER_H); rotation.x = -15; rotation.y = 45; rotation.z = 0; position.x = 0; position.y = 0; position.z = 2000; //scale them! displayComponentButtonObject(apsDroidLists[player],&rotation,&position,false, 100); } // clean up widgets if player leaves while menu is up. if(!isHumanPlayer(player) && !(game.type == SKIRMISH && player<game.maxPlayers)) { if(widgGetFromID(psWScreen,MULTIMENU_CHANNEL+player)) { widgDelete(psWScreen,MULTIMENU_CHANNEL+ player); } if(widgGetFromID(psWScreen,MULTIMENU_ALLIANCE_BASE+player) ) { widgDelete(psWScreen,MULTIMENU_ALLIANCE_BASE+ player); widgDelete(psWScreen,MULTIMENU_GIFT_RAD+ player); widgDelete(psWScreen,MULTIMENU_GIFT_RES+ player); widgDelete(psWScreen,MULTIMENU_GIFT_DRO+ player); widgDelete(psWScreen,MULTIMENU_GIFT_POW+ player); giftsUp[player] = false; } } }
/* renders the Research IMDs into the surface - used by message display in Intelligence Map */ void renderResearchToBuffer(RESEARCH *psResearch, UDWORD OriginX, UDWORD OriginY) { UDWORD angle = 0; BASE_STATS *psResGraphic; UDWORD compID, IMDType; Vector3i Rotation,Position; UDWORD basePlateSize, Radius; SDWORD scale = 0; // Set identity (present) context pie_MatBegin(); pie_SetGeometricOffset(OriginX+10, OriginY+10); // Pitch down a bit //pie_MatRotX(-65536/12); // Rotate round // full rotation once every 2 seconds.. angle = (realTime % ROTATE_TIME) * 360 / ROTATE_TIME; Position.x = 0; Position.y = 0; Position.z = BUTTON_DEPTH; // Rotate round Rotation.x = -30; Rotation.y = angle; Rotation.z = 0; //draw the IMD for the research if (psResearch->psStat) { //we have a Stat associated with this research topic if (StatIsStructure(psResearch->psStat)) { //this defines how the button is drawn IMDType = IMDTYPE_STRUCTURESTAT; psResGraphic = psResearch->psStat; //set up the scale basePlateSize= getStructureStatSizeMax((STRUCTURE_STATS*)psResearch->psStat); if(basePlateSize == 1) { scale = RESEARCH_COMPONENT_SCALE / 2; /*HACK HACK HACK! if its a 'tall thin (ie tower)' structure stat with something on the top - offset the position to show the object on top*/ if (((STRUCTURE_STATS*)psResearch->psStat)->pIMD[0]->nconnectors && getStructureStatHeight((STRUCTURE_STATS*)psResearch->psStat) > TOWER_HEIGHT) { Position.y -= 30; } } else if(basePlateSize == 2) { scale = RESEARCH_COMPONENT_SCALE / 4; } else { scale = RESEARCH_COMPONENT_SCALE / 5; } } else { compID = StatIsComponent(psResearch->psStat); if (compID != COMP_UNKNOWN) { //this defines how the button is drawn IMDType = IMDTYPE_COMPONENT; psResGraphic = psResearch->psStat; // NOTE: Another kludge to deal with the superTransport to make it "fit" the display. // Using pName, should be safe to compare, pName doesn't get translated. if (!strcmp("SuperTransport", psResearch->pName)) { scale = RESEARCH_COMPONENT_SCALE / 3; } else { scale = RESEARCH_COMPONENT_SCALE; } } else { ASSERT( false, "intDisplayMessageButton: invalid stat" ); IMDType = IMDTYPE_RESEARCH; psResGraphic = (BASE_STATS *)psResearch; } } } else { //no Stat for this research topic so use the research topic to define what is drawn psResGraphic = (BASE_STATS *)psResearch; IMDType = IMDTYPE_RESEARCH; } //scale the research according to size of IMD if (IMDType == IMDTYPE_RESEARCH) { Radius = getResearchRadius((BASE_STATS*)psResGraphic); if(Radius <= 100) { scale = RESEARCH_COMPONENT_SCALE / 2; } else if(Radius <= 128) { scale = RESEARCH_COMPONENT_SCALE / 3; } else if(Radius <= 256) { scale = RESEARCH_COMPONENT_SCALE / 4; } else { scale = RESEARCH_COMPONENT_SCALE / 5; } } /* display the IMDs */ if(IMDType == IMDTYPE_COMPONENT) { displayComponentButton(psResGraphic, &Rotation, &Position, true, scale); } else if(IMDType == IMDTYPE_RESEARCH) { displayResearchButton(psResGraphic, &Rotation, &Position, true, scale); } else if(IMDType == IMDTYPE_STRUCTURESTAT) { displayStructureStatButton((STRUCTURE_STATS *)psResGraphic, &Rotation, &Position, true, scale); } else { ASSERT( false, "Unknown PIEType" ); } // close matrix context pie_MatEnd(); }
static void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset) { char str[128]; int x = xOffset + psWidget->x(); int y = yOffset + psWidget->y(); unsigned player = psWidget->UserData; // Get the in game player number. if (responsibleFor(player, 0)) { displayExtraGubbins(widgGetFromID(psWScreen,MULTIMENU_FORM)->height()); } iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); const bool isHuman = isHumanPlayer(player); const bool isAlly = aiCheckAlliances(selectedPlayer, player); const bool isSelectedPlayer = player == selectedPlayer; SetPlayerTextColor(alliances[selectedPlayer][player], player); if (isHuman || (game.type == SKIRMISH && player<game.maxPlayers) ) { ssprintf(str, "%d: %s", NetPlay.players[player].position, getPlayerName(player)); while (iV_GetTextWidth(str) >= MULTIMENU_C0 - MULTIMENU_C2 - 10) { str[strlen(str) - 1] = '\0'; } iV_DrawText(str, x + MULTIMENU_C2, y + MULTIMENU_FONT_OSET); //c3-7 alliance //manage buttons by showing or hiding them. gifts only in campaign, if (alliancesCanGiveAnything(game.alliance)) { if (isAlly && !isSelectedPlayer && !giftsUp[player] ) { if (alliancesCanGiveResearchAndRadar(game.alliance)) { widgReveal(psWScreen, MULTIMENU_GIFT_RAD + player); widgReveal(psWScreen, MULTIMENU_GIFT_RES + player); } widgReveal(psWScreen, MULTIMENU_GIFT_DRO + player); widgReveal(psWScreen, MULTIMENU_GIFT_POW + player); giftsUp[player] = true; } else if (!isAlly && !isSelectedPlayer && giftsUp[player]) { if (alliancesCanGiveResearchAndRadar(game.alliance)) { widgHide(psWScreen, MULTIMENU_GIFT_RAD + player); widgHide(psWScreen, MULTIMENU_GIFT_RES + player); } widgHide(psWScreen, MULTIMENU_GIFT_DRO + player); widgHide(psWScreen, MULTIMENU_GIFT_POW + player); giftsUp[player] = false; } } } // Let's use the real score for MP games if (NetPlay.bComms) { //c8:score, if (Cheated) { sprintf(str, "(cheated)"); } else { sprintf(str, "%d", getMultiStats(player).recentScore); } iV_DrawText(str, x + MULTIMENU_C8, y + MULTIMENU_FONT_OSET); //c9:kills, sprintf(str, "%d", getMultiStats(player).recentKills); iV_DrawText(str, x + MULTIMENU_C9, y + MULTIMENU_FONT_OSET); } else { // estimate of score for skirmish games sprintf(str, "%d", ingame.skScores[player][0]); iV_DrawText(str, x + MULTIMENU_C8, y + MULTIMENU_FONT_OSET); // estimated kills sprintf(str, "%d", ingame.skScores[player][1]); iV_DrawText(str, x + MULTIMENU_C9, y + MULTIMENU_FONT_OSET); } //only show player's and allies' unit counts, and nobody elses. //c10:units if (isAlly || getDebugMappingStatus()) { sprintf(str, "%d", getNumDroids(player) + getNumTransporterDroids(player)); iV_DrawText(str, x + MULTIMENU_C10, y + MULTIMENU_FONT_OSET); } /* Display player power instead of number of played games * and number of units instead of ping when in debug mode */ if (getDebugMappingStatus()) //Won't pass this when in both release and multiplayer modes { //c11: Player power sprintf(str, "%u", (int)getPower(player)); iV_DrawText(str, MULTIMENU_FORM_X + MULTIMENU_C11, y + MULTIMENU_FONT_OSET); } else if (runningMultiplayer()) { //c11:ping if (!isSelectedPlayer && isHuman) { if (ingame.PingTimes[player] < PING_LIMIT) { sprintf(str, "%03d", ingame.PingTimes[player]); } else { sprintf(str, "∞"); } iV_DrawText(str, x + MULTIMENU_C11, y + MULTIMENU_FONT_OSET); } } else { //c11: Structures if (isAlly || getDebugMappingStatus()) { // NOTE, This tallys up *all* the structures you have. Test out via 'start with no base'. int num = 0; for (STRUCTURE *temp = apsStructLists[player]; temp != NULL; temp = temp->psNext) { ++num; } sprintf(str, "%d", num); iV_DrawText(str, x + MULTIMENU_C11, y + MULTIMENU_FONT_OSET); } } // a droid of theirs. DROID *displayDroid = apsDroidLists[player]; while (displayDroid != NULL && !displayDroid->visible[selectedPlayer]) { displayDroid = displayDroid->psNext; } if (displayDroid) { pie_SetGeometricOffset( MULTIMENU_FORM_X+MULTIMENU_C1 ,y+MULTIMENU_PLAYER_H); Vector3i rotation(-15, 45, 0); Position position(0, 0, BUTTON_DEPTH); // Scale them. if (displayDroid->droidType == DROID_SUPERTRANSPORTER) { position.z = 7850; } else if (displayDroid->droidType == DROID_TRANSPORTER) { position.z = 4100; } displayComponentButtonObject(displayDroid, &rotation, &position, false, 100); } else if (apsDroidLists[player]) { // Show that they have droids, but not which droids, since we can't see them. iV_DrawImageTc(IntImages, IMAGE_GENERIC_TANK, IMAGE_GENERIC_TANK_TC, MULTIMENU_FORM_X + MULTIMENU_C1 - iV_GetImageWidth(IntImages, IMAGE_GENERIC_TANK)/2, y + MULTIMENU_PLAYER_H - iV_GetImageHeight(IntImages, IMAGE_GENERIC_TANK), pal_GetTeamColour(getPlayerColour(player))); } // clean up widgets if player leaves while menu is up. if (!isHuman && !(game.type == SKIRMISH && player < game.maxPlayers)) { if (widgGetFromID(psWScreen, MULTIMENU_CHANNEL + player) != NULL) { widgDelete(psWScreen, MULTIMENU_CHANNEL + player); } if (widgGetFromID(psWScreen, MULTIMENU_ALLIANCE_BASE + player) != NULL) { widgDelete(psWScreen, MULTIMENU_ALLIANCE_BASE + player); widgDelete(psWScreen, MULTIMENU_GIFT_RAD + player); widgDelete(psWScreen, MULTIMENU_GIFT_RES + player); widgDelete(psWScreen, MULTIMENU_GIFT_DRO + player); widgDelete(psWScreen, MULTIMENU_GIFT_POW + player); giftsUp[player] = false; } } }