- moved the draw functions which are exclusively used by the Strife status bar into strife_sbar.cpp to get them out of the way. They are not expected to survive anyway.

This commit is contained in:
Christoph Oelckers 2017-01-21 00:41:59 +01:00
parent 74f4171947
commit 274727e8ae
3 changed files with 173 additions and 211 deletions

View File

@ -388,11 +388,6 @@ protected:
void DrawImage (FTexture *image, int x, int y, FRemapTable *translation=NULL) const;
void DrawDimImage (FTexture *image, int x, int y, bool dimmed) const;
void DrINumber (signed int val, int x, int y, int imgBase=imgINumbers) const;
void DrINumberOuter (signed int val, int x, int y, bool center=false, int w=9) const;
void DrBNumberOuterFont (signed int val, int x, int y, int w=3) const;
void RefreshBackground () const;
void GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const;

View File

@ -576,212 +576,6 @@ void DBaseStatusBar::DrawDimImage (FTexture *img,
}
}
//---------------------------------------------------------------------------
//
// PROC DrINumber
//
// Draws a three digit number.
//
//---------------------------------------------------------------------------
void DBaseStatusBar::DrINumber (signed int val, int x, int y, int imgBase) const
{
int oldval;
if (val > 999)
val = 999;
oldval = val;
if (val < 0)
{
if (val < -9)
{
DrawImage (Images[imgLAME], x+1, y+1);
return;
}
val = -val;
DrawImage (Images[imgBase+val], x+18, y);
DrawImage (Images[imgNEGATIVE], x+9, y);
return;
}
if (val > 99)
{
DrawImage (Images[imgBase+val/100], x, y);
}
val = val % 100;
if (val > 9 || oldval > 99)
{
DrawImage (Images[imgBase+val/10], x+9, y);
}
val = val % 10;
DrawImage (Images[imgBase+val], x+18, y);
}
//---------------------------------------------------------------------------
//
// PROC DrINumberOuter
//
// Draws a number outside the status bar, possibly scaled.
//
//---------------------------------------------------------------------------
void DBaseStatusBar::DrINumberOuter (signed int val, int x, int y, bool center, int w) const
{
bool negative = false;
x += w*2;
if (val < 0)
{
negative = true;
val = -val;
}
else if (val == 0)
{
screen->DrawTexture (Images[imgINumbers], x + 1, y + 1,
DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
screen->DrawTexture (Images[imgINumbers], x, y,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
return;
}
int oval = val;
int ox = x;
// First the shadow
while (val != 0)
{
screen->DrawTexture (Images[imgINumbers + val % 10], x + 1, y + 1,
DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
x -= w;
val /= 10;
}
if (negative)
{
screen->DrawTexture (Images[imgNEGATIVE], x + 1, y + 1,
DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
}
// Then the real deal
val = oval;
x = ox;
while (val != 0)
{
screen->DrawTexture (Images[imgINumbers + val % 10], x, y,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
x -= w;
val /= 10;
}
if (negative)
{
screen->DrawTexture (Images[imgNEGATIVE], x, y,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
}
}
//---------------------------------------------------------------------------
//
// PROC DrBNumberOuter
//
// Draws a three digit number using the real big font outside the status bar.
//
//---------------------------------------------------------------------------
void DBaseStatusBar::DrBNumberOuterFont (signed int val, int x, int y, int size) const
{
int xpos;
int w, v;
bool negative = false;
FTexture *pic;
w = 0;
BigFont->GetChar ('0', &w);
if (w > 1)
{
w--;
}
xpos = x + w/2 + (size-1)*w;
if (val == 0)
{
pic = BigFont->GetChar ('0', &v);
screen->DrawTexture (pic, xpos - v/2 + 2, y + 2,
DTA_HUDRules, HUD_Normal,
DTA_AlphaF, HR_SHADOW,
DTA_FillColor, 0,
DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED),
TAG_DONE);
screen->DrawTexture (pic, xpos - v/2, y,
DTA_HUDRules, HUD_Normal,
DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED),
TAG_DONE);
return;
}
else if (val < 0)
{
negative = true;
val = -val;
}
int oval = val;
int oxpos = xpos;
// First the shadow
while (val != 0)
{
pic = BigFont->GetChar ('0' + val % 10, &v);
screen->DrawTexture (pic, xpos - v/2 + 2, y + 2,
DTA_HUDRules, HUD_Normal,
DTA_AlphaF, HR_SHADOW,
DTA_FillColor, 0,
DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED),
TAG_DONE);
val /= 10;
xpos -= w;
}
if (negative)
{
pic = BigFont->GetChar ('-', &v);
if (pic != NULL)
{
screen->DrawTexture (pic, xpos - v/2 + 2, y + 2,
DTA_HUDRules, HUD_Normal,
DTA_AlphaF, HR_SHADOW,
DTA_FillColor, 0,
DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED),
TAG_DONE);
}
}
// Then the foreground number
val = oval;
xpos = oxpos;
while (val != 0)
{
pic = BigFont->GetChar ('0' + val % 10, &v);
screen->DrawTexture (pic, xpos - v/2, y,
DTA_HUDRules, HUD_Normal,
DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED),
TAG_DONE);
val /= 10;
xpos -= w;
}
if (negative)
{
pic = BigFont->GetChar ('-', &v);
if (pic != NULL)
{
screen->DrawTexture (pic, xpos - v/2, y,
DTA_HUDRules, HUD_Normal,
DTA_Translation, BigFont->GetColorTranslation (CR_UNTRANSLATED),
TAG_DONE);
}
}
}
//---------------------------------------------------------------------------
//

View File

@ -845,8 +845,181 @@ private:
int CurrentPop, PendingPop, PopHeight, PopHeightChange;
int KeyPopPos, KeyPopScroll;
double ItemFlash;
void DrINumberOuter(signed int val, int x, int y, bool center = false, int w = 9) const;
void DrBNumberOuterFont(signed int val, int x, int y, int w = 3) const;
};
//---------------------------------------------------------------------------
//
// PROC DrINumberOuter
//
// Draws a number outside the status bar, possibly scaled.
//
//---------------------------------------------------------------------------
void DStrifeStatusBar::DrINumberOuter(signed int val, int x, int y, bool center, int w) const
{
bool negative = false;
x += w * 2;
if (val < 0)
{
negative = true;
val = -val;
}
else if (val == 0)
{
screen->DrawTexture(Images[imgINumbers], x + 1, y + 1,
DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
screen->DrawTexture(Images[imgINumbers], x, y,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
return;
}
int oval = val;
int ox = x;
// First the shadow
while (val != 0)
{
screen->DrawTexture(Images[imgINumbers + val % 10], x + 1, y + 1,
DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
x -= w;
val /= 10;
}
if (negative)
{
screen->DrawTexture(Images[imgNEGATIVE], x + 1, y + 1,
DTA_FillColor, 0, DTA_AlphaF, HR_SHADOW,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
}
// Then the real deal
val = oval;
x = ox;
while (val != 0)
{
screen->DrawTexture(Images[imgINumbers + val % 10], x, y,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
x -= w;
val /= 10;
}
if (negative)
{
screen->DrawTexture(Images[imgNEGATIVE], x, y,
DTA_HUDRules, center ? HUD_HorizCenter : HUD_Normal, TAG_DONE);
}
}
//---------------------------------------------------------------------------
//
// PROC DrBNumberOuter
//
// Draws a three digit number using the real big font outside the status bar.
//
//---------------------------------------------------------------------------
void DStrifeStatusBar::DrBNumberOuterFont(signed int val, int x, int y, int size) const
{
int xpos;
int w, v;
bool negative = false;
FTexture *pic;
w = 0;
BigFont->GetChar('0', &w);
if (w > 1)
{
w--;
}
xpos = x + w / 2 + (size - 1)*w;
if (val == 0)
{
pic = BigFont->GetChar('0', &v);
screen->DrawTexture(pic, xpos - v / 2 + 2, y + 2,
DTA_HUDRules, HUD_Normal,
DTA_AlphaF, HR_SHADOW,
DTA_FillColor, 0,
DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED),
TAG_DONE);
screen->DrawTexture(pic, xpos - v / 2, y,
DTA_HUDRules, HUD_Normal,
DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED),
TAG_DONE);
return;
}
else if (val < 0)
{
negative = true;
val = -val;
}
int oval = val;
int oxpos = xpos;
// First the shadow
while (val != 0)
{
pic = BigFont->GetChar('0' + val % 10, &v);
screen->DrawTexture(pic, xpos - v / 2 + 2, y + 2,
DTA_HUDRules, HUD_Normal,
DTA_AlphaF, HR_SHADOW,
DTA_FillColor, 0,
DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED),
TAG_DONE);
val /= 10;
xpos -= w;
}
if (negative)
{
pic = BigFont->GetChar('-', &v);
if (pic != NULL)
{
screen->DrawTexture(pic, xpos - v / 2 + 2, y + 2,
DTA_HUDRules, HUD_Normal,
DTA_AlphaF, HR_SHADOW,
DTA_FillColor, 0,
DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED),
TAG_DONE);
}
}
// Then the foreground number
val = oval;
xpos = oxpos;
while (val != 0)
{
pic = BigFont->GetChar('0' + val % 10, &v);
screen->DrawTexture(pic, xpos - v / 2, y,
DTA_HUDRules, HUD_Normal,
DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED),
TAG_DONE);
val /= 10;
xpos -= w;
}
if (negative)
{
pic = BigFont->GetChar('-', &v);
if (pic != NULL)
{
screen->DrawTexture(pic, xpos - v / 2, y,
DTA_HUDRules, HUD_Normal,
DTA_Translation, BigFont->GetColorTranslation(CR_UNTRANSLATED),
TAG_DONE);
}
}
}
IMPLEMENT_CLASS(DStrifeStatusBar, false, false);
DBaseStatusBar *CreateStrifeStatusBar ()