Browse Source

Adding player mode identification (and attached debugger query for Windows)

Josh Engebretson 8 years ago
parent
commit
c97c87526a

+ 12 - 0
Source/AtomicApp/AppBase.cpp

@@ -232,4 +232,16 @@ namespace Atomic
 
     }
 
+    bool AppBase::GetDebuggerAttached()
+    {
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+        return IsDebuggerPresent() ? true : false;
+#else
+        return false;
+#endif
+
+
+    }
+
 }

+ 3 - 0
Source/AtomicApp/AppBase.h

@@ -57,6 +57,9 @@ namespace Atomic
 
         static void AddEngineConfigSearchPath(const String& path) { engineConfigSearchPaths_.Push(path); }
 
+        /// Returns whether a debugger is attached to the process
+        static bool GetDebuggerAttached();
+
     protected:
 
         void ReadEngineConfig();

+ 2 - 0
Source/AtomicApp/Player/PlayerApp.cpp

@@ -42,6 +42,8 @@ namespace AtomicPlayer
 namespace Atomic
 {
 
+    PlayerLaunchMode PlayerApp::launchMode_ = PLAYER_LAUNCH_STANDALONE;
+
     PlayerApp::PlayerApp(Context* context) :
         AppBase(context),
         executeJSMain_(true),

+ 18 - 0
Source/AtomicApp/Player/PlayerApp.h

@@ -26,6 +26,16 @@
 
 namespace Atomic
 {
+    /// Player launch mode
+    enum PlayerLaunchMode
+    {
+        /// Standalone redistributable player
+        PLAYER_LAUNCH_STANDALONE = 0,
+        /// Editor binary play mode
+        PLAYER_LAUNCH_ATOMICEDITOR,
+        /// Launched from an external IDE such as Visual Studio
+        PLAYER_LAUNCH_EXTERNALEDITOR
+    };
 
     class PlayerApp : public AppBase
     {
@@ -45,8 +55,16 @@ namespace Atomic
 
         virtual void ProcessArguments();
 
+        /// Get the player launch mode
+        static PlayerLaunchMode GetLaunchMode() { return launchMode_; }
+
     protected:
 
+        /// Set the player launch mode
+        static void SetLaunchMode(PlayerLaunchMode launchMode) { launchMode_ = launchMode; }
+
+        static PlayerLaunchMode launchMode_;
+
         bool executeJSMain_;
 
     private:

+ 4 - 1
Source/AtomicEditor/Application/AEPlayerApp.cpp

@@ -35,7 +35,6 @@ namespace AtomicEditor
     AEPlayerApplication::AEPlayerApplication(Context* context) :
         IPCPlayerApp(context)
     {
-
     }
 
     AEPlayerApplication::~AEPlayerApplication()
@@ -54,6 +53,10 @@ namespace AtomicEditor
         JSVM::RegisterPackage(jsapi_init_webview, engineParameters_);
 #endif
 
+        StringVector args = GetArguments();
+
+        // Set whether we're launched from the Atomic Editor or from an external tool
+        SetLaunchMode(args.Contains("--atomiceditor") ? PLAYER_LAUNCH_ATOMICEDITOR : PLAYER_LAUNCH_EXTERNALEDITOR);
     }
 
     void AEPlayerApplication::Start()

+ 1 - 1
Source/AtomicEditor/EditorMode/AEEditorMode.cpp

@@ -240,7 +240,7 @@ bool EditorMode::PlayProjectInternal(const String &addArgs, bool debug)
 
     Vector<String> vargs;
 
-    String args = ToString("--player --project \"%s\"", AddTrailingSlash(project->GetProjectPath()).CString());
+    String args = ToString("--atomiceditor --player --project \"%s\"", AddTrailingSlash(project->GetProjectPath()).CString());
 
     vargs = args.Split(' ');
 

+ 5 - 0
Source/AtomicNET/NETNative/Desktop/NETIPCPlayerApp.cpp

@@ -58,6 +58,11 @@ namespace Atomic
             engineParameters_["ResourcePrefixPaths"] = "AtomicPlayer_Resources";
             engineParameters_["ResourcePaths"] = "AtomicResources";
         }
+        else
+        {
+            // Set whether we're launched from the Atomic Editor or from an external tool
+            SetLaunchMode(args.Contains("--atomiceditor") ? PLAYER_LAUNCH_ATOMICEDITOR : PLAYER_LAUNCH_EXTERNALEDITOR);
+        }
     }
 
     int NETIPCPlayerApp::Initialize()