From dadc8e2ec2ad95a77f2e17fa729dad0a480039df Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Feb 2017 23:26:28 +0100 Subject: [PATCH] - 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. --- src/am_map.cpp | 2 +- src/g_statusbar/sbarinfo.cpp | 37 ++++++++++++++++--------------- src/g_statusbar/strife_sbar.cpp | 5 ++--- src/intermission/intermission.cpp | 20 +++++------------ src/intermission/intermission.h | 2 +- src/menu/menuinput.cpp | 6 +---- src/menu/playerdisplay.cpp | 5 ++--- src/r_things.cpp | 2 +- src/v_draw.cpp | 6 ++++- src/v_text.cpp | 2 +- src/v_video.h | 3 ++- 11 files changed, 41 insertions(+), 49 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 19f10f067..be92fd37a 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -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), diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 33b47f15d..2fd21737f 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -1267,7 +1267,7 @@ public: DTA_ClipTop, static_cast(dcy), DTA_ClipRight, static_cast(MIN(INT_MAX, dcr)), DTA_ClipBottom, static_cast(MIN(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(dcy), DTA_ClipRight, static_cast(MIN(INT_MAX, dcr)), DTA_ClipBottom, static_cast(MIN(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(rcy), DTA_ClipRight, static_cast(rcr), DTA_ClipBottom, static_cast(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(rcy), DTA_ClipRight, static_cast(rcr), DTA_ClipBottom, static_cast(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; diff --git a/src/g_statusbar/strife_sbar.cpp b/src/g_statusbar/strife_sbar.cpp index 8e1374491..177117eb2 100644 --- a/src/g_statusbar/strife_sbar.cpp +++ b/src/g_statusbar/strife_sbar.cpp @@ -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); } diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index 9c3353b60..8310914be 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -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); } } diff --git a/src/intermission/intermission.h b/src/intermission/intermission.h index 0f2c38dde..cdc100d88 100644 --- a/src/intermission/intermission.h +++ b/src/intermission/intermission.h @@ -234,7 +234,7 @@ class DIntermissionScreenCast : public DIntermissionScreen TArray 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; diff --git a/src/menu/menuinput.cpp b/src/menu/menuinput.cpp index cca4756f5..b59080278 100644 --- a/src/menu/menuinput.cpp +++ b/src/menu/menuinput.cpp @@ -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 == ' ') { diff --git a/src/menu/playerdisplay.cpp b/src/menu/playerdisplay.cpp index aaec6fba3..9b26d7471 100644 --- a/src/menu/playerdisplay.cpp +++ b/src/menu/playerdisplay.cpp @@ -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); } diff --git a/src/r_things.cpp b/src/r_things.cpp index 8aaf0dcfe..3d0ce269e 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -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, diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 3961c1ec1..b61d83b01 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -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; diff --git a/src/v_text.cpp b/src/v_text.cpp index 5772b078c..3fcac5541 100644 --- a/src/v_text.cpp +++ b/src/v_text.cpp @@ -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; diff --git a/src/v_video.h b/src/v_video.h index 2f42b9807..f52e8b8aa 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -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;