mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- scriptified the AltHUD's inventory drawer and fixed the InvPrev CCMD.
This commit is contained in:
parent
714ca9b2ce
commit
4431ec06fd
3 changed files with 67 additions and 50 deletions
|
@ -404,7 +404,7 @@ CCMD(invprev)
|
|||
{
|
||||
if (who != NULL)
|
||||
{
|
||||
IFVM(PlayerPawn, InvNext)
|
||||
IFVM(PlayerPawn, InvPrev)
|
||||
{
|
||||
VMValue param = who;
|
||||
VMCall(func, ¶m, 1, nullptr, 0);
|
||||
|
|
|
@ -283,57 +283,12 @@ static void DrawWeapons(player_t *CPlayer, int x, int y)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void DrawInventory(player_t * CPlayer, int x,int y)
|
||||
static void DrawInventory(player_t * CPlayer, int x, int y)
|
||||
{
|
||||
AInventory * rover;
|
||||
int numitems = (hudwidth - 2*x) / 32;
|
||||
int i;
|
||||
|
||||
CPlayer->mo->InvFirst = rover = StatusBar->ValidateInvFirst(numitems);
|
||||
if (rover!=NULL)
|
||||
IFVM(AltHud, DrawInventory)
|
||||
{
|
||||
if(rover->PrevInv())
|
||||
{
|
||||
screen->DrawTexture(invgems[0], x-10, y,
|
||||
DTA_KeepRatio, true,
|
||||
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0.4, TAG_DONE);
|
||||
}
|
||||
|
||||
for(i=0;i<numitems && rover;rover=rover->NextInv())
|
||||
{
|
||||
if (rover->Amount>0)
|
||||
{
|
||||
FTextureID AltIcon = rover->AltHUDIcon;
|
||||
|
||||
if (AltIcon.Exists() && (rover->Icon.isValid() || AltIcon.isValid()) )
|
||||
{
|
||||
double trans = rover==CPlayer->mo->InvSel ? 1.0 : 0.4;
|
||||
|
||||
DrawImageToBox(TexMan[AltIcon.isValid()? AltIcon : rover->Icon], x, y, 19, 25, trans);
|
||||
if (rover->Amount>1)
|
||||
{
|
||||
char buffer[10];
|
||||
int xx;
|
||||
mysnprintf(buffer, countof(buffer), "%d", rover->Amount);
|
||||
if (rover->Amount>=1000) xx = 32 - IndexFont->StringWidth(buffer);
|
||||
else xx = 22;
|
||||
|
||||
screen->DrawText(IndexFont, CR_GOLD, x+xx, y+20, buffer,
|
||||
DTA_KeepRatio, true,
|
||||
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, trans, TAG_DONE);
|
||||
}
|
||||
|
||||
x+=32;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(rover)
|
||||
{
|
||||
screen->DrawTexture(invgems[1], x-10, y,
|
||||
DTA_KeepRatio, true,
|
||||
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0.4, TAG_DONE);
|
||||
}
|
||||
VMValue params[] = { althud, CPlayer, x, y };
|
||||
VMCall(func, params, countof(params), nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -651,7 +606,10 @@ void DrawHUD()
|
|||
althud->IntVar("healthpic") = healthpic? healthpic->id.GetIndex() : -1;
|
||||
althud->IntVar("berserkpic") = berserkpic? berserkpic->id.GetIndex() : -1;
|
||||
althud->IntVar("tnt1a0") = tnt1a0.GetIndex();
|
||||
althud->IntVar("invgem_left") = invgems[0]->id.GetIndex();
|
||||
althud->IntVar("invgem_right") = invgems[1]->id.GetIndex();
|
||||
althud->PointerVar<FFont>("HUDFont") = HudFont;
|
||||
althud->PointerVar<FFont>("IndexFont") = IndexFont;
|
||||
|
||||
if (!automapactive)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ class AltHud ui
|
|||
{
|
||||
TextureID healthPic, berserkPic;
|
||||
TextureID tnt1a0;
|
||||
TextureID invgem_left, invgem_right;
|
||||
int hudwidth, hudheight;
|
||||
int statspace;
|
||||
Font HudFont; // The font for the health and armor display
|
||||
|
@ -600,5 +601,63 @@ class AltHud ui
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Draw the Inventory
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DrawInventory(PlayerInfo CPlayer, int x,int y)
|
||||
{
|
||||
Inventory rover;
|
||||
int numitems = (hudwidth - 2*x) / 32;
|
||||
int i;
|
||||
|
||||
CPlayer.mo.InvFirst = rover = StatusBar.ValidateInvFirst(numitems);
|
||||
if (rover!=NULL)
|
||||
{
|
||||
if(rover.PrevInv())
|
||||
{
|
||||
screen.DrawTexture(invgem_left, true, x-10, y,
|
||||
DTA_KeepRatio, true,
|
||||
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0.4);
|
||||
}
|
||||
|
||||
for(i = 0; i < numitems && rover; rover = rover.NextInv())
|
||||
{
|
||||
if (rover.Amount > 0)
|
||||
{
|
||||
let AltIcon = rover.AltHUDIcon;
|
||||
|
||||
if (AltIcon.Exists() && (rover.Icon.isValid() || AltIcon.isValid()) )
|
||||
{
|
||||
double trans = rover == CPlayer.mo.InvSel ? 1.0 : 0.4;
|
||||
|
||||
DrawImageToBox(AltIcon.isValid()? AltIcon : rover.Icon, x, y, 19, 25, trans);
|
||||
if (rover.Amount > 1)
|
||||
{
|
||||
int xx;
|
||||
String buffer = String.Format("%d", rover.Amount);
|
||||
if (rover.Amount >= 1000) xx = 32 - IndexFont.StringWidth(buffer);
|
||||
else xx = 22;
|
||||
|
||||
screen.DrawText(IndexFont, Font.CR_GOLD, x+xx, y+20, buffer,
|
||||
DTA_KeepRatio, true,
|
||||
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, trans);
|
||||
}
|
||||
|
||||
x+=32;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(rover)
|
||||
{
|
||||
screen.DrawTexture(invgem_right, true, x-10, y,
|
||||
DTA_KeepRatio, true,
|
||||
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0.4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue