- removed all uses of DTA_Translation except for the single one that passes a custom built table.

This means that with the exception of 3 pointers the DrawTexture interface only accepts numeric values now.
Still need to get rid of the last 3 to have this ready for scripting.
This commit is contained in:
Christoph Oelckers 2017-02-04 23:26:28 +01:00
parent d50e52ea59
commit dadc8e2ec2
11 changed files with 41 additions and 49 deletions

View file

@ -2934,7 +2934,7 @@ static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
DTA_ClipLeft, f_x,
DTA_ClipRight, f_x + f_w,
DTA_FlipX, flip,
DTA_Translation, TranslationToTable(translation),
DTA_TranslationIndex, translation,
DTA_Alpha, alpha,
DTA_FillColor, fillcolor,
DTA_RenderStyle, DWORD(renderstyle),

View file

@ -1267,7 +1267,7 @@ public:
DTA_ClipTop, static_cast<int>(dcy),
DTA_ClipRight, static_cast<int>(MIN<double>(INT_MAX, dcr)),
DTA_ClipBottom, static_cast<int>(MIN<double>(INT_MAX, dcb)),
DTA_Translation, translate ? GetTranslation() : 0,
DTA_TranslationIndex, translate ? GetTranslation() : 0,
DTA_ColorOverlay, dim ? DIM_OVERLAY : 0,
DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM,
DTA_Alpha, Alpha,
@ -1284,7 +1284,7 @@ public:
DTA_ClipTop, static_cast<int>(dcy),
DTA_ClipRight, static_cast<int>(MIN<double>(INT_MAX, dcr)),
DTA_ClipBottom, static_cast<int>(MIN<double>(INT_MAX, dcb)),
DTA_Translation, translate ? GetTranslation() : 0,
DTA_TranslationIndex, translate ? GetTranslation() : 0,
DTA_ColorOverlay, dim ? DIM_OVERLAY : 0,
DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM,
DTA_Alpha, Alpha,
@ -1344,7 +1344,7 @@ public:
DTA_ClipTop, static_cast<int>(rcy),
DTA_ClipRight, static_cast<int>(rcr),
DTA_ClipBottom, static_cast<int>(rcb),
DTA_Translation, translate ? GetTranslation() : 0,
DTA_TranslationIndex, translate ? GetTranslation() : 0,
DTA_ColorOverlay, dim ? DIM_OVERLAY : 0,
DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM,
DTA_Alpha, Alpha,
@ -1361,7 +1361,7 @@ public:
DTA_ClipTop, static_cast<int>(rcy),
DTA_ClipRight, static_cast<int>(rcr),
DTA_ClipBottom, static_cast<int>(rcb),
DTA_Translation, translate ? GetTranslation() : 0,
DTA_TranslationIndex, translate ? GetTranslation() : 0,
DTA_ColorOverlay, dim ? DIM_OVERLAY : 0,
DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM,
DTA_Alpha, Alpha,
@ -1382,7 +1382,7 @@ public:
const BYTE* str = (const BYTE*) cstring;
const EColorRange boldTranslation = EColorRange(translation ? translation - 1 : NumTextColors - 1);
FRemapTable *remap = font->GetColorTranslation(translation);
int fontcolor = translation;
if(fullScreenOffsets)
{
@ -1408,7 +1408,7 @@ public:
{
EColorRange newColor = V_ParseFontColor(++str, translation, boldTranslation);
if(newColor != CR_UNDEFINED)
remap = font->GetColorTranslation(newColor);
fontcolor = newColor;
continue;
}
@ -1417,20 +1417,22 @@ public:
width = font->GetCharWidth((unsigned char) *str);
else
width = font->GetCharWidth((unsigned char) script->spacingCharacter);
FTexture* character = font->GetChar((unsigned char) *str, &width);
if(character == NULL) //missing character.
FTexture* c = font->GetChar((unsigned char) *str, &width);
if(c == NULL) //missing character.
{
str++;
continue;
}
int character = (unsigned char)*str;
if(script->spacingCharacter == '\0') //If we are monospaced lets use the offset
ax += (character->LeftOffset+1); //ignore x offsets since we adapt to character size
ax += (c->LeftOffset+1); //ignore x offsets since we adapt to character size
double rx, ry, rw, rh;
rx = ax + xOffset;
ry = ay + yOffset;
rw = character->GetScaledWidthDouble();
rh = character->GetScaledHeightDouble();
rw = c->GetScaledWidthDouble();
rh = c->GetScaledHeightDouble();
if(script->spacingCharacter != '\0')
{
@ -1484,32 +1486,31 @@ public:
double salpha = (Alpha *HR_SHADOW);
double srx = rx + (shadowX*xScale);
double sry = ry + (shadowY*yScale);
screen->DrawTexture(character, srx, sry,
screen->DrawChar(font, CR_UNTRANSLATED, srx, sry, character,
DTA_DestWidthF, rw,
DTA_DestHeightF, rh,
DTA_Alpha, salpha,
DTA_FillColor, 0,
TAG_DONE);
}
screen->DrawTexture(character, rx, ry,
screen->DrawChar(font, fontcolor, rx, ry, character,
DTA_DestWidthF, rw,
DTA_DestHeightF, rh,
DTA_Translation, remap,
DTA_Alpha, Alpha,
TAG_DONE);
if(script->spacingCharacter == '\0')
ax += width + spacing - (character->LeftOffset+1);
ax += width + spacing - (c->LeftOffset+1);
else //width gets changed at the call to GetChar()
ax += font->GetCharWidth((unsigned char) script->spacingCharacter) + spacing;
str++;
}
}
FRemapTable* GetTranslation() const
uint32_t GetTranslation() const
{
if(gameinfo.gametype & GAME_Raven)
return translationtables[TRANSLATION_PlayersExtra][int(CPlayer - players)];
return translationtables[TRANSLATION_Players][int(CPlayer - players)];
return TRANSLATION(TRANSLATION_PlayersExtra, int(CPlayer - players));
return TRANSLATION(TRANSLATION_Players, int(CPlayer - players));
}
AInventory *ammo1, *ammo2;

View file

@ -849,7 +849,7 @@ private:
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 DrawDimImage(FTexture *image, int x, int y, bool dimmed) const;
void DrawImage(FTexture *image, int x, int y, FRemapTable *translation = NULL) const;
void DrawImage(FTexture *image, int x, int y/*, FRemapTable *translation = NULL*/) const;
};
@ -1022,12 +1022,11 @@ void DStrifeStatusBar::DrBNumberOuterFont(signed int val, int x, int y, int size
//---------------------------------------------------------------------------
void DStrifeStatusBar::DrawImage(FTexture *img,
int x, int y, FRemapTable *translation) const
int x, int y) const
{
if (img != NULL)
{
screen->DrawTexture(img, x + ST_X, y + ST_Y,
DTA_Translation, translation,
DTA_Bottom320x200, Scaled,
TAG_DONE);
}

View file

@ -388,15 +388,8 @@ void DIntermissionScreenText::Drawer ()
w *= CleanXfac;
if (cx + w > SCREENWIDTH)
continue;
if (pic != NULL)
{
screen->DrawTexture (pic,
cx,
cy,
DTA_Translation, range,
DTA_CleanNoMove, true,
TAG_DONE);
}
screen->DrawChar(SmallFont, mTextColor, cx, cy, c, DTA_CleanNoMove, true, TAG_DONE);
cx += w;
}
}
@ -432,16 +425,15 @@ void DIntermissionScreenCast::Init(FIntermissionAction *desc, bool first)
if (mClass->IsDescendantOf(RUNTIME_CLASS(APlayerPawn)))
{
advplayerstate = mDefaults->MissileState;
casttranslation = translationtables[TRANSLATION_Players][consoleplayer];
casttranslation = TRANSLATION(TRANSLATION_Players, consoleplayer);
}
else
{
advplayerstate = NULL;
casttranslation = NULL;
casttranslation = 0;
if (mDefaults->Translation != 0)
{
casttranslation = translationtables[GetTranslationType(mDefaults->Translation)]
[GetTranslationIndex(mDefaults->Translation)];
casttranslation = mDefaults->Translation;
}
}
castdeath = false;
@ -631,7 +623,7 @@ void DIntermissionScreenCast::Drawer ()
DTA_DestWidthF, pic->GetScaledWidthDouble() * castscale.X,
DTA_RenderStyle, mDefaults->RenderStyle,
DTA_Alpha, mDefaults->Alpha,
DTA_Translation, casttranslation,
DTA_TranslationIndex, casttranslation,
TAG_DONE);
}
}

