Skip to content

Commit a594681

Browse files
committed
Fixed #9059 ([Request] flashMTAWindow)
1 parent 2b4d48a commit a594681

File tree

8 files changed

+53
-0
lines changed

8 files changed

+53
-0
lines changed

MTA10/core/CClientVariables.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ void CClientVariables::LoadDefaults ( void )
286286
DEFAULT ( "chat_line_fade_out", 3000 ); // chatbox line fade out time
287287
DEFAULT ( "chat_use_cegui", false ); // chatbox uses cegui
288288
DEFAULT ( "chat_nickcompletion", true ); // chatbox nick completion
289+
DEFAULT ( "server-can-flash-window", true ); // server can flash MTA window
289290
DEFAULT ( "text_scale", 1.0f ); // text scale
290291
DEFAULT ( "invert_mouse", false ); // mouse inverting
291292
DEFAULT ( "fly_with_mouse", false ); // flying with mouse controls

MTA10/core/CSettings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,11 @@ void CSettings::CreateGUI ( void )
11411141
m_pChatNickCompletion->SetPosition ( CVector2D ( vecTemp.fX, vecTemp.fY + 20.0f ) );
11421142
m_pChatNickCompletion->GetPosition ( vecTemp );
11431143
m_pChatNickCompletion->AutoSize ( NULL, 20.0f );
1144+
1145+
m_pFlashWindow = reinterpret_cast < CGUICheckBox* > ( pManager->CreateCheckBox ( pTabInterface, _("Server can flash the window") ) );
1146+
m_pFlashWindow->SetPosition ( CVector2D ( vecTemp.fX, vecTemp.fY + 20.0f ) );
1147+
m_pFlashWindow->GetPosition ( vecTemp );
1148+
m_pFlashWindow->AutoSize ( NULL, 20.0f );
11441149
}
11451150

11461151
/**
@@ -2976,6 +2981,7 @@ void CSettings::LoadData ( void )
29762981
CVARS_GET ( "chat_line_fade_out", iVar );
29772982
SetMilliseconds ( m_pChatLineFadeout, iVar );
29782983
}
2984+
CVARS_GET ( "server-can-flash-window", bVar ); m_pFlashWindow->SetSelected ( bVar );
29792985

29802986
// Browser
29812987
CVARS_GET ( "browser_remote_websites", bVar ); m_pCheckBoxRemoteBrowser->SetSelected ( bVar );
@@ -3256,6 +3262,7 @@ void CSettings::SaveData ( void )
32563262
CVARS_SET ( "chat_nickcompletion", m_pChatNickCompletion->GetSelected () );
32573263
CVARS_SET ( "chat_line_life", GetMilliseconds ( m_pChatLineLife ) );
32583264
CVARS_SET ( "chat_line_fade_out", GetMilliseconds ( m_pChatLineFadeout ) );
3265+
CVARS_SET ( "server-can-flash-window", m_pFlashWindow->GetSelected () );
32593266

32603267
// Set our new skin last, as it'll destroy all our GUI
32613268
pItem = m_pInterfaceSkinSelector->GetSelectedItem ();

MTA10/core/CSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ class CSettings
324324
CGUICheckBox* m_pChatCssText;
325325
CGUIEdit* m_pChatLineLife;
326326
CGUIEdit* m_pChatLineFadeout;
327+
CGUICheckBox* m_pFlashWindow;
327328

328329
CGUILabel* m_pLabelBrowserGeneral;
329330
CGUICheckBox* m_pCheckBoxRemoteBrowser;

MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,28 @@ bool CStaticFunctionDefinitions::ShowChat ( bool bShow )
328328
}
329329

330330

331+
bool CStaticFunctionDefinitions::SetWindowFlashing ( bool flash, uint count )
332+
{
333+
// Don't flash if the window is active
334+
if ( g_pCore->IsFocused () || !g_pCore->GetCVars ()->GetValue < bool > ( "server-can-flash-window", true ) )
335+
return false;
336+
337+
// 0 is infinite flashing
338+
if ( count == 0 )
339+
return false;
340+
341+
FLASHWINFO flashInfo;
342+
flashInfo.cbSize = sizeof(FLASHWINFO);
343+
flashInfo.hwnd = g_pCore->GetHookedWindow ();
344+
flashInfo.dwTimeout = 0;
345+
flashInfo.uCount = count;
346+
flashInfo.dwFlags = flash ? (FLASHW_ALL | FLASHW_TIMERNOFG) : FLASHW_STOP;
347+
::FlashWindowEx ( &flashInfo );
348+
349+
return true;
350+
}
351+
352+
331353
CClientEntity* CStaticFunctionDefinitions::GetRootElement ( void )
332354
{
333355
return m_pRootEntity;

MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CStaticFunctionDefinitions
5555
static bool ShowChat ( bool bShow );
5656
static bool SetClipboard ( SString& strText );
5757
static bool GetClipboard ( SString& strText );
58+
static bool SetWindowFlashing ( bool flash, uint count = 10 );
5859

5960
// Element get funcs
6061
static CClientEntity* GetRootElement ( void );

MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Output.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,23 @@ int CLuaFunctionDefs::OutputClientDebugString ( lua_State* luaVM )
197197
}
198198

199199

200+
int CLuaFunctionDefs::SetWindowFlashing ( lua_State* luaVM )
201+
{
202+
// bool setWindowFlashing ( bool flash [, int count = 10 ] )
203+
bool flash; uint count;
204+
205+
CScriptArgReader argStream ( luaVM );
206+
argStream.ReadBool ( flash );
207+
argStream.ReadNumber ( count, 10 );
208+
209+
if ( !argStream.HasErrors () )
210+
{
211+
lua_pushboolean ( luaVM, CStaticFunctionDefinitions::SetWindowFlashing ( flash, count ) );
212+
return 1;
213+
}
214+
else
215+
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
200216

217+
lua_pushboolean ( luaVM, false );
218+
return 1;
219+
}

MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class CLuaFunctionDefs
111111
LUA_DECLARE ( OutputClientDebugString );
112112
LUA_DECLARE ( SetClipboard );
113113
LUA_DECLARE ( GetClipboard );
114+
LUA_DECLARE ( SetWindowFlashing );
114115

115116
// Element get functions
116117
LUA_DECLARE ( GetRootElement );

MTA10/mods/shared_logic/lua/CLuaManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ void CLuaManager::LoadCFunctions ( void )
252252
CLuaCFunctions::AddFunction ( "outputDebugString", CLuaFunctionDefs::OutputClientDebugString );
253253
CLuaCFunctions::AddFunction ( "setClipboard", CLuaFunctionDefs::SetClipboard );
254254
//CLuaCFunctions::AddFunction ( "getClipboard", CLuaFunctionDefs::GetClipboard );
255+
CLuaCFunctions::AddFunction ( "setWindowFlashing", CLuaFunctionDefs::SetWindowFlashing );
255256

256257
// Element get funcs
257258
CLuaCFunctions::AddFunction ( "getRootElement", CLuaFunctionDefs::GetRootElement );

0 commit comments

Comments
 (0)