mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
Full Template for ticket #1
This commit is contained in:
parent
74f265b3b3
commit
f439dc8dcd
2150 changed files with 286240 additions and 0 deletions
BIN
Templates/Full/web/source/activex/IEWebGameCtrl.bmp
Normal file
BIN
Templates/Full/web/source/activex/IEWebGameCtrl.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 246 B |
482
Templates/Full/web/source/activex/IEWebGameCtrl.cpp
Normal file
482
Templates/Full/web/source/activex/IEWebGameCtrl.cpp
Normal file
|
|
@ -0,0 +1,482 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "IEWebGameCtrl.h"
|
||||
|
||||
#include "../common/webCommon.h"
|
||||
|
||||
// CIEWebGameCtrl (one and only one instance please)
|
||||
CIEWebGameCtrl* CIEWebGameCtrl::sInstance = NULL;
|
||||
|
||||
// Javascript accessible methods
|
||||
|
||||
// plugin.getVariable("$MyVariable"); - get a Torque 3D console variable
|
||||
STDMETHODIMP CIEWebGameCtrl::getVariable(BSTR name, BSTR* value)
|
||||
{
|
||||
std::wstring wstr;
|
||||
std::string sstr;
|
||||
const char* astr;
|
||||
|
||||
wstr.assign(name);
|
||||
sstr = WebCommon::WStringToString(wstr);
|
||||
astr = sstr.c_str();
|
||||
|
||||
const char* avalue = NULL;
|
||||
char vinfo[256];
|
||||
vinfo[0] = 0;
|
||||
|
||||
// requesting the version information
|
||||
if (!_stricmp(astr, "$version"))
|
||||
{
|
||||
char plugin[4096];
|
||||
|
||||
GetModuleFileNameA(WebCommon::gPluginModule, plugin, 4096);
|
||||
DWORD dwHandle = 0;
|
||||
DWORD dwSize = GetFileVersionInfoSizeA(plugin, &dwHandle);
|
||||
if (dwSize >= 0)
|
||||
{
|
||||
LPBYTE lpInfo = new BYTE[dwSize];
|
||||
ZeroMemory(lpInfo, dwSize);
|
||||
if(GetFileVersionInfoA(plugin, 0, dwSize, lpInfo))
|
||||
{
|
||||
UINT valLen = MAX_PATH;
|
||||
LPVOID valPtr = NULL;
|
||||
if(::VerQueryValue(lpInfo,
|
||||
TEXT("\\"),
|
||||
&valPtr,
|
||||
&valLen))
|
||||
{
|
||||
VS_FIXEDFILEINFO* pFinfo = (VS_FIXEDFILEINFO*)valPtr;
|
||||
|
||||
sprintf(vinfo, "%i.%i", (pFinfo->dwProductVersionMS >> 16) & 0xFF, (pFinfo->dwFileVersionMS) & 0xFF);
|
||||
|
||||
}
|
||||
}
|
||||
delete[] lpInfo;
|
||||
}
|
||||
|
||||
if (!vinfo[0])
|
||||
strcpy(vinfo, "-1");
|
||||
|
||||
|
||||
avalue = vinfo;
|
||||
|
||||
}
|
||||
else
|
||||
avalue = WebCommon::GetVariable(astr);
|
||||
|
||||
sstr = avalue;
|
||||
wstr = WebCommon::StringToWString(sstr);
|
||||
|
||||
*value = SysAllocString(wstr.c_str());
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
// plugin.setVariable("$MyVariable", 42); - set a Torque 3D console variable
|
||||
STDMETHODIMP CIEWebGameCtrl::setVariable(BSTR name, BSTR value)
|
||||
{
|
||||
std::wstring wstr;
|
||||
std::string nstr, vstr;
|
||||
const char* vname;
|
||||
const char* vvalue;
|
||||
|
||||
wstr.assign(name);
|
||||
nstr = WebCommon::WStringToString(wstr);
|
||||
vname = nstr.c_str();
|
||||
|
||||
wstr.assign(value);
|
||||
vstr = WebCommon::WStringToString(wstr);
|
||||
vvalue = vstr.c_str();
|
||||
|
||||
WebCommon::SetVariable(vname, vvalue);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
// plugin.startup(); - called once web page is fully loaded and plugin (including Torque 3D) is initialized
|
||||
STDMETHODIMP CIEWebGameCtrl::startup()
|
||||
{
|
||||
|
||||
mInitialized = true;
|
||||
std::vector<JavasScriptExport>::iterator i;
|
||||
for (i = mJavaScriptExports.begin(); i != mJavaScriptExports.end();i++)
|
||||
{
|
||||
internalExportFunction(*i);
|
||||
}
|
||||
|
||||
WebCommon::AddSecureFunctions();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// var result = plugin.callScript("mySecureFunction('one', 'two', 'three');"); - call a TorqueScript function marked as secure in webConfig.h with supplied arguments
|
||||
// includes function parser
|
||||
STDMETHODIMP CIEWebGameCtrl::callScript(BSTR code, BSTR* value)
|
||||
{
|
||||
std::wstring wcode;
|
||||
std::string scode;
|
||||
wcode.assign(code);
|
||||
scode = WebCommon::WStringToString(wcode);
|
||||
const char* sig = scode.c_str();
|
||||
|
||||
// do not allow large strings which could be used maliciously
|
||||
if (scode.length() > 255 || !mInitialized)
|
||||
{
|
||||
*value = SysAllocString(L"");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
// data buffers for laying out data in a Torque 3D console friendly manner
|
||||
char nameSpace[256];
|
||||
char fname[256];
|
||||
char argv[256][256];
|
||||
char* argvv[256];
|
||||
int argc = 0;
|
||||
unsigned int argBegin = 0;
|
||||
|
||||
memset(nameSpace, 0, 256);
|
||||
memset(fname, 0, 256);
|
||||
memset(argv, 0, 256 * 256);
|
||||
|
||||
for (unsigned int i = 0; i < scode.length(); i++)
|
||||
{
|
||||
if (sig[i] == ')' || sig[i] == ';')
|
||||
{
|
||||
//scan out last arg is any
|
||||
char dummy[256];
|
||||
memset(dummy, 0, 256);
|
||||
|
||||
WebCommon::StringCopy(dummy, &sig[argBegin], i - argBegin);
|
||||
|
||||
if (strlen(dummy))
|
||||
{
|
||||
strcpy_s(argv[argc], dummy);
|
||||
argvv[argc] = argv[argc];
|
||||
argc++;
|
||||
}
|
||||
|
||||
break; // done
|
||||
}
|
||||
|
||||
// namespace
|
||||
if (sig[i]==':')
|
||||
{
|
||||
if (nameSpace[0] || fname[0])
|
||||
{
|
||||
*value = SysAllocString(L"");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (i > 0 && sig[i-1] == ':')
|
||||
{
|
||||
if (i - 2 > 0)
|
||||
WebCommon::StringCopy(nameSpace, sig, i - 1);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// args begin
|
||||
if (sig[i] == '(' )
|
||||
{
|
||||
if (fname[0] || i < 1)
|
||||
{
|
||||
*value = SysAllocString(L"");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
//everything before this is function name, minus nameSpace
|
||||
if (nameSpace[0])
|
||||
{
|
||||
int nlen = strlen(nameSpace);
|
||||
WebCommon::StringCopy(fname, &sig[nlen + 2], i - nlen - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
WebCommon::StringCopy(fname, sig, i);
|
||||
}
|
||||
|
||||
WebCommon::StringCopy(argv[0], fname, strlen(fname)+1);
|
||||
argvv[0] = argv[0];
|
||||
argc++;
|
||||
|
||||
argBegin = i + 1;
|
||||
}
|
||||
|
||||
// args
|
||||
if (sig[i] == ',' )
|
||||
{
|
||||
if (argBegin >= i || argc == 255)
|
||||
{
|
||||
*value = SysAllocString(L"");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
WebCommon::StringCopy(argv[argc], &sig[argBegin], i - argBegin);
|
||||
argvv[argc] = argv[argc];
|
||||
|
||||
argc++;
|
||||
argBegin = i + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const char* retVal;
|
||||
std::string sretVal;
|
||||
std::wstring wretVal;
|
||||
|
||||
if (fname[0])
|
||||
{
|
||||
// call into the Torque 3D shared library (console system) and get return value
|
||||
retVal = torque_callsecurefunction(nameSpace, fname, argc, (const char **) argvv);
|
||||
|
||||
sretVal= retVal;
|
||||
wretVal = WebCommon::StringToWString(sretVal);
|
||||
|
||||
*value = SysAllocString(wretVal.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = SysAllocString(L"");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// the sole entry point for Torque 3D console system into our browser plugin (handed over as a function pointer)
|
||||
static const char * MyStringCallback(void *obj, int argc, const char* argv[])
|
||||
{
|
||||
static char ret[4096];
|
||||
strcpy_s(ret,CIEWebGameCtrl::sInstance->callFunction(argv[0], argc, argv));
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Get the location we're loading the plugin from (http://, file://) including address
|
||||
// this is used by the domain locking feature to ensure that your plugin is only
|
||||
// being used from your web site
|
||||
bool CIEWebGameCtrl::checkDomain()
|
||||
{
|
||||
HRESULT hrResult = S_FALSE;
|
||||
IMoniker* pMoniker = NULL;
|
||||
LPOLESTR sDisplayName;
|
||||
|
||||
hrResult = m_spClientSite->GetMoniker(OLEGETMONIKER_TEMPFORUSER,
|
||||
OLEWHICHMK_CONTAINER,
|
||||
&pMoniker);
|
||||
|
||||
if(SUCCEEDED(hrResult))
|
||||
{
|
||||
hrResult = pMoniker->GetDisplayName(NULL,
|
||||
NULL,
|
||||
&sDisplayName);
|
||||
pMoniker->Release();
|
||||
|
||||
std::wstring wstr;
|
||||
std::string sstr;
|
||||
|
||||
wstr.assign(sDisplayName);
|
||||
sstr = WebCommon::WStringToString(wstr);
|
||||
|
||||
return WebCommon::CheckDomain(sstr.c_str());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// handles TorqueScript -> Javascript calling including return value
|
||||
const char* CIEWebGameCtrl::callFunction(const char* name, LONG numArguments, const char* argv[])
|
||||
{
|
||||
|
||||
//sanity
|
||||
if (numArguments > 200)
|
||||
return "";
|
||||
|
||||
// A bunch of COM'esque stuff to which ultimately boils down to finding a Javascript function on the page
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
LPOLECONTAINER pContainer;
|
||||
IHTMLDocument* pHTML = NULL;
|
||||
CComPtr<IDispatch> pScript;
|
||||
CComQIPtr<IHTMLWindow2> pWin;
|
||||
|
||||
|
||||
if (!m_spClientSite)
|
||||
return "";
|
||||
|
||||
hr = m_spClientSite->GetContainer(&pContainer);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
hr = pContainer->QueryInterface(IID_IHTMLDocument, (void
|
||||
**)&pHTML);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
pContainer->Release();
|
||||
return "";
|
||||
}
|
||||
|
||||
hr = pHTML->get_Script(&pScript);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
pContainer->Release();
|
||||
pHTML->Release();
|
||||
return "";
|
||||
}
|
||||
|
||||
DISPID idMethod = 0;
|
||||
std::string smethod = name;
|
||||
std::wstring wmethod = WebCommon::StringToWString(smethod);
|
||||
OLECHAR FAR* sMethod = (OLECHAR FAR*)wmethod.c_str();
|
||||
hr = pScript->GetIDsOfNames(IID_NULL, &sMethod, 1, LOCALE_SYSTEM_DEFAULT,&idMethod);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
pContainer->Release();
|
||||
pHTML->Release();
|
||||
return "";
|
||||
}
|
||||
|
||||
// setup arguments and return value variants
|
||||
|
||||
VARIANT pVarRet = {0};
|
||||
|
||||
VariantInit(&pVarRet);
|
||||
|
||||
if (numArguments <= 1)
|
||||
{
|
||||
DISPPARAMS dpNoArgs = {NULL, NULL, 0, 0};
|
||||
hr = pScript->Invoke(idMethod, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD,
|
||||
&dpNoArgs, &pVarRet, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
DISPPARAMS params;
|
||||
VARIANTARG args[256];
|
||||
std::wstring wargs[256];
|
||||
|
||||
for (LONG i = 0; i < numArguments - 1; i++ )
|
||||
{
|
||||
VariantInit(&args[i]);
|
||||
// Invoke wants these in reverse order
|
||||
std::string s = argv[numArguments - i - 1];
|
||||
wargs[i] = WebCommon::StringToWString(s);
|
||||
args[i].vt = VT_BSTR;
|
||||
args[i].bstrVal = SysAllocString(wargs[i].c_str());
|
||||
}
|
||||
|
||||
params.cArgs = numArguments - 1;
|
||||
params.rgdispidNamedArgs = NULL;
|
||||
params.cNamedArgs = 0;
|
||||
params.rgvarg = args;
|
||||
|
||||
// whew, actually call the Javascript
|
||||
hr = pScript->Invoke(idMethod, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD,
|
||||
¶ms, &pVarRet, NULL, NULL);
|
||||
|
||||
for (LONG i = 0; i < numArguments - 1; i++ )
|
||||
{
|
||||
SysFreeString(args[i].bstrVal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
pContainer->Release();
|
||||
pHTML->Release();
|
||||
return "";
|
||||
}
|
||||
|
||||
VariantChangeType(&pVarRet, &pVarRet, 0, VT_BSTR);
|
||||
|
||||
std::wstring wstr;
|
||||
std::string sstr;
|
||||
static char ret[4096];
|
||||
|
||||
wstr.assign(pVarRet.bstrVal);
|
||||
sstr = WebCommon::WStringToString(wstr);
|
||||
strcpy_s(ret, sstr.c_str());
|
||||
|
||||
pContainer->Release();
|
||||
pHTML->Release();
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
// handle the actual export (once we're actually all ready to go)
|
||||
void CIEWebGameCtrl::internalExportFunction(const JavasScriptExport& jsexport)
|
||||
{
|
||||
torque_exportstringcallback(MyStringCallback,"JS",jsexport.jsCallback.c_str(),"",jsexport.numArguments,jsexport.numArguments);
|
||||
}
|
||||
|
||||
// plugin.exportFunction("MyJavascriptFunction",3); - export a Javascript function to the Torque 3D console system via its name and argument count
|
||||
// If we haven't initialized Torque 3D yet, cache it
|
||||
STDMETHODIMP CIEWebGameCtrl::exportFunction(BSTR callback, LONG numArguments)
|
||||
{
|
||||
JavasScriptExport jsexport;
|
||||
std::wstring wstr;
|
||||
|
||||
wstr.assign(callback);
|
||||
jsexport.jsCallback = WebCommon::WStringToString(wstr);
|
||||
jsexport.numArguments = numArguments;
|
||||
|
||||
if (!mInitialized)
|
||||
{
|
||||
//queue it up
|
||||
mJavaScriptExports.push_back(jsexport);
|
||||
}
|
||||
else
|
||||
{
|
||||
internalExportFunction(jsexport);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
// Our web deployment is installer based, no code signing necessary
|
||||
STDMETHODIMP CIEWebGameCtrl::GetInterfaceSafetyOptions(REFIID riid,
|
||||
DWORD *pdwSupportedOptions,DWORD *pdwEnabledOptions)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CIEWebGameCtrl::SetInterfaceSafetyOptions(REFIID riid,
|
||||
DWORD dwOptionSetMask,DWORD dwEnabledOptions)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
177
Templates/Full/web/source/activex/IEWebGameCtrl.h
Normal file
177
Templates/Full/web/source/activex/IEWebGameCtrl.h
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Torque 3D web deployment for Internet Explorer (ActiveX)
|
||||
|
||||
#pragma once
|
||||
#include "resource.h" // main symbols
|
||||
#include <atlctl.h>
|
||||
#include "IEWebGamePlugin_i.h"
|
||||
#include "IEWebGameWindow.h"
|
||||
|
||||
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
|
||||
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
|
||||
#endif
|
||||
|
||||
// The heavy lifting is done by our game control (which inherits from WebGameWindow)
|
||||
|
||||
// CIEWebGameCtrl
|
||||
class ATL_NO_VTABLE CIEWebGameCtrl :
|
||||
public CComObjectRootEx<CComSingleThreadModel>,
|
||||
public CStockPropImpl<CIEWebGameCtrl, IIEWebGameCtrl>,
|
||||
public IPersistStreamInitImpl<CIEWebGameCtrl>,
|
||||
public IOleControlImpl<CIEWebGameCtrl>,
|
||||
public IOleObjectImpl<CIEWebGameCtrl>,
|
||||
public IOleInPlaceActiveObjectImpl<CIEWebGameCtrl>,
|
||||
public IViewObjectExImpl<CIEWebGameCtrl>,
|
||||
public IOleInPlaceObjectWindowlessImpl<CIEWebGameCtrl>,
|
||||
public IObjectSafetyImpl<CIEWebGameCtrl, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
|
||||
public CComCoClass<CIEWebGameCtrl, &CLSID_IEWebGameCtrl>,
|
||||
public CComControl<CIEWebGameCtrl, WebGameWindow>
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
|
||||
DECLARE_OLEMISC_STATUS(OLEMISC_RECOMPOSEONRESIZE |
|
||||
OLEMISC_CANTLINKINSIDE |
|
||||
OLEMISC_INSIDEOUT |
|
||||
OLEMISC_ACTIVATEWHENVISIBLE |
|
||||
OLEMISC_SETCLIENTSITEFIRST
|
||||
)
|
||||
|
||||
DECLARE_REGISTRY_RESOURCEID(IDR_IEWEBGAMECTRL)
|
||||
|
||||
|
||||
BEGIN_COM_MAP(CIEWebGameCtrl)
|
||||
COM_INTERFACE_ENTRY(IIEWebGameCtrl)
|
||||
COM_INTERFACE_ENTRY(IDispatch)
|
||||
COM_INTERFACE_ENTRY(IViewObjectEx)
|
||||
COM_INTERFACE_ENTRY(IViewObject2)
|
||||
COM_INTERFACE_ENTRY(IViewObject)
|
||||
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
|
||||
COM_INTERFACE_ENTRY(IOleInPlaceObject)
|
||||
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
|
||||
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
|
||||
COM_INTERFACE_ENTRY(IOleControl)
|
||||
COM_INTERFACE_ENTRY(IOleObject)
|
||||
COM_INTERFACE_ENTRY(IPersistStreamInit)
|
||||
COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IObjectSafety, IObjectSafety)
|
||||
|
||||
END_COM_MAP()
|
||||
|
||||
BEGIN_PROP_MAP(CIEWebGameCtrl)
|
||||
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
|
||||
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
|
||||
// Example entries
|
||||
// PROP_ENTRY_TYPE("Property Name", dispid, clsid, vtType)
|
||||
// PROP_PAGE(CLSID_StockColorPage)
|
||||
END_PROP_MAP()
|
||||
|
||||
|
||||
BEGIN_MSG_MAP(WebGameWindow)
|
||||
CHAIN_MSG_MAP(WebGameWindow)
|
||||
DEFAULT_REFLECTION_HANDLER()
|
||||
END_MSG_MAP()
|
||||
|
||||
// Handler prototypes:
|
||||
// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
|
||||
// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
|
||||
|
||||
// IViewObjectEx
|
||||
DECLARE_VIEW_STATUS(0)
|
||||
|
||||
// IIEWebGameCtrl
|
||||
public:
|
||||
|
||||
static CIEWebGameCtrl* sInstance;
|
||||
|
||||
CIEWebGameCtrl()
|
||||
{
|
||||
m_bWindowOnly = TRUE;
|
||||
sInstance = this;
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
||||
|
||||
HRESULT FinalConstruct()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void FinalRelease()
|
||||
{
|
||||
}
|
||||
|
||||
// the javascript accessible methods which can be called our on plugin object
|
||||
|
||||
// plugin.getVariable("$MyVariable"); - get a Torque 3D console variable
|
||||
STDMETHOD(getVariable)(BSTR name, BSTR* value);
|
||||
|
||||
// plugin.setVariable("$MyVariable", 42); - set a Torque 3D console variable
|
||||
STDMETHOD(setVariable)(BSTR name, BSTR value);
|
||||
|
||||
// var result = plugin.callScript("mySecureFunction('one', 'two', 'three');"); - call a TorqueScript function marked as secure in webConfig.h with supplied arguments
|
||||
STDMETHOD(callScript)(BSTR code, BSTR* retValue);
|
||||
|
||||
// plugin.exportFunction("MyJavascriptFunction",3); - export a Javascript function to the Torque 3D console system via its name and argument count
|
||||
STDMETHOD(exportFunction)(BSTR name, LONG numArguments);
|
||||
|
||||
// plugin.startup(); - called once web page is fully loaded and plugin (including Torque 3D) is initialized
|
||||
STDMETHOD(startup)();
|
||||
|
||||
// TorqueScript -> Javascript call handling
|
||||
const char* callFunction(const char* name, LONG numArguments, const char* argv[]);
|
||||
|
||||
// our plugin requires no signing as it is installer based
|
||||
STDMETHOD(GetInterfaceSafetyOptions)(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions);
|
||||
STDMETHOD(SetInterfaceSafetyOptions)(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// these can be added on the page before we're initialized, so we cache them at startup
|
||||
typedef struct JavasScriptExport
|
||||
{
|
||||
std::string jsCallback; //javascript function name
|
||||
UINT numArguments; //the number of arguments it takes
|
||||
};
|
||||
|
||||
std::vector<JavasScriptExport> mJavaScriptExports;
|
||||
|
||||
// actually handle the export (once Torque 3D is fully initialized)
|
||||
void internalExportFunction(const JavasScriptExport& jsexport);
|
||||
|
||||
|
||||
BOOL mInitialized;
|
||||
|
||||
// checks a given domain against the allowed domains in webConfig.h
|
||||
bool checkDomain();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
OBJECT_ENTRY_AUTO(__uuidof(IEWebGameCtrl), CIEWebGameCtrl)
|
||||
34
Templates/Full/web/source/activex/IEWebGameCtrl.rgs
Normal file
34
Templates/Full/web/source/activex/IEWebGameCtrl.rgs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
HKCR
|
||||
{
|
||||
IEFullPlugin.IEWebGameCtrl.1 = s 'IEWebGameCtrl Class'
|
||||
{
|
||||
CLSID = s '{D62D1B36-253D-4218-B033-5ACE0B42B8BF}'
|
||||
}
|
||||
IEFullPlugin.IEWebGameCtrl = s 'IEWebGameCtrl Class'
|
||||
{
|
||||
CLSID = s '{D62D1B36-253D-4218-B033-5ACE0B42B8BF}'
|
||||
CurVer = s 'IEFullPlugin.IEWebGameCtrl.1'
|
||||
}
|
||||
NoRemove CLSID
|
||||
{
|
||||
ForceRemove {D62D1B36-253D-4218-B033-5ACE0B42B8BF} = s 'IEWebGameCtrl Class'
|
||||
{
|
||||
ProgID = s 'IEFullPlugin.IEWebGameCtrl.1'
|
||||
VersionIndependentProgID = s 'IEFullPlugin.IEWebGameCtrl'
|
||||
ForceRemove 'Programmable'
|
||||
InprocServer32 = s '%MODULE%'
|
||||
{
|
||||
val ThreadingModel = s 'Apartment'
|
||||
}
|
||||
val AppID = s '%APPID%'
|
||||
ForceRemove 'Control'
|
||||
ForceRemove 'ToolboxBitmap32' = s '%MODULE%, 102'
|
||||
'MiscStatus' = s '0'
|
||||
{
|
||||
'1' = s '%OLEMISC%'
|
||||
}
|
||||
'TypeLib' = s '{5240D24D-FBCE-4AF2-99FC-4C7AD4318E91}'
|
||||
'Version' = s '1.0'
|
||||
}
|
||||
}
|
||||
}
|
||||
91
Templates/Full/web/source/activex/IEWebGamePlugin.cpp
Normal file
91
Templates/Full/web/source/activex/IEWebGamePlugin.cpp
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "resource.h"
|
||||
#include "IEWebGamePlugin_i.h"
|
||||
#include "dllmain.h"
|
||||
|
||||
// Used to determine whether the DLL can be unloaded by OLE
|
||||
STDAPI DllCanUnloadNow(void)
|
||||
{
|
||||
return _AtlModule.DllCanUnloadNow();
|
||||
}
|
||||
|
||||
|
||||
// Returns a class factory to create an object of the requested type
|
||||
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
|
||||
{
|
||||
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
|
||||
}
|
||||
|
||||
|
||||
// DllRegisterServer - Adds entries to the system registry
|
||||
STDAPI DllRegisterServer(void)
|
||||
{
|
||||
// registers object, typelib and all interfaces in typelib
|
||||
HRESULT hr = _AtlModule.DllRegisterServer();
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
// DllUnregisterServer - Removes entries from the system registry
|
||||
STDAPI DllUnregisterServer(void)
|
||||
{
|
||||
HRESULT hr = _AtlModule.DllUnregisterServer();
|
||||
return hr;
|
||||
}
|
||||
|
||||
// DllInstall - Adds/Removes entries to the system registry per user
|
||||
// per machine.
|
||||
STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
|
||||
{
|
||||
HRESULT hr = E_FAIL;
|
||||
static const wchar_t szUserSwitch[] = _T("user");
|
||||
|
||||
if (pszCmdLine != NULL)
|
||||
{
|
||||
if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
|
||||
{
|
||||
#if (_MSC_VER >= 1500) //vs2008 or higher
|
||||
AtlSetPerUserRegistration(true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (bInstall)
|
||||
{
|
||||
hr = DllRegisterServer();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
DllUnregisterServer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = DllUnregisterServer();
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
8
Templates/Full/web/source/activex/IEWebGamePlugin.def
Normal file
8
Templates/Full/web/source/activex/IEWebGamePlugin.def
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
; IEWebGamePlugin.def : Declares the module parameters.
|
||||
|
||||
EXPORTS
|
||||
DllCanUnloadNow PRIVATE
|
||||
DllGetClassObject PRIVATE
|
||||
DllRegisterServer PRIVATE
|
||||
DllUnregisterServer PRIVATE
|
||||
DllInstall PRIVATE
|
||||
46
Templates/Full/web/source/activex/IEWebGamePlugin.idl
Normal file
46
Templates/Full/web/source/activex/IEWebGamePlugin.idl
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// IEWebGamePlugin.idl : IDL source for IEWebGamePlugin
|
||||
//
|
||||
|
||||
// This file will be processed by the MIDL tool to
|
||||
// produce the type library (IEWebGamePlugin.tlb) and marshalling code.
|
||||
|
||||
#include "olectl.h"
|
||||
import "oaidl.idl";
|
||||
import "ocidl.idl";
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(5240D24D-FBCE-4AF2-99FC-4C7AD4318E91),
|
||||
dual,
|
||||
nonextensible,
|
||||
helpstring("IIEWebGameCtrl Interface"),
|
||||
pointer_default(unique)
|
||||
]
|
||||
interface IIEWebGameCtrl : IDispatch{
|
||||
[propget, bindable, requestedit, id(DISPID_HWND)]
|
||||
HRESULT HWND([out, retval]LONG_PTR* pHWND);
|
||||
[id(1), helpstring("method getVariable")] HRESULT getVariable([in] BSTR name, [out, retval] BSTR* value);
|
||||
[id(2), helpstring("method setVariable")] HRESULT setVariable([in] BSTR name, [in] BSTR value);
|
||||
[id(3), helpstring("method export")] HRESULT exportFunction([in] BSTR callback, [in] LONG numArguments);
|
||||
[id(4), helpstring("method callScript")] HRESULT callScript([in] BSTR code, [out, retval] BSTR* retValue);
|
||||
[id(5), helpstring("method startup")] HRESULT startup();
|
||||
};
|
||||
|
||||
[
|
||||
uuid(FC143328-E29C-4BC4-8C83-618FEB562532),
|
||||
version(1.0),
|
||||
helpstring("IEFullPlugin 1.0 Type Library")
|
||||
]
|
||||
library IEFullPluginLib
|
||||
{
|
||||
importlib("stdole2.tlb");
|
||||
[
|
||||
uuid(D62D1B36-253D-4218-B033-5ACE0B42B8BF),
|
||||
control,
|
||||
helpstring("IEWebGameCtrl Class")
|
||||
]
|
||||
coclass IEWebGameCtrl
|
||||
{
|
||||
[default] interface IIEWebGameCtrl;
|
||||
};
|
||||
};
|
||||
135
Templates/Full/web/source/activex/IEWebGamePlugin.rc
Normal file
135
Templates/Full/web/source/activex/IEWebGamePlugin.rc
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
#include "targetver.h"
|
||||
#endif
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#ifndef APSTUDIO_INVOKED\r\n"
|
||||
"#include ""targetver.h""\r\n"
|
||||
"#endif\r\n"
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"1 TYPELIB ""IEWebGamePlugin.tlb""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "PluginType", "ActiveX"
|
||||
VALUE "CompanyName", "My Game Company"
|
||||
VALUE "FileDescription", "ActiveX Web Game Plugin"
|
||||
VALUE "FileVersion", "1.0.0.1"
|
||||
VALUE "LegalCopyright", "(c) My Game Company. All rights reserved."
|
||||
VALUE "InternalName", "IE Full Plugin.dll"
|
||||
VALUE "OriginalFilename", "IE Full Plugin.dll"
|
||||
VALUE "ProductName", "My Web Game"
|
||||
VALUE "ProductVersion", "1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// REGISTRY
|
||||
//
|
||||
|
||||
IDR_IEWEBGAMEPLUGIN REGISTRY "IEWebGamePlugin.rgs"
|
||||
IDR_IEWEBGAMECTRL REGISTRY "IEWebGameCtrl.rgs"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDB_IEWEBGAMECTRL BITMAP "IEWebGameCtrl.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_PROJNAME "IEFullPlugin"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
1 TYPELIB "IEWebGamePlugin.tlb"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
11
Templates/Full/web/source/activex/IEWebGamePlugin.rgs
Normal file
11
Templates/Full/web/source/activex/IEWebGamePlugin.rgs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
HKCR
|
||||
{
|
||||
NoRemove AppID
|
||||
{
|
||||
'%APPID%' = s 'IEFullPlugin'
|
||||
'IEFullPlugin.DLL'
|
||||
{
|
||||
val AppID = s '%APPID%'
|
||||
}
|
||||
}
|
||||
}
|
||||
182
Templates/Full/web/source/activex/IEWebGameWindow.cpp
Normal file
182
Templates/Full/web/source/activex/IEWebGameWindow.cpp
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include <shlobj.h>
|
||||
#include "IEWebGameWindow.h"
|
||||
#include "../common/webCommon.h"
|
||||
|
||||
|
||||
// We hook the keyboard at application level so we TAB, Backspace, other accelerator combos
|
||||
// are captured and don't cause us grief
|
||||
static HHOOK hHook = NULL;
|
||||
|
||||
// Hook procedure for WH_GETMESSAGE hook type.
|
||||
LRESULT CALLBACK GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// If this is a keystrokes message, translate it in controls'
|
||||
LPMSG lpMsg = (LPMSG) lParam;
|
||||
if( (nCode >= 0) &&
|
||||
PM_REMOVE == wParam &&
|
||||
(lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST) )
|
||||
{
|
||||
if (torque_directmessage)
|
||||
{
|
||||
// call directly into the Torque 3D message queue, bypassing the windows event queue
|
||||
// as we're hooking into the application level processing, this would cause a hang
|
||||
torque_directmessage(lpMsg->message, lpMsg->wParam, lpMsg->lParam);
|
||||
|
||||
// The value returned from this hookproc is ignored, and it cannot
|
||||
// be used to tell Windows the message has been handled. To avoid
|
||||
// further processing, convert the message to WM_NULL before
|
||||
// returning.
|
||||
lpMsg->message = WM_NULL;
|
||||
lpMsg->lParam = 0L;
|
||||
lpMsg->wParam = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Passes the hook information to the next hook procedure in
|
||||
// the current hook chain.
|
||||
return ::CallNextHookEx(hHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
WebGameWindow::WebGameWindow(void)
|
||||
{
|
||||
mTimer = false;
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
WebGameWindow::~WebGameWindow(void)
|
||||
{
|
||||
//handling threads in event callbacks (onDestroy for instance) seems to cause loads of problems (deadlocks, etc)
|
||||
if (mInitialized)
|
||||
WebCommon::ShutdownTorque3D();
|
||||
}
|
||||
|
||||
// we use a timer to update the Torque 3D game loop (tick) and handle rendering
|
||||
VOID CALLBACK MyTimerProc(
|
||||
HWND hwnd, // handle to window for timer messages
|
||||
UINT message, // WM_TIMER message
|
||||
UINT idTimer, // timer identifier
|
||||
DWORD dwTime) // current system time
|
||||
{
|
||||
static bool reentrant = false;
|
||||
|
||||
if (!reentrant)
|
||||
{
|
||||
reentrant = true;
|
||||
torque_enginetick();
|
||||
reentrant = false;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT
|
||||
WebGameWindow::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
|
||||
bHandled = TRUE;
|
||||
|
||||
// check that the domain we're loading the plugin from is allowed
|
||||
if (!checkDomain())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// load up the Torque 3D shared library and initialize it
|
||||
if (!WebCommon::InitTorque3D(this->m_hWnd))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
mTimer = true;
|
||||
mInitialized = true;
|
||||
|
||||
// fire up timer for ticking Torque 3D update
|
||||
SetTimer( 1, // timer identifier
|
||||
1, // 1 millisecond
|
||||
(TIMERPROC) MyTimerProc); // timer callback
|
||||
|
||||
hHook = ::SetWindowsHookEx(
|
||||
WH_GETMESSAGE,
|
||||
GetMessageProc,
|
||||
WebCommon::gPluginModule,
|
||||
GetCurrentThreadId());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
*/
|
||||
LRESULT
|
||||
WebGameWindow::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
// let the default handler run
|
||||
bHandled = FALSE;
|
||||
|
||||
// kill update timer
|
||||
if (mTimer)
|
||||
KillTimer( 1);
|
||||
mTimer = false;
|
||||
|
||||
if (hHook)
|
||||
::UnhookWindowsHookEx (hHook);
|
||||
|
||||
hHook = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
*/
|
||||
|
||||
LRESULT
|
||||
WebGameWindow::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
// let the default handler run
|
||||
bHandled = FALSE;
|
||||
|
||||
// resize the Torque 3D child window depending on our browser's parent window
|
||||
if (mInitialized && torque_resizewindow)
|
||||
{
|
||||
int width = (int) LOWORD( lParam );
|
||||
int height = (int) HIWORD( lParam );
|
||||
torque_resizewindow(width,height);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
*/
|
||||
LRESULT
|
||||
WebGameWindow::OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
return MA_ACTIVATE;
|
||||
}
|
||||
|
||||
65
Templates/Full/web/source/activex/IEWebGameWindow.h
Normal file
65
Templates/Full/web/source/activex/IEWebGameWindow.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// "Platform" window specifics to keep IE plugin consistent with Safari/Firefox/Chrome
|
||||
|
||||
class WebGameWindow : public CWindowImpl<WebGameWindow>
|
||||
{
|
||||
public:
|
||||
WebGameWindow();
|
||||
virtual ~WebGameWindow();
|
||||
|
||||
DECLARE_WND_CLASS(_T("WebGameCtrl:WebGameWindow"))
|
||||
|
||||
BEGIN_MSG_MAP(WebGameWindow)
|
||||
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
|
||||
MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate);
|
||||
MESSAGE_HANDLER(WM_SIZE, OnSize);
|
||||
END_MSG_MAP()
|
||||
|
||||
public:
|
||||
|
||||
// message handlers (all window based)
|
||||
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
|
||||
protected:
|
||||
|
||||
// // checks a given domain against the allowed domains in webConfig.h (defined in IEWebGamePlugin)
|
||||
virtual bool checkDomain() = 0;
|
||||
|
||||
private:
|
||||
|
||||
bool mTimer;
|
||||
bool mInitialized;
|
||||
|
||||
};
|
||||
|
||||
38
Templates/Full/web/source/activex/dllmain.cpp
Normal file
38
Templates/Full/web/source/activex/dllmain.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// dllmain.cpp : Implementation of DllMain.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "resource.h"
|
||||
#include "IEWebGamePlugin_i.h"
|
||||
#include "dllmain.h"
|
||||
#include "../common/webCommon.h"
|
||||
|
||||
CIEWebGamePluginModule _AtlModule;
|
||||
|
||||
// DLL Entry Point
|
||||
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
WebCommon::gPluginModule = (HMODULE) hInstance;
|
||||
return _AtlModule.DllMain(dwReason, lpReserved);
|
||||
}
|
||||
32
Templates/Full/web/source/activex/dllmain.h
Normal file
32
Templates/Full/web/source/activex/dllmain.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// dllmain.h : Declaration of module class.
|
||||
|
||||
class CIEWebGamePluginModule : public CAtlDllModuleT< CIEWebGamePluginModule >
|
||||
{
|
||||
public :
|
||||
DECLARE_LIBID(LIBID_IEFullPluginLib)
|
||||
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_IEWEBGAMEPLUGIN, "{AB7615A3-A918-488B-B128-96DD62D0AE36}")
|
||||
};
|
||||
|
||||
extern class CIEWebGamePluginModule _AtlModule;
|
||||
19
Templates/Full/web/source/activex/resource.h
Normal file
19
Templates/Full/web/source/activex/resource.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by IEWebGamePlugin.rc
|
||||
//
|
||||
#define IDS_PROJNAME 100
|
||||
#define IDR_IEWEBGAMEPLUGIN 101
|
||||
#define IDB_IEWEBGAMECTRL 102
|
||||
#define IDR_IEWEBGAMECTRL 103
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 201
|
||||
#define _APS_NEXT_COMMAND_VALUE 32768
|
||||
#define _APS_NEXT_CONTROL_VALUE 201
|
||||
#define _APS_NEXT_SYMED_VALUE 104
|
||||
#endif
|
||||
#endif
|
||||
27
Templates/Full/web/source/activex/stdafx.cpp
Normal file
27
Templates/Full/web/source/activex/stdafx.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// IEWebGamePlugin.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
45
Templates/Full/web/source/activex/stdafx.h
Normal file
45
Templates/Full/web/source/activex/stdafx.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently,
|
||||
// but are changed infrequently
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef STRICT
|
||||
#define STRICT
|
||||
#endif
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define _ATL_APARTMENT_THREADED
|
||||
#define _ATL_NO_AUTOMATIC_NAMESPACE
|
||||
|
||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
|
||||
|
||||
#include "resource.h"
|
||||
#include <atlbase.h>
|
||||
#include <atlcom.h>
|
||||
#include <atlctl.h>
|
||||
|
||||
using namespace ATL;
|
||||
47
Templates/Full/web/source/activex/targetver.h
Normal file
47
Templates/Full/web/source/activex/targetver.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
// The following macros define the minimum required platform. The minimum required platform
|
||||
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
|
||||
// your application. The macros work by enabling all features available on platform versions up to and
|
||||
// including the version specified.
|
||||
|
||||
// Modify the following defines if you have to target a platform prior to the ones specified below.
|
||||
// Refer to MSDN for the latest info on corresponding values for different platforms.
|
||||
#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
|
||||
#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
|
||||
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
|
||||
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
|
||||
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
|
||||
#endif
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue