- Fixed: FBaseStatusBar::DrBNumber() should behave like Doom's

STlib_drawNum(), and FDoomStatusBarTexture::DrawToBar() should add
  the textures left offset to the x coordinate before drawing.
  These fix Twice Risen's status bar.
- Changed: VPrintf now uses string.VFormat(), instead of vsprintf().


SVN r53 (trunk)
This commit is contained in:
Randy Heit 2006-04-18 06:07:09 +00:00
parent d8500150f3
commit c3c22c9453
4 changed files with 65 additions and 73 deletions

View file

@ -1,3 +1,10 @@
April 18, 2006
- Fixed: FBaseStatusBar::DrBNumber() should behave like Doom's
STlib_drawNum(), and FDoomStatusBarTexture::DrawToBar() should add
the textures left offset to the x coordinate before drawing.
These fix Twice Risen's status bar.
- Changed: VPrintf now uses string.VFormat(), instead of vsprintf().
April 17, 2006 (Changes by Graf Zahl) April 17, 2006 (Changes by Graf Zahl)
- Fixed: The Oracle Pass is an item, not a key. Strictly speaking the - Fixed: The Oracle Pass is an item, not a key. Strictly speaking the
same applies to the Prison pass but having that as a key masks same applies to the Prison pass but having that as a key masks

View file

@ -712,13 +712,12 @@ extern BOOL gameisdead;
int VPrintf (int printlevel, const char *format, va_list parms) int VPrintf (int printlevel, const char *format, va_list parms)
{ {
char outline[8192];
if (gameisdead) if (gameisdead)
return 0; return 0;
vsprintf (outline, format, parms); string outline;
return PrintString (printlevel, outline); outline.VFormat (format, parms);
return PrintString (printlevel, outline.GetChars());
} }
int STACK_ARGS Printf (int printlevel, const char *format, ...) int STACK_ARGS Printf (int printlevel, const char *format, ...)

View file

@ -39,7 +39,7 @@ public:
FTexture *tex; FTexture *tex;
FBaseStatusBar::Images.Init (sharedLumpNames, NUM_BASESB_IMAGES); FBaseStatusBar::Images.Init (sharedLumpNames, NUM_BASESB_IMAGES);
tex = FBaseStatusBar::Images[imgBNumbers+3]; tex = FBaseStatusBar::Images[imgBNumbers];
BigWidth = tex->GetWidth(); BigWidth = tex->GetWidth();
BigHeight = tex->GetHeight(); BigHeight = tex->GetHeight();
@ -257,7 +257,7 @@ private:
if (FragsRefresh) if (FragsRefresh)
{ {
FragsRefresh--; FragsRefresh--;
DrawNumber (OldFrags, 110, 3, 2); DrawNumber (OldFrags, 138/*110*/, 3, 2);
} }
} }
if (CPlayer->health != OldHealth) if (CPlayer->health != OldHealth)
@ -268,7 +268,7 @@ private:
if (HealthRefresh) if (HealthRefresh)
{ {
HealthRefresh--; HealthRefresh--;
DrawNumber (OldHealth, 48, 3); DrawNumber (OldHealth, 90/*48*/, 3);
} }
AInventory *armor = CPlayer->mo->FindInventory<ABasicArmor>(); AInventory *armor = CPlayer->mo->FindInventory<ABasicArmor>();
int armorpoints = armor != NULL ? armor->Amount : 0; int armorpoints = armor != NULL ? armor->Amount : 0;
@ -280,7 +280,7 @@ private:
if (ArmorRefresh) if (ArmorRefresh)
{ {
ArmorRefresh--; ArmorRefresh--;
DrawNumber (OldArmor, 179, 3); DrawNumber (OldArmor, 221/*179*/, 3);
} }
if (CPlayer->ReadyWeapon != NULL) if (CPlayer->ReadyWeapon != NULL)
{ {
@ -301,7 +301,7 @@ private:
ActiveAmmoRefresh--; ActiveAmmoRefresh--;
if (OldActiveAmmo != -9999) if (OldActiveAmmo != -9999)
{ {
DrawNumber (OldActiveAmmo, 2, 3); DrawNumber (OldActiveAmmo, 44/*2*/, 3);
} }
else else
{ {
@ -348,26 +348,29 @@ private:
{ {
ArmsRefresh[i]--; ArmsRefresh[i]--;
int x = 111 + i * 12; int x = 111 + i * 12;
DrawPartialImage (&StatusBarTex, x, 6);
DrawArm (arms[i], i, x, 4, true);
DrawArm (arms[i+3], i+3, x, 14, false);
}
}
}
if (arms[i]) void DrawArm (int on, int picnum, int x, int y, bool drawBackground)
{ {
DrawImage (FBaseStatusBar::Images[imgSmNumbers+2+i], x, 4); int w;
} FTexture *pic = on ? FBaseStatusBar::Images[imgSmNumbers + 2 + picnum] : Images[imgGNUM2 + picnum];
else
if (pic != NULL)
{ {
DrawImage (Images[imgGNUM2+i], x, 4); w = pic->GetWidth();
} x -= pic->LeftOffset;
if (arms[i+3]) y -= pic->TopOffset;
if (drawBackground)
{ {
DrawImage (FBaseStatusBar::Images[imgSmNumbers+2+i+3], x, 14); DrawPartialImage (&StatusBarTex, x, w);
}
else
{
DrawImage (Images[imgGNUM2+i+3], x, 14);
}
} }
DrawImage (pic, x, y);
} }
} }
@ -576,7 +579,7 @@ private:
void DrawNumber (int val, int x, int y, int size=3) void DrawNumber (int val, int x, int y, int size=3)
{ {
DrawPartialImage (&StatusBarTex, x-1, size*BigWidth+2); DrawPartialImage (&StatusBarTex, x-BigWidth*size, size*BigWidth);
DrBNumber (val, x, y, size); DrBNumber (val, x, y, size);
} }
@ -1026,6 +1029,7 @@ FDoomStatusBar::FDoomStatusBarTexture::FDoomStatusBarTexture ()
void FDoomStatusBar::FDoomStatusBarTexture::DrawToBar (const char *name, int x, int y, BYTE *colormap_in) void FDoomStatusBar::FDoomStatusBarTexture::DrawToBar (const char *name, int x, int y, BYTE *colormap_in)
{ {
FTexture *pic;
BYTE colormap[256]; BYTE colormap[256];
if (Pixels == NULL) if (Pixels == NULL)
@ -1049,7 +1053,13 @@ void FDoomStatusBar::FDoomStatusBarTexture::DrawToBar (const char *name, int x,
colormap[255] = Near255; colormap[255] = Near255;
} }
TexMan[name]->CopyToBlock (Pixels, Width, Height, x, y, colormap); pic = TexMan[name];
if (pic != NULL)
{
pic->GetWidth();
x -= pic->LeftOffset;
pic->CopyToBlock (Pixels, Width, Height, x, y, colormap);
}
} }
FBaseStatusBar *CreateDoomStatusBar () FBaseStatusBar *CreateDoomStatusBar ()

