diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index d58a896f4..cd208af76 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -1050,7 +1050,6 @@ TerminateLevel(void) pp->CurWpn = NULL; memset(pp->Wpn, 0, sizeof(pp->Wpn)); - memset(pp->InventorySprite, 0, sizeof(pp->InventorySprite)); memset(pp->InventoryTics, 0, sizeof(pp->InventoryTics)); pp->Killer = -1; diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 442ce9d95..139b34875 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -1214,10 +1214,6 @@ struct PLAYERstruct // short InventoryNum; short InventoryBarTics; - PANEL_SPRITEp InventorySprite[MAX_INVENTORY]; - PANEL_SPRITEp InventorySelectionBox; - PANEL_SPRITEp MiniBarHealthBox, MiniBarAmmo; - PANEL_SPRITEp MiniBarHealthBoxDigit[3], MiniBarAmmoDigit[3]; short InventoryTics[MAX_INVENTORY]; short InventoryPercent[MAX_INVENTORY]; int8_t InventoryAmount[MAX_INVENTORY]; diff --git a/source/sw/src/inv.cpp b/source/sw/src/inv.cpp index b679e5dab..7a6697eaa 100644 --- a/source/sw/src/inv.cpp +++ b/source/sw/src/inv.cpp @@ -44,20 +44,11 @@ BEGIN_SW_NS extern short NormalVisibility; -// indexed by gs.BorderNum 130,172 -short InventoryBarXpos[] = {110, 110, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80}; -short InventoryBarYpos[] = {172, 172, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130}; - void PlayerUpdateInventory(PLAYERp pp, short InventoryNum); -void SpawnInventoryBar(PLAYERp pp); -void InventoryBarUpdatePosition(PLAYERp pp); void InventoryUse(PLAYERp pp); void InventoryStop(PLAYERp pp, short InventoryNum); -void KillInventoryBar(PLAYERp pp); -//#define INVENTORY_ICON_WIDTH 32 -#define INVENTORY_ICON_WIDTH 28 void UseInventoryRepairKit(PLAYERp pp); void UseInventoryMedkit(PLAYERp pp); @@ -77,30 +68,20 @@ void StopInventoryEnvironSuit(PLAYERp pp, short); void StopInventoryNightVision(PLAYERp pp, short); extern PANEL_STATE ps_PanelEnvironSuit[]; -extern PANEL_STATE ps_PanelCloak[]; -extern PANEL_STATE ps_PanelMedkit[]; -extern PANEL_STATE ps_PanelRepairKit[]; -extern PANEL_STATE ps_PanelSelectionBox[]; -extern PANEL_STATE ps_PanelNightVision[]; -extern PANEL_STATE ps_PanelChemBomb[]; -extern PANEL_STATE ps_PanelFlashBomb[]; -extern PANEL_STATE ps_PanelCaltrops[]; INVENTORY_DATA InventoryData[MAX_INVENTORY+1] = { - {"PORTABLE MEDKIT", UseInventoryMedkit, NULL, ps_PanelMedkit, 0, 1, (1<<16), 0}, - {"REPAIR KIT", NULL, NULL, ps_PanelRepairKit, 100, 1, (1<<16), INVF_AUTO_USE}, - {"SMOKE BOMB", UseInventoryCloak, StopInventoryCloak, ps_PanelCloak, 4, 1, (1<<16), INVF_TIMED}, - {"NIGHT VISION", UseInventoryNightVision, StopInventoryNightVision, ps_PanelNightVision,3, 1, (1<<16), INVF_TIMED}, - {"GAS BOMB", UseInventoryChemBomb, NULL, ps_PanelChemBomb, 0, 1, (1<<16), INVF_COUNT}, - {"FLASH BOMB", UseInventoryFlashBomb, NULL, ps_PanelFlashBomb, 0, 2, (1<<16), INVF_COUNT}, - {"CALTROPS", UseInventoryCaltrops, NULL, ps_PanelCaltrops, 0, 3, (1<<16), INVF_COUNT}, - {NULL, NULL, NULL, NULL, 0, 0, 0, 0} + {"PORTABLE MEDKIT", UseInventoryMedkit, NULL, 0, 1, (1<<16), 0}, + {"REPAIR KIT", NULL, NULL, 100, 1, (1<<16), INVF_AUTO_USE}, + {"SMOKE BOMB", UseInventoryCloak, StopInventoryCloak, 4, 1, (1<<16), INVF_TIMED}, + {"NIGHT VISION", UseInventoryNightVision, StopInventoryNightVision, 3, 1, (1<<16), INVF_TIMED}, + {"GAS BOMB", UseInventoryChemBomb, NULL, 0, 1, (1<<16), INVF_COUNT}, + {"FLASH BOMB", UseInventoryFlashBomb, NULL, 0, 2, (1<<16), INVF_COUNT}, + {"CALTROPS", UseInventoryCaltrops, NULL, 0, 3, (1<<16), INVF_COUNT}, + {NULL, NULL, NULL, NULL, 0, 0, 0} }; -void PanelInvTestSuicide(PANEL_SPRITEp psp); - void PanelInvTestSuicide(PANEL_SPRITEp psp) { if (TEST(psp->flags, PANF_SUICIDE)) @@ -109,84 +90,21 @@ void PanelInvTestSuicide(PANEL_SPRITEp psp) } } -PANEL_SPRITEp SpawnInventoryIcon(PLAYERp pp, short InventoryNum) -{ - PANEL_SPRITEp psp; - short x,y; - - // check invalid value - ASSERT(InventoryNum < MAX_INVENTORY); - - // check to see if its already spawned - if (pp->InventorySprite[InventoryNum]) - return NULL; - - // check for Icon panel state - if (!InventoryData[InventoryNum].State) - return NULL; - - x = InventoryBarXpos[gs.BorderNum] + (InventoryNum*INVENTORY_ICON_WIDTH); - y = InventoryBarYpos[gs.BorderNum]; - psp = pSpawnSprite(pp, InventoryData[InventoryNum].State, PRI_FRONT, x, y); - pp->InventorySprite[InventoryNum] = psp; - - psp->x1 = 0; - psp->y1 = 0; - psp->x2 = xdim - 1; - psp->y2 = ydim - 1; - psp->scale = InventoryData[InventoryNum].Scale; - SET(psp->flags, PANF_STATUS_AREA | PANF_SCREEN_CLIP); - - return psp; -} - void KillPanelInv(PLAYERp pp, short InventoryNum) { - ASSERT(pp->InventorySprite[InventoryNum]); ASSERT(InventoryNum < MAX_INVENTORY); pp->InventoryTics[InventoryNum] = 0; - SET(pp->InventorySprite[InventoryNum]->flags, PANF_SUICIDE); - pp->InventorySprite[InventoryNum] = NULL; -} - -void -KillPlayerIcon(PANEL_SPRITEp *pspp) -{ - SET((*pspp)->flags, PANF_SUICIDE); - (*pspp) = NULL; } void KillAllPanelInv(PLAYERp pp) { - short i; - - for (i = 0; i < MAX_INVENTORY; i++) + for (int i = 0; i < MAX_INVENTORY; i++) { - if (!pp->InventorySprite[i]) - continue; - pp->InventoryTics[i] = 0; - SET(pp->InventorySprite[i]->flags, PANF_SUICIDE); - pp->InventorySprite[i]->numpages = 0; - pp->InventorySprite[i] = NULL; } } -PANEL_SPRITEp SpawnIcon(PLAYERp pp, PANEL_STATEp state) -{ - PANEL_SPRITEp psp; - - psp = pSpawnSprite(pp, state, PRI_FRONT, 0, 0); - - psp->x1 = 0; - psp->y1 = 0; - psp->x2 = xdim - 1; - psp->y2 = ydim - 1; - SET(psp->flags, PANF_STATUS_AREA | PANF_SCREEN_CLIP); - return psp; -} - ////////////////////////////////////////////////////////////////////// // // MEDKIT @@ -413,47 +331,6 @@ void StopInventoryCloak(PLAYERp pp, short InventoryNum) PlaySound(DIGI_GASPOP, pp, v3df_none); } -////////////////////////////////////////////////////////////////////// -// -// ENVIRONMENT SUIT -// -////////////////////////////////////////////////////////////////////// -#if 0 -void UseInventoryEnvironSuit(PLAYERp pp) -{ - SPRITEp sp = pp->SpriteP; - short inv = INVENTORY_ENVIRON_SUIT; - - // only activate if you have one - if (pp->InventoryAmount[inv]) - { - pp->InventoryActive[inv] = TRUE; - // on/off - PlayerUpdateInventory(pp, inv); - } -} - -void StopInventoryEnvironSuit(PLAYERp pp, short InventoryNum) -{ - SPRITEp sp = pp->SpriteP; - short inv = INVENTORY_ENVIRON_SUIT; - - pp->InventoryActive[InventoryNum] = FALSE; - - if (pp->InventoryPercent[InventoryNum] <= 0) - { - pp->InventoryPercent[InventoryNum] = 0; - if (--pp->InventoryAmount[InventoryNum] < 0) - pp->InventoryAmount[InventoryNum] = 0; - } - - // on/off - PlayerUpdateInventory(pp, InventoryNum); - - PlaySound(DIGI_SWCLOAKUNCLOAK, pp, v3df_none); -} -#endif - ////////////////////////////////////////////////////////////////////// // // NIGHT VISION @@ -545,10 +422,9 @@ void InventoryKeys(PLAYERp pp) if (FLAG_KEY_PRESSED(pp, SK_INV_LEFT)) { FLAG_KEY_RELEASE(pp, SK_INV_LEFT); - SpawnInventoryBar(pp); + pp->InventoryBarTics = SEC(2); PlayerUpdateInventory(pp, pp->InventoryNum - 1); PutStringInfo(pp, InventoryData[pp->InventoryNum].Name); - InventoryBarUpdatePosition(pp); } } else @@ -562,10 +438,9 @@ void InventoryKeys(PLAYERp pp) if (FLAG_KEY_PRESSED(pp, SK_INV_RIGHT)) { FLAG_KEY_RELEASE(pp, SK_INV_RIGHT); - SpawnInventoryBar(pp); + pp->InventoryBarTics = SEC(2); PlayerUpdateInventory(pp, pp->InventoryNum + 1); PutStringInfo(pp, InventoryData[pp->InventoryNum].Name); - InventoryBarUpdatePosition(pp); } } else @@ -649,14 +524,10 @@ void InventoryTimer(PLAYERp pp) // if bar is up if (pp->InventoryBarTics) { - InventoryBarUpdatePosition(pp); - pp->InventoryBarTics -= synctics; // if bar time has elapsed if (pp->InventoryBarTics <= 0) { - // get rid of the bar - KillInventoryBar(pp); // don't update bar anymore pp->InventoryBarTics = 0; } @@ -722,73 +593,6 @@ void InventoryTimer(PLAYERp pp) } } -////////////////////////////////////////////////////////////////////// -// -// INVENTORY BAR -// -////////////////////////////////////////////////////////////////////// - -void SpawnInventoryBar(PLAYERp pp) -{ - short inv = 0; - INVENTORY_DATAp id; - PANEL_SPRITEp psp; - - - // its already up - if (pp->InventoryBarTics) - { - pp->InventoryBarTics = SEC(2); - return; - } - - pp->InventorySelectionBox = SpawnIcon(pp, ps_PanelSelectionBox); - - for (id = InventoryData; id->Name; id++, inv++) - { - psp = SpawnInventoryIcon(pp, inv); - - if (!pp->InventoryAmount[inv]) - { - //SET(psp->flags, PANF_TRANSLUCENT); - //SET(psp->flags, PANF_TRANS_FLIP); - psp->shade = 100; //Darken it - } - } - - pp->InventoryBarTics = SEC(2); -} - -void KillInventoryBar(PLAYERp pp) -{ - KillAllPanelInv(pp); - KillPlayerIcon(&pp->InventorySelectionBox); -} - -// In case the BorderNum changes - move the postions -void InventoryBarUpdatePosition(PLAYERp pp) -{ - short inv = 0; - short x,y; - INVENTORY_DATAp id; - - x = InventoryBarXpos[gs.BorderNum] + (pp->InventoryNum * INVENTORY_ICON_WIDTH); - y = InventoryBarYpos[gs.BorderNum]; - - pp->InventorySelectionBox->x = x - 5; - pp->InventorySelectionBox->y = y - 5; - - for (id = InventoryData; id->Name && inv < MAX_INVENTORY; id++, inv++) - { - x = InventoryBarXpos[gs.BorderNum] + (inv * INVENTORY_ICON_WIDTH); - y = InventoryBarYpos[gs.BorderNum]; - - pp->InventorySprite[inv]->x = x; - pp->InventorySprite[inv]->y = y; - } - -} - void InventoryUse(PLAYERp pp) { INVENTORY_DATAp id = &InventoryData[pp->InventoryNum]; @@ -813,36 +617,6 @@ void InventoryStop(PLAYERp pp, short InventoryNum) void PlayerUpdateInventory(PLAYERp pp, short InventoryNum) { - // Check for items that need to go translucent from use - if (pp->InventoryBarTics) - { - short inv = 0; - INVENTORY_DATAp id; - PANEL_SPRITEp psp; - - // Go translucent if used - for (id = InventoryData; id->Name && inv < MAX_INVENTORY; id++, inv++) - { - psp = pp->InventorySprite[inv]; - - if (!psp) - continue; - - if (!pp->InventoryAmount[inv]) - { - //SET(psp->flags, PANF_TRANSLUCENT); - //SET(psp->flags, PANF_TRANS_FLIP); - psp->shade = 100; // Darken it - } - else - { - //RESET(psp->flags, PANF_TRANSLUCENT); - //RESET(psp->flags, PANF_TRANS_FLIP); - psp->shade = 0; - } - } - } - pp->InventoryNum = InventoryNum; if (pp->InventoryNum < 0) diff --git a/source/sw/src/inv.h b/source/sw/src/inv.h index 25f8b207e..3147b2518 100644 --- a/source/sw/src/inv.h +++ b/source/sw/src/inv.h @@ -41,7 +41,6 @@ typedef struct const char *Name; void (*Init)(PLAYERp); void (*Stop)(PLAYERp, short); - PANEL_STATEp State; short DecPerSec; short MaxInv; int Scale; diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index 396efc4d2..b9a1885cb 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -7546,83 +7546,6 @@ PANEL_STATE ps_PanelEnvironSuit[] = {ID_PanelEnvironSuit, EnvironSuit_RATE, PanelInvTestSuicide, &ps_PanelEnvironSuit[0], 0,0,0} }; -#define ID_PanelCloak 2397 //2400 -PANEL_STATE ps_PanelCloak[] = -{ - {ID_PanelCloak, Cloak_RATE, PanelInvTestSuicide, &ps_PanelCloak[0], 0,0,0} -}; - -#define ID_PanelRepairKit 2399 -PANEL_STATE ps_PanelRepairKit[] = -{ - {ID_PanelRepairKit, RepairKit_RATE, PanelInvTestSuicide, &ps_PanelRepairKit[0], 0,0,0} -}; - -#define ID_PanelMedkit 2396 -PANEL_STATE ps_PanelMedkit[] = -{ - {ID_PanelMedkit, Medkit_RATE, PanelInvTestSuicide, &ps_PanelMedkit[0], 0,0,0} -}; - -#define ID_PanelNightVision 2398 -PANEL_STATE ps_PanelNightVision[] = -{ - {ID_PanelNightVision, Night_RATE, PanelInvTestSuicide, &ps_PanelNightVision[0], 0,0,0} -}; - -#define ID_PanelChemBomb 2407 -PANEL_STATE ps_PanelChemBomb[] = -{ - {ID_PanelChemBomb, ChemBomb_RATE, PanelInvTestSuicide, &ps_PanelChemBomb[0], 0,0,0} -}; - -#define ID_PanelFlashBomb 2408 -PANEL_STATE ps_PanelFlashBomb[] = -{ - {ID_PanelFlashBomb, FlashBomb_RATE, PanelInvTestSuicide, &ps_PanelFlashBomb[0], 0,0,0} -}; - -//#define ID_PanelSmokeBomb 2397 -//PANEL_STATE ps_PanelSmokeBomb[] = { -// {ID_PanelSmokeBomb, SmokeBomb_RATE, PanelInvTestSuicide, &ps_PanelSmokeBomb[0], 0,0,0} -// }; - -#define ID_PanelCaltrops 2409 -PANEL_STATE ps_PanelCaltrops[] = -{ - {ID_PanelCaltrops, Caltrops_RATE, PanelInvTestSuicide, &ps_PanelCaltrops[0], 0,0,0} -}; - -#define ID_SelectionBox 2435 -PANEL_STATE ps_PanelSelectionBox[] = -{ - {ID_SelectionBox, Box_RATE, PanelInvTestSuicide, &ps_PanelSelectionBox[0], 0,0,0} -}; - -#define ID_KeyRed 2392 -PANEL_STATE ps_PanelKeyRed[] = -{ - {ID_KeyRed, Box_RATE, PanelInvTestSuicide, &ps_PanelKeyRed[0], 0,0,0} -}; - -#define ID_KeyGreen 2393 -PANEL_STATE ps_PanelKeyGreen[] = -{ - {ID_KeyGreen, Box_RATE, PanelInvTestSuicide, &ps_PanelKeyGreen[0], 0,0,0} -}; - -#define ID_KeyBlue 2394 -PANEL_STATE ps_PanelKeyBlue[] = -{ - {ID_KeyBlue, Box_RATE, PanelInvTestSuicide, &ps_PanelKeyBlue[0], 0,0,0} -}; - -#define ID_KeyYellow 2395 -PANEL_STATE ps_PanelKeyYellow[] = -{ - {ID_KeyYellow, Box_RATE, PanelInvTestSuicide, &ps_PanelKeyYellow[0], 0,0,0} -}; - #include "saveable.h" @@ -7760,18 +7683,6 @@ static saveable_data saveable_panel_data[] = SAVE_DATA(ps_RetractFist), SAVE_DATA(ps_PanelEnvironSuit), - SAVE_DATA(ps_PanelCloak), - SAVE_DATA(ps_PanelRepairKit), - SAVE_DATA(ps_PanelMedkit), - SAVE_DATA(ps_PanelNightVision), - SAVE_DATA(ps_PanelChemBomb), - SAVE_DATA(ps_PanelFlashBomb), - SAVE_DATA(ps_PanelCaltrops), - SAVE_DATA(ps_PanelSelectionBox), - SAVE_DATA(ps_PanelKeyRed), - SAVE_DATA(ps_PanelKeyGreen), - SAVE_DATA(ps_PanelKeyBlue), - SAVE_DATA(ps_PanelKeyYellow), }; saveable_module saveable_panel = diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 461b26bc9..9af264143 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -5684,7 +5684,6 @@ DoPlayerWade(PLAYERp pp) if (PlayerFlyKey()) { - //pp->InventoryTics[INVENTORY_FLY] = -99; DoPlayerBeginFly(pp); pp->bob_amt = 0; pp->bob_ndx = 0; @@ -7407,7 +7406,6 @@ DoPlayerRun(PLAYERp pp) if (PlayerFlyKey()) { - //pp->InventoryTics[INVENTORY_FLY] = -99; DoPlayerBeginFly(pp); return; } @@ -8147,7 +8145,6 @@ InitAllPlayers(void) { for (i = 0; i < MAX_INVENTORY; i++) { - //pp->InventoryAmount[i] = InventoryData[i].MaxInv = 0; pp->InventoryAmount[i] = 0; pp->InventoryPercent[i] = 0; } diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index d6d87d0ec..08162ab2b 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -257,15 +257,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) for (ndx = 0; ndx < MAX_WEAPONS; ndx++) pp->Wpn[ndx] = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->Wpn[ndx]); pp->Chops = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->Chops); - for (ndx = 0; ndx < MAX_INVENTORY; ndx++) - pp->InventorySprite[ndx] = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->InventorySprite[ndx]); - pp->InventorySelectionBox = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->InventorySelectionBox); - pp->MiniBarHealthBox = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->MiniBarHealthBox); - pp->MiniBarAmmo = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->MiniBarAmmo); - for (ndx = 0; ndx < (short)SIZ(pp->MiniBarHealthBoxDigit); ndx++) - pp->MiniBarHealthBoxDigit[ndx] = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->MiniBarHealthBoxDigit[ndx]); - for (ndx = 0; ndx < (short)SIZ(pp->MiniBarAmmoDigit); ndx++) - pp->MiniBarAmmoDigit[ndx] = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->MiniBarAmmoDigit[ndx]); #endif MWRITE(&tp, sizeof(PLAYER),1,fil); @@ -1111,19 +1102,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) for (ndx = 0; ndx < MAX_WEAPONS; ndx++) pp->Wpn[ndx] = PanelNdxToSprite(pp, (int)(intptr_t)pp->Wpn[ndx]); - for (ndx = 0; ndx < MAX_INVENTORY; ndx++) - pp->InventorySprite[ndx] = PanelNdxToSprite(pp, (int)(intptr_t)pp->InventorySprite[ndx]); - pp->Chops = PanelNdxToSprite(pp, (int)(intptr_t)pp->Chops); - pp->InventorySelectionBox = PanelNdxToSprite(pp, (int)(intptr_t)pp->InventorySelectionBox); - pp->MiniBarHealthBox = PanelNdxToSprite(pp, (int)(intptr_t)pp->MiniBarHealthBox); - pp->MiniBarAmmo = PanelNdxToSprite(pp, (int)(intptr_t)pp->MiniBarAmmo); - - for (ndx = 0; ndx < (short)SIZ(pp->MiniBarHealthBoxDigit); ndx++) - pp->MiniBarHealthBoxDigit[ndx] = PanelNdxToSprite(pp, (int)(intptr_t)pp->MiniBarHealthBoxDigit[ndx]); - - for (ndx = 0; ndx < (short)SIZ(pp->MiniBarAmmoDigit); ndx++) - pp->MiniBarAmmoDigit[ndx] = PanelNdxToSprite(pp, (int)(intptr_t)pp->MiniBarAmmoDigit[ndx]); #endif } diff --git a/source/sw/src/sbar.cpp b/source/sw/src/sbar.cpp index 8b59d0295..716614f45 100644 --- a/source/sw/src/sbar.cpp +++ b/source/sw/src/sbar.cpp @@ -29,9 +29,9 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #undef MAIN #include "build.h" +#include "game.h" #include "names2.h" #include "panel.h" -#include "game.h" #include "pal.h" #include "misc.h" #include "player.h" @@ -41,6 +41,26 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS +enum +{ + ID_PanelMedkit = 2396, + ID_PanelRepairKit = 2399, + ID_PanelCloak = 2397, //2400 + ID_PanelNightVision = 2398, + ID_PanelChemBomb = 2407, + ID_PanelFlashBomb = 2408, + ID_PanelCaltrops = 2409, +}; + +static const short icons[] = { + ID_PanelMedkit, + ID_PanelRepairKit, + ID_PanelCloak, + ID_PanelNightVision, + ID_PanelChemBomb, + ID_PanelFlashBomb, + ID_PanelCaltrops, +}; class DSWStatusBar : public DBaseStatusBar { @@ -114,6 +134,7 @@ class DSWStatusBar : public DBaseStatusBar MINI_BAR_AMMO_BOX_PIC = 2437, MINI_BAR_INVENTORY_BOX_PIC = 2438, + ID_SelectionBox = 2435, }; //--------------------------------------------------------------------------- @@ -458,12 +479,9 @@ class DSWStatusBar : public DBaseStatusBar void PlayerUpdateInventoryPic(PLAYERp pp, int InventoryBoxX, int InventoryBoxY, int InventoryXoff, int InventoryYoff) { INVENTORY_DATAp id = &InventoryData[pp->InventoryNum]; - int x = InventoryBoxX + INVENTORY_PIC_XOFF + InventoryXoff; int y = InventoryBoxY + INVENTORY_PIC_YOFF + InventoryYoff; - - int pic = id->State->picndx; - DrawGraphic(tileGetTexture(pic), x, y, DI_ITEM_LEFT_TOP, 1, -1, -1, id->Scale/65536., id->Scale / 65536.); + DrawGraphic(tileGetTexture(icons[pp->InventoryNum]), x, y, DI_ITEM_LEFT_TOP, 1, -1, -1, id->Scale/65536., id->Scale / 65536.); } //--------------------------------------------------------------------------- @@ -697,25 +715,93 @@ class DSWStatusBar : public DBaseStatusBar // // //--------------------------------------------------------------------------- + + void DrawInventoryIcon(double xs, double ys, int align, int InventoryNum, int amount, bool selected) + { + double x, y; + const int INVENTORY_ICON_WIDTH = 28; + + // check invalid value + assert(InventoryNum < MAX_INVENTORY); + + x =xs + (InventoryNum * INVENTORY_ICON_WIDTH); + y = ys; + auto tex = icons[InventoryNum]; + auto scale = InventoryData[InventoryNum].Scale / 65536.; + DrawGraphic(tileGetTexture(tex), x, y, align | DI_ITEM_LEFT_TOP, amount? 1. : 0.333, -1, -1, scale, scale); + if (selected) + { + DrawGraphic(tileGetTexture(ID_SelectionBox), x-5, y-5, align | DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); + } + } + + ////////////////////////////////////////////////////////////////////// + // + // INVENTORY BAR + // + ////////////////////////////////////////////////////////////////////// + + void DrawInventory(double xs, double ys, int align) + { + auto pp = Player + screenpeek; + short inv = 0; + INVENTORY_DATAp id; + + if (!pp->InventoryBarTics) + { + return; + } + + for (id = InventoryData; id->Name; id++, inv++) + { + DrawInventoryIcon(xs, ys, align, inv, pp->InventoryAmount[inv], inv == pp->InventoryNum); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- public: void UpdateStatusBar(ClockTicks arg) { int nPalette = 0; + double inv_x, inv_y; + int align; - if (gs.BorderNum <= BORDER_NONE) return; + short InventoryBarXpos[] = { 110, 110, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80 }; + short InventoryBarYpos[] = { 172, 172, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130 }; - /*if (gs.BorderNum == BORDER_HUD) + if (gs.BorderNum <= BORDER_NONE) { + align = DI_SCREEN_RIGHT_BOTTOM; + inv_x = -210 * hud_scale / 100.; + inv_y = -28 * hud_scale / 100.; + } + /*else if (gs.BorderNum == BORDER_HUD) + { + align = DI_SCREEN_CENTER_TOP; + inv_x = -80 * hud_scale / 100.; + inv_y = -70 * hud_scale / 100.; DrawHUD2(); } - else*/ if (gs.BorderNum == BORDER_MINI_BAR) + */ + else if (gs.BorderNum == BORDER_MINI_BAR) { + align = DI_SCREEN_RIGHT_BOTTOM; + inv_x = -210 * hud_scale / 100.; + inv_y = -28 * hud_scale / 100.; DrawHUD1(); } else { + align = 0; + inv_x = 80 * hud_scale / 100.; + inv_y = 130 * hud_scale / 100.; DrawStatusBar(); } + DrawInventory(inv_x, inv_y, align); } }; diff --git a/source/sw/src/weapon.h b/source/sw/src/weapon.h index 33b88d670..968491c9c 100644 --- a/source/sw/src/weapon.h +++ b/source/sw/src/weapon.h @@ -185,8 +185,6 @@ int InitBunnyRocket(PLAYERp pp); int GetDamage(short SpriteNum, short Weapon, short DamageNdx); int DoFlamesDamageTest(short Weapon); -void DoActorSpawnIcon(int16_t SpriteNum); - typedef struct { STATEp state;