From 66cb7f61a41f33f6a252eaeb45841e9414c293f7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 14 Aug 2020 21:01:27 +0200 Subject: [PATCH] - fixed rendering on narrow screens with an aspect ratio less than 4:3 and removed some parts that are no longer needed. --- source/blood/src/blood.cpp | 2 +- source/blood/src/d_menu.cpp | 15 +++-- source/blood/src/endgame.cpp | 4 +- source/blood/src/hudsprites.cpp | 12 ++-- source/blood/src/map2d.cpp | 2 +- source/blood/src/qav.cpp | 39 +++++++------ source/blood/src/view.cpp | 4 +- source/build/include/build.h | 13 +---- source/common/2d/v_draw.cpp | 46 +++++++++++---- source/common/2d/v_draw.h | 15 +++++ source/core/menu/messagebox.cpp | 2 +- source/core/screenjob.cpp | 10 ++-- source/games/duke/src/2d_d.cpp | 42 +++++++------- source/games/duke/src/2d_r.cpp | 16 +++--- source/games/duke/src/d_menu.cpp | 18 +++--- source/games/duke/src/game_misc.cpp | 10 ++-- source/games/duke/src/sbar.cpp | 2 +- source/glbackend/glbackend.cpp | 14 +++-- source/glbackend/glbackend.h | 2 +- source/sw/src/panel.cpp | 86 +++-------------------------- source/sw/src/panel.h | 2 - source/sw/src/text.cpp | 3 + 22 files changed, 166 insertions(+), 193 deletions(-) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index c6827b4c1..acf131796 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -874,7 +874,7 @@ static void gameTicker() static void drawBackground() { twod->ClearScreen(); - DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, 3, TAG_DONE); + DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); if (gQuitRequest && !gQuitGame) netBroadcastMyLogoff(gQuitRequest == 2); } diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index 80b9c89b5..595e177de 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "qav.h" #include "view.h" #include "sound.h" +#include "v_video.h" bool ShowOptionMenu(); @@ -167,7 +168,9 @@ protected: void PostDraw() { - itemBloodQAV->Draw(); + // For narrow screens this would be mispositioned so skip drawing it there. + double ratio = screen->GetWidth() / double(screen->GetHeight()); + if (ratio > 1.32) itemBloodQAV->Draw(); } }; @@ -225,10 +228,10 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, double xpos, doub xpos -= width / 2; } DrawText(twod, gamefont, CR_UNDEFINED, xpos+1, ypos+1, text, DTA_Color, 0xff000000, //DTA_Alpha, 0.5, - DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); + DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); DrawText(twod, gamefont, CR_UNDEFINED, xpos, ypos, text, DTA_TranslationIndex, TRANSLATION(Translation_Remap, pal), DTA_Color, shadeToLight(shade), - DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); + DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); } @@ -271,8 +274,8 @@ void DrawMenuCaption(const char* text) int boxwidth = tileWidth(2038); if (boxwidth - 10 < width) scalex = double(width) / (boxwidth - 10); - DrawTexture(twod, tileGetTexture(2038, true), 160, 20, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, DTA_ScaleX, scalex, TAG_DONE); - DrawText(twod, BigFont, CR_UNDEFINED, 160 - width/2, 20 - tileHeight(4193) / 2, text, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); + DrawTexture(twod, tileGetTexture(2038, true), 160, 20, DTA_FullscreenScale, FSMode_ScaleToFit43Top, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, DTA_ScaleX, scalex, TAG_DONE); + DrawText(twod, BigFont, CR_UNDEFINED, 160 - width/2, 20 - tileHeight(4193) / 2, text, DTA_FullscreenScale, FSMode_ScaleToFit43Top, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); } void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text) @@ -292,7 +295,7 @@ void GameInterface::DrawCenteredTextScreen(const DVector2& origin, const char* t { int width = SmallFont->StringWidth(l); int x = 160 - width / 2; - DrawText(twod, SmallFont, CR_UNTRANSLATED, x, y, l, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); + DrawText(twod, SmallFont, CR_UNTRANSLATED, x, y, l, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); y += height; } } diff --git a/source/blood/src/endgame.cpp b/source/blood/src/endgame.cpp index aa72d3bc0..5b90c33c8 100644 --- a/source/blood/src/endgame.cpp +++ b/source/blood/src/endgame.cpp @@ -64,7 +64,7 @@ static void drawTextScreenBackground(void) { if (yxaspect >= 65536) { - DrawTexture(twod, tileGetTexture(kLoadScreen), 0, 0, DTA_FullscreenEx, 3, TAG_DONE); + DrawTexture(twod, tileGetTexture(kLoadScreen), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); } else { @@ -84,7 +84,7 @@ static void drawTextScreenBackground(void) } else { - DrawTexture(twod, tileGetTexture(kLoadScreen), 0, 0, DTA_FullscreenEx, 3, TAG_DONE); + DrawTexture(twod, tileGetTexture(kLoadScreen), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); } } diff --git a/source/blood/src/hudsprites.cpp b/source/blood/src/hudsprites.cpp index 816861d3e..9ec881eb2 100644 --- a/source/blood/src/hudsprites.cpp +++ b/source/blood/src/hudsprites.cpp @@ -71,10 +71,12 @@ static struct { static void drawElement(int x, int y, int tile, double scale = 1, int flipx = 0, int flipy = 0, int pin = 0, int basepal = 0, double alpha = 1) { - DrawTexture(&twodpsp, tileGetTexture(tile), x, y, DTA_FlipX, flipx, DTA_FlipY, flipy, DTA_TopLeft, true, DTA_FlipOffsets, true, - DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ViewportX, gViewX0, DTA_ViewportY, gViewY0, DTA_Alpha, alpha, - DTA_ViewportWidth, gViewX1 - gViewX0 + 1, DTA_ViewportHeight, gViewY1 - gViewY0 + 1, DTA_Pin, pin, DTA_ScaleX, scale, DTA_ScaleY, scale, - DTA_TranslationIndex, TRANSLATION(Translation_Remap + basepal, 0), TAG_DONE); + int flags = RS_TOPLEFT; + if (flipx) flags |= RS_XFLIPHUD; + if (flipy) flags |= RS_YFLIPHUD; + if (pin == -1) flags |= RS_ALIGN_L; + else if (pin == 1) flags |= RS_ALIGN_R; + hud_drawsprite(x, y, int(scale*65536), 0, tile, 0, basepal, flags, alpha); } @@ -103,7 +105,7 @@ void hudDraw(PLAYER *gView, int nSectnum, int defaultHoriz, double bobx, double { double crosshair_scale = cl_crosshairscale * .02; DrawTexture(twod, tileGetTexture(kCrosshairTile), 160, defaultHoriz, - DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, crosshair_scale, DTA_ScaleY, crosshair_scale, DTA_CenterOffsetRel, true, + DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, crosshair_scale, DTA_ScaleY, crosshair_scale, DTA_CenterOffsetRel, true, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, TAG_DONE); } double cX = 160; diff --git a/source/blood/src/map2d.cpp b/source/blood/src/map2d.cpp index 5974d6671..b7e0010b2 100644 --- a/source/blood/src/map2d.cpp +++ b/source/blood/src/map2d.cpp @@ -160,7 +160,7 @@ void sub_2541C(int x, int y, int z, short a) double x = xdim/2. + x1 / double(1<<12); double y = ydim/2. + y1 / double(1<<12); // This very likely needs fixing later - DrawTexture(twod, tileGetTexture(nTile, true), x, y, DTA_FullscreenScale, 3, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, + DrawTexture(twod, tileGetTexture(nTile, true), x, y, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x+1, DTA_ViewportHeight, windowxy2.y - windowxy1.y+1, DTA_Alpha, (pSprite->cstat&2? 0.5:1.), TAG_DONE); } } diff --git a/source/blood/src/qav.cpp b/source/blood/src/qav.cpp index 57cf68821..2bda0eb1b 100644 --- a/source/blood/src/qav.cpp +++ b/source/blood/src/qav.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "qav.h" #include "sound.h" #include "v_draw.h" +#include "glbackend/glbackend.h" BEGIN_BLD_NS @@ -50,31 +51,35 @@ void DrawFrame(F2DDrawer *twod, double x, double y, TILE_FRAME *pTile, int stat, stat |= pTile->stat; x += pTile->x; y += pTile->y; - auto tex = tileGetTexture(pTile->picnum); - double scale = pTile->z/65536.; - double angle = pTile->angle * (360./2048); - int renderstyle = (stat & RS_NOMASK)? STYLE_Normal : STYLE_Translucent; - double alpha = (stat & RS_TRANS1)? glblend[0].def[!!(stat & RS_TRANS2)].alpha : 1.; - int pin = (stat & kQavOrientationLeft)? -1 : (stat & RS_ALIGN_R)? 1:0; - if (palnum <= 0) palnum = pTile->palnum; - auto translation = TRANSLATION(Translation_Remap + basepal, palnum); - bool topleft = !!(stat & RS_TOPLEFT); - - bool xflip = !!(stat & 0x100); // repurposed flag - bool yflip = !!(stat & RS_YFLIP); - auto color = shadeToLight(pTile->shade + shade); if (!to3dview) { + auto tex = tileGetTexture(pTile->picnum); + double scale = pTile->z/65536.; + double angle = pTile->angle * (360./2048); + int renderstyle = (stat & RS_NOMASK)? STYLE_Normal : STYLE_Translucent; + double alpha = (stat & RS_TRANS1)? glblend[0].def[!!(stat & RS_TRANS2)].alpha : 1.; + int pin = (stat & kQavOrientationLeft)? -1 : (stat & RS_ALIGN_R)? 1:0; + if (palnum <= 0) palnum = pTile->palnum; + auto translation = TRANSLATION(Translation_Remap + basepal, palnum); + bool topleft = !!(stat & RS_TOPLEFT); + + bool xflip = !!(stat & 0x100); // repurposed flag + bool yflip = !!(stat & RS_YFLIP); + auto color = shadeToLight(pTile->shade + shade); + DrawTexture(twod, tex, x, y, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Rotate, angle, DTA_LegacyRenderStyle, renderstyle, DTA_Alpha, alpha, DTA_Pin, pin, DTA_TranslationIndex, translation, - DTA_TopLeft, topleft, DTA_CenterOffsetRel, !topleft, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_FlipOffsets, true, DTA_Color, color, + DTA_TopLeft, topleft, DTA_CenterOffsetRel, !topleft, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_FlipOffsets, true, DTA_Color, color, DTA_FlipX, xflip, DTA_FlipY, yflip, TAG_DONE); } else { - DrawTexture(twod, tex, x, y, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Rotate, angle, DTA_LegacyRenderStyle, renderstyle, DTA_Alpha, alpha, DTA_Pin, pin, DTA_TranslationIndex, translation, - DTA_TopLeft, topleft, DTA_CenterOffsetRel, !topleft, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_FlipOffsets, true, DTA_Color, color, - DTA_FlipX, xflip, DTA_FlipY, yflip, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x+1, DTA_ViewportHeight, windowxy2.y - windowxy1.y+1, TAG_DONE); + if (stat & RS_YFLIP) stat |= RS_YFLIPHUD; + stat &= ~RS_YFLIP; + if (stat & 0x100) stat |= RS_XFLIPHUD; + if ((stat & kQavOrientationLeft)) stat |= RS_ALIGN_L; + + hud_drawsprite(x, y, pTile->z, pTile->angle, pTile->picnum, shade, palnum, stat); } } diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index d518c783f..72bb6f2cb 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -230,9 +230,9 @@ void viewDrawText(int nFont, const char *pString, int x, int y, int nShade, int if (shadow) { - DrawText(twod, pFont, CR_UNDEFINED, x+1, y+1, pString, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff000000, DTA_Alpha, 0.5, TAG_DONE); + DrawText(twod, pFont, CR_UNDEFINED, x+1, y+1, pString, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff000000, DTA_Alpha, 0.5, TAG_DONE); } - DrawText(twod, pFont, CR_UNDEFINED, x, y, pString, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, TRANSLATION(Translation_Remap, nPalette), + DrawText(twod, pFont, CR_UNDEFINED, x, y, pString, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, TRANSLATION(Translation_Remap, nPalette), DTA_Color, shadeToLight(nShade), DTA_Alpha, alpha / 255., TAG_DONE); } diff --git a/source/build/include/build.h b/source/build/include/build.h index 4e9d7abde..f5d03c772 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -156,6 +156,8 @@ enum { RS_MODELSUBST= 4096, // ROTATESPRITE_MAX-1 is the mask of all externally available orientation bits ROTATESPRITE_MAX = 8192, + RS_XFLIPHUD = RS_YFLIP, + RS_YFLIPHUD = 16384, // this is for hud_drawsprite which uses RS_YFLIP for x-flipping but needs both flags RS_CENTER = (1<<29), // proper center align. RS_CENTERORIGIN = (1<<30), @@ -1164,7 +1166,7 @@ class F2DDrawer; extern F2DDrawer twodpsp; extern F2DDrawer* twod; -// This is for safely substituting the 2D drawer for a block of code. +// This is for safely substituting the 2D drawer for a block of code. Won't be needed anymore after proper refactoring. class PspTwoDSetter { F2DDrawer* old; @@ -1178,15 +1180,6 @@ public: { twod = old; } - // Shadow Warrior fucked this up and draws the weapons in the same pass as the hud, meaning we have to switch this on and off depending on context. - void set() - { - twod = &twodpsp; - } - void clear() - { - twod = old; - } }; #endif // build_h_ diff --git a/source/common/2d/v_draw.cpp b/source/common/2d/v_draw.cpp index 3112fe6c4..220bd219f 100644 --- a/source/common/2d/v_draw.cpp +++ b/source/common/2d/v_draw.cpp @@ -335,12 +335,13 @@ DEFINE_ACTION_FUNCTION(_Screen, GetClipRect) } -static void CalcFullscreenScale(F2DDrawer* drawer, DrawParms *parms, double srcwidth, double srcheight, int autoaspect, DoubleRect &rect) +static void CalcFullscreenScale(F2DDrawer* drawer, DrawParms *parms, double srcwidth, double srcheight, int oautoaspect, DoubleRect &rect) { auto GetWidth = [=]() { return parms->viewport.width; }; auto GetHeight = [=]() {return parms->viewport.height; }; - if (autoaspect == 4) + int autoaspect = oautoaspect; + if (autoaspect == FSMode_ScaleToScreen) { rect.left = rect.top = 0; rect.width = GetWidth(); @@ -354,23 +355,35 @@ static void CalcFullscreenScale(F2DDrawer* drawer, DrawParms *parms, double srcw else aspect = srcwidth / srcheight; rect.left = rect.top = 0; auto screenratio = ActiveRatio(GetWidth(), GetHeight()); - if (autoaspect == 3) + if (autoaspect == FSMode_ScaleToFit43 || autoaspect == FSMode_ScaleToFit43Top || autoaspect == FSMode_ScaleToFit43Bottom) { - if (screenratio >= aspect || aspect < 1.4) autoaspect = 1; // screen is wider than the image -> pillarbox it. 4:3 images must also be pillarboxed if the screen is taller than the image - else if (screenratio > 1.32) autoaspect = 2; // on anything 4:3 and wider crop the sides of the image. + // screen is wider than the image -> pillarbox it. 4:3 images must also be pillarboxed if the screen is taller than the image + if (screenratio >= aspect || aspect < 1.4) autoaspect = FSMode_ScaleToFit; + else if (screenratio > 1.32) autoaspect = FSMode_ScaleToFill; // on anything 4:3 and wider crop the sides of the image. else { // special case: Crop image to 4:3 and then letterbox this. This avoids too much cropping on narrow windows. double width4_3 = srcheight * (4. / 3.); rect.width = (double)GetWidth() * srcwidth / width4_3; rect.height = GetHeight() * screenratio * (3. / 4.); // use 4:3 for the image - rect.top = (GetHeight() - rect.height) / 2; rect.left = -(srcwidth - width4_3) / 2; + switch (oautoaspect) + { + default: + rect.top = (GetHeight() - rect.height) / 2; + break; + case FSMode_ScaleToFit43Top: + rect.top = 0; + break; + case FSMode_ScaleToFit43Bottom: + rect.top = (GetHeight() - rect.height); + break; + } return; } } - if ((screenratio > aspect) ^ (autoaspect == 2)) + if (autoaspect == FSMode_ScaleToHeight || (screenratio > aspect) ^ (autoaspect == FSMode_ScaleToFill)) { // pillarboxed or vertically cropped (i.e. scale to height) rect.height = GetHeight(); @@ -382,7 +395,18 @@ static void CalcFullscreenScale(F2DDrawer* drawer, DrawParms *parms, double srcw // letterboxed or horizontally cropped (i.e. scale to width) rect.width = GetWidth(); rect.height = GetHeight() * screenratio / aspect; - rect.top = (GetHeight() - rect.height) / 2; + switch (oautoaspect) + { + default: + rect.top = (GetHeight() - rect.height) / 2; + break; + case FSMode_ScaleToFit43Top: + rect.top = 0; + break; + case FSMode_ScaleToFit43Bottom: + rect.top = (GetHeight() - rect.height); + break; + } } } @@ -447,7 +471,7 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FGameTexture *img, do break; case DTA_Base: - if (parms->fsscalemode != -1) + if (parms->fsscalemode > 0) { // First calculate the destination rect for an image of the given size and then reposition this object in it. DoubleRect rect; @@ -771,9 +795,9 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double case DTA_FullscreenScale: intval = ListGetInt(tags); - if (intval >= 0 && intval <= 4) + if (intval >= FSMode_None && intval < FSMode_Max) { - parms->fsscalemode = (uint8_t)intval; + parms->fsscalemode = (int8_t)intval; } break; diff --git a/source/common/2d/v_draw.h b/source/common/2d/v_draw.h index 4b2dc01a6..5d6fe78df 100644 --- a/source/common/2d/v_draw.h +++ b/source/common/2d/v_draw.h @@ -23,6 +23,21 @@ enum tags : uint32_t TAG_USER = ((uint32_t)(1u << 30)) }; +enum +{ + FSMode_None = 0, + FSMode_ScaleToFit = 1, + FSMode_ScaleToFill = 2, + FSMode_ScaleToFit43 = 3, + FSMode_ScaleToScreen = 4, + FSMode_ScaleToFit43Top = 5, + FSMode_ScaleToFit43Bottom = 6, + FSMode_ScaleToHeight = 7, + + + FSMode_Max +}; + enum { DTA_Base = TAG_USER + 5000, diff --git a/source/core/menu/messagebox.cpp b/source/core/menu/messagebox.cpp index 4ea2e6d70..73c139d15 100644 --- a/source/core/menu/messagebox.cpp +++ b/source/core/menu/messagebox.cpp @@ -63,7 +63,7 @@ void GameInterface::DrawCenteredTextScreen(const DVector2& origin, const char* t for (auto& line : lines) { double x = origin.X + 160 - line.Width * scale * 0.5; - DrawText(twod, SmallFont, CR_UNTRANSLATED, x, y, line.Text, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); + DrawText(twod, SmallFont, CR_UNTRANSLATED, x, y, line.Text, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); y += fheight; } } diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index 45fca0ac6..5641e0f58 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -76,7 +76,7 @@ int DImageScreen::Frame(uint64_t clock, bool skiprequest) if (!tex) return 0; int span = int(clock / 1'000'000); twod->ClearScreen(); - DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); // Only end after having faded out. return skiprequest ? -1 : span > waittime? 0 : 1; } @@ -137,7 +137,7 @@ public: if (totalclock < ototalclock - 1) { twod->ClearScreen(); - DrawTexture(twod, animtex.GetFrame(), 0, 0, DTA_FullscreenEx, 3, DTA_Masked, false, TAG_DONE); + DrawTexture(twod, animtex.GetFrame(), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Masked, false, TAG_DONE); if (skiprequest) soundEngine->StopAllChannels(); return skiprequest? -1 : 1; } @@ -146,7 +146,7 @@ public: frametime = totalclock; twod->ClearScreen(); - DrawTexture(twod, animtex.GetFrame(), 0, 0, DTA_FullscreenEx, 3, DTA_Masked, false, TAG_DONE); + DrawTexture(twod, animtex.GetFrame(), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Masked, false, TAG_DONE); int delay = 20; if (frameTicks) @@ -210,7 +210,7 @@ public: if (failed) return -1; bool playon = decoder.RunFrame(clock); twod->ClearScreen(); - DrawTexture(twod, decoder.animTex().GetFrame(), 0, 0, DTA_FullscreenEx, 3, TAG_DONE); + DrawTexture(twod, decoder.animTex().GetFrame(), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); return skiprequest ? -1 : playon ? 1 : 0; } @@ -285,7 +285,7 @@ public: } if (fullscreenScale) { - DrawTexture(twod, animtex.GetFrame(), 0, 0, DTA_FullscreenEx, 3, TAG_DONE); + DrawTexture(twod, animtex.GetFrame(), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); } else { diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index f000b6768..cafbcb6cb 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -137,21 +137,21 @@ void InitFonts_d() static void BigText(double x, double y, const char* text, double alpha = 1.) { auto width = BigFont->StringWidth(text); - DrawText(twod, BigFont, CR_UNTRANSLATED, x - width / 2, y - 12, text, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Alpha, alpha, TAG_DONE); + DrawText(twod, BigFont, CR_UNTRANSLATED, x - width / 2, y - 12, text, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Alpha, alpha, TAG_DONE); } static void GameText(double x, double y, const char* t, int shade, int align = -1, int trans = 0) { if (align != -1) x -= SmallFont->StringWidth(t) * (align == 0 ? 0.5 : 1); - DrawText(twod, SmallFont, CR_UNDEFINED, x, y + 2, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, shadeToLight(shade), TAG_DONE); + DrawText(twod, SmallFont, CR_UNDEFINED, x, y + 2, t, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, shadeToLight(shade), TAG_DONE); } static void MiniText(double x, double y, const char* t, int shade, int align = -1, int trans = 0) { if (align != -1) x -= SmallFont2->StringWidth(t) * (align == 0 ? 0.5 : 1); - DrawText(twod, SmallFont2, CR_UNDEFINED, x, y, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, shadeToLight(shade), TAG_DONE); + DrawText(twod, SmallFont2, CR_UNDEFINED, x, y, t, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, shadeToLight(shade), TAG_DONE); } //--------------------------------------------------------------------------- @@ -172,7 +172,7 @@ public: const int translation = TRANSLATION(Translation_BasePalettes, DREALMSPAL); twod->ClearScreen(); - DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); return skiprequest ? -1 : clock < duration ? 1 : 0; } }; @@ -198,7 +198,7 @@ public: auto translation = TRANSLATION(Translation_BasePalettes, TITLEPAL); twod->ClearScreen(); - DrawTexture(twod, tileGetTexture(BETASCREEN, true), 0, 0, DTA_FullscreenEx, 3, DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DrawTexture(twod, tileGetTexture(BETASCREEN, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); if (soundanm == 0 && clock >= 120 && clock < 120 + 60) { @@ -223,19 +223,19 @@ public: double scale = clamp(clock - 120, 0, 60) / 64.; if (scale > 0.) - DrawTexture(twod, tileGetTexture(DUKENUKEM, true), 160, 104, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DrawTexture(twod, tileGetTexture(DUKENUKEM, true), 160, 104, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); scale = clamp(clock - 220, 0, 30) / 32.; if (scale > 0.) - DrawTexture(twod, tileGetTexture(THREEDEE, true), 160, 129, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DrawTexture(twod, tileGetTexture(THREEDEE, true), 160, 129, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); if (PLUTOPAK) { scale = (410 - clamp(clock, 280, 395)) / 16.; if (scale > 0. && clock > 280) - DrawTexture(twod, tileGetTexture(PLUTOPAKSPRITE+1, true), 160, 151, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DrawTexture(twod, tileGetTexture(PLUTOPAKSPRITE+1, true), 160, 151, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); } @@ -315,7 +315,7 @@ public: uint64_t span = nsclock / 1'000'000; twod->ClearScreen(); - DrawTexture(twod, tileGetTexture(VICTORY1, true), 0, 50, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DrawTexture(twod, tileGetTexture(VICTORY1, true), 0, 50, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, DTA_TopLeft, true, TAG_DONE); @@ -329,7 +329,7 @@ public: S_PlaySound(SQUISHED, CHAN_AUTO, CHANF_UI); bonuscnt++; } - DrawTexture(twod, tileGetTexture(bossmove[t + 2], true), bossmove[t + 3], bossmove[t + 4], DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DrawTexture(twod, tileGetTexture(bossmove[t + 2], true), bossmove[t + 3], bossmove[t + 4], DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, translation, DTA_TopLeft, true, TAG_DONE); } @@ -338,7 +338,7 @@ public: { if (totalclock >= 750) { - DrawTexture(twod, tileGetTexture(VICTORY1 + 8, true), 86, 59, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DrawTexture(twod, tileGetTexture(VICTORY1 + 8, true), 86, 59, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, translation, DTA_TopLeft, true, TAG_DONE); if (totalclock >= 750 && bonuscnt == 2) { @@ -354,7 +354,7 @@ public: S_PlaySound(BOSSTALKTODUKE, CHAN_AUTO, CHANF_UI); bonuscnt++; } - DrawTexture(twod, tileGetTexture(breathe[t + 2], true), breathe[t + 3], breathe[t + 4], DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DrawTexture(twod, tileGetTexture(breathe[t + 2], true), breathe[t + 3], breathe[t + 4], DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TranslationIndex, translation, DTA_TopLeft, true, TAG_DONE); } } @@ -674,10 +674,10 @@ public: char tempbuf[32]; int totalclock = int(clock * 120 / 1'000'000'000); twod->ClearScreen(); - DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); - DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); if (PLUTOPAK) - DrawTexture(twod, tileGetTexture(PLUTOPAKSPRITE+2, true), 260, 36, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(PLUTOPAKSPRITE+2, true), 260, 36, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); GameText(160, 58 + 2, GStrings("Multiplayer Totals"), 0, 0); GameText(160, 58 + 10, currentLevel->DisplayName(), 0, 0); @@ -877,7 +877,7 @@ public: if (clock == 0) S_PlayBonusMusic(); twod->ClearScreen(); int totalclock = int(clock * 120 / 1'000'000'000); - DrawTexture(twod, tileGetTexture(gfx_offset, true), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DrawTexture(twod, tileGetTexture(gfx_offset, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); if (lastmapname) BigText(160, 20 - 6, lastmapname); BigText(160, 36 - 6, GStrings("Completed")); @@ -911,11 +911,11 @@ public: case 1: case 4: case 5: - DrawTexture(twod, tileGetTexture(gfx_offset + 3), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(gfx_offset + 3), 199, 31, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); break; case 2: case 3: - DrawTexture(twod, tileGetTexture(gfx_offset + 4), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(gfx_offset + 4), 199, 31, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); break; } } @@ -926,10 +926,10 @@ public: { case 1: case 3: - DrawTexture(twod, tileGetTexture(gfx_offset + 1), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(gfx_offset + 1), 199, 31, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); break; case 2: - DrawTexture(twod, tileGetTexture(gfx_offset + 2), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(gfx_offset + 2), 199, 31, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); break; } } @@ -1050,7 +1050,7 @@ public: int Frame(uint64_t clock, bool skiprequest) { - DrawTexture(twod, tileGetTexture(LOADSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DrawTexture(twod, tileGetTexture(LOADSCREEN), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); BigText(160, 90, (rec->flags & MI_USERMAP)? GStrings("TXT_LOADUM") : GStrings("TXT_LOADING")); BigText(160, 114, rec->DisplayName()); diff --git a/source/games/duke/src/2d_r.cpp b/source/games/duke/src/2d_r.cpp index ccadeab6d..33f057358 100644 --- a/source/games/duke/src/2d_r.cpp +++ b/source/games/duke/src/2d_r.cpp @@ -136,7 +136,7 @@ static void BigText(double x, double y, const char* text, int align, double alph if (align != -1) x -= BigFont->StringWidth(text) * (align == 0 ? 0.2 : 0.4); auto width = BigFont->StringWidth(text); - DrawText(twod, BigFont, CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.4, DTA_ScaleY, 0.4, DTA_Alpha, alpha, TAG_DONE); + DrawText(twod, BigFont, CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.4, DTA_ScaleY, 0.4, DTA_Alpha, alpha, TAG_DONE); } static void GameText(double x, double y, const char* t, int shade, int align = -1, int trans = 0) @@ -144,7 +144,7 @@ static void GameText(double x, double y, const char* t, int shade, int align = - x *= 2; y *= 2; if (align != -1) x -= SmallFont->StringWidth(t) * (align == 0 ? 0.5 : 1); - DrawText(twod, SmallFont, CR_UNDEFINED, x, y + 2, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, shadeToLight(shade), TAG_DONE); + DrawText(twod, SmallFont, CR_UNDEFINED, x, y + 2, t, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, shadeToLight(shade), TAG_DONE); } static void MiniText(double x, double y, const char* t, int shade, int align = -1, int trans = 0) @@ -152,7 +152,7 @@ static void MiniText(double x, double y, const char* t, int shade, int align = - x *= 2; y *= 2; if (align != -1) x -= SmallFont2->StringWidth(t) * (align == 0 ? 0.5 : 1); - DrawText(twod, SmallFont2, CR_UNDEFINED, x, y, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, shadeToLight(shade), TAG_DONE); + DrawText(twod, SmallFont2, CR_UNDEFINED, x, y, t, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, shadeToLight(shade), TAG_DONE); } //--------------------------------------------------------------------------- @@ -265,9 +265,9 @@ public: if (clock == 0) S_PlayBonusMusic(); char tempbuf[32]; twod->ClearScreen(); - DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); double scale = 0.36; - DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, DTA_ScaleX, scale, DTA_ScaleY, 0.36, TAG_DONE); GameText(160, 58, GStrings("Multiplayer Totals"), 0, 0); @@ -470,7 +470,7 @@ public: if (clock == 0) S_PlayBonusMusic(); twod->ClearScreen(); int totalclock = int(clock * 120 / 1'000'000'000); - DrawTexture(twod, tileGetTexture(gfx_offset, true), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DrawTexture(twod, tileGetTexture(gfx_offset, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); if (lastmapname) BigText(80, 16, lastmapname, -1); BigText(15, 192, GStrings("PRESSKEY"), -1); @@ -534,7 +534,7 @@ public: { int totalclock = int(clock * 120 / 1'000'000'000); auto tex = tileGetTexture(RRTILE8677 + ((totalclock >> 4) & 1)); - DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, TAG_DONE); + DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); if (!S_CheckSoundPlaying(-1, 35) && totalclock > 15*120) return 0; // make sure it stays, even if sound is off. if (skiprequest) { @@ -608,7 +608,7 @@ public: int Frame(uint64_t clock, bool skiprequest) { - DrawTexture(twod, tileGetTexture(LOADSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DrawTexture(twod, tileGetTexture(LOADSCREEN), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); int y = isRRRA()? 140 : 90; BigText(160, y, (rec->flags & MI_USERMAP) ? GStrings("TXT_ENTRUM") : GStrings("TXT_ENTERIN"), 0); diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index 6b56eae9b..ce5c42453 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -53,7 +53,7 @@ BEGIN_DUKE_NS static void Menu_DrawBackground(const DVector2 &origin) { - DrawTexture(twod, tileGetTexture(TILE_MENUSCREEN), origin.X + 160, origin.Y + 100, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff808080, DTA_CenterOffset, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_MENUSCREEN), origin.X + 160, origin.Y + 100, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff808080, DTA_CenterOffset, true, TAG_DONE); } //---------------------------------------------------------------------------- @@ -70,7 +70,7 @@ static void Menu_DrawCursor(double x, double y, double scale, bool right) else picnum = TILE_SPINNINGNUKEICON + frames - 1 - ((frames - 1 + ((int)totalclock >> 3)) % frames); int light = int(224 + 31 * sin((int)totalclock / 20.)); PalEntry pe(255, light, light, light); - DrawTexture(twod, tileGetTexture(picnum), x, y, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffsetRel, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(picnum), x, y, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffsetRel, true, TAG_DONE); } //---------------------------------------------------------------------------- @@ -141,20 +141,20 @@ class DukeMainMenu : public DukeListMenu double x = origin.X + 160; if (isRRRA()) { - DrawTexture(twod, tileGetTexture(TILE_THREEDEE), x-5, origin.Y+57, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.253, DTA_ScaleY, 0.253, DTA_CenterOffsetRel, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_THREEDEE), x-5, origin.Y+57, DTA_FullscreenScale, FSMode_ScaleToFit43Top, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.253, DTA_ScaleY, 0.253, DTA_CenterOffsetRel, true, TAG_DONE); } else if (isRR()) { - DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x+5, origin.Y + 24, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.36, DTA_ScaleY, 0.36, DTA_CenterOffsetRel, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x+5, origin.Y + 24, DTA_FullscreenScale, FSMode_ScaleToFit43Top, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.36, DTA_ScaleY, 0.36, DTA_CenterOffsetRel, true, TAG_DONE); } else { - DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x, origin.Y + 29, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x, origin.Y + 29, DTA_FullscreenScale, FSMode_ScaleToFit43Top, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); if (PLUTOPAK) { int light = 224 + 31 * sin(int(totalclock) / 40.); PalEntry pe(255, light, light, light); - DrawTexture(twod, tileGetTexture(TILE_PLUTOPAKSPRITE + 2), x + 100, origin.Y + 36, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, pe, DTA_CenterOffsetRel, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_PLUTOPAKSPRITE + 2), x + 100, origin.Y + 36, DTA_FullscreenScale, FSMode_ScaleToFit43Top, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, pe, DTA_CenterOffsetRel, true, TAG_DONE); } } @@ -194,7 +194,7 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, double oxpos, dou pe = 0xffa0a0a0; } - DrawText(twod, BigFont, CR_UNDEFINED, xpos, ypos, text, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, + DrawText(twod, BigFont, CR_UNDEFINED, xpos, ypos, text, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_TranslationIndex, trans, TAG_DONE); if (state == NIT_SelectedState) @@ -321,7 +321,7 @@ FSavegameInfo GameInterface::GetSaveSig() void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text) { - DrawTexture(twod, tileGetTexture(TILE_MENUBAR), origin.X + 160, origin.Y + 19, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff808080, DTA_CenterOffsetRel, 1, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_MENUBAR), origin.X + 160, origin.Y + 19, DTA_FullscreenScale, FSMode_ScaleToFit43Top, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff808080, DTA_CenterOffsetRel, 1, TAG_DONE); FString t = text; size_t newlen = t.Len(); @@ -330,7 +330,7 @@ void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text) t.Truncate(newlen); double scale = isRR() ? 0.4 : 1.0; double x = 160 + origin.X - BigFont->StringWidth(t) * scale * 0.5; - DrawText(twod, BigFont, CR_UNTRANSLATED, x, origin.Y + 12, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); + DrawText(twod, BigFont, CR_UNTRANSLATED, x, origin.Y + 12, t, DTA_FullscreenScale, FSMode_ScaleToFit43Top, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); } void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position, bool bg) diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 501c5fdbb..b5359312c 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -180,7 +180,7 @@ void drawbackground(void) auto tex = tileGetTexture(TILE_MENUSCREEN); PalEntry color = 0xff808080; if (!hud_bgstretch) - DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, DTA_Color, color, TAG_DONE); + DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Color, color, TAG_DONE); else DrawTexture(twod, tex, 0, 0, DTA_VirtualWidth, twod->GetWidth(), DTA_VirtualHeight, twod->GetHeight(), DTA_KeepRatio, true, DTA_Color, color, TAG_DONE); } @@ -359,7 +359,7 @@ void displayrest(double smoothratio) if (isRR()) crosshair_scale *= .5; DrawTexture(twod, tileGetTexture(a), 160 - getHalfLookAng(screenpeek, cl_syncinput, smoothratio), 100, - DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, crosshair_scale, DTA_ScaleY, crosshair_scale, DTA_CenterOffsetRel, true, + DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, crosshair_scale, DTA_ScaleY, crosshair_scale, DTA_CenterOffsetRel, true, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, TAG_DONE); } } @@ -658,9 +658,9 @@ void drawoverheadmap(int cposx, int cposy, int czoom, int cang) int top = isRR() ? 0 : (hud_size < 11 ? 147 : 179); if (!(currentLevel->flags & MI_USERMAP)) DrawText(twod, SmallFont2, CR_UNDEFINED, 5, top+6, GStrings.localize(gVolumeNames[volfromlevelnum(currentLevel->levelNumber)]), - DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); + DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); DrawText(twod, SmallFont2, CR_UNDEFINED, 5, top + 12, currentLevel->DisplayName(), - DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); + DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); } } @@ -676,7 +676,7 @@ void cameratext(int i) auto drawitem = [=](int tile, double x, double y, bool flipx, bool flipy) { DrawTexture(twod, tileGetTexture(tile), x, y, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_CenterOffsetRel, true, - DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, DTA_FlipX, flipx, DTA_FlipY, flipy, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); + DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, DTA_FlipX, flipx, DTA_FlipY, flipy, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); }; if (!hittype[i].temp_data[0]) { diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index b6104dd11..72f955c9e 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -71,7 +71,7 @@ void DDukeCommonStatusBar::displayfragbar(void) auto tex = tileGetTexture(TILE_FRAGBAR); for (int y = 0; y < 32; y += 8) - DrawTexture(twod, tex, 0, 0, DTA_FullscreenScale, 3, DTA_ViewportWidth, 320, DTA_ViewportHeight, 200, DTA_ScaleX, 1.001, DTA_ScaleY, 1.001, TAG_Done); + DrawTexture(twod, tex, 0, 0, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_ViewportWidth, 320, DTA_ViewportHeight, 200, DTA_ScaleX, 1.001, DTA_ScaleY, 1.001, TAG_Done); for (i = connecthead; i >= 0; i = connectpoint2[i]) { diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 39a5ad84a..16bb3937a 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -533,25 +533,27 @@ void precacheMarkedTiles() } } -void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dashade, int dapalnum, int dastat) +void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha) { double dz = z / 65536.; - int light = Scale(numshades - clamp(dashade, 0, numshades - 1), 255, numshades); - PalEntry pe(255, light, light, light); + alpha *= (dastat & RS_TRANS1)? glblend[0].def[!!(dastat & RS_TRANS2)].alpha : 1.; + DrawTexture(&twodpsp, tileGetTexture(picnum, true), sx, sy, DTA_ScaleX, dz, DTA_ScaleY, dz, - DTA_Color, pe, + DTA_Color, shadeToLight(dashade), DTA_TranslationIndex, TRANSLATION(Translation_Remap + curbasepal, dapalnum), DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, - DTA_FullscreenScale, (dastat & RS_STRETCH)? 4: 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DTA_FullscreenScale, (dastat & RS_STRETCH)? FSMode_ScaleToScreen: FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, !(dastat & (RS_TOPLEFT | RS_CENTER)), DTA_TopLeft, !!(dastat & RS_TOPLEFT), DTA_CenterOffset, !!(dastat & RS_CENTER), - DTA_FlipX, !!(dastat & RS_YFLIP), // the weapon drawer uses y-flip+180° rotation for x-flip but no other transformation. + DTA_FlipX, !!(dastat & RS_XFLIPHUD), + DTA_FlipY, !!(dastat & RS_YFLIPHUD), DTA_Pin, (dastat & RS_ALIGN_R) ? 1 : (dastat & RS_ALIGN_L) ? -1 : 0, DTA_Rotate, a * (-360./2048), DTA_FlipOffsets, !(dastat & (/*RS_TOPLEFT |*/ RS_CENTER)), + DTA_Alpha, alpha, TAG_DONE); } diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 2a33e7bec..5ed5e2b38 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -363,4 +363,4 @@ void renderBeginScene(); void renderFinishScene(); void DrawRateStuff(); -void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dashade, int dapalnum, int dastat); +void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha = 1); diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index d7aff221f..6016ba7be 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -42,9 +42,11 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "weapon.h" #include "menu.h" #include "raze_sound.h" +#include "glbackend/glbackend.h" BEGIN_SW_NS + int InitSwordAttack(PLAYERp pp); PANEL_SPRITEp InitWeaponUziSecondaryReload(PANEL_SPRITEp); PANEL_SPRITEp InitWeaponUzi2(PANEL_SPRITEp); @@ -58,19 +60,6 @@ int InitGrenade(PLAYERp pp); int InitMine(PLAYERp pp); int InitFistAttack(PLAYERp pp); - -#pragma message("delete me") -enum -{ - PANEL_BOX_Y = (174 - 6), - -}; - - - - -//#define UK_VERSION TRUE - #define PANF_UZI_XFLIP (BIT(21)) #define XDIM 320 @@ -187,27 +176,6 @@ SWBOOL pKillScreenSpiteIDs(PLAYERp pp, short id) // Used to sprites in the view at correct aspect ratio and x,y location. -PANEL_SPRITEp pSpawnFullViewSprite(PLAYERp pp, short pic, short pri, int x, int y) -{ - PANEL_SPRITEp nsp; - - if ((nsp = pFindMatchingSprite(pp, x, y, pri)) == NULL) - { - nsp = pSpawnSprite(pp, NULL, pri, x, y); - } - - nsp->numpages = numpages; - nsp->picndx = -1; - nsp->picnum = pic; - nsp->x1 = 0; - nsp->y1 = 0; - nsp->x2 = xdim - 1; - nsp->y2 = ydim - 1; - SET(nsp->flags, PANF_STATUS_AREA | PANF_SCREEN_CLIP); - - return nsp; -} - void pSetSuicide(PANEL_SPRITEp psp) { //SET(psp->flags, PANF_SUICIDE); @@ -419,9 +387,6 @@ void PlayerUpdateWeapon(PLAYERp pp, short WeaponNum) void PlayerUpdateKills(PLAYERp pp, short value) { -#define PANEL_KILLS_X 31 -#define PANEL_KILLS_Y 164 - if (Prediction) return; @@ -6992,10 +6957,7 @@ pDisplaySprites(PLAYERp pp) uint8_t pal = 0; short ang; int flags; - int x1,y1,x2,y2; - PspTwoDSetter set; - set.clear(); TRAVERSE(&pp->PanelSpriteList, psp, next) { ang = psp->rotate_ang; @@ -7122,7 +7084,6 @@ pDisplaySprites(PLAYERp pp) // if its a weapon sprite and the view is set to the outside don't draw the sprite if (TEST(psp->flags, PANF_WEAPON_SPRITE)) { - set.set(); SECT_USERp sectu = nullptr; int16_t floorshade = 0; if (pp->cursectnum >= 0) @@ -7165,7 +7126,6 @@ pDisplaySprites(PLAYERp pp) if (sectu && TEST(sectu->flags, SECTFU_DONT_COPY_PALETTE)) pal = 0; } - else set.clear(); SET(flags, ROTATE_SPRITE_VIEW_CLIP); @@ -7177,35 +7137,9 @@ pDisplaySprites(PLAYERp pp) if (TEST(psp->flags, PANF_CORNER)) SET(flags, ROTATE_SPRITE_CORNER); - if (TEST(psp->flags, PANF_STATUS_AREA)) - { - SET(flags,ROTATE_SPRITE_CORNER); - RESET(flags,ROTATE_SPRITE_VIEW_CLIP); - - if (TEST(psp->flags, PANF_SCREEN_CLIP)) - SET(flags, ROTATE_SPRITE_SCREEN_CLIP); - - if (TEST(psp->flags, PANF_IGNORE_START_MOST)) - SET(flags, ROTATE_SPRITE_IGNORE_START_MOST); - - x1 = psp->x1; - y1 = psp->y1; - x2 = psp->x2; - y2 = psp->y2; - shade = psp->shade; - } - else - { - x1 = windowxy1.x; - y1 = windowxy1.y; - x2 = windowxy2.x; - y2 = windowxy2.y; - } - if ((psp->State && TEST(psp->State->flags, psf_Xflip)) || TEST(psp->flags, PANF_XFLIP)) { - // this is what you have to do to x-flip - ang = NORM_ANGLE(ang + 1024); + // Build has no xflip, so it uses yflip plus rotation. We don't need the rotation here. SET(flags, ROTATE_SPRITE_YFLIP); } @@ -7252,19 +7186,16 @@ pDisplaySprites(PLAYERp pp) case BLOODYFIST3_SWING0: case BLOODYFIST3_SWING1: case BLOODYFIST3_SWING2: - if (TEST(flags, BIT(2)) && x > 160) + if (TEST(flags, ROTATE_SPRITE_YFLIP) && x > 160) x = 65; - else if (!TEST(flags, BIT(2)) && x < 160) + else if (!TEST(flags, ROTATE_SPRITE_YFLIP) && x < 160) x = 345; break; default: break; } - rotatesprite(x << 16, y << 16, - psp->scale, ang, - picnum, shade, pal, - flags, x1, y1, x2, y2); + hud_drawsprite(x, y, psp->scale, ang, picnum, shade, pal, flags); // do overlays (if any) for (i = 0; i < SIZ(psp->over); i++) @@ -7284,10 +7215,7 @@ pDisplaySprites(PLAYERp pp) if (picnum) { - rotatesprite((x + psp->over[i].xoff) << 16, (y + psp->over[i].yoff) << 16, - psp->scale, ang, - picnum, overlay_shade, pal, - flags, x1, y1, x2, y2); + hud_drawsprite((x + psp->over[i].xoff), (y + psp->over[i].yoff), psp->scale, ang, picnum, overlay_shade, pal, flags); } } } diff --git a/source/sw/src/panel.h b/source/sw/src/panel.h index f3a23a88d..610fd0ac3 100644 --- a/source/sw/src/panel.h +++ b/source/sw/src/panel.h @@ -79,7 +79,6 @@ struct PANEL_STATEstruct #define PANF_INVISIBLE (BIT(9)) // turn invisible #define PANF_DEATH_HIDE (BIT(10)) // hide done when dead #define PANF_SCREEN_CLIP (BIT(12)) // maintain aspect to the screen -#define PANF_STATUS_AREA (BIT(13)) // maintain aspect to the screen #define PANF_IGNORE_START_MOST (BIT(14)) // maintain aspect to the screen #define PANF_XFLIP (BIT(15)) // xflip #define PANF_SUICIDE (BIT(16)) // kill myself @@ -184,7 +183,6 @@ enum BorderTypes #define SHOTGUN_AUTO 2078 PANEL_SPRITEp pSpawnSprite(PLAYERp pp, PANEL_STATEp state, uint8_t priority, int x, int y); -PANEL_SPRITEp pSpawnFullViewSprite(PLAYERp pp,short pic,short pri,int x,int y); void pSetSuicide(PANEL_SPRITEp psp); SWBOOL pKillScreenSpiteIDs(PLAYERp pp, short id); void PreUpdatePanel(void); diff --git a/source/sw/src/text.cpp b/source/sw/src/text.cpp index 755ca081e..671fddd06 100644 --- a/source/sw/src/text.cpp +++ b/source/sw/src/text.cpp @@ -128,6 +128,8 @@ void PutStringTimer(PLAYERp pp, short x, short y, const char *string, short seco id = ID_TEXT; } + // Temporarily disabled because this uses a feature of the panel system that needs to be removed before this can be refactored. +#if 0 for (ndx = 0; (c = string[ndx]) != 0; ndx++) { ac = c - '!' + STARTALPHANUM; @@ -145,6 +147,7 @@ void PutStringTimer(PLAYERp pp, short x, short y, const char *string, short seco else if (c == asc_Space) offset += 4; // Special case for space char } +#endif } void KillString(PLAYERp pp, short y)