コード例 #1
0
void SRPWindows::SetDefaultCallBackFunctions()
{
	// bind the default javascript functions for use
	/*Awesomium::JSValue cJSDragWindow = GetAwesomiumWindow()->CreateGlobalJavascriptObject(Awesomium::WebString::CreateFromUTF8(String(DRAGWINDOW).GetUTF8(), String(DRAGWINDOW).GetLength()));
	GetAwesomiumWindow()->CreateGlobalJavascriptObject(Awesomium::WebString::CreateFromUTF8(String(HIDEWINDOW).GetUTF8(), String(HIDEWINDOW).GetLength()));
	GetAwesomiumWindow()->CreateGlobalJavascriptObject(Awesomium::WebString::CreateFromUTF8(String(CLOSEWINDOW).GetUTF8(), String(CLOSEWINDOW).GetLength()));

	Awesomium::JSObject cJSObject = cJSDragWindow.ToObject();

	cJSObject.SetCustomMethod(Awesomium::WebString::CreateFromUTF8(String(DRAGWINDOW).GetUTF8(), String(DRAGWINDOW).GetLength()), false);

	DebugToConsole("last error: '" + String(GetAwesomiumWindow()->last_error()) + "'\n");*/



	Awesomium::JSValue cJSTest = GetAwesomiumWindow()->CreateGlobalJavascriptObject(Awesomium::WebString::CreateFromUTF8("external", 5));

	if (cJSTest.IsObject())
	{
		Awesomium::JSObject cJSObject = cJSTest.ToObject();

		cJSObject.SetCustomMethod(Awesomium::WebString::CreateFromUTF8("hello", 5), false);

		if (cJSObject.HasMethod(Awesomium::WebString::CreateFromUTF8("hello", 5)))
		{
			DebugToConsole("last error: '" + String(GetAwesomiumWindow()->last_error()) + "'\n");
		}
	}
}
コード例 #2
0
ファイル: Menu.cpp プロジェクト: DrBrobot/ElDorito
void Menu::bindCallbacks()
{
	Awesomium::JSValue result = webView->CreateGlobalJavascriptObject(Awesomium::WSLit("callbacks"));

	if (result.IsObject())
	{
		Awesomium::JSObject& callbacksObject = result.ToObject();
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("HUDShake"), JSDelegate(&callbacks, &Callbacks::HUDShakeCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("playerMarkerColors"), JSDelegate(&callbacks, &Callbacks::playerMarkerColorsCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("fov"), JSDelegate(&callbacks, &Callbacks::fovCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("hostStartTimer"), JSDelegate(&callbacks, &Callbacks::hostStartTimerCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("playerName"), JSDelegate(&callbacks, &Callbacks::playerNameCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("showFPS"), JSDelegate(&callbacks, &Callbacks::showFPSCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("enableDXExtensions"), JSDelegate(&callbacks, &Callbacks::enableDXExtensionsCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("keyboardInput"), JSDelegate(&callbacks, &Callbacks::keyboardInputCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("toggleCrouch"), JSDelegate(&callbacks, &Callbacks::toggleCrouchCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("infantrySens"), JSDelegate(&callbacks, &Callbacks::infantrySensCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("vehicleSens"), JSDelegate(&callbacks, &Callbacks::vehicleSensCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("mouseAcceleration"), JSDelegate(&callbacks, &Callbacks::mouseAccelerationCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("mouseInverted"), JSDelegate(&callbacks, &Callbacks::mouseInvertedCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("centeredCrosshair"), JSDelegate(&callbacks, &Callbacks::centeredCrosshairCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("rawInput"), JSDelegate(&callbacks, &Callbacks::rawInputCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("resolution"), JSDelegate(&callbacks, &Callbacks::resolutionCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("textureResolution"), JSDelegate(&callbacks, &Callbacks::textureResolutionCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("textureFiltering"), JSDelegate(&callbacks, &Callbacks::textureFilteringCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("lightningQuality"), JSDelegate(&callbacks, &Callbacks::lightningQualityCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("effectsQuality"), JSDelegate(&callbacks, &Callbacks::effectsQualityCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("shadowQuality"), JSDelegate(&callbacks, &Callbacks::shadowQualityCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("detailsLevel"), JSDelegate(&callbacks, &Callbacks::detailsLevelCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("postProcessing"), JSDelegate(&callbacks, &Callbacks::postProcessingCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("motionBlur"), JSDelegate(&callbacks, &Callbacks::motionBlurCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("brightness"), JSDelegate(&callbacks, &Callbacks::brightnessCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("fullScreen"), JSDelegate(&callbacks, &Callbacks::fullScreenCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("VSync"), JSDelegate(&callbacks, &Callbacks::VSyncCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("antiAliasing"), JSDelegate(&callbacks, &Callbacks::antiAliasingCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("masterVolume"), JSDelegate(&callbacks, &Callbacks::masterVolumeCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("sfxVolume"), JSDelegate(&callbacks, &Callbacks::sfxVolumeCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("musicVolume"), JSDelegate(&callbacks, &Callbacks::musicVolumeCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("lanEnabled"), JSDelegate(&callbacks, &Callbacks::lanEnabledCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("gameType"), JSDelegate(&callbacks, &Callbacks::gameTypeCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("map"), JSDelegate(&callbacks, &Callbacks::mapCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("forgeMap"), JSDelegate(&callbacks, &Callbacks::forgeMapCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("scoreToWin"), JSDelegate(&callbacks, &Callbacks::scoreToWinCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("startGame"), JSDelegate(&callbacks, &Callbacks::startGameCallback));
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("server"), JSDelegate(&callbacks, &Callbacks::serverCallback));

		// TODO: TEMP: remove
		methodDispatcher.Bind(callbacksObject, Awesomium::WSLit("connect"), JSDelegate(&callbacks, &Callbacks::connectCallback));
	}

	webView->set_js_method_handler(&methodDispatcher);
}
コード例 #3
0
void WebListener::executeFunction(const he::String& object,
                                    const he::String& method,
                                    const Awesomium::JSArray& args)
{
    // global js object for global functions
    he::String objName("window");
    Awesomium::WebString aweMethod = Awesomium::WSLit(method.c_str());

    if (object != "window" && object != "")
    {
        objName = object;

        // check if jsobject already exists
        auto it(std::find_if(m_Objects.cbegin(), m_Objects.cend(), [&objName](JSObject* obj)
        {
            return obj->getObjectName() == objName;
        }));
        
        bool objectExists(it != m_Objects.cend());

        // create new js object if it doesn't already exists
        if (objectExists == false)
        {
            Awesomium::JSValue val = m_WebView->CreateGlobalJavascriptObject(
                Awesomium::WSLit(objName.c_str()));

            Awesomium::JSObject& obj = val.ToObject();

            JSObject* jsObject(HENew(JSObject)(obj, objName));

            m_Objects.add(jsObject);

            jsObject->executeFunction(aweMethod, args);
        }
        else
        {
            (*it)->executeFunction(aweMethod, args);
        };
    }
    else
    {
        Awesomium::JSValue window(
            m_WebView->ExecuteJavascriptWithResult(
            Awesomium::WSLit("window"), Awesomium::WSLit("")));

        Awesomium::JSObject& obj = window.ToObject();

        obj.Invoke(aweMethod, args);
    }
}
コード例 #4
0
ファイル: ClientObject.cpp プロジェクト: dbabox/aomi
void ClientObject::setProperty(const std::string& name, const Awesomium::JSValue& value)
{
	std::map<std::string, CppVariant*>::iterator i = clientProperties.find(name);

	if(i == clientProperties.end())
	{
		CppVariant* newValue = new CppVariant();

		if(value.isString())
			newValue->Set(value.toString());
		else if(value.isInteger())
			newValue->Set(value.toInteger());
		else if(value.isDouble())
			newValue->Set(value.toDouble());
		else if(value.isBoolean())
			newValue->Set(value.toBoolean());
		else
			newValue->SetNull();
		
		clientProperties[name] = newValue;

		BindProperty(name, newValue);
	}
	else
	{
		if(value.isString())
			i->second->Set(value.toString());
		else if(value.isInteger())
			i->second->Set(value.toInteger());
		else if(value.isDouble())
			i->second->Set(value.toDouble());
		else if(value.isBoolean())
			i->second->Set(value.toBoolean());
		else
			i->second->SetNull();
	}
}