- adapt the bunny scroller to widescreen images.

This only concerns the actual horizontal scroller. The vertical one still needs work and the "The End" screen only works if the second picture of the scroller is the full widescreen image because this page is done as a regular single image page which does not know anything about widescreen asset replacements.
This commit is contained in:
Christoph Oelckers 2020-10-24 15:31:45 +02:00
parent 30e71c7c16
commit e1af278b37
3 changed files with 83 additions and 30 deletions

View file

@ -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);

View file

@ -254,6 +254,8 @@ template<class T>
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, ...);

View file

@ -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();
}
*/
}