- scriptified the main statusbar interface and the Strife status bar.
Note that the Strife status bar does not draw the health bars yet. I tried to replace the hacky custom texture with a single fill operation but had to find out that all the coordinate mangling for the status bar is being done deep in the video code. This needs to be fixed before this can be made to work. Currently this is not usable in mods because they cannot initialize custom status bars yet.
This commit is contained in:
parent
4110f34139
commit
9bffe4ee50
29 changed files with 1184 additions and 1167 deletions
|
|
@ -87,7 +87,6 @@ DBaseStatusBar *StatusBar;
|
|||
extern int setblocks;
|
||||
|
||||
int gST_X, gST_Y;
|
||||
int SB_state = 3;
|
||||
|
||||
FTexture *CrosshairImage;
|
||||
static int CrosshairNum;
|
||||
|
|
@ -107,7 +106,7 @@ CUSTOM_CVAR (Bool, st_scale, true, CVAR_ARCHIVE)
|
|||
{
|
||||
if (StatusBar)
|
||||
{
|
||||
StatusBar->SetScaled (self);
|
||||
StatusBar->CallSetScaled (self);
|
||||
setsizeneeded = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -219,17 +218,6 @@ void ST_Clear()
|
|||
CrosshairNum = 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// ST_SetNeedRefresh
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void ST_SetNeedRefresh()
|
||||
{
|
||||
SB_state = (StatusBar == NULL || screen == NULL) ? 0 : screen->GetPageCount();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Constructor
|
||||
|
|
@ -250,7 +238,7 @@ DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres)
|
|||
HorizontalResolution = hres;
|
||||
VerticalResolution = vres;
|
||||
|
||||
SetScaled (st_scale);
|
||||
CallSetScaled (st_scale);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
@ -319,7 +307,25 @@ void DBaseStatusBar::SetScaled (bool scale, bool force)
|
|||
Displacement = 0;
|
||||
}
|
||||
gST_X = ST_X;
|
||||
ST_SetNeedRefresh();
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, SetScaled)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
PARAM_BOOL(scale);
|
||||
PARAM_BOOL_DEF(force);
|
||||
self->SetScaled(scale, force);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DBaseStatusBar::CallSetScaled(bool scale, bool force)
|
||||
{
|
||||
IFVIRTUAL(DBaseStatusBar, SetScaled)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this, scale, force };
|
||||
GlobalVMStack.Call(func, params, countof(params), nullptr, 0);
|
||||
}
|
||||
else SetScaled(scale, force);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
@ -331,7 +337,24 @@ void DBaseStatusBar::SetScaled (bool scale, bool force)
|
|||
void DBaseStatusBar::AttachToPlayer (player_t *player)
|
||||
{
|
||||
CPlayer = player;
|
||||
ST_SetNeedRefresh();
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, AttachToPlayer)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
PARAM_POINTER(player, player_t);
|
||||
self->AttachToPlayer(player);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DBaseStatusBar::CallAttachToPlayer(player_t *player)
|
||||
{
|
||||
IFVIRTUAL(DBaseStatusBar, AttachToPlayer)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this, player };
|
||||
GlobalVMStack.Call(func, params, countof(params), nullptr, 0);
|
||||
}
|
||||
else AttachToPlayer(player);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
@ -345,17 +368,6 @@ int DBaseStatusBar::GetPlayer ()
|
|||
return int(CPlayer - players);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC MultiplayerChanged
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DBaseStatusBar::MultiplayerChanged ()
|
||||
{
|
||||
ST_SetNeedRefresh();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC Tick
|
||||
|
|
@ -397,6 +409,23 @@ void DBaseStatusBar::Tick ()
|
|||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, Tick)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
self->Tick();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DBaseStatusBar::CallTick()
|
||||
{
|
||||
IFVIRTUAL(DBaseStatusBar, Tick)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this };
|
||||
GlobalVMStack.Call(func, params, countof(params), nullptr, 0);
|
||||
}
|
||||
else Tick();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC AttachMessage
|
||||
|
|
@ -460,11 +489,6 @@ DHUDMessage *DBaseStatusBar::DetachMessage (DHUDMessage *msg)
|
|||
{
|
||||
*prev = probe->Next;
|
||||
probe->Next = NULL;
|
||||
// Redraw the status bar in case it was covered
|
||||
if (screen != NULL)
|
||||
{
|
||||
ST_SetNeedRefresh();
|
||||
}
|
||||
return probe;
|
||||
}
|
||||
}
|
||||
|
|
@ -487,11 +511,6 @@ DHUDMessage *DBaseStatusBar::DetachMessage (uint32_t id)
|
|||
{
|
||||
*prev = probe->Next;
|
||||
probe->Next = NULL;
|
||||
// Redraw the status bar in case it was covered
|
||||
if (screen != NULL)
|
||||
{
|
||||
ST_SetNeedRefresh();
|
||||
}
|
||||
return probe;
|
||||
}
|
||||
}
|
||||
|
|
@ -589,6 +608,13 @@ void DBaseStatusBar::RefreshBackground () const
|
|||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, RefreshBackground)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
self->RefreshBackground();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// DrawCrosshair
|
||||
|
|
@ -734,7 +760,7 @@ void DBaseStatusBar::Draw (EHudState state)
|
|||
|
||||
char line[64+10];
|
||||
|
||||
if ((SB_state != 0 || BorderNeedRefresh) && state == HUD_StatusBar)
|
||||
if (state == HUD_StatusBar)
|
||||
{
|
||||
RefreshBackground ();
|
||||
}
|
||||
|
|
@ -902,6 +928,25 @@ void DBaseStatusBar::Draw (EHudState state)
|
|||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, Draw)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
PARAM_INT(state);
|
||||
self->Draw((EHudState)state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DBaseStatusBar::CallDraw(EHudState state)
|
||||
{
|
||||
IFVIRTUAL(DBaseStatusBar, Draw)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this, state, r_viewpoint.TicFrac };
|
||||
GlobalVMStack.Call(func, params, countof(params), nullptr, 0);
|
||||
}
|
||||
else Draw(state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DBaseStatusBar::DrawLog ()
|
||||
{
|
||||
|
|
@ -959,8 +1004,16 @@ void DBaseStatusBar::DrawLog ()
|
|||
}
|
||||
}
|
||||
|
||||
bool DBaseStatusBar::MustDrawLog(EHudState)
|
||||
bool DBaseStatusBar::MustDrawLog(EHudState state)
|
||||
{
|
||||
IFVIRTUAL(DBaseStatusBar, MustDrawLog)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this };
|
||||
int rv;
|
||||
VMReturn ret(&rv);
|
||||
GlobalVMStack.Call(func, params, countof(params), &ret, 1);
|
||||
return !!rv;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1154,14 +1207,20 @@ void DBaseStatusBar::DrawWaiting () const
|
|||
|
||||
void DBaseStatusBar::FlashItem (const PClass *itemtype)
|
||||
{
|
||||
IFVIRTUAL(DBaseStatusBar, FlashItem)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this, (PClass*)itemtype };
|
||||
GlobalVMStack.Call(func, params, countof(params), nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DBaseStatusBar::NewGame ()
|
||||
{
|
||||
}
|
||||
|
||||
void DBaseStatusBar::SetInteger (int pname, int param)
|
||||
{
|
||||
IFVIRTUAL(DBaseStatusBar, NewGame)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this };
|
||||
GlobalVMStack.Call(func, params, countof(params), nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DBaseStatusBar::ShowPop (int popnum)
|
||||
|
|
@ -1169,15 +1228,35 @@ void DBaseStatusBar::ShowPop (int popnum)
|
|||
ShowLog = (popnum == POP_Log && !ShowLog);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, ShowPop)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
PARAM_INT(state);
|
||||
self->ShowPop(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DBaseStatusBar::CallShowPop(int pop)
|
||||
{
|
||||
IFVIRTUAL(DBaseStatusBar, ShowPop)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this, pop };
|
||||
GlobalVMStack.Call(func, params, countof(params), nullptr, 0);
|
||||
}
|
||||
else ShowPop(pop);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DBaseStatusBar::ReceivedWeapon (AWeapon *weapon)
|
||||
{
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_StatusBar, ReceivedWeapon)
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, ReceivedWeapon)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
PARAM_POINTER(w, AWeapon);
|
||||
StatusBar->ReceivedWeapon(w);
|
||||
self->ReceivedWeapon(w);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1190,7 +1269,6 @@ void DBaseStatusBar::SerializeMessages(FSerializer &arc)
|
|||
void DBaseStatusBar::ScreenSizeChanged ()
|
||||
{
|
||||
st_scale.Callback ();
|
||||
ST_SetNeedRefresh();
|
||||
|
||||
for (size_t i = 0; i < countof(Messages); ++i)
|
||||
{
|
||||
|
|
@ -1203,6 +1281,23 @@ void DBaseStatusBar::ScreenSizeChanged ()
|
|||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, ScreenSizeChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
self->ScreenSizeChanged();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DBaseStatusBar::CallScreenSizeChanged()
|
||||
{
|
||||
IFVIRTUAL(DBaseStatusBar, ScreenSizeChanged)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this };
|
||||
GlobalVMStack.Call(func, params, countof(params), nullptr, 0);
|
||||
}
|
||||
else ScreenSizeChanged();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// ValidateInvFirst
|
||||
|
|
@ -1294,6 +1389,14 @@ AInventory *DBaseStatusBar::ValidateInvFirst (int numVisible) const
|
|||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, ValidateInvFirst)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
PARAM_INT(num);
|
||||
ACTION_RETURN_POINTER(self->ValidateInvFirst(num));
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// DBaseStatusBar :: GetCurrentAmmo
|
||||
|
|
@ -1323,6 +1426,20 @@ void DBaseStatusBar::GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int
|
|||
ammocount2 = ammo2 != NULL ? ammo2->Amount : 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, GetCurrentAmmo)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
AInventory *ammo1, *ammo2;
|
||||
int ammocount1, ammocount2;
|
||||
self->GetCurrentAmmo(ammo1, ammo2, ammocount1, ammocount2);
|
||||
if (numret >= 1) ret[0].SetPointer(ammo1, ATAG_OBJECT);
|
||||
if (numret >= 2) ret[1].SetPointer(ammo2, ATAG_OBJECT);
|
||||
if (numret >= 3) ret[2].SetInt(ammocount1);
|
||||
if (numret >= 4) ret[3].SetInt(ammocount2);
|
||||
return MIN(numret, 4);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// CCMD showpop
|
||||
|
|
@ -1344,6 +1461,32 @@ CCMD (showpop)
|
|||
{
|
||||
popnum = 0;
|
||||
}
|
||||
StatusBar->ShowPop (popnum);
|
||||
StatusBar->CallShowPop (popnum);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_FIELD(DBaseStatusBar, ST_X);
|
||||
DEFINE_FIELD(DBaseStatusBar, ST_Y);
|
||||
DEFINE_FIELD(DBaseStatusBar, RelTop);
|
||||
DEFINE_FIELD(DBaseStatusBar, HorizontalResolution);
|
||||
DEFINE_FIELD(DBaseStatusBar, VerticalResolution);
|
||||
DEFINE_FIELD(DBaseStatusBar, Scaled);
|
||||
DEFINE_FIELD(DBaseStatusBar, Centering);
|
||||
DEFINE_FIELD(DBaseStatusBar, FixedOrigin);
|
||||
DEFINE_FIELD(DBaseStatusBar, CompleteBorder);
|
||||
DEFINE_FIELD(DBaseStatusBar, CrosshairSize);
|
||||
DEFINE_FIELD(DBaseStatusBar, Displacement);
|
||||
DEFINE_FIELD(DBaseStatusBar, CPlayer);
|
||||
DEFINE_GLOBAL(StatusBar);
|
||||
|
||||
|
||||
DBaseStatusBar *CreateStrifeStatusBar()
|
||||
{
|
||||
auto sb = (DBaseStatusBar *)PClass::FindClass("StrifeStatusBar")->CreateNew();
|
||||
IFVIRTUALPTR(sb, DBaseStatusBar, Init)
|
||||
{
|
||||
VMValue params[] = { sb };
|
||||
GlobalVMStack.Call(func, params, 1, nullptr, 0);
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue