mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
2948: Show File button in demo player r=heinrich5991 a=def- to easily get the file instead of having to search for it in the file browser again. Complements #2946 2956: Add Background music volume slider r=heinrich5991 a=def- as requested by hussainx3 2965: Clean up some data r=heinrich5991 a=def- Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
d2df9c6a66
|
@ -4019,6 +4019,11 @@ CCommandProcessor_SDL_OpenGL::CCommandProcessor_SDL_OpenGL(int OpenGLMajor, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCommandProcessor_SDL_OpenGL::~CCommandProcessor_SDL_OpenGL()
|
||||||
|
{
|
||||||
|
delete m_pOpenGL;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------ CGraphicsBackend_SDL_OpenGL
|
// ------------ CGraphicsBackend_SDL_OpenGL
|
||||||
|
|
||||||
static void GetGlewVersion(int &GlewMajor, int &GlewMinor, int &GlewPatch)
|
static void GetGlewVersion(int &GlewMajor, int &GlewMinor, int &GlewPatch)
|
||||||
|
|
|
@ -211,6 +211,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCommandProcessorFragment_OpenGL();
|
CCommandProcessorFragment_OpenGL();
|
||||||
|
virtual ~CCommandProcessorFragment_OpenGL() = default;
|
||||||
|
|
||||||
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
||||||
};
|
};
|
||||||
|
@ -468,6 +469,7 @@ class CCommandProcessor_SDL_OpenGL : public CGraphicsBackend_Threaded::ICommandP
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCommandProcessor_SDL_OpenGL(int OpenGLMajor, int OpenGLMinor, int OpenGLPatch);
|
CCommandProcessor_SDL_OpenGL(int OpenGLMajor, int OpenGLMinor, int OpenGLPatch);
|
||||||
|
virtual ~CCommandProcessor_SDL_OpenGL();
|
||||||
virtual void RunBuffer(CCommandBuffer *pBuffer);
|
virtual void RunBuffer(CCommandBuffer *pBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,17 @@ struct CFontSizeData
|
||||||
class CFont
|
class CFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
~CFont()
|
||||||
|
{
|
||||||
|
free(m_pBuf);
|
||||||
|
delete[] m_TextureData[0];
|
||||||
|
delete[] m_TextureData[1];
|
||||||
|
for(size_t i = 0; i < m_FtFallbackFonts.size(); i++)
|
||||||
|
{
|
||||||
|
free(m_FtFallbackFonts[i].m_pBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InitFontSizes()
|
void InitFontSizes()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < NUM_FONT_SIZES; ++i)
|
for(int i = 0; i < NUM_FONT_SIZES; ++i)
|
||||||
|
@ -97,11 +108,13 @@ public:
|
||||||
return &m_aFontSizes[FontSize - MIN_FONT_SIZE];
|
return &m_aFontSizes[FontSize - MIN_FONT_SIZE];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *m_pBuf;
|
||||||
char m_aFilename[512];
|
char m_aFilename[512];
|
||||||
FT_Face m_FtFace;
|
FT_Face m_FtFace;
|
||||||
|
|
||||||
struct SFontFallBack
|
struct SFontFallBack
|
||||||
{
|
{
|
||||||
|
void *m_pBuf;
|
||||||
char m_aFilename[512];
|
char m_aFilename[512];
|
||||||
FT_Face m_FtFace;
|
FT_Face m_FtFace;
|
||||||
};
|
};
|
||||||
|
@ -584,7 +597,14 @@ public:
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < m_Fonts.size(); ++i)
|
for(size_t i = 0; i < m_Fonts.size(); ++i)
|
||||||
{
|
{
|
||||||
DestroyFont(m_Fonts[i]);
|
FT_Done_Face(m_Fonts[i]->m_FtFace);
|
||||||
|
|
||||||
|
for(CFont::SFontFallBack &FallbackFont : m_Fonts[i]->m_FtFallbackFonts)
|
||||||
|
{
|
||||||
|
FT_Done_Face(FallbackFont.m_FtFace);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete m_Fonts[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_FTLibrary != 0)
|
if(m_FTLibrary != 0)
|
||||||
|
@ -660,6 +680,7 @@ public:
|
||||||
|
|
||||||
dbg_msg("textrender", "loaded pFont from '%s'", pFilename);
|
dbg_msg("textrender", "loaded pFont from '%s'", pFilename);
|
||||||
|
|
||||||
|
pFont->m_pBuf = (void *)pBuf;
|
||||||
pFont->m_CurTextureDimensions[0] = 1024;
|
pFont->m_CurTextureDimensions[0] = 1024;
|
||||||
pFont->m_TextureData[0] = new unsigned char[pFont->m_CurTextureDimensions[0] * pFont->m_CurTextureDimensions[0]];
|
pFont->m_TextureData[0] = new unsigned char[pFont->m_CurTextureDimensions[0] * pFont->m_CurTextureDimensions[0]];
|
||||||
mem_zero(pFont->m_TextureData[0], pFont->m_CurTextureDimensions[0] * pFont->m_CurTextureDimensions[0] * sizeof(unsigned char));
|
mem_zero(pFont->m_TextureData[0], pFont->m_CurTextureDimensions[0] * pFont->m_CurTextureDimensions[0] * sizeof(unsigned char));
|
||||||
|
@ -683,6 +704,7 @@ public:
|
||||||
virtual bool LoadFallbackFont(CFont *pFont, const char *pFilename, const unsigned char *pBuf, size_t Size)
|
virtual bool LoadFallbackFont(CFont *pFont, const char *pFilename, const unsigned char *pBuf, size_t Size)
|
||||||
{
|
{
|
||||||
CFont::SFontFallBack FallbackFont;
|
CFont::SFontFallBack FallbackFont;
|
||||||
|
FallbackFont.m_pBuf = (void *)pBuf;
|
||||||
str_copy(FallbackFont.m_aFilename, pFilename, sizeof(FallbackFont.m_aFilename));
|
str_copy(FallbackFont.m_aFilename, pFilename, sizeof(FallbackFont.m_aFilename));
|
||||||
|
|
||||||
if(FT_New_Memory_Face(m_FTLibrary, pBuf, Size, 0, &FallbackFont.m_FtFace) == 0)
|
if(FT_New_Memory_Face(m_FTLibrary, pBuf, Size, 0, &FallbackFont.m_FtFace) == 0)
|
||||||
|
@ -715,27 +737,6 @@ public:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DestroyFont(CFont *pFont)
|
|
||||||
{
|
|
||||||
for(size_t i = 0; i < m_Fonts.size(); ++i)
|
|
||||||
{
|
|
||||||
if(m_Fonts[i] == pFont)
|
|
||||||
{
|
|
||||||
m_Fonts[i] = m_Fonts[m_Fonts.size() - 1];
|
|
||||||
m_Fonts.pop_back();
|
|
||||||
|
|
||||||
FT_Done_Face(pFont->m_FtFace);
|
|
||||||
|
|
||||||
for(CFont::SFontFallBack &FallbackFont : pFont->m_FtFallbackFonts)
|
|
||||||
{
|
|
||||||
FT_Done_Face(FallbackFont.m_FtFace);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete pFont;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void SetDefaultFont(CFont *pFont)
|
virtual void SetDefaultFont(CFont *pFont)
|
||||||
{
|
{
|
||||||
dbg_msg("textrender", "default pFont set %p", pFont);
|
dbg_msg("textrender", "default pFont set %p", pFont);
|
||||||
|
|
|
@ -82,6 +82,7 @@ MACRO_CONFIG_INT(SndMusic, snd_enable_music, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLI
|
||||||
MACRO_CONFIG_INT(SndVolume, snd_volume, 100, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Sound volume")
|
MACRO_CONFIG_INT(SndVolume, snd_volume, 100, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Sound volume")
|
||||||
MACRO_CONFIG_INT(SndDevice, snd_device, -1, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "(deprecated) Sound device to use")
|
MACRO_CONFIG_INT(SndDevice, snd_device, -1, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "(deprecated) Sound device to use")
|
||||||
MACRO_CONFIG_INT(SndMapSoundVolume, snd_ambient_volume, 70, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Map Sound sound volume")
|
MACRO_CONFIG_INT(SndMapSoundVolume, snd_ambient_volume, 70, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Map Sound sound volume")
|
||||||
|
MACRO_CONFIG_INT(SndBackgroundMusicVolume, snd_background_music_volume, 50, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Background music sound volume")
|
||||||
|
|
||||||
MACRO_CONFIG_INT(SndNonactiveMute, snd_nonactive_mute, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "")
|
MACRO_CONFIG_INT(SndNonactiveMute, snd_nonactive_mute, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "")
|
||||||
MACRO_CONFIG_INT(SndGame, snd_game, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable game sounds")
|
MACRO_CONFIG_INT(SndGame, snd_game, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable game sounds")
|
||||||
|
|
|
@ -82,7 +82,6 @@ public:
|
||||||
virtual bool LoadFallbackFont(CFont *pFont, const char *pFilename, const unsigned char *pBuf, size_t Size) = 0;
|
virtual bool LoadFallbackFont(CFont *pFont, const char *pFilename, const unsigned char *pBuf, size_t Size) = 0;
|
||||||
virtual CFont *GetFont(int FontIndex) = 0;
|
virtual CFont *GetFont(int FontIndex) = 0;
|
||||||
virtual CFont *GetFont(const char *pFilename) = 0;
|
virtual CFont *GetFont(const char *pFilename) = 0;
|
||||||
virtual void DestroyFont(CFont *pFont) = 0;
|
|
||||||
|
|
||||||
virtual void SetDefaultFont(CFont *pFont) = 0;
|
virtual void SetDefaultFont(CFont *pFont) = 0;
|
||||||
virtual void SetCurFont(CFont *pFont) = 0;
|
virtual void SetCurFont(CFont *pFont) = 0;
|
||||||
|
|
|
@ -387,6 +387,27 @@ void mem_copy_special(void *pDest, void *pSource, size_t Size, size_t Count, siz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMapLayers::~CMapLayers()
|
||||||
|
{
|
||||||
|
//clear everything and destroy all buffers
|
||||||
|
if(m_TileLayerVisuals.size() != 0)
|
||||||
|
{
|
||||||
|
int s = m_TileLayerVisuals.size();
|
||||||
|
for(int i = 0; i < s; ++i)
|
||||||
|
{
|
||||||
|
delete m_TileLayerVisuals[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(m_QuadLayerVisuals.size() != 0)
|
||||||
|
{
|
||||||
|
int s = m_QuadLayerVisuals.size();
|
||||||
|
for(int i = 0; i < s; ++i)
|
||||||
|
{
|
||||||
|
delete m_QuadLayerVisuals[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CMapLayers::OnMapLoad()
|
void CMapLayers::OnMapLoad()
|
||||||
{
|
{
|
||||||
if(!Graphics()->IsTileBufferingEnabled() && !Graphics()->IsQuadBufferingEnabled())
|
if(!Graphics()->IsTileBufferingEnabled() && !Graphics()->IsQuadBufferingEnabled())
|
||||||
|
|
|
@ -139,6 +139,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
CMapLayers(int Type, bool OnlineOnly = true);
|
CMapLayers(int Type, bool OnlineOnly = true);
|
||||||
|
virtual ~CMapLayers();
|
||||||
virtual void OnInit();
|
virtual void OnInit();
|
||||||
virtual void OnRender();
|
virtual void OnRender();
|
||||||
virtual void OnMapLoad();
|
virtual void OnMapLoad();
|
||||||
|
|
|
@ -463,6 +463,23 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
DemolistOnUpdate(false);
|
DemolistOnUpdate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// file button
|
||||||
|
ButtonBar.VSplitRight(Margins, &ButtonBar, 0);
|
||||||
|
ButtonBar.VSplitRight(ButtonbarHeight * 3, &ButtonBar, &Button);
|
||||||
|
static int s_FileButton = 0;
|
||||||
|
if(DoButton_DemoPlayer(&s_FileButton, Localize("File"), 0, &Button))
|
||||||
|
{
|
||||||
|
char aBuf[MAX_PATH_LENGTH];
|
||||||
|
char aBufFull[MAX_PATH_LENGTH + 7];
|
||||||
|
str_format(aBufFull, sizeof(aBufFull), "%s/%s", m_aCurrentDemoFolder, m_lDemos[m_DemolistSelectedIndex].m_aFilename);
|
||||||
|
Storage()->GetCompletePath(m_lDemos[m_DemolistSelectedIndex].m_StorageType, aBufFull, aBuf, sizeof(aBuf));
|
||||||
|
str_format(aBufFull, sizeof(aBufFull), "file://%s", aBuf);
|
||||||
|
if(!open_link(aBufFull))
|
||||||
|
{
|
||||||
|
dbg_msg("menus", "couldn't open link");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// toggle keyboard shortcuts button
|
// toggle keyboard shortcuts button
|
||||||
ButtonBar.VSplitRight(Margins * 3, &ButtonBar, 0);
|
ButtonBar.VSplitRight(Margins * 3, &ButtonBar, 0);
|
||||||
ButtonBar.VSplitRight(ButtonbarHeight, &ButtonBar, &Button);
|
ButtonBar.VSplitRight(ButtonbarHeight, &ButtonBar, &Button);
|
||||||
|
|
|
@ -1267,6 +1267,17 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
||||||
UI()->DoLabelScaled(&Label, Localize("Map sound volume"), 14.0f, -1);
|
UI()->DoLabelScaled(&Label, Localize("Map sound volume"), 14.0f, -1);
|
||||||
g_Config.m_SndMapSoundVolume = (int)(DoScrollbarH(&g_Config.m_SndMapSoundVolume, &Button, g_Config.m_SndMapSoundVolume / 100.0f) * 100.0f);
|
g_Config.m_SndMapSoundVolume = (int)(DoScrollbarH(&g_Config.m_SndMapSoundVolume, &Button, g_Config.m_SndMapSoundVolume / 100.0f) * 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// volume slider background music
|
||||||
|
{
|
||||||
|
CUIRect Button, Label;
|
||||||
|
MainView.HSplitTop(5.0f, &Button, &MainView);
|
||||||
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||||
|
Button.VSplitLeft(190.0f, &Label, &Button);
|
||||||
|
Button.HMargin(2.0f, &Button);
|
||||||
|
UI()->DoLabelScaled(&Label, Localize("Background music volume"), 14.0f, -1);
|
||||||
|
g_Config.m_SndBackgroundMusicVolume = (int)(DoScrollbarH(&g_Config.m_SndBackgroundMusicVolume, &Button, g_Config.m_SndBackgroundMusicVolume / 100.0f) * 100.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CLanguage
|
class CLanguage
|
||||||
|
|
|
@ -59,9 +59,10 @@ void CSounds::OnInit()
|
||||||
{
|
{
|
||||||
// setup sound channels
|
// setup sound channels
|
||||||
m_MapSoundVolume = g_Config.m_SndMapSoundVolume / 100.0f;
|
m_MapSoundVolume = g_Config.m_SndMapSoundVolume / 100.0f;
|
||||||
|
m_BackgroundMusicVolume = g_Config.m_SndBackgroundMusicVolume / 100.0f;
|
||||||
|
|
||||||
Sound()->SetChannel(CSounds::CHN_GUI, 1.0f, 0.0f);
|
Sound()->SetChannel(CSounds::CHN_GUI, 1.0f, 0.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_MUSIC, 1.0f, 0.0f);
|
Sound()->SetChannel(CSounds::CHN_MUSIC, m_BackgroundMusicVolume, 1.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f, 1.0f);
|
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f, 1.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_GLOBAL, 1.0f, 0.0f);
|
Sound()->SetChannel(CSounds::CHN_GLOBAL, 1.0f, 0.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
||||||
|
@ -121,6 +122,13 @@ void CSounds::OnRender()
|
||||||
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float NewBackgroundMusicVol = g_Config.m_SndBackgroundMusicVolume / 100.0f;
|
||||||
|
if(NewBackgroundMusicVol != m_BackgroundMusicVolume)
|
||||||
|
{
|
||||||
|
m_BackgroundMusicVolume = NewBackgroundMusicVol;
|
||||||
|
Sound()->SetChannel(CSounds::CHN_MUSIC, m_BackgroundMusicVolume, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
// play sound from queue
|
// play sound from queue
|
||||||
if(m_QueuePos > 0)
|
if(m_QueuePos > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,7 @@ class CSounds : public CComponent
|
||||||
int GetSampleId(int SetId);
|
int GetSampleId(int SetId);
|
||||||
|
|
||||||
float m_MapSoundVolume;
|
float m_MapSoundVolume;
|
||||||
|
float m_BackgroundMusicVolume;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// sound channels
|
// sound channels
|
||||||
|
|
|
@ -2537,6 +2537,7 @@ void CGameClient::LoadGameSkin(const char *pPath, bool AsDir)
|
||||||
else if(PngLoaded)
|
else if(PngLoaded)
|
||||||
{
|
{
|
||||||
g_pData->m_aImages[IMAGE_GAME].m_Id = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0, aPath);
|
g_pData->m_aImages[IMAGE_GAME].m_Id = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0, aPath);
|
||||||
|
free(ImgInfo.m_pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2575,6 +2576,7 @@ void CGameClient::LoadEmoticonsSkin(const char *pPath, bool AsDir)
|
||||||
else if(PngLoaded)
|
else if(PngLoaded)
|
||||||
{
|
{
|
||||||
g_pData->m_aImages[IMAGE_EMOTICONS].m_Id = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0, aPath);
|
g_pData->m_aImages[IMAGE_EMOTICONS].m_Id = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0, aPath);
|
||||||
|
free(ImgInfo.m_pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2613,6 +2615,7 @@ void CGameClient::LoadParticlesSkin(const char *pPath, bool AsDir)
|
||||||
else if(PngLoaded)
|
else if(PngLoaded)
|
||||||
{
|
{
|
||||||
g_pData->m_aImages[IMAGE_PARTICLES].m_Id = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0, aPath);
|
g_pData->m_aImages[IMAGE_PARTICLES].m_Id = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0, aPath);
|
||||||
|
free(ImgInfo.m_pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue