From 6760a3bfe98ec659639668e6859874908f6ff8bf Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 21 Jul 2012 02:32:04 +0000 Subject: [PATCH] - Fixed: hud_scale is supposed use strictly integral scaling factors. SVN r3776 (trunk) --- src/g_shared/sbarinfo.cpp | 49 +++++++------------- src/g_shared/sbarinfo.h | 2 + src/g_shared/shared_sbar.cpp | 1 - src/v_video.cpp | 87 ++++++++++++++++++++---------------- src/v_video.h | 1 + 5 files changed, 68 insertions(+), 72 deletions(-) diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index 99158f568..1640899a2 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -149,6 +149,8 @@ class SBarInfoCommand virtual void Reset() {} virtual void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) {} + SBarInfo *GetScript() { return script; } + protected: void GetCoordinates(FScanner &sc, bool fullScreenOffsets, SBarInfoCoordinate &x, SBarInfoCoordinate &y) { @@ -798,6 +800,8 @@ void SBarInfo::Init() spacingAlignment = ALIGN_CENTER; resW = 320; resH = 200; + cleanX = -1; + cleanY = -1; for(unsigned int i = 0;i < NUMHUDS;i++) huds[i] = new SBarInfoMainBlock(this); @@ -987,9 +991,18 @@ public: Images.Uninit(); } + void ScreenSizeChanged() + { + V_CalcCleanFacs(script->resW, script->resH, SCREENWIDTH, SCREENHEIGHT, &script->cleanX, &script->cleanY); + } + void Draw (EHudState state) { DBaseStatusBar::Draw(state); + if (script->cleanX <= 0) + { // Calculate cleanX and cleanY + ScreenSizeChanged(); + } int hud = STBAR_NORMAL; if(state == HUD_StatusBar) { @@ -1245,8 +1258,8 @@ public: { double rx, ry, rcx=0, rcy=0, rcr=INT_MAX, rcb=INT_MAX; - double xScale = !hud_scale ? 1.0 : (double) CleanXfac*320.0/(double) script->resW;//(double) SCREENWIDTH/(double) script->resW; - double yScale = !hud_scale ? 1.0 : (double) CleanYfac*200.0/(double) script->resH;//(double) SCREENHEIGHT/(double) script->resH; + double xScale = !hud_scale ? 1 : script->cleanX; + double yScale = !hud_scale ? 1 : script->cleanY; adjustRelCenter(x.RelCenter(), y.RelCenter(), dx, dy, rx, ry, xScale, yScale); @@ -1278,34 +1291,6 @@ public: rcy = cy == 0 ? 0 : ry+(((double) cy/FRACUNIT)*yScale); rcr = cr == 0 ? INT_MAX : rx+w-(((double) cr/FRACUNIT)*xScale); rcb = cb == 0 ? INT_MAX : ry+h-(((double) cb/FRACUNIT)*yScale); - - // Fix the clipping for fullscreenoffsets. - /*if(ry < 0) - { - if(rcy != 0) - rcy = hud_scale ? SCREENHEIGHT + (int) (rcy*CleanYfac*200.0/script->resH) : SCREENHEIGHT + rcy; - if(rcb != INT_MAX) - rcb = hud_scale ? SCREENHEIGHT + (int) (rcb*CleanYfac*200.0/script->resH) : SCREENHEIGHT + rcb; - } - else if(hud_scale) - { - rcy *= (int) (CleanYfac*200.0/script->resH); - if(rcb != INT_MAX) - rcb *= (int) (CleanYfac*200.0/script->resH); - } - if(rx < 0) - { - if(rcx != 0) - rcx = hud_scale ? SCREENWIDTH + (int) (rcx*CleanXfac*320.0/script->resW) : SCREENWIDTH + rcx; - if(rcr != INT_MAX) - rcr = hud_scale ? SCREENWIDTH + (int) (rcr*CleanXfac*320.0/script->resW) : SCREENWIDTH + rcr; - } - else if(hud_scale) - { - rcx *= (int) (CleanXfac*320.0/script->resW); - if(rcr != INT_MAX) - rcr *= (int) (CleanXfac*320.0/script->resW); - }*/ } if(clearDontDraw) @@ -1365,8 +1350,8 @@ public: { if(hud_scale) { - xScale = (double) CleanXfac*320.0/(double) script->resW;//(double) SCREENWIDTH/(double) script->resW; - yScale = (double) CleanYfac*200.0/(double) script->resH;//(double) SCREENWIDTH/(double) script->resW; + xScale = script->cleanX; + yScale = script->cleanY; } adjustRelCenter(x.RelCenter(), y.RelCenter(), *x, *y, ax, ay, xScale, yScale); } diff --git a/src/g_shared/sbarinfo.h b/src/g_shared/sbarinfo.h index d2d81f1f7..1b92b1d80 100644 --- a/src/g_shared/sbarinfo.h +++ b/src/g_shared/sbarinfo.h @@ -108,6 +108,8 @@ struct SBarInfo FMugShot MugShot; int resW; int resH; + int cleanX; + int cleanY; int GetGameType() { return gameType; } void ParseSBarInfo(int lump); diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 57a0d9106..f7054fe22 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -70,7 +70,6 @@ EXTERN_CVAR (Bool, am_showitems) EXTERN_CVAR (Bool, am_showtime) EXTERN_CVAR (Bool, am_showtotaltime) EXTERN_CVAR (Bool, noisedebug) -EXTERN_CVAR (Bool, hud_scale) EXTERN_CVAR (Int, con_scaletext) DBaseStatusBar *StatusBar; diff --git a/src/v_video.cpp b/src/v_video.cpp index 310ca5b2e..ad850f6f4 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1324,10 +1324,7 @@ CCMD(clean) bool V_DoModeSetup (int width, int height, int bits) { DFrameBuffer *buff = I_SetMode (width, height, screen); - int ratio; - int cwidth; - int cheight; - int cx1, cy1, cx2, cy2; + int cx1, cx2; if (buff == NULL) { @@ -1342,41 +1339,7 @@ bool V_DoModeSetup (int width, int height, int bits) // if D3DFB is being used for the display. FFont::StaticPreloadFonts(); - ratio = CheckRatio (width, height); - if (ratio & 4) - { - cwidth = width; - cheight = height * BaseRatioSizes[ratio][3] / 48; - } - else - { - cwidth = width * BaseRatioSizes[ratio][3] / 48; - cheight = height; - } - // Use whichever pair of cwidth/cheight or width/height that produces less difference - // between CleanXfac and CleanYfac. - cx1 = MAX(cwidth / 320, 1); - cy1 = MAX(cheight / 200, 1); - cx2 = MAX(width / 320, 1); - cy2 = MAX(height / 200, 1); - if (abs(cx1 - cy1) <= abs(cx2 - cy2)) - { // e.g. 640x360 looks better with this. - CleanXfac = cx1; - CleanYfac = cy1; - } - else - { // e.g. 720x480 looks better with this. - CleanXfac = cx2; - CleanYfac = cy2; - } - - if (CleanXfac > 1 && CleanYfac > 1 && CleanXfac != CleanYfac) - { - if (CleanXfac < CleanYfac) - CleanYfac = CleanXfac; - else - CleanXfac = CleanYfac; - } + V_CalcCleanFacs(320, 200, width, height, &CleanXfac, &CleanYfac, &cx1, &cx2); CleanWidth = width / CleanXfac; CleanHeight = height / CleanYfac; @@ -1426,6 +1389,52 @@ bool V_DoModeSetup (int width, int height, int bits) return true; } +void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *_cx1, int *_cx2) +{ + int ratio; + int cwidth; + int cheight; + int cx1, cy1, cx2, cy2; + + ratio = CheckRatio(realwidth, realheight); + if (ratio & 4) + { + cwidth = realwidth; + cheight = realheight * BaseRatioSizes[ratio][3] / 48; + } + else + { + cwidth = realwidth * BaseRatioSizes[ratio][3] / 48; + cheight = realheight; + } + // Use whichever pair of cwidth/cheight or width/height that produces less difference + // between CleanXfac and CleanYfac. + cx1 = MAX(cwidth / designwidth, 1); + cy1 = MAX(cheight / designheight, 1); + cx2 = MAX(realwidth / designwidth, 1); + cy2 = MAX(realheight / designheight, 1); + if (abs(cx1 - cy1) <= abs(cx2 - cy2)) + { // e.g. 640x360 looks better with this. + *cleanx = cx1; + *cleany = cy1; + } + else + { // e.g. 720x480 looks better with this. + *cleanx = cx2; + *cleany = cy2; + } + + if (*cleanx > 1 && *cleany > 1 && *cleanx != *cleany) + { + if (*cleanx < *cleany) + *cleany = *cleanx; + else + *cleanx = *cleany; + } + if (_cx1 != NULL) *_cx1 = cx1; + if (_cx2 != NULL) *_cx2 = cx2; +} + bool IVideo::SetResolution (int width, int height, int bits) { int oldwidth, oldheight; diff --git a/src/v_video.h b/src/v_video.h index 6aee6d203..f6a1caeba 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -46,6 +46,7 @@ extern int CleanWidth_1, CleanHeight_1, CleanXfac_1, CleanYfac_1; extern int DisplayWidth, DisplayHeight, DisplayBits; bool V_DoModeSetup (int width, int height, int bits); +void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *cx1=NULL, int *cx2=NULL); class FTexture;