void TTower::GetUnitInfo() { char cbuf[30]; int clr; TObject::GetUnitInfo(); CopyBmpNZ(UInfoBuf, UINFO_SX, 77, 1, LevelBmps[Level], 29, 16); PutStr(UInfoBuf, UINFO_SX, 2, 2, GetName(), NormalFont, clrLightBlue, clrBlack); PutStr(UInfoBuf, UINFO_SX, 2, 26, SigText[TXT_STATE], NormalFont, clrWhite, clrBlack); PutStr(UInfoBuf, UINFO_SX, 2, 42, SigText[TXT_TIME], NormalFont, clrWhite, clrBlack); sprintf(cbuf, "%i %%", 100 * HitPoints / MaxHitPoints); clr = (100 * HitPoints < 20 * MaxHitPoints) ? clrRed : clrLightBlue2; PercentBar(UInfoBuf, UINFO_SX, 54, 28, 52, 13, clr, clrSeaBlue, (double)HitPoints / MaxHitPoints, cbuf); sprintf(cbuf, "%i/%i", TimeUnits, MaxTimeUnits); PercentBar(UInfoBuf, UINFO_SX, 54, 44, 52, 13, clrLightBlue2, clrSeaBlue, (double)TimeUnits / MaxTimeUnits, cbuf); // zbrane: for (int i = 0; i < WeaponsCnt; i++) { CopyBmp(UInfoBuf, UINFO_SX, 3, 83 + i * 26, ((i == CurWpn) && (WeaponsCnt != 1)) ? WpnInfoBkg[1] : WpnInfoBkg[0], 102, 23); PutStr(UInfoBuf, UINFO_SX, 5, 86 + i * 26, Weapons[i]->Name, NormalFont, clrWhite, clrBlack); sprintf(cbuf, "%i/%i", Weapons[i]->Ammo, Weapons[i]->MaxAmmo); PercentBar(UInfoBuf, UINFO_SX, 60, 88 + i * 26, 41, 13, clrLightBlue2, clrSeaBlue, (double)Weapons[i]->Ammo / Weapons[i]->MaxAmmo, cbuf); } if (CurWpn != -1) { CopyBmpNZ(UInfoBuf, UINFO_SX, 2, 188, BmpAmmoIcons[Weapons[CurWpn]->GetType()], 30, 13); sprintf(cbuf, "%i", Weapons[CurWpn]->TimeLost); PutStr(UInfoBuf, UINFO_SX, 35, 188, cbuf, NormalFont, clrWhite, clrBlack); } }
void TGanymedes::GetUnitInfo() { char cbuf[30]; int i, clr; TTrainSupportUnit::GetUnitInfo(); for (i = 0; i <4; i++) { sprintf(cbuf, "%i/%i", Ammo[i], MaxAmmo[i]); PercentBar(UInfoBuf, UINFO_SX, 34, 80+i*20, 72, 13, clrLightBlue2, clrSeaBlue, (double)Ammo[i] / MaxAmmo[i], cbuf); CopyBmpNZ(UInfoBuf, UINFO_SX, 2, 80+i*20, BmpAmmoIcons[i], 30, 13); } }
int TTransBox::Handle() { TEvent e; int lastun = -1, un; DrawUnits(); while (TRUE) { GetEvent(&e); if (e.What == evMouseDown) { if (e.Mouse.Buttons == mbRightButton) return -1; else { if (!IsInRect(e.Mouse.Where.x-x, e.Mouse.Where.y-y, 0, 0, w-1, h-1)) return -1; e.Mouse.Where.x -= x+8, e.Mouse.Where.y -= y+8; un = (e.Mouse.Where.x / 57) + (e.Mouse.Where.y / 57) * ((w-8) / 57); if ((un >= Cnt) || (un < 0)) un = -1; return un; } } else if (e.What == evMouseMove) { e.Mouse.Where.x -= x+8, e.Mouse.Where.y -= y+8; un = (e.Mouse.Where.x / 57) + (e.Mouse.Where.y / 57) * (w-8) / 57; if (!IsInRect(e.Mouse.Where.x+8, e.Mouse.Where.y+8, 0, 0, w-1, h-1) || (un >= Cnt) || (un < 0)) { memcpy(Buf + 180*w, Templ+180*w, 18*w); PutBitmap32(x, y+180, Buf+180*w, w, 18); lastun = -1; continue; } if (un == lastun) continue; lastun = un; // vykresli info o jednotce: memcpy(Buf + 180*w, Templ+180*w, 18*w); PutStr(Buf, w, 30+8, 181, Units[lunits[un]]->GetName(), NormalFont, clrWhite, clrBlack); CopyBmpNZ(Buf, w, 1+8, 181, LevelBmps[((TUnit*)Units[lunits[un]])->Level], 29, 16); PutBitmap32(x, y+180, Buf+180*w, w, 18); } else if (e.What == evKeyDown) { if (e.Key.KeyCode == kbEnter) return lastun; else return -1; } } }
void TThor::GetUnitInfo() { char cbuf[40]; TTower::GetUnitInfo(); PutStr(UInfoBuf, UINFO_SX, 2, 58, SigText[TXT_ROCKETS_LEFT], NormalFont, clrWhite, clrBlack); sprintf(cbuf, "%i / 100", TotalRockets); PercentBar(UInfoBuf, UINFO_SX, 54, 60, 52, 13, clrLightBlue2, clrSeaBlue, (double)TotalRockets / 100, cbuf); if (IsOverground) CopyBmp(UInfoBuf, UINFO_SX, 2, 147, IconThorIn->IconPic[0], 59, 59); else CopyBmp(UInfoBuf, UINFO_SX, 2, 147, IconThorOut->IconPic[0], 59, 59); CopyBmpNZ(UInfoBuf, UINFO_SX, 2, 129, BmpAmmoIcons[Weapons[CurWpn]->GetType()], 30, 13); sprintf(cbuf, "%i", Weapons[CurWpn]->TimeLost); PutStr(UInfoBuf, UINFO_SX, 35, 129, cbuf, NormalFont, clrWhite, clrBlack); }
void DrawOnScreen(int DrawBackground) { int i; int WordLineCnt; int LocalWordCnt = 0; int LocalPicCnt = 0; int PixColCnt = 0; int ArtCnt = -1; // Citac odstavcu double PixLineCnt; if (DrawBackground != 0) { void *ptr; char buf[20]; sprintf(buf, "%ibriefbk", iniResolution - 0x0100); ptr = GraphicsDF->get(buf); MouseHide(); DrawPicture(ptr); MouseShow(); memfree(ptr); } for (i = 0; i <= NumOfLines; i++) { WordLineCnt = -1; PixLineCnt = 0; do { WordLineCnt++; LocalWordCnt++; if (WordsTypes[LocalWordCnt] == 1) { if (LocalWordCnt != 1) i++; ArtCnt++; PixLineCnt = GetStrWidth(" ", NormalFont); if (LocalWordCnt != 1) PixColCnt += ArticleSpace*2; WordLineCnt = 0; } if (Links[LocalWordCnt] == 0) PutStr (BigDrawBuffer, LinePixels, PixLineCnt, PixColCnt, Words[LocalWordCnt], NormalFont, clrWhite, clrBlack); else { PutStr (BigDrawBuffer, LinePixels, PixLineCnt, PixColCnt, Words[LocalWordCnt], NormalFont, clrRed, clrBlack); LastLink++; LinksXY[LastLink].x1 = PixLineCnt; LinksXY[LastLink].x2 = PixLineCnt+GetStrWidth(Words[LocalWordCnt],NormalFont); LinksXY[LastLink].y1 = PixColCnt; LinksXY[LastLink].y2 = PixColCnt + 16; Links2[LastLink] = Links[LocalWordCnt]; } if (WordsTypes[LocalWordCnt] == 4) { // Obrazky (jee...) LocalPicCnt++; void *ptr; ptr = GraphicsDF->get(PicFiles[LocalPicCnt]); PixColCnt += 32; CopyBmpNZ(BigDrawBuffer, LinePixels, (LinePixels-PicSize[LocalPicCnt].x)/2, PixColCnt, ptr, PicSize[LocalPicCnt].x, PicSize[LocalPicCnt].y); PixColCnt += (PicSize[LocalPicCnt].y-16); memfree(ptr); } PixLineCnt += (double)GetStrWidth(Words[LocalWordCnt], NormalFont); PixLineCnt += LineSpace[i]; if (WordsTypes[LocalWordCnt] == 3) goto LastWord; } while (WordsTypes[LocalWordCnt] != 2); PixColCnt += 16; } LastWord: BriefRedrawScr(); }