View file

@ -513,76 +513,52 @@ void FBaseStatusBar::DrINumber (signed int val, int x, int y, int imgBase) const
void FBaseStatusBar::DrBNumber (signed int val, int x, int y, int size) const void FBaseStatusBar::DrBNumber (signed int val, int x, int y, int size) const
{ {
int xpos;
int index;
int w, h;
bool neg; bool neg;
int i; int i, w;
int power; int power;
FTexture *pic = Images[imgBNumbers+3]; FTexture *pic;
pic = Images[imgBNumbers];
w = (pic != NULL) ? pic->GetWidth() : 0;
if (val == 0)
{
if (pic != NULL) if (pic != NULL)
{ {
w = pic->GetWidth (); DrawImage (pic, x - w, y);
h = pic->GetHeight ();
} }
else return;
}
if ( (neg = val < 0) )
{ {
w = h = 0; val = -val;
size--;
} }
xpos = x + w/2 + w*size;
for (i = size-1, power = 10; i > 0; i--) for (i = size-1, power = 10; i > 0; i--)
{ {
power *= 10; power *= 10;
} }
if (val >= power) if (val >= power)
{ {
val = power - 1; val = power - 1;
} }
if ( (neg = val < 0) )
{
if (size == 2 && val < -9)
{
val = -9;
}
else if (size == 3 && val < -99)
{
val = -99;
}
val = -val;
size--;
}
if (val == 0)
{
pic = Images[imgBNumbers];
if (pic != NULL)
{
DrawImage (pic, xpos - pic->GetWidth()/2 - w, y);
}
return;
}
while (val != 0 && size--) while (val != 0 && size--)
{ {
xpos -= w; x -= w;
int oldval = val; pic = Images[imgBNumbers + val % 10];
val /= 10; val /= 10;
index = imgBNumbers + (oldval - val*10);
pic = Images[index];
if (pic != NULL) if (pic != NULL)
{ {
DrawImage (pic, xpos - pic->GetWidth()/2, y); DrawImage (pic, x, y);
} }
} }
if (neg) if (neg)
{ {
xpos -= w;
pic = Images[imgBNEGATIVE]; pic = Images[imgBNEGATIVE];
if (pic != NULL) if (pic != NULL)
{ {
DrawImage (pic, xpos - pic->GetWidth()/2, y); DrawImage (pic, x - w, y);
} }
} }
} }