- added colorization for untranslated fonts. This uses the light color of the vertices. The software rendered 2D code will ignore this infomation.

- added a virtual OnRetrun method to menus.
This commit is contained in:
Christoph Oelckers 2017-03-29 21:22:05 +02:00
parent d36f656caf
commit 01b095c911
10 changed files with 53 additions and 7 deletions

View File

@ -140,6 +140,7 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms)
color = PalEntry(light, light, light); color = PalEntry(light, light, light);
} }
color.a = (uint8_t)(parms.Alpha * 255); color.a = (uint8_t)(parms.Alpha * 255);
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);
// scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates
dg.mScissor[0] = GLRenderer->ScreenToWindowX(parms.lclip); dg.mScissor[0] = GLRenderer->ScreenToWindowX(parms.lclip);

View File

@ -2773,6 +2773,12 @@ void OpenGLSWFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms)
vert = &VertexData[VertexPos]; vert = &VertexData[VertexPos];
{
PalEntry color = color1;
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);
color1 = color;
}
// Fill the vertex buffer. // Fill the vertex buffer.
vert[0].x = float(x0); vert[0].x = float(x0);
vert[0].y = float(y0); vert[0].y = float(y0);

View File

@ -243,6 +243,12 @@ void DMenu::Close ()
if (CurrentMenu != nullptr) if (CurrentMenu != nullptr)
{ {
GC::WriteBarrier(CurrentMenu); GC::WriteBarrier(CurrentMenu);
IFVIRTUALPTR(CurrentMenu, DMenu, OnReturn)
{
VMValue params[] = { CurrentMenu };
GlobalVMStack.Call(func, params, 1, nullptr, 0, nullptr);
}
} }
else else
{ {

View File

@ -366,6 +366,7 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t t
parms->colorOverlay = 0; parms->colorOverlay = 0;
parms->alphaChannel = false; parms->alphaChannel = false;
parms->flipX = false; parms->flipX = false;
parms->color = 0xffffffff;
//parms->shadowAlpha = 0; //parms->shadowAlpha = 0;
parms->shadowColor = 0; parms->shadowColor = 0;
parms->virtWidth = this->GetWidth(); parms->virtWidth = this->GetWidth();
@ -542,6 +543,10 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t t
parms->colorOverlay = ListGetInt(tags); parms->colorOverlay = ListGetInt(tags);
break; break;
case DTA_Color:
parms->color = ListGetInt(tags);
break;
case DTA_FlipX: case DTA_FlipX:
parms->flipX = ListGetInt(tags); parms->flipX = ListGetInt(tags);
break; break;

View File

@ -756,9 +756,18 @@ void FFont::BuildTranslations (const double *luminosity, const uint8_t *identity
// //
//========================================================================== //==========================================================================
FRemapTable *FFont::GetColorTranslation (EColorRange range) const FRemapTable *FFont::GetColorTranslation (EColorRange range, PalEntry *color) const
{ {
if (ActiveColors == 0 || noTranslate) if (noTranslate)
{
PalEntry retcolor = PalEntry(255, 255, 255, 255);
if (range >= 0 && range < NumTextColors && range != CR_UNTRANSLATED)
{
retcolor = TranslationColors[range];
}
if (color != nullptr) *color = retcolor;
}
if (ActiveColors == 0)
return NULL; return NULL;
else if (range >= NumTextColors) else if (range >= NumTextColors)
range = CR_UNTRANSLATED; range = CR_UNTRANSLATED;

View File

@ -80,7 +80,7 @@ public:
virtual FTexture *GetChar (int code, int *const width) const; virtual FTexture *GetChar (int code, int *const width) const;
virtual int GetCharWidth (int code) const; virtual int GetCharWidth (int code) const;
FRemapTable *GetColorTranslation (EColorRange range) const; FRemapTable *GetColorTranslation (EColorRange range, PalEntry *color = nullptr) const;
int GetLump() const { return Lump; } int GetLump() const { return Lump; }
int GetSpaceWidth () const { return SpaceWidth; } int GetSpaceWidth () const { return SpaceWidth; }
int GetHeight () const { return FontHeight; } int GetHeight () const { return FontHeight; }

View File

@ -80,7 +80,9 @@ void DCanvas::DrawChar (FFont *font, int normalcolor, double x, double y, int ch
{ {
return; return;
} }
parms.remap = font->GetColorTranslation((EColorRange)normalcolor); PalEntry color;
parms.remap = 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);
DrawTextureParms(pic, parms); DrawTextureParms(pic, parms);
} }
} }
@ -102,7 +104,9 @@ void DCanvas::DrawChar(FFont *font, int normalcolor, double x, double y, int cha
uint32_t tag = ListGetInt(args); uint32_t tag = ListGetInt(args);
bool res = ParseDrawTextureTags(pic, x, y, tag, args, &parms, false); bool res = ParseDrawTextureTags(pic, x, y, tag, args, &parms, false);
if (!res) return; if (!res) return;
parms.remap = font->GetColorTranslation((EColorRange)normalcolor); PalEntry color;
parms.remap = 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);
DrawTextureParms(pic, parms); DrawTextureParms(pic, parms);
} }
} }
@ -151,7 +155,10 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c
normalcolor = CR_UNTRANSLATED; normalcolor = CR_UNTRANSLATED;
boldcolor = normalcolor ? normalcolor - 1 : NumTextColors - 1; boldcolor = normalcolor ? normalcolor - 1 : NumTextColors - 1;
range = font->GetColorTranslation((EColorRange)normalcolor); PalEntry colorparm = parms.color;
PalEntry color;
range = font->GetColorTranslation((EColorRange)normalcolor, &color);
parms.color = PalEntry((color.a * colorparm.a) / 255, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255);
kerning = font->GetDefaultKerning(); kerning = font->GetDefaultKerning();
@ -171,7 +178,8 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c
EColorRange newcolor = V_ParseFontColor(ch, normalcolor, boldcolor); EColorRange newcolor = V_ParseFontColor(ch, normalcolor, boldcolor);
if (newcolor != CR_UNDEFINED) if (newcolor != CR_UNDEFINED)
{ {
range = font->GetColorTranslation(newcolor); range = font->GetColorTranslation(newcolor, &color);
parms.color = PalEntry((color.a * colorparm.a) / 255, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255);
} }
continue; continue;
} }

