From 274727e8aedd6bd1292214d33cee06e979e05041 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Jan 2017 00:41:59 +0100 Subject: [PATCH] - 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. --- src/g_statusbar/sbar.h | 5 - src/g_statusbar/shared_sbar.cpp | 206 -------------------------------- src/g_statusbar/strife_sbar.cpp | 173 +++++++++++++++++++++++++++ 3 files changed, 173 insertions(+), 211 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index f50128fa8..cf17a5354 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -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; diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index c299eca38..81655d2ab 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -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); - } - } -} - //--------------------------------------------------------------------------- // diff --git a/src/g_statusbar/strife_sbar.cpp b/src/g_statusbar/strife_sbar.cpp index af06b7474..43624c2fa 100644 --- a/src/g_statusbar/strife_sbar.cpp +++ b/src/g_statusbar/strife_sbar.cpp @@ -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 ()