diff --git a/src/am_map.cpp b/src/am_map.cpp index f4382f0fd5..721bd3650e 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -790,6 +790,7 @@ static double mapystart=0; // y-value for the start of the map bitmap...used in static double mapxstart=0; //x-value for the bitmap. static bool stopped = true; +static int viewbottom; static void AM_calcMinMaxMtoF(); @@ -1062,7 +1063,7 @@ static void AM_findMinMaxBoundaries () static void AM_calcMinMaxMtoF() { double a = SCREENWIDTH / max_w; - double b = gST_Y / max_h; + double b = viewbottom / max_h; min_scale_mtof = a < b ? a : b; max_scale_mtof = SCREENHEIGHT / (2*PLAYERRADIUS); @@ -1420,7 +1421,7 @@ void AM_NewResolution() else if (scale_mtof > max_scale_mtof) AM_maxOutWindowScale(); f_w = screen->GetWidth(); - f_h = gST_Y; + f_h = viewbottom; AM_activateNewScale(); } @@ -3160,7 +3161,7 @@ void AM_drawCrosshair (const AMColor &color) // //============================================================================= -void AM_Drawer () +void AM_Drawer (int bottom) { if (!automapactive) return; @@ -3168,6 +3169,7 @@ void AM_Drawer () bool allmap = (level.flags2 & LEVEL2_ALLMAP) != 0; bool allthings = allmap && players[consoleplayer].mo->FindInventory(NAME_PowerScanner, true) != nullptr; + viewbottom = bottom; if (am_portaloverlay) { sector_t *sec; @@ -3184,7 +3186,7 @@ void AM_Drawer () // and view size adjustments. f_x = f_y = 0; f_w = screen->GetWidth (); - f_h = gST_Y; + f_h = viewbottom; f_p = screen->GetPitch (); AM_clearFB(AMColors[AMColors.Background]); diff --git a/src/am_map.h b/src/am_map.h index fd9079c1e3..8bf9b08c22 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -37,7 +37,7 @@ void AM_Ticker (void); // Called by main loop, // called instead of view drawer if automap active. -void AM_Drawer (void); +void AM_Drawer (int bottom); // Called to force the automap to quit // if the level is completed while it is up. diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp index c49e95f578..ac026143ea 100644 --- a/src/ct_chat.cpp +++ b/src/ct_chat.cpp @@ -31,6 +31,7 @@ #include "templates.h" #include "d_net.h" #include "d_event.h" +#include "sbar.h" #define QUEUESIZE 128 #define MESSAGESIZE 128 @@ -236,19 +237,10 @@ void CT_Drawer (void) scalex = 1; } - int screen_width, screen_height, st_y; - if (active_con_scaletext() == 0) - { - screen_width = SCREENWIDTH; - screen_height = SCREENHEIGHT; - st_y = gST_Y; - } - else - { - screen_width = SCREENWIDTH / active_con_scaletext(); - screen_height = SCREENHEIGHT / active_con_scaletext(); - st_y = gST_Y / active_con_scaletext(); - } + int scale = active_con_scaletext(); + int screen_width = SCREENWIDTH / scale; + int screen_height= SCREENHEIGHT / scale; + int st_y = StatusBar->GetTopOfStatusbar() / scale; y += ((SCREENHEIGHT == viewheight && viewactive) || gamestate != GS_LEVEL) ? screen_height : st_y; diff --git a/src/d_main.cpp b/src/d_main.cpp index 22ba39cfe4..2ba45fe1d4 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -160,7 +160,6 @@ EXTERN_CVAR (Bool, sv_unlimited_pickup) extern int testingmode; extern bool setmodeneeded; extern int NewWidth, NewHeight, NewBits, DisplayBits; -EXTERN_CVAR (Bool, st_scale) extern bool gameisdead; extern bool demorecording; extern bool M_DemoNoPlay; // [RH] if true, then skip any demos in the loop @@ -790,13 +789,7 @@ void D_Display () screen->DrawBlendingRect(); if (automapactive) { - int saved_ST_Y = gST_Y; - if (hud_althud && viewheight == SCREENHEIGHT) - { - gST_Y = viewheight; - } - AM_Drawer (); - gST_Y = saved_ST_Y; + AM_Drawer (hud_althud? viewheight : StatusBar->GetTopOfStatusbar()); } if (!automapactive || viewactive) { diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index 95f170a85a..5515cd96c3 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -490,7 +490,6 @@ bool wipe_ScreenWipe (int ticks) return true; // do a piece of wipe-in - V_MarkRect(0, 0, SCREENWIDTH, SCREENHEIGHT); rc = (*wipes[(CurrentWipeType-1)*3+1])(ticks); return rc; diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index c27977b1b2..1cb0ffb7ff 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -357,7 +357,7 @@ public: }; DBaseStatusBar (); - void SetSize(int reltop = 32, int hres = 320, int vres = 200); + void SetSize(int reltop = 32, int hres = 320, int vres = 200, int hhres = -1, int hvres = -1); void OnDestroy() override; void AttachMessage (DHUDMessage *msg, uint32_t id=0, int layer=HUDMSGLayer_Default); @@ -373,8 +373,7 @@ public: // do not make this a DObject Serialize function because it's not used like one! void SerializeMessages(FSerializer &arc); - virtual void SetScaled(bool scale, bool force = false); - void CallSetScaled(bool scale, bool force = false); + void SetScale(); virtual void Tick (); void CallTick(); virtual void Draw (EHudState state); @@ -399,11 +398,14 @@ public: void DrawString(FFont *font, const FString &cstring, double x, double y, int flags, double Alpha, int translation, int spacing, bool monospaced, int shadowX, int shadowY); void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0); - void BeginStatusBar(int resW, int resH, int relTop, bool completeborder = false, bool forceScaled = false); + void BeginStatusBar(int resW, int resH, int relTop, bool forceScaled); void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false); void ForceHUDScale(bool on) { ForcedScale = on; } // This is for SBARINFO which should not use BeginStatusBar or BeginHUD. void StatusbarToRealCoords(double &x, double &y, double &w, double &h) const; - double GetTopOfStatusbar() const; + int GetTopOfStatusbar() const + { + return SBarTop; + } //protected: void DrawPowerups (); @@ -417,7 +419,10 @@ public: void DrawCrosshair (); // Sizing info for ths status bar. - int ST_X, ST_Y; + int ST_X; + int ST_Y; + int SBarTop; + DVector2 SBarScale; int RelTop; int HorizontalResolution, VerticalResolution; bool Scaled; // This needs to go away. @@ -446,8 +451,16 @@ private: void DrawMessages (int layer, int bottom); void DrawConsistancy () const; void DrawWaiting () const; + void SetDrawSize(int reltop, int hres, int vres); TObjPtr Messages[NUM_HUDMSGLAYERS]; + + int BaseRelTop; + int BaseSBarHorizontalResolution; + int BaseSBarVerticalResolution; + int BaseHUDHorizontalResolution; + int BaseHUDVerticalResolution; + }; extern DBaseStatusBar *StatusBar; diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index a28205ae26..9fcd0c48bd 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -973,7 +973,7 @@ public: DSBarInfo (DBaseStatusBar *wrapper, SBarInfo *script=NULL) : ammo1(NULL), ammo2(NULL), ammocount1(0), ammocount2(0), armor(NULL), pendingPopup(DBaseStatusBar::POP_None), currentPopup(DBaseStatusBar::POP_None), lastHud(-1), - scalingWasForced(false), lastInventoryBar(NULL), lastPopup(NULL) + lastInventoryBar(NULL), lastPopup(NULL) { this->script = script; this->wrapper = wrapper; @@ -1032,14 +1032,7 @@ public: } if(script->huds[hud]->ForceScaled()) //scale the statusbar { - if(script->huds[hud]->FullScreenOffsets()) - wrapper->ForceHUDScale(true); - else if(!wrapper->Scaled) - { - scalingWasForced = true; - wrapper->SetScaled(true, true); - setsizeneeded = true; - } + wrapper->ForceHUDScale(true); } if (CPlayer->ReadyWeapon != NULL) @@ -1067,14 +1060,8 @@ public: if(hud != lastHud) { script->huds[hud]->Tick(NULL, this, true); - // Restore scaling if need be. - if(scalingWasForced) - { - scalingWasForced = false; - wrapper->SetScaled(false); - setsizeneeded = true; - } + wrapper->ForceHUDScale(false); } if(currentPopup != DBaseStatusBar::POP_None && !script->huds[hud]->FullScreenOffsets()) @@ -1478,7 +1465,6 @@ private: int pendingPopup; int currentPopup; int lastHud; - bool scalingWasForced; SBarInfoMainBlock *lastInventoryBar; SBarInfoMainBlock *lastPopup; }; @@ -1487,30 +1473,9 @@ private: void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha) { // Popups can also be forced to scale - bool rescale = false; - if(ForceScaled()) - { - if(FullScreenOffsets()) - { - rescale = true; - statusBar->wrapper->ForceHUDScale(true); - } - else if(!statusBar->wrapper->Scaled) - { - rescale = true; - statusBar->wrapper->SetScaled(true, true); - } - } - + if(ForceScaled()) statusBar->wrapper->ForceHUDScale(true); Draw(block, statusBar, xOffset, yOffset, alpha); - - if(rescale) - { - if(FullScreenOffsets()) - statusBar->wrapper->ForceHUDScale(false); - else - statusBar->wrapper->SetScaled(false); - } + statusBar->wrapper->ForceHUDScale(false); } #include "sbarinfo_commands.cpp" diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 78394038b7..adec61bf5d 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -92,8 +92,6 @@ DBaseStatusBar *StatusBar; extern int setblocks; -int gST_Y; - FTexture *CrosshairImage; static int CrosshairNum; @@ -108,11 +106,24 @@ CVAR (Flag, pf_ice, paletteflash, PF_ICE) CVAR (Flag, pf_hazard, paletteflash, PF_HAZARD) // Stretch status bar to full screen width? -CUSTOM_CVAR (Bool, st_scale, true, CVAR_ARCHIVE) +CUSTOM_CVAR (Int, st_scale, -1, CVAR_ARCHIVE) +{ + if (self < -1) + { + self = -1; + return; + } + if (StatusBar) + { + StatusBar->SetScale(); + setsizeneeded = true; + } +} +CUSTOM_CVAR(Bool, st_aspectscale, false, CVAR_ARCHIVE) { if (StatusBar) { - StatusBar->CallSetScaled (self); + StatusBar->SetScale(); setsizeneeded = true; } } @@ -339,7 +350,17 @@ DBaseStatusBar::DBaseStatusBar () defaultScale = { (double)CleanXfac, (double)CleanYfac }; } -void DBaseStatusBar::SetSize(int reltop, int hres, int vres) +void DBaseStatusBar::SetSize(int reltop, int hres, int vres, int hhres, int hvres) +{ + BaseRelTop = reltop; + BaseSBarHorizontalResolution = hres; + BaseSBarVerticalResolution = vres; + BaseHUDHorizontalResolution = hhres < 0? hres : hhres; + BaseHUDVerticalResolution = hvres < 0? vres : hvres; + SetDrawSize(reltop, hres, vres); +} + +void DBaseStatusBar::SetDrawSize(int reltop, int hres, int vres) { RelTop = reltop; HorizontalResolution = hres; @@ -348,16 +369,19 @@ void DBaseStatusBar::SetSize(int reltop, int hres, int vres) V_CalcCleanFacs(hres, vres, SCREENWIDTH, SCREENHEIGHT, &x, &y); defaultScale = { (double)x, (double)y }; - CallSetScaled(st_scale); + SetScale(); // recalculate positioning info. } + DEFINE_ACTION_FUNCTION(DBaseStatusBar, SetSize) { PARAM_SELF_PROLOGUE(DBaseStatusBar); - PARAM_INT_DEF(rt); - PARAM_INT_DEF(vw); - PARAM_INT_DEF(vh); - self->SetSize(rt, vw, vh); + PARAM_INT(rt); + PARAM_INT(vw); + PARAM_INT(vh); + PARAM_INT_DEF(hvw); + PARAM_INT_DEF(hvh); + self->SetSize(rt, vw, vh, hvw, hvh); return 0; } @@ -390,62 +414,58 @@ void DBaseStatusBar::OnDestroy () // //--------------------------------------------------------------------------- -//[BL] Added force argument to have forcescaled mean forcescaled. -// - Also, if the VerticalResolution is something other than the default (200) -// We should always obey the value of scale. -void DBaseStatusBar::SetScaled (bool scale, bool force) +void DBaseStatusBar::SetScale () { - Scaled = (RelTop != 0 || force) && ((SCREENWIDTH != 320 || HorizontalResolution != 320) && scale); - - if (!Scaled) + int w = SCREENWIDTH; + int h = SCREENHEIGHT; + if (st_scale == -1) { - ST_X = (SCREENWIDTH - HorizontalResolution) / 2; - ST_Y = SCREENHEIGHT - RelTop; - gST_Y = ST_Y; + // This is the classic fullscreen scale with aspect ratio compensation. + int sby = VerticalResolution - RelTop; + float aspect = ActiveRatio(w, h); + if (!AspectTallerThanWide(aspect)) + { + // Wider or equal than 4:3 + SBarTop = Scale(sby, h, VerticalResolution); + double width4_3 = w * 1.333 / aspect; + ST_X = int((w - width4_3) / 2); + } + else + { // 5:4 resolution + ST_X = 0; + + // this was far more obtuse before... + double height4_3 = h * aspect / 1.333; + SBarTop = int(h - height4_3 + sby * height4_3 / VerticalResolution); + } + Displacement = 0; + SBarScale.X = -1; + ST_Y = 0; + } + else + { + // Since status bars and HUDs can be designed for non 320x200 screens this needs to be factored in here. + // The global scaling factors are for resources at 320x200, so if the actual ones are higher resolution + // the resulting scaling factor needs to be reduced accordingly. + + int newscale = (st_scale > 0) ? *st_scale : *uiscale; + int realscale = clamp((320 * st_scale) / HorizontalResolution, 1, w / HorizontalResolution); // do not scale wider than the screen. + double realscaley = realscale * (st_aspectscale ? 1.2 : 1.); + + ST_X = (w - HorizontalResolution * realscale) / 2; + SBarTop = int(h - RelTop * realscaley); if (RelTop > 0) { - Displacement = double((ST_Y * VerticalResolution / SCREENHEIGHT) - (VerticalResolution - RelTop))/RelTop; + Displacement = double((SBarTop * VerticalResolution / h) - (VerticalResolution - RelTop))/RelTop/realscaley; } else { Displacement = 0; } + SBarScale.X = realscale; + SBarScale.Y = realscaley; + ST_Y = int(h - VerticalResolution * realscaley); } - else - { - ST_X = 0; - ST_Y = VerticalResolution - RelTop; - float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT); - if (!AspectTallerThanWide(aspect)) - { // Normal resolution - gST_Y = Scale (ST_Y, SCREENHEIGHT, VerticalResolution); - } - else - { // 5:4 resolution - gST_Y = Scale(ST_Y - VerticalResolution/2, SCREENHEIGHT*3, Scale(VerticalResolution, AspectBaseHeight(aspect), 200)) + SCREENHEIGHT/2 - + (SCREENHEIGHT - SCREENHEIGHT * AspectMultiplier(aspect) / 48) / 2; - } - Displacement = 0; - } -} - -DEFINE_ACTION_FUNCTION(DBaseStatusBar, SetScaled) -{ - PARAM_SELF_PROLOGUE(DBaseStatusBar); - PARAM_BOOL(scale); - PARAM_BOOL_DEF(force); - self->SetScaled(scale, force); - return 0; -} - -void DBaseStatusBar::CallSetScaled(bool scale, bool force) -{ - IFVIRTUAL(DBaseStatusBar, SetScaled) - { - VMValue params[] = { (DObject*)this, scale, force }; - GlobalVMStack.Call(func, params, countof(params), nullptr, 0); - } - else SetScaled(scale, force); } //--------------------------------------------------------------------------- @@ -493,23 +513,21 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, GetHUDScale) // //--------------------------------------------------------------------------- -void DBaseStatusBar::BeginStatusBar(int resW, int resH, int relTop, bool completeborder, bool forceScaled) +void DBaseStatusBar::BeginStatusBar(int resW, int resH, int relTop, bool forceScaled) { - SetSize(relTop, resW, resH); - SetScaled(st_scale, forceScaled); - CompleteBorder = completeborder; + SetDrawSize(relTop < 0? BaseRelTop : relTop, resW < 0? BaseSBarHorizontalResolution : resW, resH < 0? BaseSBarVerticalResolution : resH); + ForcedScale = forceScaled; fullscreenOffsets = false; } DEFINE_ACTION_FUNCTION(DBaseStatusBar, BeginStatusBar) { PARAM_SELF_PROLOGUE(DBaseStatusBar); - PARAM_INT(w); - PARAM_INT(h); - PARAM_INT(r); - PARAM_BOOL_DEF(cb); PARAM_BOOL_DEF(fs); - self->BeginStatusBar(w, h, r, cb, fs); + PARAM_INT_DEF(w); + PARAM_INT_DEF(h); + PARAM_INT_DEF(r); + self->BeginStatusBar(w, h, r, fs); return 0; } //--------------------------------------------------------------------------- @@ -520,7 +538,7 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, BeginStatusBar) void DBaseStatusBar::BeginHUD(int resW, int resH, double Alpha, bool forcescaled) { - SetSize(RelTop, resW, resH); + SetDrawSize(RelTop, resW < 0? BaseHUDHorizontalResolution : resW, resH < 0? BaseHUDVerticalResolution : resH); this->Alpha = Alpha; ForcedScale = forcescaled; CompleteBorder = false; @@ -530,10 +548,10 @@ void DBaseStatusBar::BeginHUD(int resW, int resH, double Alpha, bool forcescaled DEFINE_ACTION_FUNCTION(DBaseStatusBar, BeginHUD) { PARAM_SELF_PROLOGUE(DBaseStatusBar); - PARAM_INT(w); - PARAM_INT(h); - PARAM_FLOAT(a); + PARAM_FLOAT_DEF(a); PARAM_BOOL_DEF(fs); + PARAM_INT_DEF(w); + PARAM_INT_DEF(h); self->BeginHUD(w, h, a, fs); return 0; } @@ -775,8 +793,8 @@ void DBaseStatusBar::RefreshBackground () const int x, x2, y; float ratio = ActiveRatio (SCREENWIDTH, SCREENHEIGHT); - x = (ratio < 1.5f || !Scaled) ? ST_X : SCREENWIDTH*(48-AspectMultiplier(ratio))/(48*2); - y = x == ST_X && x > 0 ? ST_Y : gST_Y; + x = ST_X; + y = SBarTop; if(!CompleteBorder) { @@ -795,8 +813,7 @@ void DBaseStatusBar::RefreshBackground () const { if(!CompleteBorder) { - x2 = ratio < 1.5f || !Scaled ? ST_X+HorizontalResolution : - SCREENWIDTH - (SCREENWIDTH*(48-AspectMultiplier(ratio))+48*2-1)/(48*2); + x2 = SCREENWIDTH - ST_X; } else { @@ -818,13 +835,6 @@ void DBaseStatusBar::RefreshBackground () const } } -DEFINE_ACTION_FUNCTION(DBaseStatusBar, RefreshBackground) -{ - PARAM_SELF_PROLOGUE(DBaseStatusBar); - self->RefreshBackground(); - return 0; -} - //--------------------------------------------------------------------------- // // DrawCrosshair @@ -959,8 +969,6 @@ void DBaseStatusBar::Draw (EHudState state) if (state == HUD_AltHud) return; - char line[64+10]; - if (state == HUD_StatusBar) { RefreshBackground (); @@ -968,57 +976,6 @@ void DBaseStatusBar::Draw (EHudState state) if (idmypos) { // Draw current coordinates - int height = SmallFont->GetHeight(); - char labels[3] = { 'X', 'Y', 'Z' }; - int i; - - int vwidth; - int vheight; - int xpos; - int y; - - if (active_con_scaletext() == 1) - { - vwidth = SCREENWIDTH; - vheight = SCREENHEIGHT; - xpos = vwidth - 80; - y = gST_Y - height; - } - else if (active_con_scaletext() > 1) - { - vwidth = SCREENWIDTH / active_con_scaletext(); - vheight = SCREENHEIGHT / active_con_scaletext(); - xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; - y = gST_Y/4 - height; - } - else - { - vwidth = SCREENWIDTH/2; - vheight = SCREENHEIGHT/2; - xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; - y = gST_Y/2 - height; - } - - if (gameinfo.gametype == GAME_Strife) - { - if (active_con_scaletext() == 1) - y -= height * 4; - else if (active_con_scaletext() > 3) - y -= height; - else - y -= height * 2; - } - - DVector3 pos = CPlayer->mo->Pos(); - for (i = 2; i >= 0; y -= height, --i) - { - mysnprintf (line, countof(line), "%c: %d", labels[i], int(pos[i])); - screen->DrawText (SmallFont, CR_GREEN, xpos, y, line, - DTA_KeepRatio, true, - DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, - TAG_DONE); - V_SetBorderNeedRefresh(); - } } if (viewactive) @@ -1055,6 +1012,7 @@ void DBaseStatusBar::CallDraw(EHudState state) } else Draw(state); screen->ClearClipRect(); // make sure the scripts don't leave a valid clipping rect behind. + BeginStatusBar(BaseSBarHorizontalResolution, BaseSBarVerticalResolution, BaseRelTop, false); } @@ -1156,7 +1114,7 @@ void DBaseStatusBar::SetMugShotState(const char *stateName, bool waitTillDone, b void DBaseStatusBar::DrawBottomStuff (EHudState state) { - DrawMessages (HUDMSGLayer_UnderHUD, (state == HUD_StatusBar) ? gST_Y : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_UnderHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); } //--------------------------------------------------------------------------- @@ -1169,7 +1127,7 @@ void DBaseStatusBar::DrawTopStuff (EHudState state) { if (demoplayback && demover != DEMOGAMEVERSION) { - screen->DrawText (SmallFont, CR_TAN, 0, ST_Y - 40 * CleanYfac, + screen->DrawText (SmallFont, CR_TAN, 0, GetTopOfStatusbar() - 40 * CleanYfac, "Demo was recorded with a different version\n" "of " GAMENAME ". Expect it to go out of sync.", DTA_CleanNoMove, true, TAG_DONE); @@ -1189,9 +1147,9 @@ void DBaseStatusBar::DrawTopStuff (EHudState state) if (automapactive && !viewactive) { - DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? gST_Y : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); } - DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? gST_Y : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); DrawConsistancy (); DrawWaiting (); if (ShowLog && MustDrawLog(state)) DrawLog (); @@ -1485,14 +1443,16 @@ uint32_t DBaseStatusBar::GetTranslation() const void DBaseStatusBar::StatusbarToRealCoords(double &x, double &y, double &w, double &h) const { - if (Scaled) + if (SBarScale.X == -1 || ForcedScale) { screen->VirtualToRealCoords(x, y, w, h, HorizontalResolution, VerticalResolution, true, true); } else { - x += ST_X; - y += screen->GetHeight() - VerticalResolution; + x = ST_X + x * SBarScale.X; + y = ST_Y + y * SBarScale.Y; + w *= SBarScale.X; + h *= SBarScale.Y; } } @@ -1512,15 +1472,10 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, StatusbarToRealCoords) } -double DBaseStatusBar::GetTopOfStatusbar() const -{ - return gST_Y; // fixme: Get rid of this global later. -} - DEFINE_ACTION_FUNCTION(DBaseStatusBar, GetTopOfStatusbar) { PARAM_SELF_PROLOGUE(DBaseStatusBar); - ACTION_RETURN_FLOAT(self->GetTopOfStatusbar()); + ACTION_RETURN_INT(self->GetTopOfStatusbar()); } //============================================================================ @@ -1994,12 +1949,9 @@ CCMD (showpop) } } -DEFINE_FIELD(DBaseStatusBar, ST_X); -DEFINE_FIELD(DBaseStatusBar, ST_Y); DEFINE_FIELD(DBaseStatusBar, RelTop); DEFINE_FIELD(DBaseStatusBar, HorizontalResolution); DEFINE_FIELD(DBaseStatusBar, VerticalResolution); -DEFINE_FIELD(DBaseStatusBar, Scaled); DEFINE_FIELD(DBaseStatusBar, Centering); DEFINE_FIELD(DBaseStatusBar, FixedOrigin); DEFINE_FIELD(DBaseStatusBar, CompleteBorder); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 5f261d9d4c..c0dc250f71 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -52,7 +52,6 @@ EXTERN_CVAR (Bool, r_drawplayersprites) EXTERN_CVAR(Float, transsouls) -EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR(Int, gl_fuzztype) EXTERN_CVAR (Bool, r_deathcamera) @@ -121,7 +120,7 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa { ftexturemid -= fYAd; } - else if (!st_scale) + else { ftexturemid -= StatusBar->GetDisplacement () * fYAd; } diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 0c001a3ba0..a399011812 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -51,6 +51,7 @@ #include "d_net.h" #include "c_dispatch.h" #include "g_levellocals.h" +#include "sbar.h" // MACROS ------------------------------------------------------------------ @@ -262,7 +263,7 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER lineheight = MAX(height, maxiconheight * CleanYfac); ypadding = (lineheight - height + 1) / 2; - bottom = gST_Y; + bottom = StatusBar->GetTopOfStatusbar(); y = MAX(48*CleanYfac, (bottom - MAXPLAYERS * (height + CleanYfac + 1)) / 2); HU_DrawTimeRemaining (bottom - height); diff --git a/src/p_user.cpp b/src/p_user.cpp index 694daffa1d..ab9319f20c 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -759,6 +759,7 @@ bool player_t::Resurrect() E_PlayerRespawned(int(this - players)); // FBehavior::StaticStartTypedScripts(SCRIPT_Respawn, mo, true); + return true; } DEFINE_ACTION_FUNCTION(_PlayerInfo, Resurrect) diff --git a/src/polyrenderer/scene/poly_playersprite.cpp b/src/polyrenderer/scene/poly_playersprite.cpp index 360af43bc2..eb1ff323ed 100644 --- a/src/polyrenderer/scene/poly_playersprite.cpp +++ b/src/polyrenderer/scene/poly_playersprite.cpp @@ -32,7 +32,6 @@ EXTERN_CVAR(Bool, r_drawplayersprites) EXTERN_CVAR(Bool, r_deathcamera) -EXTERN_CVAR(Bool, st_scale) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) EXTERN_CVAR(Bool, r_shadercolormaps) @@ -275,7 +274,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *pspr, AActor *owner, float if (viewpoint.camera->player && (renderTarget != screen || viewheight == renderTarget->GetHeight() || - (renderTarget->GetWidth() > (BASEXCENTER * 2) && !st_scale))) + (renderTarget->GetWidth() > (BASEXCENTER * 2)))) { // Adjust PSprite for fullscreen views AWeapon *weapon = dyn_cast(pspr->GetCaller()); if (weapon != nullptr && weapon->YAdjust != 0) diff --git a/src/r_utility.cpp b/src/r_utility.cpp index df6c1e3ddb..6af399bfbd 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -59,6 +59,7 @@ #include "p_local.h" #include "g_levellocals.h" #include "p_maputl.h" +#include "sbar.h" #include "math/cmath.h" @@ -262,13 +263,13 @@ void R_ExecuteSetViewSize (FRenderViewpoint &viewpoint, FViewWindow &viewwindow) setsizeneeded = false; V_SetBorderNeedRefresh(); - R_SetWindow (viewpoint, viewwindow, setblocks, SCREENWIDTH, SCREENHEIGHT, gST_Y); + R_SetWindow (viewpoint, viewwindow, setblocks, SCREENWIDTH, SCREENHEIGHT, StatusBar->GetTopOfStatusbar()); // Handle resize, e.g. smaller view windows with border and/or status bar. viewwindowx = (screen->GetWidth() - viewwidth) >> 1; // Same with base row offset. - viewwindowy = (viewwidth == screen->GetWidth()) ? 0 : (gST_Y - viewheight) >> 1; + viewwindowy = (viewwidth == screen->GetWidth()) ? 0 : (StatusBar->GetTopOfStatusbar() - viewheight) >> 1; } //========================================================================== diff --git a/src/st_stuff.h b/src/st_stuff.h index a0434f8b42..19e17a1114 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -26,8 +26,6 @@ struct event_t; -extern int gST_Y; - bool ST_Responder(event_t* ev); // [RH] Base blending values (for e.g. underwater) diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp index 4afa44d607..c56b95980b 100644 --- a/src/swrenderer/things/r_playersprite.cpp +++ b/src/swrenderer/things/r_playersprite.cpp @@ -58,7 +58,6 @@ #include "swrenderer/r_renderthread.h" #include "g_levellocals.h" -EXTERN_CVAR(Bool, st_scale) EXTERN_CVAR(Bool, r_drawplayersprites) EXTERN_CVAR(Bool, r_deathcamera) EXTERN_CVAR(Bool, r_shadercolormaps) @@ -275,7 +274,7 @@ namespace swrenderer if (Thread->Viewport->viewpoint.camera->player && (viewport->RenderTarget != screen || viewheight == viewport->RenderTarget->GetHeight() || - (viewport->RenderTarget->GetWidth() > (BASEXCENTER * 2) && !st_scale))) + (viewport->RenderTarget->GetWidth() > (BASEXCENTER * 2)))) { // Adjust PSprite for fullscreen views AWeapon *weapon = dyn_cast(pspr->GetCaller()); if (weapon != nullptr && weapon->YAdjust != 0) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index b95ade5bda..97aa21ef01 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -65,6 +65,11 @@ CUSTOM_CVAR(Int, uiscale, 2, CVAR_ARCHIVE | CVAR_NOINITCALL) { + if (self < 0) + { + self = 0; + return; + } if (StatusBar != NULL) { StatusBar->CallScreenSizeChanged(); @@ -1257,10 +1262,9 @@ static void V_DrawViewBorder (void) V_DrawBorder (0, 0, SCREENWIDTH, viewwindowy); V_DrawBorder (0, viewwindowy, viewwindowx, viewheight + viewwindowy); V_DrawBorder (viewwindowx + viewwidth, viewwindowy, SCREENWIDTH, viewheight + viewwindowy); - V_DrawBorder (0, viewwindowy + viewheight, SCREENWIDTH, gST_Y); + V_DrawBorder (0, viewwindowy + viewheight, SCREENWIDTH, StatusBar->GetTopOfStatusbar()); V_DrawFrame (viewwindowx, viewwindowy, viewwidth, viewheight); - V_MarkRect (0, 0, SCREENWIDTH, gST_Y); } //========================================================================== diff --git a/src/v_video.cpp b/src/v_video.cpp index 3dea831be6..07990af8bd 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -197,13 +197,6 @@ bool setmodeneeded = false; int NewWidth, NewHeight, NewBits; -// -// V_MarkRect -// -void V_MarkRect (int x, int y, int width, int height) -{ -} - //========================================================================== // // DCanvas Constructor diff --git a/src/v_video.h b/src/v_video.h index 2d554dea92..81ae91c701 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -528,8 +528,6 @@ void V_Init2 (); void V_Shutdown (); -void V_MarkRect (int x, int y, int width, int height); - class FScanner; // Returns the closest color to the one desired. String // should be of the form "rr gg bb". diff --git a/wadsrc/static/zscript/statusbar/doom_sbar.txt b/wadsrc/static/zscript/statusbar/doom_sbar.txt index 25e8bb7b93..f5ac66ac28 100644 --- a/wadsrc/static/zscript/statusbar/doom_sbar.txt +++ b/wadsrc/static/zscript/statusbar/doom_sbar.txt @@ -32,12 +32,12 @@ class DoomStatusBar : BaseStatusBar if (state == HUD_StatusBar) { - BeginStatusBar(320, 200, 32); + BeginStatusBar(); DrawMainBar (TicFrac); } else if (state == HUD_Fullscreen) { - BeginHUD(320, 200, 1., false); + BeginHUD(); DrawFullScreenStuff (); } } diff --git a/wadsrc/static/zscript/statusbar/heretic_sbar.txt b/wadsrc/static/zscript/statusbar/heretic_sbar.txt index 821621d97e..b6db47dcf0 100644 --- a/wadsrc/static/zscript/statusbar/heretic_sbar.txt +++ b/wadsrc/static/zscript/statusbar/heretic_sbar.txt @@ -48,12 +48,12 @@ class HereticStatusBar : BaseStatusBar if (state == HUD_StatusBar) { - BeginStatusBar(320, 200, 42); + BeginStatusBar(); DrawMainBar (TicFrac); } else if (state == HUD_Fullscreen) { - BeginHUD(320, 200, 1., false); + BeginHUD(); DrawFullScreenStuff (); } } diff --git a/wadsrc/static/zscript/statusbar/hexen_sbar.txt b/wadsrc/static/zscript/statusbar/hexen_sbar.txt index baac12ba00..d1418763f6 100644 --- a/wadsrc/static/zscript/statusbar/hexen_sbar.txt +++ b/wadsrc/static/zscript/statusbar/hexen_sbar.txt @@ -52,12 +52,12 @@ class HexenStatusBar : BaseStatusBar if (state == HUD_StatusBar) { - BeginStatusBar(320, 200, 38); + BeginStatusBar(); DrawMainBar (TicFrac); } else if (state == HUD_Fullscreen) { - BeginHUD(320, 200, 1., false); + BeginHUD(); DrawFullScreenStuff (); } } diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index 1659fbc500..dc916cad40 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -270,10 +270,8 @@ class BaseStatusBar native ui const POWERUPICONSIZE = 32; - native int ST_X, ST_Y; native int RelTop; native int HorizontalResolution, VerticalResolution; - native bool Scaled; native bool Centering; native bool FixedOrigin; native bool CompleteBorder; @@ -294,17 +292,16 @@ class BaseStatusBar native ui private HUDFont mSmallFont; - native void SetSize(int height, int vwidth, int vheight); + native void SetSize(int height, int vwidth, int vheight, int hwidth = -1, int hheight = -1); native Vector2 GetHUDScale(); - native void BeginStatusBar(int resW, int resH, int relTop, bool completeborder = false, bool forceScaled = false); - native void BeginHUD(int resW, int resH, double Alpha, bool forcescaled = false); + native void BeginStatusBar(bool forceScaled = false, int resW = -1, int resH = -1, int rel = -1); + native void BeginHUD(double Alpha = 1., bool forcescaled = false, int resW = -1, int resH = -1); virtual void Init() { mSmallFont = HUDFont.Create("SmallFont"); } - native virtual void SetScaled(bool scale, bool force = false); native virtual void Tick (); native virtual void Draw (int state, double TicFrac); native virtual void ScreenSizeChanged (); @@ -318,7 +315,6 @@ class BaseStatusBar native ui virtual void ShowPop (int popnum) { ShowLog = (popnum == POP_Log && !ShowLog); } virtual bool MustDrawLog(int state) { return true; } - native void RefreshBackground () const; native TextureID GetMugshot(int accuracy, int stateflags=MugShot.STANDARD, String default_face = "STF"); // These functions are kept native solely for performance reasons. They get called repeatedly and can drag down performance easily if they get too slow. @@ -330,7 +326,7 @@ class BaseStatusBar native ui native void Fill(Color col, double x, double y, double w, double h, int flags = 0); native static String FormatNumber(int number, int minsize = 0, int maxsize = 0, int format = 0, String prefix = ""); native double, double, double, double StatusbarToRealCoords(double x, double y=0, double w=0, double h=0); - native double GetTopOfStatusBar(); + native int GetTopOfStatusBar(); //============================================================================ // @@ -678,6 +674,68 @@ class BaseStatusBar native ui return it != null && it.Amount >= amount; } + //============================================================================ + // + // mypos cheat + // + //============================================================================ + + virtual void DrawMyPos() + { + /* + int height = SmallFont->GetHeight(); + char labels[3] = { 'X', 'Y', 'Z' }; + int i; + + int vwidth; + int vheight; + int xpos; + int y; + + if (active_con_scaletext() == 1) + { + vwidth = SCREENWIDTH; + vheight = SCREENHEIGHT; + xpos = vwidth - 80; + y = SBarTop - height; + } + else if (active_con_scaletext() > 1) + { + vwidth = SCREENWIDTH / active_con_scaletext(); + vheight = SCREENHEIGHT / active_con_scaletext(); + xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; + y = SBarTop/4 - height; + } + else + { + vwidth = SCREENWIDTH/2; + vheight = SCREENHEIGHT/2; + xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; + y = SBarTop/2 - height; + } + + if (gameinfo.gametype == GAME_Strife) + { + if (active_con_scaletext() == 1) + y -= height * 4; + else if (active_con_scaletext() > 3) + y -= height; + else + y -= height * 2; + } + + DVector3 pos = CPlayer->mo->Pos(); + for (i = 2; i >= 0; y -= height, --i) + { + mysnprintf (line, countof(line), "%c: %d", labels[i], int(pos[i])); + screen->DrawText (SmallFont, CR_GREEN, xpos, y, line, + DTA_KeepRatio, true, + DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, + TAG_DONE); + V_SetBorderNeedRefresh(); + } + */ + } //============================================================================ // @@ -696,7 +754,7 @@ class BaseStatusBar native ui String printtext; int SCREENWIDTH = screen.GetWidth(); - BeginHUD(320, 200, 1., false); + BeginHUD(); // Draw timer let y = textdist; diff --git a/wadsrc/static/zscript/statusbar/strife_sbar.txt b/wadsrc/static/zscript/statusbar/strife_sbar.txt index 78084dbc6a..8a7717e99e 100644 --- a/wadsrc/static/zscript/statusbar/strife_sbar.txt +++ b/wadsrc/static/zscript/statusbar/strife_sbar.txt @@ -85,14 +85,14 @@ class StrifeStatusBar : BaseStatusBar if (state == HUD_StatusBar) { - BeginStatusBar(320, 200, 32); + BeginStatusBar(); DrawMainBar (TicFrac); } else { if (state == HUD_Fullscreen) { - BeginHUD(320, 200, 1., false); + BeginHUD(); DrawFullScreenStuff (); } @@ -100,7 +100,7 @@ class StrifeStatusBar : BaseStatusBar if (CurrentPop != POP_None && PopHeight < 0) { // This uses direct low level draw commands and would otherwise require calling - // BeginStatusBar(320, 200, false, true); + // BeginStatusBar(true); DrawPopScreen (screen.GetHeight(), TicFrac); } }