mirror of https://github.com/ddnet/ddnet.git
Compare commits
5 Commits
516315e0e2
...
d265057591
Author | SHA1 | Date |
---|---|---|
Dennis Felsing | d265057591 | |
Dennis Felsing | b3bd831cde | |
Robert Müller | b3bcfd39bc | |
Robert Müller | e4dddb95ce | |
Robert Müller | 86bf5424e3 |
|
@ -483,6 +483,19 @@ std::unique_ptr<ILogger> log_logger_windows_debugger()
|
|||
}
|
||||
#endif
|
||||
|
||||
class CLoggerNoOp : public ILogger
|
||||
{
|
||||
public:
|
||||
void Log(const CLogMessage *pMessage) override
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
};
|
||||
std::unique_ptr<ILogger> log_logger_noop()
|
||||
{
|
||||
return std::make_unique<CLoggerNoOp>();
|
||||
}
|
||||
|
||||
void CFutureLogger::Set(std::shared_ptr<ILogger> pLogger)
|
||||
{
|
||||
const CLockScope LockScope(m_PendingLock);
|
||||
|
|
|
@ -210,6 +210,13 @@ std::unique_ptr<ILogger> log_logger_stdout();
|
|||
*/
|
||||
std::unique_ptr<ILogger> log_logger_windows_debugger();
|
||||
|
||||
/**
|
||||
* @ingroup Log
|
||||
*
|
||||
* Logger which discards all logs.
|
||||
*/
|
||||
std::unique_ptr<ILogger> log_logger_noop();
|
||||
|
||||
/**
|
||||
* @ingroup Log
|
||||
*
|
||||
|
|
|
@ -1539,6 +1539,7 @@ bool CGraphicsBackend_SDL_GL::UpdateDisplayMode(int Index)
|
|||
return false;
|
||||
}
|
||||
|
||||
g_Config.m_GfxScreen = Index;
|
||||
g_Config.m_GfxDesktopWidth = DisplayMode.w;
|
||||
g_Config.m_GfxDesktopHeight = DisplayMode.h;
|
||||
|
||||
|
|
|
@ -3929,8 +3929,10 @@ void CClient::SwitchWindowScreen(int Index)
|
|||
int IsFullscreen = g_Config.m_GfxFullscreen;
|
||||
int IsBorderless = g_Config.m_GfxBorderless;
|
||||
|
||||
if(Graphics()->SetWindowScreen(Index))
|
||||
g_Config.m_GfxScreen = Index;
|
||||
if(!Graphics()->SetWindowScreen(Index))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetWindowParams(3, false); // prevent DDNet to get stretch on monitors
|
||||
|
||||
|
@ -3943,7 +3945,7 @@ void CClient::SwitchWindowScreen(int Index)
|
|||
g_Config.m_GfxScreenHeight = CurMode.m_WindowHeight;
|
||||
g_Config.m_GfxScreenRefreshRate = CurMode.m_RefreshRate;
|
||||
|
||||
Graphics()->Resize(g_Config.m_GfxScreenWidth, g_Config.m_GfxScreenHeight, g_Config.m_GfxScreenRefreshRate);
|
||||
Graphics()->ResizeToScreen();
|
||||
|
||||
SetWindowParams(IsFullscreen, IsBorderless);
|
||||
}
|
||||
|
@ -4032,7 +4034,7 @@ void CClient::ConchainWindowResize(IConsole::IResult *pResult, void *pUserData,
|
|||
pfnCallback(pResult, pCallbackUserData);
|
||||
if(pSelf->Graphics() && pResult->NumArguments())
|
||||
{
|
||||
pSelf->Graphics()->Resize(g_Config.m_GfxScreenWidth, g_Config.m_GfxScreenHeight, g_Config.m_GfxScreenRefreshRate);
|
||||
pSelf->Graphics()->ResizeToScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4499,9 +4501,9 @@ int main(int argc, const char **argv)
|
|||
pSteam->ClearConnectAddress();
|
||||
}
|
||||
|
||||
const int Mode = g_Config.m_Logappend ? IOFLAG_APPEND : IOFLAG_WRITE;
|
||||
if(g_Config.m_Logfile[0])
|
||||
{
|
||||
const int Mode = g_Config.m_Logappend ? IOFLAG_APPEND : IOFLAG_WRITE;
|
||||
IOHANDLE Logfile = pStorage->OpenFile(g_Config.m_Logfile, Mode, IStorage::TYPE_SAVE_OR_ABSOLUTE);
|
||||
if(Logfile)
|
||||
{
|
||||
|
@ -4510,8 +4512,13 @@ int main(int argc, const char **argv)
|
|||
else
|
||||
{
|
||||
log_error("client", "failed to open '%s' for logging", g_Config.m_Logfile);
|
||||
pFutureFileLogger->Set(log_logger_noop());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pFutureFileLogger->Set(log_logger_noop());
|
||||
}
|
||||
|
||||
// Register protocol and file extensions
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
|
|
|
@ -2664,15 +2664,15 @@ void CGraphics_Threaded::Move(int x, int y)
|
|||
PropChangedListener();
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::Resize(int w, int h, int RefreshRate)
|
||||
bool CGraphics_Threaded::Resize(int w, int h, int RefreshRate)
|
||||
{
|
||||
#if defined(CONF_VIDEORECORDER)
|
||||
if(IVideo::Current() && IVideo::Current()->IsRecording())
|
||||
return;
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if(WindowWidth() == w && WindowHeight() == h && RefreshRate == m_ScreenRefreshRate)
|
||||
return;
|
||||
return false;
|
||||
|
||||
// if the size is changed manually, only set the window resize, a window size changed event is triggered anyway
|
||||
if(m_pBackend->ResizeWindow(w, h, RefreshRate))
|
||||
|
@ -2680,7 +2680,20 @@ void CGraphics_Threaded::Resize(int w, int h, int RefreshRate)
|
|||
CVideoMode CurMode;
|
||||
m_pBackend->GetCurrentVideoMode(CurMode, m_ScreenHiDPIScale, g_Config.m_GfxDesktopWidth, g_Config.m_GfxDesktopHeight, g_Config.m_GfxScreen);
|
||||
GotResized(w, h, RefreshRate);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::ResizeToScreen()
|
||||
{
|
||||
if(Resize(g_Config.m_GfxScreenWidth, g_Config.m_GfxScreenHeight, g_Config.m_GfxScreenRefreshRate))
|
||||
return;
|
||||
|
||||
// Revert config variables if the change was not accepted
|
||||
g_Config.m_GfxScreenWidth = ScreenWidth();
|
||||
g_Config.m_GfxScreenHeight = ScreenHeight();
|
||||
g_Config.m_GfxScreenRefreshRate = m_ScreenRefreshRate;
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::GotResized(int w, int h, int RefreshRate)
|
||||
|
|
|
@ -1237,7 +1237,8 @@ public:
|
|||
void SetWindowParams(int FullscreenMode, bool IsBorderless) override;
|
||||
bool SetWindowScreen(int Index) override;
|
||||
void Move(int x, int y) override;
|
||||
void Resize(int w, int h, int RefreshRate) override;
|
||||
bool Resize(int w, int h, int RefreshRate) override;
|
||||
void ResizeToScreen() override;
|
||||
void GotResized(int w, int h, int RefreshRate) override;
|
||||
void UpdateViewport(int X, int Y, int W, int H, bool ByResize) override;
|
||||
void AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc) override;
|
||||
|
|
|
@ -295,7 +295,8 @@ public:
|
|||
virtual bool SetMultiSampling(uint32_t ReqMultiSamplingCount, uint32_t &MultiSamplingCountBackend) = 0;
|
||||
virtual int GetWindowScreen() = 0;
|
||||
virtual void Move(int x, int y) = 0;
|
||||
virtual void Resize(int w, int h, int RefreshRate) = 0;
|
||||
virtual bool Resize(int w, int h, int RefreshRate) = 0;
|
||||
virtual void ResizeToScreen() = 0;
|
||||
virtual void GotResized(int w, int h, int RefreshRate) = 0;
|
||||
virtual void UpdateViewport(int X, int Y, int W, int H, bool ByResize) = 0;
|
||||
|
||||
|
|
|
@ -170,9 +170,9 @@ int main(int argc, const char **argv)
|
|||
pConfigManager->SetReadOnly("sv_test_cmds", true);
|
||||
pConfigManager->SetReadOnly("sv_rescue", true);
|
||||
|
||||
const int Mode = g_Config.m_Logappend ? IOFLAG_APPEND : IOFLAG_WRITE;
|
||||
if(g_Config.m_Logfile[0])
|
||||
{
|
||||
const int Mode = g_Config.m_Logappend ? IOFLAG_APPEND : IOFLAG_WRITE;
|
||||
IOHANDLE Logfile = pStorage->OpenFile(g_Config.m_Logfile, Mode, IStorage::TYPE_SAVE_OR_ABSOLUTE);
|
||||
if(Logfile)
|
||||
{
|
||||
|
@ -181,8 +181,14 @@ int main(int argc, const char **argv)
|
|||
else
|
||||
{
|
||||
log_error("server", "failed to open '%s' for logging", g_Config.m_Logfile);
|
||||
pFutureFileLogger->Set(log_logger_noop());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pFutureFileLogger->Set(log_logger_noop());
|
||||
}
|
||||
|
||||
auto pServerLogger = std::make_shared<CServerLogger>(pServer);
|
||||
pEngine->SetAdditionalLogger(pServerLogger);
|
||||
|
||||
|
|
|
@ -1567,7 +1567,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
|||
g_Config.m_GfxScreenWidth = s_aModes[NewSelected].m_WindowWidth;
|
||||
g_Config.m_GfxScreenHeight = s_aModes[NewSelected].m_WindowHeight;
|
||||
g_Config.m_GfxScreenRefreshRate = s_aModes[NewSelected].m_RefreshRate;
|
||||
Graphics()->Resize(g_Config.m_GfxScreenWidth, g_Config.m_GfxScreenHeight, g_Config.m_GfxScreenRefreshRate);
|
||||
Graphics()->ResizeToScreen();
|
||||
}
|
||||
|
||||
// switches
|
||||
|
|
Loading…
Reference in New Issue