- backend update from GZDoom.

This commit is contained in:
Christoph Oelckers 2022-10-02 20:33:18 +02:00
parent 5a27390eaf
commit c1d603e1e9
58 changed files with 487 additions and 333 deletions

View file

@ -931,10 +931,6 @@ set( FASTMATH_SOURCES
common/textures/hires/xbr/xbrz.cpp common/textures/hires/xbr/xbrz.cpp
common/textures/hires/xbr/xbrz_old.cpp common/textures/hires/xbr/xbrz_old.cpp
common/utility/matrix.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 #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/cutscenes/screenjob.cpp
common/utility/engineerrors.cpp common/utility/engineerrors.cpp
common/utility/i_module.cpp common/utility/i_module.cpp
common/utility/gitinfo.cpp
common/utility/m_alloc.cpp common/utility/m_alloc.cpp
common/utility/utf8.cpp common/utility/utf8.cpp
common/utility/palette.cpp common/utility/palette.cpp

View file

@ -199,7 +199,7 @@ void DoDrawTexture(F2DDrawer *drawer, FGameTexture* img, double x, double y, int
DrawParms parms; DrawParms parms;
if (!img || !img->isValid()) return; 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); va_end(tags.list);
if (!res) if (!res)
{ {
@ -238,7 +238,7 @@ void DoDrawTexture(F2DDrawer *drawer, FGameTexture *img, double x, double y, VMV
DrawParms parms; DrawParms parms;
uint32_t tag = ListGetInt(args); uint32_t tag = ListGetInt(args);
if (!img || !img->isValid()) return; 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; if (!res) return;
drawer->AddTexture(img, parms); 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); va_start(tags.list, tags_first);
DrawParms parms; 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); va_end(tags.list);
if (!res) return; if (!res) return;
drawer->AddShape(img, shape, parms); drawer->AddShape(img, shape, parms);
@ -301,21 +301,19 @@ void DrawShape(F2DDrawer *drawer, FGameTexture *img, DShape2D *shape, VMVa_List
DrawParms parms; DrawParms parms;
uint32_t tag = ListGetInt(args); 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; if (!res) return;
drawer->AddShape(img, shape, parms); 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; DrawParms parms;
uint32_t tag = ListGetInt(args); 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; if (!res) return;
parms.fillcolor = color;
drawer->AddShape(nullptr, shape, parms); 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 }; VMVa_List args = { param + 3, 0, numparam - 4, va_reginfo + 3 };
color.a = int(amount * 255.0f); DrawShapeFill(twod, color, amount, shape, args);
DrawShapeFill(twod, color, shape, args);
return 0; return 0;
} }
@ -384,9 +380,7 @@ DEFINE_ACTION_FUNCTION(FCanvas, DrawShapeFill)
VMVa_List args = { param + 4, 0, numparam - 5, va_reginfo + 4 }; VMVa_List args = { param + 4, 0, numparam - 5, va_reginfo + 4 };
color.a = int(amount * 255.0f); DrawShapeFill(&self->Drawer, color, amount, shape, args);
DrawShapeFill(&self->Drawer, color, shape, args);
self->Tex->NeedUpdate(); self->Tex->NeedUpdate();
return 0; return 0;
} }
@ -833,13 +827,13 @@ static inline FSpecialColormap * ListGetSpecialColormap(VMVa_List &tags)
//========================================================================== //==========================================================================
template<class T> template<class T>
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; INTBOOL boolval;
int intval; int intval;
bool fillcolorset = false; bool fillcolorset = type == DrawTexture_Fill;
if (!fortext && checkimage) if (type == DrawTexture_Normal)
{ {
if (img == NULL || !img->isValid()) if (img == NULL || !img->isValid())
{ {
@ -855,7 +849,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
return false; return false;
} }
parms->fortext = fortext; parms->fortext = type == DrawTexture_Text;
parms->windowleft = 0; parms->windowleft = 0;
parms->windowright = INT_MAX; parms->windowright = INT_MAX;
parms->dclip = drawer->GetHeight(); parms->dclip = drawer->GetHeight();
@ -866,8 +860,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
parms->top = INT_MAX; parms->top = INT_MAX;
parms->destwidth = INT_MAX; parms->destwidth = INT_MAX;
parms->destheight = INT_MAX; parms->destheight = INT_MAX;
parms->Alpha = 1.f; parms->Alpha = type == DrawTexture_Fill ? fillalpha : 1.f;
parms->fillcolor = -1; parms->fillcolor = type == DrawTexture_Fill ? fill : PalEntry(~0u);
parms->TranslationId = -1; parms->TranslationId = -1;
parms->colorOverlay = 0; parms->colorOverlay = 0;
parms->alphaChannel = false; parms->alphaChannel = false;
@ -916,29 +910,29 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
break; break;
case DTA_DestWidth: case DTA_DestWidth:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->cleanmode = DTA_Base; parms->cleanmode = DTA_Base;
parms->destwidth = ListGetInt(tags); parms->destwidth = ListGetInt(tags);
break; break;
case DTA_DestWidthF: case DTA_DestWidthF:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->cleanmode = DTA_Base; parms->cleanmode = DTA_Base;
parms->destwidth = ListGetDouble(tags); parms->destwidth = ListGetDouble(tags);
break; break;
case DTA_DestHeight: case DTA_DestHeight:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->cleanmode = DTA_Base; parms->cleanmode = DTA_Base;
parms->destheight = ListGetInt(tags); parms->destheight = ListGetInt(tags);
break; break;
case DTA_DestHeightF: case DTA_DestHeightF:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->cleanmode = DTA_Base; parms->cleanmode = DTA_Base;
parms->destheight = ListGetDouble(tags); parms->destheight = ListGetDouble(tags);
break; break;
@ -1046,7 +1040,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
boolval = ListGetInt(tags); boolval = ListGetInt(tags);
if (boolval) if (boolval)
{ {
assert(fortext == false); assert(type != DrawTexture_Text);
if (img == NULL) return false; if (img == NULL) return false;
parms->cleanmode = DTA_Fullscreen; parms->cleanmode = DTA_Fullscreen;
parms->fsscalemode = (uint8_t)twod->fullscreenautoaspect; parms->fsscalemode = (uint8_t)twod->fullscreenautoaspect;
@ -1060,7 +1054,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
intval = ListGetInt(tags); intval = ListGetInt(tags);
if (intval >= 0 && intval <= 3) if (intval >= 0 && intval <= 3)
{ {
assert(fortext == false); assert(type != DrawTexture_Text);
if (img == NULL) return false; if (img == NULL) return false;
parms->cleanmode = DTA_Fullscreen; parms->cleanmode = DTA_Fullscreen;
parms->fsscalemode = (uint8_t)intval; parms->fsscalemode = (uint8_t)intval;
@ -1135,32 +1129,32 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
break; break;
case DTA_TopOffset: case DTA_TopOffset:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->top = ListGetInt(tags); parms->top = ListGetInt(tags);
break; break;
case DTA_TopOffsetF: case DTA_TopOffsetF:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->top = ListGetDouble(tags); parms->top = ListGetDouble(tags);
break; break;
case DTA_LeftOffset: case DTA_LeftOffset:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->left = ListGetInt(tags); parms->left = ListGetInt(tags);
break; break;
case DTA_LeftOffsetF: case DTA_LeftOffsetF:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->left = ListGetDouble(tags); parms->left = ListGetDouble(tags);
break; break;
case DTA_TopLeft: case DTA_TopLeft:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
if (ListGetInt(tags)) if (ListGetInt(tags))
{ {
parms->left = 0; parms->left = 0;
@ -1169,8 +1163,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
break; break;
case DTA_CenterOffset: case DTA_CenterOffset:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
if (ListGetInt(tags)) if (ListGetInt(tags))
{ {
parms->left = img->GetDisplayWidth() * 0.5; parms->left = img->GetDisplayWidth() * 0.5;
@ -1179,8 +1173,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
break; break;
case DTA_CenterOffsetRel: case DTA_CenterOffsetRel:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
intval = ListGetInt(tags); intval = ListGetInt(tags);
if (intval == 1) if (intval == 1)
{ {
@ -1195,8 +1189,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
break; break;
case DTA_CenterBottomOffset: case DTA_CenterBottomOffset:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
if (ListGetInt(tags)) if (ListGetInt(tags))
{ {
parms->left = img->GetDisplayWidth() * 0.5; parms->left = img->GetDisplayWidth() * 0.5;
@ -1205,26 +1199,26 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
break; break;
case DTA_WindowLeft: case DTA_WindowLeft:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->windowleft = ListGetInt(tags); parms->windowleft = ListGetInt(tags);
break; break;
case DTA_WindowLeftF: case DTA_WindowLeftF:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->windowleft = ListGetDouble(tags); parms->windowleft = ListGetDouble(tags);
break; break;
case DTA_WindowRight: case DTA_WindowRight:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->windowright = ListGetInt(tags); parms->windowright = ListGetInt(tags);
break; break;
case DTA_WindowRightF: case DTA_WindowRightF:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->windowright = ListGetDouble(tags); parms->windowright = ListGetDouble(tags);
break; break;
@ -1362,8 +1356,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
break; break;
case DTA_Rotate: case DTA_Rotate:
assert(fortext == false); assert(type != DrawTexture_Text);
if (fortext) return false; if (type == DrawTexture_Text) return false;
parms->rotateangle = ListGetDouble(tags); parms->rotateangle = ListGetDouble(tags);
break; break;
@ -1436,8 +1430,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
} }
// explicitly instantiate both versions for v_text.cpp. // explicitly instantiate both versions for v_text.cpp.
template bool ParseDrawTextureTags<Va_List>(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, bool fortext, bool checkimage); template bool ParseDrawTextureTags<Va_List>(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<VMVa_List>(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, bool fortext, bool checkimage); template bool ParseDrawTextureTags<VMVa_List>(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha);
//========================================================================== //==========================================================================
// //
@ -1980,4 +1974,3 @@ DEFINE_ACTION_FUNCTION(FCanvas, ClearTransform)
self->Tex->NeedUpdate(); self->Tex->NeedUpdate();
return 0; return 0;
} }

View file

@ -258,8 +258,15 @@ inline int active_con_scale(F2DDrawer *drawer)
#undef DrawText // See WinUser.h for the definition of DrawText as a macro #undef DrawText // See WinUser.h for the definition of DrawText as a macro
#endif #endif
enum
{
DrawTexture_Normal,
DrawTexture_Text,
DrawTexture_Fill,
};
template<class T> template<class T>
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<class T> template<class T>
void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms); void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms);

View file

@ -179,7 +179,7 @@ void DrawChar(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double
DrawParms parms; DrawParms parms;
Va_List tags; Va_List tags;
va_start(tags.list, tag_first); 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); va_end(tags.list);
if (!res) if (!res)
{ {
@ -208,7 +208,7 @@ void DrawChar(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double
{ {
DrawParms parms; DrawParms parms;
uint32_t tag = ListGetInt(args); 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; if (!res) return;
bool palettetrans = (normalcolor == CR_NATIVEPAL && parms.TranslationId != 0); bool palettetrans = (normalcolor == CR_NATIVEPAL && parms.TranslationId != 0);
PalEntry color = 0xffffffff; PalEntry color = 0xffffffff;
@ -374,7 +374,7 @@ void DrawText(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double
return; return;
va_start(tags.list, tag_first); 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); va_end(tags.list);
if (!res) if (!res)
{ {
@ -393,7 +393,7 @@ void DrawText(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double
return; return;
va_start(tags.list, tag_first); 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); va_end(tags.list);
if (!res) if (!res)
{ {
@ -411,7 +411,7 @@ void DrawText(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double
return; return;
uint32_t tag = ListGetInt(args); 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) if (!res)
{ {
return; return;
@ -455,4 +455,3 @@ DEFINE_ACTION_FUNCTION(FCanvas, DrawText)
self->Tex->NeedUpdate(); self->Tex->NeedUpdate();
return 0; return 0;
} }

View file

@ -156,6 +156,23 @@ int wipe_CalcBurn (uint8_t *burnarray, int width, int height, int density)
// TYPES ------------------------------------------------------------------- // 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 class Wiper_Crossfade : public Wiper
{ {
public: public:

View file

@ -5,7 +5,6 @@
#include <functional> #include <functional>
class FTexture; class FTexture;
int wipe_CalcBurn(uint8_t *buffer, int width, int height, int density);
enum enum
{ {
@ -16,22 +15,6 @@ enum
wipe_NUMWIPES 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<void()> overlaydrawer); void PerformWipe(FTexture* startimg, FTexture* endimg, int wipe_type, bool stopsound, std::function<void()> overlaydrawer);

View file

@ -58,12 +58,12 @@ EXTERN_CVAR(Float, snd_musicvolume)
inline float AmplitudeTodB(float amplitude) inline float AmplitudeTodB(float amplitude)
{ {
return 20.0f * log10(amplitude); return 20.0f * log10f(amplitude);
} }
inline float dBToAmplitude(float dB) inline float dBToAmplitude(float dB)
{ {
return pow(10.0f, dB / 20.0f); return powf(10.0f, dB / 20.0f);
} }
#endif //__I_MUSIC_H__ #endif //__I_MUSIC_H__

View file

@ -38,12 +38,13 @@
#include "i_soundinternal.h" #include "i_soundinternal.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "i_system.h" #include "i_system.h"
#include "gameconfigfile.h"
#include "filereadermusicinterface.h" #include "filereadermusicinterface.h"
#include <zmusic.h> #include <zmusic.h>
#include "resourcefile.h" #include "resourcefile.h"
#include "version.h" #include "version.h"
#include "findfile.h" #include "findfile.h"
#include "i_interface.h"
#include "configfile.h"
//========================================================================== //==========================================================================
// //
@ -392,6 +393,7 @@ void FSoundFontManager::CollectSoundfonts()
findstate_t c_file; findstate_t c_file;
void *file; void *file;
FConfigFile* GameConfig = sysCallbacks.GetConfig ? sysCallbacks.GetConfig() : nullptr;
if (GameConfig != NULL && GameConfig->SetSection ("SoundfontSearch.Directories")) if (GameConfig != NULL && GameConfig->SetSection ("SoundfontSearch.Directories"))
{ {
const char *key; const char *key;

View file

@ -51,8 +51,8 @@
#include <zmusic.h> #include <zmusic.h>
#include "md5.h" #include "md5.h"
#include "gain_analysis.h" #include "gain_analysis.h"
#include "gameconfigfile.h"
#include "i_specialpaths.h" #include "i_specialpaths.h"
#include "configfile.h"
// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------

View file

@ -44,8 +44,11 @@
#include "m_random.h" #include "m_random.h"
#include "printf.h" #include "printf.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "gamestate.h"
CVARD(Bool, snd_enabled, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enables/disables sound effects") 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() int SoundEnabled()
{ {
@ -1710,3 +1713,155 @@ void S_SoundReset()
S_RestartMusic(); S_RestartMusic();
} }
//==========================================================================
//
// CCMD cachesound <sound name>
//
//==========================================================================
#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 <sound> ...\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();
}

View file

@ -306,6 +306,7 @@ public:
void MarkUsed(int num); void MarkUsed(int num);
void CacheMarkedSounds(); void CacheMarkedSounds();
TArray<FSoundChan*> AllActiveChannels(); TArray<FSoundChan*> AllActiveChannels();
virtual void SetSoundPaused(int state) {}
void MarkAllUnused() void MarkAllUnused()
{ {

View file

@ -49,8 +49,6 @@
#include "d_eventbase.h" #include "d_eventbase.h"
extern int chatmodeon;
const char *KeyNames[NUM_KEYS] = const char *KeyNames[NUM_KEYS] =
{ {
// We use the DirectInput codes and assume a qwerty keyboard layout. // 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 "KP2", "KP3", "KP0", "KP.", nullptr, nullptr, "OEM102", "F11", //50
"F12", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, //58 "F12", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, //58
nullptr, nullptr, nullptr, nullptr, "F13", "F14", "F15", "F16", //60 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 "Kana", nullptr, nullptr, "Abnt_C1", nullptr, nullptr, nullptr, nullptr, //70
nullptr, "Convert", nullptr, "NoConvert",nullptr, "Yen", "Abnt_C2", nullptr, //78 nullptr, "Convert", nullptr, "NoConvert",nullptr, "Yen", "Abnt_C2", nullptr, //78
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, //80 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, //80

View file

@ -45,7 +45,7 @@
#include "filesystem.h" #include "filesystem.h"
#include "d_gui.h" #include "d_gui.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "d_event.h" #include "d_eventbase.h"
#include "c_consolebuffer.h" #include "c_consolebuffer.h"
#include "utf8.h" #include "utf8.h"
#include "v_2ddrawer.h" #include "v_2ddrawer.h"
@ -95,7 +95,6 @@ static FTextureID conflat;
static uint32_t conshade; static uint32_t conshade;
static bool conline; static bool conline;
extern int chatmodeon;
extern FBaseCVar *CVars; extern FBaseCVar *CVars;
extern FConsoleCommand *Commands[FConsoleCommand::HASH_SIZE]; extern FConsoleCommand *Commands[FConsoleCommand::HASH_SIZE];

View file

@ -85,5 +85,6 @@ extern double NotifyFontScale;
void C_SetNotifyFontScale(double scale); void C_SetNotifyFontScale(double scale);
extern const char *console_bar; extern const char *console_bar;
extern int chatmodeon;
#endif #endif

View file

@ -43,6 +43,7 @@
#include "engineerrors.h" #include "engineerrors.h"
#include "printf.h" #include "printf.h"
#include "palutil.h" #include "palutil.h"
#include "i_interface.h"
struct FLatchedValue struct FLatchedValue
@ -1462,7 +1463,7 @@ EXTERN_CVAR(Bool, sv_cheats);
void FBaseCVar::CmdSet (const char *newval) void FBaseCVar::CmdSet (const char *newval)
{ {
if ((GetFlags() & CVAR_CHEAT) && CheckCheatmode ()) if ((GetFlags() & CVAR_CHEAT) && sysCallbacks.CheckCheatmode && sysCallbacks.CheckCheatmode(true, false))
return; return;
MarkUnsafe(); MarkUnsafe();

View file

@ -59,8 +59,6 @@ extern bool ParsingKeyConf, UnsafeExecutionContext;
extern FString StoredWarp; // [RH] +warp at the command line extern FString StoredWarp; // [RH] +warp at the command line
extern bool CheckCheatmode (bool printmsg = true, bool sponly = false);
FExecList *C_ParseCmdLineParams(FExecList *exec); FExecList *C_ParseCmdLineParams(FExecList *exec);
// Add commands to the console as if they were typed in. Can handle wait // Add commands to the console as if they were typed in. Can handle wait

View file

@ -94,7 +94,7 @@ void D_ProcessEvents (void)
continue; // menu ate the event 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) for (auto& ev: delayedevents)

View file

@ -1,5 +1,9 @@
#include "i_interface.h" #include "i_interface.h"
#include "st_start.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"); static_assert(sizeof(void*) == 8, "32 builds are not supported");
@ -10,3 +14,25 @@ FString endoomName;
bool batchrun; bool batchrun;
float menuBlurAmount; 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);
}

View file

@ -2,14 +2,18 @@
#include "zstring.h" #include "zstring.h"
#include "intrect.h" #include "intrect.h"
#include "name.h"
struct event_t; struct event_t;
class FRenderState; class FRenderState;
class FGameTexture; class FGameTexture;
class FTextureID;
enum EUpscaleFlags : int; enum EUpscaleFlags : int;
class FConfigFile;
struct SystemCallbacks struct SystemCallbacks
{ {
bool (*G_Responder)(event_t* ev); // this MUST be set, otherwise nothing will work
bool (*WantGuiCapture)(); bool (*WantGuiCapture)();
bool (*WantLeftButton)(); bool (*WantLeftButton)();
bool (*NetGame)(); bool (*NetGame)();
@ -35,6 +39,13 @@ struct SystemCallbacks
void (*ToggleFullConsole)(); void (*ToggleFullConsole)();
void (*StartCutscene)(bool blockui); void (*StartCutscene)(bool blockui);
void (*SetTransition)(int type); 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; extern SystemCallbacks sysCallbacks;
@ -50,5 +61,7 @@ extern FString endoomName;
extern bool batchrun; extern bool batchrun;
extern float menuBlurAmount; extern float menuBlurAmount;
extern bool generic_ui; extern bool generic_ui;
extern int paused;
extern bool pauseext;
void UpdateGenericUI(bool cvar); void UpdateGenericUI(bool cvar);

View file

@ -35,7 +35,8 @@
#include <math.h> #include <math.h>
#include "vectors.h" #include "vectors.h"
#include "m_joy.h" #include "m_joy.h"
#include "gameconfigfile.h" #include "configfile.h"
#include "i_interface.h"
#include "d_eventbase.h" #include "d_eventbase.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "printf.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:"; FString id = "Joy:";
id += joy->GetIdentifier(); id += joy->GetIdentifier();
if (!GameConfig) return false;
return GameConfig->SetSection(id, create); return GameConfig->SetSection(id, create);
} }
@ -107,13 +109,14 @@ static bool M_SetJoystickConfigSection(IJoystickConfig *joy, bool create)
bool M_LoadJoystickConfig(IJoystickConfig *joy) bool M_LoadJoystickConfig(IJoystickConfig *joy)
{ {
FConfigFile* GameConfig = sysCallbacks.GetConfig ? sysCallbacks.GetConfig() : nullptr;
char key[32]; char key[32];
const char *value; const char *value;
int axislen; int axislen;
int numaxes; int numaxes;
joy->SetDefaultConfig(); joy->SetDefaultConfig();
if (!M_SetJoystickConfigSection(joy, false)) if (!M_SetJoystickConfigSection(joy, false, GameConfig))
{ {
return false; return false;
} }
@ -166,10 +169,11 @@ bool M_LoadJoystickConfig(IJoystickConfig *joy)
void M_SaveJoystickConfig(IJoystickConfig *joy) void M_SaveJoystickConfig(IJoystickConfig *joy)
{ {
FConfigFile* GameConfig = sysCallbacks.GetConfig ? sysCallbacks.GetConfig() : nullptr;
char key[32], value[32]; char key[32], value[32];
int axislen, numaxes; int axislen, numaxes;
if (GameConfig != NULL && M_SetJoystickConfigSection(joy, true)) if (GameConfig != NULL && M_SetJoystickConfigSection(joy, true, GameConfig))
{ {
GameConfig->ClearCurrentSection(); GameConfig->ClearCurrentSection();
if (!joy->IsSensitivityDefault()) if (!joy->IsSensitivityDefault())

View file

@ -1612,7 +1612,7 @@ FString::FString(ELumpNum lumpnum)
{ {
auto lumpr = fileSystem.OpenFileReader ((int)lumpnum); auto lumpr = fileSystem.OpenFileReader ((int)lumpnum);
auto size = lumpr.GetLength (); auto size = lumpr.GetLength ();
AllocBuffer(size + 1); AllocBuffer (1 + size);
auto numread = lumpr.Read (&Chars[0], size); auto numread = lumpr.Read (&Chars[0], size);
Chars[size] = '\0'; Chars[size] = '\0';

View file

@ -265,7 +265,6 @@ DEFINE_ACTION_FUNCTION(FFont, BreakLines)
bool generic_ui; bool generic_ui;
EXTERN_CVAR(String, language)
bool CheckFontComplete(FFont* font) bool CheckFontComplete(FFont* font)
{ {

View file

@ -55,11 +55,8 @@
#include "i_time.h" #include "i_time.h"
#include "printf.h" #include "printf.h"
void M_StartControlPanel(bool makeSound, bool scaleoverride = false);
int DMenu::InMenu; int DMenu::InMenu;
static ScaleOverrider *CurrentScaleOverrider; static ScaleOverrider *CurrentScaleOverrider;
extern int chatmodeon;
// //
// Todo: Move these elsewhere // Todo: Move these elsewhere
// //
@ -114,8 +111,6 @@ extern PClass *DefaultOptionMenuClass;
#define KEY_REPEAT_DELAY (GameTicRate*5/12) #define KEY_REPEAT_DELAY (GameTicRate*5/12)
#define KEY_REPEAT_RATE (3) #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 // intro might call this repeatedly
if (CurrentMenu != nullptr) if (CurrentMenu != nullptr)
return; 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) 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); DMenuDescriptor **desc = MenuDescriptors.CheckKey(menu);
if (desc != nullptr) if (desc != nullptr)

View file

@ -303,7 +303,7 @@ void M_ActivateMenu(DMenu *menu);
void M_ClearMenus (); void M_ClearMenus ();
void M_PreviousMenu (); void M_PreviousMenu ();
void M_ParseMenuDefs(); 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_SetMenu(FName menu, int param = -1);
void M_StartMessage(const char *message, int messagemode, FName action = NAME_None); void M_StartMessage(const char *message, int messagemode, FName action = NAME_None);
DMenu *StartPickerMenu(DMenu *parent, const char *name, FColorCVar *cvar); DMenu *StartPickerMenu(DMenu *parent, const char *name, FColorCVar *cvar);

View file

@ -40,7 +40,6 @@
#include "vm.h" #include "vm.h"
#include "menustate.h" #include "menustate.h"
void M_StartControlPanel(bool makeSound, bool scaleoverride = false);
FName MessageBoxClass = NAME_MessageBoxMenu; FName MessageBoxClass = NAME_MessageBoxMenu;
CVAR(Bool, m_quickexit, false, CVAR_ARCHIVE) CVAR(Bool, m_quickexit, false, CVAR_ARCHIVE)

View file

@ -55,7 +55,7 @@ CVAR(Bool, use_mouse, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
extern int paused, chatmodeon; extern int paused;
extern bool ToggleFullscreen; extern bool ToggleFullscreen;
bool GUICapture; bool GUICapture;

View file

@ -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) if (!showwin)
{ {

View file

@ -36,12 +36,11 @@
#include "cmdlib.h" #include "cmdlib.h"
#include "i_system.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 return false; // return true to retry
} }

View file

@ -56,7 +56,7 @@ static bool NativeMouse = true;
CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
extern int WaitingForKey, chatmodeon; extern int WaitingForKey;
static const SDL_Keycode DIKToKeySym[256] = static const SDL_Keycode DIKToKeySym[256] =
{ {

View file

@ -301,7 +301,7 @@ void I_PrintStr(const char *cp)
if (StartWindow) RedrawProgressBar(ProgressBarCurPos,ProgressBarMaxPos); 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; int i;

View file

@ -63,7 +63,6 @@
#include "d_gui.h" #include "d_gui.h"
#include "c_console.h" #include "c_console.h"
#include "s_soundinternal.h" #include "s_soundinternal.h"
#include "gameconfigfile.h"
#include "hardware.h" #include "hardware.h"
#include "d_eventbase.h" #include "d_eventbase.h"
#include "v_text.h" #include "v_text.h"
@ -125,8 +124,6 @@ static bool EventHandlerResultForNativeMouse;
CVAR (Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
extern int chatmodeon;
static void I_CheckGUICapture () static void I_CheckGUICapture ()
{ {
bool wantCapt = sysCallbacks.WantGuiCapture && sysCallbacks.WantGuiCapture(); bool wantCapt = sysCallbacks.WantGuiCapture && sysCallbacks.WantGuiCapture();

View file

@ -80,7 +80,6 @@
#include "i_input.h" #include "i_input.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "gameconfigfile.h"
#include "v_font.h" #include "v_font.h"
#include "i_system.h" #include "i_system.h"
#include "bitmap.h" #include "bitmap.h"
@ -112,10 +111,6 @@ static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP
EXTERN_CVAR (Bool, queryiwad); EXTERN_CVAR (Bool, queryiwad);
// Used on welcome/IWAD screen. // 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_CVAR (Int, vid_preferbackend)
extern HANDLE StdOut; extern HANDLE StdOut;
@ -357,9 +352,12 @@ static void SetQueryIWad(HWND dialog)
// Dialog proc for the IWAD selector. // Dialog proc for the IWAD selector.
// //
//========================================================================== //==========================================================================
static int* pAutoloadflags;
BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
int& flags = *pAutoloadflags;;
HWND ctrl; HWND ctrl;
int i; int i;
@ -403,10 +401,10 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
// [SP] This is our's // [SP] This is our's
SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_SETCHECK, disableautoload ? 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, autoloadlights ? 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, autoloadbrightmaps ? 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, autoloadwidescreen ? BST_CHECKED : BST_UNCHECKED, 0 ); SendDlgItemMessage( hDlg, IDC_WELCOME_WIDESCREEN, BM_SETCHECK, (flags & 8) ? BST_CHECKED : BST_UNCHECKED, 0 );
// Set up our version string. // Set up our version string.
sprintf(szString, "Version %s.", GetVersionString()); sprintf(szString, "Version %s.", GetVersionString());
@ -461,10 +459,11 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
vid_preferbackend = 0; vid_preferbackend = 0;
// [SP] This is our's. // [SP] This is our's.
disableautoload = SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_GETCHECK, 0, 0 ) == BST_CHECKED; flags = 0;
autoloadlights = SendDlgItemMessage( hDlg, IDC_WELCOME_LIGHTS, BM_GETCHECK, 0, 0 ) == BST_CHECKED; if (SendDlgItemMessage(hDlg, IDC_WELCOME_NOAUTOLOAD, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 1;
autoloadbrightmaps = SendDlgItemMessage( hDlg, IDC_WELCOME_BRIGHTMAPS, BM_GETCHECK, 0, 0 ) == BST_CHECKED; if (SendDlgItemMessage(hDlg, IDC_WELCOME_LIGHTS, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 2;
autoloadwidescreen = SendDlgItemMessage( hDlg, IDC_WELCOME_WIDESCREEN, BM_GETCHECK, 0, 0 ) == BST_CHECKED; 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); ctrl = GetDlgItem (hDlg, IDC_IWADLIST);
EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); 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; int vkey;
pAutoloadflags = &autoloadflags;
if (stricmp(queryiwad_key, "shift") == 0) if (stricmp(queryiwad_key, "shift") == 0)
{ {
vkey = VK_SHIFT; vkey = VK_SHIFT;
@ -764,7 +763,7 @@ void DestroyCustomCursor()
// //
//========================================================================== //==========================================================================
bool I_WriteIniFailed() bool I_WriteIniFailed(const char* filename)
{ {
char *lpMsgBuf; char *lpMsgBuf;
FString errortext; FString errortext;
@ -779,7 +778,7 @@ bool I_WriteIniFailed()
0, 0,
NULL 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); LocalFree (lpMsgBuf);
return MessageBoxA(mainwindow.GetHandle(), errortext.GetChars(), GAMENAME " configuration not saved", MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY; return MessageBoxA(mainwindow.GetHandle(), errortext.GetChars(), GAMENAME " configuration not saved", MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY;
} }

View file

@ -38,10 +38,10 @@ void I_PrintStr (const char *cp);
void I_SetIWADInfo (); void I_SetIWADInfo ();
// Pick from multiple IWADs to use // 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 // 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 // [RH] Checks the registry for Steam's install path, so we can scan its
// directories for IWADs if the user purchased any through Steam. // directories for IWADs if the user purchased any through Steam.

View file

@ -44,6 +44,7 @@
#include "gl_framebuffer.h" #include "gl_framebuffer.h"
#include "gl_shaderprogram.h" #include "gl_shaderprogram.h"
#include "gl_buffers.h" #include "gl_buffers.h"
#include "menu.h"
EXTERN_CVAR(Int, vr_mode) EXTERN_CVAR(Int, vr_mode)
@ -53,7 +54,32 @@ EXTERN_CVAR(Float, vid_contrast)
EXTERN_CVAR(Int, gl_satformula) EXTERN_CVAR(Int, gl_satformula)
EXTERN_CVAR(Int, gl_dither_bpc) 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<FOptionValues::Pair>& vals = (*pVRModes)->mValues;
TArray<FOptionValues::Pair> 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 namespace OpenGLRenderer
{ {

View file

@ -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_MIN_FILTER, TexFilter[filter].minfilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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, gl_texture_filter_anisotropic);
} }
break; 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_MIN_FILTER, TexFilter[filter].minfilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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, gl_texture_filter_anisotropic);
} }
break; 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_MIN_FILTER, TexFilter[filter].minfilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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, gl_texture_filter_anisotropic);
} }
break; 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_MIN_FILTER, TexFilter[filter].minfilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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, gl_texture_filter_anisotropic);
} }
break; 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_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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; break;
case CLAMP_NOFILTER: 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_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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; break;
case CLAMP_NOFILTER_X: 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_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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; break;
case CLAMP_NOFILTER_Y: 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_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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; break;
case CLAMP_NOFILTER_XY: 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_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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; break;
case CLAMP_CAMTEX: 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_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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; break;
} }
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);

View file

@ -184,11 +184,13 @@ namespace OpenGLESRenderer
gles.depthStencilAvailable = CheckExtension("GL_OES_packed_depth_stencil"); gles.depthStencilAvailable = CheckExtension("GL_OES_packed_depth_stencil");
gles.npotAvailable = CheckExtension("GL_OES_texture_npot"); gles.npotAvailable = CheckExtension("GL_OES_texture_npot");
gles.depthClampAvailable = CheckExtension("GL_EXT_depth_clamp"); gles.depthClampAvailable = CheckExtension("GL_EXT_depth_clamp");
gles.anistropicFilterAvailable = CheckExtension("GL_EXT_texture_filter_anisotropic");
#else #else
gles.depthStencilAvailable = true; gles.depthStencilAvailable = true;
gles.npotAvailable = true; gles.npotAvailable = true;
gles.useMappedBuffers = true; gles.useMappedBuffers = true;
gles.depthClampAvailable = true; gles.depthClampAvailable = true;
gles.anistropicFilterAvailable = true;
#endif #endif
gles.numlightvectors = (gles.maxlights * LIGHT_VEC4_NUM); gles.numlightvectors = (gles.maxlights * LIGHT_VEC4_NUM);

View file

@ -23,7 +23,8 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#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) #if (USE_GLES2)
#include "glad/glad.h" #include "glad/glad.h"
@ -43,6 +44,7 @@ GLAPI PFNGLUNMAPBUFFEROESPROC glUnmapBuffer;
#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 #define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
#define GL_BGRA 0x80E1 #define GL_BGRA 0x80E1
#define GL_DEPTH_CLAMP 0x864F #define GL_DEPTH_CLAMP 0x864F
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
#else #else
#include "gl_load/gl_load.h" #include "gl_load/gl_load.h"
@ -71,6 +73,7 @@ namespace OpenGLESRenderer
bool npotAvailable; bool npotAvailable;
bool forceGLSLv100; bool forceGLSLv100;
bool depthClampAvailable; bool depthClampAvailable;
bool anistropicFilterAvailable;
int max_texturesize; int max_texturesize;
char* vendorstring; char* vendorstring;
char* modelstring; char* modelstring;

View file

@ -842,27 +842,45 @@ DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Clear, ArrayClear<FDynArray_Ptr>)
// //
//----------------------------------------------------- //-----------------------------------------------------
DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Copy, ArrayCopy<FDynArray_Obj>) void ObjArrayCopy(FDynArray_Obj *self, FDynArray_Obj *other)
{ {
PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); for (auto& elem : *other) GC::WriteBarrier(elem);
PARAM_POINTER(other, FDynArray_Obj);
*self = *other; *self = *other;
return 0;
} }
DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Move, ArrayMove<FDynArray_Obj>) DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Copy, ObjArrayCopy)
{ {
PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj);
PARAM_POINTER(other, 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); *self = std::move(*other);
return 0;
} }
DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Append, ArrayAppend<FDynArray_Obj>) DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Move, ObjArrayMove)
{ {
PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj);
PARAM_POINTER(other, 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); 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; return 0;
} }

View file

@ -522,11 +522,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckRealHeight, CheckRealHeight)
ACTION_RETURN_INT(CheckRealHeight(texid)); ACTION_RETURN_INT(CheckRealHeight(texid));
} }
bool OkForLocalization(FTextureID texnum, const char* substitute);
static int OkForLocalization_(int index, const FString& 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_) DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, OkForLocalization, OkForLocalization_)
@ -719,6 +717,19 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetDefaultKerning, GetDefaultKerning)
ACTION_RETURN_INT(self->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 // file system

View file

@ -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_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_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_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_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_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); #define PARAM_FANGLE_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_FLOAT); FAngle x = FAngle::fromDeg(param[p].f);

View file

@ -49,7 +49,6 @@
#include "v_draw.h" #include "v_draw.h"
#include "g_input.h" #include "g_input.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "gi.h"
// Text mode color values // Text mode color values
enum{ enum{

View file

@ -38,6 +38,7 @@
#include <stdint.h> #include <stdint.h>
#include <functional> #include <functional>
#include "bitmap.h" #include "bitmap.h"
#include "zstring.h"
class FGameTexture; class FGameTexture;

View file

@ -46,6 +46,7 @@
#include "utf8.h" #include "utf8.h"
#include "v_text.h" #include "v_text.h"
#include "vm.h" #include "vm.h"
#include "i_interface.h"
FGameTexture* CrosshairImage; FGameTexture* CrosshairImage;
static int CrosshairNum; 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"); CVARD(Float, crosshairscale, 0.5, CVAR_ARCHIVE, "changes the size of the crosshair");
CVAR(Bool, crosshairgrow, false, CVAR_ARCHIVE); CVAR(Bool, crosshairgrow, false, CVAR_ARCHIVE);
EXTERN_CVAR(Float, hud_scalefactor) CUSTOM_CVARD(Float, hud_scalefactor, 1, CVAR_ARCHIVE, "changes the hud scale")
EXTERN_CVAR(Bool, hud_aspectscale) {
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) void ST_LoadCrosshair(int num, bool alwaysload)
{ {

View file

@ -35,7 +35,6 @@
*/ */
#include "files.h" #include "files.h"
#include "gi.h"
#include "bitmap.h" #include "bitmap.h"
#include "textures.h" #include "textures.h"
#include "imagehelpers.h" #include "imagehelpers.h"

View file

@ -1183,7 +1183,6 @@ void FTextureManager::AddLocalizedVariants()
// //
//========================================================================== //==========================================================================
FGameTexture *CreateShaderTexture(bool, bool); FGameTexture *CreateShaderTexture(bool, bool);
void InitBuildTiles();
FImageSource* CreateEmptyTexture(); FImageSource* CreateEmptyTexture();
void FTextureManager::Init() void FTextureManager::Init()
@ -1213,7 +1212,7 @@ void FTextureManager::Init()
AddGameTexture(mt); AddGameTexture(mt);
} }
void FTextureManager::AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&)) void FTextureManager::AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&), void (*customtexturehandler)())
{ {
progressFunc = progressFunc_; progressFunc = progressFunc_;
//if (BuildTileFiles.Size() == 0) CountBuildTiles (); //if (BuildTileFiles.Size() == 0) CountBuildTiles ();
@ -1229,9 +1228,9 @@ void FTextureManager::AddTextures(void (*progressFunc_)(), void (*checkForHacks)
build.ResolveAllPatches(); build.ResolveAllPatches();
// Add one marker so that the last WAD is easier to handle and treat // 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()); FirstTextureForFile.Push(Textures.Size());
InitBuildTiles (); if (customtexturehandler) customtexturehandler();
FirstTextureForFile.Push(Textures.Size()); FirstTextureForFile.Push(Textures.Size());
DefaultTexture = CheckForTexture ("-NOFLAT-", ETextureType::Override, 0); DefaultTexture = CheckForTexture ("-NOFLAT-", ETextureType::Override, 0);

View file

@ -124,7 +124,7 @@ public:
void LoadTextureX(int wadnum, FMultipatchTextureBuilder &build); void LoadTextureX(int wadnum, FMultipatchTextureBuilder &build);
void AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &build); void AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &build);
void Init(); void Init();
void AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&)); void AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&), void (*customtexturehandler)() = nullptr);
void DeleteAll(); void DeleteAll();
void ReplaceTexture (FTextureID picnum, FGameTexture *newtexture, bool free); void ReplaceTexture (FTextureID picnum, FGameTexture *newtexture, bool free);

View file

@ -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<class T> template<class T>
inline TAngle<T> fabs (const TAngle<T> &deg) inline TAngle<T> fabs (const TAngle<T> &deg)
{ {

View file

@ -42,6 +42,7 @@
#include "utf8.h" #include "utf8.h"
#include "d_protocol.h" #include "d_protocol.h"
#include "d_net.h" #include "d_net.h"
#include "gamecontrol.h"
static cheatseq_t *cheatlist; static cheatseq_t *cheatlist;
static int numcheats; static int numcheats;

View file

@ -72,7 +72,7 @@ void CT_Drawer ();
bool CT_Responder (event_t *ev); bool CT_Responder (event_t *ev);
void CT_PasteChat(const char *clip); void CT_PasteChat(const char *clip);
int chatmodeon; extern int chatmodeon;
// Private data // Private data

View file

@ -88,19 +88,12 @@ void LoadHexFont(const char* filename);
CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, autoloadwidescreen, 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". // 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") 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) EXTERN_CVAR(Bool, ui_generic)
EXTERN_CVAR(String, language)
CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
{
GStrings.UpdateLanguage(self);
UpdateGenericUI(ui_generic);
}
CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
{ {
@ -136,7 +129,6 @@ extern bool pauseext;
cycle_t thinktime, actortime, gameupdatetime, drawtime; cycle_t thinktime, actortime, gameupdatetime, drawtime;
gamestate_t gamestate = GS_STARTUP;
gameaction_t gameaction = ga_nothing; gameaction_t gameaction = ga_nothing;
// gameaction state // gameaction state
MapRecord* g_nextmap; MapRecord* g_nextmap;
@ -146,8 +138,6 @@ int g_bossexit;
FILE* hashfile; FILE* hashfile;
FStartupInfo GameStartupInfo;
InputState inputState; InputState inputState;
int ShowStartupWindow(TArray<GrpEntry> &); int ShowStartupWindow(TArray<GrpEntry> &);
TArray<FString> GetGameFronUserFiles(); TArray<FString> GetGameFronUserFiles();
@ -166,22 +156,22 @@ void MarkMap();
void BuildFogTable(); void BuildFogTable();
void ParseGLDefs(); void ParseGLDefs();
void I_UpdateDiscordPresence(bool SendPresence, const char* curstatus, const char* appid, const char* steamappid); 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; DStatusBarCore* StatusBar;
bool AppActive = true;
FString currentGame; FString currentGame;
FString LumpFilter; FString LumpFilter;
CVAR(Bool, queryiwad, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); EXTERN_CVAR(Bool, queryiwad);
CVAR(String, defaultiwad, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG); EXTERN_CVAR(String, defaultiwad);
CVAR(Bool, disableautoload, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) CVAR(Bool, disableautoload, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
extern int hud_size_max; extern int hud_size_max;
int paused;
bool pausedWithKey; bool pausedWithKey;
bool gamesetinput = false; bool gamesetinput = false;
@ -553,6 +543,8 @@ static void System_SetTransition(int type)
nextwipe = type; nextwipe = type;
} }
void I_StartupJoysticks(); void I_StartupJoysticks();
void I_ShutdownInput(); void I_ShutdownInput();
int RunGame(); int RunGame();
@ -566,6 +558,7 @@ int GameMain()
SetConsoleNotifyBuffer(); SetConsoleNotifyBuffer();
sysCallbacks = sysCallbacks =
{ {
G_Responder,
System_WantGuiCapture, System_WantGuiCapture,
System_WantLeftButton, System_WantLeftButton,
System_NetGame, System_NetGame,
@ -591,6 +584,13 @@ int GameMain()
System_ToggleFullConsole, System_ToggleFullConsole,
System_StartCutscene, System_StartCutscene,
System_SetTransition, System_SetTransition,
CheckCheatmode,
HudScaleChanged,
M_SetSpecialMenu,
OnMenuOpen,
nullptr,
nullptr,
[]() ->FConfigFile* { return GameConfig; }
}; };
try try
@ -773,9 +773,20 @@ static TArray<GrpEntry> SetupGame()
stuff.Path = ExtractFileBase(found.FileName); stuff.Path = ExtractFileBase(found.FileName);
wads.Push(stuff); 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) if (pick >= 0)
{ {
disableautoload = !!(flags & 1);
autoloadlights = !!(flags & 2);
autoloadbrightmaps = !!(flags & 4);
autoloadwidescreen = !!(flags & 8);
// The newly selected IWAD becomes the new default // The newly selected IWAD becomes the new default
defaultiwad = groups[pick].FileName; defaultiwad = groups[pick].FileName;
} }
@ -1242,92 +1253,6 @@ CCMD(snd_reset)
Mus_ResumeSaved(); 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() FString G_GetDemoPath()
{ {

View file

@ -45,6 +45,7 @@ void updatePauseStatus();
void DeferredStartGame(MapRecord* map, int skill, bool nostopsound = false); void DeferredStartGame(MapRecord* map, int skill, bool nostopsound = false);
void ChangeLevel(MapRecord* map, int skill, bool bossexit = false); void ChangeLevel(MapRecord* map, int skill, bool bossexit = false);
void CompleteLevel(MapRecord* map); void CompleteLevel(MapRecord* map);
bool CheckCheatmode(bool printmsg = true, bool sponly = false);
void TITLE_InformName(const char* newname); void TITLE_InformName(const char* newname);

View file

@ -132,19 +132,11 @@ CUSTOM_CVARD(Int, hud_size, Hud_Stbar, CVAR_ARCHIVE, "Defines the HUD size and s
else setViewport(self); else setViewport(self);
} }
CUSTOM_CVARD(Float, hud_scalefactor, 1, CVAR_ARCHIVE, "changes the hud scale") void HudScaleChanged()
{
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)
{ {
setViewport(hud_size); 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. // 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) CCMD(sizeup)
{ {

View file

@ -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. // Draws the fps counter, dot ticker, and palette debug.
// //
//========================================================================== //==========================================================================
CVAR(Bool, vid_fps, false, 0) EXTERN_CVAR(Bool, vid_fps)
static FString statFPS() static FString statFPS()

View file

@ -163,7 +163,7 @@ void InputState::ClearAllInput()
//========================================================================== //==========================================================================
void I_StartTic(); void I_StartTic();
bool ToggleFullscreen; extern bool ToggleFullscreen;
int32_t handleevents(void) int32_t handleevents(void)
{ {

View file

@ -88,6 +88,7 @@
#include "v_draw.h" #include "v_draw.h"
#include "gamehud.h" #include "gamehud.h"
#include "wipe.h" #include "wipe.h"
#include "i_interface.h"
CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, r_ticstability, true, 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 stabilityticduration = 0;
static uint64_t stabilitystarttime = 0; static uint64_t stabilitystarttime = 0;
bool pauseext;
bool r_NoInterpolate; bool r_NoInterpolate;
int entertic; int entertic;
int oldentertics; int oldentertics;

View file

@ -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 // intro might call this repeatedly
if (CurrentMenu != NULL) if (CurrentMenu != NULL)
@ -200,7 +200,6 @@ void M_StartControlPanel(bool makeSound, bool)
GSnd->SetSfxPaused(true, PAUSESFX_MENU); GSnd->SetSfxPaused(true, PAUSESFX_MENU);
gi->MenuOpened(); gi->MenuOpened();
if (makeSound && menu_sounds) gi->MenuSound(ActivateSound); if (makeSound && menu_sounds) gi->MenuSound(ActivateSound);
M_DoStartControlPanel(false);
} }
@ -755,29 +754,3 @@ DEFINE_ACTION_FUNCTION(_PlayerMenu, DrawPlayerSprite)
return 0; 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<FOptionValues::Pair>& vals = (*pVRModes)->mValues;
TArray<FOptionValues::Pair> 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;
}

View file

@ -6,9 +6,6 @@
extern bool help_disabled; extern bool help_disabled;
void M_StartControlPanel (bool makeSound, bool scaleoverride = false);
extern FNewGameStartup NewGameStartupInfo; extern FNewGameStartup NewGameStartupInfo;
void M_StartupEpisodeMenu(FNewGameStartup *gs); void M_StartupEpisodeMenu(FNewGameStartup *gs);
void M_StartupSkillMenu(FNewGameStartup *gs); void M_StartupSkillMenu(FNewGameStartup *gs);