diff --git a/src/am_map.cpp b/src/am_map.cpp index 246adcc9be..aa66341270 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -41,6 +41,7 @@ #include "farchive.h" #include "r_renderer.h" #include "r_sky.h" +#include "sbar.h" #include "m_cheat.h" #include "i_system.h" @@ -1081,7 +1082,7 @@ void AM_Stop () { automapactive = false; stopped = true; - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); viewactive = true; } @@ -1180,7 +1181,7 @@ void AM_ToggleMap () if (dmflags2 & DF2_NO_AUTOMAP) return; - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); if (!automapactive) { AM_Start (); @@ -1191,7 +1192,7 @@ void AM_ToggleMap () if (am_overlay==1 && viewactive) { viewactive = false; - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); } else { diff --git a/src/c_console.cpp b/src/c_console.cpp index 8e439df6ce..3f4ae9e5fe 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1134,7 +1134,7 @@ void C_DrawConsole (bool hw2d) (viewwindowx || viewwindowy) && viewactive) { - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); } oldbottom = ConBottom; @@ -1224,8 +1224,8 @@ void C_DrawConsole (bool hw2d) { screen->Dim (PalEntry ((unsigned char)(player->BlendR*255), (unsigned char)(player->BlendG*255), (unsigned char)(player->BlendB*255)), player->BlendA, 0, ConBottom, screen->GetWidth(), screen->GetHeight() - ConBottom); - SB_state = screen->GetPageCount (); - BorderNeedRefresh = screen->GetPageCount (); + ST_SetNeedRefresh(); + V_SetBorderNeedRefresh(); } } } diff --git a/src/d_main.cpp b/src/d_main.cpp index 50311c8267..aa4abd3662 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -697,21 +697,21 @@ void D_Display () if (screen->Lock (false)) { - SB_state = screen->GetPageCount (); - BorderNeedRefresh = screen->GetPageCount (); + ST_SetNeedRefresh(); + V_SetBorderNeedRefresh(); } // [RH] Allow temporarily disabling wipes if (NoWipe) { - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); NoWipe--; wipe = false; wipegamestate = gamestate; } else if (gamestate != wipegamestate && gamestate != GS_FULLCONSOLE && gamestate != GS_TITLELEVEL) { // save the current screen if about to wipe - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); switch (wipegamestate) { default: @@ -780,8 +780,8 @@ void D_Display () if ((hw2d = screen->Begin2D(viewactive))) { // Redraw everything every frame when using 2D accel - SB_state = screen->GetPageCount(); - BorderNeedRefresh = screen->GetPageCount(); + ST_SetNeedRefresh(); + V_SetBorderNeedRefresh(); } Renderer->DrawRemainingPlayerSprites(); screen->DrawBlendingRect(); @@ -1278,7 +1278,7 @@ void D_DoAdvanceDemo (void) Advisory = NULL; if (!M_DemoNoPlay) { - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); democount++; mysnprintf (demoname + 4, countof(demoname) - 4, "%d", democount); if (Wads.CheckNumForName (demoname) < 0) diff --git a/src/d_net.cpp b/src/d_net.cpp index 3acee3af45..dff5c948ef 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2245,7 +2245,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) paused = player + 1; S_PauseSound (false, false); } - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); } break; diff --git a/src/g_level.cpp b/src/g_level.cpp index 3fd2bae73c..3e54f5aa3b 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -227,7 +227,7 @@ void G_NewInit () int i; G_ClearSnapshots (); - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); netgame = false; multiplayer = false; if (demoplayback) @@ -424,7 +424,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel) demoplayback = false; automapactive = false; viewactive = true; - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); //Added by MC: Initialize bots. if (!deathmatch) diff --git a/src/g_shared/hudmessages.cpp b/src/g_shared/hudmessages.cpp index adc375c24e..f60c8a84e4 100644 --- a/src/g_shared/hudmessages.cpp +++ b/src/g_shared/hudmessages.cpp @@ -163,7 +163,7 @@ DHUDMessage::~DHUDMessage () Lines = NULL; if (screen != NULL) { - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); } } if (SourceText != NULL) @@ -597,7 +597,7 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh DTA_RenderStyle, Style, TAG_DONE); } - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); } } @@ -698,7 +698,7 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu DTA_RenderStyle, Style, TAG_DONE); } - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); } else { diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index fcba22fa94..230e457d80 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -55,6 +55,8 @@ enum EHudState class AWeapon; +void ST_SetNeedRefresh(); + // HUD Message base object -------------------------------------------------- class DHUDMessage : public DObject diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index eb739e6c21..471e3047fc 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -209,6 +209,17 @@ void ST_Clear() CrosshairNum = 0; } +//--------------------------------------------------------------------------- +// +// ST_SetNeedRefresh +// +//--------------------------------------------------------------------------- + +void ST_SetNeedRefresh() +{ + SB_state = (StatusBar == NULL || screen == NULL) ? 0 : screen->GetPageCount(); +} + //--------------------------------------------------------------------------- // // Constructor @@ -297,7 +308,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) Displacement = 0; } ::ST_X = ST_X; - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); } //--------------------------------------------------------------------------- @@ -309,7 +320,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) void DBaseStatusBar::AttachToPlayer (player_t *player) { CPlayer = player; - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); } //--------------------------------------------------------------------------- @@ -331,7 +342,7 @@ int DBaseStatusBar::GetPlayer () void DBaseStatusBar::MultiplayerChanged () { - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); } //--------------------------------------------------------------------------- @@ -441,7 +452,7 @@ DHUDMessage *DBaseStatusBar::DetachMessage (DHUDMessage *msg) // Redraw the status bar in case it was covered if (screen != NULL) { - SB_state = screen->GetPageCount(); + ST_SetNeedRefresh(); } return probe; } @@ -468,7 +479,7 @@ DHUDMessage *DBaseStatusBar::DetachMessage (DWORD id) // Redraw the status bar in case it was covered if (screen != NULL) { - SB_state = screen->GetPageCount(); + ST_SetNeedRefresh(); } return probe; } @@ -1281,7 +1292,7 @@ void DBaseStatusBar::Draw (EHudState state) DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); - BorderNeedRefresh = screen->GetPageCount(); + V_SetBorderNeedRefresh(); } } @@ -1641,7 +1652,7 @@ void DBaseStatusBar::Serialize (FArchive &arc) void DBaseStatusBar::ScreenSizeChanged () { st_scale.Callback (); - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); for (unsigned int i = 0; i < countof(Messages); ++i) { diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index 0a986495c1..02db33d25a 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -234,7 +234,7 @@ public: { if (state == HUD_Fullscreen) { - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); DrawFullScreenStuff (); } @@ -311,7 +311,7 @@ private: CursorImage = Images[imgINVCURS] != NULL ? imgINVCURS : imgCURSOR01; - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); CurrentPop = POP_None; PendingPop = POP_NoChange; diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 55d657b7ca..a1870b4aee 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -168,7 +168,7 @@ void HU_DrawScores (player_t *player) HU_DoDrawScores (player, sortedplayers); - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); } //========================================================================== diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index b6bd24ae3d..e717aa3d25 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -88,7 +88,7 @@ void cht_DoCheat (player_t *player, int cheat) msg = GStrings("STSTR_DQDON"); else msg = GStrings("STSTR_DQDOFF"); - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); break; case CHT_BUDDHA: diff --git a/src/menu/loadsavemenu.cpp b/src/menu/loadsavemenu.cpp index 78bdadf59e..99ac599380 100644 --- a/src/menu/loadsavemenu.cpp +++ b/src/menu/loadsavemenu.cpp @@ -961,7 +961,7 @@ void DSaveMenu::DoSave (FSaveGameNode *node) G_SaveGame (filename, savegamestring); } M_ClearMenus(); - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); } //============================================================================= @@ -1100,7 +1100,7 @@ bool DLoadMenu::MenuEvent (int mkey, bool fromcontroller) quickSaveSlot = SaveGames[Selected]; } M_ClearMenus(); - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); LastAccessed = Selected; return true; } diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index e07bc142fd..4b4b0c5e83 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -734,7 +734,7 @@ void M_ClearMenus () DMenu::CurrentMenu->Destroy(); DMenu::CurrentMenu = NULL; } - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); menuactive = MENU_Off; } diff --git a/src/menu/messagebox.cpp b/src/menu/messagebox.cpp index e7b6abcef4..b94daae0a9 100644 --- a/src/menu/messagebox.cpp +++ b/src/menu/messagebox.cpp @@ -179,8 +179,8 @@ void DMessageBoxMenu::Drawer () PalEntry fade = 0; int fontheight = SmallFont->GetHeight(); - //BorderNeedRefresh = screen->GetPageCount (); - //SB_state = screen->GetPageCount (); + //V_SetBorderNeedRefresh(); + //ST_SetNeedRefresh(); y = 100; diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 46da3e2256..b75811038a 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -460,7 +460,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) void R_ExecuteSetViewSize () { setsizeneeded = false; - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); R_SetWindow (setblocks, SCREENWIDTH, SCREENHEIGHT, ST_Y); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index dc890c12b1..2f0c3e44a4 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -268,7 +268,7 @@ void S_NoiseDebug (void) } chan = (FSoundChan *)((size_t)chan->PrevChan - myoffsetof(FSoundChan, NextChan)); } - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); } static FString LastLocalSndInfo; diff --git a/src/st_stuff.h b/src/st_stuff.h index bd42c9eda5..aaa407585a 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -29,7 +29,6 @@ struct event_t; extern int ST_X; extern int ST_Y; -extern int SB_state; bool ST_Responder(event_t* ev); // [RH] Base blending values (for e.g. underwater) diff --git a/src/stats.cpp b/src/stats.cpp index 76fe36c268..61b04f87f2 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -94,7 +94,7 @@ void FStat::ToggleStat (const char *name) void FStat::ToggleStat () { m_Active = !m_Active; - SB_state = StatusBar == NULL ? 0 : screen->GetPageCount (); + ST_SetNeedRefresh(); } void FStat::PrintStat () @@ -124,7 +124,7 @@ void FStat::PrintStat () } if (count) { - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); } } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 87b4e08425..cd07b44a10 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -53,6 +53,7 @@ #include "gi.h" #include "g_level.h" #include "st_stuff.h" +#include "sbar.h" #include "i_system.h" #include "i_video.h" @@ -1377,8 +1378,32 @@ bool DCanvas::ClipBox (int &x, int &y, int &w, int &h, const BYTE *&src, const i return false; } +//========================================================================== +// +// V_SetBorderNeedRefresh +// +// Flag the border as in need of updating. (Probably because something that +// was on top of it has changed. +// +//========================================================================== + +void V_SetBorderNeedRefresh() +{ + if (screen != NULL) + { + BorderNeedRefresh = screen->GetPageCount(); + } +} + +//========================================================================== +// +// V_DrawFrame +// // Draw a frame around the specified area using the view border // frame graphics. The border is drawn outside the area, not in it. +// +//========================================================================== + void V_DrawFrame (int left, int top, int width, int height) { FTexture *p; @@ -1411,7 +1436,7 @@ void V_DrawFrame (int left, int top, int width, int height) //========================================================================== // -// +// V_DrawBorder // //========================================================================== @@ -1455,7 +1480,7 @@ static void V_DrawViewBorder (void) // Will draw borders around itself, too. if (SCREENWIDTH > 320) { - SB_state = screen->GetPageCount (); + ST_SetNeedRefresh(); } if (viewwidth == SCREENWIDTH) diff --git a/src/v_video.cpp b/src/v_video.cpp index e3a832dde8..855b9fda3c 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1605,7 +1605,7 @@ void V_Init2() FBaseCVar::ResetColors (); C_NewModeAdjust(); M_InitVideoModesMenu(); - BorderNeedRefresh = screen->GetPageCount (); + V_SetBorderNeedRefresh(); setsizeneeded = true; } diff --git a/src/v_video.h b/src/v_video.h index f6a1caebaf..09022d9ffa 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -485,6 +485,7 @@ void V_DrawFrame (int left, int top, int width, int height); void V_DrawBorder (int x1, int y1, int x2, int y2); void V_RefreshViewBorder (); +void V_SetBorderNeedRefresh(); #if defined(X86_ASM) || defined(X64_ASM) extern "C" void ASM_PatchPitch (void); diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 3598f52d12..6481042716 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -66,7 +66,7 @@ #include "r_main.h" #include "r_data/r_translate.h" #include "f_wipe.h" -#include "st_stuff.h" +#include "sbar.h" #include "win32iface.h" #include "doomstat.h" #include "v_palette.h" @@ -225,7 +225,8 @@ const char *const D3DFB::ShaderNames[D3DFB::NUM_SHADERS] = CUSTOM_CVAR(Bool, vid_hw2d, true, CVAR_NOINITCALL) { - BorderNeedRefresh = SB_state = screen->GetPageCount(); + V_SetBorderNeedRefresh(); + ST_SetNeedRefresh(); } CVAR(Bool, d3d_antilag, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)