Skip to content

Commit 8cafb58

Browse files
committed
Add Lua function 'isBrowserSupported'
1 parent 206ef63 commit 8cafb58

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

MTA10/mods/shared_logic/luadefs/CLuaBrowserDefs.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
void CLuaBrowserDefs::LoadFunctions ( void )
1515
{
1616
// Define browser functions
17+
CLuaCFunctions::AddFunction( "isBrowserSupported", IsBrowserSupported );
18+
1719
std::map<const char*, lua_CFunction> functions
1820
{
1921
{ "createBrowser", CreateBrowser },
@@ -49,7 +51,7 @@ void CLuaBrowserDefs::LoadFunctions ( void )
4951
};
5052

5153
// Add browser functions
52-
if ( IsBrowserSupported () )
54+
if ( g_pCore->GetWebCore () )
5355
{
5456
for ( const auto& pair : functions )
5557
{
@@ -87,6 +89,7 @@ void CLuaBrowserDefs::AddClass ( lua_State* luaVM )
8789
lua_newclass ( luaVM );
8890

8991
lua_classfunction ( luaVM, "create", "createBrowser" );
92+
lua_classfunction ( luaVM, "isSupported", "isBrowserSupported" );
9093
lua_classfunction ( luaVM, "loadURL", "loadBrowserURL" );
9194
lua_classfunction ( luaVM, "isLoading", "isBrowserLoading" );
9295
lua_classfunction ( luaVM, "injectMouseMove", "injectBrowserMouseMove" );
@@ -133,12 +136,6 @@ void CLuaBrowserDefs::AddClass ( lua_State* luaVM )
133136
}
134137

135138

136-
bool CLuaBrowserDefs::IsBrowserSupported ()
137-
{
138-
return g_pCore->GetWebCore() != nullptr;
139-
}
140-
141-
142139
int CLuaBrowserDefs::CreateBrowser ( lua_State* luaVM )
143140
{
144141
// texture createBrowser ( int width, int height, bool isLocal [, bool transparent = false] )
@@ -182,6 +179,12 @@ int CLuaBrowserDefs::CreateBrowser ( lua_State* luaVM )
182179
return 1;
183180
}
184181

182+
int CLuaBrowserDefs::IsBrowserSupported ( lua_State* luaVM )
183+
{
184+
lua_pushboolean ( luaVM, g_pCore->GetWebCore() != nullptr );
185+
return 1;
186+
}
187+
185188
int CLuaBrowserDefs::RequestBrowserDomains ( lua_State* luaVM )
186189
{
187190
// bool requestBrowserDomains ( table domains, bool isURL [, function callback ] )

MTA10/mods/shared_logic/luadefs/CLuaBrowserDefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class CLuaBrowserDefs : public CLuaDefs
2121
static bool IsBrowserSupported ();
2222

2323
LUA_DECLARE ( CreateBrowser );
24+
LUA_DECLARE ( IsBrowserSupported );
2425
LUA_DECLARE ( RequestBrowserDomains );
2526
LUA_DECLARE ( LoadBrowserURL );
2627
LUA_DECLARE ( IsBrowserLoading );

0 commit comments

Comments
 (0)