Merge pull request #66 from cinaera/pr_flash

Notify player on chat highlight (windows only)
This commit is contained in:
Dennis Felsing 2014-10-18 17:45:07 +02:00
commit ab07b90ae8
8 changed files with 60 additions and 1 deletions

View file

@ -1,5 +1,6 @@
#include "SDL.h"
#include "SDL_syswm.h"
#if defined(__ANDROID__)
#define GL_GLEXT_PROTOTYPES
#include <GLES/gl.h>
@ -647,7 +648,29 @@ int CGraphicsBackend_SDL_OpenGL::WindowActive()
int CGraphicsBackend_SDL_OpenGL::WindowOpen()
{
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
}

View file

@ -308,4 +308,5 @@ public:
virtual void Maximize();
virtual int WindowActive();
virtual int WindowOpen();
virtual void NotifyWindow();
};

View file

@ -6,6 +6,7 @@
#include <base/tl/threading.h>
#include "SDL.h"
#include "SDL_syswm.h"
#if defined(__ANDROID__)
#define GL_GLEXT_PROTOTYPES
#include <GLES/gl.h>
@ -953,6 +954,29 @@ int CGraphics_SDL::WindowActive()
int CGraphics_SDL::WindowOpen()
{
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
}

View file

@ -142,6 +142,8 @@ public:
virtual int WindowActive();
virtual int WindowOpen();
virtual void NotifyWindow();
virtual void TakeScreenshot(const char *pFilename);
virtual void TakeCustomScreenshot(const char *pFilename);
virtual void Swap();

View file

@ -805,7 +805,11 @@ int CGraphics_Threaded::WindowActive()
int CGraphics_Threaded::WindowOpen()
{
return m_pBackend->WindowOpen();
}
void CGraphics_Threaded::NotifyWindow()
{
return m_pBackend->NotifyWindow();
}
void CGraphics_Threaded::TakeScreenshot(const char *pFilename)

View file

@ -311,6 +311,7 @@ public:
virtual void Maximize() = 0;
virtual int WindowActive() = 0;
virtual int WindowOpen() = 0;
virtual void NotifyWindow() = 0;
virtual void RunBuffer(CCommandBuffer *pBuffer) = 0;
virtual bool IsIdle() const = 0;
@ -427,6 +428,8 @@ public:
virtual int WindowActive();
virtual int WindowOpen();
virtual void NotifyWindow();
virtual int Init();
virtual void Shutdown();

View file

@ -142,6 +142,8 @@ public:
virtual void InsertSignal(class semaphore *pSemaphore) = 0;
virtual bool IsIdle() = 0;
virtual void WaitForIdle() = 0;
virtual void NotifyWindow() = 0;
};
class IEngineGraphics : public IGraphics
@ -156,7 +158,6 @@ public:
virtual int WindowActive() = 0;
virtual int WindowOpen() = 0;
};
extern IEngineGraphics *CreateEngineGraphics();

View file

@ -452,6 +452,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
{
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_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now;
}