forked from multitheftauto/mtasa-blue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2,420 changed files
with
658,864 additions
and
658,864 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* (Shared logic for modifications) | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: ceflauncher/Main.cpp | ||
* PURPOSE: CEF launcher entry point | ||
* | ||
*****************************************************************************/ | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
#include <string> | ||
|
||
/* | ||
IMPORTANT | ||
If this project changes, a new release build should be copied into | ||
the Shared\data\launchers directory. | ||
The .exe in Shared\data\launchers will be used by the installer and updater. | ||
(set flag.new_cef_exe on the build server to generate new exe) | ||
*/ | ||
|
||
int _declspec(dllimport) InitCEF(); | ||
|
||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdShow, int nCmdShow) | ||
{ | ||
return InitCEF(); | ||
} | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* (Shared logic for modifications) | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: ceflauncher/Main.cpp | ||
* PURPOSE: CEF launcher entry point | ||
* | ||
*****************************************************************************/ | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
#include <string> | ||
|
||
/* | ||
IMPORTANT | ||
If this project changes, a new release build should be copied into | ||
the Shared\data\launchers directory. | ||
The .exe in Shared\data\launchers will be used by the installer and updater. | ||
(set flag.new_cef_exe on the build server to generate new exe) | ||
*/ | ||
|
||
int _declspec(dllimport) InitCEF(); | ||
|
||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdShow, int nCmdShow) | ||
{ | ||
return InitCEF(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,94 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* (Shared logic for modifications) | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: ceflauncher/CCefApp.h | ||
* PURPOSE: CefApp implementation | ||
* | ||
*****************************************************************************/ | ||
#include <cef3/include/cef_app.h> | ||
#include <string> | ||
#include <sstream> | ||
#include "V8Helpers.h" | ||
using V8Helpers::CV8Handler; | ||
|
||
class CCefApp : public CefApp, public CefRenderProcessHandler | ||
{ | ||
public: | ||
CCefApp() {} | ||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override { return this; }; | ||
|
||
// http://magpcss.org/ceforum/apidocs3/projects/(default)/CefRenderProcessHandler.html#OnFocusedNodeChanged(CefRefPtr%3CCefBrowser%3E,CefRefPtr%3CCefFrame%3E,CefRefPtr%3CCefDOMNode%3E) | ||
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) override | ||
{ | ||
if (m_bHasInputFocus) | ||
{ | ||
if (node) | ||
return; | ||
|
||
// Tell MTA that we lost input focus | ||
auto message = CefProcessMessage::Create("InputFocus"); | ||
message->GetArgumentList()->SetBool(0, false); | ||
browser->GetMainFrame()->SendProcessMessage(PID_BROWSER, message); | ||
|
||
// Set variable to ensure that the event does not trigger twice | ||
m_bHasInputFocus = false; | ||
return; | ||
} | ||
else | ||
{ | ||
if (!node) | ||
return; | ||
|
||
if (node->GetType() == CefDOMNode::Type::DOM_NODE_TYPE_ELEMENT && !node->GetFormControlElementType().empty()) | ||
{ | ||
auto message = CefProcessMessage::Create("InputFocus"); | ||
message->GetArgumentList()->SetBool(0, true); | ||
browser->GetMainFrame()->SendProcessMessage(PID_BROWSER, message); | ||
|
||
// Set variable to ensure that the event does not trigger twice | ||
m_bHasInputFocus = true; | ||
} | ||
} | ||
} | ||
|
||
virtual void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) override | ||
{ | ||
// Register custom MTA scheme (has to be called in all proceseses) | ||
registrar->AddCustomScheme("mtalocal", CEF_SCHEME_OPTION_CSP_BYPASSING); | ||
} | ||
|
||
// http://magpcss.org/ceforum/apidocs3/projects/(default)/CefRenderProcessHandler.html#OnContextCreated(CefRefPtr%3CCefBrowser%3E,CefRefPtr%3CCefFrame%3E,CefRefPtr%3CCefV8Context%3E) | ||
// // | ||
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) override | ||
{ | ||
// Get global object and create a v8 handler instance | ||
CefRefPtr<CefV8Value> globalObject = context->GetGlobal(); | ||
CefRefPtr<CV8Handler> handler = new CV8Handler(frame); | ||
|
||
// Create MTA object | ||
CefRefPtr<CefV8Value> mtaObject = CefV8Value::CreateObject(nullptr, nullptr); | ||
|
||
// Bind V8 --> C++ functions | ||
V8Helpers::BindV8Function(handler, mtaObject, "triggerEvent", Javascript_triggerEvent); | ||
|
||
// Assign mtaObject to global object | ||
globalObject->SetValue("mta", mtaObject, V8_PROPERTY_ATTRIBUTE_NONE); | ||
} | ||
|
||
static void Javascript_triggerEvent(CefRefPtr<CefFrame> frame, const CefV8ValueList& arguments) | ||
{ | ||
if (arguments.size() == 0) | ||
return; | ||
|
||
CefRefPtr<CefProcessMessage> message = V8Helpers::SerialiseV8Arguments("TriggerLuaEvent", arguments); | ||
frame->GetBrowser()->GetMainFrame()->SendProcessMessage(PID_BROWSER, message); | ||
} | ||
|
||
public: | ||
IMPLEMENT_REFCOUNTING(CCefApp); | ||
|
||
private: | ||
bool m_bHasInputFocus = false; | ||
}; | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* (Shared logic for modifications) | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: ceflauncher/CCefApp.h | ||
* PURPOSE: CefApp implementation | ||
* | ||
*****************************************************************************/ | ||
#include <cef3/include/cef_app.h> | ||
#include <string> | ||
#include <sstream> | ||
#include "V8Helpers.h" | ||
using V8Helpers::CV8Handler; | ||
|
||
class CCefApp : public CefApp, public CefRenderProcessHandler | ||
{ | ||
public: | ||
CCefApp() {} | ||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override { return this; }; | ||
|
||
// http://magpcss.org/ceforum/apidocs3/projects/(default)/CefRenderProcessHandler.html#OnFocusedNodeChanged(CefRefPtr%3CCefBrowser%3E,CefRefPtr%3CCefFrame%3E,CefRefPtr%3CCefDOMNode%3E) | ||
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) override | ||
{ | ||
if (m_bHasInputFocus) | ||
{ | ||
if (node) | ||
return; | ||
|
||
// Tell MTA that we lost input focus | ||
auto message = CefProcessMessage::Create("InputFocus"); | ||
message->GetArgumentList()->SetBool(0, false); | ||
browser->GetMainFrame()->SendProcessMessage(PID_BROWSER, message); | ||
|
||
// Set variable to ensure that the event does not trigger twice | ||
m_bHasInputFocus = false; | ||
return; | ||
} | ||
else | ||
{ | ||
if (!node) | ||
return; | ||
|
||
if (node->GetType() == CefDOMNode::Type::DOM_NODE_TYPE_ELEMENT && !node->GetFormControlElementType().empty()) | ||
{ | ||
auto message = CefProcessMessage::Create("InputFocus"); | ||
message->GetArgumentList()->SetBool(0, true); | ||
browser->GetMainFrame()->SendProcessMessage(PID_BROWSER, message); | ||
|
||
// Set variable to ensure that the event does not trigger twice | ||
m_bHasInputFocus = true; | ||
} | ||
} | ||
} | ||
|
||
virtual void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) override | ||
{ | ||
// Register custom MTA scheme (has to be called in all proceseses) | ||
registrar->AddCustomScheme("mtalocal", CEF_SCHEME_OPTION_CSP_BYPASSING); | ||
} | ||
|
||
// http://magpcss.org/ceforum/apidocs3/projects/(default)/CefRenderProcessHandler.html#OnContextCreated(CefRefPtr%3CCefBrowser%3E,CefRefPtr%3CCefFrame%3E,CefRefPtr%3CCefV8Context%3E) | ||
// // | ||
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) override | ||
{ | ||
// Get global object and create a v8 handler instance | ||
CefRefPtr<CefV8Value> globalObject = context->GetGlobal(); | ||
CefRefPtr<CV8Handler> handler = new CV8Handler(frame); | ||
|
||
// Create MTA object | ||
CefRefPtr<CefV8Value> mtaObject = CefV8Value::CreateObject(nullptr, nullptr); | ||
|
||
// Bind V8 --> C++ functions | ||
V8Helpers::BindV8Function(handler, mtaObject, "triggerEvent", Javascript_triggerEvent); | ||
|
||
// Assign mtaObject to global object | ||
globalObject->SetValue("mta", mtaObject, V8_PROPERTY_ATTRIBUTE_NONE); | ||
} | ||
|
||
static void Javascript_triggerEvent(CefRefPtr<CefFrame> frame, const CefV8ValueList& arguments) | ||
{ | ||
if (arguments.size() == 0) | ||
return; | ||
|
||
CefRefPtr<CefProcessMessage> message = V8Helpers::SerialiseV8Arguments("TriggerLuaEvent", arguments); | ||
frame->GetBrowser()->GetMainFrame()->SendProcessMessage(PID_BROWSER, message); | ||
} | ||
|
||
public: | ||
IMPLEMENT_REFCOUNTING(CCefApp); | ||
|
||
private: | ||
bool m_bHasInputFocus = false; | ||
}; |
Oops, something went wrong.