- started replacing rotatesprite with DrawTexture.

As an added bonus, thia now allows stretching the menu caption box for longer texts, rotatesprite could not do that.
This commit is contained in:
Christoph Oelckers 2020-07-31 20:39:02 +02:00
parent f0e0a3db41
commit b308e730ea
5 changed files with 43 additions and 27 deletions

View file

@ -976,7 +976,7 @@ static void gameTicker()
static void drawBackground() static void drawBackground()
{ {
twod->ClearScreen(); twod->ClearScreen();
rotatesprite(160 << 16, 100 << 16, 65536, 0, 2518, 0, 0, 0x4a, 0, 0, xdim - 1, ydim - 1); DrawTexture(twod, tileGetTexture(2518), 0, 0, DTA_FullscreenEx, 3, TAG_DONE);
if (gQuitRequest && !gQuitGame) if (gQuitRequest && !gQuitGame)
netBroadcastMyLogoff(gQuitRequest == 2); netBroadcastMyLogoff(gQuitRequest == 2);
} }

View file

@ -269,10 +269,17 @@ FSavegameInfo GameInterface::GetSaveSig()
void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text) void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text)
{ {
int height; int height, width;
// font #1, tile #2038. // font #1, tile #2038.
viewGetFontInfo(1, NULL, NULL, &height);
rotatesprite(int(origin.X * 65536) + (320 << 15), 20 << 16, 65536, 0, 2038, -128, 0, 78, 0, 0, xdim - 1, ydim - 1); viewGetFontInfo(1, text, &width, &height);
double scalex = 1.; // Expand the box if the text is longer
int boxwidth = tileWidth(2038);
if (boxwidth - 10 < width) scalex = double(width) / (boxwidth - 10);
DrawTexture(twod, tileGetTexture(2038), 160, 20, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, DTA_ScaleX, scalex, TAG_DONE);
viewDrawText(1, text, 160, 20 - height / 2, -128, 0, 1, false); viewDrawText(1, text, 160, 20 - height / 2, -128, 0, 1, false);
} }

View file

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else! #include "ns.h" // Must come before everything else!
#include "build.h" #include "build.h"
#include "v_draw.h"
#include "common.h" #include "common.h"
#include "mmulti.h" #include "mmulti.h"
#include "common_game.h" #include "common_game.h"
@ -54,7 +55,7 @@ void CEndGameMgr::Draw(void)
viewLoadingScreenWide(); viewLoadingScreenWide();
int nHeight; int nHeight;
viewGetFontInfo(1, NULL, NULL, &nHeight); viewGetFontInfo(1, NULL, NULL, &nHeight);
rotatesprite(160<<16, 20<<16, 65536, 0, 2038, -128, 0, 6, 0, 0, xdim-1, ydim-1); DrawTexture(twod, tileGetTexture(2038), 160, 20, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE);
int nY = 20 - nHeight / 2; int nY = 20 - nHeight / 2;
if (gGameOptions.nGameType == 0) if (gGameOptions.nGameType == 0)
{ {

View file

@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "map2d.h" #include "map2d.h"
#include "view.h" #include "view.h"
#include "v_2ddrawer.h" #include "v_2ddrawer.h"
#include "v_draw.h"
BEGIN_BLD_NS BEGIN_BLD_NS
@ -156,8 +157,11 @@ void sub_2541C(int x, int y, int z, short a)
int nScale = mulscale((pSprite->yrepeat+((floorZ-nBottom)>>8))*z, yxaspect, 16); int nScale = mulscale((pSprite->yrepeat+((floorZ-nBottom)>>8))*z, yxaspect, 16);
nScale = ClipRange(nScale, 8000, 65536<<1); nScale = ClipRange(nScale, 8000, 65536<<1);
// Players on automap // Players on automap
rotatesprite((xdim<<15)+(x1<<4), (ydim<<15)+(y1<<4), nScale, pa, nTile, pSprite->shade, pSprite->pal, (pSprite->cstat&2)>>1, double x = xdim/2. + x1 / double(1<<12);
windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y); double y = ydim/2. + y1 / double(1<<12);
// This very likely needs fixing later
DrawTexture(twod, tileGetTexture(nTile), x, y, DTA_FullscreenScale, 3, 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);
} }
} }
} }

View file

@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "common_game.h" #include "common_game.h"
#include "qav.h" #include "qav.h"
#include "sound.h" #include "sound.h"
#include "v_draw.h"
BEGIN_BLD_NS BEGIN_BLD_NS
@ -47,32 +48,35 @@ int qavRegisterClient(void(*pClient)(int, void *))
void DrawFrame(F2DDrawer *twod, int x, int y, TILE_FRAME *pTile, int stat, int shade, int palnum, int basepal, bool to3dview) void DrawFrame(F2DDrawer *twod, int x, int y, TILE_FRAME *pTile, int stat, int shade, int palnum, int basepal, bool to3dview)
{ {
stat |= pTile->stat; stat |= pTile->stat;
int angle = pTile->angle; x += pTile->x;
if (stat & 0x100) y += pTile->y;
{ auto tex = tileGetTexture(pTile->picnum);
angle = (angle+1024)&2047; double scale = pTile->z/65536.;
stat &= ~0x100; double angle = pTile->angle * (360./2048);
stat ^= 0x4; int renderstyle = (stat & RS_NOMASK)? STYLE_Normal : STYLE_Translucent;
} double alpha = (stat & RS_TRANS1)? glblend[0].def[!!(stat & RS_TRANS2)].alpha : 1.;
if (stat & kQavOrientationLeft) int pin = (stat & kQavOrientationLeft)? -1 : (stat & RS_ALIGN_R)? 1:0;
{ if (palnum <= 0) palnum = pTile->palnum;
stat &= ~kQavOrientationLeft; auto translation = TRANSLATION(Translation_Remap + basepal, palnum);
stat |= 256; bool topleft = !!(stat & RS_TOPLEFT);
}
if (palnum <= 0) bool xflip = !!(stat & 0x100); // repurposed flag
palnum = pTile->palnum; bool yflip = !!(stat & RS_YFLIP);
shade = clamp(pTile->shade + shade, 0, numshades-1);
int light = ::scale(numshades-1-shade, 255, numshades-1);
PalEntry color(255,light,light,light);
if (!to3dview) if (!to3dview)
{ {
twod_rotatesprite(twod, (x + pTile->x) << 16, (y + pTile->y) << 16, pTile->z, angle, 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,
pTile->picnum, ClipRange(pTile->shade + shade, -128, 127), palnum, stat, DTA_TopLeft, topleft, DTA_CenterOffsetRel, !topleft, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_FlipOffsets, !topleft, DTA_Color, color,
0, 0, 0, 0, twod->GetWidth(), twod->GetHeight(), nullptr, basepal); DTA_FlipX, xflip, DTA_FlipY, yflip, TAG_DONE);
} }
else else
{ {
twod_rotatesprite(twod, (x + pTile->x) << 16, (y + pTile->y) << 16, pTile->z, angle, 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,
pTile->picnum, ClipRange(pTile->shade + shade, -128, 127), palnum, stat, DTA_TopLeft, topleft, DTA_CenterOffsetRel, !topleft, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_FlipOffsets, !topleft, DTA_Color, color,
0, 0, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y, nullptr, basepal); 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);
} }
} }