- Added A_SetCrosshair.
SVN r1700 (trunk)
This commit is contained in:
parent
9bf7c02194
commit
fe19767ac2
8 changed files with 75 additions and 30 deletions
|
|
@ -79,6 +79,7 @@ int ST_X, ST_Y;
|
|||
int SB_state = 3;
|
||||
|
||||
FTexture *CrosshairImage;
|
||||
static int CrosshairNum;
|
||||
|
||||
// [RH] Base blending values (for e.g. underwater)
|
||||
int BaseBlendR, BaseBlendG, BaseBlendB;
|
||||
|
|
@ -94,38 +95,8 @@ CUSTOM_CVAR (Bool, st_scale, true, CVAR_ARCHIVE)
|
|||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR (Int, crosshair, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
|
||||
{
|
||||
int num = self;
|
||||
char name[16], size;
|
||||
int lump;
|
||||
|
||||
if (CrosshairImage != NULL)
|
||||
{
|
||||
CrosshairImage->Unload ();
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
CrosshairImage = NULL;
|
||||
return;
|
||||
}
|
||||
if (num < 0)
|
||||
{
|
||||
num = -num;
|
||||
}
|
||||
size = (SCREENWIDTH < 640) ? 'S' : 'B';
|
||||
mysnprintf (name, countof(name), "XHAIR%c%d", size, num);
|
||||
if ((lump = Wads.CheckNumForName (name, ns_graphics)) == -1)
|
||||
{
|
||||
mysnprintf (name, countof(name), "XHAIR%c1", size);
|
||||
if ((lump = Wads.CheckNumForName (name, ns_graphics)) == -1)
|
||||
{
|
||||
strcpy (name, "XHAIRS1");
|
||||
}
|
||||
}
|
||||
CrosshairImage = TexMan[TexMan.CheckForTexture(name, FTexture::TEX_MiscPatch)];
|
||||
}
|
||||
|
||||
CVAR (Int, crosshair, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Bool, crosshairforce, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Color, crosshaircolor, 0xff0000, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
CVAR (Bool, crosshairhealth, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
CVAR (Bool, crosshairscale, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
|
|
@ -147,6 +118,57 @@ BYTE DBaseStatusBar::DamageToAlpha[114] =
|
|||
230, 231, 232, 233, 234, 235, 235, 236, 237
|
||||
};
|
||||
|
||||
void ST_LoadCrosshair(bool alwaysload)
|
||||
{
|
||||
int num = 0;
|
||||
char name[16], size;
|
||||
int lump;
|
||||
|
||||
if (!crosshairforce &&
|
||||
players[consoleplayer].camera != NULL &&
|
||||
players[consoleplayer].camera->player != NULL &&
|
||||
players[consoleplayer].camera->player->ReadyWeapon != NULL)
|
||||
{
|
||||
num = players[consoleplayer].camera->player->ReadyWeapon->Crosshair;
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
num = crosshair;
|
||||
}
|
||||
if (!alwaysload && CrosshairNum == num && CrosshairImage != NULL)
|
||||
{ // No change.
|
||||
return;
|
||||
}
|
||||
|
||||
if (CrosshairImage != NULL)
|
||||
{
|
||||
CrosshairImage->Unload ();
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
CrosshairNum = 0;
|
||||
CrosshairImage = NULL;
|
||||
return;
|
||||
}
|
||||
if (num < 0)
|
||||
{
|
||||
num = -num;
|
||||
}
|
||||
size = (SCREENWIDTH < 640) ? 'S' : 'B';
|
||||
mysnprintf (name, countof(name), "XHAIR%c%d", size, num);
|
||||
if ((lump = Wads.CheckNumForName (name, ns_graphics)) == -1)
|
||||
{
|
||||
mysnprintf (name, countof(name), "XHAIR%c1", size);
|
||||
if ((lump = Wads.CheckNumForName (name, ns_graphics)) == -1)
|
||||
{
|
||||
strcpy (name, "XHAIRS1");
|
||||
}
|
||||
num = 1;
|
||||
}
|
||||
CrosshairNum = num;
|
||||
CrosshairImage = TexMan[TexMan.CheckForTexture(name, FTexture::TEX_MiscPatch)];
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Constructor
|
||||
|
|
@ -1009,6 +1031,8 @@ void DBaseStatusBar::DrawCrosshair ()
|
|||
if (players[consoleplayer].cheats & CF_CHASECAM)
|
||||
return;
|
||||
|
||||
ST_LoadCrosshair();
|
||||
|
||||
// Don't draw the crosshair if there is none
|
||||
if (CrosshairImage == NULL || gamestate == GS_TITLELEVEL)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue