diff --git a/source/common/2d/v_drawtext.cpp b/source/common/2d/v_drawtext.cpp index 5c06457b4..9a778eb13 100644 --- a/source/common/2d/v_drawtext.cpp +++ b/source/common/2d/v_drawtext.cpp @@ -186,8 +186,9 @@ void DrawChar(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double { return; } + bool palettetrans = (normalcolor == CR_UNDEFINED && parms.TranslationId != 0); PalEntry color = 0xffffffff; - parms.TranslationId = redirected ? -1 : font->GetColorTranslation((EColorRange)normalcolor, &color); + if (!palettetrans) parms.TranslationId = redirected ? -1 : font->GetColorTranslation((EColorRange)normalcolor, &color); parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); drawer->AddTexture(pic, parms); } @@ -211,8 +212,9 @@ void DrawChar(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double uint32_t tag = ListGetInt(args); bool res = ParseDrawTextureTags(drawer, pic, x, y, tag, args, &parms, false); if (!res) return; + bool palettetrans = (normalcolor == CR_UNDEFINED && parms.TranslationId != 0); PalEntry color = 0xffffffff; - parms.TranslationId = redirected ? -1 : font->GetColorTranslation((EColorRange)normalcolor, &color); + if (!palettetrans) parms.TranslationId = redirected ? -1 : font->GetColorTranslation((EColorRange)normalcolor, &color); parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); drawer->AddTexture(pic, parms); } diff --git a/source/common/scripting/interface/vmnatives.cpp b/source/common/scripting/interface/vmnatives.cpp index 3f34c3b2a..502d78de3 100644 --- a/source/common/scripting/interface/vmnatives.cpp +++ b/source/common/scripting/interface/vmnatives.cpp @@ -124,7 +124,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImage, SBar_DrawImage) return 0; } -void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY); +void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int translation); DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawString, SBar_DrawString) { @@ -140,7 +140,8 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawString, SBar_DrawString) PARAM_INT(linespacing); PARAM_FLOAT(scaleX); PARAM_FLOAT(scaleY); - SBar_DrawString(self, font, string, x, y, flags, trans, alpha, wrapwidth, linespacing, scaleX, scaleY); + PARAM_INT(pt); + SBar_DrawString(self, font, string, x, y, flags, trans, alpha, wrapwidth, linespacing, scaleX, scaleY, pt); return 0; } diff --git a/source/common/statusbar/base_sbar.cpp b/source/common/statusbar/base_sbar.cpp index 331ea4096..18cbe778c 100644 --- a/source/common/statusbar/base_sbar.cpp +++ b/source/common/statusbar/base_sbar.cpp @@ -602,7 +602,7 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag // //============================================================================ -void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY) +void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, int pt) { bool monospaced = monospacing != EMonospacing::Off; double dx = 0; @@ -724,10 +724,11 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d DTA_FillColor, 0, TAG_DONE); } - DrawChar(twod, font, fontcolor, rx, ry, ch, + DrawChar(twod, font, pt == 0? fontcolor : CR_UNDEFINED, rx, ry, ch, DTA_DestWidthF, rw, DTA_DestHeightF, rh, DTA_Alpha, Alpha, + DTA_TranslationIndex, pt, TAG_DONE); dx = monospaced @@ -739,7 +740,7 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d } } -void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY) +void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int pt) { if (font == nullptr) ThrowAbortException(X_READ_NIL, nullptr); if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); @@ -758,13 +759,13 @@ void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string auto brk = V_BreakLines(font->mFont, int(wrapwidth * scaleX), string, true); for (auto& line : brk) { - self->DrawString(font->mFont, line.Text, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY, scaleX, scaleY); + self->DrawString(font->mFont, line.Text, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY, scaleX, scaleY, pt); y += (font->mFont->GetHeight() + linespacing) * scaleY; } } else { - self->DrawString(font->mFont, string, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY, scaleX, scaleY); + self->DrawString(font->mFont, string, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY, scaleX, scaleY, pt); } } diff --git a/source/common/statusbar/base_sbar.h b/source/common/statusbar/base_sbar.h index 96fdd3d1b..75daeb826 100644 --- a/source/common/statusbar/base_sbar.h +++ b/source/common/statusbar/base_sbar.h @@ -186,7 +186,7 @@ public: void StatusbarToRealCoords(double& x, double& y, double& w, double& h) const; void DrawGraphic(FGameTexture* texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, double rotate = 0, ERenderStyle style = STYLE_Translucent); void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, double rotate = 0, ERenderStyle style = STYLE_Translucent); - void DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY); + void DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, int pt); void TransformRect(double& x, double& y, double& w, double& h, int flags = 0); void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0); void SetClipRect(double x, double y, double w, double h, int flags = 0); diff --git a/source/core/statusbar.h b/source/core/statusbar.h index 23d84169f..846751204 100644 --- a/source/core/statusbar.h +++ b/source/core/statusbar.h @@ -136,7 +136,7 @@ void ST_Clear(); extern FGameTexture *CrosshairImage; -void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY); +void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int pt = 0); void setViewport(int viewSize); struct MapRecord; void setLevelStarted(MapRecord *); diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index 40d509d9a..32b65659d 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -98,9 +98,9 @@ void DDukeCommonStatusBar::displayfragbar(void) // //========================================================================== -std::pair DDukeCommonStatusBar::ontext(struct player_struct *p) +std::pair DDukeCommonStatusBar::ontext(struct player_struct *p) { - std::pair retval(nullptr, CR_RED); + std::pair retval(nullptr, CR_RED); int onstate = 0x80000000; switch (p->inven_icon) @@ -119,12 +119,12 @@ std::pair DDukeCommonStatusBar::ontext(struct player_s // Texts are intentionally not translated because the font is too small for making localization work and the translated words are too long. if ((unsigned)onstate != 0x80000000 && !(g_gameType & (GAMEFLAG_WW2GI|GAMEFLAG_RRALL))) { - retval.second = onstate > 0 ? CR_LIGHTBLUE : CR_RED; + retval.second = onstate > 0 ? 0 : 2; retval.first = onstate > 0 ? "ON" : "OFF"; } if (p->inven_icon >= ICON_SCUBA) { - retval.second = CR_ORANGE; + retval.second = 2; retval.first = "AUTO"; } return retval; diff --git a/source/games/duke/src/sbar.h b/source/games/duke/src/sbar.h index af4429e4f..135d0134b 100644 --- a/source/games/duke/src/sbar.h +++ b/source/games/duke/src/sbar.h @@ -22,7 +22,7 @@ protected: std::array item_icons; DDukeCommonStatusBar(); - std::pair ontext(struct player_struct *p); + std::pair ontext(struct player_struct *p); void DrawInventory(const struct player_struct* p, double x, double y, int align); PalEntry LightForShade(int shade); public: diff --git a/source/games/duke/src/sbar_d.cpp b/source/games/duke/src/sbar_d.cpp index 1129c80d7..06de50fec 100644 --- a/source/games/duke/src/sbar_d.cpp +++ b/source/games/duke/src/sbar_d.cpp @@ -44,6 +44,7 @@ source as it is released. #include "texturemanager.h" #include "dukeactor.h" + BEGIN_DUKE_NS //========================================================================== @@ -206,11 +207,12 @@ public: int percentv = getinvamount(p); format.Format("%3d%%", percentv); - EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; - SBar_DrawString(this, indexFont, format, x + 36.5, -indexFont->mFont->GetHeight() + 0.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); + int color = percentv > 50 ? 11 : percentv > 25 ? 23 : 2; + SBar_DrawString(this, miniFont, format, x + 36.5, -indexFont->mFont->GetHeight() + 0.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, color)); auto text = ontext(p); - if (text.first) SBar_DrawString(this, miniFont, text.first, x + 36.5, -miniFont->mFont->GetHeight() - 9.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); + if (text.first) SBar_DrawString(this, miniFont, text.first, x + 36.5, -miniFont->mFont->GetHeight() - 9.5, DI_TEXT_ALIGN_RIGHT, + CR_UNDEFINED, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, text.second)); } // @@ -259,11 +261,11 @@ public: int percentv = getinvamount(p); format.Format("%3d%%", percentv); - EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; - SBar_DrawString(this, indexFont, format, x + 34, -indexFont->mFont->GetHeight() - 3, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); + int color = percentv > 50 ? 11 : percentv > 25 ? 23 : 2; + SBar_DrawString(this, miniFont, format, x + 34, -indexFont->mFont->GetHeight() - 3, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, color)); auto text = ontext(p); - if (text.first) SBar_DrawString(this, miniFont, text.first, x + 34, -miniFont->mFont->GetHeight() - 14, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); + if (text.first) SBar_DrawString(this, miniFont, text.first, x + 34, -miniFont->mFont->GetHeight() - 14, DI_TEXT_ALIGN_RIGHT, CR_UNDEFINED, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, text.second)); } } @@ -432,11 +434,11 @@ public: int percentv = getinvamount(p); format.Format("%3d%%", percentv); - EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; - SBar_DrawString(this, indexFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); + int color = percentv > 50 ? 11 : percentv > 25 ? 23 : 2; + SBar_DrawString(this, miniFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, CR_UNDEFINED, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, color)); auto text = ontext(p); - if (text.first) SBar_DrawString(this, miniFont, text.first, x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); + if (text.first) SBar_DrawString(this, miniFont, text.first, x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, CR_UNDEFINED, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, text.second)); } PrintLevelStats(-1); } diff --git a/source/sw/src/sbar.cpp b/source/sw/src/sbar.cpp index ed855aee0..5216c02e2 100644 --- a/source/sw/src/sbar.cpp +++ b/source/sw/src/sbar.cpp @@ -242,7 +242,7 @@ private: void DisplayTinyString(double xs, double ys, const char* buffer, int pal) { - SBar_DrawString(this, miniFont, buffer, xs, ys, DI_ITEM_LEFT_TOP, TRANSLATION(Translation_Remap, pal), 1, -1, -1, 1, 1); + SBar_DrawString(this, miniFont, buffer, xs, ys, DI_ITEM_LEFT_TOP, CR_UNTRANSLATED, 1, -1, -1, 1, 1); } void DisplayFragString(PLAYERp pp, double xs, double ys, const char* buffer)