mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #66 from cinaera/pr_flash
Notify player on chat highlight (windows only)
This commit is contained in:
commit
ab07b90ae8
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
#include "SDL_syswm.h"
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
|
@ -647,7 +648,29 @@ int CGraphicsBackend_SDL_OpenGL::WindowActive()
|
||||||
int CGraphicsBackend_SDL_OpenGL::WindowOpen()
|
int CGraphicsBackend_SDL_OpenGL::WindowOpen()
|
||||||
{
|
{
|
||||||
return SDL_GetAppState()&SDL_APPACTIVE;
|
return SDL_GetAppState()&SDL_APPACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphicsBackend_SDL_OpenGL::NotifyWindow()
|
||||||
|
{
|
||||||
|
// get window handle
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
if(!SDL_GetWMInfo(&info))
|
||||||
|
{
|
||||||
|
dbg_msg("gfx", "unable to obtain window handle");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONF_FAMILY_WINDOWS)
|
||||||
|
FLASHWINFO desc;
|
||||||
|
desc.cbSize = sizeof(desc);
|
||||||
|
desc.hwnd = info.window;
|
||||||
|
desc.dwFlags = FLASHW_TRAY;
|
||||||
|
desc.uCount = 3; // flash 3 times
|
||||||
|
desc.dwTimeout = 0;
|
||||||
|
|
||||||
|
FlashWindowEx(&desc);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -308,4 +308,5 @@ public:
|
||||||
virtual void Maximize();
|
virtual void Maximize();
|
||||||
virtual int WindowActive();
|
virtual int WindowActive();
|
||||||
virtual int WindowOpen();
|
virtual int WindowOpen();
|
||||||
|
virtual void NotifyWindow();
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <base/tl/threading.h>
|
#include <base/tl/threading.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
#include "SDL_syswm.h"
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
|
@ -953,6 +954,29 @@ int CGraphics_SDL::WindowActive()
|
||||||
int CGraphics_SDL::WindowOpen()
|
int CGraphics_SDL::WindowOpen()
|
||||||
{
|
{
|
||||||
return SDL_GetAppState()&SDL_APPACTIVE;
|
return SDL_GetAppState()&SDL_APPACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphics_SDL::NotifyWindow()
|
||||||
|
{
|
||||||
|
// get window handle
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
if(!SDL_GetWMInfo(&info))
|
||||||
|
{
|
||||||
|
dbg_msg("gfx", "unable to obtain window handle");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONF_FAMILY_WINDOWS)
|
||||||
|
FLASHWINFO desc;
|
||||||
|
desc.cbSize = sizeof(desc);
|
||||||
|
desc.hwnd = info.window;
|
||||||
|
desc.dwFlags = FLASHW_TRAY;
|
||||||
|
desc.uCount = 3; // flash 3 times
|
||||||
|
desc.dwTimeout = 0;
|
||||||
|
|
||||||
|
FlashWindowEx(&desc);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,8 @@ public:
|
||||||
virtual int WindowActive();
|
virtual int WindowActive();
|
||||||
virtual int WindowOpen();
|
virtual int WindowOpen();
|
||||||
|
|
||||||
|
virtual void NotifyWindow();
|
||||||
|
|
||||||
virtual void TakeScreenshot(const char *pFilename);
|
virtual void TakeScreenshot(const char *pFilename);
|
||||||
virtual void TakeCustomScreenshot(const char *pFilename);
|
virtual void TakeCustomScreenshot(const char *pFilename);
|
||||||
virtual void Swap();
|
virtual void Swap();
|
||||||
|
|
|
@ -805,7 +805,11 @@ int CGraphics_Threaded::WindowActive()
|
||||||
int CGraphics_Threaded::WindowOpen()
|
int CGraphics_Threaded::WindowOpen()
|
||||||
{
|
{
|
||||||
return m_pBackend->WindowOpen();
|
return m_pBackend->WindowOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphics_Threaded::NotifyWindow()
|
||||||
|
{
|
||||||
|
return m_pBackend->NotifyWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphics_Threaded::TakeScreenshot(const char *pFilename)
|
void CGraphics_Threaded::TakeScreenshot(const char *pFilename)
|
||||||
|
|
|
@ -311,6 +311,7 @@ public:
|
||||||
virtual void Maximize() = 0;
|
virtual void Maximize() = 0;
|
||||||
virtual int WindowActive() = 0;
|
virtual int WindowActive() = 0;
|
||||||
virtual int WindowOpen() = 0;
|
virtual int WindowOpen() = 0;
|
||||||
|
virtual void NotifyWindow() = 0;
|
||||||
|
|
||||||
virtual void RunBuffer(CCommandBuffer *pBuffer) = 0;
|
virtual void RunBuffer(CCommandBuffer *pBuffer) = 0;
|
||||||
virtual bool IsIdle() const = 0;
|
virtual bool IsIdle() const = 0;
|
||||||
|
@ -427,6 +428,8 @@ public:
|
||||||
virtual int WindowActive();
|
virtual int WindowActive();
|
||||||
virtual int WindowOpen();
|
virtual int WindowOpen();
|
||||||
|
|
||||||
|
virtual void NotifyWindow();
|
||||||
|
|
||||||
virtual int Init();
|
virtual int Init();
|
||||||
virtual void Shutdown();
|
virtual void Shutdown();
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,8 @@ public:
|
||||||
virtual void InsertSignal(class semaphore *pSemaphore) = 0;
|
virtual void InsertSignal(class semaphore *pSemaphore) = 0;
|
||||||
virtual bool IsIdle() = 0;
|
virtual bool IsIdle() = 0;
|
||||||
virtual void WaitForIdle() = 0;
|
virtual void WaitForIdle() = 0;
|
||||||
|
|
||||||
|
virtual void NotifyWindow() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IEngineGraphics : public IGraphics
|
class IEngineGraphics : public IGraphics
|
||||||
|
@ -156,7 +158,6 @@ public:
|
||||||
|
|
||||||
virtual int WindowActive() = 0;
|
virtual int WindowActive() = 0;
|
||||||
virtual int WindowOpen() = 0;
|
virtual int WindowOpen() = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern IEngineGraphics *CreateEngineGraphics();
|
extern IEngineGraphics *CreateEngineGraphics();
|
||||||
|
|
|
@ -452,6 +452,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
|
||||||
{
|
{
|
||||||
if(Now-m_aLastSoundPlayed[CHAT_HIGHLIGHT] >= time_freq()*3/10)
|
if(Now-m_aLastSoundPlayed[CHAT_HIGHLIGHT] >= time_freq()*3/10)
|
||||||
{
|
{
|
||||||
|
Graphics()->NotifyWindow();
|
||||||
m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0);
|
m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0);
|
||||||
m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now;
|
m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue