static void DrawHealth(player_t *CPlayer, int x, int y) { int health = CPlayer->health; // decide on the color first int fontcolor = health < hud_health_red ? CR_RED : health < hud_health_yellow ? CR_GOLD : health <= hud_health_green ? CR_GREEN : CR_BLUE; const bool haveBerserk = hud_berserk_health && NULL != berserkpic && NULL != CPlayer->mo->FindInventory< APowerStrength >(); DrawImageToBox(haveBerserk ? berserkpic : healthpic, x, y, 31, 17); DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17); }
static void DrawArmor(AInventory * armor, int x, int y) { if (armor) { int ap=armor->Amount; // decide on color int fontcolor = ap < hud_armor_red ? CR_RED : ap < hud_armor_yellow ? CR_GOLD : ap <= hud_armor_green ? CR_GREEN : CR_BLUE; if (ap) { DrawImageToBox(TexMan[armor->Icon], x, y, 31, 17); DrawHudNumber(HudFont, fontcolor, ap, x + 33, y + 17); } } }
static void DrawOneKey(int xo, int & x, int & y, int & c, AInventory * inv) { FTextureID icon = FNullTextureID(); FTextureID AltIcon = GetHUDIcon(inv->GetClass()); if (!AltIcon.Exists()) return; if (AltIcon.isValid()) { icon = AltIcon; } else if (inv->SpawnState && inv->SpawnState->sprite!=0) { FState * state = inv->SpawnState; if (state && (unsigned)state->sprite < (unsigned)sprites.Size ()) { spritedef_t * sprdef = &sprites[state->sprite]; spriteframe_t * sprframe = &SpriteFrames[sprdef->spriteframes + state->GetFrame()]; icon = sprframe->Texture[0]; } } if (icon.isNull()) icon = inv->Icon; if (icon.isValid()) { x -= 9; DrawImageToBox(TexMan[icon], x, y, 8, 10); c++; if (c>=10) { x=xo; y-=11; c=0; } } }
static void DrawFrags(player_t * CPlayer, int x, int y) { DrawImageToBox(fragpic, x, y, 31, 17); DrawHudNumber(HudFont, CR_GRAY, CPlayer->fragcount, x + 33, y + 17); }
static int DrawAmmo(player_t *CPlayer, int x, int y) { int i,j,k; char buf[256]; AInventory *inv; AWeapon *wi=CPlayer->ReadyWeapon; orderedammos.Clear(); if (0 == hud_showammo) { // Show ammo for current weapon if any if (wi) AddAmmoToList(wi); } else { // Order ammo by use of weapons in the weapon slots for (k = 0; k < NUM_WEAPON_SLOTS; k++) for(j = 0; j < CPlayer->weapons.Slots[k].Size(); j++) { PClassActor *weap = CPlayer->weapons.Slots[k].GetWeapon(j); if (weap) { // Show ammo for available weapons if hud_showammo CVAR is 1 // or show ammo for all weapons if hud_showammo is greater than 1 if (hud_showammo > 1 || CPlayer->mo->FindInventory(weap)) { AddAmmoToList((AWeapon*)GetDefaultByType(weap)); } } } // Now check for the remaining weapons that are in the inventory but not in the weapon slots for(inv=CPlayer->mo->Inventory;inv;inv=inv->Inventory) { if (inv->IsKindOf(RUNTIME_CLASS(AWeapon))) { AddAmmoToList((AWeapon*)inv); } } } // ok, we got all ammo types. Now draw the list back to front (bottom to top) int def_width = ConFont->StringWidth("000/000"); x-=def_width; int yadd = ConFont->GetHeight(); for(i=orderedammos.Size()-1;i>=0;i--) { PClassAmmo * type = orderedammos[i]; AAmmo * ammoitem = (AAmmo*)CPlayer->mo->FindInventory(type); AAmmo * inv = ammoitem? ammoitem : (AAmmo*)GetDefaultByType(orderedammos[i]); FTextureID AltIcon = GetHUDIcon(type); FTextureID icon = !AltIcon.isNull()? AltIcon : inv->Icon; if (!icon.isValid()) continue; int trans= (wi && (type==wi->AmmoType1 || type==wi->AmmoType2)) ? 0xc000:0x6000; int maxammo = inv->MaxAmount; int ammo = ammoitem? ammoitem->Amount : 0; mysnprintf(buf, countof(buf), "%3d/%3d", ammo, maxammo); int tex_width= clamp<int>(ConFont->StringWidth(buf)-def_width, 0, 1000); int fontcolor=( !maxammo ? CR_GRAY : ammo < ( (maxammo * hud_ammo_red) / 100) ? CR_RED : ammo < ( (maxammo * hud_ammo_yellow) / 100) ? CR_GOLD : CR_GREEN ); DrawHudText(ConFont, fontcolor, buf, x-tex_width, y+yadd, trans); DrawImageToBox(TexMan[icon], x-20, y, 16, 8, trans); y-=10; } return y; }