diff --git a/src/common/2d/v_draw.cpp b/src/common/2d/v_draw.cpp index cdf4413f8..6a02f0a32 100644 --- a/src/common/2d/v_draw.cpp +++ b/src/common/2d/v_draw.cpp @@ -410,7 +410,15 @@ void CalcFullscreenScale(DrawParms *parms, double srcwidth, double srcheight, in } } -DEFINE_ACTION_FUNCTION(_Screen, GetFullscreenRect) +void GetFullscreenRect(double width, double height, int fsmode, DoubleRect* rect) +{ + DrawParms parms; + parms.viewport.width = twod->GetWidth(); + parms.viewport.height = twod->GetHeight(); + CalcFullscreenScale(&parms, width, height, fsmode, *rect); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Screen, GetFullscreenRect, GetFullscreenRect) { PARAM_PROLOGUE; PARAM_FLOAT(virtw); diff --git a/src/common/2d/v_draw.h b/src/common/2d/v_draw.h index b7eafbbec..49ca81ed3 100644 --- a/src/common/2d/v_draw.h +++ b/src/common/2d/v_draw.h @@ -254,6 +254,8 @@ template void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms); bool SetTextureParms(F2DDrawer *drawer, DrawParms* parms, FGameTexture* img, double x, double y); +void GetFullscreenRect(double width, double height, int fsmode, DoubleRect* rect); + void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char* string, int tag_first, ...); void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char32_t* string, int tag_first, ...); void DrawChar(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, int character, int tag_first, ...); diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index d52b2ebcc..74cd0bb87 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -713,55 +713,98 @@ void DIntermissionScreenScroller::Drawer () { auto tex = TexMan.GetGameTexture(mFirstPic); auto tex2 = TexMan.GetGameTexture(mSecondPic); - if (mTicker >= mScrollDelay && mTicker < mScrollDelay + mScrollTime && tex != NULL && tex2 != NULL) + //if (mTicker >= mScrollDelay && mTicker < mScrollDelay + mScrollTime && tex != nullptr && tex2 != nullptr) { // These must round down to the nearest full pixel to cover seams between the two textures. int fwidth = (int)tex->GetDisplayWidth(); int fheight = (int)tex->GetDisplayHeight(); + int fwidth2 = (int)tex2->GetDisplayWidth(); + int fheight2 = (int)tex2->GetDisplayHeight(); double xpos1 = 0, ypos1 = 0, xpos2 = 0, ypos2 = 0; - switch (mScrollDir) + if (mScrollDir == SCROLL_Left || mScrollDir == SCROLL_Right) { - case SCROLL_Up: - ypos1 = double(mTicker - mScrollDelay) * fheight / mScrollTime; - ypos2 = ypos1 - fheight; - break; + // guesstimate the intended aspect ratio. + int aheight = fheight == 200 ? 240 : fheight == 400 ? 480 : fheight; + int awidth = aheight * 4 / 3; + int atotalwidth = fwidth + fwidth2; + int sidespace = (atotalwidth - 2*awidth); + // Now set a clipping rectangle for the intended viewport + double displayratio = atotalwidth / double(aheight) - 4./3.; + double displaywidth = aheight * displayratio; + DoubleRect drect; + GetFullscreenRect(displaywidth, aheight, FSMode_ScaleToFit43, &drect); + twod->SetClipRect(int(drect.left), int(drect.top), int(drect.width), int(drect.height)); - case SCROLL_Down: - ypos1 = -double(mTicker - mScrollDelay) * fheight / mScrollTime; - ypos2 = ypos1 + fheight; - break; + int ticker = clamp(mTicker - mScrollDelay, 0, mScrollTime); - case SCROLL_Left: - default: - xpos1 = double(mTicker - mScrollDelay) * fwidth / mScrollTime; - xpos2 = xpos1 - fwidth; - break; + switch (mScrollDir) + { + case SCROLL_Left: + default: + xpos2 = -awidth + double(ticker) * awidth / mScrollTime; + xpos1 = xpos2 + fwidth2; + break; - case SCROLL_Right: - xpos1 = -double(mTicker - mScrollDelay) * fwidth / mScrollTime; - xpos2 = xpos1 + fwidth; - break; + case SCROLL_Right: + xpos1 = -double(ticker) * awidth / mScrollTime; + xpos2 = xpos1 + fwidth; + break; + } + double scale = drect.height / aheight; + xpos1 *= scale; + xpos2 *= scale; + + DrawTexture(twod, tex, xpos1 + drect.left, drect.top, + DTA_DestWidthF, fwidth * scale, + DTA_DestHeightF, aheight * scale, + DTA_Masked, false, + TAG_DONE); + DrawTexture(twod, tex2, xpos2 + drect.left, drect.top, + DTA_DestWidthF, fwidth2 * scale, + DTA_DestHeightF, aheight * scale, + DTA_Masked, false, + TAG_DONE); + + + twod->ClearClipRect(); } + else + { + switch (mScrollDir) + { + case SCROLL_Up: + default: + ypos1 = double(mTicker - mScrollDelay) * fheight / mScrollTime; + ypos2 = ypos1 - fheight; + break; - DrawTexture(twod, tex, xpos1, ypos1, - DTA_VirtualWidth, fwidth, - DTA_VirtualHeight, fheight, - DTA_Masked, false, - TAG_DONE); - DrawTexture(twod, tex2, xpos2, ypos2, - DTA_VirtualWidth, fwidth, - DTA_VirtualHeight, fheight, - DTA_Masked, false, - TAG_DONE); + case SCROLL_Down: + ypos1 = -double(mTicker - mScrollDelay) * fheight / mScrollTime; + ypos2 = ypos1 + fheight; + break; + } + DrawTexture(twod, tex, xpos1, ypos1, + DTA_VirtualWidth, fwidth, + DTA_VirtualHeight, fheight, + DTA_Masked, false, + TAG_DONE); + DrawTexture(twod, tex2, xpos2, ypos2, + DTA_VirtualWidth, fwidth, + DTA_VirtualHeight, fheight, + DTA_Masked, false, + TAG_DONE); + } mBackground = mSecondPic; } + /* else { Super::Drawer(); } + */ }