View File

@ -125,6 +125,9 @@ enum
DTA_TextLen, // stop after this many characters, even if \0 not hit DTA_TextLen, // stop after this many characters, even if \0 not hit
DTA_CellX, // horizontal size of character cell DTA_CellX, // horizontal size of character cell
DTA_CellY, // vertical size of character cell DTA_CellY, // vertical size of character cell
// New additions.
DTA_Color,
}; };
enum enum
@ -161,6 +164,7 @@ struct DrawParms
uint32_t fillcolor; uint32_t fillcolor;
FRemapTable *remap; FRemapTable *remap;
uint32_t colorOverlay; uint32_t colorOverlay;
PalEntry color;
INTBOOL alphaChannel; INTBOOL alphaChannel;
INTBOOL flipX; INTBOOL flipX;
//float shadowAlpha; //float shadowAlpha;

View File

@ -2942,6 +2942,12 @@ void D3DFB::DrawTextureParms (FTexture *img, DrawParms &parms)
vert = &VertexData[VertexPos]; vert = &VertexData[VertexPos];
{
PalEntry color = color1;
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);
color1 = color;
}
// Fill the vertex buffer. // Fill the vertex buffer.
vert[0].x = float(x0); vert[0].x = float(x0);
vert[0].y = float(y0); vert[0].y = float(y0);

View File

@ -271,6 +271,7 @@ class Menu : Object native ui version("2.4")
virtual void ResetColor() {} virtual void ResetColor() {}
virtual bool MouseEvent(int type, int mx, int my) { return true; } virtual bool MouseEvent(int type, int mx, int my) { return true; }
virtual void Ticker() {} virtual void Ticker() {}
virtual void OnReturn() {}
//============================================================================= //=============================================================================
// //