|
|
@@ -3,7 +3,11 @@
|
|
|
#include <Atomic/IO/Log.h>
|
|
|
#include <Atomic/Input/InputEvents.h>
|
|
|
#include <Atomic/Core/ProcessUtils.h>
|
|
|
+#include <Atomic/Graphics/GraphicsEvents.h>
|
|
|
+#include <Atomic/Graphics/Camera.h>
|
|
|
#include <Atomic/UI/SystemUI/DebugHud.h>
|
|
|
+#include <Atomic/UI/SystemUI/SystemUIEvents.h>
|
|
|
+#include <Atomic/UI/UI.h>
|
|
|
#include <Atomic/IPC/IPCEvents.h>
|
|
|
#include <Atomic/IPC/IPCWorker.h>
|
|
|
|
|
|
@@ -19,7 +23,8 @@ namespace AtomicEditor
|
|
|
PlayerMode::PlayerMode(Context* context) :
|
|
|
Object(context),
|
|
|
brokerActive_(false),
|
|
|
- launchedByEditor_(false)
|
|
|
+ launchedByEditor_(false),
|
|
|
+ licenseModule3D_(false)
|
|
|
{
|
|
|
fd_[0] = INVALID_IPCHANDLE_VALUE;
|
|
|
fd_[1] = INVALID_IPCHANDLE_VALUE;
|
|
|
@@ -28,6 +33,10 @@ PlayerMode::PlayerMode(Context* context) :
|
|
|
|
|
|
SubscribeToEvent(E_LOGMESSAGE, HANDLER(PlayerMode, HandleLogMessage));
|
|
|
SubscribeToEvent(E_JSERROR, HANDLER(PlayerMode, HandleJSError));
|
|
|
+
|
|
|
+ // BEGIN LICENSE MANAGEMENT
|
|
|
+ SubscribeToEvent(E_BEGINVIEWRENDER, HANDLER(PlayerMode, HandleViewRender));
|
|
|
+ // END LICENSE MANAGEMENT
|
|
|
}
|
|
|
|
|
|
PlayerMode::~PlayerMode()
|
|
|
@@ -46,6 +55,12 @@ void PlayerMode::HandleIPCInitialize(StringHash eventType, VariantMap& eventData
|
|
|
SendEvent(E_EXITREQUESTED);
|
|
|
}
|
|
|
|
|
|
+ // BEGIN LICENSE MANAGEMENT
|
|
|
+
|
|
|
+ licenseModule3D_ = eventData["license3D"].GetBool();
|
|
|
+
|
|
|
+ // END LICENSE MANAGEMENT
|
|
|
+
|
|
|
SystemUI::DebugHud* debugHud = GetSubsystem<SystemUI::DebugHud>();
|
|
|
if (debugHud)
|
|
|
debugHud->SetMode(eventData["debugHudMode"].GetUInt());
|
|
|
@@ -70,7 +85,7 @@ void PlayerMode::ProcessArguments() {
|
|
|
Vector<String> idc = argument.Split(argument.CString(), '=');
|
|
|
if (idc.Size() == 2)
|
|
|
|
|
|
- id = ToInt(idc[1].CString());
|
|
|
+ id = ToInt(idc[1].CString());
|
|
|
}
|
|
|
|
|
|
else if (argument.StartsWith("--ipc-server=") || argument.StartsWith("--ipc-client="))
|
|
|
@@ -84,7 +99,7 @@ void PlayerMode::ProcessArguments() {
|
|
|
if (argument.StartsWith("--ipc-server="))
|
|
|
{
|
|
|
#ifdef ATOMIC_PLATFORM_WINDOWS
|
|
|
- // clientRead
|
|
|
+ // clientRead
|
|
|
WString wipc(ipc[1]);
|
|
|
HANDLE pipe = reinterpret_cast<HANDLE>(_wtoi64(wipc.CString()));
|
|
|
fd_[0] = pipe;
|
|
|
@@ -96,7 +111,7 @@ void PlayerMode::ProcessArguments() {
|
|
|
else
|
|
|
{
|
|
|
#ifdef ATOMIC_PLATFORM_WINDOWS
|
|
|
- // clientWrite
|
|
|
+ // clientWrite
|
|
|
WString wipc(ipc[1]);
|
|
|
HANDLE pipe = reinterpret_cast<HANDLE>(_wtoi64(wipc.CString()));
|
|
|
fd_[1] = pipe;
|
|
|
@@ -114,7 +129,7 @@ void PlayerMode::ProcessArguments() {
|
|
|
}
|
|
|
|
|
|
if (id > 0 && fd_[0] != INVALID_IPCHANDLE_VALUE && fd_[1] != INVALID_IPCHANDLE_VALUE)
|
|
|
- {
|
|
|
+ {
|
|
|
launchedByEditor_ = true;
|
|
|
SubscribeToEvent(E_IPCINITIALIZE, HANDLER(PlayerMode, HandleIPCInitialize));
|
|
|
ipc_->InitWorker((unsigned) id, fd_[0], fd_[1]);
|
|
|
@@ -168,5 +183,47 @@ void PlayerMode::HandleLogMessage(StringHash eventType, VariantMap& eventData)
|
|
|
|
|
|
}
|
|
|
|
|
|
+void PlayerMode::HandleMessageAck(StringHash eventType, VariantMap& eventData)
|
|
|
+{
|
|
|
+ messageBox_ = 0;
|
|
|
+ GetSubsystem<UI>()->RequestExit();
|
|
|
+}
|
|
|
+
|
|
|
+void PlayerMode::HandleViewRender(StringHash eventType, VariantMap& eventData)
|
|
|
+{
|
|
|
+// BEGIN LICENSE MANAGEMENT
|
|
|
+ static bool done = false;
|
|
|
+
|
|
|
+ if (licenseModule3D_)
|
|
|
+ return;
|
|
|
+
|
|
|
+ Camera* camera = static_cast<Camera*>(eventData[BeginViewRender::P_CAMERA].GetPtr());
|
|
|
+
|
|
|
+ if (!camera || camera->IsOrthographic())
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (!done) {
|
|
|
+
|
|
|
+ done = true;
|
|
|
+
|
|
|
+ messageBox_ = GetSubsystem<UI>()->ShowSystemMessageBox("3D Module License Required", "A 3D Module License is required to display 3D content.\n\nUpgrade to Atomic Pro for all features and platforms.");
|
|
|
+ SubscribeToEvent(messageBox_, SystemUI::E_MESSAGEACK, HANDLER(PlayerMode, HandleMessageAck));
|
|
|
+
|
|
|
+ if (brokerActive_)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (ipc_.Null())
|
|
|
+ return;
|
|
|
+
|
|
|
+ VariantMap msgEvent;
|
|
|
+ msgEvent[IPCMessage::P_MESSAGE] = String("3D Module License Required");
|
|
|
+ ipc_->SendEventToBroker(E_IPCMESSAGE, msgEvent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// END LICENSE MANAGEMENT
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
}
|