From c3c22c9453825ece34f4596f529b3defc4178a28 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 18 Apr 2006 06:07:09 +0000 Subject: [PATCH] - 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) --- docs/rh-log.txt | 7 ++++ src/c_console.cpp | 7 ++-- src/g_doom/doom_sbar.cpp | 60 +++++++++++++++++++-------------- src/g_shared/shared_sbar.cpp | 64 +++++++++++------------------------- 4 files changed, 65 insertions(+), 73 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index fb3833266..214ca006a 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -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) - 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 diff --git a/src/c_console.cpp b/src/c_console.cpp index 8f3047258..a86dd502a 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -712,13 +712,12 @@ extern BOOL gameisdead; int VPrintf (int printlevel, const char *format, va_list parms) { - char outline[8192]; - if (gameisdead) return 0; - vsprintf (outline, format, parms); - return PrintString (printlevel, outline); + string outline; + outline.VFormat (format, parms); + return PrintString (printlevel, outline.GetChars()); } int STACK_ARGS Printf (int printlevel, const char *format, ...) diff --git a/src/g_doom/doom_sbar.cpp b/src/g_doom/doom_sbar.cpp index 1af51b79f..6805ab186 100644 --- a/src/g_doom/doom_sbar.cpp +++ b/src/g_doom/doom_sbar.cpp @@ -39,7 +39,7 @@ public: FTexture *tex; FBaseStatusBar::Images.Init (sharedLumpNames, NUM_BASESB_IMAGES); - tex = FBaseStatusBar::Images[imgBNumbers+3]; + tex = FBaseStatusBar::Images[imgBNumbers]; BigWidth = tex->GetWidth(); BigHeight = tex->GetHeight(); @@ -257,7 +257,7 @@ private: if (FragsRefresh) { FragsRefresh--; - DrawNumber (OldFrags, 110, 3, 2); + DrawNumber (OldFrags, 138/*110*/, 3, 2); } } if (CPlayer->health != OldHealth) @@ -268,7 +268,7 @@ private: if (HealthRefresh) { HealthRefresh--; - DrawNumber (OldHealth, 48, 3); + DrawNumber (OldHealth, 90/*48*/, 3); } AInventory *armor = CPlayer->mo->FindInventory(); int armorpoints = armor != NULL ? armor->Amount : 0; @@ -280,7 +280,7 @@ private: if (ArmorRefresh) { ArmorRefresh--; - DrawNumber (OldArmor, 179, 3); + DrawNumber (OldArmor, 221/*179*/, 3); } if (CPlayer->ReadyWeapon != NULL) { @@ -301,7 +301,7 @@ private: ActiveAmmoRefresh--; if (OldActiveAmmo != -9999) { - DrawNumber (OldActiveAmmo, 2, 3); + DrawNumber (OldActiveAmmo, 44/*2*/, 3); } else { @@ -348,29 +348,32 @@ private: { ArmsRefresh[i]--; int x = 111 + i * 12; - DrawPartialImage (&StatusBarTex, x, 6); - - if (arms[i]) - { - DrawImage (FBaseStatusBar::Images[imgSmNumbers+2+i], x, 4); - } - else - { - DrawImage (Images[imgGNUM2+i], x, 4); - } - if (arms[i+3]) - { - DrawImage (FBaseStatusBar::Images[imgSmNumbers+2+i+3], x, 14); - } - else - { - DrawImage (Images[imgGNUM2+i+3], x, 14); - } + DrawArm (arms[i], i, x, 4, true); + DrawArm (arms[i+3], i+3, x, 14, false); } } } + void DrawArm (int on, int picnum, int x, int y, bool drawBackground) + { + int w; + FTexture *pic = on ? FBaseStatusBar::Images[imgSmNumbers + 2 + picnum] : Images[imgGNUM2 + picnum]; + + if (pic != NULL) + { + w = pic->GetWidth(); + x -= pic->LeftOffset; + y -= pic->TopOffset; + + if (drawBackground) + { + DrawPartialImage (&StatusBarTex, x, w); + } + DrawImage (pic, x, y); + } + } + void DrawAmmoStats () { static const char *const ammoTypes[4] = @@ -576,7 +579,7 @@ private: 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); } @@ -1026,6 +1029,7 @@ FDoomStatusBar::FDoomStatusBarTexture::FDoomStatusBarTexture () void FDoomStatusBar::FDoomStatusBarTexture::DrawToBar (const char *name, int x, int y, BYTE *colormap_in) { + FTexture *pic; BYTE colormap[256]; if (Pixels == NULL) @@ -1049,7 +1053,13 @@ void FDoomStatusBar::FDoomStatusBarTexture::DrawToBar (const char *name, int x, 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 () diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 43f6ec8de..1b681d989 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -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 { - int xpos; - int index; - int w, h; bool neg; - int i; + int i, w; int power; - FTexture *pic = Images[imgBNumbers+3]; + FTexture *pic; - if (pic != NULL) + pic = Images[imgBNumbers]; + w = (pic != NULL) ? pic->GetWidth() : 0; + + if (val == 0) { - w = pic->GetWidth (); - h = pic->GetHeight (); - } - else - { - w = h = 0; + if (pic != NULL) + { + DrawImage (pic, x - w, y); + } + return; } - xpos = x + w/2 + w*size; - + if ( (neg = val < 0) ) + { + val = -val; + size--; + } for (i = size-1, power = 10; i > 0; i--) { power *= 10; } - if (val >= power) { 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--) { - xpos -= w; - int oldval = val; + x -= w; + pic = Images[imgBNumbers + val % 10]; val /= 10; - index = imgBNumbers + (oldval - val*10); - pic = Images[index]; if (pic != NULL) { - DrawImage (pic, xpos - pic->GetWidth()/2, y); + DrawImage (pic, x, y); } } if (neg) { - xpos -= w; pic = Images[imgBNEGATIVE]; if (pic != NULL) { - DrawImage (pic, xpos - pic->GetWidth()/2, y); + DrawImage (pic, x - w, y); } } }