From c1d603e1e930ee226f9fb2ba8067c3eb7a622f46 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Oct 2022 20:33:18 +0200 Subject: [PATCH] - backend update from GZDoom. --- source/CMakeLists.txt | 5 +- source/common/2d/v_draw.cpp | 117 +++++++------ source/common/2d/v_draw.h | 11 +- source/common/2d/v_drawtext.cpp | 13 +- source/common/2d/wipe.cpp | 17 ++ source/common/2d/wipe.h | 17 -- source/common/audio/music/i_music.h | 4 +- source/common/audio/music/i_soundfont.cpp | 4 +- source/common/audio/music/music.cpp | 2 +- source/common/audio/sound/s_sound.cpp | 155 ++++++++++++++++++ source/common/audio/sound/s_soundinternal.h | 1 + source/common/console/c_bind.cpp | 4 +- source/common/console/c_console.cpp | 3 +- source/common/console/c_console.h | 1 + source/common/console/c_cvars.cpp | 3 +- source/common/console/c_dispatch.h | 2 - source/common/engine/d_event.cpp | 2 +- source/common/engine/i_interface.cpp | 26 +++ source/common/engine/i_interface.h | 13 ++ source/common/engine/m_joy.cpp | 12 +- source/common/filesystem/filesystem.cpp | 12 +- source/common/fonts/v_text.cpp | 1 - source/common/menu/menu.cpp | 13 +- source/common/menu/menu.h | 2 +- source/common/menu/messagebox.cpp | 1 - source/common/platform/posix/cocoa/i_input.mm | 2 +- .../common/platform/posix/cocoa/i_system.mm | 2 +- .../common/platform/posix/i_system_posix.cpp | 5 +- source/common/platform/posix/sdl/i_input.cpp | 2 +- source/common/platform/posix/sdl/i_system.cpp | 2 +- source/common/platform/win32/i_input.cpp | 3 - source/common/platform/win32/i_system.cpp | 33 ++-- source/common/platform/win32/i_system.h | 4 +- source/common/rendering/gl/gl_stereo3d.cpp | 28 +++- .../common/rendering/gles/gles_samplers.cpp | 20 +++ source/common/rendering/gles/gles_system.cpp | 2 + source/common/rendering/gles/gles_system.h | 5 +- source/common/scripting/core/dynarrays.cpp | 32 +++- .../common/scripting/interface/vmnatives.cpp | 17 +- source/common/scripting/vm/vm.h | 4 +- source/common/startscreen/startscreen.cpp | 1 - source/common/startscreen/startscreen.h | 1 + source/common/statusbar/base_sbar.cpp | 15 +- .../textures/formats/startscreentexture.cpp | 1 - source/common/textures/texturemanager.cpp | 7 +- source/common/textures/texturemanager.h | 2 +- source/{ => common/utility}/gitinfo.cpp | 0 source/common/utility/vectors.h | 6 - source/core/cheathandler.cpp | 1 + source/core/ct_chat.cpp | 2 +- source/core/gamecontrol.cpp | 133 ++++----------- source/core/gamecontrol.h | 1 + source/core/gamecvars.cpp | 10 +- source/core/gamehud.cpp | 2 +- source/core/inputstate.cpp | 2 +- source/core/mainloop.cpp | 2 +- source/core/menu/razemenu.cpp | 29 +--- source/core/menu/razemenu.h | 3 - 58 files changed, 487 insertions(+), 333 deletions(-) rename source/{ => common/utility}/gitinfo.cpp (100%) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 9e55ae994..d646a4635 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -931,10 +931,6 @@ set( FASTMATH_SOURCES common/textures/hires/xbr/xbrz.cpp common/textures/hires/xbr/xbrz_old.cpp common/utility/matrix.cpp - - # The rest is only here because it is C, not C++ - - gitinfo.cpp ) #Vulkan stuff must go into a separate list because it needs to be disabled for some platforms @@ -1164,6 +1160,7 @@ set (PCH_SOURCES common/cutscenes/screenjob.cpp common/utility/engineerrors.cpp common/utility/i_module.cpp + common/utility/gitinfo.cpp common/utility/m_alloc.cpp common/utility/utf8.cpp common/utility/palette.cpp diff --git a/source/common/2d/v_draw.cpp b/source/common/2d/v_draw.cpp index 807a207d1..3d56829ba 100644 --- a/source/common/2d/v_draw.cpp +++ b/source/common/2d/v_draw.cpp @@ -199,7 +199,7 @@ void DoDrawTexture(F2DDrawer *drawer, FGameTexture* img, double x, double y, int DrawParms parms; if (!img || !img->isValid()) return; - bool res = ParseDrawTextureTags(drawer, img, x, y, tags_first, tags, &parms, false); + bool res = ParseDrawTextureTags(drawer, img, x, y, tags_first, tags, &parms, DrawTexture_Normal); va_end(tags.list); if (!res) { @@ -238,7 +238,7 @@ void DoDrawTexture(F2DDrawer *drawer, FGameTexture *img, double x, double y, VMV DrawParms parms; uint32_t tag = ListGetInt(args); if (!img || !img->isValid()) return; - bool res = ParseDrawTextureTags(drawer, img, x, y, tag, args, &parms, false); + bool res = ParseDrawTextureTags(drawer, img, x, y, tag, args, &parms, DrawTexture_Normal); if (!res) return; drawer->AddTexture(img, parms); } @@ -290,7 +290,7 @@ void DrawShape(F2DDrawer *drawer, FGameTexture *img, DShape2D *shape, int tags_f va_start(tags.list, tags_first); DrawParms parms; - bool res = ParseDrawTextureTags(drawer, img, 0, 0, tags_first, tags, &parms, false); + bool res = ParseDrawTextureTags(drawer, img, 0, 0, tags_first, tags, &parms, DrawTexture_Normal); va_end(tags.list); if (!res) return; drawer->AddShape(img, shape, parms); @@ -301,21 +301,19 @@ void DrawShape(F2DDrawer *drawer, FGameTexture *img, DShape2D *shape, VMVa_List DrawParms parms; uint32_t tag = ListGetInt(args); - bool res = ParseDrawTextureTags(drawer, img, 0, 0, tag, args, &parms, false); + bool res = ParseDrawTextureTags(drawer, img, 0, 0, tag, args, &parms, DrawTexture_Normal); if (!res) return; drawer->AddShape(img, shape, parms); } -void DrawShapeFill(F2DDrawer *drawer, int color, DShape2D *shape, VMVa_List &args) +void DrawShapeFill(F2DDrawer *drawer, PalEntry color, double amount, DShape2D *shape, VMVa_List &args) { DrawParms parms; uint32_t tag = ListGetInt(args); - bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag, args, &parms, false, false); + bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag, args, &parms, DrawTexture_Fill, color, amount); if (!res) return; - parms.fillcolor = color; - drawer->AddShape(nullptr, shape, parms); } @@ -367,9 +365,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawShapeFill) VMVa_List args = { param + 3, 0, numparam - 4, va_reginfo + 3 }; - color.a = int(amount * 255.0f); - - DrawShapeFill(twod, color, shape, args); + DrawShapeFill(twod, color, amount, shape, args); return 0; } @@ -384,9 +380,7 @@ DEFINE_ACTION_FUNCTION(FCanvas, DrawShapeFill) VMVa_List args = { param + 4, 0, numparam - 5, va_reginfo + 4 }; - color.a = int(amount * 255.0f); - - DrawShapeFill(&self->Drawer, color, shape, args); + DrawShapeFill(&self->Drawer, color, amount, shape, args); self->Tex->NeedUpdate(); return 0; } @@ -532,7 +526,7 @@ void CalcFullscreenScale(DrawParms *parms, double srcwidth, double srcheight, in if (autoaspect == FSMode_ScaleToFit43 || autoaspect == FSMode_ScaleToFit43Top || autoaspect == FSMode_ScaleToFit43Bottom) { // screen is wider than the image -> pillarbox it. 4:3 images must also be pillarboxed if the screen is taller than the image - if (screenratio >= aspect || aspect < 1.4) autoaspect = FSMode_ScaleToFit; + if (screenratio >= aspect || aspect < 1.4) autoaspect = FSMode_ScaleToFit; else if (screenratio > 1.32) autoaspect = FSMode_ScaleToFill; // on anything 4:3 and wider crop the sides of the image. else { @@ -833,13 +827,13 @@ static inline FSpecialColormap * ListGetSpecialColormap(VMVa_List &tags) //========================================================================== template -bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext, bool checkimage) +bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha) { INTBOOL boolval; int intval; - bool fillcolorset = false; + bool fillcolorset = type == DrawTexture_Fill; - if (!fortext && checkimage) + if (type == DrawTexture_Normal) { if (img == NULL || !img->isValid()) { @@ -855,7 +849,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double return false; } - parms->fortext = fortext; + parms->fortext = type == DrawTexture_Text; parms->windowleft = 0; parms->windowright = INT_MAX; parms->dclip = drawer->GetHeight(); @@ -866,8 +860,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double parms->top = INT_MAX; parms->destwidth = INT_MAX; parms->destheight = INT_MAX; - parms->Alpha = 1.f; - parms->fillcolor = -1; + parms->Alpha = type == DrawTexture_Fill ? fillalpha : 1.f; + parms->fillcolor = type == DrawTexture_Fill ? fill : PalEntry(~0u); parms->TranslationId = -1; parms->colorOverlay = 0; parms->alphaChannel = false; @@ -916,29 +910,29 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_DestWidth: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->cleanmode = DTA_Base; parms->destwidth = ListGetInt(tags); break; case DTA_DestWidthF: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->cleanmode = DTA_Base; parms->destwidth = ListGetDouble(tags); break; case DTA_DestHeight: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->cleanmode = DTA_Base; parms->destheight = ListGetInt(tags); break; case DTA_DestHeightF: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->cleanmode = DTA_Base; parms->destheight = ListGetDouble(tags); break; @@ -1046,7 +1040,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double boolval = ListGetInt(tags); if (boolval) { - assert(fortext == false); + assert(type != DrawTexture_Text); if (img == NULL) return false; parms->cleanmode = DTA_Fullscreen; parms->fsscalemode = (uint8_t)twod->fullscreenautoaspect; @@ -1060,7 +1054,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double intval = ListGetInt(tags); if (intval >= 0 && intval <= 3) { - assert(fortext == false); + assert(type != DrawTexture_Text); if (img == NULL) return false; parms->cleanmode = DTA_Fullscreen; parms->fsscalemode = (uint8_t)intval; @@ -1135,32 +1129,32 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_TopOffset: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->top = ListGetInt(tags); break; case DTA_TopOffsetF: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->top = ListGetDouble(tags); break; case DTA_LeftOffset: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->left = ListGetInt(tags); break; case DTA_LeftOffsetF: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->left = ListGetDouble(tags); break; case DTA_TopLeft: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; if (ListGetInt(tags)) { parms->left = 0; @@ -1169,8 +1163,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_CenterOffset: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; if (ListGetInt(tags)) { parms->left = img->GetDisplayWidth() * 0.5; @@ -1179,8 +1173,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_CenterOffsetRel: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; intval = ListGetInt(tags); if (intval == 1) { @@ -1195,8 +1189,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_CenterBottomOffset: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; if (ListGetInt(tags)) { parms->left = img->GetDisplayWidth() * 0.5; @@ -1205,26 +1199,26 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_WindowLeft: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->windowleft = ListGetInt(tags); break; case DTA_WindowLeftF: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->windowleft = ListGetDouble(tags); break; case DTA_WindowRight: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->windowright = ListGetInt(tags); break; case DTA_WindowRightF: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->windowright = ListGetDouble(tags); break; @@ -1362,8 +1356,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_Rotate: - assert(fortext == false); - if (fortext) return false; + assert(type != DrawTexture_Text); + if (type == DrawTexture_Text) return false; parms->rotateangle = ListGetDouble(tags); break; @@ -1436,8 +1430,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double } // explicitly instantiate both versions for v_text.cpp. -template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, bool fortext, bool checkimage); -template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, bool fortext, bool checkimage); +template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha); +template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha); //========================================================================== // @@ -1446,7 +1440,7 @@ template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *i //========================================================================== static void VirtualToRealCoords(F2DDrawer *drawer, double Width, double Height, double &x, double &y, double &w, double &h, - double vwidth, double vheight, bool vbottom, bool handleaspect) + double vwidth, double vheight, bool vbottom, bool handleaspect) { float myratio = float(handleaspect ? ActiveRatio (Width, Height) : (4.0 / 3.0)); @@ -1594,7 +1588,7 @@ DEFINE_ACTION_FUNCTION(FCanvas, DrawLine) return 0; } -static void DrawThickLine(int x0, int y0, int x1, int y1, double thickness, uint32_t realcolor, int alpha) +static void DrawThickLine(int x0, int y0, int x1, int y1, double thickness, uint32_t realcolor, int alpha) { if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); twod->AddThickLine(x0, y0, x1, y1, thickness, realcolor, alpha); @@ -1980,4 +1974,3 @@ DEFINE_ACTION_FUNCTION(FCanvas, ClearTransform) self->Tex->NeedUpdate(); return 0; } - diff --git a/source/common/2d/v_draw.h b/source/common/2d/v_draw.h index a9e2d7306..686e5dc46 100644 --- a/source/common/2d/v_draw.h +++ b/source/common/2d/v_draw.h @@ -103,7 +103,7 @@ enum DTA_CellX, // horizontal size of character cell DTA_CellY, // vertical size of character cell - // New additions. + // New additions. DTA_Color, DTA_FlipY, // bool: flip image vertically DTA_SrcX, // specify a source rectangle (this supersedes the poorly implemented DTA_WindowLeft/Right @@ -258,8 +258,15 @@ inline int active_con_scale(F2DDrawer *drawer) #undef DrawText // See WinUser.h for the definition of DrawText as a macro #endif +enum +{ + DrawTexture_Normal, + DrawTexture_Text, + DrawTexture_Fill, +}; + template -bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, bool fortext, bool checkimage = true); +bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, int type, PalEntry fill = ~0u, double fillalpha = 0.0); template void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms); diff --git a/source/common/2d/v_drawtext.cpp b/source/common/2d/v_drawtext.cpp index 143cc911a..2bdb64dca 100644 --- a/source/common/2d/v_drawtext.cpp +++ b/source/common/2d/v_drawtext.cpp @@ -179,7 +179,7 @@ void DrawChar(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double DrawParms parms; Va_List tags; va_start(tags.list, tag_first); - bool res = ParseDrawTextureTags(drawer, pic, x, y, tag_first, tags, &parms, false); + bool res = ParseDrawTextureTags(drawer, pic, x, y, tag_first, tags, &parms, DrawTexture_Normal); va_end(tags.list); if (!res) { @@ -208,7 +208,7 @@ void DrawChar(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double { DrawParms parms; uint32_t tag = ListGetInt(args); - bool res = ParseDrawTextureTags(drawer, pic, x, y, tag, args, &parms, false); + bool res = ParseDrawTextureTags(drawer, pic, x, y, tag, args, &parms, DrawTexture_Normal); if (!res) return; bool palettetrans = (normalcolor == CR_NATIVEPAL && parms.TranslationId != 0); PalEntry color = 0xffffffff; @@ -261,7 +261,7 @@ DEFINE_ACTION_FUNCTION(FCanvas, DrawChar) //========================================================================== // This is only needed as a dummy. The code using wide strings does not need color control. -EColorRange V_ParseFontColor(const char32_t *&color_value, int normalcolor, int boldcolor) { return CR_UNTRANSLATED; } +EColorRange V_ParseFontColor(const char32_t *&color_value, int normalcolor, int boldcolor) { return CR_UNTRANSLATED; } template void DrawTextCommon(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double y, const chartype *string, DrawParms &parms) @@ -374,7 +374,7 @@ void DrawText(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double return; va_start(tags.list, tag_first); - bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag_first, tags, &parms, true); + bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag_first, tags, &parms, DrawTexture_Text); va_end(tags.list); if (!res) { @@ -393,7 +393,7 @@ void DrawText(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double return; va_start(tags.list, tag_first); - bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag_first, tags, &parms, true); + bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag_first, tags, &parms, DrawTexture_Text); va_end(tags.list); if (!res) { @@ -411,7 +411,7 @@ void DrawText(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double return; uint32_t tag = ListGetInt(args); - bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag, args, &parms, true); + bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag, args, &parms, DrawTexture_Text); if (!res) { return; @@ -455,4 +455,3 @@ DEFINE_ACTION_FUNCTION(FCanvas, DrawText) self->Tex->NeedUpdate(); return 0; } - diff --git a/source/common/2d/wipe.cpp b/source/common/2d/wipe.cpp index 78079f47a..cc57ca29f 100755 --- a/source/common/2d/wipe.cpp +++ b/source/common/2d/wipe.cpp @@ -156,6 +156,23 @@ int wipe_CalcBurn (uint8_t *burnarray, int width, int height, int density) // TYPES ------------------------------------------------------------------- +class Wiper +{ +protected: + FGameTexture* startScreen = nullptr, * endScreen = nullptr; +public: + virtual ~Wiper(); + virtual bool Run(int ticks) = 0; + virtual void SetTextures(FGameTexture* startscreen, FGameTexture* endscreen) + { + startScreen = startscreen; + endScreen = endscreen; + } + + static Wiper* Create(int type); +}; + + class Wiper_Crossfade : public Wiper { public: diff --git a/source/common/2d/wipe.h b/source/common/2d/wipe.h index b87af09c2..08a7eeb3b 100755 --- a/source/common/2d/wipe.h +++ b/source/common/2d/wipe.h @@ -5,7 +5,6 @@ #include class FTexture; -int wipe_CalcBurn(uint8_t *buffer, int width, int height, int density); enum { @@ -16,22 +15,6 @@ enum wipe_NUMWIPES }; -class Wiper -{ -protected: - FGameTexture *startScreen = nullptr, *endScreen = nullptr; -public: - virtual ~Wiper(); - virtual bool Run(int ticks) = 0; - virtual void SetTextures(FGameTexture *startscreen, FGameTexture *endscreen) - { - startScreen = startscreen; - endScreen = endscreen; - } - - static Wiper *Create(int type); -}; - void PerformWipe(FTexture* startimg, FTexture* endimg, int wipe_type, bool stopsound, std::function overlaydrawer); diff --git a/source/common/audio/music/i_music.h b/source/common/audio/music/i_music.h index 85be1dea2..a6609eadb 100644 --- a/source/common/audio/music/i_music.h +++ b/source/common/audio/music/i_music.h @@ -58,12 +58,12 @@ EXTERN_CVAR(Float, snd_musicvolume) inline float AmplitudeTodB(float amplitude) { - return 20.0f * log10(amplitude); + return 20.0f * log10f(amplitude); } inline float dBToAmplitude(float dB) { - return pow(10.0f, dB / 20.0f); + return powf(10.0f, dB / 20.0f); } #endif //__I_MUSIC_H__ diff --git a/source/common/audio/music/i_soundfont.cpp b/source/common/audio/music/i_soundfont.cpp index a01f835e6..f05f0cb76 100644 --- a/source/common/audio/music/i_soundfont.cpp +++ b/source/common/audio/music/i_soundfont.cpp @@ -38,12 +38,13 @@ #include "i_soundinternal.h" #include "cmdlib.h" #include "i_system.h" -#include "gameconfigfile.h" #include "filereadermusicinterface.h" #include #include "resourcefile.h" #include "version.h" #include "findfile.h" +#include "i_interface.h" +#include "configfile.h" //========================================================================== // @@ -392,6 +393,7 @@ void FSoundFontManager::CollectSoundfonts() findstate_t c_file; void *file; + FConfigFile* GameConfig = sysCallbacks.GetConfig ? sysCallbacks.GetConfig() : nullptr; if (GameConfig != NULL && GameConfig->SetSection ("SoundfontSearch.Directories")) { const char *key; diff --git a/source/common/audio/music/music.cpp b/source/common/audio/music/music.cpp index d125bf36d..ffc0b5ad8 100644 --- a/source/common/audio/music/music.cpp +++ b/source/common/audio/music/music.cpp @@ -51,8 +51,8 @@ #include #include "md5.h" #include "gain_analysis.h" -#include "gameconfigfile.h" #include "i_specialpaths.h" +#include "configfile.h" // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- diff --git a/source/common/audio/sound/s_sound.cpp b/source/common/audio/sound/s_sound.cpp index cdd0361c5..3cb91a446 100644 --- a/source/common/audio/sound/s_sound.cpp +++ b/source/common/audio/sound/s_sound.cpp @@ -44,8 +44,11 @@ #include "m_random.h" #include "printf.h" #include "c_cvars.h" +#include "gamestate.h" CVARD(Bool, snd_enabled, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enables/disables sound effects") +CVAR(Bool, i_soundinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, i_pauseinbackground, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) int SoundEnabled() { @@ -1710,3 +1713,155 @@ void S_SoundReset() S_RestartMusic(); } +//========================================================================== +// +// CCMD cachesound +// +//========================================================================== + +#include "s_music.h" +#include "vm.h" +#include "c_dispatch.h" +#include "stats.h" +#include "i_net.h" +#include "i_interface.h" + + +CCMD(cachesound) +{ + if (argv.argc() < 2) + { + Printf("Usage: cachesound ...\n"); + return; + } + for (int i = 1; i < argv.argc(); ++i) + { + FSoundID sfxnum = argv[i]; + if (sfxnum != FSoundID(0)) + { + soundEngine->CacheSound(sfxnum); + } + } +} + + +CCMD(listsoundchannels) +{ + Printf("%s", soundEngine->ListSoundChannels().GetChars()); +} + +// intentionally moved here to keep the s_music include out of the rest of the file. + +//========================================================================== +// +// S_PauseSound +// +// Stop music and sound effects, during game PAUSE. +//========================================================================== + +void S_PauseSound(bool notmusic, bool notsfx) +{ + if (!notmusic) + { + S_PauseMusic(); + } + if (!notsfx) + { + soundEngine->SetPaused(true); + GSnd->SetSfxPaused(true, 0); + } +} + +DEFINE_ACTION_FUNCTION(DObject, S_PauseSound) +{ + PARAM_PROLOGUE; + PARAM_BOOL(notmusic); + PARAM_BOOL(notsfx); + S_PauseSound(notmusic, notsfx); + return 0; +} + +//========================================================================== +// +// S_ResumeSound +// +// Resume music and sound effects, after game PAUSE. +//========================================================================== + +void S_ResumeSound(bool notsfx) +{ + S_ResumeMusic(); + if (!notsfx) + { + soundEngine->SetPaused(false); + GSnd->SetSfxPaused(false, 0); + } +} + +DEFINE_ACTION_FUNCTION(DObject, S_ResumeSound) +{ + PARAM_PROLOGUE; + PARAM_BOOL(notsfx); + S_ResumeSound(notsfx); + return 0; +} + +//========================================================================== +// +// S_SetSoundPaused +// +// Called with state non-zero when the app is active, zero when it isn't. +// +//========================================================================== + +void S_SetSoundPaused(int state) +{ + if (!netgame && (i_pauseinbackground)) + { + pauseext = !state; + } + + if ((state || i_soundinbackground) && !pauseext) + { + if (paused == 0) + { + S_ResumeSound(true); + if (GSnd != nullptr) + { + GSnd->SetInactive(SoundRenderer::INACTIVE_Active); + } + } + } + else + { + if (paused == 0) + { + S_PauseSound(false, true); + if (GSnd != nullptr) + { + GSnd->SetInactive(gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL ? + SoundRenderer::INACTIVE_Complete : + SoundRenderer::INACTIVE_Mute); + } + } + } +} + + + +CCMD(snd_status) +{ + GSnd->PrintStatus(); +} + +CCMD(snd_listdrivers) +{ + GSnd->PrintDriversList(); +} + +ADD_STAT(sound) +{ + return GSnd->GatherStats(); +} + + diff --git a/source/common/audio/sound/s_soundinternal.h b/source/common/audio/sound/s_soundinternal.h index f15c994dc..a30dd3fc0 100644 --- a/source/common/audio/sound/s_soundinternal.h +++ b/source/common/audio/sound/s_soundinternal.h @@ -306,6 +306,7 @@ public: void MarkUsed(int num); void CacheMarkedSounds(); TArray AllActiveChannels(); + virtual void SetSoundPaused(int state) {} void MarkAllUnused() { diff --git a/source/common/console/c_bind.cpp b/source/common/console/c_bind.cpp index d131cb6ed..90ceaedce 100644 --- a/source/common/console/c_bind.cpp +++ b/source/common/console/c_bind.cpp @@ -49,8 +49,6 @@ #include "d_eventbase.h" -extern int chatmodeon; - const char *KeyNames[NUM_KEYS] = { // We use the DirectInput codes and assume a qwerty keyboard layout. @@ -69,7 +67,7 @@ const char *KeyNames[NUM_KEYS] = "KP2", "KP3", "KP0", "KP.", nullptr, nullptr, "OEM102", "F11", //50 "F12", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, //58 nullptr, nullptr, nullptr, nullptr, "F13", "F14", "F15", "F16", //60 - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, //68 + "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", //68 "Kana", nullptr, nullptr, "Abnt_C1", nullptr, nullptr, nullptr, nullptr, //70 nullptr, "Convert", nullptr, "NoConvert",nullptr, "Yen", "Abnt_C2", nullptr, //78 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, //80 diff --git a/source/common/console/c_console.cpp b/source/common/console/c_console.cpp index ca8540dd4..c436ddd56 100644 --- a/source/common/console/c_console.cpp +++ b/source/common/console/c_console.cpp @@ -45,7 +45,7 @@ #include "filesystem.h" #include "d_gui.h" #include "cmdlib.h" -#include "d_event.h" +#include "d_eventbase.h" #include "c_consolebuffer.h" #include "utf8.h" #include "v_2ddrawer.h" @@ -95,7 +95,6 @@ static FTextureID conflat; static uint32_t conshade; static bool conline; -extern int chatmodeon; extern FBaseCVar *CVars; extern FConsoleCommand *Commands[FConsoleCommand::HASH_SIZE]; diff --git a/source/common/console/c_console.h b/source/common/console/c_console.h index 8fff823b4..bae857f7d 100644 --- a/source/common/console/c_console.h +++ b/source/common/console/c_console.h @@ -85,5 +85,6 @@ extern double NotifyFontScale; void C_SetNotifyFontScale(double scale); extern const char *console_bar; +extern int chatmodeon; #endif diff --git a/source/common/console/c_cvars.cpp b/source/common/console/c_cvars.cpp index 2d08d7b68..15b2ca747 100644 --- a/source/common/console/c_cvars.cpp +++ b/source/common/console/c_cvars.cpp @@ -43,6 +43,7 @@ #include "engineerrors.h" #include "printf.h" #include "palutil.h" +#include "i_interface.h" struct FLatchedValue @@ -1462,7 +1463,7 @@ EXTERN_CVAR(Bool, sv_cheats); void FBaseCVar::CmdSet (const char *newval) { - if ((GetFlags() & CVAR_CHEAT) && CheckCheatmode ()) + if ((GetFlags() & CVAR_CHEAT) && sysCallbacks.CheckCheatmode && sysCallbacks.CheckCheatmode(true, false)) return; MarkUnsafe(); diff --git a/source/common/console/c_dispatch.h b/source/common/console/c_dispatch.h index 57d681c49..532ed9b92 100644 --- a/source/common/console/c_dispatch.h +++ b/source/common/console/c_dispatch.h @@ -59,8 +59,6 @@ extern bool ParsingKeyConf, UnsafeExecutionContext; extern FString StoredWarp; // [RH] +warp at the command line -extern bool CheckCheatmode (bool printmsg = true, bool sponly = false); - FExecList *C_ParseCmdLineParams(FExecList *exec); // Add commands to the console as if they were typed in. Can handle wait diff --git a/source/common/engine/d_event.cpp b/source/common/engine/d_event.cpp index f851bb49e..6458500b1 100644 --- a/source/common/engine/d_event.cpp +++ b/source/common/engine/d_event.cpp @@ -94,7 +94,7 @@ void D_ProcessEvents (void) continue; // menu ate the event } - if (G_Responder(ev) && ev->type == EV_KeyDown) keywasdown.Set(ev->data1); + if (sysCallbacks.G_Responder(ev) && ev->type == EV_KeyDown) keywasdown.Set(ev->data1); } for (auto& ev: delayedevents) diff --git a/source/common/engine/i_interface.cpp b/source/common/engine/i_interface.cpp index 13d35a3a9..580dde407 100644 --- a/source/common/engine/i_interface.cpp +++ b/source/common/engine/i_interface.cpp @@ -1,5 +1,9 @@ #include "i_interface.h" #include "st_start.h" +#include "gamestate.h" +#include "startupinfo.h" +#include "c_cvars.h" +#include "gstrings.h" static_assert(sizeof(void*) == 8, "32 builds are not supported"); @@ -10,3 +14,25 @@ FString endoomName; bool batchrun; float menuBlurAmount; +bool AppActive = true; +int chatmodeon; +gamestate_t gamestate = GS_STARTUP; +bool ToggleFullscreen; +int paused; +bool pauseext; + +FStartupInfo GameStartupInfo; + +CVAR(Bool, queryiwad, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR(String, defaultiwad, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR(Bool, vid_fps, false, 0) + +EXTERN_CVAR(Bool, ui_generic) + +CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +{ + GStrings.UpdateLanguage(self); + UpdateGenericUI(ui_generic); + if (sysCallbacks.LanguageChanged) sysCallbacks.LanguageChanged(self); +} + diff --git a/source/common/engine/i_interface.h b/source/common/engine/i_interface.h index be3651886..c391e21dc 100644 --- a/source/common/engine/i_interface.h +++ b/source/common/engine/i_interface.h @@ -2,14 +2,18 @@ #include "zstring.h" #include "intrect.h" +#include "name.h" struct event_t; class FRenderState; class FGameTexture; +class FTextureID; enum EUpscaleFlags : int; +class FConfigFile; struct SystemCallbacks { + bool (*G_Responder)(event_t* ev); // this MUST be set, otherwise nothing will work bool (*WantGuiCapture)(); bool (*WantLeftButton)(); bool (*NetGame)(); @@ -35,6 +39,13 @@ struct SystemCallbacks void (*ToggleFullConsole)(); void (*StartCutscene)(bool blockui); void (*SetTransition)(int type); + bool (*CheckCheatmode)(bool printmsg, bool sponly); + void (*HudScaleChanged)(); + bool (*SetSpecialMenu)(FName& menu, int param); + void (*OnMenuOpen)(bool makesound); + void (*LanguageChanged)(const char*); + bool (*OkForLocalization)(FTextureID, const char*); + FConfigFile* (*GetConfig)(); }; extern SystemCallbacks sysCallbacks; @@ -50,5 +61,7 @@ extern FString endoomName; extern bool batchrun; extern float menuBlurAmount; extern bool generic_ui; +extern int paused; +extern bool pauseext; void UpdateGenericUI(bool cvar); diff --git a/source/common/engine/m_joy.cpp b/source/common/engine/m_joy.cpp index 4d64f420f..3c46d2527 100644 --- a/source/common/engine/m_joy.cpp +++ b/source/common/engine/m_joy.cpp @@ -35,7 +35,8 @@ #include #include "vectors.h" #include "m_joy.h" -#include "gameconfigfile.h" +#include "configfile.h" +#include "i_interface.h" #include "d_eventbase.h" #include "cmdlib.h" #include "printf.h" @@ -92,10 +93,11 @@ IJoystickConfig::~IJoystickConfig() // //========================================================================== -static bool M_SetJoystickConfigSection(IJoystickConfig *joy, bool create) +static bool M_SetJoystickConfigSection(IJoystickConfig *joy, bool create, FConfigFile* GameConfig) { FString id = "Joy:"; id += joy->GetIdentifier(); + if (!GameConfig) return false; return GameConfig->SetSection(id, create); } @@ -107,13 +109,14 @@ static bool M_SetJoystickConfigSection(IJoystickConfig *joy, bool create) bool M_LoadJoystickConfig(IJoystickConfig *joy) { + FConfigFile* GameConfig = sysCallbacks.GetConfig ? sysCallbacks.GetConfig() : nullptr; char key[32]; const char *value; int axislen; int numaxes; joy->SetDefaultConfig(); - if (!M_SetJoystickConfigSection(joy, false)) + if (!M_SetJoystickConfigSection(joy, false, GameConfig)) { return false; } @@ -166,10 +169,11 @@ bool M_LoadJoystickConfig(IJoystickConfig *joy) void M_SaveJoystickConfig(IJoystickConfig *joy) { + FConfigFile* GameConfig = sysCallbacks.GetConfig ? sysCallbacks.GetConfig() : nullptr; char key[32], value[32]; int axislen, numaxes; - if (GameConfig != NULL && M_SetJoystickConfigSection(joy, true)) + if (GameConfig != NULL && M_SetJoystickConfigSection(joy, true, GameConfig)) { GameConfig->ClearCurrentSection(); if (!joy->IsSensitivityDefault()) diff --git a/source/common/filesystem/filesystem.cpp b/source/common/filesystem/filesystem.cpp index 69f887860..5af6215fb 100644 --- a/source/common/filesystem/filesystem.cpp +++ b/source/common/filesystem/filesystem.cpp @@ -1608,17 +1608,17 @@ FileData::~FileData () { } -FString::FString(ELumpNum lumpnum) +FString::FString (ELumpNum lumpnum) { - auto lumpr = fileSystem.OpenFileReader((int)lumpnum); - auto size = lumpr.GetLength(); - AllocBuffer(size + 1); - auto numread = lumpr.Read(&Chars[0], size); + auto lumpr = fileSystem.OpenFileReader ((int)lumpnum); + auto size = lumpr.GetLength (); + AllocBuffer (1 + size); + auto numread = lumpr.Read (&Chars[0], size); Chars[size] = '\0'; if (numread != size) { - I_Error("ConstructStringFromLump: Only read %ld of %ld bytes on lump %i (%s)\n", + I_Error ("ConstructStringFromLump: Only read %ld of %ld bytes on lump %i (%s)\n", numread, size, lumpnum, fileSystem.GetFileFullName((int)lumpnum)); } } diff --git a/source/common/fonts/v_text.cpp b/source/common/fonts/v_text.cpp index e9ccb2a50..b7467a8ab 100644 --- a/source/common/fonts/v_text.cpp +++ b/source/common/fonts/v_text.cpp @@ -265,7 +265,6 @@ DEFINE_ACTION_FUNCTION(FFont, BreakLines) bool generic_ui; -EXTERN_CVAR(String, language) bool CheckFontComplete(FFont* font) { diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 89017d67b..187fe5e9e 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -55,11 +55,8 @@ #include "i_time.h" #include "printf.h" -void M_StartControlPanel(bool makeSound, bool scaleoverride = false); - int DMenu::InMenu; static ScaleOverrider *CurrentScaleOverrider; -extern int chatmodeon; // // Todo: Move these elsewhere // @@ -114,8 +111,6 @@ extern PClass *DefaultOptionMenuClass; #define KEY_REPEAT_DELAY (GameTicRate*5/12) #define KEY_REPEAT_RATE (3) -bool OkForLocalization(FTextureID texnum, const char* substitute); - //============================================================================ // // @@ -435,8 +430,10 @@ bool DMenu::TranslateKeyboardEvents() // //============================================================================= -void M_DoStartControlPanel (bool scaleoverride) + +void M_StartControlPanel (bool makesound, bool scaleoverride) { + if (sysCallbacks.OnMenuOpen) sysCallbacks.OnMenuOpen(makesound); // intro might call this repeatedly if (CurrentMenu != nullptr) return; @@ -505,11 +502,9 @@ DEFINE_ACTION_FUNCTION(DMenu, ActivateMenu) // //============================================================================= -bool M_SetSpecialMenu(FName& menu, int param); // game specific checks - void M_SetMenu(FName menu, int param) { - if (!M_SetSpecialMenu(menu, param)) return; + if (sysCallbacks.SetSpecialMenu && !sysCallbacks.SetSpecialMenu(menu, param)) return; DMenuDescriptor **desc = MenuDescriptors.CheckKey(menu); if (desc != nullptr) diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index a8ed61061..bad3406e9 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -303,7 +303,7 @@ void M_ActivateMenu(DMenu *menu); void M_ClearMenus (); void M_PreviousMenu (); void M_ParseMenuDefs(); -void M_DoStartControlPanel(bool scaleoverride); +void M_StartControlPanel(bool makeSound, bool scaleoverride = false); void M_SetMenu(FName menu, int param = -1); void M_StartMessage(const char *message, int messagemode, FName action = NAME_None); DMenu *StartPickerMenu(DMenu *parent, const char *name, FColorCVar *cvar); diff --git a/source/common/menu/messagebox.cpp b/source/common/menu/messagebox.cpp index 8b43d8d76..8b8334b02 100644 --- a/source/common/menu/messagebox.cpp +++ b/source/common/menu/messagebox.cpp @@ -40,7 +40,6 @@ #include "vm.h" #include "menustate.h" -void M_StartControlPanel(bool makeSound, bool scaleoverride = false); FName MessageBoxClass = NAME_MessageBoxMenu; CVAR(Bool, m_quickexit, false, CVAR_ARCHIVE) diff --git a/source/common/platform/posix/cocoa/i_input.mm b/source/common/platform/posix/cocoa/i_input.mm index 79f9d037c..46b380431 100644 --- a/source/common/platform/posix/cocoa/i_input.mm +++ b/source/common/platform/posix/cocoa/i_input.mm @@ -55,7 +55,7 @@ CVAR(Bool, use_mouse, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -extern int paused, chatmodeon; +extern int paused; extern bool ToggleFullscreen; bool GUICapture; diff --git a/source/common/platform/posix/cocoa/i_system.mm b/source/common/platform/posix/cocoa/i_system.mm index fa0134d6f..3338f54db 100644 --- a/source/common/platform/posix/cocoa/i_system.mm +++ b/source/common/platform/posix/cocoa/i_system.mm @@ -121,7 +121,7 @@ void I_ShowFatalError(const char *message) } -int I_PickIWad(WadStuff* const wads, const int numwads, const bool showwin, const int defaultiwad) +int I_PickIWad(WadStuff* const wads, const int numwads, const bool showwin, const int defaultiwad, int&) { if (!showwin) { diff --git a/source/common/platform/posix/i_system_posix.cpp b/source/common/platform/posix/i_system_posix.cpp index 698ea1c69..bb381d551 100644 --- a/source/common/platform/posix/i_system_posix.cpp +++ b/source/common/platform/posix/i_system_posix.cpp @@ -36,12 +36,11 @@ #include "cmdlib.h" #include "i_system.h" -#include "gameconfigfile.h" -bool I_WriteIniFailed() +bool I_WriteIniFailed(const char * filename) { - printf("The config file %s could not be saved:\n%s\n", GameConfig->GetPathName(), strerror(errno)); + printf("The config file %s could not be saved:\n%s\n", filename, strerror(errno)); return false; // return true to retry } diff --git a/source/common/platform/posix/sdl/i_input.cpp b/source/common/platform/posix/sdl/i_input.cpp index 933423e62..02cf31e45 100644 --- a/source/common/platform/posix/sdl/i_input.cpp +++ b/source/common/platform/posix/sdl/i_input.cpp @@ -56,7 +56,7 @@ static bool NativeMouse = true; CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -extern int WaitingForKey, chatmodeon; +extern int WaitingForKey; static const SDL_Keycode DIKToKeySym[256] = { diff --git a/source/common/platform/posix/sdl/i_system.cpp b/source/common/platform/posix/sdl/i_system.cpp index 2111adc1d..8db0f63ce 100644 --- a/source/common/platform/posix/sdl/i_system.cpp +++ b/source/common/platform/posix/sdl/i_system.cpp @@ -301,7 +301,7 @@ void I_PrintStr(const char *cp) if (StartWindow) RedrawProgressBar(ProgressBarCurPos,ProgressBarMaxPos); } -int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad) +int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad, int&) { int i; diff --git a/source/common/platform/win32/i_input.cpp b/source/common/platform/win32/i_input.cpp index f8b2c429b..01c4ce0be 100644 --- a/source/common/platform/win32/i_input.cpp +++ b/source/common/platform/win32/i_input.cpp @@ -63,7 +63,6 @@ #include "d_gui.h" #include "c_console.h" #include "s_soundinternal.h" -#include "gameconfigfile.h" #include "hardware.h" #include "d_eventbase.h" #include "v_text.h" @@ -125,8 +124,6 @@ static bool EventHandlerResultForNativeMouse; CVAR (Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -extern int chatmodeon; - static void I_CheckGUICapture () { bool wantCapt = sysCallbacks.WantGuiCapture && sysCallbacks.WantGuiCapture(); diff --git a/source/common/platform/win32/i_system.cpp b/source/common/platform/win32/i_system.cpp index 1005bd9d1..1e4c73d9f 100644 --- a/source/common/platform/win32/i_system.cpp +++ b/source/common/platform/win32/i_system.cpp @@ -80,7 +80,6 @@ #include "i_input.h" #include "c_dispatch.h" -#include "gameconfigfile.h" #include "v_font.h" #include "i_system.h" #include "bitmap.h" @@ -112,10 +111,6 @@ static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP EXTERN_CVAR (Bool, queryiwad); // Used on welcome/IWAD screen. -EXTERN_CVAR (Bool, disableautoload) -EXTERN_CVAR (Bool, autoloadlights) -EXTERN_CVAR (Bool, autoloadbrightmaps) -EXTERN_CVAR (Bool, autoloadwidescreen) EXTERN_CVAR (Int, vid_preferbackend) extern HANDLE StdOut; @@ -357,9 +352,12 @@ static void SetQueryIWad(HWND dialog) // Dialog proc for the IWAD selector. // //========================================================================== +static int* pAutoloadflags; BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { + int& flags = *pAutoloadflags;; + HWND ctrl; int i; @@ -403,10 +401,10 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // [SP] This is our's - SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_SETCHECK, disableautoload ? BST_CHECKED : BST_UNCHECKED, 0 ); - SendDlgItemMessage( hDlg, IDC_WELCOME_LIGHTS, BM_SETCHECK, autoloadlights ? BST_CHECKED : BST_UNCHECKED, 0 ); - SendDlgItemMessage( hDlg, IDC_WELCOME_BRIGHTMAPS, BM_SETCHECK, autoloadbrightmaps ? BST_CHECKED : BST_UNCHECKED, 0 ); - SendDlgItemMessage( hDlg, IDC_WELCOME_WIDESCREEN, BM_SETCHECK, autoloadwidescreen ? BST_CHECKED : BST_UNCHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_SETCHECK, (flags & 1) ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage( hDlg, IDC_WELCOME_LIGHTS, BM_SETCHECK, (flags & 2) ? BST_CHECKED : BST_UNCHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_BRIGHTMAPS, BM_SETCHECK, (flags & 4) ? BST_CHECKED : BST_UNCHECKED, 0 ); + SendDlgItemMessage( hDlg, IDC_WELCOME_WIDESCREEN, BM_SETCHECK, (flags & 8) ? BST_CHECKED : BST_UNCHECKED, 0 ); // Set up our version string. sprintf(szString, "Version %s.", GetVersionString()); @@ -461,10 +459,11 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa vid_preferbackend = 0; // [SP] This is our's. - disableautoload = SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_GETCHECK, 0, 0 ) == BST_CHECKED; - autoloadlights = SendDlgItemMessage( hDlg, IDC_WELCOME_LIGHTS, BM_GETCHECK, 0, 0 ) == BST_CHECKED; - autoloadbrightmaps = SendDlgItemMessage( hDlg, IDC_WELCOME_BRIGHTMAPS, BM_GETCHECK, 0, 0 ) == BST_CHECKED; - autoloadwidescreen = SendDlgItemMessage( hDlg, IDC_WELCOME_WIDESCREEN, BM_GETCHECK, 0, 0 ) == BST_CHECKED; + flags = 0; + if (SendDlgItemMessage(hDlg, IDC_WELCOME_NOAUTOLOAD, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 1; + if (SendDlgItemMessage(hDlg, IDC_WELCOME_LIGHTS, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 2; + if (SendDlgItemMessage(hDlg, IDC_WELCOME_BRIGHTMAPS, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 4; + if (SendDlgItemMessage(hDlg, IDC_WELCOME_WIDESCREEN, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 8; ctrl = GetDlgItem (hDlg, IDC_IWADLIST); EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); } @@ -481,10 +480,10 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // //========================================================================== -int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad) +int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad, int& autoloadflags) { int vkey; - + pAutoloadflags = &autoloadflags; if (stricmp(queryiwad_key, "shift") == 0) { vkey = VK_SHIFT; @@ -764,7 +763,7 @@ void DestroyCustomCursor() // //========================================================================== -bool I_WriteIniFailed() +bool I_WriteIniFailed(const char* filename) { char *lpMsgBuf; FString errortext; @@ -779,7 +778,7 @@ bool I_WriteIniFailed() 0, NULL ); - errortext.Format ("The config file %s could not be written:\n%s", GameConfig->GetPathName(), lpMsgBuf); + errortext.Format ("The config file %s could not be written:\n%s", filename, lpMsgBuf); LocalFree (lpMsgBuf); return MessageBoxA(mainwindow.GetHandle(), errortext.GetChars(), GAMENAME " configuration not saved", MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY; } diff --git a/source/common/platform/win32/i_system.h b/source/common/platform/win32/i_system.h index cebbfde8f..9d360b55a 100644 --- a/source/common/platform/win32/i_system.h +++ b/source/common/platform/win32/i_system.h @@ -38,10 +38,10 @@ void I_PrintStr (const char *cp); void I_SetIWADInfo (); // Pick from multiple IWADs to use -int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad); +int I_PickIWad(WadStuff* wads, int numwads, bool queryiwad, int defaultiwad, int& autoloadflags); // The ini could not be saved at exit -bool I_WriteIniFailed (); +bool I_WriteIniFailed (const char* filename); // [RH] Checks the registry for Steam's install path, so we can scan its // directories for IWADs if the user purchased any through Steam. diff --git a/source/common/rendering/gl/gl_stereo3d.cpp b/source/common/rendering/gl/gl_stereo3d.cpp index 9f6bb56f5..c13914e22 100644 --- a/source/common/rendering/gl/gl_stereo3d.cpp +++ b/source/common/rendering/gl/gl_stereo3d.cpp @@ -44,6 +44,7 @@ #include "gl_framebuffer.h" #include "gl_shaderprogram.h" #include "gl_buffers.h" +#include "menu.h" EXTERN_CVAR(Int, vr_mode) @@ -53,7 +54,32 @@ EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Int, gl_satformula) EXTERN_CVAR(Int, gl_dither_bpc) -void UpdateVRModes(bool considerQuadBuffered = true); +#ifdef _WIN32 +EXTERN_CVAR(Bool, vr_enable_quadbuffered) +#endif + +void UpdateVRModes(bool considerQuadBuffered) +{ + FOptionValues** pVRModes = OptionValues.CheckKey("VRMode"); + if (pVRModes == nullptr) return; + + TArray& vals = (*pVRModes)->mValues; + TArray filteredValues; + int cnt = vals.Size(); + for (int i = 0; i < cnt; ++i) { + auto const& mode = vals[i]; + if (mode.Value == 7) { // Quad-buffered stereo +#ifdef _WIN32 + if (!vr_enable_quadbuffered) continue; +#else + continue; // Remove quad-buffered option on Mac and Linux +#endif + if (!considerQuadBuffered) continue; // Probably no compatible screen mode was found + } + filteredValues.Push(mode); + } + vals = filteredValues; +} namespace OpenGLRenderer { diff --git a/source/common/rendering/gles/gles_samplers.cpp b/source/common/rendering/gles/gles_samplers.cpp index 8d9ddecdf..b651889e3 100644 --- a/source/common/rendering/gles/gles_samplers.cpp +++ b/source/common/rendering/gles/gles_samplers.cpp @@ -78,6 +78,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); } break; @@ -88,6 +90,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); } break; @@ -98,6 +102,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); } break; @@ -108,6 +114,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); } break; @@ -116,6 +124,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; case CLAMP_NOFILTER: @@ -123,6 +133,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; case CLAMP_NOFILTER_X: @@ -130,6 +142,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; case CLAMP_NOFILTER_Y: @@ -137,6 +151,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; case CLAMP_NOFILTER_XY: @@ -144,6 +160,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; case CLAMP_CAMTEX: @@ -151,6 +169,8 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); + if (gles.anistropicFilterAvailable) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; } glActiveTexture(GL_TEXTURE0); diff --git a/source/common/rendering/gles/gles_system.cpp b/source/common/rendering/gles/gles_system.cpp index edaa86afa..5d82511b6 100644 --- a/source/common/rendering/gles/gles_system.cpp +++ b/source/common/rendering/gles/gles_system.cpp @@ -184,11 +184,13 @@ namespace OpenGLESRenderer gles.depthStencilAvailable = CheckExtension("GL_OES_packed_depth_stencil"); gles.npotAvailable = CheckExtension("GL_OES_texture_npot"); gles.depthClampAvailable = CheckExtension("GL_EXT_depth_clamp"); + gles.anistropicFilterAvailable = CheckExtension("GL_EXT_texture_filter_anisotropic"); #else gles.depthStencilAvailable = true; gles.npotAvailable = true; gles.useMappedBuffers = true; gles.depthClampAvailable = true; + gles.anistropicFilterAvailable = true; #endif gles.numlightvectors = (gles.maxlights * LIGHT_VEC4_NUM); diff --git a/source/common/rendering/gles/gles_system.h b/source/common/rendering/gles/gles_system.h index d7f6ed139..f884d4593 100644 --- a/source/common/rendering/gles/gles_system.h +++ b/source/common/rendering/gles/gles_system.h @@ -23,7 +23,8 @@ #include #include -#define USE_GLES2 0 +#define USE_GLES2 0 // For Desktop PC leave as 0, it will use the exisiting OpenGL context creationg code but run with the GLES2 renderer + // Set to 1 for when comipling for a real GLES device #if (USE_GLES2) #include "glad/glad.h" @@ -43,6 +44,7 @@ GLAPI PFNGLUNMAPBUFFEROESPROC glUnmapBuffer; #define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 #define GL_BGRA 0x80E1 #define GL_DEPTH_CLAMP 0x864F +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE #else #include "gl_load/gl_load.h" @@ -71,6 +73,7 @@ namespace OpenGLESRenderer bool npotAvailable; bool forceGLSLv100; bool depthClampAvailable; + bool anistropicFilterAvailable; int max_texturesize; char* vendorstring; char* modelstring; diff --git a/source/common/scripting/core/dynarrays.cpp b/source/common/scripting/core/dynarrays.cpp index 8c51daa94..207c91fbc 100644 --- a/source/common/scripting/core/dynarrays.cpp +++ b/source/common/scripting/core/dynarrays.cpp @@ -842,27 +842,45 @@ DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Clear, ArrayClear) // //----------------------------------------------------- -DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Copy, ArrayCopy) +void ObjArrayCopy(FDynArray_Obj *self, FDynArray_Obj *other) { - PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); - PARAM_POINTER(other, FDynArray_Obj); + for (auto& elem : *other) GC::WriteBarrier(elem); *self = *other; - return 0; } -DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Move, ArrayMove) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Copy, ObjArrayCopy) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_POINTER(other, FDynArray_Obj); + ObjArrayCopy(self, other); + return 0; +} + +void ObjArrayMove(FDynArray_Obj *self, FDynArray_Obj *other) +{ + for (auto& elem : *other) GC::WriteBarrier(elem); *self = std::move(*other); - return 0; } -DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Append, ArrayAppend) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Move, ObjArrayMove) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_POINTER(other, FDynArray_Obj); + ObjArrayMove(self, other); + return 0; +} + +void ObjArrayAppend(FDynArray_Obj *self, FDynArray_Obj *other) +{ + for (auto& elem : *other) GC::WriteBarrier(elem); self->Append(*other); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Append, ObjArrayAppend) +{ + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); + PARAM_POINTER(other, FDynArray_Obj); + ObjArrayAppend(self, other); return 0; } diff --git a/source/common/scripting/interface/vmnatives.cpp b/source/common/scripting/interface/vmnatives.cpp index 8f9f8dfad..4a0d3758b 100644 --- a/source/common/scripting/interface/vmnatives.cpp +++ b/source/common/scripting/interface/vmnatives.cpp @@ -522,11 +522,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckRealHeight, CheckRealHeight) ACTION_RETURN_INT(CheckRealHeight(texid)); } -bool OkForLocalization(FTextureID texnum, const char* substitute); - static int OkForLocalization_(int index, const FString& substitute) { - return OkForLocalization(FSetTextureID(index), substitute); + return sysCallbacks.OkForLocalization? sysCallbacks.OkForLocalization(FSetTextureID(index), substitute) : false; } DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, OkForLocalization, OkForLocalization_) @@ -719,6 +717,19 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetDefaultKerning, GetDefaultKerning) ACTION_RETURN_INT(self->GetDefaultKerning()); } +static double GetDisplayTopOffset(FFont* font, int c) +{ + auto texc = font->GetChar(c, CR_UNDEFINED, nullptr); + return texc ? texc->GetDisplayTopOffset() : 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetDisplayTopOffset, GetDisplayTopOffset) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + PARAM_INT(code); + ACTION_RETURN_FLOAT(GetDisplayTopOffset(self, code)); +} + //========================================================================== // // file system diff --git a/source/common/scripting/vm/vm.h b/source/common/scripting/vm/vm.h index fe64e9b4d..980f5b1d8 100644 --- a/source/common/scripting/vm/vm.h +++ b/source/common/scripting/vm/vm.h @@ -131,7 +131,7 @@ struct VMReturn *(double *)Location = val; } void SetVector(const double val[3]) - { + { assert(RegType == (REGT_FLOAT|REGT_MULTIREG3)); ((double *)Location)[0] = val[0]; ((double *)Location)[1] = val[1]; @@ -513,7 +513,7 @@ bool AssertObject(void * ob); #define PARAM_BOOL_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); bool x = !!param[p].i; #define PARAM_NAME_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); FName x = ENamedName(param[p].i); #define PARAM_SOUND_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); FSoundID x = param[p].i; -#define PARAM_COLOR_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); PalEntry x; x.d = param[p].i; +#define PARAM_COLOR_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); PalEntry x = param[p].i; #define PARAM_FLOAT_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_FLOAT); double x = param[p].f; #define PARAM_ANGLE_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_FLOAT); DAngle x = DAngle::fromDeg(param[p].f); #define PARAM_FANGLE_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_FLOAT); FAngle x = FAngle::fromDeg(param[p].f); diff --git a/source/common/startscreen/startscreen.cpp b/source/common/startscreen/startscreen.cpp index 14adefac4..660561fd2 100644 --- a/source/common/startscreen/startscreen.cpp +++ b/source/common/startscreen/startscreen.cpp @@ -49,7 +49,6 @@ #include "v_draw.h" #include "g_input.h" #include "texturemanager.h" -#include "gi.h" // Text mode color values enum{ diff --git a/source/common/startscreen/startscreen.h b/source/common/startscreen/startscreen.h index 2b81a9cfb..75ccf97a0 100644 --- a/source/common/startscreen/startscreen.h +++ b/source/common/startscreen/startscreen.h @@ -38,6 +38,7 @@ #include #include #include "bitmap.h" +#include "zstring.h" class FGameTexture; diff --git a/source/common/statusbar/base_sbar.cpp b/source/common/statusbar/base_sbar.cpp index bac2bbd3a..9e0431610 100644 --- a/source/common/statusbar/base_sbar.cpp +++ b/source/common/statusbar/base_sbar.cpp @@ -46,6 +46,7 @@ #include "utf8.h" #include "v_text.h" #include "vm.h" +#include "i_interface.h" FGameTexture* CrosshairImage; static int CrosshairNum; @@ -60,8 +61,18 @@ CVAR(Int, crosshairhealth, 2, CVAR_ARCHIVE); CVARD(Float, crosshairscale, 0.5, CVAR_ARCHIVE, "changes the size of the crosshair"); CVAR(Bool, crosshairgrow, false, CVAR_ARCHIVE); -EXTERN_CVAR(Float, hud_scalefactor) -EXTERN_CVAR(Bool, hud_aspectscale) +CUSTOM_CVARD(Float, hud_scalefactor, 1, CVAR_ARCHIVE, "changes the hud scale") +{ + if (self < 0.36f) self = 0.36f; + else if (self > 1) self = 1; + else if (sysCallbacks.HudScaleChanged) sysCallbacks.HudScaleChanged(); +} + +CUSTOM_CVARD(Bool, hud_aspectscale, true, CVAR_ARCHIVE, "enables aspect ratio correction for the status bar") +{ + if (sysCallbacks.HudScaleChanged) sysCallbacks.HudScaleChanged(); +} + void ST_LoadCrosshair(int num, bool alwaysload) { diff --git a/source/common/textures/formats/startscreentexture.cpp b/source/common/textures/formats/startscreentexture.cpp index 490b74fd7..85710d42f 100644 --- a/source/common/textures/formats/startscreentexture.cpp +++ b/source/common/textures/formats/startscreentexture.cpp @@ -35,7 +35,6 @@ */ #include "files.h" -#include "gi.h" #include "bitmap.h" #include "textures.h" #include "imagehelpers.h" diff --git a/source/common/textures/texturemanager.cpp b/source/common/textures/texturemanager.cpp index cc070bcd6..654519d0f 100644 --- a/source/common/textures/texturemanager.cpp +++ b/source/common/textures/texturemanager.cpp @@ -1183,7 +1183,6 @@ void FTextureManager::AddLocalizedVariants() // //========================================================================== FGameTexture *CreateShaderTexture(bool, bool); -void InitBuildTiles(); FImageSource* CreateEmptyTexture(); void FTextureManager::Init() @@ -1213,7 +1212,7 @@ void FTextureManager::Init() AddGameTexture(mt); } -void FTextureManager::AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&)) +void FTextureManager::AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&), void (*customtexturehandler)()) { progressFunc = progressFunc_; //if (BuildTileFiles.Size() == 0) CountBuildTiles (); @@ -1229,9 +1228,9 @@ void FTextureManager::AddTextures(void (*progressFunc_)(), void (*checkForHacks) build.ResolveAllPatches(); // Add one marker so that the last WAD is easier to handle and treat - // Build tiles as a completely separate block. + // custom textures as a completely separate block. FirstTextureForFile.Push(Textures.Size()); - InitBuildTiles (); + if (customtexturehandler) customtexturehandler(); FirstTextureForFile.Push(Textures.Size()); DefaultTexture = CheckForTexture ("-NOFLAT-", ETextureType::Override, 0); diff --git a/source/common/textures/texturemanager.h b/source/common/textures/texturemanager.h index 03212ddf5..bed10e659 100644 --- a/source/common/textures/texturemanager.h +++ b/source/common/textures/texturemanager.h @@ -124,7 +124,7 @@ public: void LoadTextureX(int wadnum, FMultipatchTextureBuilder &build); void AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &build); void Init(); - void AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&)); + void AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&), void (*customtexturehandler)() = nullptr); void DeleteAll(); void ReplaceTexture (FTextureID picnum, FGameTexture *newtexture, bool free); diff --git a/source/gitinfo.cpp b/source/common/utility/gitinfo.cpp similarity index 100% rename from source/gitinfo.cpp rename to source/common/utility/gitinfo.cpp diff --git a/source/common/utility/vectors.h b/source/common/utility/vectors.h index 23452f07b..c009cb505 100644 --- a/source/common/utility/vectors.h +++ b/source/common/utility/vectors.h @@ -1366,12 +1366,6 @@ public: } }; -// Emulates the old floatbob offset table with direct calls to trig functions. -inline double BobSin(double fb) -{ - return g_sindeg(double(fb * (180.0 / 32))) * 8; -} - template inline TAngle fabs (const TAngle °) { diff --git a/source/core/cheathandler.cpp b/source/core/cheathandler.cpp index 11c0633fb..5d3ee95f2 100644 --- a/source/core/cheathandler.cpp +++ b/source/core/cheathandler.cpp @@ -42,6 +42,7 @@ #include "utf8.h" #include "d_protocol.h" #include "d_net.h" +#include "gamecontrol.h" static cheatseq_t *cheatlist; static int numcheats; diff --git a/source/core/ct_chat.cpp b/source/core/ct_chat.cpp index 80e288559..bbdeb8909 100644 --- a/source/core/ct_chat.cpp +++ b/source/core/ct_chat.cpp @@ -72,7 +72,7 @@ void CT_Drawer (); bool CT_Responder (event_t *ev); void CT_PasteChat(const char *clip); -int chatmodeon; +extern int chatmodeon; // Private data diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 058bf2ab1..5c1ed04c7 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -88,19 +88,12 @@ void LoadHexFont(const char* filename); CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, autoloadwidescreen, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR (Bool, i_soundinbackground, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR (Bool, i_pauseinbackground, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // Note: For the automap label there is a separate option "am_textfont". CVARD(Bool, hud_textfont, false, CVAR_ARCHIVE, "Use the regular text font as replacement for the tiny 3x5 font for HUD messages whenever possible") EXTERN_CVAR(Bool, ui_generic) - -CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) -{ - GStrings.UpdateLanguage(self); - UpdateGenericUI(ui_generic); -} +EXTERN_CVAR(String, language) CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) { @@ -136,7 +129,6 @@ extern bool pauseext; cycle_t thinktime, actortime, gameupdatetime, drawtime; -gamestate_t gamestate = GS_STARTUP; gameaction_t gameaction = ga_nothing; // gameaction state MapRecord* g_nextmap; @@ -146,8 +138,6 @@ int g_bossexit; FILE* hashfile; -FStartupInfo GameStartupInfo; - InputState inputState; int ShowStartupWindow(TArray &); TArray GetGameFronUserFiles(); @@ -166,22 +156,22 @@ void MarkMap(); void BuildFogTable(); void ParseGLDefs(); void I_UpdateDiscordPresence(bool SendPresence, const char* curstatus, const char* appid, const char* steamappid); +bool G_Responder(event_t* ev); +void HudScaleChanged(); +bool M_SetSpecialMenu(FName& menu, int param); +void OnMenuOpen(bool makeSound); DStatusBarCore* StatusBar; - -bool AppActive = true; - FString currentGame; FString LumpFilter; -CVAR(Bool, queryiwad, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); -CVAR(String, defaultiwad, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +EXTERN_CVAR(Bool, queryiwad); +EXTERN_CVAR(String, defaultiwad); CVAR(Bool, disableautoload, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) extern int hud_size_max; -int paused; bool pausedWithKey; bool gamesetinput = false; @@ -553,6 +543,8 @@ static void System_SetTransition(int type) nextwipe = type; } + + void I_StartupJoysticks(); void I_ShutdownInput(); int RunGame(); @@ -566,6 +558,7 @@ int GameMain() SetConsoleNotifyBuffer(); sysCallbacks = { + G_Responder, System_WantGuiCapture, System_WantLeftButton, System_NetGame, @@ -591,6 +584,13 @@ int GameMain() System_ToggleFullConsole, System_StartCutscene, System_SetTransition, + CheckCheatmode, + HudScaleChanged, + M_SetSpecialMenu, + OnMenuOpen, + nullptr, + nullptr, + []() ->FConfigFile* { return GameConfig; } }; try @@ -773,9 +773,20 @@ static TArray SetupGame() stuff.Path = ExtractFileBase(found.FileName); wads.Push(stuff); } - pick = I_PickIWad(&wads[0], (int)wads.Size(), queryiwad, pick); + + int flags = 0; + if (disableautoload) flags |= 1; + if (autoloadlights) flags |= 2; + if (autoloadbrightmaps) flags |= 4; + if (autoloadwidescreen) flags |= 8; + + pick = I_PickIWad(&wads[0], (int)wads.Size(), queryiwad, pick, flags); if (pick >= 0) { + disableautoload = !!(flags & 1); + autoloadlights = !!(flags & 2); + autoloadbrightmaps = !!(flags & 4); + autoloadwidescreen = !!(flags & 8); // The newly selected IWAD becomes the new default defaultiwad = groups[pick].FileName; } @@ -1242,92 +1253,6 @@ CCMD(snd_reset) Mus_ResumeSaved(); } -//========================================================================== -// -// S_PauseSound -// -// Stop music and sound effects, during game PAUSE. -// -//========================================================================== - -void S_PauseSound (bool notmusic, bool notsfx) -{ - if (!notmusic) - { - S_PauseMusic(); - } - if (!notsfx) - { - soundEngine->SetPaused(true); - GSnd->SetSfxPaused (true, 0); - S_PauseAllCustomStreams(true); - } -} - -//========================================================================== -// -// S_ResumeSound -// -// Resume music and sound effects, after game PAUSE. -// -//========================================================================== - -void S_ResumeSound (bool notsfx) -{ - S_ResumeMusic(); - if (!notsfx) - { - soundEngine->SetPaused(false); - GSnd->SetSfxPaused (false, 0); - S_PauseAllCustomStreams(false); - } -} - -//========================================================================== -// -// S_SetSoundPaused -// -// Called with state non-zero when the app is active, zero when it isn't. -// -//========================================================================== - -void S_SetSoundPaused(int state) -{ - if (!netgame && (i_pauseinbackground) -#if 0 //ifdef _DEBUG - && !demoplayback -#endif - ) - { - pauseext = !state; - } - - if ((state || i_soundinbackground) && !pauseext) - { - if (paused == 0) - { - S_ResumeSound(true); - if (GSnd != nullptr) - { - GSnd->SetInactive(SoundRenderer::INACTIVE_Active); - } - } - } - else - { - if (paused == 0) - { - S_PauseSound(false, true); - if (GSnd != nullptr) - { - GSnd->SetInactive(gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL ? - SoundRenderer::INACTIVE_Complete : - SoundRenderer::INACTIVE_Mute); - } - } - } -} - FString G_GetDemoPath() { diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 191f071e0..93cf9b6f0 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -45,6 +45,7 @@ void updatePauseStatus(); void DeferredStartGame(MapRecord* map, int skill, bool nostopsound = false); void ChangeLevel(MapRecord* map, int skill, bool bossexit = false); void CompleteLevel(MapRecord* map); +bool CheckCheatmode(bool printmsg = true, bool sponly = false); void TITLE_InformName(const char* newname); diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 15b6baf50..dd53cd347 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -132,19 +132,11 @@ CUSTOM_CVARD(Int, hud_size, Hud_Stbar, CVAR_ARCHIVE, "Defines the HUD size and s else setViewport(self); } -CUSTOM_CVARD(Float, hud_scalefactor, 1, CVAR_ARCHIVE, "changes the hud scale") -{ - if (self < 0.36f) self = 0.36f; - else if (self > 1) self = 1; - else setViewport(hud_size); -} - -CUSTOM_CVAR(Bool, hud_aspectscale, true, CVAR_ARCHIVE) +void HudScaleChanged() { setViewport(hud_size); } - // Note: The shift detection here should be part of the key event data, but that requires a lot more work. Ideally use a ShiftBinds mapping. For control through bound keys this should be fine, bunt not for use from the console. CCMD(sizeup) { diff --git a/source/core/gamehud.cpp b/source/core/gamehud.cpp index 33b07e4f7..f76c62306 100644 --- a/source/core/gamehud.cpp +++ b/source/core/gamehud.cpp @@ -87,7 +87,7 @@ void hud_drawsprite(double sx, double sy, double sz, double a, int picnum, int d // Draws the fps counter, dot ticker, and palette debug. // //========================================================================== -CVAR(Bool, vid_fps, false, 0) +EXTERN_CVAR(Bool, vid_fps) static FString statFPS() diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index fecc727e8..661333a5a 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -163,7 +163,7 @@ void InputState::ClearAllInput() //========================================================================== void I_StartTic(); -bool ToggleFullscreen; +extern bool ToggleFullscreen; int32_t handleevents(void) { diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 086f47078..82c773a6d 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -88,6 +88,7 @@ #include "v_draw.h" #include "gamehud.h" #include "wipe.h" +#include "i_interface.h" CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, r_ticstability, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -99,7 +100,6 @@ ticcmd_t playercmds[MAXPLAYERS]; static uint64_t stabilityticduration = 0; static uint64_t stabilitystarttime = 0; -bool pauseext; bool r_NoInterpolate; int entertic; int oldentertics; diff --git a/source/core/menu/razemenu.cpp b/source/core/menu/razemenu.cpp index d99a82642..ce85bfb10 100644 --- a/source/core/menu/razemenu.cpp +++ b/source/core/menu/razemenu.cpp @@ -191,7 +191,7 @@ bool M_SetSpecialMenu(FName& menu, int param) // //============================================================================= -void M_StartControlPanel(bool makeSound, bool) +void OnMenuOpen(bool makeSound) { // intro might call this repeatedly if (CurrentMenu != NULL) @@ -200,7 +200,6 @@ void M_StartControlPanel(bool makeSound, bool) GSnd->SetSfxPaused(true, PAUSESFX_MENU); gi->MenuOpened(); if (makeSound && menu_sounds) gi->MenuSound(ActivateSound); - M_DoStartControlPanel(false); } @@ -755,29 +754,3 @@ DEFINE_ACTION_FUNCTION(_PlayerMenu, DrawPlayerSprite) return 0; } -#ifdef _WIN32 -EXTERN_CVAR(Bool, vr_enable_quadbuffered) -#endif - -void UpdateVRModes(bool considerQuadBuffered) -{ - FOptionValues** pVRModes = OptionValues.CheckKey("VRMode"); - if (pVRModes == nullptr) return; - - TArray& vals = (*pVRModes)->mValues; - TArray filteredValues; - int cnt = vals.Size(); - for (int i = 0; i < cnt; ++i) { - auto const& mode = vals[i]; - if (mode.Value == 7) { // Quad-buffered stereo -#ifdef _WIN32 - if (!vr_enable_quadbuffered) continue; -#else - continue; // Remove quad-buffered option on Mac and Linux -#endif - if (!considerQuadBuffered) continue; // Probably no compatible screen mode was found - } - filteredValues.Push(mode); - } - vals = filteredValues; -} diff --git a/source/core/menu/razemenu.h b/source/core/menu/razemenu.h index 25a16b28f..fa40ae464 100644 --- a/source/core/menu/razemenu.h +++ b/source/core/menu/razemenu.h @@ -6,9 +6,6 @@ extern bool help_disabled; -void M_StartControlPanel (bool makeSound, bool scaleoverride = false); - - extern FNewGameStartup NewGameStartupInfo; void M_StartupEpisodeMenu(FNewGameStartup *gs); void M_StartupSkillMenu(FNewGameStartup *gs);