mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 16:51:31 +00:00
- Added A_SetCrosshair.
SVN r1700 (trunk)
This commit is contained in:
parent
9bf7c02194
commit
fe19767ac2
8 changed files with 84 additions and 39 deletions
|
@ -1,4 +1,5 @@
|
|||
June 30, 2009
|
||||
- Added A_SetCrosshair.
|
||||
- Added A_WeaponBob.
|
||||
- Dropped the Hexen player classes' JumpZ down to 9, since the original value
|
||||
now works as it originally did.
|
||||
|
|
|
@ -135,7 +135,6 @@ static const char *BaseFileSearch (const char *file, const char *ext, bool lookf
|
|||
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
||||
|
||||
EXTERN_CVAR (Float, turbo)
|
||||
EXTERN_CVAR (Int, crosshair)
|
||||
EXTERN_CVAR (Bool, freelook)
|
||||
EXTERN_CVAR (Float, m_pitch)
|
||||
EXTERN_CVAR (Float, m_yaw)
|
||||
|
@ -541,7 +540,7 @@ void D_Display ()
|
|||
// Refresh the console.
|
||||
C_NewModeAdjust ();
|
||||
// Reload crosshair if transitioned to a different size
|
||||
crosshair.Callback ();
|
||||
ST_LoadCrosshair (true);
|
||||
AM_NewResolution ();
|
||||
}
|
||||
}
|
||||
|
@ -1888,9 +1887,6 @@ void D_DoomMain (void)
|
|||
Printf ("Texman.Init: Init texture manager.\n");
|
||||
TexMan.Init();
|
||||
|
||||
// Now that all textues have been loaded the crosshair can be initialized.
|
||||
crosshair.Callback ();
|
||||
|
||||
// [CW] Parse any TEAMINFO lumps.
|
||||
Printf ("ParseTeamInfo: Load team definitions.\n");
|
||||
TeamLibrary.ParseTeamInfo ();
|
||||
|
|
|
@ -263,8 +263,9 @@ public:
|
|||
// In-inventory instance variables
|
||||
TObjPtr<AAmmo> Ammo1, Ammo2;
|
||||
TObjPtr<AWeapon> SisterWeapon;
|
||||
bool GivenAsMorphWeapon;
|
||||
float FOVScale;
|
||||
int Crosshair; // 0 to use player's crosshair
|
||||
bool GivenAsMorphWeapon;
|
||||
|
||||
bool bAltFire; // Set when this weapon's alternate fire is used.
|
||||
|
||||
|
|
|
@ -1721,3 +1721,20 @@ DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor)
|
|||
self->player->ReadyWeapon->FOVScale = zoom;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// A_SetCrosshair
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_SetCrosshair)
|
||||
{
|
||||
ACTION_PARAM_START(1);
|
||||
ACTION_PARAM_INT(xhair, 0);
|
||||
|
||||
if (self->player != NULL && self->player->ReadyWeapon != NULL)
|
||||
{
|
||||
self->player->ReadyWeapon->Crosshair = xhair;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -364,3 +364,8 @@ DBaseStatusBar *CreateHereticStatusBar();
|
|||
DBaseStatusBar *CreateHexenStatusBar();
|
||||
DBaseStatusBar *CreateStrifeStatusBar();
|
||||
DBaseStatusBar *CreateCustomStatusBar(int script=0);
|
||||
|
||||
// Crosshair stuff ----------------------------------------------------------
|
||||
|
||||
void ST_LoadCrosshair(bool alwaysload=false);
|
||||
extern FTexture *CrosshairImage;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "v_palette.h"
|
||||
|
||||
|
||||
extern FTexture *CrosshairImage;
|
||||
extern fixed_t globaluclip, globaldclip;
|
||||
|
||||
|
||||
|
|
|
@ -329,6 +329,8 @@ Actor Weapon : Inventory native
|
|||
action native A_ZoomFactor(float scale = 1, int flags = 0);
|
||||
const int ZOOM_INSTANT = 1;
|
||||
const int ZOOM_NOSCALETURNING = 2;
|
||||
|
||||
action native A_SetCrosshair(int xhair);
|
||||
}
|
||||
|
||||
ACTOR WeaponGiver : Weapon native
|
||||
|
|
Loading…
Reference in a new issue