View file

@ -234,7 +234,7 @@ class DIntermissionScreenCast : public DIntermissionScreen
TArray<FICastSound> mCastSounds;
int casttics;
const FRemapTable *casttranslation; // [RH] Draw "our hero" with their chosen suit color
uint32_t casttranslation; // [RH] Draw "our hero" with their chosen suit color
FState* caststate;
FState* basestate;
FState* advplayerstate;

View file

@ -336,15 +336,11 @@ void DTextEnterMenu::Drawer ()
// The highlighted character is yellow; the rest are dark gray.
color = (x == InputGridX && y == InputGridY) ? CR_YELLOW : CR_DARKGRAY;
remap = SmallFont->GetColorTranslation(color);
if (pic != NULL)
{
// Draw a normal character.
screen->DrawTexture(pic, xx + cell_width/2 - width*CleanXfac/2, yy + top_padding,
DTA_Translation, remap,
DTA_CleanNoMove, true,
TAG_DONE);
screen->DrawChar(SmallFont, color, xx + cell_width/2 - width*CleanXfac/2, yy + top_padding, ch, DTA_CleanNoMove, true, TAG_DONE);
}
else if (ch == ' ')
{

View file

@ -605,13 +605,12 @@ void DListMenuItemPlayerDisplay::Drawer(bool selected)
FTexture *tex = TexMan(sprframe->Texture[mRotation]);
if (tex != NULL && tex->UseType != FTexture::TEX_Null)
{
FRemapTable *trans = NULL;
if (mTranslate) trans = translationtables[TRANSLATION_Players](MAXPLAYERS);
int trans = mTranslate? TRANSLATION(TRANSLATION_Players, MAXPLAYERS) : 0;
screen->DrawTexture (tex,
x + 36*CleanXfac, y + 71*CleanYfac,
DTA_DestWidthF, tex->GetScaledWidthDouble() * CleanXfac * Scale.X,
DTA_DestHeightF, tex->GetScaledHeightDouble() * CleanYfac * Scale.Y,
DTA_Translation, trans,
DTA_TranslationIndex, trans,
DTA_FlipX, sprframe->Flip & (1 << mRotation),
TAG_DONE);
}

View file

@ -1712,7 +1712,7 @@ void R_DrawRemainingPlayerSprites()
viewwindowy + viewheight/2 - vis->texturemid * vis->yscale - 0.5,
DTA_DestWidthF, FIXED2DBL(vis->pic->GetWidth() * vis->xscale),
DTA_DestHeightF, vis->pic->GetHeight() * vis->yscale,
DTA_Translation, TranslationToTable(vis->Translation),
DTA_TranslationIndex, vis->Translation,
DTA_FlipX, flip,
DTA_TopOffset, 0,
DTA_LeftOffset, 0,

View file

@ -201,7 +201,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
{
parms.colorOverlay = PalEntry(parms.colorOverlay).InverseColor();
}
// Note that this overrides DTA_Translation in software, but not in hardware.
// Note that this overrides the translation in software, but not in hardware.
FDynamicColormap *colormap = GetSpecialLights(MAKERGB(255,255,255),
parms.colorOverlay & MAKEARGB(0,255,255,255), 0);
translation = &colormap->Maps[(APART(parms.colorOverlay)*NUMCOLORMAPS/255)*256];
@ -735,6 +735,10 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, DWORD tag,
parms->remap = ListGetTranslation(tags);
break;
case DTA_TranslationIndex:
parms->remap = TranslationToTable(ListGetInt(tags));
break;
case DTA_ColorOverlay:
parms->colorOverlay = ListGetInt(tags);
break;

View file

@ -52,7 +52,7 @@
//
// Write a single character using the given font
//
void DCanvas::DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, int tag_first, ...)
void DCanvas::DrawChar (FFont *font, int normalcolor, double x, double y, int character, int tag_first, ...)
{
if (font == NULL)
return;

View file

@ -77,6 +77,7 @@ enum
DTA_Alpha, // alpha value for translucency
DTA_FillColor, // color to stencil onto the destination (RGB is the color for truecolor drawers, A is the palette index for paletted drawers)
DTA_Translation, // translation table to recolor the source
DTA_TranslationIndex,
DTA_AlphaChannel, // bool: the source is an alpha channel; used with DTA_FillColor
DTA_Clean, // bool: scale texture size and position by CleanXfac and CleanYfac
DTA_320x200, // bool: scale texture size and position to fit on a virtual 320x200 screen
@ -270,7 +271,7 @@ public:
#endif
// 2D Text drawing
void DrawText (FFont *font, int normalcolor, int x, int y, const char *string, int tag_first, ...);
void DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, int tag_first, ...);
void DrawChar (FFont *font, int normalcolor, double x, double y, int character, int tag_first, ...);
protected:
BYTE *Buffer;