diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index cf677771a3..440de41dd0 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -215,6 +215,7 @@ class FMugShot FMugShot(); void Grin(bool grin=true) { bEvilGrin = grin; } + void Reset(); void Tick(player_t *player); bool SetState(const char *state_name, bool wait_till_done=false, bool reset=false); int UpdateState(player_t *player, StateFlags stateflags=STANDARD); @@ -275,7 +276,7 @@ public: ST_DEADFACE = ST_GODFACE + 1 }; - DBaseStatusBar (int reltop); + DBaseStatusBar (int reltop, int hres=320, int vres=200); void Destroy (); void SetScaled (bool scale, bool force=false); @@ -338,6 +339,7 @@ public: int ST_X, ST_Y; int RelTop; + int HorizontalResolution, VirticalResolution; bool Scaled; bool Centering; bool FixedOrigin; diff --git a/src/g_shared/sbar_mugshot.cpp b/src/g_shared/sbar_mugshot.cpp index 73d469eac4..cecae1df33 100644 --- a/src/g_shared/sbar_mugshot.cpp +++ b/src/g_shared/sbar_mugshot.cpp @@ -221,6 +221,17 @@ int FindMugShotStateIndex(FName state) //=========================================================================== FMugShot::FMugShot() +{ + Reset(); +} + +//=========================================================================== +// +// FMugShot :: Reset +// +//=========================================================================== + +void FMugShot::Reset() { FaceHealth = -1; bEvilGrin = false; diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index 9e424c0985..a359fb3cb1 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -190,8 +190,8 @@ class SBarInfoCommand } } - if(!fullScreenOffsets) - y.SetCoord((negative ? -sc.Number : sc.Number) - (200 - script->height)); + //if(!fullScreenOffsets) + // y.SetCoord((negative ? -sc.Number : sc.Number) - (200 - script->height)); } EColorRange GetTranslation(FScanner &sc) { @@ -367,6 +367,7 @@ enum //Key words SBARINFO_COMPLETEBORDER, SBARINFO_MONOSPACEFONTS, SBARINFO_LOWERHEALTHCAP, + SBARINFO_RESOLUTION, SBARINFO_STATUSBAR, SBARINFO_MUGSHOT, SBARINFO_CREATEPOPUP, @@ -394,6 +395,7 @@ static const char *SBarInfoTopLevel[] = "completeborder", "monospacefonts", "lowerhealthcap", + "resolution", "statusbar", "mugshot", "createpopup", @@ -579,6 +581,14 @@ void SBarInfo::ParseSBarInfo(int lump) } sc.MustGetToken(';'); break; + case SBARINFO_RESOLUTION: + sc.MustGetToken(TK_IntConst); + resW = sc.Number; + sc.MustGetToken(','); + sc.MustGetToken(TK_IntConst); + resH = sc.Number; + sc.MustGetToken(';'); + break; case SBARINFO_STATUSBAR: { if(!baseSet) //If the user didn't explicitly define a base, do so now. @@ -761,6 +771,8 @@ void SBarInfo::Init() armorInterpolationSpeed = 8; height = 0; spacingCharacter = '\0'; + resW = 320; + resH = 200; for(unsigned int i = 0;i < NUMHUDS;i++) huds[i] = new SBarInfoMainBlock(this); @@ -902,7 +914,7 @@ class DSBarInfo : public DBaseStatusBar { DECLARE_CLASS(DSBarInfo, DBaseStatusBar) public: - DSBarInfo (SBarInfo *script=NULL) : DBaseStatusBar(script->height), + DSBarInfo (SBarInfo *script=NULL) : DBaseStatusBar(script->height, script->resW, script->resH), ammo1(NULL), ammo2(NULL), ammocount1(0), ammocount2(0), armor(NULL), pendingPopup(POP_None), currentPopup(POP_None), lastHud(-1), lastInventoryBar(NULL), lastPopup(NULL) @@ -1110,7 +1122,7 @@ public: fixed_t tmp = 0; // I'll handle the conversion from fixed to int myself for more control fixed_t fx = (x + ST_X).Coordinate() << FRACBITS; - fixed_t fy = (y + ST_Y).Coordinate() << FRACBITS; + fixed_t fy = (y + ST_Y - (Scaled ? script->resH : 200) + script->height).Coordinate() << FRACBITS; fixed_t fw = (forceWidth <= -1 ? texture->GetScaledWidth() : forceWidth) << FRACBITS; fixed_t fh = (forceHeight <= -1 ? texture->GetScaledHeight() : forceHeight) << FRACBITS; fixed_t fcx = cx == 0 ? 0 : fx + cx - (texture->GetScaledLeftOffset() << FRACBITS); @@ -1120,10 +1132,16 @@ public: if(Scaled) { if(cx != 0 || cy != 0) - screen->VirtualToRealCoordsFixed(fcx, fcy, tmp, tmp, 320, 200, true); + screen->VirtualToRealCoordsFixed(fcx, fcy, tmp, tmp, script->resW, script->resH, true); if(cr != 0 || cb != 0 || clearDontDraw) - screen->VirtualToRealCoordsFixed(fcr, fcb, tmp, tmp, 320, 200, true); - screen->VirtualToRealCoordsFixed(fx, fy, fw, fh, 320, 200, true); + screen->VirtualToRealCoordsFixed(fcr, fcb, tmp, tmp, script->resW, script->resH, true); + screen->VirtualToRealCoordsFixed(fx, fy, fw, fh, script->resW, script->resH, true); + } + else + { + fy += (200 - script->resH)<resH)<resH)<>1)) >> FRACBITS; @@ -1173,10 +1191,26 @@ public: int rx, ry, rcx=0, rcy=0, rcr=INT_MAX, rcb=INT_MAX; ADJUST_RELCENTER(x,y,rx,ry) + // We can't use DTA_HUDRules since it forces a width and height. + // Translation: No high res. + bool xright = rx < 0; + bool ybot = ry < 0; + w = (forceWidth <= -1 ? texture->GetScaledWidth() : forceWidth); h = (forceHeight <= -1 ? texture->GetScaledHeight() : forceHeight); if(vid_fps && rx < 0 && ry >= 0) ry += 10; + if(hud_scale) + { + rx *= CleanXfac * 320.0/script->resW; + ry *= CleanYfac * 200.0/script->resH; + w *= CleanXfac * 320.0/script->resW; + h *= CleanYfac * 200.0/script->resH; + } + if(xright) + rx = SCREENWIDTH + rx; + if(ybot) + ry = SCREENHEIGHT + ry; // Check for clipping if(cx != 0 || cy != 0 || cr != 0 || cb != 0) @@ -1189,34 +1223,34 @@ public: if(ry < 0) { if(rcy != 0) - rcy = hud_scale ? SCREENHEIGHT + (rcy*CleanYfac) : SCREENHEIGHT + rcy; + rcy = hud_scale ? SCREENHEIGHT + (rcy*CleanYfac*200.0/script->resH) : SCREENHEIGHT + rcy; if(rcb != INT_MAX) - rcb = hud_scale ? SCREENHEIGHT + (rcb*CleanYfac) : SCREENHEIGHT + rcb; + rcb = hud_scale ? SCREENHEIGHT + (rcb*CleanYfac*200.0/script->resH) : SCREENHEIGHT + rcb; } else if(hud_scale) { - rcy *= CleanYfac; + rcy *= CleanYfac*200.0/script->resH; if(rcb != INT_MAX) - rcb *= CleanYfac; + rcb *= CleanYfac*200.0/script->resH; } if(rx < 0) { if(rcx != 0) - rcx = hud_scale ? SCREENWIDTH + (rcx*CleanXfac) : SCREENWIDTH + rcx; + rcx = hud_scale ? SCREENWIDTH + (rcx*CleanXfac*320.0/script->resW) : SCREENWIDTH + rcx; if(rcr != INT_MAX) - rcr = hud_scale ? SCREENWIDTH + (rcr*CleanXfac) : SCREENWIDTH + rcr; + rcr = hud_scale ? SCREENWIDTH + (rcr*CleanXfac*320.0/script->resW) : SCREENWIDTH + rcr; } else if(hud_scale) { - rcx *= CleanXfac; + rcx *= CleanXfac*320.0/script->resW; if(rcr != INT_MAX) - rcr *= CleanXfac; + rcr *= CleanXfac*320.0/script->resW; } } if(clearDontDraw) { - screen->Clear(rcx, rcy, MIN(rcr, w*(hud_scale ? CleanXfac : 1)), MIN(rcb, h*(hud_scale ? CleanYfac : 1)), GPalette.BlackIndex, 0); + screen->Clear(rcx, rcy, MIN(rcr, w), MIN(rcb, h), GPalette.BlackIndex, 0); } else { @@ -1232,7 +1266,6 @@ public: DTA_Translation, translate ? GetTranslation() : 0, DTA_ColorOverlay, dim ? DIM_OVERLAY : 0, DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM, - DTA_HUDRules, HUD_Normal, DTA_Alpha, alpha, DTA_AlphaChannel, alphaMap, DTA_FillColor, 0, @@ -1250,7 +1283,6 @@ public: DTA_Translation, translate ? GetTranslation() : 0, DTA_ColorOverlay, dim ? DIM_OVERLAY : 0, DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM, - DTA_HUDRules, HUD_Normal, DTA_Alpha, alpha, TAG_DONE); } @@ -1297,9 +1329,13 @@ public: if(!fullScreenOffsets) { rx += ST_X; - ry += ST_Y; + ry += ST_Y - (Scaled ? script->resH : 200) + script->height; if(Scaled) - screen->VirtualToRealCoordsInt(rx, ry, rw, rh, 320, 200, true); + screen->VirtualToRealCoordsInt(rx, ry, rw, rh, script->resW, script->resH, true); + else + { + ry += (200 - script->resH); + } } else { @@ -1340,12 +1376,26 @@ public: } else { + bool xright = rx < 0; + bool ybot = ry < 0; + + if(hud_scale) + { + rx *= CleanXfac * 320.0/script->resW; + ry *= CleanYfac * 200.0/script->resH; + rw *= CleanXfac * 320.0/script->resW; + rh *= CleanYfac * 200.0/script->resH; + } + if(xright) + rx = SCREENWIDTH + rx; + if(ybot) + ry = SCREENHEIGHT + ry; + screen->DrawTexture(character, rx, ry, DTA_DestWidth, rw, DTA_DestHeight, rh, DTA_Translation, font->GetColorTranslation(translation), DTA_Alpha, alpha, - DTA_HUDRules, HUD_Normal, TAG_DONE); } if(script->spacingCharacter == '\0') diff --git a/src/g_shared/sbarinfo.h b/src/g_shared/sbarinfo.h index 03aae3434c..9952e21a8a 100644 --- a/src/g_shared/sbarinfo.h +++ b/src/g_shared/sbarinfo.h @@ -98,6 +98,8 @@ struct SBarInfo int height; int gameType; FMugShot MugShot; + int resW; + int resH; int GetGameType() { return gameType; } void ParseSBarInfo(int lump); diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 6d8982c409..f5dcf198e3 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -1175,6 +1175,10 @@ class CommandDrawMugShot : public SBarInfoCommand GetCoordinates(sc, fullScreenOffsets, x, y); sc.MustGetToken(';'); } + void Reset() + { + script->MugShot.Reset(); + } protected: FString defaultFace; //Deprecated diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 96074390c0..8c04738323 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -175,7 +175,7 @@ void ST_LoadCrosshair(bool alwaysload) // //--------------------------------------------------------------------------- -DBaseStatusBar::DBaseStatusBar (int reltop) +DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres) { Centering = false; FixedOrigin = false; @@ -185,6 +185,8 @@ DBaseStatusBar::DBaseStatusBar (int reltop) Displacement = 0; CPlayer = NULL; ShowLog = false; + HorizontalResolution = hres; + VirticalResolution = vres; SetScaled (st_scale); } @@ -216,18 +218,20 @@ void DBaseStatusBar::Destroy () //--------------------------------------------------------------------------- //[BL] Added force argument to have forcescaled mean forcescaled. +// - Also, if the VirticalResolution is something other than the default (200) +// We should always obey the value of scale. void DBaseStatusBar::SetScaled (bool scale, bool force) { - Scaled = (RelTop != 0 || force) && (SCREENWIDTH != 320 && scale); + Scaled = (RelTop != 0 || force) && ((SCREENWIDTH != 320 || HorizontalResolution != 320) && scale); if (!Scaled) { - ST_X = (SCREENWIDTH - 320) / 2; + ST_X = (SCREENWIDTH - HorizontalResolution) / 2; ST_Y = SCREENHEIGHT - RelTop; ::ST_Y = ST_Y; if (RelTop > 0) { - Displacement = ((ST_Y * 200 / SCREENHEIGHT) - (200 - RelTop))*FRACUNIT/RelTop; + Displacement = ((ST_Y * VirticalResolution / SCREENHEIGHT) - (VirticalResolution - RelTop))*FRACUNIT/RelTop; } else { @@ -237,14 +241,14 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) else { ST_X = 0; - ST_Y = 200 - RelTop; + ST_Y = VirticalResolution - RelTop; if (CheckRatio(SCREENWIDTH, SCREENHEIGHT) != 4) { // Normal resolution - ::ST_Y = Scale (ST_Y, SCREENHEIGHT, 200); + ::ST_Y = Scale (ST_Y, SCREENHEIGHT, VirticalResolution); } else { // 5:4 resolution - ::ST_Y = Scale(ST_Y - 100, SCREENHEIGHT*3, BaseRatioSizes[4][1]) + SCREENHEIGHT/2 + ::ST_Y = Scale(ST_Y - VirticalResolution/2, SCREENHEIGHT*3, Scale(VirticalResolution, BaseRatioSizes[4][1], 200)) + SCREENHEIGHT/2 + (SCREENHEIGHT - SCREENHEIGHT * BaseRatioSizes[4][3] / 48) / 2; } Displacement = 0; @@ -1000,7 +1004,7 @@ void DBaseStatusBar::RefreshBackground () const if (x > 0) { y = x == ST_X ? ST_Y : ::ST_Y; - x2 = !(ratio & 3) || !Scaled ? ST_X+320 : + x2 = !(ratio & 3) || !Scaled ? ST_X+HorizontalResolution : SCREENWIDTH - (SCREENWIDTH*(48-BaseRatioSizes[ratio][3])+48*2-1)/(48*2); R_DrawBorder (0, y, x, SCREENHEIGHT); R_DrawBorder (x2, y, SCREENWIDTH, SCREENHEIGHT);