/** ** Draw costs in status line. ** ** @todo FIXME : make DrawCosts more configurable. ** @todo FIXME : 'time' resource should be shown too. ** @todo FIXME : remove hardcoded image for mana. ** ** @internal MaxCost == FoodCost. */ void DrawCosts(void) { int x = UI.StatusLine.TextX + 268; if (CostsMana) { // FIXME: hardcoded image!!! UI.Resources[GoldCost].G->DrawFrameClip(3, x, UI.StatusLine.TextY); VideoDrawNumber(x + 15, UI.StatusLine.TextY, GameFont, CostsMana); x += 60; } for (int i = 1; i <= MaxCosts; ++i) { if (Costs[i]) { if (UI.Resources[i].G) { UI.Resources[i].G->DrawFrameClip(UI.Resources[i].IconFrame, x, UI.StatusLine.TextY); } VideoDrawNumber(x + 15, UI.StatusLine.TextY, GameFont,Costs[i]); x += 60; if (x > Video.Width - 60) { break; } } } }
/** ** Draw costs in status line. ** ** @todo FIXME: make DrawCosts more configurable. */ void DrawCosts(void) { int x = UI.StatusLine.TextX + 268; if (CostsMana) { if (UI.Resources[EnergyCost].G->NumFrames >= 3) { UI.Resources[EnergyCost].G->DrawFrameClip(2, x, UI.StatusLine.TextY); } VideoDrawNumber(x + 15, UI.StatusLine.TextY, GameFont, CostsMana); x += 60; } for (int i = 0; i < MaxCosts; ++i) { if (Costs[i]) { if (UI.Resources[i].G) { UI.Resources[i].G->DrawFrameClip(UI.Resources[i].IconFrame, x, UI.StatusLine.TextY); } VideoDrawNumber(x + 15, UI.StatusLine.TextY, GameFont, Costs[i] / CYCLES_PER_SECOND); x += 60; if (x > Video.Width - 60) { break; } } } }
/** ** Draw info panel with no units selected */ static void DrawInfoPanelNoneSelected() { // Check if a unit is under the cursor if (UnitUnderCursor && UnitUnderCursor->IsVisible(ThisPlayer)) { DrawUnitInfo(UnitUnderCursor); return; } std::string nc; std::string rc; int x = UI.InfoPanel.X + 16; int y = UI.InfoPanel.Y + 8; VideoDrawText(x, y, GameFont, "Bos Wars"); y += 16; VideoDrawText(x, y, GameFont, "Cycle:"); VideoDrawNumber(x + 48, y, GameFont, GameCycle); VideoDrawNumber(x + 110, y, GameFont, CYCLES_PER_SECOND * VideoSyncSpeed / 100); y += 20; GetDefaultTextColors(nc, rc); for (int i = 0; i < PlayerMax - 1; ++i) { if (Players[i].Type != PlayerNobody) { if (ThisPlayer->Allied & (1 << Players[i].Index)) { SetDefaultTextColors(FontGreen, rc); } else if (ThisPlayer->Enemy & (1 << Players[i].Index)) { SetDefaultTextColors(FontRed, rc); } else { SetDefaultTextColors(nc, rc); } VideoDrawNumber(x + 15, y, GameFont, i); Video.DrawRectangle(ColorWhite,x, y, 12, 12); Video.FillRectangle(Players[i].Color, x + 1, y + 1, 10, 10); VideoDrawText(x + 27, y, GameFont,Players[i].Name); VideoDrawNumber(x + 117, y, GameFont,Players[i].Score); y += 14; } } SetDefaultTextColors(nc, rc); }
/** ** Draw the stat for an unit in top-panel. ** ** @param x Screen X position ** @param y Screen Y position ** @param modified The modified stat value ** @param original The original stat value */ local void DrawStats(int x,int y,int modified,int original) { char buf[64]; if( modified==original ) { VideoDrawNumber(x,y,GameFont,modified); } else { sprintf(buf,"%d~<+%d~>",original,modified-original); VideoDrawText(x,y,GameFont,buf); } }
/** ** Draw the player resource in top line. ** ** @todo FIXME : make DrawResources more configurable (format, font). */ void DrawResources(void) { char tmp[128]; int i; int v; // Draw all icons of resource. for (i = 0; i <= ScoreCost; ++i) { if (UI.Resources[i].G) { UI.Resources[i].G->DrawFrameClip(UI.Resources[i].IconFrame, UI.Resources[i].IconX, UI.Resources[i].IconY); } } for (i = 0; i < MaxCosts; ++i) { if (UI.Resources[i].TextX != -1) { v = ThisPlayer->Resources[i]; VideoDrawNumber(UI.Resources[i].TextX, UI.Resources[i].TextY + (v > 99999) * 3, v > 99999 ? SmallFont : GameFont, v); } } if (UI.Resources[FoodCost].TextX != -1) { sprintf(tmp, "%d/%d", ThisPlayer->Demand, ThisPlayer->Supply); if (ThisPlayer->Supply < ThisPlayer->Demand) { VideoDrawReverseText(UI.Resources[FoodCost].TextX, UI.Resources[FoodCost].TextY, GameFont, tmp); } else { VideoDrawText(UI.Resources[FoodCost].TextX, UI.Resources[FoodCost].TextY, GameFont, tmp); } } if (UI.Resources[ScoreCost].TextX != -1) { v = ThisPlayer->Score; VideoDrawNumber(UI.Resources[ScoreCost].TextX, UI.Resources[ScoreCost].TextY + (v > 99999) * 3, v > 99999 ? SmallFont : GameFont, v); } }
/** ** Draw text with variable. ** ** @param unit unit with variable to show. ** @param defaultfont default font if no specific font in extra data. */ void CContentTypeText::Draw(const CUnit *unit, CFont *defaultfont) const { char *text; // Optional text to display. CFont *font; // Font to use. int x; // X coordinate to display. int y; // Y coordinate to display. x = this->PosX; y = this->PosY; font = this->Font ? this->Font : defaultfont; Assert(font); Assert(unit || this->Index == -1); Assert(this->Index == -1 || (0 <= this->Index && this->Index < UnitTypeVar.NumberVariable)); if (this->Text) { text = EvalString(this->Text); if (this->Centered) { VideoDrawTextCentered(x, y, font, text); } else { VideoDrawText(x, y, font, text); } x += font->Width(text); delete[] text; } if (this->ShowName) { VideoDrawTextCentered(x, y, font, unit->Type->Name); return; } if (this->Index != -1) { if (!this->Stat) { EnumVariable component = this->Component; switch (component) { case VariableValue: case VariableMax: case VariableIncrease: case VariableDiff: case VariablePercent: VideoDrawNumber(x, y, font, GetComponent(unit, this->Index, component, 0).i); break; case VariableName: VideoDrawText(x, y, font, GetComponent(unit, this->Index, component, 0).s); break; default: Assert(0); } } else { int value = unit->Type->Variable[this->Index].Value; int diff = unit->Stats->Variables[this->Index].Value - value; if (!diff) { VideoDrawNumber(x, y, font, value); } else { char buf[64]; sprintf(buf, diff > 0 ? "%d~<+%d~>" : "%d~<-%d~>", value, diff); VideoDrawText(x, y, font, buf); } } } }
/** ** Draw info panel. ** ** Panel: ** neutral - neutral or opponent ** normal - not 1,3,4 ** magic unit - magic units ** construction - under construction */ void CInfoPanel::Draw(void) { int i; if (NumSelected) { if (NumSelected > 1) { // // If there are more units selected draw their pictures and a health bar // DrawInfoPanelBackground(0); for (i = 0; i < (NumSelected > (int)UI.SelectedButtons.size() ? (int)UI.SelectedButtons.size() : NumSelected); ++i) { Selected[i]->Type->Icon.Icon->DrawUnitIcon(ThisPlayer, UI.SelectedButtons[i].Style, (ButtonAreaUnderCursor == ButtonAreaSelected && ButtonUnderCursor == i) ? (IconActive | (MouseButtons & LeftButton)) : 0, UI.SelectedButtons[i].X, UI.SelectedButtons[i].Y, ""); UiDrawLifeBar(Selected[i], UI.SelectedButtons[i].X, UI.SelectedButtons[i].Y); if (ButtonAreaUnderCursor == ButtonAreaSelected && ButtonUnderCursor == i) { UI.StatusLine.Set(Selected[i]->Type->Name); } } if (NumSelected > (int)UI.SelectedButtons.size()) { char buf[5]; sprintf(buf, "+%u", static_cast<unsigned int> (NumSelected - UI.SelectedButtons.size())); VideoDrawText(UI.MaxSelectedTextX, UI.MaxSelectedTextY, UI.MaxSelectedFont, buf); } return; } else { // FIXME: not correct for enemy's units if (Selected[0]->Player == ThisPlayer || ThisPlayer->IsTeamed(Selected[0]) || ThisPlayer->IsAllied(Selected[0]) || ReplayRevealMap) { if (Selected[0]->Orders[0]->Action == UnitActionBuilt || Selected[0]->Orders[0]->Action == UnitActionResearch || Selected[0]->Orders[0]->Action == UnitActionUpgradeTo || Selected[0]->Orders[0]->Action == UnitActionTrain) { i = 3; } else if (Selected[0]->Stats->Variables[MANA_INDEX].Max) { i = 2; } else { i = 1; } } else { i = 0; } DrawInfoPanelBackground(i); DrawUnitInfo(Selected[0]); if (ButtonAreaUnderCursor == ButtonAreaSelected && ButtonUnderCursor == 0) { UI.StatusLine.Set(Selected[0]->Type->Name); } return; } } // Nothing selected DrawInfoPanelBackground(0); if (UnitUnderCursor && UnitUnderCursor->IsVisible(ThisPlayer)) { // FIXME: not correct for enemies units DrawUnitInfo(UnitUnderCursor); } else { int x; int y; std::string nc; std::string rc; // FIXME: need some cool ideas for this. x = UI.InfoPanel.X + 16; y = UI.InfoPanel.Y + 8; VideoDrawText(x, y, GameFont, "Stratagus"); y += 16; VideoDrawText(x, y, GameFont, "Cycle:"); VideoDrawNumber(x + 48, y, GameFont, GameCycle); VideoDrawNumber(x + 110, y, GameFont, CYCLES_PER_SECOND * VideoSyncSpeed / 100); y += 20; GetDefaultTextColors(nc, rc); for (i = 0; i < PlayerMax - 1; ++i) { if (Players[i].Type != PlayerNobody) { if (ThisPlayer->Allied & (1 << Players[i].Index)) { SetDefaultTextColors(FontGreen, rc); } else if (ThisPlayer->Enemy & (1 << Players[i].Index)) { SetDefaultTextColors(FontRed, rc); } else { SetDefaultTextColors(nc, rc); } VideoDrawNumber(x + 15, y, GameFont, i); Video.DrawRectangle(ColorWhite,x, y, 12, 12); Video.FillRectangle(Players[i].Color, x + 1, y + 1, 10, 10); VideoDrawText(x + 27, y, GameFont,Players[i].Name); VideoDrawNumber(x + 117, y, GameFont,Players[i].Score); y += 14; } } SetDefaultTextColors(nc, rc); } }