mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- Duke: use original colors for inventory status display.
I took one liberty and still use green/yellow/red for the percentage, but this now uses palette translations so that it works better with hires replacements.
This commit is contained in:
parent
85edf38eba
commit
a92b4943f9
9 changed files with 32 additions and 26 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 *);
|
||||
|
|
|
@ -98,9 +98,9 @@ void DDukeCommonStatusBar::displayfragbar(void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
std::pair<const char*, EColorRange> DDukeCommonStatusBar::ontext(struct player_struct *p)
|
||||
std::pair<const char*, int> DDukeCommonStatusBar::ontext(struct player_struct *p)
|
||||
{
|
||||
std::pair<const char*, EColorRange> retval(nullptr, CR_RED);
|
||||
std::pair<const char*, int> retval(nullptr, CR_RED);
|
||||
|
||||
int onstate = 0x80000000;
|
||||
switch (p->inven_icon)
|
||||
|
@ -119,12 +119,12 @@ std::pair<const char*, EColorRange> 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;
|
||||
|
|
|
@ -22,7 +22,7 @@ protected:
|
|||
std::array<int, 8> item_icons;
|
||||
|
||||
DDukeCommonStatusBar();
|
||||
std::pair<const char*, EColorRange> ontext(struct player_struct *p);
|
||||
std::pair<const char*, int> ontext(struct player_struct *p);
|
||||
void DrawInventory(const struct player_struct* p, double x, double y, int align);
|
||||
PalEntry LightForShade(int shade);
|
||||
public:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue