From b50bdb1ca11da0e97df80738b8e02b1cb57b19b1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 Aug 2020 18:45:55 +0200 Subject: [PATCH] - SW: started transition of the status bar. --- source/sw/src/border.cpp | 1 - source/sw/src/panel.cpp | 25 +++-------- source/sw/src/sbar.cpp | 96 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 101 insertions(+), 21 deletions(-) diff --git a/source/sw/src/border.cpp b/source/sw/src/border.cpp index db6c682bf..00fa06267 100644 --- a/source/sw/src/border.cpp +++ b/source/sw/src/border.cpp @@ -186,7 +186,6 @@ void SetBorder(PLAYERp pp, int value) if (gs.BorderNum >= BORDER_BAR) { - pSpawnFullScreenSprite(pp, STATUS_BAR, PRI_FRONT, 0, 200 - tilesiz[STATUS_BAR].y); PlayerUpdatePanelInfo(Player + screenpeek); } diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index db4aa54d6..2355d90e9 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -59,6 +59,13 @@ int InitMine(PLAYERp pp); int InitFistAttack(PLAYERp pp); +#pragma message("delete me") +enum +{ + PANEL_BOX_Y = (174 - 6), + +}; + @@ -286,12 +293,6 @@ void PlayerUpdateHealth(PLAYERp pp, short value) USERp u = User[pp->PlayerSprite]; short x,y; -#define PANEL_HEALTH_BOX_X 20 -#define PANEL_BOX_Y (174-6) -#define PANEL_HEALTH_XOFF 2 -#define PANEL_HEALTH_YOFF 4 -#define HEALTH_ERASE 2401 - if (Prediction) return; @@ -392,19 +393,8 @@ void PlayerUpdateHealth(PLAYERp pp, short value) if (u->Health > pp->MaxHealth) u->Health = pp->MaxHealth; - - if (gs.BorderNum < BORDER_BAR || pp - Player != screenpeek) - return; - - // erase old info - pSpawnFullScreenSprite(pp, HEALTH_ERASE, PRI_MID, PANEL_HEALTH_BOX_X, PANEL_BOX_Y); - - x = PANEL_HEALTH_BOX_X + PANEL_HEALTH_XOFF; - y = PANEL_BOX_Y + PANEL_HEALTH_YOFF; - DisplayPanelNumber(pp, x, y, u->Health); } - void PlayerUpdateAmmo(PLAYERp pp, short UpdateWeaponNum, short value) { USERp u = User[pp->PlayerSprite]; @@ -759,7 +749,6 @@ void PlayerUpdatePanelInfo(PLAYERp pp) if (Prediction) return; - PlayerUpdateHealth(pp, 0); PlayerUpdateInventory(pp, pp->InventoryNum); PlayerUpdateAmmo(pp, u->WeaponNum, 0); PlayerUpdateWeapon(pp, u->WeaponNum); diff --git a/source/sw/src/sbar.cpp b/source/sw/src/sbar.cpp index fb5b214da..239b9190e 100644 --- a/source/sw/src/sbar.cpp +++ b/source/sw/src/sbar.cpp @@ -36,10 +36,102 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "misc.h" #include "player.h" #include "v_2ddrawer.h" +#include "statusbar.h" BEGIN_SW_NS +class DSWStatusBar : public DBaseStatusBar +{ + + enum + { + PANEL_HEALTH_BOX_X = 20, + PANEL_BOX_Y = (174-6), + PANEL_HEALTH_XOFF = 2, + PANEL_HEALTH_YOFF = 4, + + }; + + enum + { + PANEL_FONT_G = 3636, + PANEL_FONT_Y = 3646, + PANEL_FONT_R = 3656, + + PANEL_SM_FONT_G = 3601, + PANEL_SM_FONT_Y = 3613, + PANEL_SM_FONT_R = 3625, + + }; + + void DisplayPanelNumber(double xs, double ys, int number) + { + char buffer[32]; + char* ptr; + double x; + + mysnprintf(buffer, 32, "%03d", number); + + for (ptr = buffer, x = xs; *ptr; ptr++) + { + if (!isdigit(*ptr)) + { + continue; + } + int tex = PANEL_FONT_G + (*ptr - '0'); + DrawGraphic(tileGetTexture(tex), x, ys, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); + x += tileWidth(tex) + 1; + } + } + + void DrawStatusbarHealth(int value) + { + double x = PANEL_HEALTH_BOX_X + PANEL_HEALTH_XOFF; + double y = PANEL_BOX_Y + PANEL_HEALTH_YOFF; + DisplayPanelNumber(x, y, value); + } + + + void DrawStatusBar() + { + auto pp = Player + screenpeek; + USERp u = User[pp->PlayerSprite]; + BeginStatusBar(320, 200, tileHeight(STATUS_BAR)); + + DrawGraphic(tileGetTexture(STATUS_BAR), 0, 200, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1); + DrawStatusbarHealth(u->Health); + } + + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- +public: + void UpdateStatusBar(ClockTicks arg) + { + int nPalette = 0; + + if (gs.BorderNum <= BORDER_NONE) return; + + /*if (gs.BorderNum == BORDER_HUD) + { + DrawHUD2(); + } + else*/ if (gs.BorderNum == BORDER_MINI_BAR) + { + //DrawHUD1(nPalette); + } + else + { + DrawStatusBar(); + } + } + +}; + static void UpdateFrame(void) { @@ -59,14 +151,14 @@ static void UpdateFrame(void) void UpdateStatusBar(ClockTicks arg) { - //DSWStatusBar sbar; + DSWStatusBar sbar; if (gs.BorderNum >= BORDER_BAR) { UpdateFrame(); } - //sbar.UpdateStatusBar(arg); + sbar.UpdateStatusBar(arg); }