From 17c9513c982ed3f7c55cb26f54214665a2841ff2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 2 Jul 2020 20:17:29 +0200 Subject: [PATCH] - statusbar code cleanup. - removed adult_lockout option because it is just a stupid relic from the 90's without any purpose. Were people even using this anymore? --- source/games/duke/CMakeLists.txt | 4 +- source/games/duke/src/animatesprites_d.cpp | 11 +- source/games/duke/src/animatesprites_r.cpp | 11 +- source/games/duke/src/game.h | 2 +- source/games/duke/src/game_main.cpp | 62 ++ source/games/duke/src/sbar.cpp | 173 ++++ source/games/duke/src/sbar.h | 47 +- source/games/duke/src/sbar_d.cpp | 414 +++++++++ source/games/duke/src/sbar_r.cpp | 398 +++++++++ source/games/duke/src/sounds.cpp | 2 +- source/games/duke/src/zz_demo.cpp | 4 +- source/games/duke/src/zz_game.cpp | 8 +- source/games/duke/src/zz_namesdyn.cpp | 2 - source/games/duke/src/zz_premap.cpp | 4 +- source/games/duke/src/zz_savegame.cpp | 29 +- source/games/duke/src/zz_sbar.cpp | 921 --------------------- source/games/duke/src/zz_screens.cpp | 9 +- source/games/duke/src/zz_text.h | 6 + 18 files changed, 1096 insertions(+), 1011 deletions(-) create mode 100644 source/games/duke/src/sbar.cpp create mode 100644 source/games/duke/src/sbar_d.cpp create mode 100644 source/games/duke/src/sbar_r.cpp delete mode 100644 source/games/duke/src/zz_sbar.cpp diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index eef3df3bf..8878474bb 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -29,6 +29,9 @@ set( PCH_SOURCES src/premap.cpp src/premap_d.cpp src/premap_r.cpp + src/sbar.cpp + src/sbar_d.cpp + src/sbar_r.cpp src/sectors.cpp src/sectors_d.cpp src/sectors_r.cpp @@ -47,7 +50,6 @@ set( PCH_SOURCES src/zz_player.cpp src/zz_premap.cpp src/zz_savegame.cpp - src/zz_sbar.cpp src/zz_screens.cpp src/zz_text.cpp src/zz_sector.cpp diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index e2ed2aa2f..e51531791 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -163,11 +163,7 @@ void animatesprites_d(int x,int y,int a,int smoothratio) break; default: - if((tileinfo[s->picnum].flags & SFLAG_ADULT) && adult_lockout) - { - t->xrepeat = t->yrepeat = 0; - continue; - } + break; } if( t->statnum == 99 ) continue; @@ -209,11 +205,6 @@ void animatesprites_d(int x,int y,int a,int smoothratio) case MAIL+1: case PAPER: case PAPER+1: - if(adult_lockout && s->pal == 2) - { - t->xrepeat = t->yrepeat = 0; - continue; - } break; case TRIPBOMB: continue; diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 3b5766578..bef54ee0b 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -150,11 +150,7 @@ void animatesprites_r(int x,int y,int a,int smoothratio) t->xrepeat = t->yrepeat = 0; break; default: - if ((tileinfo[s->picnum].flags & SFLAG_ADULT) && adult_lockout) - { - t->xrepeat = t->yrepeat = 0; - continue; - } + break; } if( t->statnum == 99 ) continue; @@ -209,11 +205,6 @@ void animatesprites_r(int x,int y,int a,int smoothratio) t->shade = -127; case MONEY: case MONEY+1: - if(adult_lockout && s->pal == 2) - { - t->xrepeat = t->yrepeat = 0; - continue; - } break; case TRIPBOMBSPRITE: continue; diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index c780e3f07..d859a52b5 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -242,7 +242,7 @@ void G_BonusScreenRRRA(int32_t bonusonly); //void G_CheatGetInv(void); void G_DisplayRest(int32_t smoothratio); void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, int32_t smoothratio); -void G_DrawBackground(void); +void drawbackground(void); void G_DrawFrags(void); void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t horiz, int32_t smoothratio); void G_DrawRooms(int32_t playerNum,int32_t smoothratio); diff --git a/source/games/duke/src/game_main.cpp b/source/games/duke/src/game_main.cpp index 954ad48b1..505aee02b 100644 --- a/source/games/duke/src/game_main.cpp +++ b/source/games/duke/src/game_main.cpp @@ -198,5 +198,67 @@ void FTA(int q, struct player_struct* p) } } +//========================================================================== +// +// Draws the background +// todo: split up to have dedicated functions for both cases. +// +//========================================================================== + +void drawbackground(void) +{ + if ((g_player[myconnectindex].ps->gm & MODE_GAME) == 0 && ud.recstat != 2) + { + twod->ClearScreen(); + auto tex = tileGetTexture(TILE_MENUSCREEN); + PalEntry color = 0xff808080; + if (!hud_bgstretch) + DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, DTA_Color, color, TAG_DONE); + else + DrawTexture(twod, tex, 0, 0, DTA_VirtualWidth, twod->GetWidth(), DTA_VirtualHeight, twod->GetHeight(), DTA_KeepRatio, true, DTA_Color, color, TAG_DONE); + return; + } + + auto tex = tileGetTexture(isRRRA() ? /*TILE_RRTILE*/7629 : TILE_BIGHOLE); + if (tex != nullptr && tex->isValid()) + { + if (windowxy1.y > 0) + { + twod->AddFlatFill(0, 0, twod->GetWidth(), windowxy1.y, tex, false, 1); + } + if (windowxy2.y + 1 < twod->GetHeight()) + { + twod->AddFlatFill(0, windowxy2.y + 1, twod->GetWidth(), twod->GetHeight(), tex, false, 1); + } + if (windowxy1.x > 0) + { + twod->AddFlatFill(0, windowxy1.y, windowxy1.x, windowxy2.y + 1, tex, false, 1); + } + if (windowxy2.x + 1 < twod->GetWidth()) + { + twod->AddFlatFill(windowxy2.x + 1, windowxy1.y, twod->GetWidth(), windowxy2.y + 1, tex, false, 1); + } + auto vb = tileGetTexture(TILE_VIEWBORDER); + auto ve = tileGetTexture(TILE_VIEWBORDER + 1); + int x1 = windowxy1.x - 4; + int y1 = windowxy1.y - 4; + int x2 = windowxy2.x + 5; + int y2 = windowxy2.y + 5; + twod->AddFlatFill(x1, y1, x2, y1 + 4, vb, 5); + twod->AddFlatFill(x1, y2 - 4, x2, y2, vb, 6); + twod->AddFlatFill(x1, y1, x1 + 4, y2, vb, 1); + twod->AddFlatFill(x2 - 4, y1, x2, y2, vb, 3); + twod->AddFlatFill(x1, y1, x1 + 4, y1 + 4, ve, 1); + twod->AddFlatFill(x2 - 4, y1, x2, y1 + 4, ve, 3); + twod->AddFlatFill(x1, y2 - 4, x1 + 4, y2, ve, 2); + twod->AddFlatFill(x2 - 4, y2 - 4, x2, y2, ve, 4); + } + else + { + // If we got no frame just clear the screen. + twod->ClearScreen(); + } +} + END_DUKE_NS diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp new file mode 100644 index 000000000..0d48e8059 --- /dev/null +++ b/source/games/duke/src/sbar.cpp @@ -0,0 +1,173 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) +Copyright (C) 2020 - Christoph Oelckers + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +EDuke enhancements integrated: 04/13/2003 - Matt Saettler + +Note: EDuke source was in transition. Changes are in-progress in the +source as it is released. + +*/ +//------------------------------------------------------------------------- +#include "ns.h" // Must come before everything else! + +#include "v_font.h" +#include "duke3d.h" +#include "compat.h" +#include "sbar.h" +#include "v_draw.h" +#include "texturemanager.h" +BEGIN_DUKE_NS + +//========================================================================== +// +// very much a dummy to access the methods. +// The goal is to export this to a script. +// +//========================================================================== + +DDukeCommonStatusBar::DDukeCommonStatusBar() + : numberFont(BigFont, 1, Off, 1, 1), + indexFont(IndexFont, 4, CellRight, 1, 1), + miniFont(SmallFont2, 1, Off, 1, 1), + digiFont(DigiFont, 1 , Off, 1, 1) +{ + drawOffset.Y = 0; +} + + +//========================================================================== +// +// Frag bar - todo +// +//========================================================================== +#if 0 +void DDukeCommonStatusBar::displayfragbar(void) +{ + short i, j; + + j = 0; + + for (i = connecthead; i >= 0; i = connectpoint2[i]) + if (i > j) j = i; + + rotatesprite(0, 0, 65600L, 0, TILE_FRAGBAR, 0, 0, 2 + 8 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); + if (j >= 4) rotatesprite(319, (8) << 16, 65600L, 0, TILE_FRAGBAR, 0, 0, 10 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); + if (j >= 8) rotatesprite(319, (16) << 16, 65600L, 0, TILE_FRAGBAR, 0, 0, 10 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); + if (j >= 12) rotatesprite(319, (24) << 16, 65600L, 0, TILE_FRAGBAR, 0, 0, 10 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); + + for (i = connecthead; i >= 0; i = connectpoint2[i]) + { + minitext(21 + (73 * (i & 3)), 2 + ((i & 28) << 1), &ud.user_name[i][0], sprite[ps[i].i].pal, 2 + 8 + 16 + 128); + sprintf(tempbuf, "%d", ps[i].frag - ps[i].fraggedself); + minitext(17 + 50 + (73 * (i & 3)), 2 + ((i & 28) << 1), tempbuf, sprite[ps[i].i].pal, 2 + 8 + 16 + 128); + } +} +#endif +//========================================================================== +// +// Common inventory icon code for all styles +// +//========================================================================== + +std::pair DDukeCommonStatusBar::ontext(DukePlayer_t *p) +{ + std::pair retval(nullptr, CR_RED); + + int onstate = 0x80000000; + switch (p->inven_icon) + { + case ICON_HOLODUKE: + onstate = p->holoduke_on; + case ICON_JETPACK: + onstate = p->jetpack_on; + case ICON_HEATS: + onstate = p->heat_on; + } + + // Texts are intentionally not translated because the font is too small for making localization work and the translated words are too long. + if ((unsigned)onstate != 0x80000000 && !(g_gameType & (GAMEFLAG_WW2GI|GAMEFLAG_RRALL))) + { + retval.second = onstate > 0 ? CR_LIGHTBLUE : CR_RED; + retval.first = onstate > 0 ? "ON" : "OFF"; + } + if (p->inven_icon >= ICON_SCUBA) + { + retval.second = CR_ORANGE; + retval.first = "AUTO"; + } + return retval; +} + +//========================================================================== +// +// draws the inventory selector +// +//========================================================================== + +void DDukeCommonStatusBar::DrawInventory(const DukePlayer_t* p, double x, double y, int align) +{ + if (p->invdisptime <= 0)return; + + int n = 0, j = 0; + if (p->inv_amount[GET_FIRSTAID] > 0) n |= 1, j++; + if (p->inv_amount[GET_STEROIDS] > 0) n |= 2, j++; + if (p->inv_amount[GET_HOLODUKE] > 0) n |= 4, j++; + if (p->inv_amount[GET_JETPACK] > 0) n |= 8, j++; + if (p->inv_amount[GET_HEATS] > 0) n |= 16, j++; + if (p->inv_amount[GET_SCUBA] > 0) n |= 32, j++; + if (p->inv_amount[GET_BOOTS] > 0) n |= 64, j++; + + x -= (j * 11); + y -= 6; + + ; align |= DI_ITEM_CENTER; + for(int bit = 0; bit < 7; bit++) + { + int i = 1 << bit; + if (n & i) + { + int select = 1 << (p->inven_icon - 1); + double alpha = select == i ? 1.0 : 0.7; + DrawGraphic(tileGetTexture(item_icons[bit+1]), x, y, align, alpha, 0, 0, scale, scale); + if (select == i) DrawGraphic(tileGetTexture(TILE_ARROW), x, y, align, alpha, 0, 0, scale, scale); + x += 22; + } + } +} + +//========================================================================== +// +// Helper +// +//========================================================================== + +PalEntry DDukeCommonStatusBar::LightForShade(int shade) +{ + int ll = clamp((numshades - shade) * 255 / numshades, 0, 255); + return PalEntry(255, ll, ll, ll); +} + +END_DUKE_NS diff --git a/source/games/duke/src/sbar.h b/source/games/duke/src/sbar.h index 6ba18dae0..21ed76805 100644 --- a/source/games/duke/src/sbar.h +++ b/source/games/duke/src/sbar.h @@ -1,36 +1,29 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2016 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - #pragma once +#include +#include "statusbar.h" +#include "duke3d.h" + BEGIN_DUKE_NS -static FORCE_INLINE int32_t sbarsc(int32_t sc) +class DDukeCommonStatusBar : public DBaseStatusBar { - return scale(sc, ud.statusbarscale, 100); -} +protected: + DHUDFont numberFont; + DHUDFont indexFont; + DHUDFont miniFont; + DHUDFont digiFont; + double scale = 1; + std::array ammo_sprites; + std::array item_icons; -void G_DrawInventory(const DukePlayer_t *p); -void G_DrawStatusBar(int32_t snum); + DDukeCommonStatusBar(); + std::pair ontext(DukePlayer_t *p); + void DrawInventory(const DukePlayer_t* p, double x, double y, int align); + PalEntry LightForShade(int shade); +}; + +void drawstatusbar(int snum); END_DUKE_NS diff --git a/source/games/duke/src/sbar_d.cpp b/source/games/duke/src/sbar_d.cpp new file mode 100644 index 000000000..6cf2d93fb --- /dev/null +++ b/source/games/duke/src/sbar_d.cpp @@ -0,0 +1,414 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) +Copyright (C) 2020 - Christoph Oelckers + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +EDuke enhancements integrated: 04/13/2003 - Matt Saettler + +Note: EDuke source was in transition. Changes are in-progress in the +source as it is released. + +*/ +//------------------------------------------------------------------------- +#include "ns.h" // Must come before everything else! + +#include +#include "v_font.h" +#include "duke3d.h" +#include "compat.h" +#include "sbar.h" +#include "statusbar.h" +#include "v_draw.h" +#include "names.h" +#include "texturemanager.h" + +BEGIN_DUKE_NS + +//========================================================================== +// +// very much a dummy to access the methods. +// The goal is to export this to a script. +// +//========================================================================== + +class DDukeStatusBar : public DDukeCommonStatusBar +{ +public: + DDukeStatusBar() + { + // optionally draw at the top of the screen. + SetSize(tilesiz[BOTTOMSTATUSBAR].y); + scale = 1; + + ammo_sprites = { -1, AMMO, SHOTGUNAMMO, BATTERYAMMO, RPGAMMO, HBOMBAMMO, CRYSTALAMMO, DEVISTATORAMMO, TRIPBOMBSPRITE, FREEZEAMMO + 1, HBOMBAMMO, GROWAMMO/*, FLAMETHROWERAMMO + 1*/ }; + item_icons = { 0, FIRSTAID_ICON, STEROIDS_ICON, HOLODUKE_ICON, JETPACK_ICON, HEAT_ICON, AIRTANK_ICON, BOOT_ICON }; + } + + //========================================================================== + // + // Helpers + // + //========================================================================== + + int getinvamount(const DukePlayer_t* p) + { + switch (p->inven_icon) + { + case ICON_FIRSTAID: + return p->inv_amount[GET_FIRSTAID]; + case ICON_STEROIDS: + return (p->inv_amount[GET_STEROIDS] + 3) >> 2; + case ICON_HOLODUKE: + return (p->inv_amount[GET_HOLODUKE] + 15) / 24; + case ICON_JETPACK: + return (p->inv_amount[GET_JETPACK] + 15) >> 4; + case ICON_HEATS: + return p->inv_amount[GET_HEATS] / 12; + case ICON_SCUBA: + return (p->inv_amount[GET_SCUBA] + 63) >> 6; + case ICON_BOOTS: + return p->inv_amount[GET_BOOTS] >> 1; + } + + return -1; + } + + int GetMoraleOrShield(DukePlayer_t *p, int snum) + { + // special handling for WW2GI + int lAmount = GetGameVar("PLR_MORALE", -1, p->i, snum); + if (lAmount == -1) lAmount = p->inv_amount[GET_SHIELD]; + return lAmount; + } + + + //========================================================================== + // + // Fullscreen HUD variant #1 + // + //========================================================================== + + void FullscreenHUD1(DukePlayer_t* p, int snum) + { + // + // Health + // + DrawGraphic(tileGetTexture(TILE_COLA), 2, -2, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, 0.75, 0.75); + + FString format; + if (!althud_flashing || p->last_extra > (max_player_health >> 2) || ((int)totalclock & 32) || (sprite[p->i].pal == 1 && p->last_extra < 2)) + { + int s = -8; + if (althud_flashing && p->last_extra > max_player_health) + s += (sintable[((int)totalclock << 5) & 2047] >> 10); + int intens = clamp(255 - 4 * s, 0, 255); + auto pe = PalEntry(255, intens, intens, intens); + format.Format("%d", p->last_extra); + SBar_DrawString(this, &numberFont, format, 40, -BigFont->GetHeight() - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + } + + // + // Armor + // + DrawGraphic(tileGetTexture(TILE_SHIELD), 62, -2, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, 0.75, 0.75); + + format.Format("%d", GetMoraleOrShield(p, snum)); + SBar_DrawString(this, &numberFont, format, 105, -numberFont.mFont->GetHeight() - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + + // + // Weapon + // + + int wicon = ammo_sprites[p->curr_weapon]; + if (wicon > 0) + { + auto img = tileGetTexture(wicon); + auto scale = img && img->GetDisplayHeight() >= 50 ? 0.25 : 0.5; + DrawGraphic(img, -57, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + } + + int weapon = p->curr_weapon; + if (weapon == HANDREMOTE_WEAPON) weapon = HANDBOMB_WEAPON; + + if (p->curr_weapon != KNEE_WEAPON && (!althud_flashing || (int)totalclock & 32 || p->ammo_amount[weapon] > (max_ammo_amount[weapon] / 10))) + { + format.Format("%d", p->ammo_amount[weapon]); + SBar_DrawString(this, &numberFont, format, -22, -numberFont.mFont->GetHeight() - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + } + + // + // Selected inventory item + // + + unsigned icon = p->inven_icon; + if (icon > 0) + { + int x = 131; + + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1); + + int percentv = getinvamount(p); + format.Format("%3d%%", percentv); + EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; + SBar_DrawString(this, &indexFont, format, x + 35, -indexFont.mFont->GetHeight() - 0.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); + + auto text = ontext(p); + if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 35, -miniFont.mFont->GetHeight() - 9.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); + } + + // + // keys + // + if (p->got_access & 1) DrawGraphic(tileGetTexture(TILE_ACCESSCARD), -29, -30, DI_ITEM_CENTER, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 0)); + if (p->got_access & 4) DrawGraphic(tileGetTexture(TILE_ACCESSCARD), -24, -28, DI_ITEM_CENTER, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 23)); + if (p->got_access & 2) DrawGraphic(tileGetTexture(TILE_ACCESSCARD), -19, -26, DI_ITEM_CENTER, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 21)); + } + + + //========================================================================== + // + // Fullscreen HUD variant #2 + // + //========================================================================== + + void FullscreenHUD2(DukePlayer_t *p) + { + // + // health + // + DrawGraphic(tileGetTexture(TILE_HEALTHBOX), 5, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + int health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; + FStringf format("%d", health); + SBar_DrawString(this, &digiFont, format, 19, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // ammo + // + DrawGraphic(tileGetTexture(TILE_AMMOBOX), 37, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? HANDBOMB_WEAPON : p->curr_weapon; + format.Format("%d", p->ammo_amount[wp]); + SBar_DrawString(this, &digiFont, format, 53, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // inventory + // + unsigned icon = p->inven_icon; + if (icon > 0) + { + int x = 73; + DrawGraphic(tileGetTexture(TILE_INVENTORYBOX), 69, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, -14, DI_ITEM_LEFT|DI_ITEM_VCENTER, 1, -1, -1, scale, scale); + + int percentv = getinvamount(p); + format.Format("%3d%%", percentv); + EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; + SBar_DrawString(this, &indexFont, format, x + 34, -indexFont.mFont->GetHeight() - 5.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); + + auto text = ontext(p); + if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 34, -miniFont.mFont->GetHeight() - 14.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); + + } + } + + //========================================================================== + // + // Fullscreen HUD drawer + // + //========================================================================== + + void DrawHud(int snum, int style) + { + auto p = g_player[snum].ps; + BeginHUD(320, 200, 1.f, true); + if (style == 1) + { + DrawInventory(p, 0, -46, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD1(p, snum); + } + else if (style == 2) + { + DrawInventory(p, (ud.multimode > 1) ? 56 : 65, -28, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD2(p); + } + else + { + DrawInventory(p, 0, -28, DI_SCREEN_CENTER_BOTTOM); + } + } + + + //========================================================================== + // + // Helper for weapon display + // + //========================================================================== + + void DrawWeaponNum(int index, int x, int y, int num1, int num2, int shade, int numdigits) + { + /* + if (VOLUMEONE && (ind > HANDBOMB_WEAPON || ind < 0)) + { + minitextshade(x + 1, y - 4, "ORDER", 20, 11, 2 + 8 + 16 + ROTATESPRITE_MAX); + return; + } + */ + FString format; + + if (numdigits == 2) + { + if (num1 > 99) num1 = 99; + if (num2 > 99) num2 = 99; + format.Format("%2d/%d", num1, num2); + } + else + { + if (num1 > 999) num1 = 999; + if (num2 > 999) num2 = 999; + format.Format("%3d/%d", num1, num2); + } + y--; + DrawGraphic(tileGetTexture(THREEBYFIVE + index), x - 7, y, DI_ITEM_LEFT|DI_ITEM_VCENTER, 1, 0, 0, 1, 1, LightForShade(shade - 10), TRANSLATION(Translation_Remap, 7)); + auto pe = LightForShade(shade); + DrawGraphic(tileGetTexture(THREEBYFIVE + 10), x - 3, y, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, 0, 0, 1, 1, pe); + for (size_t i = 0; i < format.Len(); i++) + { + if (format[i] != ' ') + { + char c = format[i] == '/' ? 11 : format[i] - '0'; + DrawGraphic(tileGetTexture(THREEBYFIVE + c), x + 4 * i, y, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, 0, 0, 1, 1, pe); + } + } + } + + //========================================================================== + // + // Weapon display (Duke only) + // + //========================================================================== + + void DrawWeaponAmounts(const DukePlayer_t* p, int x, int y) + { + int cw = p->curr_weapon; + + auto ShadeForWeapon = [=](int weapon, int optweapon = -1) + { + // Headache-inducing math at play here. + return (((!p->ammo_amount[weapon]) | (!p->gotweapon[weapon])) * 9) + 12 - 18 * ((cw == weapon) || (optweapon != -1 && cw == optweapon)); + }; + + DrawWeaponNum(2, x, y, p->ammo_amount[PISTOL_WEAPON], max_ammo_amount[PISTOL_WEAPON], 12 - 20 * (cw == PISTOL_WEAPON), 3); + DrawWeaponNum(3, x, y + 6, p->ammo_amount[SHOTGUN_WEAPON], max_ammo_amount[SHOTGUN_WEAPON], ShadeForWeapon(SHOTGUN_WEAPON), 3); + DrawWeaponNum(4, x, y + 12, p->ammo_amount[CHAINGUN_WEAPON], max_ammo_amount[CHAINGUN_WEAPON], ShadeForWeapon(CHAINGUN_WEAPON), 3); + DrawWeaponNum(5, x + 39, y, p->ammo_amount[RPG_WEAPON], max_ammo_amount[RPG_WEAPON], ShadeForWeapon(RPG_WEAPON), 2); + DrawWeaponNum(6, x + 39, y + 6, p->ammo_amount[HANDBOMB_WEAPON], max_ammo_amount[HANDBOMB_WEAPON], ShadeForWeapon(HANDBOMB_WEAPON, HANDREMOTE_WEAPON), 2); + if (p->subweapon & (1 << GROW_WEAPON)) // original code says: if(!p->ammo_amount[SHRINKER_WEAPON] || cw == GROW_WEAPON) + DrawWeaponNum(7, x + 39, y + 12, p->ammo_amount[GROW_WEAPON], max_ammo_amount[GROW_WEAPON], ShadeForWeapon(GROW_WEAPON), 2); + else + DrawWeaponNum(7, x + 39, y + 12, p->ammo_amount[SHRINKER_WEAPON], max_ammo_amount[SHRINKER_WEAPON], ShadeForWeapon(SHRINKER_WEAPON), 2); + DrawWeaponNum(8, x + 70, y, p->ammo_amount[DEVISTATOR_WEAPON], max_ammo_amount[DEVISTATOR_WEAPON], ShadeForWeapon(DEVISTATOR_WEAPON), 2); + DrawWeaponNum(9, x + 70, y + 6, p->ammo_amount[TRIPBOMB_WEAPON], max_ammo_amount[TRIPBOMB_WEAPON], ShadeForWeapon(TRIPBOMB_WEAPON), 2); + DrawWeaponNum(0, x + 70, y + 12, p->ammo_amount[FREEZE_WEAPON], max_ammo_amount[FREEZE_WEAPON], ShadeForWeapon(FREEZE_WEAPON), 2); + } + + //========================================================================== + // + // Status bar drawer + // + //========================================================================== + + void Statusbar(int snum) + { + auto p = g_player[snum].ps; + int h = tilesiz[BOTTOMSTATUSBAR].y; + int top = 200 - h; + BeginStatusBar(320, 200, h, true); + DrawInventory(p, 160, 154, 0); + DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), 0, top, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); + + FString format; + + if (ud.multimode > 1 && (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) + { + DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1); + format.Format("%d", max(p->frag - p->fraggedself, 0)); + SBar_DrawString(this, &digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + } + else + { + auto key = tileGetTexture(ACCESS_ICON); + if (p->got_access & 4) DrawGraphic(key, 275, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, 23)); + if (p->got_access & 2) DrawGraphic(key, 288, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, 21)); + if (p->got_access & 1) DrawGraphic(key, 281, top + 23, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, 0)); + } + DrawWeaponAmounts(p, 96, top + 16); + + int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; + format.Format("%d", num); + SBar_DrawString(this, &digiFont, format, 32, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + format.Format("%d", GetMoraleOrShield(p, snum)); + SBar_DrawString(this, &digiFont, format, 64, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + + if (p->curr_weapon != KNEE_WEAPON) + { + int wep = (p->curr_weapon == HANDREMOTE_WEAPON)? HANDBOMB_WEAPON : p->curr_weapon; + format.Format("%d", p->ammo_amount[wep]); + SBar_DrawString(this, &digiFont, format, 208, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + } + + int icon = p->inven_icon; + if (icon) + { + int x = 231; + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, top + 20, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, 1, 1); + + int percentv = getinvamount(p); + format.Format("%3d%%", percentv); + EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; + SBar_DrawString(this, &indexFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); + + auto text = ontext(p); + if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); + } + } + + +}; + +void drawstatusbar_d(int snum) +{ + DDukeStatusBar dsb; + if (ud.screen_size <= 4) + { + dsb.DrawHud(snum, ud.screen_size < 4 ? 0 : ud.althud ? 1 : 2); + } + else + { + dsb.Statusbar(snum); + } +} + +END_DUKE_NS diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp new file mode 100644 index 000000000..37dbd208d --- /dev/null +++ b/source/games/duke/src/sbar_r.cpp @@ -0,0 +1,398 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2020 - Christoph Oelckers + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +*/ +//------------------------------------------------------------------------- +#include "ns.h" // Must come before everything else! + +#include "v_font.h" +#include "duke3d.h" +#include "compat.h" +#include "sbar.h" +#include "v_draw.h" +#include "names_rr.h" +#include "texturemanager.h" + +BEGIN_DUKE_NS + +//========================================================================== +// +// very much a dummy just to access the methods. +// The goal is to export this to a script. +// +//========================================================================== + +class DRedneckStatusBar : public DDukeCommonStatusBar +{ + +public: + DRedneckStatusBar() + { + // optionally draw at the top of the screen. + SetSize(tilesiz[BOTTOMSTATUSBAR].y); + scale = 0.5; + ammo_sprites = { -1, AMMO, SHOTGUNAMMO, BATTERYAMMO, HBOMBAMMO, HBOMBAMMO, RRTILE43, DEVISTATORAMMO, TRIPBOMBSPRITE, GROWSPRITEICON, HBOMBAMMO, -1, BOWLINGBALLSPRITE, MOTOAMMO, BOATAMMO, -1, RPG2SPRITE }; + item_icons = { 0, FIRSTAID_ICON, STEROIDS_ICON, HOLODUKE_ICON, JETPACK_ICON, HEAT_ICON, AIRTANK_ICON, BOOT_ICON }; + } + + + int getinvamount(const DukePlayer_t* p) + { + switch (p->inven_icon) + { + case ICON_FIRSTAID: + return p->inv_amount[GET_FIRSTAID]; + case ICON_STEROIDS: + return (p->inv_amount[GET_STEROIDS] + 3) >> 2; + case ICON_HOLODUKE: + return p->inv_amount[GET_HOLODUKE] / 400; + case ICON_JETPACK: + return p->inv_amount[GET_JETPACK] / 100; + case ICON_HEATS: + return p->inv_amount[GET_HEATS] / 12; + case ICON_SCUBA: + return (p->inv_amount[GET_SCUBA] + 63) >> 6; + case ICON_BOOTS: + return (p->inv_amount[GET_BOOTS] / 10) >> 1; + } + + return -1; + } + + + //========================================================================== + // + // Fullscreen HUD variant #1 for RR + // + //========================================================================== + + void FullscreenHUD1(DukePlayer_t* p, int snum) + { + // + // Health + // + + DrawGraphic(tileGetTexture(SPINNINGNUKEICON+1), 2, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 10000. / 65536., 10000. / 65536.); + + FString format; + if (!althud_flashing || p->last_extra > (max_player_health >> 2) || ((int)totalclock & 32) || (sprite[p->i].pal == 1 && p->last_extra < 2)) + { + int s = -8; + if (althud_flashing && p->last_extra > max_player_health) + s += (sintable[((int)totalclock << 5) & 2047] >> 10); + int intens = clamp(255 - 4 * s, 0, 255); + auto pe = PalEntry(255, intens, intens, intens); + format.Format("%d", p->last_extra); + SBar_DrawString(this, &numberFont, format, 44, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + + // + // drink + // + DrawGraphic(tileGetTexture(COLA), 70, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 10000. / 65536., 10000. / 65536.); + format.Format("%d", p->drink_amt); + SBar_DrawString(this, &numberFont, format, 98, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // eat + // + DrawGraphic(tileGetTexture(JETPACK), 122, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 20000. / 65536., 20000. / 65536.); + format.Format("%d", p->eat); + SBar_DrawString(this, &numberFont, format, 175, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // selected weapon + // + int wicon = ammo_sprites[p->curr_weapon]; + if (wicon > 0) + { + auto img = tileGetTexture(wicon); + auto myscale = img && img->GetDisplayHeight() >= 50 ? 0.25 : 0.5; + DrawGraphic(img, -50, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, myscale, myscale); + } + + int weapon = p->curr_weapon; + if (weapon == HANDREMOTE_WEAPON) weapon = DYNAMITE_WEAPON; + + if (p->curr_weapon != KNEE_WEAPON && p->curr_weapon != SLINGBLADE_WEAPON && (!althud_flashing || (int)totalclock & 32 || p->ammo_amount[weapon] > (max_ammo_amount[weapon] / 10))) + { + format.Format("%d", p->ammo_amount[weapon]); + SBar_DrawString(this, &numberFont, format, -20, -numberFont.mFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + + // + // Selected inventory item + // + + unsigned icon = p->inven_icon; + if (icon > 0) + { + int x = -122; + + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + + int percentv = getinvamount(p); + if (icon <= 2) format.Format("%3d%%", percentv); + else format.Format("%3d ", percentv); + SBar_DrawString(this, &miniFont, format, x + 35, -miniFont.mFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + auto text = ontext(p); + if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 35, -miniFont.mFont->GetHeight() * scale - 9.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + if (p->keys[1]) DrawGraphic(tileGetTexture(ACCESSCARD), -29, -32, DI_ITEM_BOTTOM, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 0)); + if (p->keys[3]) DrawGraphic(tileGetTexture(ACCESSCARD), -24, -30, DI_ITEM_BOTTOM, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 23)); + if (p->keys[2]) DrawGraphic(tileGetTexture(ACCESSCARD), -19, -28, DI_ITEM_BOTTOM, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 21)); + } + + + //========================================================================== + // + // Fullscreen HUD variant #2 for RR + // + //========================================================================== + + void FullscreenHUD2(DukePlayer_t* p) + { + // + // health + // + DrawGraphic(tileGetTexture(HEALTHBOX), 2, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + int health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; + FStringf format("%d", health); + SBar_DrawString(this, &digiFont, format, 17, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // ammo + // + DrawGraphic(tileGetTexture(AMMOBOX), 41, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? DYNAMITE_WEAPON : p->curr_weapon; + format.Format("%d", p->ammo_amount[wp]); + SBar_DrawString(this, &digiFont, format, 57, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // inventory + // + unsigned icon = p->inven_icon; + if (icon > 0) + { + int x = 81; + DrawGraphic(tileGetTexture(INVENTORYBOX), 77, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, -14, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, scale, scale); + + int percentv = getinvamount(p); + if (icon <= 2) format.Format("%3d%%", percentv); + else format.Format("%3d ", percentv); + SBar_DrawString(this, &miniFont, format, x + 34, -miniFont.mFont->GetHeight() * scale - 5.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + } + + //========================================================================== + // + // Fullscreen HUD drawer + // + //========================================================================== + + void DrawHud(int snum, int style) + { + auto p = g_player[snum].ps; + BeginHUD(320, 200, 1.f, true); + if (style == 1) + { + double y = -40; + if (ud.multimode > 1) + y -= 4; + if (ud.multimode > 4) + y -= 4; + DrawInventory(p, 0, y, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD1(p, snum); + } + else if (style == 2) + { + DrawInventory(p, 56, -20, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD2(p); + } + else + { + DrawInventory(p, 0, -20, DI_SCREEN_CENTER_BOTTOM); + } + } + + //========================================================================== + // + // Status bar drawer (RR) + // + //========================================================================== + + void DrawWeaponBar(const DukePlayer_t* p, int top) + { + double sbscale = 32800. / 65536.; + + DrawGraphic(tileGetTexture(WEAPONBAR), 0, 158, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); + + FString format; + for (int i = 0; i < 9; i++) + { + if ((g_gameType & GAMEFLAG_RRRA) && i == 4 && p->curr_weapon == CHICKEN_WEAPON) + { + DrawGraphic(tileGetTexture(AMMO_ICON + 10), 18 + i * 32, top - 6, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); + format.Format("%d", p->ammo_amount[CHICKEN_WEAPON]); + } + else + { + if (p->gotweapon[i+1]) { + DrawGraphic(tileGetTexture(AMMO_ICON + i), 18 + i * 32, top - 6, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); + } + format.Format("%d", p->ammo_amount[i+1]); + } + SBar_DrawString(this, &miniFont, format, 38 + i * 32, 162 - miniFont.mFont->GetHeight() * scale * 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + } + + + //========================================================================== + // + // Status bar drawer (RR) + // + //========================================================================== + + void Statusbar(int snum) + { + auto p = g_player[snum].ps; + double h = tilesiz[BOTTOMSTATUSBAR].y * scale; + double top = 200 - h; + BeginStatusBar(320, 200, h, true); + DrawInventory(p, 160, 154, 0); + + if (ud.screen_size > 8) + DrawWeaponBar(p, top); + + DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), 0, top, DI_ITEM_LEFT_TOP, 1, -1, -1, scale, scale); + + FString format; + + if (ud.multimode > 1 && (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) + { + DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1); + format.Format("%d", max(p->frag - p->fraggedself, 0)); + SBar_DrawString(this, &digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + else + { + auto key = tileGetTexture(ACCESS_ICON); + if (p->keys[3]) DrawGraphic(key, 140, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 23)); + if (p->keys[2]) DrawGraphic(key, 153, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 21)); + if (p->keys[1]) DrawGraphic(key, 146, top + 23, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 0)); + } + + int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; + format.Format("%d", num); + SBar_DrawString(this, &digiFont, format, 64, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + if (p->curr_weapon != KNEE_WEAPON) + { + int wep = (p->curr_weapon == HANDREMOTE_WEAPON) ? DYNAMITE_WEAPON : p->curr_weapon; + format.Format("%d", p->ammo_amount[wep]); + SBar_DrawString(this, &digiFont, format, 107, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + + int icon = p->inven_icon; + if (icon) + { + int x = 183; + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, top + 20, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, scale, scale); + + int percentv = getinvamount(p); + if (icon <= 2) format.Format("%3d%%", percentv); + else format.Format("%3d ", percentv); + SBar_DrawString(this, &miniFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + if (p->inven_icon == ICON_SCUBA || p->inven_icon == ICON_BOOTS) + SBar_DrawString(this, &miniFont, "AUTO", x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + + p->drunkang = ((p->drink_amt * 8) + 1647) & 2047; + if (p->drink_amt >= 100) + { + p->drink_amt = 100; + p->drunkang = 400; + } + + // Todo: These need rotation support which currently does not exist. + DrawGraphic(tileGetTexture(GUTMETER), 257, top + 24, DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, 0xffffffff, 0 /*, p->drunkang * 360. / 2048 */ ); + DrawGraphic(tileGetTexture(GUTMETER), 293, top + 24, DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, 0xffffffff, 0 /*, p->eatang * 360. / 2048 */); + + if (p->drink_amt >= 0 && p->drink_amt <= 30) + { + DrawGraphic(tileGetTexture(GUTMETER_LIGHT1), 239, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); + } + else if (p->drink_amt >= 31 && p->drink_amt <= 65) + { + DrawGraphic(tileGetTexture(GUTMETER_LIGHT2), 248, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); + } + else if (p->drink_amt >= 66 && p->drink_amt <= 87) + { + DrawGraphic(tileGetTexture(GUTMETER_LIGHT3), 256, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); + } + else + { + DrawGraphic(tileGetTexture(GUTMETER_LIGHT4), 265, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); + } + + if (p->eat >= 0 && p->eat <= 30) + { + DrawGraphic(tileGetTexture(GUTMETER_LIGHT1), 276, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); + } + else if (p->eat >= 31 && p->eat <= 65) + { + DrawGraphic(tileGetTexture(GUTMETER_LIGHT2), 285, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); + } + else if (p->eat >= 66 && p->eat <= 87) + { + DrawGraphic(tileGetTexture(GUTMETER_LIGHT3), 294, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); + } + else + { + DrawGraphic(tileGetTexture(GUTMETER_LIGHT4), 302, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); + } + } +}; + +void drawstatusbar_r(int snum) +{ + DRedneckStatusBar dsb; + if (ud.screen_size <= 4) + { + dsb.DrawHud(snum, ud.screen_size < 4 ? 0 : ud.althud ? 1 : 2); + } + else + { + dsb.Statusbar(snum); + } +} + +END_DUKE_NS diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 09668a7f2..b69b1fe98 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -475,7 +475,7 @@ int S_PlaySound(int sndnum, int channel, EChanFlags flags) if (!soundEngine->isValidSoundId(sndnum+1) || !SoundEnabled()) return -1; int userflags = S_GetUserFlags(sndnum); - if ((!(snd_speech & 1) && (userflags & SF_TALK)) || ((userflags & SF_ADULT) && adult_lockout)) + if ((!(snd_speech & 1) && (userflags & SF_TALK)) || ((userflags & SF_ADULT))) return -1; int const pitch = S_GetPitch(sndnum); diff --git a/source/games/duke/src/zz_demo.cpp b/source/games/duke/src/zz_demo.cpp index b56813edc..ab589785c 100644 --- a/source/games/duke/src/zz_demo.cpp +++ b/source/games/duke/src/zz_demo.cpp @@ -78,7 +78,7 @@ RECHECK: //fadepal(0,0,0, 0,252,28); P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); // JBF 20040308 - G_DrawBackground(); + drawbackground(); //M_DisplayMenus(); videoNextPage(); //fadepal(0,0,0, 252,0,-28); @@ -106,7 +106,7 @@ RECHECK: { if (foundemo == 0) { - G_DrawBackground(); + drawbackground(); } if ((g_player[myconnectindex].ps->gm&MODE_MENU) && (g_player[myconnectindex].ps->gm&MODE_EOL)) diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index 987bd80f5..c9db6af2a 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -422,7 +422,7 @@ static void G_OROR_DupeSprites(const spritetype *sp) if (spritesortcnt >= maxspritesonscreen) break; - if (sprite[k].picnum != TILE_SECTOREFFECTOR && sprite[k].z >= sp->z) + if (sprite[k].picnum != SECTOREFFECTOR && sprite[k].z >= sp->z) { tspriteptr_t tsp = renderAddTSpriteFromSprite(k); @@ -652,7 +652,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) { //videoClearScreen(0); if (ud.screen_size >= 8) - G_DrawBackground(); + drawbackground(); pub = 0; } @@ -1165,7 +1165,7 @@ static int32_t g_RTSPlaying; // Returns: started playing? int G_StartRTS(int lumpNum, int localPlayer) { - if (!adult_lockout && SoundEnabled() && + if (SoundEnabled() && RTS_IsInitialized() && g_RTSPlaying == 0 && (snd_speech & (localPlayer ? 1 : 4))) { auto sid = RTS_GetSoundID(lumpNum - 1); @@ -2096,7 +2096,7 @@ MAIN_LOOP_RESTART: G_DrawRooms(screenpeek, smoothRatio); if (videoGetRenderMode() >= REND_POLYMOST) - G_DrawBackground(); + drawbackground(); G_DisplayRest(smoothRatio); videoNextPage(); diff --git a/source/games/duke/src/zz_namesdyn.cpp b/source/games/duke/src/zz_namesdyn.cpp index d739913dc..00e63c732 100644 --- a/source/games/duke/src/zz_namesdyn.cpp +++ b/source/games/duke/src/zz_namesdyn.cpp @@ -1781,8 +1781,6 @@ int32_t TILE_MAMAJIBA = 0; int32_t TILE_MAMAJIBB = 0; -int APLAYER, CAMERA1; - // This is run after all CON define's have been processed to set up the // dynamic->static tile mapping. void G_InitDynamicTiles(void) diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index c18df2472..4f8eaf8e9 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -266,7 +266,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum) // we don't want the intro to play after the multiplayer setup screen if (!RR && (!g_netServer && ud.multimode < 2) && UserMap == 0 && - levelNum == 0 && volumeNum == 3 && adult_lockout == 0) + levelNum == 0 && volumeNum == 3) { e4intro([](bool) {}); } @@ -627,7 +627,7 @@ int G_EnterLevel(int gameMode) G_UpdateScreenArea(); videoClearViewableArea(0L); - G_DrawBackground(); + drawbackground(); G_DrawRooms(myconnectindex,65536); Net_WaitForEverybody(); diff --git a/source/games/duke/src/zz_savegame.cpp b/source/games/duke/src/zz_savegame.cpp index 5621966ae..3cd4e2e3f 100644 --- a/source/games/duke/src/zz_savegame.cpp +++ b/source/games/duke/src/zz_savegame.cpp @@ -163,7 +163,7 @@ int32_t G_LoadPlayer(const char *path) pub = NUMPAGES; pus = NUMPAGES; G_UpdateScreenArea(); - G_DrawBackground(); + drawbackground(); menutext_center(100, "Loading..."); videoNextPage(); } @@ -1430,7 +1430,7 @@ static void postloadplayer(int32_t savegamep) P_UpdateScreenPal(g_player[myconnectindex].ps); restorepalette = -1; - //3.5 + //4 if (savegamep) { for (SPRITES_OF(STAT_FX, i)) @@ -1444,31 +1444,6 @@ static void postloadplayer(int32_t savegamep) FX_SetReverb(0); } - //4 - if (savegamep) - { - if (adult_lockout) - { - for (i=0; i= 0) - wall[animwall[i].wallnum].picnum = wall[animwall[i].wallnum].extra; - } -#endif } //5 diff --git a/source/games/duke/src/zz_sbar.cpp b/source/games/duke/src/zz_sbar.cpp deleted file mode 100644 index 1029d010f..000000000 --- a/source/games/duke/src/zz_sbar.cpp +++ /dev/null @@ -1,921 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2016 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- -#include "ns.h" // Must come before everything else! - -#include -#include "v_font.h" -#include "duke3d.h" -#include "compat.h" -#include "sbar.h" -#include "statusbar.h" -#include "v_draw.h" -#include "texturemanager.h" -BEGIN_DUKE_NS - -//========================================================================== -// -// Helpers -// -//========================================================================== - -static int32_t G_GetInvAmount(const DukePlayer_t* p) -{ - switch (p->inven_icon) - { - case ICON_FIRSTAID: - return p->inv_amount[GET_FIRSTAID]; - case ICON_STEROIDS: - return (p->inv_amount[GET_STEROIDS] + 3) >> 2; - case ICON_HOLODUKE: - if (RR) return p->inv_amount[GET_HOLODUKE] / 400; - return (p->inv_amount[GET_HOLODUKE] + 15) / 24; - case ICON_JETPACK: - if (RR) return p->inv_amount[GET_JETPACK] / 100; - return (p->inv_amount[GET_JETPACK] + 15) >> 4; - case ICON_HEATS: - return p->inv_amount[GET_HEATS] / 12; - case ICON_SCUBA: - return (p->inv_amount[GET_SCUBA] + 63) >> 6; - case ICON_BOOTS: - if (RR) return (p->inv_amount[GET_BOOTS] / 10) >> 1; - return p->inv_amount[GET_BOOTS] >> 1; - } - - return -1; -} - -static int32_t G_GetInvOn(const DukePlayer_t* p) -{ - switch (p->inven_icon) - { - case ICON_HOLODUKE: - return p->holoduke_on; - case ICON_JETPACK: - return p->jetpack_on; - case ICON_HEATS: - return p->heat_on; - } - - return 0x80000000; -} - -static int32_t GetMoraleOrShield(DukePlayer_t *p, int32_t snum) -{ - // WW2GI - int lAmount = GetGameVar("PLR_MORALE", -1, p->i, snum); - if (lAmount == -1) lAmount = p->inv_amount[GET_SHIELD]; - return lAmount; -} - -//========================================================================== -// -// very much a dummy to access the methods. -// The goal is to export this to a script. -// -//========================================================================== - -class DukeStatusBar : public DBaseStatusBar -{ - DHUDFont numberFont; - DHUDFont indexFont; - DHUDFont miniFont; - DHUDFont digiFont; - double scale; - std::array ammo_sprites; - std::array item_icons = { 0, TILE_FIRSTAID_ICON, TILE_STEROIDS_ICON, TILE_HOLODUKE_ICON, TILE_JETPACK_ICON, TILE_HEAT_ICON, TILE_AIRTANK_ICON, TILE_BOOT_ICON }; - -public: - DukeStatusBar() - : numberFont(BigFont, 1, Off, 1, 1), - indexFont(IndexFont, 4, CellRight, 1, 1), - miniFont(SmallFont2, 1, Off, 1, 1), - digiFont(DigiFont, 1 , Off, 1, 1) - { - // optionally draw at the top of the screen. - SetSize(tilesiz[TILE_BOTTOMSTATUSBAR].y); - drawOffset.Y = hud_position ? -168 : 0; - scale = (g_gameType & GAMEFLAG_RRALL) ? 0.5 : 1; - - if (!(g_gameType & GAMEFLAG_RRALL)) - { - ammo_sprites = { -1, TILE_AMMO, TILE_SHOTGUNAMMO, TILE_BATTERYAMMO, TILE_RPGAMMO, TILE_HBOMBAMMO, TILE_CRYSTALAMMO, TILE_DEVISTATORAMMO, TILE_TRIPBOMBSPRITE, TILE_FREEZEAMMO + 1, TILE_HBOMBAMMO, TILE_GROWAMMO/*, FLAMETHROWERAMMO + 1*/ }; - } - else - { - ammo_sprites = { -1, TILE_AMMO, TILE_SHOTGUNAMMO, TILE_BATTERYAMMO, TILE_HBOMBAMMO, TILE_HBOMBAMMO, 43/*TILE_RRTILE43*/, TILE_DEVISTATORAMMO, TILE_TRIPBOMBSPRITE, TILE_GROWSPRITEICON, TILE_HBOMBAMMO, -1, - TILE_BOWLINGBALLSPRITE, TILE_MOTOAMMO, TILE_BOATAMMO, -1, TILE_RPG2SPRITE }; - } - } - - - //========================================================================== - // - // Frag bar - todo - // - //========================================================================== -#if 0 - void displayfragbar(void) - { - if (ud.statusbarflags & STATUSBAR_NOFRAGBAR) - return; - - - short i, j; - - j = 0; - - for (i = connecthead; i >= 0; i = connectpoint2[i]) - if (i > j) j = i; - - rotatesprite(0, 0, 65600L, 0, TILE_FRAGBAR, 0, 0, 2 + 8 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); - if (j >= 4) rotatesprite(319, (8) << 16, 65600L, 0, TILE_FRAGBAR, 0, 0, 10 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); - if (j >= 8) rotatesprite(319, (16) << 16, 65600L, 0, TILE_FRAGBAR, 0, 0, 10 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); - if (j >= 12) rotatesprite(319, (24) << 16, 65600L, 0, TILE_FRAGBAR, 0, 0, 10 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); - - for (i = connecthead; i >= 0; i = connectpoint2[i]) - { - minitext(21 + (73 * (i & 3)), 2 + ((i & 28) << 1), &ud.user_name[i][0], sprite[ps[i].i].pal, 2 + 8 + 16 + 128); - sprintf(tempbuf, "%d", ps[i].frag - ps[i].fraggedself); - minitext(17 + 50 + (73 * (i & 3)), 2 + ((i & 28) << 1), tempbuf, sprite[ps[i].i].pal, 2 + 8 + 16 + 128); - } - } -#endif - //========================================================================== - // - // Common inventory icon code for all styles - // - //========================================================================== - - std::pair ontext(DukePlayer_t *p) - { - std::pair retval(nullptr, CR_RED); - int onstate = G_GetInvOn(p); - // Texts are intentionally not translated because the font is too small for making localization work and the translated words are too long. - if ((unsigned)onstate != 0x80000000 && !(g_gameType & (GAMEFLAG_WW2GI|GAMEFLAG_RRALL))) - { - retval.second = onstate > 0 ? CR_LIGHTBLUE : CR_RED; - retval.first = onstate > 0 ? "ON" : "OFF"; - } - if (p->inven_icon >= ICON_SCUBA) - { - retval.second = CR_ORANGE; - retval.first = "AUTO"; - } - return retval; - } - - //========================================================================== - // - // draws the inventory selector - // - //========================================================================== - - void DrawInventory(const DukePlayer_t* p, double x, double y, int align) - { - if (p->invdisptime <= 0)return; - - int n = 0, j = 0; - if (p->inv_amount[GET_FIRSTAID] > 0) n |= 1, j++; - if (p->inv_amount[GET_STEROIDS] > 0) n |= 2, j++; - if (p->inv_amount[GET_HOLODUKE] > 0) n |= 4, j++; - if (p->inv_amount[GET_JETPACK] > 0) n |= 8, j++; - if (p->inv_amount[GET_HEATS] > 0) n |= 16, j++; - if (p->inv_amount[GET_SCUBA] > 0) n |= 32, j++; - if (p->inv_amount[GET_BOOTS] > 0) n |= 64, j++; - - x -= (j * 11); - y -= 6; - - ; align |= DI_ITEM_CENTER; - for(int i = 1; i < 128; i<<=1) - { - if (n & i) - { - int select = 1 << (p->inven_icon - 1); - double alpha = select == i ? 1.0 : 0.7; - switch (i) - { - case 1: - DrawGraphic(tileGetTexture(TILE_FIRSTAID_ICON), x, y, align, alpha, 0, 0, scale, scale); - break; - case 2: - DrawGraphic(tileGetTexture(TILE_STEROIDS_ICON), x, y, align, alpha, 0, 0, scale, scale); - break; - case 4: - DrawGraphic(tileGetTexture(TILE_HOLODUKE_ICON), x, y, align, alpha, 0, 0, scale, scale); - break; - case 8: - DrawGraphic(tileGetTexture(TILE_JETPACK_ICON), x, y, align, alpha, 0, 0, scale, scale); - break; - case 16: - DrawGraphic(tileGetTexture(TILE_HEAT_ICON), x, y, align, alpha, 0, 0, scale, scale); - break; - case 32: - DrawGraphic(tileGetTexture(TILE_AIRTANK_ICON), x, y, align, alpha, 0, 0, scale, scale); - break; - case 64: - DrawGraphic(tileGetTexture(TILE_BOOT_ICON), x, y, align, alpha, 0, 0, scale, scale); - break; - } - if (select == i) DrawGraphic(tileGetTexture(TILE_ARROW), x, y, align, alpha, 0, 0, scale, scale); - x += 22; - } - } - } - - //========================================================================== - // - // Fullscreen HUD variant #1 - // - //========================================================================== - - void FullscreenHUD1(DukePlayer_t* p, int32_t snum) - { - // - // Health - // - DrawGraphic(tileGetTexture(TILE_COLA), 2, -2, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, 0.75, 0.75); - - FString format; - if (!althud_flashing || p->last_extra > (max_player_health >> 2) || ((int32_t)totalclock & 32) || (sprite[p->i].pal == 1 && p->last_extra < 2)) - { - int s = -8; - if (althud_flashing && p->last_extra > max_player_health) - s += (sintable[((int)totalclock << 5) & 2047] >> 10); - int intens = clamp(255 - 4 * s, 0, 255); - auto pe = PalEntry(255, intens, intens, intens); - format.Format("%d", p->last_extra); - SBar_DrawString(this, &numberFont, format, 40, -BigFont->GetHeight() - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - - // - // Armor - // - DrawGraphic(tileGetTexture(TILE_SHIELD), 62, -2, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, 0.75, 0.75); - - format.Format("%d", GetMoraleOrShield(p, snum)); - SBar_DrawString(this, &numberFont, format, 105, -numberFont.mFont->GetHeight() - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - - // - // Weapon - // - - int wicon = ammo_sprites[p->curr_weapon]; - if (wicon > 0) - { - auto img = tileGetTexture(wicon); - auto scale = img && img->GetDisplayHeight() >= 50 ? 0.25 : 0.5; - DrawGraphic(img, -57, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - } - - int weapon = p->curr_weapon; - if (weapon == HANDREMOTE_WEAPON) weapon = HANDBOMB_WEAPON; - - if (p->curr_weapon != KNEE_WEAPON && (!althud_flashing || (int32_t)totalclock & 32 || p->ammo_amount[weapon] > (max_ammo_amount[weapon] / 10))) - { - format.Format("%d", p->ammo_amount[weapon]); - SBar_DrawString(this, &numberFont, format, -22, -numberFont.mFont->GetHeight() - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - - // - // Selected inventory item - // - - unsigned icon = p->inven_icon; - if (icon > 0) - { - int x = 131; - - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1); - - int percentv = G_GetInvAmount(p); - format.Format("%3d%%", percentv); - EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; - SBar_DrawString(this, &indexFont, format, x + 35, -indexFont.mFont->GetHeight() - 0.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); - - auto text = ontext(p); - if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 35, -miniFont.mFont->GetHeight() - 9.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); - } - - // - // keys - // - if (p->got_access & 1) DrawGraphic(tileGetTexture(TILE_ACCESSCARD), -29, -30, DI_ITEM_CENTER, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 0)); - if (p->got_access & 4) DrawGraphic(tileGetTexture(TILE_ACCESSCARD), -24, -28, DI_ITEM_CENTER, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 23)); - if (p->got_access & 2) DrawGraphic(tileGetTexture(TILE_ACCESSCARD), -19, -26, DI_ITEM_CENTER, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 21)); - } - - - //========================================================================== - // - // Fullscreen HUD variant #2 - // - //========================================================================== - - void FullscreenHUD2(DukePlayer_t *p) - { - // - // health - // - DrawGraphic(tileGetTexture(TILE_HEALTHBOX), 5, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - int32_t health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - FStringf format("%d", health); - SBar_DrawString(this, &digiFont, format, 19, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // ammo - // - DrawGraphic(tileGetTexture(TILE_AMMOBOX), 37, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? HANDBOMB_WEAPON : p->curr_weapon; - format.Format("%d", p->ammo_amount[wp]); - SBar_DrawString(this, &digiFont, format, 53, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // inventory - // - unsigned icon = p->inven_icon; - if (icon > 0) - { - int x = 73; - DrawGraphic(tileGetTexture(TILE_INVENTORYBOX), 69, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, -14, DI_ITEM_LEFT|DI_ITEM_VCENTER, 1, -1, -1, scale, scale); - - int percentv = G_GetInvAmount(p); - format.Format("%3d%%", percentv); - EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; - SBar_DrawString(this, &indexFont, format, x + 34, -indexFont.mFont->GetHeight() - 5.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); - - auto text = ontext(p); - if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 34, -miniFont.mFont->GetHeight() - 14.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); - - } - } - - //========================================================================== - // - // Fullscreen HUD variant #1 for RR - // - //========================================================================== - - void FullscreenHUD1RR(DukePlayer_t* p, int32_t snum) - { - - // - // Health - // - - DrawGraphic(tileGetTexture(TILE_SPINNINGNUKEICON+1), 2, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 10000. / 65536., 10000. / 65536.); - - FString format; - if (!althud_flashing || p->last_extra > (max_player_health >> 2) || ((int32_t)totalclock & 32) || (sprite[p->i].pal == 1 && p->last_extra < 2)) - { - int s = -8; - if (althud_flashing && p->last_extra > max_player_health) - s += (sintable[((int)totalclock << 5) & 2047] >> 10); - int intens = clamp(255 - 4 * s, 0, 255); - auto pe = PalEntry(255, intens, intens, intens); - format.Format("%d", p->last_extra); - SBar_DrawString(this, &numberFont, format, 44, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - - // - // drink - // - DrawGraphic(tileGetTexture(TILE_COLA), 70, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 10000. / 65536., 10000. / 65536.); - format.Format("%d", p->drink_amt); - SBar_DrawString(this, &numberFont, format, 98, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // eat - // - DrawGraphic(tileGetTexture(TILE_JETPACK), 122, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 20000. / 65536., 20000. / 65536.); - format.Format("%d", p->eat); - SBar_DrawString(this, &numberFont, format, 175, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // selected weapon - // - int wicon = ammo_sprites[p->curr_weapon]; - if (wicon > 0) - { - auto img = tileGetTexture(wicon); - auto myscale = img && img->GetDisplayHeight() >= 50 ? 0.25 : 0.5; - DrawGraphic(img, -50, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, myscale, myscale); - } - - int weapon = p->curr_weapon; - if (weapon == HANDREMOTE_WEAPON) weapon = DYNAMITE_WEAPON; - - if (p->curr_weapon != KNEE_WEAPON && p->curr_weapon != SLINGBLADE_WEAPON && (!althud_flashing || (int32_t)totalclock & 32 || p->ammo_amount[weapon] > (max_ammo_amount[weapon] / 10))) - { - format.Format("%d", p->ammo_amount[weapon]); - SBar_DrawString(this, &numberFont, format, -20, -numberFont.mFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - - // - // Selected inventory item - // - - unsigned icon = p->inven_icon; - if (icon > 0) - { - int x = -122; - - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - - int percentv = G_GetInvAmount(p); - if (icon <= 2) format.Format("%3d%%", percentv); - else format.Format("%3d ", percentv); - SBar_DrawString(this, &miniFont, format, x + 35, -miniFont.mFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - auto text = ontext(p); - if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 35, -miniFont.mFont->GetHeight() * scale - 9.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - if (p->keys[1]) DrawGraphic(tileGetTexture(TILE_ACCESSCARD), -29, -32, DI_ITEM_BOTTOM, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 0)); - if (p->keys[3]) DrawGraphic(tileGetTexture(TILE_ACCESSCARD), -24, -30, DI_ITEM_BOTTOM, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 23)); - if (p->keys[2]) DrawGraphic(tileGetTexture(TILE_ACCESSCARD), -19, -28, DI_ITEM_BOTTOM, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 21)); - } - - - //========================================================================== - // - // Fullscreen HUD variant #2 for RR - // - //========================================================================== - - void FullscreenHUD2RR(DukePlayer_t* p) - { - // - // health - // - DrawGraphic(tileGetTexture(TILE_HEALTHBOX), 2, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - int32_t health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - FStringf format("%d", health); - SBar_DrawString(this, &digiFont, format, 17, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // ammo - // - DrawGraphic(tileGetTexture(TILE_AMMOBOX), 41, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? DYNAMITE_WEAPON : p->curr_weapon; - format.Format("%d", p->ammo_amount[wp]); - SBar_DrawString(this, &digiFont, format, 57, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // inventory - // - unsigned icon = p->inven_icon; - if (icon > 0) - { - int x = 81; - DrawGraphic(tileGetTexture(TILE_INVENTORYBOX), 77, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, -14, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, scale, scale); - - int percentv = G_GetInvAmount(p); - if (icon <= 2) format.Format("%3d%%", percentv); - else format.Format("%3d ", percentv); - SBar_DrawString(this, &miniFont, format, x + 34, -miniFont.mFont->GetHeight() * scale - 5.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - } - - //========================================================================== - // - // Fullscreen HUD drawer - // - //========================================================================== - - void DrawHud(int32_t snum, int style) - { - auto p = g_player[snum].ps; - BeginHUD(320, 200, 1.f, true); - bool rr = !!(g_gameType & GAMEFLAG_RRALL); - if (style == 1) - { - if (!rr) - { - DrawInventory(p, 0, -46, DI_SCREEN_CENTER_BOTTOM); - FullscreenHUD1(p, snum); - } - else - { - double y = -40; - if (ud.multimode > 1) - y -= 4; - if (ud.multimode > 4) - y -= 4; - DrawInventory(p, 0, y, DI_SCREEN_CENTER_BOTTOM); - FullscreenHUD1RR(p, snum); - } - } - else if (style == 2) - { - if (!rr) - { - DrawInventory(p, (ud.multimode > 1) ? 56 : 65, -28, DI_SCREEN_CENTER_BOTTOM); - FullscreenHUD2(p); - } - else - { - DrawInventory(p, 56, -20, DI_SCREEN_CENTER_BOTTOM); - FullscreenHUD2RR(p); - } - } - else - { - DrawInventory(p, 0, rr? -20 : -28, DI_SCREEN_CENTER_BOTTOM); - } - } - - - //========================================================================== - // - // Helper - // - //========================================================================== - - PalEntry LightForShade(int shade) - { - int ll = clamp((numshades - shade) * 255 / numshades, 0, 255); - return PalEntry(255, ll, ll, ll); - } - - //========================================================================== - // - // Helper for weapon display - // - //========================================================================== - - void DrawWeaponNum(int index, int x, int y, int num1, int num2, int shade, int numdigits) - { - /* - if (VOLUMEONE && (ind > HANDBOMB_WEAPON || ind < 0)) - { - minitextshade(x + 1, y - 4, "ORDER", 20, 11, 2 + 8 + 16 + ROTATESPRITE_MAX); - return; - } - */ - FString format; - - if (numdigits == 2) - { - if (num1 > 99) num1 = 99; - if (num2 > 99) num2 = 99; - format.Format("%2d/%d", num1, num2); - } - else - { - if (num1 > 999) num1 = 999; - if (num2 > 999) num2 = 999; - format.Format("%3d/%d", num1, num2); - } - y--; - DrawGraphic(tileGetTexture(TILE_THREEBYFIVE + index), x - 7, y, DI_ITEM_LEFT|DI_ITEM_VCENTER, 1, 0, 0, 1, 1, LightForShade(shade - 10), TRANSLATION(Translation_Remap, 7)); - auto pe = LightForShade(shade); - DrawGraphic(tileGetTexture(TILE_THREEBYFIVE + 10), x - 3, y, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, 0, 0, 1, 1, pe); - for (size_t i = 0; i < format.Len(); i++) - { - if (format[i] != ' ') - { - char c = format[i] == '/' ? 11 : format[i] - '0'; - DrawGraphic(tileGetTexture(TILE_THREEBYFIVE + c), x + 4 * i, y, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, 0, 0, 1, 1, pe); - } - } - } - - //========================================================================== - // - // Weapon display (Duke only) - // - //========================================================================== - - void DrawWeaponAmounts(const DukePlayer_t* p, int32_t x, int32_t y) - { - int32_t cw = p->curr_weapon; - - auto ShadeForWeapon = [=](int weapon, int optweapon = -1) - { - // Headache-inducing math at play here. - return (((!p->ammo_amount[weapon]) | (!p->gotweapon[weapon])) * 9) + 12 - 18 * ((cw == weapon) || (optweapon != -1 && cw == optweapon)); - }; - - DrawWeaponNum(2, x, y, p->ammo_amount[PISTOL_WEAPON], max_ammo_amount[PISTOL_WEAPON], 12 - 20 * (cw == PISTOL_WEAPON), 3); - DrawWeaponNum(3, x, y + 6, p->ammo_amount[SHOTGUN_WEAPON], max_ammo_amount[SHOTGUN_WEAPON], ShadeForWeapon(SHOTGUN_WEAPON), 3); - DrawWeaponNum(4, x, y + 12, p->ammo_amount[CHAINGUN_WEAPON], max_ammo_amount[CHAINGUN_WEAPON], ShadeForWeapon(CHAINGUN_WEAPON), 3); - DrawWeaponNum(5, x + 39, y, p->ammo_amount[RPG_WEAPON], max_ammo_amount[RPG_WEAPON], ShadeForWeapon(RPG_WEAPON), 2); - DrawWeaponNum(6, x + 39, y + 6, p->ammo_amount[HANDBOMB_WEAPON], max_ammo_amount[HANDBOMB_WEAPON], ShadeForWeapon(HANDBOMB_WEAPON, HANDREMOTE_WEAPON), 2); - if (p->subweapon & (1 << GROW_WEAPON)) // original code says: if(!p->ammo_amount[SHRINKER_WEAPON] || cw == GROW_WEAPON) - DrawWeaponNum(7, x + 39, y + 12, p->ammo_amount[GROW_WEAPON], max_ammo_amount[GROW_WEAPON], ShadeForWeapon(GROW_WEAPON), 2); - else - DrawWeaponNum(7, x + 39, y + 12, p->ammo_amount[SHRINKER_WEAPON], max_ammo_amount[SHRINKER_WEAPON], ShadeForWeapon(SHRINKER_WEAPON), 2); - DrawWeaponNum(8, x + 70, y, p->ammo_amount[DEVISTATOR_WEAPON], max_ammo_amount[DEVISTATOR_WEAPON], ShadeForWeapon(DEVISTATOR_WEAPON), 2); - DrawWeaponNum(9, x + 70, y + 6, p->ammo_amount[TRIPBOMB_WEAPON], max_ammo_amount[TRIPBOMB_WEAPON], ShadeForWeapon(TRIPBOMB_WEAPON), 2); - DrawWeaponNum(0, x + 70, y + 12, p->ammo_amount[FREEZE_WEAPON], max_ammo_amount[FREEZE_WEAPON], ShadeForWeapon(FREEZE_WEAPON), 2); - } - - //========================================================================== - // - // Status bar drawer - // - //========================================================================== - - void Statusbar(int32_t snum) - { - auto p = g_player[snum].ps; - int h = tilesiz[TILE_BOTTOMSTATUSBAR].y; - int top = 200 - h; - BeginStatusBar(320, 200, h, true); - DrawInventory(p, 160, 154, 0); - DrawGraphic(tileGetTexture(TILE_BOTTOMSTATUSBAR), 0, top, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); - - FString format; - - if (ud.multimode > 1 && (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) - { - DrawGraphic(tileGetTexture(TILE_KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1); - format.Format("%d", max(p->frag - p->fraggedself, 0)); - SBar_DrawString(this, &digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - else - { - auto key = tileGetTexture(TILE_ACCESS_ICON); - if (p->got_access & 4) DrawGraphic(key, 275, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, 23)); - if (p->got_access & 2) DrawGraphic(key, 288, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, 21)); - if (p->got_access & 1) DrawGraphic(key, 281, top + 23, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, 0)); - } - DrawWeaponAmounts(p, 96, top + 16); - - int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - format.Format("%d", num); - SBar_DrawString(this, &digiFont, format, 32, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - format.Format("%d", GetMoraleOrShield(p, snum)); - SBar_DrawString(this, &digiFont, format, 64, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - - if (p->curr_weapon != KNEE_WEAPON) - { - int wep = (p->curr_weapon == HANDREMOTE_WEAPON)? HANDBOMB_WEAPON : p->curr_weapon; - format.Format("%d", p->ammo_amount[wep]); - SBar_DrawString(this, &digiFont, format, 208, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - - int icon = p->inven_icon; - if (icon) - { - int x = 231; - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, top + 20, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, 1, 1); - - int percentv = G_GetInvAmount(p); - format.Format("%3d%%", percentv); - EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; - SBar_DrawString(this, &indexFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); - - auto text = ontext(p); - if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); - } - } - - - //========================================================================== - // - // Status bar drawer (RR) - // - //========================================================================== - - void DrawWeaponBar(const DukePlayer_t* p, int top) - { - double sbscale = 32800. / 65536.; - - DrawGraphic(tileGetTexture(TILE_WEAPONBAR), 0, 158, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); - - FString format; - for (int i = 0; i < 9; i++) - { - if ((g_gameType & GAMEFLAG_RRRA) && i == 4 && p->curr_weapon == CHICKEN_WEAPON) - { - DrawGraphic(tileGetTexture(TILE_AMMO_ICON + 10), 18 + i * 32, top - 6, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); - format.Format("%d", p->ammo_amount[CHICKEN_WEAPON]); - } - else - { - if (p->gotweapon[i+1]) { - DrawGraphic(tileGetTexture(TILE_AMMO_ICON + i), 18 + i * 32, top - 6, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); - } - format.Format("%d", p->ammo_amount[i+1]); - } - SBar_DrawString(this, &miniFont, format, 38 + i * 32, 162 - miniFont.mFont->GetHeight() * scale * 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - } - - - //========================================================================== - // - // Status bar drawer (RR) - // - //========================================================================== - - void StatusbarRR(int32_t snum) - { - auto p = g_player[snum].ps; - double h = tilesiz[TILE_BOTTOMSTATUSBAR].y * scale; - double top = 200 - h; - BeginStatusBar(320, 200, h, true); - DrawInventory(p, 160, 154, 0); - - if (ud.screen_size > 8) - DrawWeaponBar(p, top); - - DrawGraphic(tileGetTexture(TILE_BOTTOMSTATUSBAR), 0, top, DI_ITEM_LEFT_TOP, 1, -1, -1, scale, scale); - - FString format; - - if (ud.multimode > 1 && (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) - { - DrawGraphic(tileGetTexture(TILE_KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1); - format.Format("%d", max(p->frag - p->fraggedself, 0)); - SBar_DrawString(this, &digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - else - { - auto key = tileGetTexture(TILE_ACCESS_ICON); - if (p->keys[3]) DrawGraphic(key, 140, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 23)); - if (p->keys[2]) DrawGraphic(key, 153, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 21)); - if (p->keys[1]) DrawGraphic(key, 146, top + 23, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 0)); - } - - int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - format.Format("%d", num); - SBar_DrawString(this, &digiFont, format, 64, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - if (p->curr_weapon != KNEE_WEAPON) - { - int wep = (p->curr_weapon == HANDREMOTE_WEAPON) ? DYNAMITE_WEAPON : p->curr_weapon; - format.Format("%d", p->ammo_amount[wep]); - SBar_DrawString(this, &digiFont, format, 107, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - - int icon = p->inven_icon; - if (icon) - { - int x = 183; - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, top + 20, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, scale, scale); - - int percentv = G_GetInvAmount(p); - if (icon <= 2) format.Format("%3d%%", percentv); - else format.Format("%3d ", percentv); - SBar_DrawString(this, &miniFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - if (p->inven_icon == ICON_SCUBA || p->inven_icon == ICON_BOOTS) - SBar_DrawString(this, &miniFont, "AUTO", x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - - p->drunkang = ((p->drink_amt * 8) + 1647) & 2047; - if (p->drink_amt >= 100) - { - p->drink_amt = 100; - p->drunkang = 400; - } - DrawGraphic(tileGetTexture(TILE_GUTMETER), 257, top + 24, DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, 0xffffffff, 0 /*, p->drunkang * 360. / 2048 */ ); - DrawGraphic(tileGetTexture(TILE_GUTMETER), 293, top + 24, DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, 0xffffffff, 0 /*, p->eatang * 360. / 2048 */); - - if (p->drink_amt >= 0 && p->drink_amt <= 30) - { - DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT1), 239, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else if (p->drink_amt >= 31 && p->drink_amt <= 65) - { - DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT2), 248, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else if (p->drink_amt >= 66 && p->drink_amt <= 87) - { - DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT3), 256, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else - { - DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT4), 265, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - - if (p->eat >= 0 && p->eat <= 30) - { - DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT1), 276, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else if (p->eat >= 31 && p->eat <= 65) - { - DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT2), 285, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else if (p->eat >= 66 && p->eat <= 87) - { - DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT3), 294, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else - { - DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT4), 302, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - - } - -}; - -void G_DrawStatusBar(int32_t snum) -{ - //if (!RR) - { - DukeStatusBar dsb; - if (ud.screen_size <= 4) - { - dsb.DrawHud(snum, ud.screen_size < 4 ? 0 : ud.althud ? 1 : 2); - } - else - { - if (!RR) dsb.Statusbar(snum); - else dsb.StatusbarRR(snum); - } - } -} - -//========================================================================== -// -// Draws the background -// todo: split up to have dedicated functions for both cases. -// -//========================================================================== - -void G_DrawBackground(void) -{ - if ((g_player[myconnectindex].ps->gm&MODE_GAME) == 0 && ud.recstat != 2) - { - twod->ClearScreen(); - auto tex = tileGetTexture((g_gameType & GAMEFLAG_DEER) ? 7040 : TILE_MENUSCREEN); - PalEntry color = (g_gameType & GAMEFLAG_DEER) ? 0xffffffff : 0xff808080; - if (!hud_bgstretch) - DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, DTA_Color, color, TAG_DONE); - else - DrawTexture(twod, tex, 0, 0, DTA_VirtualWidth, twod->GetWidth(), DTA_VirtualHeight, twod->GetHeight(), DTA_KeepRatio, true, DTA_Color, color, TAG_DONE); - return; - } - - auto tex = tileGetTexture((g_gameType & GAMEFLAG_RRRA) ? /*TILE_RRTILE*/7629 : TILE_BIGHOLE); - if (tex != nullptr && tex->isValid()) - { - if (windowxy1.y > 0) - { - twod->AddFlatFill(0, 0, twod->GetWidth(), windowxy1.y, tex, false, 1); - } - if (windowxy2.y + 1 < twod->GetHeight()) - { - twod->AddFlatFill(0, windowxy2.y + 1, twod->GetWidth(), twod->GetHeight(), tex, false, 1); - } - if (windowxy1.x > 0) - { - twod->AddFlatFill(0, windowxy1.y, windowxy1.x, windowxy2.y + 1, tex, false, 1); - } - if (windowxy2.x + 1 < twod->GetWidth()) - { - twod->AddFlatFill(windowxy2.x + 1, windowxy1.y, twod->GetWidth(), windowxy2.y + 1, tex, false, 1); - } - auto vb = tileGetTexture(TILE_VIEWBORDER); - auto ve = tileGetTexture(TILE_VIEWBORDER + 1); - int x1 = windowxy1.x - 4; - int y1 = windowxy1.y - 4; - int x2 = windowxy2.x + 5; - int y2 = windowxy2.y + 5; - twod->AddFlatFill(x1, y1, x2, y1 + 4, vb, 5); - twod->AddFlatFill(x1, y2 - 4, x2, y2, vb, 6); - twod->AddFlatFill(x1, y1, x1 + 4, y2, vb, 1); - twod->AddFlatFill(x2 - 4, y1, x2, y2, vb, 3); - twod->AddFlatFill(x1, y1, x1 + 4, y1 + 4, ve, 1); - twod->AddFlatFill(x2 - 4, y1, x2, y1 + 4, ve, 3); - twod->AddFlatFill(x1, y2 - 4, x1 + 4, y2, ve, 2); - twod->AddFlatFill(x2 - 4, y2 - 4, x2, y2, ve, 4); - } - else - { - // If we got no frame just clear the screen. - twod->ClearScreen(); - } -} - -END_DUKE_NS diff --git a/source/games/duke/src/zz_screens.cpp b/source/games/duke/src/zz_screens.cpp index 6ad05ac53..fc1b7a2b0 100644 --- a/source/games/duke/src/zz_screens.cpp +++ b/source/games/duke/src/zz_screens.cpp @@ -39,6 +39,9 @@ BEGIN_DUKE_NS #define quotepulseshade (sintable[((uint32_t)totalclock<<5)&2047]>>11) +void drawstatusbar_d(int snum); +void drawstatusbar_r(int snum); + int32_t g_crosshairSum = -1; // yxaspect and viewingrange just before the 'main' drawrooms call int32_t dr_yxaspect, dr_viewingrange; @@ -771,7 +774,7 @@ void G_DisplayRest(int32_t smoothratio) if (ud.overhead_on == 2) { twod->ClearScreen(); - G_DrawBackground(); + drawbackground(); renderDrawMapView(cposx, cposy, pp->zoom, cang); } G_DrawOverheadMap(cposx, cposy, pp->zoom, cang); @@ -789,8 +792,8 @@ void G_DisplayRest(int32_t smoothratio) } } - - G_DrawStatusBar(screenpeek); + if (isRR()) drawstatusbar_r(screenpeek); + else drawstatusbar_d(screenpeek); if (ud.show_level_text && hud_showmapname && g_levelTextTime > 1 && !M_Active()) { diff --git a/source/games/duke/src/zz_text.h b/source/games/duke/src/zz_text.h index f352729b2..b3c25a7b7 100644 --- a/source/games/duke/src/zz_text.h +++ b/source/games/duke/src/zz_text.h @@ -40,6 +40,12 @@ inline int minitext(int x, int y, const char* t, int p, int sb) return minitext_(x, y, t, 0, p, sb); } +static FORCE_INLINE int32_t sbarsc(int32_t sc) +{ + return scale(sc, ud.statusbarscale, 100); +} + + #define menutext_center(y, t) menutext_(160<<16, (y)<<16, 0, (t), 10|16, TEXT_XCENTER) #define gametext_center(y, t) gametext_(160<<16, (y)<<16, (t), 0, MF_Bluefont.pal, 0, 0, TEXT_XCENTER) #define gametext_center_number(y, t) gametext_(160<<16, (y)<<16, (t), 0, MF_Bluefont.pal, 0, 0, TEXT_XCENTER|TEXT_GAMETEXTNUMHACK)