static void InfoPanel_draw_no_selection() { DrawInfoPanelBackground(0); if (UnitUnderCursor && UnitUnderCursor->IsVisible(*ThisPlayer) && !UnitUnderCursor->Type->BoolFlag[ISNOTSELECTABLE_INDEX].value) { // FIXME: not correct for enemies units DrawUnitInfo(*UnitUnderCursor); } else { // FIXME: need some cool ideas for this. int x = UI.InfoPanel.X + 16; int y = UI.InfoPanel.Y + 8; CLabel label(GetGameFont()); label.Draw(x, y, "Stratagus"); y += 16; label.Draw(x, y, _("Cycle:")); label.Draw(x + 48, y, GameCycle); //Wyrmgus start // label.Draw(x + 110, y, CYCLES_PER_SECOND * VideoSyncSpeed / 100); label.Draw(x + 110, y, _("Speed:")); label.Draw(x + 110 + 53, y, CYCLES_PER_SECOND * VideoSyncSpeed / 100); //Wyrmgus end y += 20; std::string nc; std::string rc; GetDefaultTextColors(nc, rc); for (int i = 0; i < PlayerMax - 1; ++i) { if (Players[i].Type != PlayerNobody) { if (ThisPlayer->IsAllied(Players[i])) { label.SetNormalColor(FontGreen); } else if (ThisPlayer->IsEnemy(Players[i])) { label.SetNormalColor(FontRed); } else { label.SetNormalColor(nc); } label.Draw(x + 15, y, i); Video.DrawRectangleClip(ColorWhite, x, y, 12, 12); Video.FillRectangleClip(Players[i].Color, x + 1, y + 1, 10, 10); //Wyrmgus start // label.Draw(x + 27, y, Players[i].Name); label.Draw(x + 27, y, _(Players[i].Name.c_str())); //the score was appearing on top of the faction name // label.Draw(x + 117, y, Players[i].Score); //Wyrmgus end y += 14; } } } }
/** ** 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); }
void StartMap(const std::string &filename, bool clean) { std::string nc, rc; gcn::Widget *oldTop = Gui->getTop(); gcn::Container *container = new gcn::Container(); Containers.push_back(container); container->setDimension(gcn::Rectangle(0, 0, Video.Width, Video.Height)); container->setOpaque(false); Gui->setTop(container); NetConnectRunning = 0; InterfaceState = IfaceStateNormal; // Create the game. DebugPrint("Creating game with map: %s\n" _C_ filename.c_str()); if (clean) { CleanPlayers(); } GetDefaultTextColors(nc, rc); CreateGame(filename.c_str(), &Map); UI.StatusLine.Set(NameLine); SetMessage("%s", _("Do it! Do it now!")); // Play the game. GameMainLoop(); // Clear screen Video.ClearScreen(); Invalidate(); CleanGame(); InterfaceState = IfaceStateMenu; SetDefaultTextColors(nc, rc); Gui->setTop(oldTop); Containers.erase(std::find(Containers.begin(), Containers.end(), container)); delete container; }
/** ** 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); } }
/** ** Draw UI button 'button' on x,y ** ** @param style Button style ** @param flags State of Button (clicked, mouse over...) ** @param x X display position ** @param y Y display position ** @param text text to print on button */ void DrawUIButton(ButtonStyle *style, unsigned flags, int x, int y, //Wyrmgus start // const std::string &text, int player) const std::string &text, int player, int skin_color, int hair_color) //Wyrmgus end { ButtonStyleProperties *p; if (flags & MI_FLAGS_CLICKED) { p = &style->Clicked; } else if (flags & MI_FLAGS_ACTIVE) { p = &style->Hover; } else { p = &style->Default; } // // Image // ButtonStyleProperties *pimage = p; if (!p->Sprite) { // No image. Try hover, selected, then default if ((flags & MI_FLAGS_ACTIVE) && style->Hover.Sprite) { pimage = &style->Hover; } else if (style->Default.Sprite) { pimage = &style->Default; } } if (pimage->Sprite) { pimage->Sprite->Load(); } if (pimage->Sprite) { CPlayerColorGraphic *colorGraphic = dynamic_cast<CPlayerColorGraphic *>(pimage->Sprite); if (colorGraphic && player != -1) { //Wyrmgus start // colorGraphic->DrawPlayerColorFrameClip(player, pimage->Frame, x, y); colorGraphic->DrawPlayerColorFrameClip(player, pimage->Frame, x, y, true, skin_color, hair_color); //Wyrmgus end } else { pimage->Sprite->DrawFrame(pimage->Frame, x, y); } } // // Text // if (!text.empty()) { std::string oldnc; std::string oldrc; GetDefaultTextColors(oldnc, oldrc); CLabel label(*style->Font, (!p->TextNormalColor.empty() ? p->TextNormalColor : !style->TextNormalColor.empty() ? style->TextNormalColor : oldnc), (!p->TextReverseColor.empty() ? p->TextReverseColor : !style->TextReverseColor.empty() ? style->TextReverseColor : oldrc)); if (p->TextAlign == TextAlignCenter || p->TextAlign == TextAlignUndefined) { label.DrawCentered(x + p->TextPos.x, y + p->TextPos.y, text); } else if (p->TextAlign == TextAlignLeft) { label.Draw(x + p->TextPos.x, y + p->TextPos.y, text); } else { label.Draw(x + p->TextPos.x - style->Font->Width(text), y + p->TextPos.y, text); } } // // Border // if (!p->BorderColor) { CColor color(p->BorderColorRGB); //Wyrmgus start /* if (p->BorderColorRGB.R > 0 || p->BorderColorRGB.G > 0 || p->BorderColorRGB.B > 0) { int shift = GameCycle % 0x20; color.R >>= shift / 2; color.G >>= shift / 2; color.B >>= shift / 2; if (shift >= 0x10) { color.R = (p->BorderColorRGB.R > 0) << ((shift - 0x10) / 2); color.G = (p->BorderColorRGB.G > 0) << ((shift - 0x10) / 2); color.B = (p->BorderColorRGB.B > 0) << ((shift - 0x10) / 2); } } */ //Wyrmgus end p->BorderColor = Video.MapRGB(TheScreen->format, color); } if (p->BorderSize) { for (int i = 0; i < p->BorderSize; ++i) { //Wyrmgus start // Video.DrawRectangleClip(p->BorderColor, x - i, y - i, // style->Width + 2 * i, style->Height + 2 * i); Video.DrawRectangleClip(p->BorderColor, x - i - 1, y - i - 1, (style->Width + 2 * i) + 2, (style->Height + 2 * i) + 2); //Wyrmgus end } } }
/** ** Draw menu button 'button' on x,y ** ** @param style Button style ** @param flags State of Button (clicked, mouse over...) ** @param x X display position ** @param y Y display position ** @param text text to print on button */ void DrawMenuButton(ButtonStyle *style, unsigned flags, int x, int y, const std::string &text) { std::string *nc; std::string *rc; std::string oldnc; std::string oldrc; ButtonStyleProperties *p; ButtonStyleProperties *pimage; if (flags & MI_FLAGS_CLICKED) { p = &style->Clicked; } else if (flags & MI_FLAGS_ACTIVE) { p = &style->Hover; } else { p = &style->Default; } // // Image // pimage = p; if (!p->Sprite) { // No image. Try hover, selected, then default if ((flags & MI_FLAGS_ACTIVE) && style->Hover.Sprite) { pimage = &style->Hover; } else if (style->Default.Sprite) { pimage = &style->Default; } } if (pimage->Sprite) { pimage->Sprite->Load(); } if (pimage->Sprite) { pimage->Sprite->DrawFrame(pimage->Frame, x, y); } // // Text // if (!text.empty()) { GetDefaultTextColors(oldnc, oldrc); nc = !p->TextNormalColor.empty() ? &p->TextNormalColor : !style->TextNormalColor.empty() ? &style->TextNormalColor : &oldnc; rc = !p->TextReverseColor.empty() ? &p->TextReverseColor : !style->TextReverseColor.empty() ? &style->TextReverseColor : &oldrc; SetDefaultTextColors(*nc, *rc); if (p->TextAlign == TextAlignCenter || p->TextAlign == TextAlignUndefined) { VideoDrawTextCentered(x + p->TextX, y + p->TextY, style->Font, text); } else if (p->TextAlign == TextAlignLeft) { VideoDrawText(x + p->TextX, y + p->TextY, style->Font, text); } else { VideoDrawText(x + p->TextX - style->Font->Width(text), y + p->TextY, style->Font, text); } SetDefaultTextColors(oldnc, oldrc); } // // Border // if (!p->BorderColor) { p->BorderColor = Video.MapRGB(TheScreen->format, p->BorderColorRGB.r, p->BorderColorRGB.g, p->BorderColorRGB.b); } if (p->BorderSize) { for (int i = 0; i < p->BorderSize; ++i) { Video.DrawRectangleClip(p->BorderColor, x - i, y - i, style->Width + 2 * i, style->Height + 2 * i); } } }
/** ** Draw UI button 'button' on x,y ** ** @param style Button style ** @param flags State of Button (clicked, mouse over...) ** @param x X display position ** @param y Y display position ** @param text text to print on button */ void DrawUIButton(ButtonStyle *style, unsigned flags, int x, int y, const std::string &text, int player) { ButtonStyleProperties *p; if (flags & MI_FLAGS_CLICKED) { p = &style->Clicked; } else if (flags & MI_FLAGS_ACTIVE) { p = &style->Hover; } else { p = &style->Default; } // // Image // ButtonStyleProperties *pimage = p; if (!p->Sprite) { // No image. Try hover, selected, then default if ((flags & MI_FLAGS_ACTIVE) && style->Hover.Sprite) { pimage = &style->Hover; } else if (style->Default.Sprite) { pimage = &style->Default; } } if (pimage->Sprite) { pimage->Sprite->Load(); } if (pimage->Sprite) { CPlayerColorGraphic *colorGraphic = dynamic_cast<CPlayerColorGraphic *>(pimage->Sprite); if (colorGraphic && player != -1) { colorGraphic->DrawPlayerColorFrameClip(player, pimage->Frame, x, y); } else { pimage->Sprite->DrawFrame(pimage->Frame, x, y); } } // // Text // if (!text.empty()) { std::string oldnc; std::string oldrc; GetDefaultTextColors(oldnc, oldrc); CLabel label(*style->Font, (!p->TextNormalColor.empty() ? p->TextNormalColor : !style->TextNormalColor.empty() ? style->TextNormalColor : oldnc), (!p->TextReverseColor.empty() ? p->TextReverseColor : !style->TextReverseColor.empty() ? style->TextReverseColor : oldrc)); if (p->TextAlign == TextAlignCenter || p->TextAlign == TextAlignUndefined) { label.DrawCentered(x + p->TextPos.x, y + p->TextPos.y, text); } else if (p->TextAlign == TextAlignLeft) { label.Draw(x + p->TextPos.x, y + p->TextPos.y, text); } else { label.Draw(x + p->TextPos.x - style->Font->Width(text), y + p->TextPos.y, text); } } // // Border // if (!p->BorderColor) { p->BorderColor = Video.MapRGB(TheScreen->format, p->BorderColorRGB); } if (p->BorderSize) { for (int i = 0; i < p->BorderSize; ++i) { Video.DrawRectangleClip(p->BorderColor, x - i, y - i, style->Width + 2 * i, style->Height + 2 * i); } } }
/** ** Draw UI button 'button' on x,y ** ** @param style Button style ** @param flags State of Button (clicked, mouse over...) ** @param x X display position ** @param y Y display position ** @param text text to print on button */ void DrawUIButton(ButtonStyle *style, unsigned flags, int x, int y, const std::string &text, int player) { ButtonStyleProperties *p; if (flags & MI_FLAGS_CLICKED) { p = &style->Clicked; } else if (flags & MI_FLAGS_ACTIVE) { p = &style->Hover; } else { p = &style->Default; } // // Image // ButtonStyleProperties *pimage = p; if (!p->Sprite) { // No image. Try hover, selected, then default if ((flags & MI_FLAGS_ACTIVE) && style->Hover.Sprite) { pimage = &style->Hover; } else if (style->Default.Sprite) { pimage = &style->Default; } } if (pimage->Sprite) { pimage->Sprite->Load(); } if (pimage->Sprite) { CPlayerColorGraphic *colorGraphic = dynamic_cast<CPlayerColorGraphic *>(pimage->Sprite); if (colorGraphic && player != -1) { colorGraphic->DrawPlayerColorFrameClip(player, pimage->Frame, x, y); } else { pimage->Sprite->DrawFrame(pimage->Frame, x, y); } } // // Text // if (!text.empty()) { std::string oldnc; std::string oldrc; GetDefaultTextColors(oldnc, oldrc); CLabel label(*style->Font, (!p->TextNormalColor.empty() ? p->TextNormalColor : !style->TextNormalColor.empty() ? style->TextNormalColor : oldnc), (!p->TextReverseColor.empty() ? p->TextReverseColor : !style->TextReverseColor.empty() ? style->TextReverseColor : oldrc)); if (p->TextAlign == TextAlignCenter || p->TextAlign == TextAlignUndefined) { label.DrawCentered(x + p->TextPos.x, y + p->TextPos.y, text); } else if (p->TextAlign == TextAlignLeft) { label.Draw(x + p->TextPos.x, y + p->TextPos.y, text); } else { label.Draw(x + p->TextPos.x - style->Font->Width(text), y + p->TextPos.y, text); } } // // Border // if (!p->BorderColor) { CColor color(p->BorderColorRGB); if (p->BorderColorRGB.R > 0 || p->BorderColorRGB.G > 0 || p->BorderColorRGB.B > 0) { int shift = GameCycle % 0x20; color.R >>= shift / 2; color.G >>= shift / 2; color.B >>= shift / 2; if (shift >= 0x10) { color.R = (p->BorderColorRGB.R > 0) << ((shift - 0x10) / 2); color.G = (p->BorderColorRGB.G > 0) << ((shift - 0x10) / 2); color.B = (p->BorderColorRGB.B > 0) << ((shift - 0x10) / 2); } }