Browse Source

Merge pull request #840 from JimMarlowe/JM-LINUX-EDITOR

Jm linux editor
JoshEngebretson 9 years ago
parent
commit
43e5274463

+ 2 - 0
AUTHORS.md

@@ -31,6 +31,8 @@
 
 - Johnny Wahib (https://github.com/JohnnyWahib)
 
+- JimMarlowe (https://github.com/JimMarlowe)
+
 ### Contribution Copyright and Licensing
 
 Atomic Game Engine contribution copyrights are held by their authors.  Each author retains the copyright to their contribution and agrees to irrevocably license the contribution under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md`.  Please see `CONTRIBUTING.md` for more details.

+ 6 - 1
Attic/AtomicEditorReference/Source/UI/Modal/UIBuildSettingsAndroid.cpp

@@ -146,7 +146,8 @@ void UIBuildSettingsAndroid::RefreshAndroidTargets()
 #ifdef ATOMIC_PLATFORM_OSX
     Vector<String> args = String("list targets").Split(' ');
     androidCommand += "tools/android";
-#else
+#endif
+#ifdef ATOMIC_PLATFORM_WINDOWS
     Vector<String> args;
     // android is a batch file on windows, so have to run with cmd /c
     args.Push("/c");
@@ -155,6 +156,10 @@ void UIBuildSettingsAndroid::RefreshAndroidTargets()
     args.Push("targets");
     androidCommand = "cmd";
 #endif
+#ifdef ATOMIC_PLATFORM_LINUX
+    Vector<String> args = String("list targets").Split(' ');
+    androidCommand += "tools/android";
+#endif
 
     targetOutput_.Clear();
     targetLookup_.Clear();

+ 18 - 0
Build/Scripts/BuildLinux.js

@@ -65,6 +65,24 @@ task('atomiceditor', {
       fs.copySync(atomicRoot + "Submodules/CEF/Linux/Release/snapshot_blob.bin",
         editorAppFolder+"/snapshot_blob.bin");
 
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/locales", editorAppFolder+"/locales");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/cef.pak", editorAppFolder+"/cef.pak");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/cef_100_percent.pak", editorAppFolder+"/cef_100_percent.pak");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/cef_200_percent.pak", editorAppFolder+"/cef_200_percent.pak");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/cef_extensions.pak", editorAppFolder+"/cef_extensions.pak");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/devtools_resources.pak", editorAppFolder+"/devtools_resources.pak");
+
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/icudtl.dat",  atomicRoot +"/Artifacts/Build/Linux/Source/AtomicEditor/icudtl.dat");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Release/natives_blob.bin", atomicRoot +"/Artifacts/Build/Linux/Source/AtomicEditor/natives_blob.bin");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Release/snapshot_blob.bin", atomicRoot +"/Artifacts/Build/Linux/Source/AtomicEditor/snapshot_blob.bin");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/locales", atomicRoot +"/Artifacts/Build/Linux/Source/AtomicEditor/locales");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/cef.pak", atomicRoot +"/Artifacts/Build/Linux/Source/AtomicEditor/cef.pak");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/cef_100_percent.pak", atomicRoot +"/Artifacts/Build/Linux/Source/AtomicEditor/cef_100_percent.pak");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/cef_200_percent.pak", atomicRoot +"/Artifacts/Build/Linux/Source/AtomicEditor/cef_200_percent.pak");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/cef_extensions.pak", atomicRoot +"/Artifacts/Build/Linux/Source/AtomicEditor/cef_extensions.pak");
+      fs.copySync(atomicRoot + "Submodules/CEF/Linux/Resources/devtools_resources.pak", atomicRoot +"/Artifacts/Build/Linux/Source/AtomicEditor/devtools_resources.pak");
+
+
     console.log("\n\nAtomic Editor build to " + editorAppFolder + "\n\n");
 
     complete();

+ 14 - 1
Source/AtomicWebView/WebBrowserHost.cpp

@@ -52,17 +52,30 @@
 
 static int XErrorHandlerImpl(Display *display, XErrorEvent *event)
 {
+    if ( display && event )
+    {
+        char msg[132];
+        XGetErrorText(display, event->error_code, msg, sizeof(msg));
+        fprintf(stderr, "X11 Error %d (%s): request %d.%d \n",
+                        event->error_code, 
+                        msg, 
+                        event->request_code,
+                        event->minor_code );
+    }
     return 0;
 }
 
 static int XIOErrorHandlerImpl(Display *display)
 {
+    if ( display )
+      fprintf(stderr, "XIO Error on display %p, quitting.\n", (void*)display );
     return 0;
 }
 
 static void TerminationSignalHandler(int signatl)
 {
-
+    fprintf(stderr,"Received signal %d, quitting.\n", signatl );
+    exit(0);
 }
 
 #endif

+ 11 - 0
Source/AtomicWebView/WebClient.cpp

@@ -368,6 +368,10 @@ public:
 
 #ifdef ATOMIC_PLATFORM_WINDOWS
                 windowInfo.SetAsWindowless(info.info.win.window, /*transparent*/ true);
+#endif
+#ifdef ATOMIC_PLATFORM_LINUX
+                if ( info.subsystem == SDL_SYSWM_X11 )
+                    windowInfo.SetAsWindowless(info.info.x11.window, true);
 #endif
             }
 
@@ -683,6 +687,13 @@ void WebClient::SendKeyEvent(const StringHash eventType, VariantMap& eventData)
     host->SendKeyEvent(keyEvent);
 #endif
 
+#ifdef ATOMIC_PLATFORM_LINUX
+    if ( keyEvent.character == 0xD && keyEvent.type == KEYEVENT_KEYUP) 
+    {
+        keyEvent.type = KEYEVENT_CHAR;
+        host->SendKeyEvent(keyEvent);
+    }
+#endif
 
 }
 

+ 34 - 1
Source/AtomicWebView/WebKeyboardLinux.cpp

@@ -36,11 +36,44 @@ namespace Atomic
 
 bool ConvertKeyEvent(Input* input, const StringHash eventType, VariantMap& eventData, CefKeyEvent& keyEvent)
 {
-    return false;
+    memset((void*)&keyEvent, 0, sizeof(keyEvent));
+    
+    WebKeyEvent wk(eventType, eventData); 
+
+    keyEvent.type = wk.keyDown ? KEYEVENT_KEYDOWN : KEYEVENT_KEYUP;
+    keyEvent.is_system_key = false;
+    keyEvent.windows_key_code = 0;
+    keyEvent.focus_on_editable_field = false;
+    keyEvent.modifiers = EVENTFLAG_NONE;
+    if (wk.qual & QUAL_SHIFT) keyEvent.modifiers |= EVENTFLAG_SHIFT_DOWN;
+    if (wk.qual & QUAL_ALT) keyEvent.modifiers |= EVENTFLAG_ALT_DOWN;
+    if (wk.qual & QUAL_CTRL) keyEvent.modifiers |= EVENTFLAG_CONTROL_DOWN;
+    
+    keyEvent.native_key_code = wk.scanCode;
+    keyEvent.character = wk.key;
+    keyEvent.unmodified_character = wk.raw;
+
+    return true;
 }
 
 bool ConvertTextInputEvent(StringHash eventType, VariantMap& eventData, CefKeyEvent& keyEvent)
 {
+   if (eventType != "TextInput")
+    {
+        LOGERROR("ConvertTextInputEvent - Unknown event type");
+        return false;
+    }
+
+    memset((void*)&keyEvent, 0, sizeof(keyEvent));
+
+    String text = eventData[TextInput::P_TEXT].GetString();
+ 
+    if ( text.Length() > 0)
+    {
+        keyEvent.character = (char16)text[0];
+        keyEvent.type = KEYEVENT_CHAR;
+        return true; 
+    }
     return false;
 }
 

+ 48 - 2
Source/ThirdParty/nativefiledialog/nfd_gtk.c

@@ -13,7 +13,8 @@
 
 
 const char INIT_FAIL_MSG[] = "gtk_init_check failed to initilaize GTK+";
-
+const char NOPATH_MSG[] = "The selected path is out of memory.";
+const char NOMEM_MSG[] = "Out of memory.";
 
 static void AddTypeToFilterName( const char *typebuf, char *filterName, size_t bufsize )
 {
@@ -121,6 +122,7 @@ static nfdresult_t AllocPathSet( GSList *fileList, nfdpathset_t *pathSet )
     pathSet->indices = NFDi_Malloc( sizeof(size_t)*pathSet->count );
     if ( !pathSet->indices )
     {
+        NFDi_SetError(NOMEM_MSG);
         return NFD_ERROR;
     }
 
@@ -206,6 +208,7 @@ nfdresult_t NFD_OpenDialog( const char *filterList,
             {
                 g_free( filename );
                 gtk_widget_destroy(dialog);
+                NFDi_SetError(NOPATH_MSG);
                 return NFD_ERROR;
             }
         }
@@ -256,6 +259,7 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList,
         if ( AllocPathSet( fileList, outPaths ) == NFD_ERROR )
         {
             gtk_widget_destroy(dialog);
+            NFDi_SetError(NOPATH_MSG);
             return NFD_ERROR;
         }
 
@@ -292,6 +296,7 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList,
 
     /* Build the filter list */
     AddFiltersToDialog(dialog, filterList);
+    SetDefaultPath(dialog, defaultPath);
 
     result = NFD_CANCEL;
     if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
@@ -307,6 +312,7 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList,
             {
                 g_free( filename );
                 gtk_widget_destroy(dialog);
+                NFDi_SetError(NOPATH_MSG);
                 return NFD_ERROR;
             }
         }
@@ -326,7 +332,47 @@ nfdresult_t NFD_ChooseDirectory( const nfdchar_t *prompt,
                                  const nfdchar_t *defaultPath,
                                  nfdchar_t **outPath )
 {
+    GtkWidget *dialog = NULL;
+    nfdresult_t result = NFD_ERROR;
+
+    if ( !gtk_init_check( NULL, NULL ) )
+    {
+        NFDi_SetError(INIT_FAIL_MSG);
+        return NFD_ERROR;
+    }
+    dialog = gtk_file_chooser_dialog_new( prompt,
+                                          NULL,
+                                          GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+                                          "_Cancel", GTK_RESPONSE_CANCEL,
+                                          "_Open", GTK_RESPONSE_ACCEPT,
+                                          NULL );
+
+    SetDefaultPath(dialog, defaultPath);
+
+    result = NFD_CANCEL;
+    if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
+    {
+        char *filename = NULL;
+        filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog) );
+        {
+            size_t len = strlen(filename);
+            *outPath = NFDi_Malloc( len + 1 );
+            memcpy( *outPath, filename, len + 1 );
+            if ( !*outPath )
+            {
+                g_free( filename );
+                gtk_widget_destroy(dialog);
+                NFDi_SetError(NOPATH_MSG);
+                return NFD_ERROR;
+            }
+        }
+        g_free(filename);
+        result = NFD_OKAY;
+    }
+
+    gtk_widget_destroy(dialog);
 
-  return NFD_ERROR;
+    WaitForCleanup();
 
+    return result;        
 }

+ 21 - 1
Source/ToolCore/Build/BuildAndroid.cpp

@@ -249,7 +249,8 @@ void BuildAndroid::RunAntDebug()
     String antCommand = tprefs->GetAntPath();
     Vector<String> args;
     args.Push("debug");
-#else
+#endif
+#ifdef ATOMIC_PLATFORM_WINDOWS
     // C:\ProgramData\Oracle\Java\javapath;
     Vector<String> args;
     String antCommand = "cmd";
@@ -260,6 +261,25 @@ void BuildAndroid::RunAntDebug()
     args.Push("\"" + antPath + "\"");
     args.Push("debug");
 #endif
+#ifdef ATOMIC_PLATFORM_LINUX 
+
+    String antCommand = tprefs->GetAntPath();
+    if ( antCommand.Empty() ) // user didnt fill it out, use installed one
+    {
+        antCommand = "/usr/bin/ant"; // system default if installed
+    }
+    else
+    {
+        antCommand.Append("/ant"); 
+    }
+    FileSystem* fileSystem = GetSubsystem<FileSystem>();
+    if ( !fileSystem->FileExists ( antCommand) ) 
+    {
+        FailBuild("BuildFailed ant program not installed");
+    }
+    Vector<String> args;
+    args.Push("debug");
+#endif
 
     currentBuildPhase_ = AntBuildDebug;
     Subprocess* subprocess = subs->Launch(antCommand, args, buildPath_, env);

+ 10 - 3
Source/ToolCore/Platform/PlatformAndroid.cpp

@@ -141,9 +141,13 @@ String PlatformAndroid::GetADBCommand() const
 
 #ifdef ATOMIC_PLATFORM_OSX
     adbCommand += "/platform-tools/adb";
-#else
+#endif
+#ifdef ATOMIC_PLATFORM_WINDOWS
     adbCommand += "/platform-tools/adb.exe";
 #endif
+#ifdef ATOMIC_PLATFORM_LINUX
+    adbCommand += "/platform-tools/adb";
+#endif
 
     return adbCommand;
 
@@ -161,14 +165,17 @@ String PlatformAndroid::GetAndroidCommand() const
 #ifdef ATOMIC_PLATFORM_OSX
     //Vector<String> args = String("list targets").Split(' ');
     androidCommand += "/tools/android";
-#else
+#endif
+#ifdef ATOMIC_PLATFORM_WINDOWS
 
     // android is a batch file on windows, so have to run with cmd /c
     androidCommand += "\\tools\\android.bat";
 
     //androidCommand = "cmd";
 #endif
-
+#ifdef ATOMIC_PLATFORM_LINUX
+    androidCommand += "/tools/android";
+#endif
     return androidCommand;
 
 }